Non-Deprecated Essentials Hints

Hi. Every shader tutorial and example I’ve found contains a lot of deprecated function usage. I need either an example, or a few particular clues (below).

I’m familiar (as a novice) with old (~year 2000) OpenGL, but I’m a complete newbie it seems to GL 3.2 - 4.*, shaders, and non-deprecated ways of doing awesome graphics in OpenGL. I can’t wait to get comfortable enough to start making the gpu show its capabilities.

I need either a good (doing things the right way) example of a “hello rotated, translated and depth-buffered triangle” shader program (in c++), or some pointers on where to take the old OpenGL functions and objects. Just some terse clues and keywords below would be a lot of help. I’m comfortable already with buffers, vertexAttributes, and shader compile, link and loading, varying and uniform. I’d like to begin with just core functionality, no non-promoted extensions should be necessary.

So, in case no good examples materialize, here is my list of what I think the essential functions and objects (in terms of the old OpenGL) are for making a “hello triangle”, with any rotation and translation and depth-culling, using shaders, and no deprecated functions or objects (I’m using gl3w and freeglut, and have GL 3.2 and higher.)

Please say 1) What (if any) is the (non-deprecated) reserved function or object name to use, 2) Where to set it up (cpu or vertex shader (vs) or fragment shader (fs)), 3) where to use it (cpu or vs or fs), for each of the following old essentials in the new OGL order. I know I have flexibility to do some things on the cpu or gpu as I please, but I’d like to start with some kind of best-practice. I’ve tried to fill in the answers to ModelViewMatrix and a few others myself, for examples. Please correct me where I’m wrong:

ModelViewMatrix – You allocate your own. Set it up on the cpu. Use it in the vs.
ProjectionMatrix – ?
Clip volume / clipping – ProjectionMatrix sets this up. It then happens automatically after fs. ?
Perspective division – Automatic, given 4-vec vertexes, as: gl_Position = vec4(in_Position, 1.0); ?
ViewportTransformation – glViewPort() as before, in cpu. Xfrm happens automatically after fs. ?
glClearColor() –
glClearDepth() –
glClear(depthbuffer. and framebuffer colors) – glClear(). Not deprecated.
glFrustum/ortho() – Make your own Projection Matrix. There are utilities for this.
glTranslatef() – Deprecated. Transform your own ModelViewMatrix on the cpu. GLM helps.
glRotated() – Same as Translate().
glEnable( GL_LIGHTING ) – Deprecated. Do your own lights, setup on cpu, use in vs and fs.
glEnable( GL_DEPTH_TEST ) –
glDepthMask( GL_TRUE ) –
glDepthFunc( GL_LESS ) –
glShadeModel() – manual, between the vs and fs.
glPushMatrix() – deprecated. Do it yourself on the cpu.
SwapBuffers() – No change. manual, cpu
glBegin()/glEnd() – deprecated. use e.g., glDrawArrays(GL_TRIANGLES, 0, 3)

Without glBegin(TRIANGLE), how would you make a triangle? I can guess how to position and light the 3 vertexes; but how to let fs know to interpolate lighting from 3 vertexes? Answer: glDrawArrays(GL_TRIANGLES, 0, 3)

I just looked up “opengl make a triangle”, and found https…opengltutorialsbyaks/introduction-to-opengl-3-2—tutorial-01, which answered some of the above, but not all.


Every shader tutorial and example I’ve found contains a lot of deprecated function usage.

The very first Google search result for “OpenGL Tutorial” is the OpenGL site. Which, sure enough, uses core OpenGL 3.3. It’s not 2008 when this stuff was hard to find. The OpenGL Wiki maintains a list of over half-a-dozen such tutorials.

“hello rotated, translated and depth-buffered triangle” shader program

That is not a “hello triangle” program. The amount of stuff you need to understand before you get to “translated” and “depth-buffered” is significant. A proper “hello triangle” program is just about putting a triangle on the screen. Moving it, having multiple triangles (which is where a “depth buffer” would come in), and so forth is beyond the level of “hello triangle”.

In any case, you’re trying to learn this the wrong way. What you need to do is forget everything you think you know about OpenGL, rendering, and the like. Then read through one of the longer sets of tutorials, starting from the beginning and walking straight through. Don’t try to skim through them to figure out how to replace <insert function name here>. Just learn what they teach you.

By the end, you’ll understand what you need to know.

I’m comfortable already with buffers, vertexAttributes, and shader compile, link and loading, varying and uniform.

I can guess how to position and light the 3 vertexes; but how to let fs know to interpolate lighting from 3 vertexes?

You cannot be both “comfortable with […] varying” and not know how interpolation works. Again, it is best to forget everything you think you know and just absorb the information as it is presented to you.

nitpicking mode on Roaoul: this stuff isn’t deprecated. It was deprecated in OpenGL 3.0 - it was removed in core OpenGL 3.1. The only reason this stuff is still around is GL_ARB_compatibility and, starting with GL 3.2, the optional compatibility profile. nitpicking mode off

First, forget that glBegin/glEnd ever existed. Client-side vertex arrays have been available since 1.1, and that’s a lot closer to the modern way.

Next, all of the gl*Pointer functions (glVertexPointer, glNormalPointer, etc) have been replaced with glVertexAttribPointer (or glVertexAttribBinding and glVertexAttribFormat). Also, using a pointer to client memory has been replaced with passing an offset into a buffer.

Almost everything else that has been removed has been replaced by uniform variables (glUniform etc). Anything which sets a “parameter” for the fixed-function pipeline has been replaced by setting a uniform for use in your shaders.

Some removed features don’t have direct equivalents, but can be implemented using newer features. E.g. accumulation buffers no longer exist, but the same effect can be obtained by using framebuffer objects and blending. Evaluators (glMap*, glEval* etc) have been removed, but can be implemented using tessellation shaders. glRenderMode() has been removed, but selection and feedback can be implemented using transform-feedback mode.

While not deprecated, these have been supplemented with glClearBuffer(), which allows the use of integer values for clearing colour buffers with an integer format.

Everything related to depth testing is still present.


Thanks! Your link is perfect! I will plod (scamper?!) through those tutorials. They look wonderful.
Also thanks for your advice to forget all and start fresh. I just needed a clean tutorial to follow that wasn’t carrying a lot of deprecated things I will still have to unlearn when I am done. You’ve steered me well, Obi-Wan! :slight_smile:

In defense of my apparent stupidity: :stuck_out_tongue:
I followed the links on “coding resources, sample code and tutorials” through to wiki/Code_Resources and wiki/Getting_started, and ended up in several places like the admittedly outdated Code_Resources. I had followed the “coding resources, getting started” tabs before, but the link to was buried among several of the non-core using links I burned myself out on before resorting to YOU! :slight_smile: Thanks to you I’m on a good track now. RE: My overly-advanced “hello, triangle” – Parts of what I want in a basic functionality were covered in some tutorials I’d seen, but not all. I don’t want the whole thing (textures, extensions, packs like GLM) before I get a basic functionality. RE: Interpolation. I wasn’t asking how interpolation (varying) worked, but how fs knows to interpolate from a particular 3 vertices, basically, what is the keyword to replace glBegin(TRIANGLE)? I think the answer is glDrawArrays(GL_TRIANGLES…).

Thanks again!!

thokra, Thanks, that was itching. :wink: So everything I flagged as deprecated should instead show as “removed”? But I also really don’t want to use deprecated functions either, for fear they will be removed in future. So I’m (dis)interested in anything deprecated or removed. Thanks again for the distinction. I’ll try not to bring any more vermin in here. :slight_smile:

GClements, I just keep saying “awesome” reading your text. Most makes great sense, some is over my head, but I’ll watch for them in the tutorials Alfonse showed me.

All, You guys really helped me. This is what I wanted / needed. Thanks! Back to school now-