Advertisement

Skybox problem

Started by November 15, 2000 06:56 AM
1 comment, last by tripper 24 years, 3 months ago
I have a small problem drawing skybox... Everything else is fine, but there occurs some clipping where the GL_QUADS edges meet, so the edges are clearly seen, witch is not what I want for a skybox... I use the code shown below. any advices? other methods? Tommi Laukkanen ... // Back glBindTexture(GL_TEXTURE_2D, textures[1].texID); glBegin(GL_QUADS); glTexCoord2f(1.0f, 0.0f); glVertex3f(-10.0f, -10.0f, -10.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(-10.0f, 10.0f, -10.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f( 10.0f, 10.0f, -10.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f( 10.0f, -10.0f, -10.0f); glEnd(); // Top glBindTexture(GL_TEXTURE_2D, textures[5].texID); glBegin(GL_QUADS); glTexCoord2f(1.0f, 1.0f); glVertex3f(-10.0f, 10.0f, -10.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-10.0f, 10.0f, 10.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f( 10.0f, 10.0f, 10.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 10.0f, 10.0f, -10.0f); glEnd(); // Left glBindTexture(GL_TEXTURE_2D, textures[4].texID); glBegin(GL_QUADS); ...etc
you have to calculate other tex-coords which are based on the texture size. so you avoid texturing the pixels around the texture!


try using the folowing code:

/* calculate texcoords */

...
size=1*scale;
a = 1.0 / (float)tex_size;
b = 1.0 - a;


glDisable(GL_DEPTH_TEST);

// front
glBindTexture(GL_TEXTURE_2D, Textures[ISKYBOX_TEXFT]);
glBegin(GL_TRIANGLE_FAN);
glColor3f(1.0, 1.0, 1.0);
glTexCoord2f(a, a);
glVertex3f(-size,-size,-size);
glTexCoord2f(b, a);
glVertex3f(size,-size,-size);
glTexCoord2f(b, b);
glVertex3f(size,size,-size);
glTexCoord2f(a, b);
glVertex3f(-size,size,-size);
glEnd();


// top
glBindTexture(GL_TEXTURE_2D, Textures[ISKYBOX_TEXUP]);
glBegin(GL_TRIANGLE_FAN);
glTexCoord2f(b, a);
glVertex3f(-size, size, size);
glTexCoord2f(b, b);
glVertex3f(-size, size,-size);
glTexCoord2f(a, b);
glVertex3f(size, size,-size);
glTexCoord2f(a, a);
glVertex3f(size, size,size);
glEnd();
...
Advertisement
You have to use GL_CLAMP instead of GL_REPEAT, at least that''s one of the things you have to do to make it look rigth...
Tim--------------------------glvelocity.gamedev.netwww.gamedev.net/hosted/glvelocity

This topic is closed to new replies.

Advertisement