Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

ltrain_riders

Help with Texture Mapping and Nehe's TUT 24

This topic is 5860 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Well I adopted nehe''s example in tut #24 for texture mapping .TGA files. I can get it to texture map using the Floor.TGA file but File.TGA does not work. I tried using the File.TGA in textures[0].textID and the base won''t texture map. When I swap "file.TGA" and "Floor.TGA" back, it works but "file.TGA still doesn''t. I''m suspecting something is wrong with my File.TGA but I''m not completely sure. I used 123Graphic Converter to convert the once JPEG into the current TGA file. here is my code http://sourcepost.sytes.net/sourcepost/sourceview.aspx?source_id=1573

Share this post


Link to post
Share on other sites
Advertisement
No it is not the file. The problem has to do with the if statement in void init( ). I have if( (LoadTGA(&textures[0],"wood.TGA")) || (LoadTGA(&textures[1],"Floor.TGA") )) { }
Any .TGA file will load and texture map in &textures[0] but if I try to use that same texture, or any other texture and load it in &textures[1], my objects binded to textures[1] wont be that texture, the objects turn gray. I don''t know if my LoadTGA function is properly generating the second texture. I adopted Nehe''s code from Tutorial #24 because I can''t get glaux.h to work so I use the method of loading .TGA files. Here''s my code:
http://sourcepost.sytes.net/sourcepost/sourceview.aspx?source_id=1611
can somebody help me and tell me what i''m doing wrong and correct.

Share this post


Link to post
Share on other sites
// Build A Texture From The Data
glGenTextures(2, &texture[0].texID); // Generate OpenGL texture IDs
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
glBindTexture(GL_TEXTURE_2D, texture[0].texID); // Bind Our Texture
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // Linear Filtered
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // Linear Filtered

if (texture[0].bpp==24) // Was The TGA 24 Bits
{
type=GL_RGB; // If So Set The 'type' To GL_RGB
}
glTexImage2D(GL_TEXTURE_2D, 0, type, texture[0].width, texture[0].height, 0, type, GL_UNSIGNED_BYTE, texture[0].imageData);

--------
You seem to be only creating the [0] texture you have to do that for the [1] too.Try that and see what happens.
O_o


World of Entaria|Shadowy Tree
Omnium rerum principia parva sunt.
Think twice before you code!!
Black Knight

[edited by - Black Knight on November 4, 2002 1:43:45 AM]

Share this post


Link to post
Share on other sites
The problem was I was using || in my if statement inside the intit() so I switched to &&; this way both loads get called. However my next problem is resizing my screen. When I press ''f'' and ''w'' to resize the screen I lose my textures.
Here''s my updated code:
http://sourcepost.sytes.net/sourcepost/sourceview.aspx?source_id=1637

Share this post


Link to post
Share on other sites
How is it possible to texture map N amount of time across the face of an object using this code:
glBegin(GL_QUADS);
glTexCoord2f( 10.0f, 10.0f );glVertex3f( 5.1f, 0.1f, -4.1f );// back right
glTexCoord2f( 0.0f, 10.0f );glVertex3f( -5.1f, 0.1f, -4.1f );//back left
glTexCoord2f( 0.0f, 0.0f );glVertex3f( -5.1f, 0.1f, 4.1f );//front left
glTexCoord2f( 10.0f, 0.0f );glVertex3f( 5.1f, 0.1f, 4.1f ); //front right

/* bottom of base */
glTexCoord2f( 10.0f, 10.0f );glVertex3f( 5.1f, 0.0f, -4.1f );// back right
glTexCoord2f( 0.0f, 10.0f );glVertex3f( -5.1f, 0.0f, -4.1f );//back left
glTexCoord2f( 0.0f, 0.0f );glVertex3f( -5.1f, 0.0f, 4.1f );//front left
glTexCoord2f( 10.0f, 0.0f );glVertex3f( 5.1f, 0.0f, 4.1f ); //front right

/* right side of base */
glTexCoord2f( 10.0f, 10.0f );glVertex3f( 5.1f, 0.1f, -4.1f );//top right
glTexCoord2f( 0.0f, 10.0f );glVertex3f( 5.1f, 0.1f, 4.1f );//top left
glTexCoord2f( 0.0f, 0.0f );glVertex3f( 5.1f, 0.0f, 4.1f );//bottom left
glTexCoord2f( 10.0f, 0.0f );glVertex3f( 5.1f, 0.0f, -4.1f );//bottom right

/* left side of base */
glTexCoord2f( 10.0f, 10.0f );glVertex3f( -5.1f, 0.1f, 4.1f );//top right
glTexCoord2f( 0.0f, 10.0f );glVertex3f( -5.1f, 0.1f, -4.1f );//top left
glTexCoord2f( 0.0f, 0.0f );glVertex3f( -5.1f, 0.0f, -4.1f );//bottom left
glTexCoord2f( 10.0f, 0.0f );glVertex3f( -5.1f, 0.0f, 4.1f );//bottom right

/* front of base */
glTexCoord2f( 10.0f, 10.0f );glVertex3f( 5.1f, 0.1f, 4.1f );//top right
glTexCoord2f( 0.0f, 10.0f );glVertex3f( -5.1f, 0.1f, 4.1f );//top left
glTexCoord2f( 0.0f, 0.0f );glVertex3f( -5.1f, 0.0f, 4.1f );//bottom left
glTexCoord2f( 10.0f, 0.0f );glVertex3f( 5.1f, 0.0f, 4.1f );//bottom right

/* back of base */
glTexCoord2f( 10.0f, 10.0f );glVertex3f( 5.1f, 0.1f, -4.1f );//top right
glTexCoord2f( 0.0f, 10.0f );glVertex3f( -5.1f, 0.1f, -4.1f );//top left
glTexCoord2f( 0.0f, 0.0f );glVertex3f( -5.1f, 0.0f, -4.1f );//bottom left
glTexCoord2f( 10.0f, 0.0f );glVertex3f( 5.1f, 0.0f, -4.1f );//bottom right
glEnd( );

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!