diff options
Diffstat (limited to 'progs/trivial')
-rw-r--r-- | progs/trivial/.gitignore | 1 | ||||
-rw-r--r-- | progs/trivial/Makefile | 1 | ||||
-rw-r--r-- | progs/trivial/SConscript | 11 | ||||
-rw-r--r-- | progs/trivial/clear-fbo-tex.c | 4 | ||||
-rw-r--r-- | progs/trivial/createwin.c | 2 | ||||
-rw-r--r-- | progs/trivial/dlist-begin-call-end.c | 2 | ||||
-rw-r--r-- | progs/trivial/draw2arrays.c | 2 | ||||
-rw-r--r-- | progs/trivial/drawarrays.c | 2 | ||||
-rw-r--r-- | progs/trivial/tri-blend-max.c | 6 | ||||
-rw-r--r-- | progs/trivial/tri-blend-min.c | 6 | ||||
-rw-r--r-- | progs/trivial/tri-blend-revsub.c | 6 | ||||
-rw-r--r-- | progs/trivial/tri-blend-sub.c | 6 | ||||
-rw-r--r-- | progs/trivial/tri-blend.c | 6 | ||||
-rw-r--r-- | progs/trivial/tri-fbo-tex.c | 3 | ||||
-rw-r--r-- | progs/trivial/tri-fp.c | 2 | ||||
-rw-r--r-- | progs/trivial/tri-logicop-none.c | 2 | ||||
-rw-r--r-- | progs/trivial/tri-logicop-xor.c | 2 | ||||
-rw-r--r-- | progs/trivial/tri-orig.c | 10 | ||||
-rw-r--r-- | progs/trivial/tri-z.c | 6 | ||||
-rw-r--r-- | progs/trivial/vbo-drawarrays.c | 2 | ||||
-rw-r--r-- | progs/trivial/vbo-noninterleaved.c | 4 | ||||
-rw-r--r-- | progs/trivial/vbo-tri.c | 131 |
22 files changed, 170 insertions, 47 deletions
diff --git a/progs/trivial/.gitignore b/progs/trivial/.gitignore index 4d6e405c500..4317eb607fe 100644 --- a/progs/trivial/.gitignore +++ b/progs/trivial/.gitignore @@ -147,6 +147,7 @@ vbo-drawarrays vbo-drawelements vbo-drawrange vbo-noninterleaved +vbo-tri vp-array vp-array-int vp-clip diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile index 70728616d28..e15ec33ab59 100644 --- a/progs/trivial/Makefile +++ b/progs/trivial/Makefile @@ -153,6 +153,7 @@ SOURCES = \ tristrip-clip.c \ tristrip-flat.c \ tristrip.c \ + vbo-tri.c \ vbo-drawarrays.c \ vbo-noninterleaved.c \ vbo-drawelements.c \ diff --git a/progs/trivial/SConscript b/progs/trivial/SConscript index 9a1f3575bdc..613383c77b1 100644 --- a/progs/trivial/SConscript +++ b/progs/trivial/SConscript @@ -1,11 +1,4 @@ -Import('env') - -if not env['GLUT']: - Return() - -env = env.Clone() - -env.Prepend(LIBS = ['$GLUT_LIB']) +Import('*') progs = [ 'clear-fbo-tex', @@ -154,7 +147,7 @@ progs = [ ] for prog in progs: - prog = env.Program( + prog = progs_env.Program( target = prog, source = prog + '.c', ) diff --git a/progs/trivial/clear-fbo-tex.c b/progs/trivial/clear-fbo-tex.c index 238f634bf59..ff31706fd1c 100644 --- a/progs/trivial/clear-fbo-tex.c +++ b/progs/trivial/clear-fbo-tex.c @@ -102,8 +102,8 @@ static void Draw( void ) /* draw to texture image */ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB); -// glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT); -// glReadBuffer(GL_COLOR_ATTACHMENT1_EXT); + /* glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT); */ + /* glReadBuffer(GL_COLOR_ATTACHMENT1_EXT); */ glViewport(0, 0, TexWidth, TexHeight); diff --git a/progs/trivial/createwin.c b/progs/trivial/createwin.c index 04a088642b8..93da30ee294 100644 --- a/progs/trivial/createwin.c +++ b/progs/trivial/createwin.c @@ -116,6 +116,6 @@ int main(int argc, char **argv) glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutDisplayFunc(Draw); -// glutMainLoop(); + /* glutMainLoop(); */ return 0; } diff --git a/progs/trivial/dlist-begin-call-end.c b/progs/trivial/dlist-begin-call-end.c index da3864a02a4..dbfaef3978f 100644 --- a/progs/trivial/dlist-begin-call-end.c +++ b/progs/trivial/dlist-begin-call-end.c @@ -49,7 +49,7 @@ static void Init(void) */ first_list = glGenLists(1); glNewList(first_list, GL_COMPILE); -// glColor3f(0,1,0); + /* glColor3f(0,1,0); */ glEndList(); diff --git a/progs/trivial/draw2arrays.c b/progs/trivial/draw2arrays.c index 95a89981d3a..2345ae9e9ed 100644 --- a/progs/trivial/draw2arrays.c +++ b/progs/trivial/draw2arrays.c @@ -66,7 +66,7 @@ static void Display( void ) glEnable(GL_VERTEX_PROGRAM_ARB); -// glDrawArrays( GL_TRIANGLES, 0, 3 ); + /* glDrawArrays( GL_TRIANGLES, 0, 3 ); */ glDrawArrays( GL_TRIANGLES, 1, 3 ); glFlush(); diff --git a/progs/trivial/drawarrays.c b/progs/trivial/drawarrays.c index 27d86682f75..f5c0a50f9a9 100644 --- a/progs/trivial/drawarrays.c +++ b/progs/trivial/drawarrays.c @@ -77,7 +77,7 @@ static void Display( void ) glEnable(GL_VERTEX_PROGRAM_ARB); -// glDrawArrays( GL_TRIANGLES, 0, 3 ); + /* glDrawArrays( GL_TRIANGLES, 0, 3 ); */ glDrawArrays( GL_TRIANGLES, 1, 3 ); glFlush(); diff --git a/progs/trivial/tri-blend-max.c b/progs/trivial/tri-blend-max.c index b39f8f3f12a..b173dab8ec1 100644 --- a/progs/trivial/tri-blend-max.c +++ b/progs/trivial/tri-blend-max.c @@ -83,7 +83,7 @@ static void drawRightTriangle(void) glDisable (GL_BLEND); } -void display(void) +static void display(void) { glClear(GL_COLOR_BUFFER_BIT); @@ -99,7 +99,7 @@ void display(void) glFlush(); } -void reshape(int w, int h) +static void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); @@ -111,7 +111,7 @@ void reshape(int w, int h) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 't': diff --git a/progs/trivial/tri-blend-min.c b/progs/trivial/tri-blend-min.c index 656297c0ce0..629139acae7 100644 --- a/progs/trivial/tri-blend-min.c +++ b/progs/trivial/tri-blend-min.c @@ -83,7 +83,7 @@ static void drawRightTriangle(void) glDisable (GL_BLEND); } -void display(void) +static void display(void) { glClear(GL_COLOR_BUFFER_BIT); @@ -99,7 +99,7 @@ void display(void) glFlush(); } -void reshape(int w, int h) +static void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); @@ -111,7 +111,7 @@ void reshape(int w, int h) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 't': diff --git a/progs/trivial/tri-blend-revsub.c b/progs/trivial/tri-blend-revsub.c index fe225f1f4e0..ef1e92c85dc 100644 --- a/progs/trivial/tri-blend-revsub.c +++ b/progs/trivial/tri-blend-revsub.c @@ -83,7 +83,7 @@ static void drawRightTriangle(void) glDisable (GL_BLEND); } -void display(void) +static void display(void) { glClear(GL_COLOR_BUFFER_BIT); @@ -99,7 +99,7 @@ void display(void) glFlush(); } -void reshape(int w, int h) +static void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); @@ -111,7 +111,7 @@ void reshape(int w, int h) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 't': diff --git a/progs/trivial/tri-blend-sub.c b/progs/trivial/tri-blend-sub.c index cc1aeaf4a48..3c560ae6ef7 100644 --- a/progs/trivial/tri-blend-sub.c +++ b/progs/trivial/tri-blend-sub.c @@ -83,7 +83,7 @@ static void drawRightTriangle(void) glDisable (GL_BLEND); } -void display(void) +static void display(void) { glClear(GL_COLOR_BUFFER_BIT); @@ -99,7 +99,7 @@ void display(void) glFlush(); } -void reshape(int w, int h) +static void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); @@ -111,7 +111,7 @@ void reshape(int w, int h) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 't': diff --git a/progs/trivial/tri-blend.c b/progs/trivial/tri-blend.c index 58c451c9769..f41be89b097 100644 --- a/progs/trivial/tri-blend.c +++ b/progs/trivial/tri-blend.c @@ -81,7 +81,7 @@ static void drawRightTriangle(void) glDisable (GL_BLEND); } -void display(void) +static void display(void) { glClear(GL_COLOR_BUFFER_BIT); @@ -97,7 +97,7 @@ void display(void) glFlush(); } -void reshape(int w, int h) +static void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); @@ -109,7 +109,7 @@ void reshape(int w, int h) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 't': diff --git a/progs/trivial/tri-fbo-tex.c b/progs/trivial/tri-fbo-tex.c index 72b4cf3683d..8d1f871328d 100644 --- a/progs/trivial/tri-fbo-tex.c +++ b/progs/trivial/tri-fbo-tex.c @@ -189,9 +189,6 @@ Key(unsigned char key, int x, int y) static void Init(int argc, char *argv[]) { - static const GLfloat mat[4] = { 1.0, 0.5, 0.5, 1.0 }; - GLint i; - if (!glutExtensionSupported("GL_EXT_framebuffer_object")) { printf("GL_EXT_framebuffer_object not found!\n"); exit(0); diff --git a/progs/trivial/tri-fp.c b/progs/trivial/tri-fp.c index 8f933befd3d..6ecfef4d2ac 100644 --- a/progs/trivial/tri-fp.c +++ b/progs/trivial/tri-fp.c @@ -42,7 +42,7 @@ static void Init(void) static const char *prog1 = "!!ARBfp1.0\n" "MOV result.color, fragment.texcoord[1];\n" -// "MOV result.color, fragment.color;\n" + /* "MOV result.color, fragment.color;\n" */ "END\n"; diff --git a/progs/trivial/tri-logicop-none.c b/progs/trivial/tri-logicop-none.c index 53c2614ac32..2b6a3d6f5c8 100644 --- a/progs/trivial/tri-logicop-none.c +++ b/progs/trivial/tri-logicop-none.c @@ -101,7 +101,7 @@ static void Draw(void) glVertex3f( 0.5, -0.5, -30.0); glEnd(); -// glLineWidth(12.0); + /* glLineWidth(12.0); */ /* Redraw parts of the lines: */ diff --git a/progs/trivial/tri-logicop-xor.c b/progs/trivial/tri-logicop-xor.c index f018a851ace..b8207cd6d8a 100644 --- a/progs/trivial/tri-logicop-xor.c +++ b/progs/trivial/tri-logicop-xor.c @@ -105,7 +105,7 @@ static void Draw(void) glVertex3f( 0.5, -0.5, -30.0); glEnd(); -// glLineWidth(12.0); + /* glLineWidth(12.0); */ /* Redraw parts of the lines to remove them: */ diff --git a/progs/trivial/tri-orig.c b/progs/trivial/tri-orig.c index d86d34c39de..f86ac52a026 100644 --- a/progs/trivial/tri-orig.c +++ b/progs/trivial/tri-orig.c @@ -51,7 +51,7 @@ static void Reshape(int width, int height) glMatrixMode(GL_PROJECTION); glLoadIdentity(); -/* glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); */ + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); glMatrixMode(GL_MODELVIEW); } @@ -74,11 +74,11 @@ static void Draw(void) glBegin(GL_TRIANGLES); glColor3f(0,0,.7); - glVertex3f( 0.9, -0.9, -0.0); + glVertex3f( 0.9, -0.9, -30.0); glColor3f(.8,0,0); - glVertex3f( 0.9, 0.9, -0.0); + glVertex3f( 0.9, 0.9, -30.0); glColor3f(0,.9,0); - glVertex3f(-0.9, 0.0, -0.0); + glVertex3f(-0.9, 0.0, -30.0); glEnd(); glFlush(); @@ -119,7 +119,7 @@ int main(int argc, char **argv) glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); - type = GLUT_RGB | GLUT_ALPHA; + type = GLUT_RGB; type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); diff --git a/progs/trivial/tri-z.c b/progs/trivial/tri-z.c index 014aaa071a5..092249dd765 100644 --- a/progs/trivial/tri-z.c +++ b/progs/trivial/tri-z.c @@ -101,7 +101,7 @@ static void drawRightTriangle(void) glEnd(); } -void display(void) +static void display(void) { printf("GL_CLEAR_DEPTH = %.2f, GL_DEPTH_FUNC = %s, DepthRange(%.1f, %.1f)\n", clearVal, funcs[curFunc].str, minZ, maxZ); @@ -124,7 +124,7 @@ void display(void) glFlush(); } -void reshape(int w, int h) +static void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); @@ -136,7 +136,7 @@ void reshape(int w, int h) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 'n': diff --git a/progs/trivial/vbo-drawarrays.c b/progs/trivial/vbo-drawarrays.c index c29954b9033..cb26e841156 100644 --- a/progs/trivial/vbo-drawarrays.c +++ b/progs/trivial/vbo-drawarrays.c @@ -83,7 +83,7 @@ static void Display( void ) glEnable(GL_VERTEX_PROGRAM_ARB); -// glDrawArrays( GL_TRIANGLES, 0, 3 ); + /* glDrawArrays( GL_TRIANGLES, 0, 3 ); */ glDrawArrays( GL_TRIANGLES, 1, 3 ); glFlush(); diff --git a/progs/trivial/vbo-noninterleaved.c b/progs/trivial/vbo-noninterleaved.c index 0672ca50ff1..f7c42a89818 100644 --- a/progs/trivial/vbo-noninterleaved.c +++ b/progs/trivial/vbo-noninterleaved.c @@ -87,8 +87,8 @@ static void Display( void ) glEnable(GL_VERTEX_PROGRAM_ARB); -// glDrawArrays( GL_TRIANGLES, 0, 3 ); -// glDrawArrays( GL_TRIANGLES, 1, 3 ); + /* glDrawArrays( GL_TRIANGLES, 0, 3 ); */ + /* glDrawArrays( GL_TRIANGLES, 1, 3 ); */ glDrawArrays( GL_QUADS, 0, 4 ); glFlush(); diff --git a/progs/trivial/vbo-tri.c b/progs/trivial/vbo-tri.c new file mode 100644 index 00000000000..d4cba14414c --- /dev/null +++ b/progs/trivial/vbo-tri.c @@ -0,0 +1,131 @@ +/* Even simpler for many drivers than trivial/tri -- pass-through + * vertex shader and vertex data in a VBO. + */ + +#include <assert.h> +#include <string.h> +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <GL/glew.h> +#include <GL/glut.h> + + +struct { + GLfloat pos[4]; + GLfloat color[4]; +} verts[] = +{ + { { -0.9, -0.9, 0.0, 1.0 }, + {.8,0,0, 1}, + }, + + { { 0.9, -0.9, 0.0, 1.0 }, + { 0, .9, 0, 1 }, + }, + + { { 0, 0.9, 0.0, 1.0 }, + {0,0,.7, 1}, + }, +}; + +GLuint arrayObj; + +static void Init( void ) +{ + GLint errno; + GLuint prognum; + + static const char *prog1 = + "!!ARBvp1.0\n" + "MOV result.color, vertex.color;\n" + "MOV result.position, vertex.position;\n" + "END\n"; + + + glGenProgramsARB(1, &prognum); + + glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum); + glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(prog1), (const GLubyte *) prog1); + + assert(glIsProgramARB(prognum)); + errno = glGetError(); + printf("glGetError = %d\n", errno); + if (errno != GL_NO_ERROR) + { + GLint errorpos; + + glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos); + printf("errorpos: %d\n", errorpos); + printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + } + + + glEnableClientState( GL_VERTEX_ARRAY ); + glEnableClientState( GL_COLOR_ARRAY ); + + glGenBuffersARB(1, &arrayObj); + glBindBufferARB(GL_ARRAY_BUFFER_ARB, arrayObj); + glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(verts), verts, GL_STATIC_DRAW_ARB); + + glVertexPointer( 4, GL_FLOAT, sizeof(verts[0]), 0 ); + glColorPointer( 4, GL_FLOAT, sizeof(verts[0]), (void *)(4*sizeof(float)) ); +} + + + +static void Display( void ) +{ + glClearColor(0.3, 0.3, 0.3, 1); + glClear( GL_COLOR_BUFFER_BIT ); + + glEnable(GL_VERTEX_PROGRAM_NV); + glDrawArrays( GL_TRIANGLES, 0, 3 ); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + /*glTranslatef( 0.0, 0.0, -15.0 );*/ +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 250, 250 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); + glutCreateWindow(argv[0]); + glewInit(); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} |