Jump to content
  • Advertisement

Archived

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

cavendish

Skybox problem!

This topic is 5848 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 am doing, my first game, a 3D shooter, bla,bla and I came to the point where I need a skybox. Well, I robbed a game it''s skybox (where it looked great, unfortunately I don''t have the game''s code) and I used those pics in my little game. My problem is that if I fit those textures on a cube(with only 5 faces, TOP, FRONT, LEFT, RIGHT, BACK), I get some strange lines between them. If I get the pics and if I stick them together in msPant, they fit and look good.I believe I have to do something with the code, so help please! You can look at some screenshots and at the code I use at www.cavendish.home.ro.

Share this post


Link to post
Share on other sites
Advertisement
This is the function for loading textures:

void CreateTexture(UINT textureArray[], LPSTR strFileName, int textureID)
{
AUX_RGBImageRec *pBitmap = NULL;
if(!strFileName)
return;
pBitmap = auxDIBImageLoad(strFileName);
if(pBitmap == NULL)
exit(0);
glGenTextures(1, &textureArray[textureID]);
glBindTexture(GL_TEXTURE_2D, textureArray[textureID]);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, pBitmap->sizeX, pBitmap->sizeY, GL_RGB, GL_UNSIGNED_BYTE, pBitmap->data);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);
if (pBitmap)
{
if (pBitmap->data)
free(pBitmap->data);
free(pBitmap);
}
}

RipTorn, I can't find GL_WRAP here.


[edited by - cavendish on September 15, 2002 5:41:46 AM]

Share this post


Link to post
Share on other sites

  
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);

GL_LINEAR_MIPMAP_LINEAR is not a valid magnification filter. Only GL_LINEAR and GL_NEAREST are valid.

Anyways, try put these two lines in your code. This is what RipTorn was talking about.

  
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);

Share this post


Link to post
Share on other sites
Wow!!!
Thanks Brother Bob, RipTorn!!!!
It looks super!!!
Who thought I can solve my problem in 30min after 5 hours of veryfing .....
Thanks!!

Share this post


Link to post
Share on other sites
Using GL_CLAMP will make lines appear just the way you described in non-nvidia cards.

The proper way, as someone suggested, is to use GL_CLAMP_TO_EDGE.
It's not part of OpenGL 1.1 but all major cards support this extension.

Just add the following before all your code:

  
#define GL_CLAMP_TO_EDGE 0x812F


The reason it works in nvidia cards is because they make GL_CLAMP act like GL_CLAMP_TO_EDGE, but they're different things. Anyway, there's some option in the new drivers that make it work properly.

[edited by - t0y on September 15, 2002 10:44:30 PM]

Share this post


Link to post
Share on other sites
t0y: you''re absolutely right ! For more informations on clamping textures, read the short note that Patrick Brown (one of the driver developers from NVIDIA) wrote on OpenGL.org Discussion & Help Forums.
Though you have to know that GL_CLAMP_TO_EDGE is not supported by OpenGL1.0, that is you MAY not be able to use it on a few cards. As a positive note, almost all cards support it today.
You can find a non-exhaustive list of cards that support the extension GL_SGI_texture_edge_clamp, GL_SGIS_texture_edge_clamp and GL_EXT_texture_edge_clamp. All those extensions allow the usage of GL_CLAMP_TO_EDGE.

Share this post


Link to post
Share on other sites
hmm. well. I''ve seen cases where CLAMP_TO_EDGE badly corrupted the textures... where GL_CLAMP didn''t.. but that was on a fairly dodgy laptop...

<-- smile :-)

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!