diff options
author | Brian <brian.paul@tungstengraphics.com> | 2007-07-10 14:46:15 -0600 |
---|---|---|
committer | Brian <brian.paul@tungstengraphics.com> | 2007-07-10 14:46:15 -0600 |
commit | 985e37eedb9e91fce00a08e3ba961a052d8fa898 (patch) | |
tree | 35335a816a715350264fc42280f75d9fdc7e4dc3 /progs/trivial | |
parent | 13aa51de41a93fff1aa5050cebec2a6e0985b45a (diff) | |
download | external_mesa3d-985e37eedb9e91fce00a08e3ba961a052d8fa898.zip external_mesa3d-985e37eedb9e91fce00a08e3ba961a052d8fa898.tar.gz external_mesa3d-985e37eedb9e91fce00a08e3ba961a052d8fa898.tar.bz2 |
clean-up, comments
Diffstat (limited to 'progs/trivial')
-rw-r--r-- | progs/trivial/quad-offset-factor.c | 21 | ||||
-rw-r--r-- | progs/trivial/quad-offset-units.c | 27 |
2 files changed, 18 insertions, 30 deletions
diff --git a/progs/trivial/quad-offset-factor.c b/progs/trivial/quad-offset-factor.c index becc885..90943d9 100644 --- a/progs/trivial/quad-offset-factor.c +++ b/progs/trivial/quad-offset-factor.c @@ -27,11 +27,6 @@ #include <stdlib.h> #include <GL/glut.h> - -#define CI_OFFSET_1 16 -#define CI_OFFSET_2 32 - - GLenum doubleBuffer; static void Init(void) @@ -45,7 +40,6 @@ static void Init(void) static void Reshape(int width, int height) { - glViewport(0, 0, (GLint)width, (GLint)height); glMatrixMode(GL_PROJECTION); @@ -56,7 +50,6 @@ static void Reshape(int width, int height) static void Key(unsigned char key, int x, int y) { - switch (key) { case 27: exit(1); @@ -75,7 +68,6 @@ static void quad( float half ) glVertex3f(-half/9.0, half/9.0, -25.0 - half); glVertex3f(-half/9.0, -half/9.0, -25.0 - half); glEnd(); - } static void Draw(void) @@ -83,27 +75,24 @@ static void Draw(void) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); - - + /* red: offset back */ glEnable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(1, 0); - glColor3f(1,0,0); quad(9); + /* green: no offset */ glDisable(GL_POLYGON_OFFSET_FILL); glColor3f(0,1,0); quad(6); - + /* black: offset zero, should not be visible because of z test */ glEnable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(0, 0); - - /* Black - should not be visible - */ glColor3f(0,0,0); quad(6); + /* blue: offset forward */ glEnable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(-1, 0); glColor3f(0,0,1); @@ -163,5 +152,5 @@ int main(int argc, char **argv) glutKeyboardFunc(Key); glutDisplayFunc(Draw); glutMainLoop(); - return 0; + return 0; } diff --git a/progs/trivial/quad-offset-units.c b/progs/trivial/quad-offset-units.c index afffebb..7ef9692 100644 --- a/progs/trivial/quad-offset-units.c +++ b/progs/trivial/quad-offset-units.c @@ -27,11 +27,6 @@ #include <stdlib.h> #include <GL/glut.h> - -#define CI_OFFSET_1 16 -#define CI_OFFSET_2 32 - - GLenum doubleBuffer; static void Init(void) @@ -45,7 +40,6 @@ static void Init(void) static void Reshape(int width, int height) { - glViewport(0, 0, (GLint)width, (GLint)height); glMatrixMode(GL_PROJECTION); @@ -56,7 +50,6 @@ static void Reshape(int width, int height) static void Key(unsigned char key, int x, int y) { - switch (key) { case 27: exit(1); @@ -75,7 +68,6 @@ static void quad( float half ) glVertex3f(-half/9.0, half/9.0, -25.0 - half); glVertex3f(-half/9.0, -half/9.0, -25.0 - half); glEnd(); - } static void Draw(void) @@ -83,27 +75,34 @@ static void Draw(void) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); + /* + * Because of clamping, the Z values of the first polygon may + * be 1.0 (the same as the clear value) so nothing would be + * drawn if the depth func is GL_LESS. Set it to GL_LEQUAL + * so we can see polygons with Z==1. + */ + glDepthFunc(GL_LEQUAL); - + /* red: offset back */ glEnable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(0, 4); - glColor3f(1,0,0); quad(9); + /* black: no offset */ glDisable(GL_POLYGON_OFFSET_FILL); glColor3f(0,0,0); quad(6); + /* green: offset 0 (this should obscure the black quad) */ glEnable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(0, 0); - glDepthFunc( GL_EQUAL ); glColor3f(0,1,0); quad(6); - glDepthFunc( GL_LESS ); - + /* blue: offset forward */ + glDepthFunc( GL_LESS ); glPolygonOffset(0, -4); glColor3f(0,0,1); quad(3); @@ -162,5 +161,5 @@ int main(int argc, char **argv) glutKeyboardFunc(Key); glutDisplayFunc(Draw); glutMainLoop(); - return 0; + return 0; } |