Jump to content
  • Advertisement

Archived

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

kmaz

Texture Mapping

This topic is 5492 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''m trying to manually texture map a quad. I set it''s upper left, upper right, lower left, and lower right corners to have coordinates of a texture. It works, but something wierd happens. My texture seems to be split in half and the sides switch. This might not makes sense, so I made picture showing what is happening. www.psidimension.com/problem.gif The left picture is the bitmap I give it, and the right is what openGL displays. Any ideas?

Share this post


Link to post
Share on other sites
Advertisement
Your texture coordinates are probably bad, could you post the code where you draw your quad ?

Share this post


Link to post
Share on other sites
glBegin(GL_POLYGON);
glTexCoord2f(1,1); glVertex3f(m_ptUL.m_fX, m_ptUL.m_fY, m_ptUL.m_fZ);
glTexCoord2f(1,0.0); glVertex3f(m_ptLR.m_fX, m_ptUL.m_fY, m_ptUL.m_fZ);
glTexCoord2f(0.0,1); glVertex3f(m_ptLR.m_fX, m_ptLR.m_fY, m_ptUL.m_fZ);
glTexCoord2f(0.0,0.0); glVertex3f(m_ptUL.m_fX, m_ptLR.m_fY, m_ptUL.m_fZ);
glEnd();

Share this post


Link to post
Share on other sites
This really doesn't help me, since i can't know wich of your vertices is the bottom left one, the top left one etc ...

so :

your bottom left vertex should have those tex coord : (0,0)
bottom right : (1,0)
top right : (1,1)
top left (0,1)

Is this what you do ?

[edited by - Sphax on July 6, 2003 5:37:38 AM]

Share this post


Link to post
Share on other sites
It doesn''t matter. Post your texture loading code and your texture size, it must be a power of 2 if you aren''t using gluBuild2DMipMaps().

"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"

Share this post


Link to post
Share on other sites
Sorry, heres the code I use to initiate the texture:



FILE *fp;
int nMemory;
PSI_BITMAP_IMAGE pbiTexture;

fp = fopen(szPath, "rb");
fread(&pbiTexture.bmfHeader, 1, 14, fp);
fread(&pbiTexture.bmiHeader, 1, 40, fp);

if (pbiTexture.bmiHeader.biSizeImage == 0)
{
nMemory = pbiTexture.bmiHeader.biWidth * pbiTexture.bmiHeader.biHeight * 4;
}
else
{
nMemory = pbiTexture.bmiHeader.biSizeImage;
}

pbiTexture.image_data= new GLubyte[nMemory];

fread(pbiTexture.image_data , 1, nMemory, fp);
fclose(fp);

glPixelStorei(GL_UNPACK_ALIGNMENT,1);
glGenTextures(1, &m_nTexture);
glBindTexture(GL_TEXTURE_2D, m_nTexture);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, pbiTexture.bmiHeader.biWidth, pbiTexture.bmiHeader.biHeight, GL_BGR_EXT, GL_UNSIGNED_BYTE, pbiTexture.image_data);

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);


delete[] pbiTexture.image_data;

Share this post


Link to post
Share on other sites
Long time since used opengl.

Looks like your texture coordinates are wrong and your texture is repeating?

Share this post


Link to post
Share on other sites
right now its 47x43, but I could change it to a size with more round dimensions (45x45 or 50x50) if I need to.

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!