Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


I have problem using more than 1 texture


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Evil-Dog   Members   -  Reputation: 122

Like
Likes
Like

Posted 14 August 2001 - 04:14 PM

Hi ! I''m quite new to openGL and I want to apply 2 textures on a cube. But it seems the second textures I load overwrite the first one and my cube is half white and half textured when I render it. this is my code where I load the 2 textures : if( !LoadTexture( "metal.bmp", m_tabTexture[0] ) ) { return false; } if( !LoadTexture( "space.bmp", m_tabTexture[1] ) ) { return false; } And this is my LoadTexture() Function : bool C3DObject::LoadTexture( string strFileName, GLuint &objTexture ) { int Status = FALSE; AUX_RGBImageRec* ptrTextureImage = NULL; FILE* ptrFile = NULL; ptrFile = fopen( strFileName.c_str(), "r" ); if( ptrFile ) { fclose( ptrFile ); ptrTextureImage = auxDIBImageLoad( strFileName.c_str() ); } if( ptrTextureImage ) { glGenTextures(1, &objTexture); glBindTexture(GL_TEXTURE_2D, objTexture); glTexImage2D(GL_TEXTURE_2D, 0, 3, ptrTextureImage->sizeX, ptrTextureImage->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, ptrTextureImage->data); } if( ptrTextureImage ) { if( ptrTextureImage->data ) { free( ptrTextureImage->data ); } free( ptrTextureImage ); } return true; } And I render my cube this way : glBindTexture(GL_TEXTURE_2D, GetTexture(0)); glBegin(GL_QUADS); // Front Face glNormal3f( 0.0f, 0.0f, 1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); // Back Face glNormal3f( 0.0f, 0.0f,-1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); // Top Face glNormal3f( 0.0f, 1.0f, 0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, 1.0f, 1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); glEnd(); glBindTexture(GL_TEXTURE_2D, GetTexture(1)); glBegin(GL_QUADS); // Bottom Face glNormal3f( 0.0f,-1.0f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); // Right face glNormal3f( 1.0f, 0.0f, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); // Left Face glNormal3f(-1.0f, 0.0f, 0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); glEnd(); So as I said only the second texture ( space.bmp ) is rendered correctly. The other one is all white I tried them alone and both of them is rendered correctly but If I try to put both texture on the cube it doesn''t work. Help please. Hope My problem is clear. Thanks alot !

Sponsor:

#2 mittens   Moderators   -  Reputation: 1323

Like
Likes
Like

Posted 15 August 2001 - 03:05 AM

Hey, you have to use multitexturing (NeHe has a tutorial on it over at http://nehe.gamedev.net), so go check it out..... NOW!

------------------------------
Trent (ShiningKnight)
E-mail me
Shining Darkness- A division of Chromesphere Studios

#3 Evil-Dog   Members   -  Reputation: 122

Like
Likes
Like

Posted 15 August 2001 - 03:39 AM

You probably think I want to use multiple textures for blending on a same face
But what I want to do is draw a texture on 3 faces and another texture on the other 3 faces of the cube
Can you help ? someone ? hehe

#4 Grudzio   Members   -  Reputation: 122

Like
Likes
Like

Posted 15 August 2001 - 11:47 AM

Try changing declaration of LoadTexture function
from LoadTexture(string strFileName, GLint &objtexture) to
LoadTexture(string strFileName, GLint objTexture). Maybe this will help.

K.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS