From 477e18cb026b287e8fd0cb415b81f777fe0db39e Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 14 Jun 2007 18:25:10 +0100 Subject: Add GLUT_ALPHA for softpipe --- progs/trivial/tri-cull.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'progs/trivial/tri-cull.c') diff --git a/progs/trivial/tri-cull.c b/progs/trivial/tri-cull.c index 20aeaf1d7c..fa51f51174 100644 --- a/progs/trivial/tri-cull.c +++ b/progs/trivial/tri-cull.c @@ -118,7 +118,7 @@ int main(int argc, char **argv) glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); - type = GLUT_RGB; + type = GLUT_RGB | GLUT_ALPHA; type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); -- cgit v1.2.3 From 9a89cc3b6b575a209bae535900e18dfb16e66e98 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 10 Jul 2007 11:39:08 -0600 Subject: use 'c' to cycle through polygon cull modes --- progs/trivial/tri-cull.c | 78 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 54 insertions(+), 24 deletions(-) (limited to 'progs/trivial/tri-cull.c') diff --git a/progs/trivial/tri-cull.c b/progs/trivial/tri-cull.c index fa51f51174..af26cb0b2b 100644 --- a/progs/trivial/tri-cull.c +++ b/progs/trivial/tri-cull.c @@ -27,25 +27,44 @@ #include #include +static GLenum doubleBuffer; +static GLint cullmode = 0; -#define CI_OFFSET_1 16 -#define CI_OFFSET_2 32 - - -GLenum doubleBuffer; +static void cull(void) +{ + cullmode = (cullmode + 1) % 4; + if (cullmode == 0) { + glCullFace(GL_FRONT); + glEnable(GL_CULL_FACE); + printf("cull GL_FRONT\n"); + } + else if (cullmode == 1) { + glCullFace(GL_BACK); + glEnable(GL_CULL_FACE); + printf("cull GL_BACK\n"); + } + else if (cullmode == 2) { + glCullFace(GL_FRONT_AND_BACK); + glEnable(GL_CULL_FACE); + printf("cull GL_FRONT_AND_BACK\n"); + } + else { + glDisable(GL_CULL_FACE); + printf("cull none\n"); + } +} static void Init(void) { fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); - - glClearColor(0.0, 0.0, 1.0, 0.0); + glClearColor(0.0, 0.0, 1.0, 0.0); + cull(); } static void Reshape(int width, int height) { - glViewport(0, 0, (GLint)width, (GLint)height); glMatrixMode(GL_PROJECTION); @@ -56,15 +75,16 @@ static void Reshape(int width, int height) static void Key(unsigned char key, int x, int y) { - - switch (key) { - case 27: - exit(1); - default: - return; - } - - glutPostRedisplay(); + switch (key) { + case 27: + exit(1); + case 'c': + cull(); + break; + default: + return; + } + glutPostRedisplay(); } static void Draw(void) @@ -72,12 +92,22 @@ static void Draw(void) glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_TRIANGLES); - glColor3f(0,0,1); - glVertex3f( -1.5, 0.5, -30.0); - glColor3f(1,0,0); - glVertex3f( 0, 2.0, -30.0); - glColor3f(0,1,0); - glVertex3f(-1.5, 2.0, -30.0); + /* back-facing */ + glColor3f(0,0,.7); + glVertex3f(-0.1, -0.9, -30.0); + glColor3f(.8,0,0); + glVertex3f(-0.1, 0.9, -30.0); + glColor3f(0,.9,0); + glVertex3f(-0.9, 0.0, -30.0); + + /* front-facing */ + glColor3f(0,0,.7); + glVertex3f( 0.1, -0.9, -30.0); + glColor3f(.8,0,0); + glVertex3f( 0.1, 0.9, -30.0); + glColor3f(0,.9,0); + glVertex3f( 0.9, 0.0, -30.0); + glEnd(); glFlush(); @@ -132,5 +162,5 @@ int main(int argc, char **argv) glutKeyboardFunc(Key); glutDisplayFunc(Draw); glutMainLoop(); - return 0; + return 0; } -- cgit v1.2.3 From a2e471e05e452454f78db7a5fbc6845f6ca39f35 Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 13 Jul 2007 14:25:28 -0600 Subject: press 'f' to toggle front-face winding --- progs/trivial/tri-cull.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'progs/trivial/tri-cull.c') diff --git a/progs/trivial/tri-cull.c b/progs/trivial/tri-cull.c index af26cb0b2b..2eead84115 100644 --- a/progs/trivial/tri-cull.c +++ b/progs/trivial/tri-cull.c @@ -29,6 +29,7 @@ static GLenum doubleBuffer; static GLint cullmode = 0; +static GLenum front = GL_CCW; /* GL default */ static void cull(void) { @@ -76,11 +77,16 @@ static void Reshape(int width, int height) static void Key(unsigned char key, int x, int y) { switch (key) { - case 27: - exit(1); + case 27: + exit(1); case 'c': cull(); break; + case 'f': + front = ((front == GL_CCW) ? GL_CW : GL_CCW); + glFrontFace(front); + printf("front face = %s\n", front == GL_CCW ? "GL_CCW" : "GL_CW"); + break; default: return; } @@ -92,7 +98,7 @@ static void Draw(void) glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_TRIANGLES); - /* back-facing */ + /* CCW / front-facing */ glColor3f(0,0,.7); glVertex3f(-0.1, -0.9, -30.0); glColor3f(.8,0,0); @@ -100,7 +106,7 @@ static void Draw(void) glColor3f(0,.9,0); glVertex3f(-0.9, 0.0, -30.0); - /* front-facing */ + /* CW / back-facing */ glColor3f(0,0,.7); glVertex3f( 0.1, -0.9, -30.0); glColor3f(.8,0,0); -- cgit v1.2.3