From 76ad2b4a5a38389ed733d1bf31a6cbba1881dc10 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 14 May 2009 13:28:09 +0100 Subject: progs/wgl: Use an invisible window in wglinfo. --- progs/wgl/wglinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'progs') diff --git a/progs/wgl/wglinfo.c b/progs/wgl/wglinfo.c index 881d35b297..43a216da18 100644 --- a/progs/wgl/wglinfo.c +++ b/progs/wgl/wglinfo.c @@ -364,7 +364,7 @@ print_screen_info(HDC _hdc, GLboolean limits) win = CreateWindowEx(0, wc.lpszClassName, "wglinfo", - WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, + WS_CLIPSIBLINGS | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, width, -- cgit v1.2.3 From 3c756ed39f93bd26bc81f6e3be0440429ad58c40 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 14 May 2009 15:32:10 +0100 Subject: progs/wgl: Small cleanup to wglinfo. --- progs/wgl/wglinfo.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'progs') diff --git a/progs/wgl/wglinfo.c b/progs/wgl/wglinfo.c index 43a216da18..864372c2f9 100644 --- a/progs/wgl/wglinfo.c +++ b/progs/wgl/wglinfo.c @@ -348,7 +348,6 @@ print_screen_info(HDC _hdc, GLboolean limits) HWND win; HGLRC ctx; int visinfo; - int width = 100, height = 100; HDC hdc; PIXELFORMATDESCRIPTOR pfd; @@ -367,15 +366,15 @@ print_screen_info(HDC _hdc, GLboolean limits) WS_CLIPSIBLINGS | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, - width, - height, + CW_USEDEFAULT, + CW_USEDEFAULT, NULL, NULL, wc.hInstance, NULL); if (!win) { fprintf(stderr, "Couldn't create window"); - exit(1); + return; } hdc = GetDC(win); @@ -476,7 +475,7 @@ print_visual_attribs_verbose(int iPixelFormat, LPPIXELFORMATDESCRIPTOR ppfd) ppfd->dwFlags & PFD_DRAW_TO_WINDOW ? 1 : 0); printf(" bufferSize=%d level=%d renderType=%s doubleBuffer=%d stereo=%d\n", 0 /* ppfd->bufferSize */, 0 /* ppfd->level */, - visual_render_type_name(ppfd->dwFlags), + visual_render_type_name(ppfd->iPixelType), ppfd->dwFlags & PFD_DOUBLEBUFFER ? 1 : 0, ppfd->dwFlags & PFD_STEREO ? 1 : 0); printf(" rgba: cRedBits=%d cGreenBits=%d cBlueBits=%d cAlphaBits=%d\n", -- cgit v1.2.3 From 00e7a600776ceb589bd5939ccd8aad937527db81 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 13 May 2009 13:47:38 +0100 Subject: trivial/tri-z: add controls for depthrange min/max Also add key to set up quake-1 style ztrick rendering with clear depth 1.0, deptrange(1.0, 0.0) and depthfunc GL_GREATER. --- progs/trivial/tri-z.c | 50 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 10 deletions(-) (limited to 'progs') diff --git a/progs/trivial/tri-z.c b/progs/trivial/tri-z.c index 335d2b90e2..014aaa071a 100644 --- a/progs/trivial/tri-z.c +++ b/progs/trivial/tri-z.c @@ -57,13 +57,19 @@ static struct { GLenum func; const char *str; } funcs[] = static int curFunc = 0; static double clearVal = 1.0; - +static float minZ = 0.0; +static float maxZ = 1.0; static void usage(void) { - printf("t - toggle rendering order of triangles\n"); - printf("c - toggle Z clear value between 0, 1\n"); - printf("f - cycle through depth test functions\n"); + printf("t - toggle rendering order of triangles\n"); + printf("c - toggle Z clear value between 0, 1\n"); + printf("f - cycle through depth test functions\n"); + printf("n/N - decrease/increase depthrange minZ\n"); + printf("x/X - decrease/increase depthrange maxZ\n"); + printf("spc - reset\n"); + printf("z - set to reverse-direction (ztrick) mode\n"); + fflush(stdout); } @@ -97,9 +103,11 @@ static void drawRightTriangle(void) void display(void) { - printf("GL_CLEAR_DEPTH = %f GL_DEPTH_FUNC = %s\n", - clearVal, funcs[curFunc].str); + printf("GL_CLEAR_DEPTH = %.2f, GL_DEPTH_FUNC = %s, DepthRange(%.1f, %.1f)\n", + clearVal, funcs[curFunc].str, minZ, maxZ); + fflush(stdout); glClearDepth(clearVal); + glDepthRange(minZ, maxZ); glDepthFunc(funcs[curFunc].func); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -131,27 +139,49 @@ void reshape(int w, int h) void keyboard(unsigned char key, int x, int y) { switch (key) { + case 'n': + minZ -= .1; + break; + case 'N': + minZ += .1; + break; + case 'x': + maxZ -= .1; + break; + case 'X': + maxZ += .1; + break; case 'c': case 'C': clearVal = 1.0 - clearVal; - glutPostRedisplay(); break; case 'f': case 'F': curFunc = (curFunc + 1) % NUM_FUNCS; - glutPostRedisplay(); break; case 't': case 'T': leftFirst = !leftFirst; - glutPostRedisplay(); + break; + case ' ': + curFunc = 0; + clearVal = 1.0; + minZ = 0.0; + maxZ = 1.0; + break; + case 'z': + curFunc = 2; + clearVal = 0.0; + minZ = 1.0; + maxZ = 0.0; break; case 27: /* Escape key */ exit(0); break; default: - break; + return; } + glutPostRedisplay(); } /* Main Loop -- cgit v1.2.3 From 97f5953ced6938ca8e92cde62e8717ff505cc4e2 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 14 May 2009 15:57:27 +0100 Subject: progs/vpglsl: add similar support for point rendering as progs/vp --- progs/vpglsl/psiz-imm.glsl | 6 +++++ progs/vpglsl/psiz-mul.glsl | 6 +++++ progs/vpglsl/vp-tris.c | 58 +++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 64 insertions(+), 6 deletions(-) create mode 100644 progs/vpglsl/psiz-imm.glsl create mode 100644 progs/vpglsl/psiz-mul.glsl (limited to 'progs') diff --git a/progs/vpglsl/psiz-imm.glsl b/progs/vpglsl/psiz-imm.glsl new file mode 100644 index 0000000000..101d314d58 --- /dev/null +++ b/progs/vpglsl/psiz-imm.glsl @@ -0,0 +1,6 @@ + +void main() { + gl_FrontColor = gl_Color; + gl_PointSize = 2.0; + gl_Position = gl_Vertex; +} diff --git a/progs/vpglsl/psiz-mul.glsl b/progs/vpglsl/psiz-mul.glsl new file mode 100644 index 0000000000..77f4a46b52 --- /dev/null +++ b/progs/vpglsl/psiz-mul.glsl @@ -0,0 +1,6 @@ + +void main() { + gl_FrontColor = gl_Color; + gl_PointSize = 10 * gl_Color.x; + gl_Position = gl_Vertex; +} diff --git a/progs/vpglsl/vp-tris.c b/progs/vpglsl/vp-tris.c index 9ae410bf98..b2b0508091 100644 --- a/progs/vpglsl/vp-tris.c +++ b/progs/vpglsl/vp-tris.c @@ -10,6 +10,10 @@ static const char *filename = NULL; static GLuint nr_steps = 4; +static GLuint prim = GL_TRIANGLES; +static GLfloat psz = 1.0; +static GLboolean pointsmooth = 0; +static GLboolean program_point_size = 0; static GLuint fragShader; static GLuint vertShader; @@ -229,6 +233,14 @@ static void subdiv( union vert *v0, } } +static void enable( GLenum value, GLboolean flag ) +{ + if (flag) + glEnable(value); + else + glDisable(value); +} + /** Assignment */ #define ASSIGN_3V( V, V0, V1, V2 ) \ do { \ @@ -241,10 +253,13 @@ static void Display( void ) { glClearColor(0.3, 0.3, 0.3, 1); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + glPointSize(psz); glUseProgram(program); + enable( GL_POINT_SMOOTH, pointsmooth ); + enable( GL_VERTEX_PROGRAM_POINT_SIZE_ARB, program_point_size ); - glBegin(GL_TRIANGLES); + glBegin(prim); { @@ -291,10 +306,41 @@ static void Key( unsigned char key, int x, int y ) (void) x; (void) y; switch (key) { - case 27: - CleanUp(); - exit(0); - break; + case 'p': + prim = GL_POINTS; + break; + case 't': + prim = GL_TRIANGLES; + break; + case 's': + psz += .5; + break; + case 'S': + if (psz > .5) + psz -= .5; + break; + case 'm': + pointsmooth = !pointsmooth; + break; + case 'z': + program_point_size = !program_point_size; + break; + case '+': + nr_steps++; + break; + case '-': + if (nr_steps) + nr_steps--; + break; + case ' ': + psz = 1.0; + prim = GL_TRIANGLES; + nr_steps = 4; + break; + case 27: + CleanUp(); + exit(0); + break; } glutPostRedisplay(); } @@ -305,7 +351,7 @@ int main( int argc, char *argv[] ) glutInitWindowPosition( 0, 0 ); glutInitWindowSize( 250, 250 ); glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH ); - glutCreateWindow(argv[0]); + glutCreateWindow(argv[argc-1]); glewInit(); glutReshapeFunc( Reshape ); glutKeyboardFunc( Key ); -- cgit v1.2.3