I am trying to read a .PGM/PPM file and display the image in the screen. I think I am doing everything right. I read the type of file, height,width,etc...... at the end I just get a blank screen. I don't know what I am missing......... I just started programming in OPEN GL this week so I am a novice. Here is my code

For starters, maybe grab one of the free image loading libraries (e.g. DevIL), so you can be reasonably sure you're debugging OpenGL rather than your loader.

Next you might check out the redbook examples on texturing.
http://www.opengl.org/resources/code/samples/redbook/

As always, be sure to call glGetError here and there to check for the occasional slip up.

Jose D.

01-21-2009, 08:50 AM

Hey Modus... thank your for your reply. I did look at the DevIL library and they don't support PPM/PGMs file loading. It's true. I should be debuggin OPEN GL and not the loading part of the images...... do you have any specific suggestions where I can find an example of loading an PPM/PGM image?

Brolingstanz

01-21-2009, 08:57 AM

sure? According to the docs they're supported (loading and saving).

ac_nl

01-22-2009, 08:57 AM

Add glutSwapBuffers(); to the end of the draw function

enunes

01-22-2009, 02:09 PM

Hi,

there's a little mess there. For glutSwapBuffers(), you need to be using a double buffered window. You are currently using a single buffered window, as in your glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE) call. Change GLUT_SINGLE for GLUT_DOUBLE for a double buffered window.

glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE)

In order display something, you need to update (swap) your buffer. You need to call glutSwapBuffers(). As you are not calling it nowhere in your Draw() function, it seems like you are not updating your display with anything, and thus the blank screen. You should follow ac_nl post and add glutSwapBuffers() in the end of your Draw() function so that any changes you make to your buffer are displayed.

Hope that helps.

ac_nl

01-22-2009, 06:52 PM

I missed that one, but yes, enunes is correct (although, it still works with SINGLE instead of DOUBLE).

Furthermore, I'm curious as why you first use the 'image' variable in 'glDrawPixels(windW, windH, GL_LUMINANCE, GL_UNSIGNED_BYTE, image);' for the PGM and later 'Picture' in 'glDrawPixels(windW, windH, GL_RGB, GL_UNSIGNED_BYTE, Picture);'. Why not use 'image' in both?

Also, watch out that a comment line is not always included in pgm/ppm files.