English 中文(简体)
New to OpenGL and deprecation [closed]
原标题:

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?

最佳回答

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.

问题回答

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/

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.





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签