Skip to main content
GameDev.net gamedev.net
🔒 Locked

glBufferSubData question

Started by FXACE Mar 13, 2011 at 1:57 PM 3 replies 1.4k views
Original Post
FXACE
FXACE
Hi folks!!!

Situation: I have this variables : vec3 * vertices, *normals, * texture_coords; int num_vertices;

All this (vec3*) variables have different pointers. Can I pack it to one VBO without losing time for creating mixed array (vertices,normals,...)?

GLAPI void APIENTRY glBufferSubData (GLenum, GLintptr, GLsizeiptr, const GLvoid *);

What the second argument of glBufferSubData means? Is it a starting position (index) of allocated buffer where I want to update the data? If yes? how to work with it?




Thanks forward
karwosts
karwosts
http://www.opengl.org/sdk/docs/man/xhtml/glBufferSubData.xml

The arguments are explained in the documentation.

What do you mean "without losing time"? Yes you can pack all of your information into one buffer.
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game
FXACE
FXACE
Thanks for reply, karwosts... I'd check this out.


What do you mean "without losing time"?


I mean to allocate the temporary array that would hold vector values like this:


vec3 *array = new vec3 [num_vertices*3]; // where '3' is: "vertices", "texcoords", "normals"

// here I copy the data from "vertices", "texcoords", "normals" to "array"
memcpy(array,vertices,sizeof(vec3)*num_vertices);
memcpy((void*)(int(array)+sizeof(vec3)*num_vertices), normals, sizeof(vec3)*num_vertices);
.............
..........

at the end I sending "array" to VBO and deleting temporary variable


Now, by this argument GLintptr offset I can do this without allocating temporary array for them by this way:




glBufferSubData( GL_ARRAY_BUFFER_ARB, 0, sizeof(vec3) * num_vertices, vertices);


glBufferSubData( GL_ARRAY_BUFFER_ARB, sizeof(vec3) * num_vertices, sizeof(vec3) * num_vertices, normals);

//and so on....






Thanks again!!!!
FXACE
FXACE

What is the problem you are having?

There is no problem. Everything OK.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.