Sign in to follow this  
thorpe

wrapping textures won't work :(

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this