Removed all RCS / CVS tags (Id, Header, Date, etc.) from everything.
[mesa.git] / progs / demos / texobj.c
index 56915a7c082276ea4050f5bea2e0280915d01d33..ff701e98c3b4bd5de6a38bbd88880301d595658f 100644 (file)
@@ -1,4 +1,3 @@
-/* $Id: texobj.c,v 1.2 2000/02/25 23:24:06 brianp Exp $ */
 
 /*
  * Example of using the 1.1 texture object functions.
@@ -7,25 +6,9 @@
  * Brian Paul   June 1996   This file is in the public domain.
  */
 
-
-/*
- * $Log: texobj.c,v $
- * Revision 1.2  2000/02/25 23:24:06  brianp
- * fixed bug when using display lists
- *
- * Revision 1.1.1.1  1999/08/19 00:55:40  jtg
- * Imported sources
- *
- * Revision 3.1  1999/03/28 18:24:37  brianp
- * minor clean-up
- *
- * Revision 3.0  1998/02/14 18:42:29  brianp
- * initial rev
- *
- */
-
-
+#include <assert.h>
 #include <math.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include "GL/glut.h"
@@ -34,10 +17,10 @@ static GLuint Window = 0;
 
 static GLuint TexObj[2];
 static GLfloat Angle = 0.0f;
-static GLboolean HaveTexObj = GL_FALSE;
+static GLboolean UseObj = GL_FALSE;
 
 
-#if defined(GL_VERSION_1_1)
+#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
@@ -61,7 +44,7 @@ static void draw( void )
    glPushMatrix();
    glTranslatef( -1.0, 0.0, 0.0 );
    glRotatef( Angle, 0.0, 0.0, 1.0 );
-   if (HaveTexObj) {
+   if (UseObj) {
 #ifdef TEXTURE_OBJECT
       glBindTexture( GL_TEXTURE_2D, TexObj[0] );
 #endif
@@ -81,7 +64,7 @@ static void draw( void )
    glPushMatrix();
    glTranslatef( 1.0, 0.0, 0.0 );
    glRotatef( Angle-90.0, 0.0, 1.0, 0.0 );
-   if (HaveTexObj) {
+   if (UseObj) {
 #ifdef TEXTURE_OBJECT
       glBindTexture( GL_TEXTURE_2D, TexObj[1] );
 #endif
@@ -177,7 +160,7 @@ static void init( void )
 
 
    /* generate texture object IDs */
-   if (HaveTexObj) {
+   if (UseObj) {
 #ifdef TEXTURE_OBJECT
       glGenTextures( 2, TexObj );
 #endif
@@ -188,9 +171,10 @@ static void init( void )
    }
 
    /* setup first texture object */
-   if (HaveTexObj) {
+   if (UseObj) {
 #ifdef TEXTURE_OBJECT
       glBindTexture( GL_TEXTURE_2D, TexObj[0] );
+      assert(glIsTexture(TexObj[0]));
 #endif
    }
    else {
@@ -215,16 +199,18 @@ static void init( void )
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
-   if (!HaveTexObj) {
+   if (!UseObj) {
       glEndList();
    }
    /* end of texture object */
 
    /* setup second texture object */
-   if (HaveTexObj) {
+   if (UseObj) {
 #ifdef TEXTURE_OBJECT
       glBindTexture( GL_TEXTURE_2D, TexObj[1] );
+      assert(glIsTexture(TexObj[1]));
 #endif
+      assert(!glIsTexture(TexObj[1] + 999));
    }
    else {
       glNewList( TexObj[1], GL_COMPILE );
@@ -247,7 +233,7 @@ static void init( void )
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
-   if (!HaveTexObj) {
+   if (!UseObj) {
       glEndList();
    }
    /* end texture object */
@@ -258,6 +244,7 @@ static void init( void )
 
 int main( int argc, char *argv[] )
 {
+   glutInit(&argc, argv);
    glutInitWindowPosition(0, 0);
    glutInitWindowSize(300, 300);
    glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );
@@ -275,8 +262,9 @@ int main( int argc, char *argv[] )
       char *exten = (char *) glGetString( GL_EXTENSIONS );
       char *version = (char *) glGetString( GL_VERSION );
       if (   strstr( exten, "GL_EXT_texture_object" )
-          || strncmp( version, "1.1", 3 )==0 ) {
-         HaveTexObj = GL_TRUE;
+          || strncmp( version, "1.1", 3 )==0
+          || strncmp( version, "1.2", 3 )==0 ) {
+         UseObj = GL_TRUE;
       }
    }
 #endif