From f71edfa41b70c056792a5b6f57984852cd8396ed Mon Sep 17 00:00:00 2001 From: root Date: Wed, 8 Aug 2007 12:03:18 -0600 Subject: increase texture size to 32x32 --- progs/trivial/quad-tex-2d.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'progs/trivial/quad-tex-2d.c') diff --git a/progs/trivial/quad-tex-2d.c b/progs/trivial/quad-tex-2d.c index 70b9fbf8c61..98f538eda32 100644 --- a/progs/trivial/quad-tex-2d.c +++ b/progs/trivial/quad-tex-2d.c @@ -41,7 +41,7 @@ static void Init(void) glClearColor(0.0, 0.0, 1.0, 0.0); -#define SIZE 16 +#define SIZE 32 { GLubyte tex2d[SIZE][SIZE][3]; GLint s, t; -- cgit v1.2.3 From bfcc337e386902712de49d43308167bc79c9e709 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 14 Aug 2007 15:19:37 -0600 Subject: vars to test 1D/2D textures with linear/nearest filtering --- progs/trivial/quad-tex-2d.c | 56 ++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 29 deletions(-) (limited to 'progs/trivial/quad-tex-2d.c') diff --git a/progs/trivial/quad-tex-2d.c b/progs/trivial/quad-tex-2d.c index 98f538eda32..cb0b9202a25 100644 --- a/progs/trivial/quad-tex-2d.c +++ b/progs/trivial/quad-tex-2d.c @@ -27,10 +27,8 @@ #include #include - -#define CI_OFFSET_1 16 -#define CI_OFFSET_2 32 - +static GLenum Target = GL_TEXTURE_2D; +static GLenum Filter = GL_NEAREST; GLenum doubleBuffer; static void Init(void) @@ -60,42 +58,42 @@ static void Init(void) } } + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + if (Target == GL_TEXTURE_1D) + glTexImage1D(Target, 0, 3, SIZE, 0, GL_RGB, GL_UNSIGNED_BYTE, tex2d); + else + glTexImage2D(Target, 0, 3, SIZE, SIZE, 0, + GL_RGB, GL_UNSIGNED_BYTE, tex2d); + + glEnable(Target); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_REPEAT); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameterf(Target, GL_TEXTURE_WRAP_R, GL_REPEAT); + glTexParameterf(Target, GL_TEXTURE_MIN_FILTER, Filter); + glTexParameterf(Target, GL_TEXTURE_MAG_FILTER, Filter); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glTexImage2D(GL_TEXTURE_2D, 0, 3, SIZE, SIZE, 0, - GL_RGB, GL_UNSIGNED_BYTE, tex2d); glPixelStorei(GL_UNPACK_ALIGNMENT, 4); - glEnable(GL_TEXTURE_2D); } - } static void Reshape(int width, int height) { - - glViewport(0, 0, (GLint)width, (GLint)height); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); - glMatrixMode(GL_MODELVIEW); + glViewport(0, 0, (GLint)width, (GLint)height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); } static void Key(unsigned char key, int x, int y) { - - switch (key) { - case 27: - exit(1); - default: - return; - } - - glutPostRedisplay(); + switch (key) { + case 27: + exit(0); + default: + return; + } + glutPostRedisplay(); } static void Draw(void) @@ -165,5 +163,5 @@ int main(int argc, char **argv) glutKeyboardFunc(Key); glutDisplayFunc(Draw); glutMainLoop(); - return 0; + return 0; } -- cgit v1.2.3 From 6fbbeed690c7f9aa0a97fdf64c8c57d1d79e7c33 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 18 Sep 2007 12:55:53 -0600 Subject: use perspective projection, press r/R to rotate the quad --- progs/trivial/quad-tex-2d.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'progs/trivial/quad-tex-2d.c') diff --git a/progs/trivial/quad-tex-2d.c b/progs/trivial/quad-tex-2d.c index cb0b9202a25..3a6e5237ed5 100644 --- a/progs/trivial/quad-tex-2d.c +++ b/progs/trivial/quad-tex-2d.c @@ -30,6 +30,7 @@ static GLenum Target = GL_TEXTURE_2D; static GLenum Filter = GL_NEAREST; GLenum doubleBuffer; +static float Rot = 0; static void Init(void) { @@ -81,13 +82,24 @@ static void Reshape(int width, int height) glViewport(0, 0, (GLint)width, (GLint)height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); +#if 0 glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); +#else + glFrustum(-1, 1, -1, 1, 10, 20); +#endif glMatrixMode(GL_MODELVIEW); + glTranslatef(0, 0, -15); } static void Key(unsigned char key, int x, int y) { switch (key) { + case 'r': + Rot += 10.0; + break; + case 'R': + Rot -= 10.0; + break; case 27: exit(0); default: @@ -100,17 +112,22 @@ static void Draw(void) { glClear(GL_COLOR_BUFFER_BIT); + glPushMatrix(); + glRotatef(Rot, 0, 1, 0); + glBegin(GL_QUADS); glTexCoord2f(1,0); - glVertex3f( 0.9, -0.9, -30.0); + glVertex3f( 0.9, -0.9, 0.0); glTexCoord2f(1,1); - glVertex3f( 0.9, 0.9, -30.0); + glVertex3f( 0.9, 0.9, 0.0); glTexCoord2f(0,1); - glVertex3f(-0.9, 0.9, -30.0); + glVertex3f(-0.9, 0.9, 0.0); glTexCoord2f(0,0); - glVertex3f(-0.9, -0.9, -30.0); + glVertex3f(-0.9, -0.9, 0.0); glEnd(); + glPopMatrix(); + glFlush(); if (doubleBuffer) { -- cgit v1.2.3 From b86cf714916d1bfdd6152839a8753cb3f3039cb2 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 16 May 2008 16:02:52 -0600 Subject: mesa: call glutDestroyWindow() on exit to help find mem leaks --- progs/glsl/texdemo1.c | 4 +++- progs/trivial/quad-tex-2d.c | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'progs/trivial/quad-tex-2d.c') diff --git a/progs/glsl/texdemo1.c b/progs/glsl/texdemo1.c index d29ecf452b1..3ceae14b96b 100644 --- a/progs/glsl/texdemo1.c +++ b/progs/glsl/texdemo1.c @@ -48,6 +48,7 @@ static GLfloat TexXrot = 0, TexYrot = 0; static GLfloat Xrot = 20.0, Yrot = 20.0, Zrot = 0.0; static GLfloat EyeDist = 10; static GLboolean Anim = GL_TRUE; +static int win = 0; struct uniform_info { @@ -177,6 +178,7 @@ key(unsigned char k, int x, int y) EyeDist = 90; break; case 27: + glutDestroyWindow(win); exit(0); } glutPostRedisplay(); @@ -554,7 +556,7 @@ main(int argc, char *argv[]) glutInit(&argc, argv); glutInitWindowSize(500, 400); glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); - glutCreateWindow(Demo); + win = glutCreateWindow(Demo); glutReshapeFunc(Reshape); glutKeyboardFunc(key); glutSpecialFunc(specialkey); diff --git a/progs/trivial/quad-tex-2d.c b/progs/trivial/quad-tex-2d.c index 3a6e5237ed5..97c9fc54d86 100644 --- a/progs/trivial/quad-tex-2d.c +++ b/progs/trivial/quad-tex-2d.c @@ -31,6 +31,7 @@ static GLenum Target = GL_TEXTURE_2D; static GLenum Filter = GL_NEAREST; GLenum doubleBuffer; static float Rot = 0; +static int win = 0; static void Init(void) { @@ -88,6 +89,7 @@ static void Reshape(int width, int height) glFrustum(-1, 1, -1, 1, 10, 20); #endif glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); glTranslatef(0, 0, -15); } @@ -101,6 +103,7 @@ static void Key(unsigned char key, int x, int y) Rot -= 10.0; break; case 27: + glutDestroyWindow(win); exit(0); default: return; @@ -170,7 +173,8 @@ int main(int argc, char **argv) type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); - if (glutCreateWindow("First Tri") == GL_FALSE) { + win = glutCreateWindow("First Tri"); + if (!win) { exit(1); } -- cgit v1.2.3