简体   繁体   中英

OpenGL scaling vertex arrays

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM