3

I have been tearing my hair out for a while over this. I need an OpenGL 3.2 Core (no deprecated stuff!) way to efficiently render many sprites, using batching (no instancing).

I've seen examples that do this with geometry alone, but mine also needs to send textures to it, I don't know how to do this.

I need a well done example of it working in action. And looking at how other libs like monogame and such do it isn't much help, because all I'm interested in is the GL code, and it has to have no deprecated stuff in it.

Basically I want to be able to efficiently render thousands+ of sprites, all having textures. The texture is just a spritesheet, so I just need to tell it to render a region of that spritesheet.

I'm disappointed in the amount of material available for programmable pipeline. To the point where it seems like it'd be so much easier to just say screw it and use fixed pipeline, even though I definitely don't want to do that.

So yeah, any full examples that do what I want? Or could somebody more knowledgable write one up? :)

A lot of the examples are "oh, here's how you render 1 triangle". Well that's great, except nobody needs to render only 1 triangle/quad. And they need to be textured in addition to that!

An example that uses VBOs/VAOs/EBOs

ALSO: this means the code can't use glTexPointer and that stuff, but just in raw VBOs/VAOs...

4

1 回答 1

3

我看到了这个问题,并决定编写一个小程序,使用点和 gl_PointSize 进行一些“精灵”渲染。我不太清楚你所说的“批处理”是什么意思,而不是“实例化”,但我的程序使用 glDrawArraysInstanced() 调用,这样我就可以渲染多个点,而不需要我的 VBO 是可变大小的。我的代码也不会对精灵进行纹理处理,但这很容易添加(使用 glUniform1i 将活动纹理索引(在调用 glTexSubImage 期间处于活动状态的索引)上传到 GLSL sampler2D)。

无论如何,这是我写的程序:http: //litherum.blogspot.com/2013/02/sprites-in-opengl-programmable-pipeline.html希望你能从中学习!

于 2013-02-28T06:47:38.853 回答