OpenGL 新手和弃用

发布于 2024-08-18 06:44:49 字数 407 浏览 12 评论 0原文

我已经开始使用 PyOpenGL 3.0.1b 在 Python 中使用 OpenGL。

我查看了一些示例代码并开始运行它并修改它等等。一切都很顺利,直到我变得不那么无知了。

http://pyopengl.sourceforge.net/documentation/manual-3.0/index .xhtml 列出了 OpenGL 函数以及它们是否已弃用。所以我心想我只需要找到一些不使用所有这些已弃用的废话的最新教程。

几个小时后,没有这样的运气了!已弃用的示例代码又已弃用的示例代码...我可以在哪里获取未弃用的教程吗?

I've begun playing around with OpenGL in Python using PyOpenGL 3.0.1b.

I looked at some sample code and started running it and modifying it etc. All was well until I became a little less ignorant.

On http://pyopengl.sourceforge.net/documentation/manual-3.0/index.xhtml the OpenGL functions are listed as well as whether or not they are deprecated. So I thought to myself I'll just have to find some up to date tutorials that don't use all this deprecated crap.

Hours later, no such luck! Deprecated sample code after deprecated sample code... is there somewhere I can go for non-deprecated tutorials?

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

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

发布评论

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

评论(3

我爱人 2024-08-25 06:44:49

感谢 Jason L. McKesson

这里没有弃用的代码精彩的示例和教程(在 OpenGL 3.3 中)

http:// www.arcsynthesis.org/gltut/index.html

还有一个这里没有太多解释(在 OpenGL 4.x 和 3.3 中)

http://openglbook.com/the-book/

Thanks to Jason L. McKesson

No deprecated code fantastic examples and tutorials here (in OpenGL 3.3)

http://www.arcsynthesis.org/gltut/index.html

And another one without too much explanation here (in OpenGL 4.x and 3.3)

http://openglbook.com/the-book/

迷爱 2024-08-25 06:44:49

OpenGL ES 2.0 实际上与 OpenGL 3 非常相似,只是删除了一些功能(例如多个渲染目标、一些着色器指令等)。 《OpenGL ES 2.0编程指南》一书有一些教程和源代码可供下载,可以帮助您开始使用OpenGL 3.0。大多数情况下,在 ES 2.0 中编译的内容也将针对更新的 OpenGL 规范进行编译。您也可以在线搜索 ES 2.0 教程。

我还建议检查我正在开发的图形引擎( OpenREng )。您可以查看 OpenGL 包装类以查看较新规范中支持的大部分功能。

OpenGL ES 2.0 is in fact very similar to OpenGL 3, with some functionality removed (such as Multiple Render Targets, some shader instructions, etc). OpenGL ES 2.0 Programming Guide book has some tutorials and source codes available for download, which can help you get started with OpenGL 3.0 . What compiles in ES 2.0 will also compile for newer OpenGL specifications, mostly. You can search for ES 2.0 tutorials online, as well.

I would also recommend checking out the graphics engine I am developing ( OpenREng ). You can check out OpenGL wrapper classes to see most of the functionality supported in newer specifications.

情绪失控 2024-08-25 06:44:49

我建议学习的方法是采用一个固定功能的程序,并通过一次添加一位来慢慢开始将其转变为核心配置文件。基本上,您需要解决 3 个主要问题,不幸的是,这些问题都相当大,并且相互联系在一起,如果您在屏幕上没有看到任何内容,您将不知道哪一个部分损坏了。但如果你能以正确的方式去做,你应该没问题。

首先学习顶点缓冲区对象和顶点数组对象。抛弃 glBegin、glEnd、glVertex3f、glColor4f、glNormal3f、glTexCoord2f 等...

学习手动矩阵变换,抛弃 glRotatef、glTranslate、glPushMatrix、glPopMatrix、glMatrixMode、glLoadIdentity、GL_PROJECTION、GL_MODELVIEW、glFrustum、glOrtho、gluLookAt、gluPerspective、gluOrtho2。我建议查看 glm,这是 OpenGL 网站在其 SDK 中提到的一个。当您仍在非核心配置文件上使用固定功能组件时,您可以使用 glLoadMatrixf 手动加载矩阵,稍后您需要将矩阵绑定到着色器。

学习基本的 GLSL 着色器。有已弃用的 gl_vertex、gl_normal、ftransform() 应该仍然可以与 VBO 一起使用,您可以使用它们,直到完全设置着色器绑定。

然后进行所有着色器绑定,使用顶点属性而不是固定的 gl_vertex 和 gl_position。使用uniform上传模型视图和投影矩阵,而不是ftransform()。以及诸如灯光和材质属性之类的东西(我倾向于上传模型视图投影而不仅仅是投影,因此着色器不会每次都进行计算)。

最后使用核心配置文件,您将需要一个支持创建核心配置文件的窗口工具包。过剩,GLFW 都是如此。 SMFL 没有。 SDL 1.3-dev 可以。不幸的是,我不认为 pygame 会这样做。核心配置文件将放弃任何遗留下来的已弃用的功能。

The way I recommend learning is to take a fixed function program and slowly begin turning it into a core profile one by adding each bit at a time. There are basically 3 major things you need to tackle and unfortunately there all fairly big and tie in to each other in such a way that if you don't get anything on the screen you have no idea which bit is broken. But if you can go about it the correct way you should be fine.

Firstly learn Vertex Buffer Objects and Vertex Array Object. To ditch glBegin, glEnd, glVertex3f, glColor4f, glNormal3f, glTexCoord2f, etc...

Learn manual matrix transformations to ditch glRotatef, glTranslate, glPushMatrix, glPopMatrix, glMatrixMode, glLoadIdentity, GL_PROJECTION, GL_MODELVIEW, glFrustum, glOrtho, gluLookAt, gluPerspective, gluOrtho2. I recommend looking at glm which is the one the OpenGL site mentions in their SDK. While you are still using the fixed function components on the non-core profile you can manually load the matrix with glLoadMatrixf, later you will need to bind the matrices to the shaders.

Learn basic GLSL shaders. There are deprecated gl_vertex, gl_normal, ftransform() that should still work with VBO's, you can use them until you have the shader bindings fully setup.

Then do all the shader binding, use vertex attributes instead of the fixed gl_vertex and gl_position. Use uniform's to upload the modelview, and projection matrices rather the ftransform(). and things like lights and material properties (I tend to upload the modelviewprojection instead of just the projection so the shader isn't calculating that each time).

Finally use a core profile, you will need a windowing toolkit that supports creating one. GLUT, GLFW do. SMFL doesn't. SDL 1.3-dev does. I don't think pygame does unfortunately. The core profile will ditch any deprecated functionality that was left lying around.

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