OpenGL 缩放顶点数组

发布于 2024-12-11 19:20:56 字数 484 浏览 1 评论 0原文

我有一个按如下方式绘制的顶点数组(我正在努力将其转换为单个 glDrawArrays 调用,因此这不是这里的问题):

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

这有效,但我想缩放正在绘制的线循环。我尝试在调用 glDrawArrays 之前调用 glScaled ,但这些点没有显示。我本以为缩放只是将线循环缩放到位,但情况似乎并非如此。

请注意缓冲区中的顶点何时未缩放,因为我希望能够以不同的比例重用相同的缓冲区。我的想法是,我可以将形状重新绘制为恒定的像素大小,而无需在每次传递时重新创建数组。

谁能解释我做错了什么或者这是否可能?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

没有伤那来痛 2024-12-18 19:20:56

您确定应用glScale并将当前矩阵模式设置为GL_MODELVIEW矩阵模式吗?如果是这样,它是在任何对象空间变换之前还是之后被调用?使用 glScale[f/d] 是一种合理的方法 - 它将应用于顶点数据 - 但提到“恒定像素大小”表明这可能是一个 2D 问题。在这种情况下,可能值得研究一下 glViewport 的机制。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文