diff options
author | Roland Scheidegger <sroland@tungstengraphics.com> | 2007-08-18 22:31:43 +0200 |
---|---|---|
committer | Roland Scheidegger <sroland@tungstengraphics.com> | 2007-08-18 22:31:43 +0200 |
commit | 4b4fc25c3fab92bf292a78cb9c16a5a32a8bb01b (patch) | |
tree | a7fb45a41c6558a3304210fd72cf211258996dbc /progs/xdemos/offset.c | |
parent | 7aefdd518578687f961bb512a2b408857f0b9824 (diff) | |
parent | 53cf87be1b93c760228e6a9af8115d2a9ff99337 (diff) |
Merge branch 'origin' into i915tex_privbuffersi915tex_privbuffers
Conflicts:
src/mesa/drivers/dri/i915tex/intel_buffers.c
src/mesa/drivers/dri/i915tex/intel_context.c
src/mesa/drivers/dri/i915tex/intel_pixel_draw.c
src/mesa/drivers/dri/nouveau/nouveau_buffers.c
src/mesa/main/buffers.c
src/mesa/main/buffers.h
src/mesa/main/fbobject.c
src/mesa/main/framebuffer.c
Diffstat (limited to 'progs/xdemos/offset.c')
-rw-r--r-- | progs/xdemos/offset.c | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/progs/xdemos/offset.c b/progs/xdemos/offset.c index 3e92e68daa..0ad9147aea 100644 --- a/progs/xdemos/offset.c +++ b/progs/xdemos/offset.c @@ -71,12 +71,12 @@ typedef Vertex Quad[4]; /* data to define the six faces of a unit cube */ Quad quads[MAXQUAD] = { - { {0,0,0}, {1,0,0}, {1,1,0}, {0,1,0} }, - { {0,0,1}, {1,0,1}, {1,1,1}, {0,1,1} }, - { {0,0,0}, {1,0,0}, {1,0,1}, {0,0,1} }, - { {0,1,0}, {1,1,0}, {1,1,1}, {0,1,1} }, - { {0,0,0}, {0,0,1}, {0,1,1}, {0,1,0} }, - { {1,0,0}, {1,0,1}, {1,1,1}, {1,1,0} } + { {0,0,0}, {0,0,1}, {0,1,1}, {0,1,0} }, /* x = 0 */ + { {0,0,0}, {1,0,0}, {1,0,1}, {0,0,1} }, /* y = 0 */ + { {0,0,0}, {1,0,0}, {1,1,0}, {0,1,0} }, /* z = 0 */ + { {1,0,0}, {1,0,1}, {1,1,1}, {1,1,0} }, /* x = 1 */ + { {0,1,0}, {1,1,0}, {1,1,1}, {0,1,1} }, /* y = 1 */ + { {0,0,1}, {1,0,1}, {1,1,1}, {0,1,1} } /* z = 1 */ }; #define WIREFRAME 0 @@ -86,7 +86,7 @@ static void error(const char* prog, const char* msg); static void cubes(int mx, int my, int mode); static void fill(Quad quad); static void outline(Quad quad); -static void draw_hidden(Quad quad, int mode); +static void draw_hidden(Quad quad, int mode, int face); static void process_input(Display *dpy, Window win); static int query_extension(char* extName); @@ -101,6 +101,7 @@ int main(int argc, char** argv) { XSetWindowAttributes swa; Window win; GLXContext cx; + GLint z; dpy = XOpenDisplay(0); if (!dpy) error(argv[0], "can't open display"); @@ -134,13 +135,16 @@ int main(int argc, char** argv) { /* set up viewing parameters */ glMatrixMode(GL_PROJECTION); - gluPerspective(20, 1, 0.1, 20); + gluPerspective(20, 1, 10, 20); glMatrixMode(GL_MODELVIEW); glTranslatef(0, 0, -15); /* set other relevant state information */ glEnable(GL_DEPTH_TEST); + glGetIntegerv(GL_DEPTH_BITS, &z); + printf("GL_DEPTH_BITS = %d\n", z); + #ifdef GL_EXT_polygon_offset printf("using 1.0 offset extension\n"); glPolygonOffsetEXT( 1.0, 0.00001 ); @@ -160,6 +164,7 @@ int main(int argc, char** argv) { static void draw_scene(int mx, int my) { + glClearColor(0.25, 0.25, 0.25, 0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); @@ -206,7 +211,7 @@ cubes(int mx, int my, int mode) { glTranslatef(x, y, z); glScalef(0.8, 0.8, 0.8); for (i = 0; i < MAXQUAD; i++) - draw_hidden(quads[i], mode); + draw_hidden(quads[i], mode, i); glPopMatrix(); } } @@ -236,13 +241,18 @@ outline(Quad quad) { } static void -draw_hidden(Quad quad, int mode) { +draw_hidden(Quad quad, int mode, int face) { + static const GLfloat colors[3][3] = { + {0.5, 0.5, 0.0}, + {0.8, 0.5, 0.0}, + {0.0, 0.5, 0.8} + }; if (mode == HIDDEN_LINE) { - glColor3f(0, 0, 0); + glColor3fv(colors[face % 3]); fill(quad); } - /* draw the outline using white, optionally fill the interior with black */ + /* draw the outline using white */ glColor3f(1, 1, 1); outline(quad); } |