Jump to content
  • Advertisement
Sign in to follow this  
freaky3

Resizing and interpolation Textures

This topic is 5063 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

Hi! I'm trying to create a simple skybox. So i put textures onto a huge Quad that surrounds the scene. the problem is that each texture is far too small to cover a whole side of the quad. is it possible to resize or interpolate the textures so that they fit on larger planes? GL_REPEAT or GL_CLAMP don't seeme to be possiblities.... :( Thanx a lot!!

Share this post


Link to post
Share on other sites
Advertisement
Size shouldn't really be a factor when applying texture onto a quad. Typically you could stretch the texture with the specified coordinates. Lets see your code.

Share this post


Link to post
Share on other sites
ok, here is the code: first the init-routine, then the drawSky-Routine in the display-callback function.
______________________________


void init(){
glEnable (GL_DEPTH_TEST);

glEnable (GL_NORMALIZE);
glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);

glEnable(GL_TEXTURE_2D);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
}

_________________________________________________________

void drawSky(){

glDisable(GL_CULL_FACE);

glBindTexture(GL_TEXTURE_2D,textures[TEXTURE_QUADFRONT]);
glBegin(GL_QUADS);
glColor3f (1,1,1);
// Das vordere QUAD
glNormal3f(0,0,1);
glTexCoord2d(0, 0); glVertex3f(-sz, -sz, sz);
glTexCoord2d(1, 0); glVertex3f( sz, -sz, sz);
glTexCoord2d(1, 1); glVertex3f( sz, sz, sz);
glTexCoord2d(0, 1); glVertex3f(-sz, sz, sz);
glEnd();

glBindTexture(GL_TEXTURE_2D,textures[TEXTURE_QUADRIGHT]);
glBegin(GL_QUADS);
// Das rechte QUAD
glNormal3f(1,0,0);
glTexCoord2d(1, 0); glVertex3f( sz, -sz, -sz);
glTexCoord2d(1, 1); glVertex3f( sz, sz, -sz);
glTexCoord2d(0, 1); glVertex3f( sz, sz, sz);
glTexCoord2d(0, 0); glVertex3f( sz, -sz, sz);
glEnd();

glBindTexture(GL_TEXTURE_2D,textures[TEXTURE_QUADBACK]);
glBegin(GL_QUADS);
// Das hintere QUAD
glNormal3f(0,0,-1);
glTexCoord2d(1, 0); glVertex3f(-sz, -sz, -sz);
glTexCoord2d(1, 1); glVertex3f(-sz, sz, -sz);
glTexCoord2d(0, 1); glVertex3f( sz, sz, -sz);
glTexCoord2d(0, 0); glVertex3f( sz, -sz, -sz);
glEnd();

glBindTexture(GL_TEXTURE_2D,textures[TEXTURE_QUADLEFT]);
glBegin(GL_QUADS);
// Das linke QUAD
glNormal3f(-1,0,0);
glTexCoord2d(0, 0); glVertex3f(-sz, -sz, -sz);
glTexCoord2d(1, 0); glVertex3f(-sz, -sz, sz);
glTexCoord2d(1, 1); glVertex3f(-sz, sz, sz);
glTexCoord2d(0, 1); glVertex3f(-sz, sz, -sz);
glEnd();

glBindTexture(GL_TEXTURE_2D,textures[TEXTURE_QUADUP]);
glBegin(GL_QUADS);
// Das obere QUAD
glNormal3f(0,1,0);
glTexCoord2d(0, 1); glVertex3f(-sz, sz, -sz);
glTexCoord2f(0, 0); glVertex3f(-sz, sz, sz);
glTexCoord2f(1, 0); glVertex3f( sz, sz, sz);
glTexCoord2f(1, 1); glVertex3f( sz, sz, -sz);
glEnd();

glBindTexture(GL_TEXTURE_2D,textures[TEXTURE_QUADDOWN]);
glBegin(GL_QUADS);
// Das untere QUAD
glNormal3f(0,-1,0);
glTexCoord2d(1, 1); glVertex3f( sz, -sz, sz);
glTexCoord2d(0, 1); glVertex3f(-sz, -sz, sz);
glTexCoord2d(0, 0); glVertex3f(-sz, -sz, -sz);
glTexCoord2d(1, 0); glVertex3f( sz, -sz, -sz);
glEnd();


glEnable(GL_CULL_FACE);
}

_________________________________________________________
These are the Texture parameters:


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

glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);

Share this post


Link to post
Share on other sites
Using automatic texture coordinate generation cancels out whatever texture coordinates you pass using glTexCoord*(), so try without enabling it.

Share this post


Link to post
Share on other sites
thanx a lot!! Now it works perfektly fine!!
..Unfortunately everything in the sky box (a scene with cars and other objects) ist grey now. no colors.

has it cleared the colorbuffer?

Share this post


Link to post
Share on other sites
Quote:
Original post by freaky3
thanx a lot!! Now it works perfektly fine!!
..Unfortunately everything in the sky box (a scene with cars and other objects) ist grey now. no colors.

has it cleared the colorbuffer?


It may be because you were using TexGen for the rest of the scene as well. It is usually used on a per-object level, so you shouldn't enable it in your init function like you were. Just enable it before you render anything that needs it, and then afterwards disable it again.

Let me know if that works.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!