OpenGL scaling vertex arrays

1.7k views Asked by At

I have a vertex array that I draw as follows (I am working to convert this to a single glDrawArrays call, so that is not the issue here):

gl.glVertexPointer(3, GL.GL_FLOAT, 0, buff);
for ( int i = 0; i < numPoints; i++  ) {
    gl.glDrawArrays(GL.GL_LINE_LOOP, i*verticesPerPoint, verticesPerPoint);
}

This works, but I would like to scale the line loops being drawn. I tried calling glScaled before calling glDrawArrays, but then the points don't show up. I would've thought the scaling just scales the line loops in place, but that does not seem to be the case.

Note when the vertices in the buffer are unscaled since I was hoping to be able to reuse the same buffer at different scales. The idea is that I can redraw the shapes a constant pixel size without recreating the array on each pass.

Can anyone explain what I am doing wrong or if this is even possible?

1

There are 1 answers

1
Brett Hale On BEST ANSWER

Are you sure glScale is applied with the current matrix mode set to the GL_MODELVIEW matrix mode? If so, is it being called before or after any object space transforms? Using glScale[f/d] is a sound approach - it will be applied to the vertex data - but the mention of 'constant pixel size' suggests this is perhaps a 2D problem. It might be worth looking at the mechanics of glViewport in that case.