From df36360d0b09a9165f0e83ca058703a6fb0704a9 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sun, 21 Aug 2011 16:54:18 +0100 Subject: [PATCH] vbo-drawarrays-2101010: add bgra command line option allows to test passing GL_BGRA to glColorPointer --- src/trivial/tri-2101010.c | 2 +- src/trivial/vbo-drawarrays-2101010.c | 30 ++++++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/trivial/tri-2101010.c b/src/trivial/tri-2101010.c index 817b260e..1945b29f 100644 --- a/src/trivial/tri-2101010.c +++ b/src/trivial/tri-2101010.c @@ -78,7 +78,7 @@ static void Key(unsigned char key, int x, int y) } #define i32to10(x) ((x) >= 0 ? (x & 0x1ff) : 1024-(abs((x))& 0x1ff)) -#define i32to2(x) ((x) >= 0 ? (x & 0x1) : 3-abs((x))) +#define i32to2(x) ((x) >= 0 ? (x & 0x1) : 1-abs((x))) static unsigned iconv(int x, int y, int z, int w) { diff --git a/src/trivial/vbo-drawarrays-2101010.c b/src/trivial/vbo-drawarrays-2101010.c index 358d249d..4bac1b15 100644 --- a/src/trivial/vbo-drawarrays-2101010.c +++ b/src/trivial/vbo-drawarrays-2101010.c @@ -11,6 +11,7 @@ #include #include "glut_wrap.h" +GLboolean bgra = GL_FALSE; #define i32to10(x) ((x) >= 0 ? (x & 0x1ff) : 1024-(abs((x))& 0x1ff)) #define i32to2(x) ((x) >= 0 ? (x & 0x1) : 3-abs((x))) @@ -54,7 +55,8 @@ static void Init( void ) { GLint errno; GLuint prognum; - + int color_size = 4; + static const char *prog1 = "!!ARBvp1.0\n" "PARAM mvp[4] = {state.matrix.mvp};\n" @@ -102,9 +104,12 @@ static void Init( void ) glBindBufferARB(GL_ARRAY_BUFFER_ARB, arrayObj); glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(verts), verts, GL_STATIC_DRAW_ARB); + if (bgra) + color_size = GL_BGRA; + #ifdef GL_ARB_vertex_type_2_10_10_10_rev glVertexPointer( 4, GL_INT_2_10_10_10_REV, sizeof(verts[0]), 0 ); - glColorPointer( 4, GL_UNSIGNED_INT_2_10_10_10_REV, sizeof(verts[0]), (void *)(sizeof(unsigned int)) ); + glColorPointer( color_size, GL_UNSIGNED_INT_2_10_10_10_REV, sizeof(verts[0]), (void *)(sizeof(unsigned int)) ); #endif } @@ -146,12 +151,29 @@ static void Key( unsigned char key, int x, int y ) glutPostRedisplay(); } - - +static GLenum Args(int argc, char **argv) +{ + GLint i; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-bgra") == 0) { + bgra = GL_TRUE; + } else { + fprintf(stderr, "%s (Bad option).\n", argv[i]); + return GL_FALSE; + } + } + return GL_TRUE; +} int main( int argc, char *argv[] ) { glutInit( &argc, argv ); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + glutInitWindowPosition( 0, 0 ); glutInitWindowSize( 250, 250 ); glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH ); -- 2.11.4.GIT