Results 1 to 4 of 4

Thread: glDrawPixels issue

  1. #1
    Join Date
    Jul 2007
    Location
    California, USA
    Posts
    62
    Thanks
    17
    Thanked 7 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question glDrawPixels issue

    I am developing an app with OpenGL. Here is my hierarchy:

    GLImage(my own object) which is a GLDisplay object (also my own object) which is a QGLWidget.
    I have written the paintGL() method in GLImage and intializeGL and resizeGL in the GLDisplay
    class.

    I have CameraImage class (my own object) that is inherited from another class (my own - DisplayMdiWindow) that inherits from QMdiSubWindow.

    In the CameraImage class, I set the GLImage instance as the widget of the window using setWidget();

    What I want to do is to display an image in the GLImage class. In paintGL(), I have:
    Qt Code:
    1. glRasterPos(0,0); // the x,y to start drawing at
    2. glDrawPixels(imageWidth, imageHeight, GL_LUMINANCE, GL_UNSIGNED_BYTE, buffer);
    To copy to clipboard, switch view to plain text mode 

    I believe that, for C++, drawing the pixels starts at (0,0) in the left hand corner and then draws the width and height that I specify.

    What I have noticed is that while the bottom left is 0 for the x-coordinate, 0 does not appear to work for the
    y-coordinate because I don't see anything. I've tried values like 10, 20, etc for the y_coordinate and doing so
    moves the image up a little but depending on the size of the CameraImage window, the image sometimes gets cropped. I even tried to start drawing at the top left corner (0, viewport height) but that was wrong as well.

    I've looked through the forums and online to see if there is any additional information about QGLWidget and glDrawPixels but I haven't seen any.

    Is anyone trying to do something like this?

    Thanks,
    Nisha

  2. #2
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: glDrawPixels issue


  3. #3
    Join Date
    Jul 2007
    Location
    California, USA
    Posts
    62
    Thanks
    17
    Thanked 7 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: glDrawPixels issue

    Thanks for the link. I did look at that before but there is nothing specific to glDrawPixels. The examples given are for texture mapping.

    I've done this outside of Qt (inside of glut windows) but it is behaving differently here. The real issue is coming up with a way to determine consistently where I should move to (using RasterPos) to get the full image to appear in the QMdiSubWindow via the QGLWidget.

    -- Nisha

  4. #4
    Join Date
    Jul 2007
    Location
    California, USA
    Posts
    62
    Thanks
    17
    Thanked 7 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: glDrawPixels issue -- openGL mistake

    It was an openGL issue. I forgot to add a
    Qt Code:
    1. glViewport(0, 0, width, height);
    To copy to clipboard, switch view to plain text mode 
    in my resizeGL() code before:

    Qt Code:
    1. glMatrixMode(GL_PROJECTION);
    2. glLoadIdentity();
    3. glOrtho(0.0, (double)width, 0.0, (double)height, -1.0, 1.0);
    4. glMatrixMode(GL_MODELVIEW);
    To copy to clipboard, switch view to plain text mode 

    and then the drawing does start in the lower lefthand corner (0,0) as expected.

Similar Threads

  1. QMainWindow Maximization Issue
    By vishal.chauhan in forum Qt Programming
    Replies: 6
    Last Post: 15th March 2007, 14:30
  2. qt3 to qt4 - uic issue
    By hvengel in forum Qt Programming
    Replies: 10
    Last Post: 4th March 2007, 03:59
  3. Dialog and code design issue
    By Gopala Krishna in forum Qt Programming
    Replies: 1
    Last Post: 24th September 2006, 18:54
  4. Replies: 5
    Last Post: 22nd September 2006, 09:04
  5. A Design Issue...
    By nupul in forum Qt Programming
    Replies: 6
    Last Post: 4th May 2006, 18:41

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.