Results 1 to 9 of 9

Thread: Byte co-ordinates for specifying vertices and textures

  1. #1

    Byte co-ordinates for specifying vertices and textures

    I found that the origin (0, 0, 0) lies at the center of the screen. Points on each of the x, y and z axis take fraction values between 0 and +/-1.

    To test the "byte co-ordinates extension" of opengl es, the co-ordinates should be specified in byte format. I have understood this as, each of x, y and z should be of 1 byte size.

    How to map the fraction co-ordinate values to byte format?

    For E.g.:

    GLfloat vertices[] = { //each element of the array is a fraction 0....+/-1
    0.1, 0.1, -0.6,
    -0.3, -0.1, 0.0,
    -0.1, -0.3, 0.0,
    0.1, -0.3, 0.0,
    0.3, -0.1, 0.0,
    -0.1, 0.3, 0.0,
    };
    glVertexPointer(3, GL_FLOAT, sizeof(GLfloat) * 3, vertices);


    Should each of the fraction array elements mapped to coresponding byte value?

    Thank you.

  2. #2
    Junior Member
    Join Date
    Dec 2008
    Location
    Oslo, Norway
    Posts
    25

    Re: Byte co-ordinates for specifying vertices and textures

    No, byte coordinates correspond to the integer part of the coordinate. This means, as you seem to have understood, that if just passed through the pipeline, everything will be way too big. So, you have to somehow scale the values down. Luckily, you can do this quite easily with the modelview matrix, by applying the correct scale there.
    Erik "kusma" Faye-Lund

  3. #3

    Re: Byte co-ordinates for specifying vertices and textures

    Thank you very much kusma.

    I can now give integer values for vertex co-ordinates. And also i see that the scaling factor needs to be adjusted with respect to the magnitude of the interger co-ordinate.

  4. #4

    Re: Byte co-ordinates for specifying vertices and textures

    In continuation with the above discussion. The scaling affects texture co-ordinates also.

    How to get the original texture while scaling is applyied only to vertex co-ordinates.

  5. #5
    Senior Member
    Join Date
    May 2006
    Posts
    353

    Re: Byte co-ordinates for specifying vertices and textures

    Scaling the modelview matrix does not affect texture coordinates. Could you describe more precisely what you mean?
    Georg Kolling, Imagination Technologies
    Please ask questions specific to PowerVR hardware or SDKs on the PowerVR Insider Forum
    DevTech@imgtec.com | http://www.powervrinsider.com

  6. #6

    Re: Byte co-ordinates for specifying vertices and textures

    Please find below an outline of the code, which takes byte array as vertex pointer. Since i am scaling it with a factor of 0.01f the primitive is rendered correctly.

    GLbyte vertices[] = {-50, -50, 0,
    50, -50, 0,
    0, 50, 0,
    };

    glVertexPointer(3,GL_BYTE, sizeof(GLbyte) * 3, 0);

    glTexCoordPointer(2, GL_BYTE, sizeof(GLbyte) * 5, (unsigned char*) (sizeof(GLbyte) * 3));

    glScalef( 0.01f, 0.01f, 0.01f );

    glDrawArrays(GL_TRIANGLES, 0, 3);


    Whereas the texture seems to be very different, appears as if the image is shrunk heavily and repeated to fill the primitive.
    So i thought the texels are also scaled by a factor of 0.01f. The "glTexCoordPointer" line of code is not changed while testing for byte co-ordinates. It worked fine with GLfloat co-ordinates and no scaling.

  7. #7
    Senior Member
    Join Date
    May 2006
    Posts
    353

    Re: Byte co-ordinates for specifying vertices and textures

    If you want to use bytes for texture coordinates you need to scale the texture coordinates too, using the texture matrix instead of the modelview matrix.
    Georg Kolling, Imagination Technologies
    Please ask questions specific to PowerVR hardware or SDKs on the PowerVR Insider Forum
    DevTech@imgtec.com | http://www.powervrinsider.com

  8. #8
    Junior Member
    Join Date
    Dec 2008
    Location
    Oslo, Norway
    Posts
    25

    Re: Byte co-ordinates for specifying vertices and textures

    Yeah, sorry for missing the texture coordinate point. Xmas is absolutely right, the texture coordinates must be scaled with the texture matrix.
    Erik "kusma" Faye-Lund

  9. #9

    Re: Byte co-ordinates for specifying vertices and textures

    Thank you very much. Now i am able to get the desired output.

Similar Threads

  1. byte/short vertex/texture coordinate
    By murphychen in forum OpenGL ES general technical discussions
    Replies: 3
    Last Post: 02-16-2005, 05:38 AM

Posting Permissions

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