Texture is being horizonatally flipped...
My textures are being horizontally flipped with the code below The Red book on p. 407 says"The texture coordinates of the texture square are (0,0), (1,0) (1,1) and (0,1) in
counter clockwise order. And my object vertices are in counter clockwise
order, right? I played around with clockwise ordering but that didn't seem to work.
Should both the texture and vertex coordinates go in the same CW or CCW order?
Is there some other setting that I'm missing?
glBegin(GL_QUADS);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0, 0.0);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, 0.0)
glVertex3f(-xVertices, -yVertices, 0.0); // object vertex
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0, 0.0);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 100.0, 0.0);
glVertex3f( xVertices, -yVertices, 0.0); // object vertex
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0, 1.0);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 100.0, 100.0);
glVertex3f( xVertices, yVertices, 0.0); // object vertex
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0, 1.0);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, 100.0);
glVertex3f(-xVertices, yVertices, 0.0); // object vertex
glEnd();
counter clockwise order. And my object vertices are in counter clockwise
order, right? I played around with clockwise ordering but that didn't seem to work.
Should both the texture and vertex coordinates go in the same CW or CCW order?
Is there some other setting that I'm missing?
glBegin(GL_QUADS);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0, 0.0);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, 0.0)
glVertex3f(-xVertices, -yVertices, 0.0); // object vertex
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0, 0.0);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 100.0, 0.0);
glVertex3f( xVertices, -yVertices, 0.0); // object vertex
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0, 1.0);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 100.0, 100.0);
glVertex3f( xVertices, yVertices, 0.0); // object vertex
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0, 1.0);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, 100.0);
glVertex3f(-xVertices, yVertices, 0.0); // object vertex
glEnd();
I do it like this:
then
Code:
GL_uint indexOfList = 0;
glNewList(indexOfList, GL_COMPILE);
glBindTexture(GL_TEXTURE_2D, textureIndex);
glBegin(GL_QUADS);
glTexCoord2i(0, 0); glVertex2f(-1, -1);
glTexCoord2i(1, 0); glVertex2f( 1, -1);
glTexCoord2i(1, 1); glVertex2f( 1, 1);
glTexCoord2i(0, 1); glVertex2f(-1, 1);
glEnd();
glEndList();then
Code:
glScalef(width, height, 1);
glCallList(indexOfList);Sir, e^iπ + 1 = 0, hence God exists; reply!
Ok, the glTexCoords and glVertexs are being specified in the same wrapping order.
Must be something else then. Thanks.
Must be something else then. Thanks.
Maybe your texture loading function?
Sir, e^iπ + 1 = 0, hence God exists; reply!
It looks like that code is wired up correctly. Either your texture is being loaded upside down or back to front or you are looking at every thing upside down or back to front, or some combination of both.
Chopper, iSight Screensavers, DuckDuckDuck: http://majicjungle.com
I use the below function to load in my PNG images. Is this what everybody else
uses? Particularly the call to png_read_image(png_ptr, *image);
int PNGservices::read_png_image(FILE *fp, png_structp png_ptr, png_infop info_ptr,
png_bytepp *image, png_uint_32 *width, png_uint_32 *height)
{
int i,j;
*width = png_get_image_width(png_ptr, info_ptr);
*height = png_get_image_height(png_ptr, info_ptr);
// error checking code removed...
for (i = 0; i < *height; i++)
{
(*image)[i] = (png_bytep) malloc( png_get_rowbytes(png_ptr, info_ptr) );
if ((*image)[i] == 0)
{
for (j = 0; j < i; j++)
{
free((*image)[j]);
}
free(*image);
fclose(fp);
return 0;
}
}
png_read_image(png_ptr, *image);
return 1;
}
uses? Particularly the call to png_read_image(png_ptr, *image);
int PNGservices::read_png_image(FILE *fp, png_structp png_ptr, png_infop info_ptr,
png_bytepp *image, png_uint_32 *width, png_uint_32 *height)
{
int i,j;
*width = png_get_image_width(png_ptr, info_ptr);
*height = png_get_image_height(png_ptr, info_ptr);
// error checking code removed...
for (i = 0; i < *height; i++)
{
(*image)[i] = (png_bytep) malloc( png_get_rowbytes(png_ptr, info_ptr) );
if ((*image)[i] == 0)
{
for (j = 0; j < i; j++)
{
free((*image)[j]);
}
free(*image);
fclose(fp);
return 0;
}
}
png_read_image(png_ptr, *image);
return 1;
}
Im using SDL_Surface* image = IMG_Load(name); to load pngs in one project from the SDL libs which use libpng, so thats probably ok, unless png_read_image copies the png_ptr backwards into the image.
Sir, e^iπ + 1 = 0, hence God exists; reply!

