#include #include extern GLubyte* readImage(const char*, GLsizei*, GLsizei*); GLubyte *pixels; GLsizei width, height; void init(void) { int i; GLubyte colorTable[256][3]; pixels = readImage("", &width, &height); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glClearColor(0, 0, 0, 0 ); for (i = 0; i < 256; ++i) { colorTable[i][0] = 255 - i; colorTable[i][1] = 255 - i; colorTable[i][2] = 255 - i; } glColorTable(GL_COLOR_TABLE, GL_RGB, 256, GL_RGB, GL_UNSIGNED_BYTE, colorTable); glEnable(GL_COLOR_TABLE); } void display(void) { glClear(GL_COLOR_BUFFER_BIT); glRasterPos2i(1, 1); glDrawPixels(width, height, GL_RGB, GL_UNSIGNED_BYTE, pixels); glFlush(); }