-/* $Id: texobj.c,v 1.2 2000/02/25 23:24:06 brianp Exp $ */
/*
* Example of using the 1.1 texture object functions.
* 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"
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
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
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
/* generate texture object IDs */
- if (HaveTexObj) {
+ if (UseObj) {
#ifdef TEXTURE_OBJECT
glGenTextures( 2, TexObj );
#endif
}
/* setup first texture object */
- if (HaveTexObj) {
+ if (UseObj) {
#ifdef TEXTURE_OBJECT
glBindTexture( GL_TEXTURE_2D, TexObj[0] );
+ assert(glIsTexture(TexObj[0]));
#endif
}
else {
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 );
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 */
int main( int argc, char *argv[] )
{
+ glutInit(&argc, argv);
glutInitWindowPosition(0, 0);
glutInitWindowSize(300, 300);
glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );
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