Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenFlipper-Free
OpenFlipper
Commits
635f2ee3
Commit
635f2ee3
authored
Mar 14, 2016
by
Alexander Dielen
Committed by
Max Lyon
Sep 23, 2016
Browse files
correct aspect ratio for snapshots
parent
728bc727
Changes
2
Hide whitespace changes
Inline
Side-by-side
widgets/glWidget/QtBaseViewer.cc
View file @
635f2ee3
...
...
@@ -388,7 +388,7 @@ void glViewer::setFOVY(double _fovy) {
updateProjectionMatrix
();
}
void
glViewer
::
updateProjectionMatrix
()
void
glViewer
::
updateProjectionMatrix
(
double
_aspect
)
{
if
(
projectionUpdateLocked_
)
return
;
...
...
@@ -397,7 +397,7 @@ void glViewer::updateProjectionMatrix()
glstate_
->
reset_projection
();
const
double
aspect
=
this
->
aspect_ratio
();
const
double
aspect
=
_aspect
?
_aspect
:
this
->
aspect_ratio
();
// In stereo mode we have to use a perspective matrix
if
(
projectionMode_
==
PERSPECTIVE_PROJECTION
)
{
...
...
@@ -542,7 +542,7 @@ void glViewer::updateGL()
//-----------------------------------------------------------------------------
void
glViewer
::
drawScene
()
void
glViewer
::
drawScene
(
double
_aspect
)
{
// Inside the glWidget rendering, the system should not send extra updates
...
...
@@ -574,7 +574,7 @@ void glViewer::drawScene()
properties_
.
setPlanes
(
nearPlane
,
farPlane
);
updateProjectionMatrix
();
updateProjectionMatrix
(
_aspect
);
// store time since last repaint in gl state and restart timer
glstate_
->
set_msSinceLastRedraw
(
redrawTime_
.
restart
());
...
...
@@ -1029,7 +1029,7 @@ void glViewer::initializeGL()
//-----------------------------------------------------------------------------
void
glViewer
::
paintGL
()
void
glViewer
::
paintGL
(
double
_aspect
)
{
if
(
!
initialized_
)
initializeGL
();
...
...
@@ -1065,7 +1065,7 @@ void glViewer::paintGL()
properties_
.
unLockUpdate
();
// draw scene
drawScene
();
drawScene
(
_aspect
);
glPopMatrix
();
...
...
@@ -2205,17 +2205,16 @@ void glViewer::snapshot(QImage& _image, int _width, int _height, bool _alpha, bo
// Get viewport data
glstate_
->
get_viewport
(
left
,
bottom
,
w
,
h
);
double
aspect
=
(
double
)
w
/
(
double
)
h
;
// Test if size is given:
if
(
_width
!=
0
||
_height
!=
0
)
{
// Adapt dimensions if aspect ratio is demanded
if
(
_width
==
0
)
{
double
aspect
=
(
double
)
w
/
(
double
)
h
;
_width
=
(
int
)((
double
)
_height
*
aspect
);
}
if
(
_height
==
0
)
{
double
aspect
=
(
double
)
w
/
(
double
)
h
;
_height
=
(
int
)((
double
)
_width
/
aspect
);
}
bak_w
=
w
;
...
...
@@ -2225,8 +2224,9 @@ void glViewer::snapshot(QImage& _image, int _width, int _height, bool _alpha, bo
// Set new viewport
glstate_
->
viewport
(
0
,
0
,
w
,
h
);
aspect
=
(
double
)
w
/
(
double
)
h
;
}
QFramebufferObjectFormat
format
;
format
.
setInternalTextureFormat
(
GL_RGBA
);
format
.
setTextureTarget
(
GL_TEXTURE_2D
);
...
...
@@ -2238,7 +2238,7 @@ void glViewer::snapshot(QImage& _image, int _width, int _height, bool _alpha, bo
format
.
setSamples
(
samples
);
makeCurrent
();
QFramebufferObject
fb
(
w
,
h
,
format
);
QFramebufferObject
fb
(
w
,
h
,
format
);
if
(
fb
.
isValid
()
){
...
...
@@ -2278,7 +2278,7 @@ void glViewer::snapshot(QImage& _image, int _width, int _height, bool _alpha, bo
ACG
::
GLState
::
lockBlendFuncSeparate
(
false
,
true
);
glEnable
(
GL_MULTISAMPLE
);
paintGL
();
paintGL
(
aspect
);
glFinish
();
ACG
::
GLState
::
unlockBlendFuncSeparate
();
...
...
@@ -2324,12 +2324,12 @@ void glViewer::snapshot(QImage& _image, int _width, int _height, bool _alpha, bo
}
if
(
_width
!=
0
||
_height
!=
0
)
{
// Reset viewport to former size
glstate_
->
viewport
(
left
,
bottom
,
bak_w
,
bak_h
);
}
glstate_
->
pop_modelview_matrix
();
glstate_
->
pop_projection_matrix
();
}
...
...
widgets/glWidget/QtBaseViewer.hh
View file @
635f2ee3
...
...
@@ -483,7 +483,7 @@ protected:
/// initialize OpenGL states
virtual
void
initializeGL
();
/// draw the scene. Triggered by updateGL().
virtual
void
paintGL
();
virtual
void
paintGL
(
double
_aspect
=
0.0
);
/// handle resize events
virtual
void
resizeEvent
(
QGraphicsSceneResizeEvent
*
_e
);
/// handle move events
...
...
@@ -515,7 +515,7 @@ protected:
/// updates projection matrix
void
updateProjectionMatrix
();
void
updateProjectionMatrix
(
double
_aspect
=
0.0
);
//------------------------------------------------------------- protected slots
...
...
@@ -545,7 +545,7 @@ private:
/* Recursively draws each node in the scene graph.
Called by paintGL(). */
void
drawScene
();
void
drawScene
(
double
_aspect
=
0.0
);
// helper called by drawScene().
void
drawScene_mono
();
/// helper function for setting the projection mode of the coordinate system node
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment