Hi i'm currently working on an application for showing HDR-images and need some tips on how to implement zooming in the application.
I have made a multi document interface with QtOpenGL widgets for displaying the images. in this widget I make a texture on a polygon the same size as the image.
Question is when zooming is it best to scale the polygon or change the viewport or gluOrtho2D? Or am I doing this all wrong?
I want the application to behave like for example photosshop so when I resize the window displaying the image the scale stays the same and in the middle of the window. Later on I also have to get the image coordinates from the mouseMove function so that I can display the raw color values of the image.
Right now it looks like this:
void GLWidget::resizeGL(int width, int height) {
glViewport( width / 2 - imageWith / 2,
height / 2 - imageHeight / 2,
imageWith,
imageHeight );
}
void GLWidget::resizeGL(int width, int height) {
glViewport( width / 2 - imageWith / 2,
height / 2 - imageHeight / 2,
imageWith,
imageHeight );
}
To copy to clipboard, switch view to plain text mode
void GLWidget::paintGL()
{
...........
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
gluOrtho2D( 0, imageWith, 0, imageHeight);
.................
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
.................
glBegin( GL_QUADS );
glTexCoord2f( 0.0f, 0.0f );
glVertex2f( offsetValues[0], offsetValues[1] );
glTexCoord2f( 1.0f, 0.0f );
glVertex2f( (float)imageWith + offsetValues[0], offsetValues[1] );
glTexCoord2f( 1.0f, 1.0f );
glVertex2f( (float)imageWith + offsetValues[0], (float)imageHeight + offsetValues[1] );
glTexCoord2f( 0.0f, 1.0f );
glVertex2f( offsetValues[0], (float)imageHeight + offsetValues[1] );
glEnd();
}
void GLWidget::paintGL()
{
...........
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
gluOrtho2D( 0, imageWith, 0, imageHeight);
.................
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
.................
glBegin( GL_QUADS );
glTexCoord2f( 0.0f, 0.0f );
glVertex2f( offsetValues[0], offsetValues[1] );
glTexCoord2f( 1.0f, 0.0f );
glVertex2f( (float)imageWith + offsetValues[0], offsetValues[1] );
glTexCoord2f( 1.0f, 1.0f );
glVertex2f( (float)imageWith + offsetValues[0], (float)imageHeight + offsetValues[1] );
glTexCoord2f( 0.0f, 1.0f );
glVertex2f( offsetValues[0], (float)imageHeight + offsetValues[1] );
glEnd();
}
To copy to clipboard, switch view to plain text mode
Is there a simple way to do this? How would you do it?
I'm quite new to qt and still have a lot to learn in the noble art of programming.
Some help would be much appriciated.
Thanks in advance.
/Nils
Bookmarks