Results 1 to 2 of 2

Thread: Textures are flipped/inverted

  1. #1
    Member Contributor
    Join Date
    Dec 2001
    Location
    Porto Velho
    Posts
    97

    Textures are flipped/inverted

    Im using this code to auto-generate coords for texture mapping, but the textures are drawn inverted/flipped why?

    Code :
    void draw_simple_quad(int QUAD_ID)
    {
    	glBindTexture(GL_TEXTURE_2D, texture[Terrain[QUAD_ID].texture_id]);
    	GLfloat tPlane[] = {1.0/MAP_SIZE, 0, 0, 0};
    	GLfloat sPlane[] = {0,0,1.0/MAP_SIZE, 0};
    	glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
     	glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
     
    	glTexGenfv(GL_S, GL_OBJECT_PLANE,sPlane);
    	glTexGenfv(GL_T, GL_OBJECT_PLANE, tPlane);
     
    	glBegin(GL_TRIANGLES);
    		glTexCoord2f(0,0);
    		glVertex3f(Terrain[QUAD_ID].vertices_x1[0],
    			Terrain[QUAD_ID].vertices_y1[0],
    			Terrain[QUAD_ID].vertices_z1[0]);
    		glTexCoord2f(1,0);
    		glVertex3f(Terrain[QUAD_ID].vertices_x2[0],
    			Terrain[QUAD_ID].vertices_y2[0],
    			Terrain[QUAD_ID].vertices_z2[0]);
    		glTexCoord2f(1,1);
    		glVertex3f(Terrain[QUAD_ID].vertices_x3[0],
    			Terrain[QUAD_ID].vertices_y3[0],
    			Terrain[QUAD_ID].vertices_z3[0]);
    		glTexCoord2f(0,1);
    		glVertex3f(Terrain[QUAD_ID].vertices_x4[0],
    			Terrain[QUAD_ID].vertices_y4[0],
    			Terrain[QUAD_ID].vertices_z4[0]);
    		glTexCoord2f(0,0);
    		glVertex3f(Terrain[QUAD_ID].vertices_x5[0],
    			Terrain[QUAD_ID].vertices_y5[0],
    			Terrain[QUAD_ID].vertices_z5[0]);
    		glTexCoord2f(1,1);
    		glVertex3f(Terrain[QUAD_ID].vertices_x6[0],
    			Terrain[QUAD_ID].vertices_y6[0],
    			Terrain[QUAD_ID].vertices_z6[0]);
    	glEnd();
    }

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: Textures are flipped/inverted

    Some image formats stores the image from bottom to top, while other stores them from top to bottom. Without knowing what format you use, I can say that BMPs are stored bottop up, and so a most TGAs. Also remember that OpenGL has the origin in the lower left corner. That means that texture coordinate (0,0) is the lower left corner of the image. This can also cause some confusion.

Similar Threads

  1. Reusing FBO but now getting inverted textures
    By opengldfw in forum OpenGL: Advanced Coding
    Replies: 0
    Last Post: 09-24-2013, 06:33 AM
  2. Textures showing inverted (upside down) !
    By imported_fakhir in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 03-10-2013, 04:37 PM
  3. textures displayed inverted
    By sorflex in forum COLLADA
    Replies: 1
    Last Post: 01-09-2008, 06:04 PM
  4. Cube Mapping textures are flipped
    By d_christop in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 10-07-2005, 09:38 AM
  5. Auto texture coord. -- flipped/inverted textures
    By lsdi in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 01-27-2002, 12:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean