PDA

View Full Version : drawing images with opengl



01-11-2001, 09:13 AM
Hi All
I have:
unsigned char* imagedata.
I also have a function(pnm.c) that reads in a greyscale pgm image and return a pointer to the beginning of data. this is stored in " imagedata".
then to display the image i use the following:

glRasterPos2i(0,0);
glPixelZoom(1.0,-1.0);
glDrawPixels(w,h,GL_LUMINANCE,GL_UNSIGNED_BYTE,(co nst uchar*)imagedata);


w,h are the width and height of the image.

but when i run the program i get a memory read error. it says memory cannot be read.

Can someone suggest me a fix to this problem???
thanx in advance.
-prasad-

coco
01-11-2001, 09:40 AM
Try using glPixelStorei(GL_UNPACK_ALIGNMENT,1).
This way OpenGL wont try to align rows to the standard 4byte boundaries.