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. ?
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.