我如何使用OpenGL 3.x的维也纳组织来呈现一个动态的世界? [英] How do I use OpenGL 3.x VBOs to render a dynamic world?

查看:123
本文介绍了我如何使用OpenGL 3.x的维也纳组织来呈现一个动态的世界?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然似乎很少达到的OpenGL 3.x的自身日期的引用文件,OpenGL的实际水平低的操作也比较简单。但是我有很大的麻烦试图连构思如何能操纵维也纳组织以呈现一个动态的世界。

Although there seem to be very few up to date references for OpenGL 3.x itself, the actual low level manipulation of OpenGL is relatively straight forward. However I am having serious trouble trying to even conceptualise how one would manipulate VBOs in order to render a dynamic world.

显然,旧的直接模式的方式是不适用的,但是从那里我在哪里去了?难道我写的一些场景的结构,然后将其转换为一组顶点和流即到VBO,我怎么会存储翻译数据?如果是的话怎么会那样子code明智?

Obviously the immediate mode ways of old are non applicable, but from there where do I go? Do I write some kind of scene structure and then convert that to a set of vertices and stream that to the VBO, how would I store translation data? If so how would that look code wise?

基本上真的不知道该如何继续。

Basically really unsure how to continue.

推荐答案

如果你的整个世界是真正的动态,你可以使用 GL_STREAM_DRAW_ARB 使用标志和重置数据每个帧。不要打扰操纵它,只是试图流尽可能高效。

If your entire world is truly dynamic, you can use the GL_STREAM_DRAW_ARB usage flag and reset the data on each frame. Don't bother manipulating it, just try to stream as efficient as possible.

不过,我假设你有一个场景组成的相对移动等多重刚性对象。在这种情况下,使用一个VBO每个对象,并指定 GL_STATIC_DRAW_ARB 使用标志。然后,您可以设置模型视图转换为对象的每个实例,并使用每个实例一个绘制调用渲染他们。

However, I assume that you have a scene that consists of multiple rigid objects that move relative to each other. In this case, use one VBO for each object and specify the GL_STATIC_DRAW_ARB usage flag. You can then set the modelview transform for each instance of an object and render them using one draw call per instance.

拇指(对PC)的规则是发出每MHz不超过一个绘制调用你的CPU。这是一个粗略估计,但有一定的道理吧。不要担心把多个独立的对象为单个VBO或其他性能的技巧,如果你留低于此限制。

A rule of thumb (on the PC) is to issue not more than one draw call per MHz of your CPU. This is a crude estimate, but there's some truth to it. Don't worry about putting multiple independent objects into a single VBO or other performance tricks if you stay below this limit.

这篇关于我如何使用OpenGL 3.x的维也纳组织来呈现一个动态的世界?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆