Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualMarkS

Posted 12 July 2013 - 06:46 PM

Here is a big problem and most likely the source of your problems:
 

..snip..
glGenBuffers(1, buf.buffer); // You allocate a single buffer here.
glBindBuffer(GL_ARRAY_BUFFER, buf.buffer[Vertices+ offset]); // And then access it like an array here.
..snip..
}


If "buf.buffers" is an array, then you need to tell glGenBuffers how many buffers to generate. You are currently telling it to create one buffer, and then you access it like an array of buffers.

Also, you need a separate buffer for each array. One for "GL_VERTEX_ARRAY", one for "GL_COLOR_ARRAY" and one for "GL_ELEMENT_ARRAY". You are calling glGenBuffers three times in a row on the same buffer, thereby overwriting the buffer. At the end of your "make_buffer" function, only the element buffer exists.

#3MarkS

Posted 12 July 2013 - 06:42 PM

Here is a big problem and most likely the source of your problems:
 

..snip..
glGenBuffers(1, buf.buffer); // You allocate a single buffer here.
glBindBuffer(GL_ARRAY_BUFFER, buf.buffer[Vertices+ offset]); // And then access it like an array here.
..snip..
}


If "buf.buffers" is an array, then you need to tell glGenBuffers how many buffers to generate. You are currently telling it to create one buffer, and then you access it like an array of buffers.

Also, you need a separate buffer for each array. One for "GL_VERTEX_ARRAY", one for "GL_COLOR_ARRAY" and one for "GL_ELEMENT_ARRAY". You are calling glGenBuffers three times in a row on the same buffer, thereby overwriting the buffer. At the end of your "make_buffer" function, only the element buffer exists.

#2MarkS

Posted 12 July 2013 - 06:42 PM

Here is a big problem and most likely the source of your problems:
 

..snip..
glGenBuffers(1, buf.buffer); // You allocate a single buffer here.
glBindBuffer(GL_ARRAY_BUFFER, buf.buffer[Vertices+ offset]); // And then access it like an array here.
..snip..
}


If "buf.buffers" is an array, then you need to tell glGenBuffers how many buffers to generate. You are currently telling it to create one buffer, and then access it like an array of buffers.

Also, you need a separate buffer for each array. One for "GL_VERTEX_ARRAY", one for "GL_COLOR_ARRAY" and one for "GL_ELEMENT_ARRAY". You are calling glGenBuffers three times in a row on the same buffer, thereby overwriting the buffer. At the end of your "make_buffer" function, only the element buffer exists.

#1MarkS

Posted 12 July 2013 - 06:41 PM

Here is a big problem and most likely the source of your problems:

..snip..
glGenBuffers(1, buf.buffer); // You allocate a single buffer here.
glBindBuffer(GL_ARRAY_BUFFER, buf.buffer[Vertices+ offset]); // And then access it like an array here.
..snip..
}


If "buf.buffers" is an array, then you need to tell glGenBuffers how many buffers to generate. You are currently telling it to create one buffer, and then access it like an array of buffers.

Also, you need a separate buffer for each array. One for "GL_VERTEX_ARRAY", one for "GL_COLOR_ARRAY" and one for "GL_ELEMENT_ARRAY". You are calling glGenBuffers three times in a row on the same buffer, thereby overwriting the buffer. At the end of your "make_buffer" function, only the ELEMENT_BUFFER exists.

PARTNERS