Reputation: 12628
I'm writing a simple opengl application with a default window size. Into this window I draw some objects using VBOs:
points = calc_objects()
vbo_id = GLuint()
glGenBuffers(1, pointer(vbo_id))
data = (GLfloat*len(points))(*points)
glBindBuffer(GL_ARRAY_BUFFER, vbo_id)
glBufferData(GL_ARRAY_BUFFER, sizeof(data), data, GL_STATIC_DRAW)
Currently, when the user resizes the opengl window, all objects stay in place and are not resized. This is the expected behaviour and so I'm investigating what the best way is to resize the objects without recalculating them. Is that even possible? Can I resize the data directly in the VBO? Or do I need to recalculate my objects first and replace the VBO data entirely? The size of my objects is currently proportional to my initial window size and therefore the objects should be resized according to the new window dimensions. What's the easiest way of doing that?
EDIT: here's my drawing function:
glBindBuffer(GL_ARRAY_BUFFER, vbo_id)
glVertexPointer(2, GL_FLOAT, 0, 0)
glDrawArrays(GL_LINE_STRIP, 0, len(points)/2)
Upvotes: 1
Views: 632
Reputation: 1409
You should:
glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); // or any other code you currently use to create the model transform
glScalef();
Upvotes: 1