PDA

View Full Version : Fixed Function Pipeline vs. Shaders



akiradesu
11-17-2015, 04:07 AM
Hi. I'm new to OpenGL programming. I've read a few tutorials and tried some basic rendering. One thing confuses me is those tutorials are quite different in the way they use OpenGL. After reading this (https://www.opengl.org/wiki/Fixed_Function_Pipeline), I know that some tutorials may be outdated. Should we always use shaders for new programs instead of FFP? What is the generic programming pipeline of a 'modern' OpenGL program. And is it possible to use them together to gain benefits from both sides? Please help! Thanks:)

GClements
11-17-2015, 05:04 AM
The advantage of the fixed-function pipeline is that it will work on ancient hardware, and can reduce the amount of code which you need to write.

The disadvantage is that it's very limited compared to what can be achieved with shaders.

In OpenGL 2 or an OpenGL 3/4 compatibility profile, it's possible to mix shaders with the fixed-function pipeline. You can use a vertex shader without a fragment shader, or vice versa. Shaders can access compatibility uniform variables which are set using legacy functions (e.g. the model-view, projection and texture matrices which are manipulated via the legacy matrix functions are available via gl_ModelViewMatrix etc in the shaders), a vertex shader can access compatibility attributes set by glVertexPointer(), glColorPointer(), etc.

In an OpenGL 3 core profile, none of the legacy functionality is available. Apple MacOS X systems don't provide a compatibility profile; you can use either OpenGL 2.1 or OpenGL 3/4 core profile, so you can either use legacy functionality or newer functionality, but not both in the same program. OpenGL ES 2/3 and WebGL require a valid program containing a vertex shader and a fragment shader; there is no fixed-function pipeline.

All things considered, it's not really worth using legacy OpenGL unless the program needs to work on ancient hardware or the program is particularly trivial (meaning that the overhead of the "boilerplate" involved in creating a shader program is significant compared to the total size of the code).

akiradesu
11-17-2015, 06:03 AM
Thank you for your time, GClements. Your answer is really helpful.