#include <stdlib.h>
#include <GL/glut.h>
-
-#define CI_OFFSET_1 16
-#define CI_OFFSET_2 32
-
+static GLenum Target = GL_TEXTURE_2D;
+static GLenum Filter = GL_NEAREST;
GLenum doubleBuffer;
static void Init(void)
}
}
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+
+ if (Target == GL_TEXTURE_1D)
+ glTexImage1D(Target, 0, 3, SIZE, 0, GL_RGB, GL_UNSIGNED_BYTE, tex2d);
+ else
+ glTexImage2D(Target, 0, 3, SIZE, SIZE, 0,
+ GL_RGB, GL_UNSIGNED_BYTE, tex2d);
+
+ glEnable(Target);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_REPEAT);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameterf(Target, GL_TEXTURE_WRAP_R, GL_REPEAT);
+ glTexParameterf(Target, GL_TEXTURE_MIN_FILTER, Filter);
+ glTexParameterf(Target, GL_TEXTURE_MAG_FILTER, Filter);
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- glTexImage2D(GL_TEXTURE_2D, 0, 3, SIZE, SIZE, 0,
- GL_RGB, GL_UNSIGNED_BYTE, tex2d);
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
- glEnable(GL_TEXTURE_2D);
}
-
}
static void Reshape(int width, int height)
{
-
- glViewport(0, 0, (GLint)width, (GLint)height);
-
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
- glMatrixMode(GL_MODELVIEW);
+ glViewport(0, 0, (GLint)width, (GLint)height);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode(GL_MODELVIEW);
}
static void Key(unsigned char key, int x, int y)
{
-
- switch (key) {
- case 27:
- exit(1);
- default:
- return;
- }
-
- glutPostRedisplay();
+ switch (key) {
+ case 27:
+ exit(0);
+ default:
+ return;
+ }
+ glutPostRedisplay();
}
static void Draw(void)
glutKeyboardFunc(Key);
glutDisplayFunc(Draw);
glutMainLoop();
- return 0;
+ return 0;
}