问题描述
鉴于我拥有精灵的png,如何在OpenGL中渲染2D精灵?请参阅图像作为我想要达到的效果的示例.我也想在屏幕上覆盖武器,如底部图像中的步枪.有谁知道我将如何实现这两种效果?任何帮助是极大的赞赏.
How do I render 2D sprites in OpenGL given that I have a png of the sprite? See images as an example of the effect I'd like to achieve. Also I would like to overlay weapons on the screen like the rifle in the bottom image. Does anyone know how I would achieve the two effects? Any help is greatly appreciated.
推荐答案
在3D术语中,这称为广告牌".广告牌是完全平面的2D平面,上面带有纹理,并且始终面向摄像机.
In 3D terms, this is called a "billboard". A billboard is completely flat 2D plane with a texture on it and it always faces the camera.
有关纯OpenGL实现,请参见此处: http://nehe. gamedev.net/data/articles/article.asp?article=19
See here for a pure OpenGL implementation: http://nehe.gamedev.net/data/articles/article.asp?article=19
默认情况下,几乎所有3D引擎都应该能够做到.例如,Ogre3D可以做到.
Just about any 3D engine should be able to do them by default. Ogre3D can do it, for instance.
这篇关于在3D世界中渲染2D精灵?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!