summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2009-03-01 16:53:45 -0500
committerKristian Høgsberg <krh@redhat.com>2009-03-01 16:53:45 -0500
commit21cacadbf46cf61afa94319cf1607d650a493be7 (patch)
treeb81a51fe14093cae5f7b240c0a6e51ae64293a30
parentf31da5248dcffc2493e68f8a6157c217c3377e54 (diff)
Update texture test to be useful for verifying color components.
-rw-r--r--test/setup.c4
-rw-r--r--test/texture.c32
2 files changed, 26 insertions, 10 deletions
diff --git a/test/setup.c b/test/setup.c
index 55d1688..7c64fcd 100644
--- a/test/setup.c
+++ b/test/setup.c
@@ -36,6 +36,10 @@ static void run(struct state *state, render_func_t render)
static const EGLint config_attribs[] = {
EGL_DEPTH_SIZE, 24,
+ EGL_RED_SIZE, 8,
+ EGL_GREEN_SIZE, 8,
+ EGL_BLUE_SIZE, 8,
+ EGL_BUFFER_SIZE, 32,
EGL_CONFIG_CAVEAT, EGL_NONE,
EGL_NONE
};
diff --git a/test/texture.c b/test/texture.c
index 05f1027..7d181d5 100644
--- a/test/texture.c
+++ b/test/texture.c
@@ -35,18 +35,25 @@
static int render(struct state *state)
{
GLfloat vertices[12];
- GLfloat tex_coords[12] = { 1, 0, 1, 1, 0, 0.5 };
+ GLfloat tex_coords[8] = { 1, 0, 1, 1, 0, 1, 0, 0 };
GLuint indices[4] = { 0, 1, 2, 3 };
uint32_t texture[128 * 128];
- int i;
+ GLuint colors[] = {
+ 0x00000000, 0x00110000, 0x00001100, 0x00000011,
+ 0x00001111, 0x00110011, 0x00111100, 0x00111111
+ };
+
+ int i, row, column;
for (i = 0; i < 128 * 128; i++) {
- texture[i] =
- (i >> 12) * 0x05103203 +
- ((i >> 5) & 0x03) * 0x20100f28;
+ row = (i >> 11) & 0x07;
+ column = ((i >> 3) & 0x0e) + 1;
+ texture[i] = colors[row] * column;
}
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, 128);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 128, 128, 0,
- GL_BGRA, GL_UNSIGNED_BYTE, texture);
+ GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, texture);
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
@@ -60,9 +67,10 @@ static int render(struct state *state)
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
+ glClearColor(0, 0.1, 0.1, 0.1);
glClear(GL_COLOR_BUFFER_BIT);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND);
+ //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ //glEnable(GL_BLEND);
vertices[0] = 0.9;
vertices[1] = -0.9;
@@ -73,14 +81,18 @@ static int render(struct state *state)
vertices[5] = 0;
vertices[6] = -0.9;
- vertices[7] = 0;
+ vertices[7] = 0.9;
vertices[8] = 0;
+ vertices[9] = -0.9;
+ vertices[10] = -0.9;
+ vertices[11] = 0;
+
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, vertices);
glTexCoordPointer(2, GL_FLOAT, 0, tex_coords);
- glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, indices);
+ glDrawElements(GL_QUADS, 4, GL_UNSIGNED_INT, indices);
glFlush();