Skip to main content
GameDev.net gamedev.net
🔒 Locked

Skybox

Started by snewt Nov 18, 2009 at 5:10 AM 8 replies 1.7k views
Original Post
snewt
snewt
Hello! I'm programming a skybox with opengl and I don't succeed to apply textures on the cube without using glaux. I don't know where to search, so if anybody could help me that would be very nice! Here the file I work on: http://tershooter.free.fr/skybox.cpp Thanks a lot and have good afternoon!
LordSputnik
LordSputnik
From your code, it looks like you're using GL_TEXTURE_CUBE_MAP...

At the moment you're using your own 3D texture co-ordinates with the t variable... they're probably fine, I haven't actually written co-ordinates for 3D textures before, but it might be that they're wrong...

It might be worth a try automatically generating the co-ordinates with OpenGL, by using the glTexGen() funtion, which is what I've done in the past!

I just had a problem related to this, so you might find these helpful:
http://www.gamedev.net/community/forums/topic.asp?topic_id=553586
http://developer.nvidia.com/object/cube_map_ogl_tutorial.html

Hope it helps, if you're still not making any progress, post up a screenshot of your problem if you can, then people will be able to help you more. Cause we don't know if your skybox is black, blank, or somewhere in between... :P

Bonne chance!
snewt
snewt
Thanks for your replies. I'll see your links.
With this GL_TEXTURE_CUBE_MAP, I have a white skybox. I try also with GL_TEXTURE_2D (not in the code up) but my texture is repeated four times (on the left of the picture) on each face and there is a problem with some faces (on the right, see this screenshot: http://tershooter.free.fr/skybox.PNG).
snewt
snewt
Thank you for your help, now I manage to apply the textures. But it's ugly ^^ :the effect is as if I have my head stuck in the texture, it makes big ugly packets. What settings or coordinates must be changed to improve the result?
LordSputnik
LordSputnik
Can you get another screenshot? Not sure what you mean...
snewt
snewt
Here the skybox: http://tershooter.free.fr/skybox2.PNG, and here the original texture: http://tershooter.free.fr/skybox3.PNG.
szecs
szecs
That's a very bad benchmarking texture. It's almost completely black, so it's impossible to say anything about it.

And one thing: you assign texture coordinates in the -t ... +t range,
that means -1.0 to +1.0, You have to use 0.0 to +1.0 range. Or the GL_TEXTURE_CUBE_MAP_ARB has to use it this way?
If so, than sorry.

And an other thing, I think you mix the GL_TEXTURE_CUBE_MAP_ARB thing and the naive rendering method (simply textured quads without any extensions).

Try to comment out the GL_TEXTURE_CUBE_MAP_ARB things, and simple render the cube in the naive way: bind the current sky texture before each of the quads.
glBindTexture(GL_TEXTURE 2D, texture_image[0]);	glBegin(GL_TRIANGLE_STRIP);			// X Négatif				glTexCoord2f(0,0); glVertex3f(-t,-t,-t); 			glTexCoord2f(1,0); glVertex3f(-t,t,-t);		glTexCoord2f(1,1); glVertex3f(-t,-t,t);		glTexCoord2f(0,1); glVertex3f(-t,t,t);	glEnd();glBindTexture(GL_TEXTURE 2D, texture_image[1]);	glBegin(GL_TRIANGLE_STRIP);			// X Positif				glTexCoord2f(0,0); glVertex3f(...); 			glTexCoord2f(1,0); glVertex3f(...);		glTexCoord2f(1,1); glVertex3f(...);		glTexCoord2f(0,1); glVertex3f(...);	glEnd();...
snewt
snewt
My texture is black because it represents the space. It's true it's hard to say something it's why I focus the screenshot on the planet.

Here is my new code that generate this screenshot: http://tershooter.free.fr/skyboxGLUT.c

I don't use GL_TEXTURE_CUBE_MAP_ARB but GL_TEXTURE_2D now.
LordSputnik
LordSputnik
A suggestion: try inverting the colours of your skybox image just for now, it'll speed up bug fixing. You can switch it back later :)

Also, looking at your display list code, you seem to be drawing the Bottom texture on the back, and the back texture on the bottom.

If this is a problem, then you can fix it by switching the y and z co-ordinates for the top four quads.

Also, these lines:

// le centre du cube doit se trouver à la position x,y,zx = x - width  / 2;y = y - height / 2;z = z - length / 2;


Aren't doing anything in the display list. Keep the movement of the box in your glutDisplay function, along with the glRotatef() calls.

Also, you may want to double the resolution of your textures to 1024 x 1024. It might help to reduce your "head stuck in the texture" problem.

Hope that this helps!

Sputty

[Edited by - LordSputnik on November 20, 2009 2:14:18 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.