From: Brian Paul Date: Sat, 18 Apr 2009 19:12:50 +0000 (-0600) Subject: demos: move demos/texobj.c to tests/ X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d61070b65970c9ec14b3272a6c4c6b4b1a9280a2;p=mesa.git demos: move demos/texobj.c to tests/ --- diff --git a/progs/demos/Makefile b/progs/demos/Makefile index 8febc14d410..c17595ec794 100644 --- a/progs/demos/Makefile +++ b/progs/demos/Makefile @@ -58,7 +58,6 @@ PROGS = \ tessdemo \ texcyl \ texenv \ - texobj \ textures \ trispd \ tunnel \ diff --git a/progs/demos/texobj.c b/progs/demos/texobj.c deleted file mode 100644 index 40bce6e5695..00000000000 --- a/progs/demos/texobj.c +++ /dev/null @@ -1,284 +0,0 @@ - -/* - * Example of using the 1.1 texture object functions. - * Also, this demo utilizes Mesa's fast texture map path. - * - * Brian Paul June 1996 This file is in the public domain. - */ - -#include -#include -#include -#include -#include -#include "GL/glut.h" - -static GLuint Window = 0; - -static GLuint TexObj[2]; -static GLfloat Angle = 0.0f; -static GLboolean UseObj = GL_FALSE; - - -#if defined(GL_VERSION_1_1) || defined(GL_VERSION_1_2) -# define TEXTURE_OBJECT 1 -#elif defined(GL_EXT_texture_object) -# define TEXTURE_OBJECT 1 -# define glBindTexture(A,B) glBindTextureEXT(A,B) -# define glGenTextures(A,B) glGenTexturesEXT(A,B) -# define glDeleteTextures(A,B) glDeleteTexturesEXT(A,B) -#endif - - - - -static void draw( void ) -{ - glClear( GL_COLOR_BUFFER_BIT ); - - glColor3f( 1.0, 1.0, 1.0 ); - - /* draw first polygon */ - glPushMatrix(); - glTranslatef( -1.0, 0.0, 0.0 ); - glRotatef( Angle, 0.0, 0.0, 1.0 ); - if (UseObj) { -#ifdef TEXTURE_OBJECT - glBindTexture( GL_TEXTURE_2D, TexObj[0] ); -#endif - } - else { - glCallList( TexObj[0] ); - } - glBegin( GL_POLYGON ); - glTexCoord2f( 0.0, 0.0 ); glVertex2f( -1.0, -1.0 ); - glTexCoord2f( 1.0, 0.0 ); glVertex2f( 1.0, -1.0 ); - glTexCoord2f( 1.0, 1.0 ); glVertex2f( 1.0, 1.0 ); - glTexCoord2f( 0.0, 1.0 ); glVertex2f( -1.0, 1.0 ); - glEnd(); - glPopMatrix(); - - /* draw second polygon */ - glPushMatrix(); - glTranslatef( 1.0, 0.0, 0.0 ); - glRotatef( Angle-90.0, 0.0, 1.0, 0.0 ); - if (UseObj) { -#ifdef TEXTURE_OBJECT - glBindTexture( GL_TEXTURE_2D, TexObj[1] ); -#endif - } - else { - glCallList( TexObj[1] ); - } - glBegin( GL_POLYGON ); - glTexCoord2f( 0.0, 0.0 ); glVertex2f( -1.0, -1.0 ); - glTexCoord2f( 1.0, 0.0 ); glVertex2f( 1.0, -1.0 ); - glTexCoord2f( 1.0, 1.0 ); glVertex2f( 1.0, 1.0 ); - glTexCoord2f( 0.0, 1.0 ); glVertex2f( -1.0, 1.0 ); - glEnd(); - glPopMatrix(); - - glutSwapBuffers(); -} - - - -static void idle( void ) -{ - static double t0 = -1.; - double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0; - if (t0 < 0.0) - t0 = t; - dt = t - t0; - t0 = t; - Angle += 120.0*dt; - glutPostRedisplay(); -} - - - -/* change view Angle, exit upon ESC */ -static void key(unsigned char k, int x, int y) -{ - (void) x; - (void) y; - switch (k) { - case 27: -#ifdef TEXTURE_OBJECT - glDeleteTextures( 2, TexObj ); -#endif - glutDestroyWindow(Window); - exit(0); - } -} - - - -/* new window size or exposure */ -static void reshape( int width, int height ) -{ - glViewport(0, 0, (GLint)width, (GLint)height); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - /* glOrtho( -3.0, 3.0, -3.0, 3.0, -10.0, 10.0 );*/ - glFrustum( -2.0, 2.0, -2.0, 2.0, 6.0, 20.0 ); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef( 0.0, 0.0, -8.0 ); -} - - -static void init( void ) -{ - static int width=8, height=8; - static GLubyte tex1[] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 0, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, - 0, 0, 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 1, 0, 0, 0, - 0, 0, 0, 1, 1, 1, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 }; - - static GLubyte tex2[] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 2, 2, 0, 0, 0, - 0, 0, 2, 0, 0, 2, 0, 0, - 0, 0, 0, 0, 0, 2, 0, 0, - 0, 0, 0, 0, 2, 0, 0, 0, - 0, 0, 0, 2, 0, 0, 0, 0, - 0, 0, 2, 2, 2, 2, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 }; - - GLubyte tex[64][3]; - GLint i, j; - - - glDisable( GL_DITHER ); - - /* Setup texturing */ - glEnable( GL_TEXTURE_2D ); - glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL ); - glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST ); - - - /* generate texture object IDs */ - if (UseObj) { -#ifdef TEXTURE_OBJECT - glGenTextures( 2, TexObj ); -#endif - } - else { - TexObj[0] = glGenLists(2); - TexObj[1] = TexObj[0]+1; - } - - /* setup first texture object */ - if (UseObj) { -#ifdef TEXTURE_OBJECT - glBindTexture( GL_TEXTURE_2D, TexObj[0] ); - assert(glIsTexture(TexObj[0])); -#endif - } - else { - glNewList( TexObj[0], GL_COMPILE ); - } - /* red on white */ - for (i=0;i +#include +#include +#include +#include +#include "GL/glut.h" + +static GLuint Window = 0; + +static GLuint TexObj[2]; +static GLfloat Angle = 0.0f; +static GLboolean UseObj = GL_FALSE; + + +#if defined(GL_VERSION_1_1) || defined(GL_VERSION_1_2) +# define TEXTURE_OBJECT 1 +#elif defined(GL_EXT_texture_object) +# define TEXTURE_OBJECT 1 +# define glBindTexture(A,B) glBindTextureEXT(A,B) +# define glGenTextures(A,B) glGenTexturesEXT(A,B) +# define glDeleteTextures(A,B) glDeleteTexturesEXT(A,B) +#endif + + + + +static void draw( void ) +{ + glClear( GL_COLOR_BUFFER_BIT ); + + glColor3f( 1.0, 1.0, 1.0 ); + + /* draw first polygon */ + glPushMatrix(); + glTranslatef( -1.0, 0.0, 0.0 ); + glRotatef( Angle, 0.0, 0.0, 1.0 ); + if (UseObj) { +#ifdef TEXTURE_OBJECT + glBindTexture( GL_TEXTURE_2D, TexObj[0] ); +#endif + } + else { + glCallList( TexObj[0] ); + } + glBegin( GL_POLYGON ); + glTexCoord2f( 0.0, 0.0 ); glVertex2f( -1.0, -1.0 ); + glTexCoord2f( 1.0, 0.0 ); glVertex2f( 1.0, -1.0 ); + glTexCoord2f( 1.0, 1.0 ); glVertex2f( 1.0, 1.0 ); + glTexCoord2f( 0.0, 1.0 ); glVertex2f( -1.0, 1.0 ); + glEnd(); + glPopMatrix(); + + /* draw second polygon */ + glPushMatrix(); + glTranslatef( 1.0, 0.0, 0.0 ); + glRotatef( Angle-90.0, 0.0, 1.0, 0.0 ); + if (UseObj) { +#ifdef TEXTURE_OBJECT + glBindTexture( GL_TEXTURE_2D, TexObj[1] ); +#endif + } + else { + glCallList( TexObj[1] ); + } + glBegin( GL_POLYGON ); + glTexCoord2f( 0.0, 0.0 ); glVertex2f( -1.0, -1.0 ); + glTexCoord2f( 1.0, 0.0 ); glVertex2f( 1.0, -1.0 ); + glTexCoord2f( 1.0, 1.0 ); glVertex2f( 1.0, 1.0 ); + glTexCoord2f( 0.0, 1.0 ); glVertex2f( -1.0, 1.0 ); + glEnd(); + glPopMatrix(); + + glutSwapBuffers(); +} + + + +static void idle( void ) +{ + static double t0 = -1.; + double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0; + if (t0 < 0.0) + t0 = t; + dt = t - t0; + t0 = t; + Angle += 120.0*dt; + glutPostRedisplay(); +} + + + +/* change view Angle, exit upon ESC */ +static void key(unsigned char k, int x, int y) +{ + (void) x; + (void) y; + switch (k) { + case 27: +#ifdef TEXTURE_OBJECT + glDeleteTextures( 2, TexObj ); +#endif + glutDestroyWindow(Window); + exit(0); + } +} + + + +/* new window size or exposure */ +static void reshape( int width, int height ) +{ + glViewport(0, 0, (GLint)width, (GLint)height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + /* glOrtho( -3.0, 3.0, -3.0, 3.0, -10.0, 10.0 );*/ + glFrustum( -2.0, 2.0, -2.0, 2.0, 6.0, 20.0 ); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -8.0 ); +} + + +static void init( void ) +{ + static int width=8, height=8; + static GLubyte tex1[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 1, 1, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0 }; + + static GLubyte tex2[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 2, 2, 0, 0, 0, + 0, 0, 2, 0, 0, 2, 0, 0, + 0, 0, 0, 0, 0, 2, 0, 0, + 0, 0, 0, 0, 2, 0, 0, 0, + 0, 0, 0, 2, 0, 0, 0, 0, + 0, 0, 2, 2, 2, 2, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0 }; + + GLubyte tex[64][3]; + GLint i, j; + + + glDisable( GL_DITHER ); + + /* Setup texturing */ + glEnable( GL_TEXTURE_2D ); + glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL ); + glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST ); + + + /* generate texture object IDs */ + if (UseObj) { +#ifdef TEXTURE_OBJECT + glGenTextures( 2, TexObj ); +#endif + } + else { + TexObj[0] = glGenLists(2); + TexObj[1] = TexObj[0]+1; + } + + /* setup first texture object */ + if (UseObj) { +#ifdef TEXTURE_OBJECT + glBindTexture( GL_TEXTURE_2D, TexObj[0] ); + assert(glIsTexture(TexObj[0])); +#endif + } + else { + glNewList( TexObj[0], GL_COMPILE ); + } + /* red on white */ + for (i=0;i