Results 1 to 2 of 2

Thread: Vertex Buffer Object not drawing anything

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2011

    Vertex Buffer Object not drawing anything

    This is how I'm setting up my VBO:

    Code :
    // Generate And Bind The Vertex Buffer
    		glGenBuffers( 1, &m_vbo_verts_name );                  // Get A Valid Name
    		glBindBuffer( GL_ARRAY_BUFFER, m_vbo_verts_name );         // Bind The Buffer
    		glBufferData( GL_ARRAY_BUFFER, m_faces.size()*9*sizeof(float), m_vbo_vert, GL_STATIC_DRAW );

    I'm simply generating the buffers here. Basically I know I have 9 float values per face. I have the flowing struct called VBO_vert:

    Code :
    	  struct VBO_vert {
    		  float x;
    		  float y;
    		  float z;

    So basically I have a certain number of faces and the size of the buffer is just going to be 9 floats (3 vertices per face). I'm going to have redundant vertices (faces sharing vertices but thats fine.

    Anyways, that gets run only one time in my Mesh initialization.

    Then my draw code:

    Code :
    	glVertexPointer(3, GL_FLOAT, 0, m_vbo_vert);
    	glTexCoordPointer(2, GL_FLOAT, 0, m_vbo_texture);
    	glNormalPointer(GL_FLOAT, 0, m_vbo_normal);
    	glEnableClientState( GL_VERTEX_ARRAY );
    	glEnableClientState( GL_TEXTURE_COORD_ARRAY );
    	glEnableClientState( GL_NORMAL_ARRAY );
    	glDrawArrays(GL_TRIANGLES,0, m_faces.size()*9);
    	glDisableClientState( GL_VERTEX_ARRAY );
    	glDisableClientState( GL_TEXTURE_COORD_ARRAY );
    	glDisableClientState( GL_NORMAL_ARRAY );

    I know my drawing is okay since my old draw without VBO works. I need to use VBO since I'm going to need to pass in more information per vertex and I'd like to use VBO's. Any ideas what I'm doing wrong?

  2. #2
    Junior Member Newbie
    Join Date
    Oct 2011

    Re: Vertex Buffer Object not drawing anything

    nvm guys I fixed it. I'm just an idiot (I somehow fix all my problems before they're answered). I just changed my draw code to look like this:

    Code :
    	glBindBuffer( GL_ARRAY_BUFFER, m_vbo_verts_name );
    	glVertexPointer(3, GL_FLOAT, 0, (GLvoid*)((char*)NULL));
    	glBindBuffer( GL_ARRAY_BUFFER, m_vbo_texture_name );
    	glTexCoordPointer(2, GL_FLOAT, 0, (GLvoid*)((char*)NULL));
    	glBindBuffer( GL_ARRAY_BUFFER, m_vbo_normal_name );
    	glNormalPointer(GL_FLOAT, 0, (GLvoid*)((char*)NULL));

    That fixed it. Just some opengl jargen.

Similar Threads

  1. Drawing multiple polygons with vertex buffer object
    By jorgus117 in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 02-21-2016, 03:28 AM
  2. Vertex Array Object and vertex buffer object
    By Xxacero in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 07-23-2015, 05:13 AM
  3. Vertex Array Object vs. Vertex Buffer Object
    By michaelglaz in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 11-26-2014, 02:52 PM
  4. Drawing without Vertex Buffer Object
    By MirzaSe in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 09-08-2014, 12:32 PM
  5. Texture Buffer Object shared with Vertex Buffer Ob
    By marshats in forum OpenGL: GLSL
    Replies: 3
    Last Post: 09-06-2010, 09:01 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