#include #include #include #include #define WINDSIZEX 100 #define WINDSIZEY 100 void init (void) { int i; GLfloat white[] = { 1.0, 1.0, 1.0, 1.0 }; glClearColor (0.0, 0.0, 0.0, 1.0); glColor4fv (white); glDisable (GL_DITHER); } #define TEXTURE_SIZE 4 void MakeTexture (GLubyte * image) { int i; for (i = 0; i < TEXTURE_SIZE * TEXTURE_SIZE * 3; i++) { image[i] = 1; } } static void test (void) { int i; int texName; GLubyte image[TEXTURE_SIZE * TEXTURE_SIZE * 3]; GLubyte image2[TEXTURE_SIZE * TEXTURE_SIZE * 3]; glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glPixelStorei(GL_PACK_ALIGNMENT, 1); glClear (GL_COLOR_BUFFER_BIT); glColor3f (1.0, 1.0, 1.0); glGenTextures (1, &texName); glBindTexture (GL_TEXTURE_2D, texName); MakeTexture (image); glTexImage2D (GL_TEXTURE_2D, 0, GL_SRGB_EXT, TEXTURE_SIZE, TEXTURE_SIZE, 0, GL_RGB, GL_UNSIGNED_BYTE, image); glGetTexImage (GL_TEXTURE_2D, 0, GL_RGB, GL_UNSIGNED_BYTE, image2); for (i = 0; i < TEXTURE_SIZE * TEXTURE_SIZE * 3; i++) { printf ("image2[%d] = %d\n", i, image2[i]); } } void display (void) { glMatrixMode (GL_PROJECTION); glLoadIdentity (); glOrtho (-50, 50, -50, 50, 0, 2048); test (); } int main (int argc, char **argv) { glutInit (&argc, argv); glutInitDisplayMode (GLUT_SINGLE | GLUT_RGBA); glutInitWindowSize (WINDSIZEX, WINDSIZEY); glutInitWindowPosition (100, 100); glutCreateWindow (argv[0]); init (); glutDisplayFunc (display); glutMainLoop (); return 0; }