PDA

View Full Version : OpenGL multitexturing problem (of course its in windows)



vicho
12-26-2003, 11:56 AM
hello i have the next problem, when i render a polygon in ogl using multitexturing i only can render one polygon using multitexturing, the next code is what i use

GenTexture its for generate the texture

the wierd its that the programn works fine in linux, windows its the problem...(W2K)

anyone knows how can i fix that thing?

typedef void (*GL_ActiveTextureARB)(unsigned int);
typedef void (*GL_MultiTexCoord2fARB)(unsigned int,float,float);
GL_ActiveTextureARB glActiveTextureARB;
GL_MultiTexCoord2fARB glMultiTexCoord2fARB;

int main(int argc,char *argv[])
{
GLuint texture[2];
SDL_Surface *screen;
SDL_Init(SDL_INIT_VIDEO);
screen=SDL_SetVideoMode(640,480,0,SDL_SWSURFACE|SD L_OPENGL);
glActiveTextureARB=(GL_ActiveTextureARB) SDL_GL_GetProcAddress(glActiveTextureARB");

glClientActiveTextureARB=(GL_ClientActiveTextureAR B)SDL_GL_GetProcAddress("glClientActiveTextureARB");
glMultiTexCoord2fARB=(GL_MultiTexCoord2fARB)SDL_GL _GetProcAddress("glMultiTexCoord2fARB");

glEnable( GL_TEXTURE_2D );
glShadeModel( GL_SMOOTH );
glClearColor( 0.0f, 0.0f, 0.0f, 0.5f );
glClearDepth( 1.0f );
glEnable( GL_DEPTH_TEST );
glDepthFunc( GL_LEQUAL );
glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );
glViewport( 0, 0, ( GLsizei )640, ( GLsizei )480 );
glMatrixMode( GL_PROJECTION );
glLoadIdentity( );
gluPerspective( 45.0f, 640/480, 0.1f, 100.0f );
glMatrixMode( GL_MODELVIEW );

glLoadIdentity( );

GenTexture("00.jpg",&texture[0]);
GenTexture("01.jpg",&texture[1]);

glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glLoadIdentity( );
glTranslatef( 0.0f, 0.0f, -5.0f );

glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable( GL_TEXTURE_2D );
glBindTexture(GL_TEXTURE_2D,texture[0]);

glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable( GL_TEXTURE_2D );
glBindTexture(GL_TEXTURE_2D,texture[1]);

glBegin(GL_QUADS);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB,0.0f, 0.0f);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0.0f, 0.0f);
glVertex3f(-1.0f, -1.0f, 1.0f);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB,1.0f, 0.0f);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,1.0f, 0.0f);
glVertex3f( 1.0f, -1.0f, 1.0f);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB,1.0f, 1.0f);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,1.0f, 1.0f);
glVertex3f( 1.0f, 1.0f, 1.0f);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB,0.0f, 1.0f);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0.0f, 1.0f);
glVertex3f(-1.0f, 1.0f, 1.0f);
glEnd();

SDL_GL_SwapBuffers( );
SDL_Delay(5000);

glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glLoadIdentity( );
glTranslatef( 0.0f, 0.0f, -5.0f );

glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable( GL_TEXTURE_2D );
glBindTexture(GL_TEXTURE_2D,texture[0]);

glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable( GL_TEXTURE_2D );
glBindTexture(GL_TEXTURE_2D,texture[1]);

glBegin(GL_QUADS);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB,0.0f, 0.0f);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0.0f, 0.0f);
glVertex3f(-1.0f, -1.0f, 1.0f);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB,1.0f, 0.0f);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,1.0f, 0.0f);
glVertex3f( 1.0f, -1.0f, 1.0f);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB,1.0f, 1.0f);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,1.0f, 1.0f);
glVertex3f( 1.0f, 1.0f, 1.0f);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB,0.0f, 1.0f);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0.0f, 1.0f);
glVertex3f(-1.0f, 1.0f, 1.0f);
glEnd();

SDL_GL_SwapBuffers( );
SDL_Delay(5000);
}