I've been all over the internet and this website for numerous hours looking for some hint as to what is going wrong with this, to no avail. I am trying to display an ASCII .pgm file (code P2) with OpenGL and the GLUT library. The following code is only a piece of the full code, and is called by the glutDisplayFunc(). I'd greatly appreciate it if someone could tell me what it is I am doing wrong and give me a hint on how to fix it. Currently the program either crashes or displays gobbledygook, with no discernible pattern.
With all the searching and experimentation I've done over the past few days, I am fairly certain it is a problem glDrawPixels() and how I am handing the pixel array into said function.
Thanks in advance,
int height = 0;
int width = 0;
I believe PGM is 8-bit grayscale image format, therefore the data type in glDrawPixels() would be GL_UNSIGNED_BYTE instead of GL_INT.
You may have other mistakes on loading the pixmap and OpenGL codes. Please refer to the following codes. It includes a C++ PGM (P2 and P5) loader/writer class and OpenGL (GLUT) codes to draw the PGM image to the screen;