Reputation: 445
I am tring to import an image in an OpenGl project as background for a scene.
loadTGA("Textures\\greenhill_positive_x.tga",skyboxTexture[1]);
sizeX = 20.0; sizeY = 20.0; sizeZ = 3.0;
glBindTexture(GL_TEXTURE_2D, skyboxTexture[1]);
glBegin(GL_QUADS);
glTexCoord2f(1, 1);glVertex3f(sizeX, -sizeY, -sizeZ);
glTexCoord2f(0, 1);glVertex3f(-sizeX, -sizeY, -sizeZ);
glTexCoord2f(0, 0);glVertex3f(-sizeX, -sizeY, sizeZ);
glTexCoord2f(1, 0);glVertex3f(sizeX, -sizeY, sizeZ);
glEnd();
The code works well but the texture is resized to fit sizeX
, sizeY
, sizeZ
values. The size of tga
file is 250x250 px. What values should I pass to sizeX
, sizeY
, sizeZ
to match the image size?
Upvotes: 0
Views: 45
Reputation: 48226
if you load identity matrices for all modes then it's just:
glBegin(GL_QUADS);
glTexCoord2f(1, 1);glVertex3f(1, 1, 0);
glTexCoord2f(0, 1);glVertex3f(-1, 1, 0);
glTexCoord2f(0, 0);glVertex3f(-1, -1, 0);
glTexCoord2f(1, 0);glVertex3f(1, -1, 0);
glEnd();
you should disable depth writing and testing.
Upvotes: 2