Jump to content
  • Advertisement
Sign in to follow this  

OpenGL Correct way to draw an image

This topic is 3965 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am having a strange problem. I am developing the application with Qt, so I am using their container, but I am drawing the image with standard OpenGL function, glDrawPixels. Depending on the size of the window, sometimes there is a horizontal line through the image. At first I though it might be my logic in generating the image, but when I changed the background color, the line changed colors, too. I am guessing that I am not setting up the glDrawPixels() correct which is why it skips a line sometimes. Initially I thought the problem might be that I was rounding thing off to integers, but I have rectified that so that everything uses floats, but the problem persists. Here is what I am doing: // Setting the zoom factor glPixelZoom( zoomFactor, zoomFactor); // Set the coord of where to start drawing the image on the screen glRasterPos2f( screenViewRect.x(), screenViewRect.y()); // ??Tell OpenGL how wide the view port is on the screen?? glPixelStoref(GL_UNPACK_SKIP_PIXELS, imgViewRect.x()); // ??Tell OpenGL how tall the view port is on the screen?? glPixelStoref(GL_UNPACK_SKIP_ROWS, imgViewRect.y()); // ??Set the scan line length of the original image?? glPixelStorei(GL_UNPACK_ROW_LENGTH, pDisplayImage->width()); // Draw the image glDrawPixels(imgViewRect.width(), imgViewRect.height(), GL_RGB, GL_UNSIGNED_BYTE, pDisplayImage->GetImagePtrConst()); Is my understanding of the process to drawing the image correct? Carleton

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!