Jump to content
  • Advertisement
Sign in to follow this  
thorpe

wrapping textures won't work :(

This topic is 5111 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

I can't get my wrapping functions to work. I call
TexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
TexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT));
TexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
TexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST));

Before calling glTexImage2D (well actually I don't call this myself but through DevIL, an image loading library). But it doesn't wrap when I paint it.
   glEnable(GL_TEXTURE_2D);
   glBindTexture(GL_TEXTURE_2D, TextureManager::Instance().GetBoardTexture());
   glColor3f(1.0,1.0,1.0);
   glBegin(GL_QUADS);
      glNormal3f(0.0,0.0,1.0);
      glTexCoord2f(0.0f,0.0f);        glVertex2d(0.0,0.0);
      glTexCoord2f(1.0f,0.0f);     glVertex2d(1366.0,0.0);    
      glTexCoord2f(1.0f,1.0f);   glVertex2d(1366.0,768.0);
      glTexCoord2f(0.0f,1.0f);      glVertex2d(0.0,768.0);   
   glEnd();    
   glDisable(GL_TEXTURE_2D);  

Am I missing something or could it be that I am using DevIL instead of calling glTexImage2D? Here is the exact texture creation code for those interested
ilBindImage (mImgID);
glBindTexture(GL_TEXTURE_2D, mName);
	
bool mipmap=false;
std::vector<TextureParameter>::iterator it = mParameters.begin();
    for(; it!=mParameters.end();it++){
      it->Apply();
      if(it->param == GL_LINEAR_MIPMAP_LINEAR || 
         it->param == GL_LINEAR_MIPMAP_NEAREST ||
         it->param == GL_NEAREST_MIPMAP_LINEAR || 
         it->param == GL_NEAREST_MIPMAP_NEAREST){
	   mipmap=true;
   }
}  

ilutGLTexImage(0);	
if(mipmap){
  ilutGLBuildMipmaps();	
}
    

ilDeleteImages(1, &mImgID);


it->Apply() calls the glTexParameteri in a TextureParameter struct. Thanks in advance...

Share this post


Link to post
Share on other sites
Advertisement
You mean it doesn't repeat? That's because the texture coordinates are in the range [0..1]. Try something like this:
   glBegin(GL_QUADS);
glNormal3f(0.0,0.0,1.0);
glTexCoord2f(0.0f,0.0f); glVertex2d(0.0,0.0);
glTexCoord2f(10.0f,0.0f); glVertex2d(1366.0,0.0);
glTexCoord2f(10.0f,10.0f); glVertex2d(1366.0,768.0);
glTexCoord2f(0.0f,10.0f); glVertex2d(0.0,768.0);
glEnd();

Share this post


Link to post
Share on other sites
Also, you need to call the glTexParameteri stuff AFTER the glBindTexture call in your texture loader routine.
All calls of glTexParameteri alter the state of the currently bound texture, so if no texture is bound at that stage, nothing happens.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!