×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Regular Contributor
    Join Date
    Sep 2007
    Posts
    132

    Question about texture coordinate

    Hi,

    now i puzzled with texture coordinate. There is an example about texture in s60 3rd shipped with opengl es . There are two pictures used as texture. They are mapped to a cube. The five faces of the cube are mapped one picture. The sixth face is mapped another picture.
    There are the codes for input texture coordinate:
    Code:
    #define tex(u,v) (GLbyte)( (u) - 128 ) , (GLbyte)( (v) - 128 )
    static const GLbyte nokTexCoords[24 * 2] =
    {
        /* top, whole texture nasa_hubble.h */
        tex(0,0),
        tex(255,0),
        tex(255,255),
        tex(0,255),
    
    /*	0,0,
    	1,0,
    	1,1,
    	0,1,
    */
        /* front, spiral with tail */
        tex(0,255),
        tex(127,255),
        tex(127,127),
        tex(0,127),
    
    /*	0,1,
    	0.5,1,
    	0.5,0.5,
    	0,0.5,
    */	
    	
        /* right, red nebulae */
        tex(127,255),
        tex(255,255),
        tex(255,127),
        tex(127,127),
    
    /*	0.5,1,
    	1,1,
    	1,0.5,
    	0.5,0.5,
    */	
        /* left, plasma cloud */
        tex(0,127),
        tex(127,127),
        tex(127,0),
        tex(0,0),
    
    /*	0,0.5,
    	0.5,0.5,
    	0.5,0,
    	0,0,
    */	
        /* back, 2 spirals */
       tex(127,127),
        tex(255,127),
        tex(255,0),
        tex(127,0),
    
    /*	0.5,0.5,
    	1.0,0.5,
    	1,0,
    	0.5,0,
    */	
        /* bottom, whole texture ogles.jpg */
        tex(255,255),
        tex(255,0),
        tex(0,0),
        tex(0,255)
    
    	
    /*	1,1,
    	1,0,
    	0,0,
    	0,1
    */	
    };

    There are codes for texture transformation:
    Code:
        glMatrixMode( GL_TEXTURE );
        glLoadIdentity();
        glScalef(     1.0f/255.0f, 1.0f/255.0f, 1.0f );
        glTranslatef( 128.0f,      128.0f,      0.0f );
    Obviously, the final texture is set to [0,1]. My problem is that why not set the texture coordinate as [0,1] directly. If the nokTexCoords are set in [0,1] in declaration, we need
    no transformation. But when i do like this, it works badly.

    So i assume that the texture picture coordinate is set [0,255], so why not quit the macro defination and glTranslatef and scalef them directly? But when i do like this, it also works badly.

    So why? Anyone can help me?
    Looking forward to fast replying.

    Mia

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    29

    Re: about texture coordinate

    Quote Originally Posted by freesui1984 View Post
    Obviously, the final texture is set to [0,1]. My problem is that why not set the texture coordinate as [0,1] directly. If the nokTexCoords are set in [0,1] in declaration, we need
    no transformation. But when i do like this, it works badly.
    That should work fine. Are you using the macro?

    So i assume that the texture picture coordinate is set [0,255], so why not quit the macro defination and glTranslatef and scalef them directly? But when i do like this, it also works badly.
    GLbyte is signed so the range is [-128, 127]. All the macro does is map [0, 255] to that range.

Similar Threads

  1. Using camera frame as OpenGL texture, problem!!
    By abolfoooud in forum Symbian Media (Closed)
    Replies: 29
    Last Post: 2009-06-18, 02:58
  2. Series 60 BMP Texture Mapping With OpenGL ES Problem
    By abolfoooud in forum Symbian Media (Closed)
    Replies: 7
    Last Post: 2008-06-13, 03:53
  3. Series 60 BMP Texture Mapping With OpenGL ES Problem
    By abolfoooud in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2005-09-13, 16:13
  4. texture on a sphere
    By alabama83 in forum Symbian Media (Closed)
    Replies: 0
    Last Post: 2005-06-27, 15:02
  5. problems with texturing - OpenGL ES on Symbian
    By miranda2112 in forum Symbian Media (Closed)
    Replies: 1
    Last Post: 2005-04-05, 11:20

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •