Results 1 to 3 of 3

Thread: texturing problem

  1. #1

    texturing problem

    Hey,

    I'm very confused with texture coordinates. I got something to work but its not 100% how i
    want it. I added textures to the surfaces of my cubes but the problem is, is that the top and bottom of it arnet getting the textures(just a wierd purple solid color which seems to be a blend of the texture colors. Heres what the texture part of my code looks like:

    /* GLOBALS */

    static GLfloat corners[] = {
    -1.0f, 1.0f, 1.0f, // 0
    1.0f, 1.0f, 1.0f, // 1
    1.0f, -1.0f, 1.0f, // 2
    -1.0f, -1.0f, 1.0f, // 3
    -1.0f, 1.0f, -1.0f, // 4
    1.0f, 1.0f, -1.0f, // 5
    1.0f, -1.0f, -1.0f, // 6
    -1.0f, -1.0f, -1.0f };// 7

    // Array of indexes to create the cube,
    static GLubyte indexes[] = {
    0, 3, 1, 1, 3, 2,
    1, 2, 6, 1, 6, 5,
    0, 7, 3, 4, 7, 0,
    5, 7, 4, 6, 7, 5,
    3, 7, 2, 2, 7, 6,
    4, 0, 1, 4, 1, 5};

    static GLfloat tex_corners[] ={
    -1.0f, 1.0f, // 0
    1.0f, 1.0f, // 1
    1.0f, -1.0f, // 2
    -1.0f, -1.0f, // 3
    -1.0f, 1.0f, // 4
    1.0f, 1.0f, // 5
    1.0f, -1.0f, // 6
    -1.0f, -1.0f}; // 7

    static GLubyte tex_indexes[] = {
    0, 3, 1, 1, 3, 2,
    1, 2, 6, 1, 6, 5,
    0, 7, 3, 4, 7, 0,
    5, 7, 4, 6, 7, 5,
    3, 7, 2, 2, 7, 6,
    4, 0, 1, 4, 1, 5};
    // holds the texture
    GLuint tex;

    /* END GLOBALS */

    /* In my init function */
    // load the textures
    Load_Texture("texT.bmp", &tex);
    /************************/

    /* in my display function */
    // Enable the vertex array glEnableClientState(GL_VERTEX_ARRAY);
    // enable the texture array glEnableClientState(GL_TEXTURE_COORD_ARRAY);

    glVertexPointer(3, GL_FLOAT, 0, corners);
    glTexCoordPointer(2, GL_FLOAT,0,tex_corners);
    // draw the arrays
    glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_BYTE, indexes);
    glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_BYTE, tex_indexes);

    Please help

    Frank

  2. #2
    Member Contributor
    Join Date
    Feb 2000
    Location
    England
    Posts
    65

    Re: texturing problem

    Texture coordinates should usually go from 0.0 to 1.0 (if textures not wrapped), this looks to the problem.

  3. #3
    Senior Member Regular Contributor
    Join Date
    Feb 2000
    Location
    milano, italy
    Posts
    282

    Re: texturing problem

    why do you render two times the same geometry?

    try to change the index size from UBYTE to UINT: i had some problem with colors in the UBYTE format...

    Dolo/\/\ightY
    Dolo/\/\ightY

Similar Threads

  1. Texturing Problem
    By Henners in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 07-23-2010, 07:17 AM
  2. ogl texturing problem
    By gl_CodER in forum OpenGL: Advanced Coding
    Replies: 8
    Last Post: 03-06-2006, 02:05 PM
  3. texturing problem
    By powerpad in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 03-30-2005, 07:46 AM
  4. Problem with Texturing...
    By Setzer in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 07-19-2002, 10:16 PM
  5. MDI and texturing problem?
    By asdiel in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 12-06-2000, 10:40 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
  •  
Proudly hosted by Digital Ocean