My Project
Loading...
Searching...
No Matches
CViewport.h
Go to the documentation of this file.
1//==============================================================================
2/*
3 Software License Agreement (BSD License)
4 Copyright (c) 2003-2024, CHAI3D
5 (www.chai3d.org)
6
7 All rights reserved.
8
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions
11 are met:
12
13 * Redistributions of source code must retain the above copyright
14 notice, this list of conditions and the following disclaimer.
15
16 * Redistributions in binary form must reproduce the above
17 copyright notice, this list of conditions and the following
18 disclaimer in the documentation and/or other materials provided
19 with the distribution.
20
21 * Neither the name of CHAI3D nor the names of its contributors may
22 be used to endorse or promote products derived from this software
23 without specific prior written permission.
24
25 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 POSSIBILITY OF SUCH DAMAGE.
37
38 \author <http://www.chai3d.org>
39 \author Francois Conti
40 \author Dan Morris
41 \version 3.3.0
42*/
43//==============================================================================
44
45//------------------------------------------------------------------------------
46#ifndef CViewportH
47#define CViewportH
48//------------------------------------------------------------------------------
49#include "display/CCamera.h"
51#include "widgets/CViewPanel.h"
52//------------------------------------------------------------------------------
53
54//------------------------------------------------------------------------------
55namespace chai3d {
56//------------------------------------------------------------------------------
57
58//==============================================================================
65//==============================================================================
66
67//==============================================================================
78//==============================================================================
80{
81 //--------------------------------------------------------------------------
82 // CONSTRUCTOR & DESTRUCTOR:
83 //--------------------------------------------------------------------------
84
85public:
86
88 cViewport(cCamera* a_camera = nullptr, double a_contentScaleX = 1.0, double a_contentScaleY = 1.0);
89
91 virtual ~cViewport();
92
93
94 //-----------------------------------------------------------------------
95 // PUBLIC METHODS - GENERAL:
96 //-----------------------------------------------------------------------
97
98public:
99
101 cCamera* getCamera() { return (m_camera); }
102
104 void setCamera(cCamera* a_camera);
105
106
107 //-----------------------------------------------------------------------
108 // PUBLIC METHODS - MOUSE SELECTION:
109 //-----------------------------------------------------------------------
110
111public:
112
114 virtual bool selectWorld(const int a_windowPosX, const int a_windowPosY,
115 const int a_windowWidth, const int a_windowHeight,
116 cCollisionRecorder& a_collisionRecorder,
117 cCollisionSettings& a_collisionSettings);
118
120 virtual bool selectFrontLayer(const int a_windowPosX, const int a_windowPosY,
121 const int a_windowWidth, const int a_windowHeight,
122 cCollisionRecorder& a_collisionRecorder,
123 cCollisionSettings& a_collisionSettings);
124
126 virtual bool selectBackLayer(const int a_windowPosX, const int a_windowPosY,
127 const int a_windowWidth, const int a_windowHeight,
128 cCollisionRecorder& a_collisionRecorder,
129 cCollisionSettings& a_collisionSettings);
130
132 virtual bool selectLayers(const int a_windowPosX, const int a_windowPosY,
133 const int a_windowWidth, const int a_windowHeight,
134 cCollisionRecorder& a_collisionRecorder,
135 cCollisionSettings& a_collisionSettings,
136 bool a_checkFrontLayer = true,
137 bool a_checkBackLayer = true);
138
139
140 //-----------------------------------------------------------------------
141 // PUBLIC METHODS - RENDERING AND IMAGING:
142 //-----------------------------------------------------------------------
143
144public:
145
147 virtual void renderView(const int a_windowWidth,
148 const int a_windowHeight,
149 const cEyeMode a_eyeMode = C_STEREO_LEFT_EYE,
150 const bool a_defaultBuffer = true);
151
153 void copyImageBuffer(cImagePtr a_image);
154
156 int getDisplayWidth();
157
159 int getDisplayHeight();
160
162 void setContentScaleWidth(double a_contentScaleWidth = 1.0) { setContentScale(a_contentScaleWidth, m_contentScaleHeight); };
163
165 void setContentScaleHeight(double a_contentScaleHeight = 1.0) { setContentScale(m_contentScaleWidth, a_contentScaleHeight); };
166
168 void setContentScale(double a_contentScaleWidth = 1.0, double a_contentScaleHeight = 1.0);
169
172
175
177 void updateGPU();
178
179
180 //-----------------------------------------------------------------------
181 // PROTECTED MEMBERS:
182 //-----------------------------------------------------------------------
183
184protected:
185
188
191
194
197
200
203
206
209};
210
211//------------------------------------------------------------------------------
212} // namespace chai3d
213//------------------------------------------------------------------------------
214
215//------------------------------------------------------------------------------
216#endif
217//------------------------------------------------------------------------------
Implementation of a camera.
Implementation of a framebuffer.
Implements a 2D display panel associated with a framebuffer.
This class implements a virtual camera.
Definition CCamera.h:111
This class implements a collision detection recorder that stores all collision events that are report...
Definition CCollisionBasics.h:186
This class implements a base class for all 2D or 3D objects in CHAI3D.
Definition CGenericObject.h:113
This class implements a 2D display panel associated with a framebuffer.
Definition CViewPanel.h:79
This class implements a viewport.
Definition CViewport.h:80
double m_contentScaleWidth
Content scale factor along width axis.
Definition CViewport.h:193
virtual bool selectWorld(const int a_windowPosX, const int a_windowPosY, const int a_windowWidth, const int a_windowHeight, cCollisionRecorder &a_collisionRecorder, cCollisionSettings &a_collisionSettings)
This method queries whether the specified position is 'pointing at' any objects in the world.
Definition CViewport.cpp:143
cCamera * m_cameraViewport
Camera.
Definition CViewport.h:190
double getContentScaleHeight()
This method returns the content scale factor along the height axis.
Definition CViewport.h:174
cFrameBufferPtr m_displayBuffer
Display buffer.
Definition CViewport.h:202
virtual bool selectBackLayer(const int a_windowPosX, const int a_windowPosY, const int a_windowWidth, const int a_windowHeight, cCollisionRecorder &a_collisionRecorder, cCollisionSettings &a_collisionSettings)
This method queries whether the specified position is 'pointing at' any widget on the back layer.
Definition CViewport.cpp:228
virtual void renderView(const int a_windowWidth, const int a_windowHeight, const cEyeMode a_eyeMode=C_STEREO_LEFT_EYE, const bool a_defaultBuffer=true)
This method renders the the viewport view in OpenGL.
Definition CViewport.cpp:304
void setContentScaleWidth(double a_contentScaleWidth=1.0)
This method sets the content scale factor along the width axis.
Definition CViewport.h:162
int getDisplayWidth()
This method returns the width of the current window display in pixels.
Definition CViewport.cpp:346
virtual bool selectFrontLayer(const int a_windowPosX, const int a_windowPosY, const int a_windowWidth, const int a_windowHeight, cCollisionRecorder &a_collisionRecorder, cCollisionSettings &a_collisionSettings)
This method queries whether the specified position is 'pointing at' any widget on the front layer.
Definition CViewport.cpp:182
void copyImageBuffer(cImagePtr a_image)
This method copies the output image data to an image structure.
Definition CViewport.cpp:332
cCamera * m_camera
Camera.
Definition CViewport.h:187
double m_contentScaleHeight
Content scale factor along height axis.
Definition CViewport.h:196
int getDisplayHeight()
This method returns the height of the current window display in pixels.
Definition CViewport.cpp:357
cCamera * getCamera()
This method returns a pointer to the current camera.
Definition CViewport.h:101
double m_displayWidth
Display buffer width in pixels.
Definition CViewport.h:205
void setContentScale(double a_contentScaleWidth=1.0, double a_contentScaleHeight=1.0)
This method sets the content scale factors along the width and height axes.
Definition CViewport.cpp:121
double m_displayHeight
Display buffer height in pixels.
Definition CViewport.h:208
double getContentScaleWidth()
This method returns the content scale factor along the width axis.
Definition CViewport.h:171
void updateGPU()
This method resets textures and display lists for the world associated with this camera.
Definition CViewport.cpp:368
virtual bool selectLayers(const int a_windowPosX, const int a_windowPosY, const int a_windowWidth, const int a_windowHeight, cCollisionRecorder &a_collisionRecorder, cCollisionSettings &a_collisionSettings, bool a_checkFrontLayer=true, bool a_checkBackLayer=true)
This method queries whether the specified position is 'pointing at' any widget on selected layers.
Definition CViewport.cpp:267
void setContentScaleHeight(double a_contentScaleHeight=1.0)
This method sets the content scale factor along the height axis.
Definition CViewport.h:165
void setCamera(cCamera *a_camera)
This method sets the camera.
Definition CViewport.cpp:102
virtual ~cViewport()
Destructor of cViewport.
Definition CViewport.cpp:90
cViewPanel * m_viewPanel
View panel.
Definition CViewport.h:199
Definition CAudioBuffer.cpp:57
cEyeMode
Definition CCamera.h:74
@ C_STEREO_LEFT_EYE
Definition CCamera.h:75
std::shared_ptr< cFrameBuffer > cFrameBufferPtr
Definition CFrameBuffer.h:72
std::shared_ptr< cImage > cImagePtr
Definition CImage.h:64
This structure stores the collision settings that are passed to a collision detector when querying fo...
Definition CCollisionBasics.h:243