1
votes

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)
1
Unless I'm completely missing something - why not resizing you objects by changing the transformation applied to them in the vertex shader?Tal Darom
I don't think I'm using a vertex shader - I've added my drawing function to the initial posting.memyself
Ok, so change the model view transformation you set.Tal Darom
@TalDarom should I do this with glScalef() or with a different command? sorry that I'm so clueless ...memyself
@TalDarom if you provide an answer with some example code then I can tick your answer!memyself

1 Answers

1
votes

You should:

glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); // or any other code you currently use to create the model transform
glScalef();