Results 1 to 6 of 6

Thread: Texture Mapping Triangle Strip VBO?

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2011
    Posts
    7

    Texture Mapping Triangle Strip VBO?

    Hi everyone,

    I'm currently working on a game and am having problems working out how to texture a triangle strip.

    I have a cube created using a VBO and triangle strips. I was wondering how I would go about texturing this. Would you create a new buffer object, create an array/vector of texture points (which are loaded into the buffer) and then somehow apply those points to the texture to the cube?

    Thanks,

    Gaz

  2. #2
    Senior Member Regular Contributor
    Join Date
    Nov 2010
    Location
    Brazil, Rio de Janeiro
    Posts
    147

    Re: Texture Mapping Triangle Strip VBO?

    I think you gonna need to create an array of texture coords (one for each vertex). But I can't figure out a way to automate this for any geometry you wanna texture. If the cube was the only object I have, I'll consider the use of a cube map.

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2011
    Posts
    7

    Re: Texture Mapping Triangle Strip VBO?

    I've created an array of texture coords but I can't work out how to apply this and texture. The texture I'm loading is a .tga file and I think its loaded file as my load file routine doesn't come up with any errors.

    I create the buffer:
    Code :
    //Texture Setup
    	glGenTextures(1,&texID);
    	glBindTexture(GL_TEXTURE_2D, texID);
    	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, texture.getWidth(), texture.getHeight(), 0, GL_RGB, GL_UNSIGNED_BYTE, texture.getImageData());

    Then in my render class I try rendering the texture:

    Code :
    glEnableClientState(GL_VERTEX_ARRAY);
    	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    	glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
    	glVertexPointer(3, GL_FLOAT, 0, 0);
    	glBindBuffer(GL_TEXTURE_2D, texID);
    	glTexCoordPointer(2,GL_FLOAT,0,cube_text);
    	//Draw the triangles, we pass in the number of indices, the data type of the index array
    	// (GL_UNSIGNED_INT) and then the pointer to the start of the array
    	glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
    	glDrawArrays(GL_TRIANGLE_STRIP, 0, 24);
    	//Finally disable the vertex array
    	glDisableClientState(GL_VERTEX_ARRAY);
    	glDisableClientState(GL_TEXTURE_COORD_ARRAY);

    The cube renders fine as a 3D cube in red. Just the texture isn't applied.

  4. #4

    Re: Texture Mapping Triangle Strip VBO?

    Textures are bound with glBindTexture, not glBindBuffer .

  5. #5
    Senior Member Regular Contributor
    Join Date
    Nov 2010
    Location
    Brazil, Rio de Janeiro
    Posts
    147

    Re: Texture Mapping Triangle Strip VBO?

    Guess ShaderRookie found the problem. =)

  6. #6
    Junior Member Newbie
    Join Date
    Feb 2011
    Posts
    7

    Re: Texture Mapping Triangle Strip VBO?

    Yeh thanks guys that and a few other things I'd done wrong!

Similar Threads

  1. Triangle Strip - Per Triangle color
    By Aliii in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 09-27-2013, 10:14 AM
  2. triangle strip with a LINE triangle display error
    By Samme in forum OpenGL: Windows
    Replies: 22
    Last Post: 11-20-2008, 07:50 PM
  3. How To Triangle Strip?
    By imported_nomad in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 05-20-2002, 10:24 AM
  4. How do I texture map a Triangle Strip?
    By Jim Gray in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 06-10-2000, 03:23 PM
  5. How do I texture map a Triangle Strip?
    By Jim Gray in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 06-09-2000, 04:10 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