
Skybox problem!
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.

--------Whatever
clamp your textures...
instead of GL_WRAP, use GL_CLAMP or GL_CLAMP_TO_EDGE when loading.
<-- smile :-)
instead of GL_WRAP, use GL_CLAMP or GL_CLAMP_TO_EDGE when loading.

This is the function for loading textures:
RipTorn, I can't find GL_WRAP here.
[edited by - cavendish on September 15, 2002 5:41:46 AM]
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]
--------Whatever
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);
Wow!!!
Thanks Brother Bob, RipTorn!!!!
It looks super!!!
Who thought I can solve my problem in 30min after 5 hours of veryfing .....
Thanks!!
Thanks Brother Bob, RipTorn!!!!
It looks super!!!

Thanks!!
--------Whatever
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:
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]
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]
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement