Results 1 to 4 of 4

Thread: Texture flipped on gluSphere

  1. #1
    Member Contributor
    Join Date
    Mar 2001
    Posts
    50

    Texture flipped on gluSphere

    I loaded an image of the earth from a JPeg file as a texture and applied it to a gluSphere. The texture is flipped horizontally (the west coast is now the east coast, vv). Viewing the image in IE shows it oriented properly. What gives here? Is this a quirk of gluSphere or am I screwing up something? Anyone know how to flip a texture using the texture matrix?

  2. #2
    Member Contributor
    Join Date
    Apr 2004
    Posts
    73

    Re: Texture flipped on gluSphere

    It's "normal" because image data is generally stored from top to bottom in file formats when OpenGL work with picture from bottom to top.

    The most simple thing to do for resolve this is simply to flip your picture with a paint soft (the minimalistic Microsoft Paint can make this with .bmp format for example) before present it to your OpenGL texture reader.

    Or use a TGA loader that don't reorganize the order of lines from top to bottom (cf. that conserve the initial line order of the TGA file format) : this sort of picture loader is very easy to code with uncompressed .tga file.

    On another side, make a function that flip uncompressed picture data in central memory can be a good thing too.

    Or last solution, use effectively one texture matrix that flip the t value (cf. T=1.0-t) of the texture coordinates (but this work only and only if the w vertice coordinate is equal to 1)

    1 0 0 0
    0 -1 0 1
    0 0 1 0
    0 0 0 0


    @+
    Cyclone
    @+
    Yannoo

  3. #3
    Member Contributor
    Join Date
    Mar 2001
    Posts
    50

    Re: Texture flipped on gluSphere

    Thank you very much!

  4. #4
    Senior Member Regular Contributor
    Join Date
    Nov 2000
    Location
    Huntsville, AL. USA
    Posts
    302

    Re: Texture flipped on gluSphere

    Code for flipping an RGB image in memory ...

    Code :
    void FlipImage(const char* source, char* target,unsigned width,unsigned height)
    {
    	for (int j=0;j<height; j++)
    	{
    		for (int i=0;i<width;i++)
    		{
    			unsigned jWidthI = j*width+i;
     
    			target[ jWidthI*3] = source[ ((height-1-j)*width+i)*3];
     
    			target[ jWidthI*3+1] = source[ ((height-1-j)*width+i)*3+1];
     
    			target[ jWidthI*3+2] = source[ ((height-1-j)*width+i)*3+2];
    		}
    	}
    }

    [This message has been edited by pleopard (edited 08-31-2001).]
    Obsessive - A word used by the lazy to describe the motivated.

Similar Threads

  1. Help with putting a texture on a glusphere.
    By thealmightyone in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 06-02-2009, 09:51 PM
  2. gluSphere texture poles
    By Manojo in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 12-07-2007, 06:43 AM
  3. gluSphere texture coordinates
    By imported_vince in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 10-19-2006, 06:59 AM
  4. Texture map on a gluSphere
    By starman in forum OpenGL: Basic Coding
    Replies: 16
    Last Post: 02-25-2003, 02:39 PM
  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