Results 1 to 12 of 12

Thread: OpenGL image viewer, need some help on implementation

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2006
    Posts
    20
    Qt products
    Qt4
    Platforms
    Windows

    Default OpenGL image viewer, need some help on implementation

    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:
    Qt Code:
    1. void GLWidget::resizeGL(int width, int height) {
    2.  
    3. glViewport( width / 2 - imageWith / 2,
    4. height / 2 - imageHeight / 2,
    5. imageWith,
    6. imageHeight );
    7. }
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. void GLWidget::paintGL()
    2. {
    3. ...........
    4.  
    5. glMatrixMode( GL_PROJECTION );
    6. glLoadIdentity();
    7. gluOrtho2D( 0, imageWith, 0, imageHeight);
    8. .................
    9. glMatrixMode( GL_MODELVIEW );
    10. glLoadIdentity();
    11. .................
    12. glBegin( GL_QUADS );
    13. glTexCoord2f( 0.0f, 0.0f );
    14. glVertex2f( offsetValues[0], offsetValues[1] );
    15.  
    16. glTexCoord2f( 1.0f, 0.0f );
    17. glVertex2f( (float)imageWith + offsetValues[0], offsetValues[1] );
    18.  
    19. glTexCoord2f( 1.0f, 1.0f );
    20. glVertex2f( (float)imageWith + offsetValues[0], (float)imageHeight + offsetValues[1] );
    21.  
    22. glTexCoord2f( 0.0f, 1.0f );
    23. glVertex2f( offsetValues[0], (float)imageHeight + offsetValues[1] );
    24.  
    25. glEnd();
    26.  
    27. }
    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
    Last edited by Randulf; 9th May 2007 at 21:56.

Similar Threads

  1. Help needed handling image data
    By toratora in forum General Programming
    Replies: 2
    Last Post: 11th May 2007, 09:24
  2. Replies: 0
    Last Post: 4th May 2007, 10:44
  3. Requirement for versatile image viewer
    By deekayt in forum General Discussion
    Replies: 1
    Last Post: 27th October 2006, 14:28
  4. How and when to repaint a widget ?
    By yellowmat in forum Newbie
    Replies: 7
    Last Post: 3rd April 2006, 16:36
  5. Image Viewer
    By sumsin in forum Qt Programming
    Replies: 3
    Last Post: 14th March 2006, 13:29

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.