You have a couple of problems that will help implement this with shaders.
First of all, in addition to using fixed function functions, you also use immediate mode. Before you can move on to shaders, you must switch to vertex arrays. You can write a class that accepts immediate mode-like commands that will be between glBegin (...)
and glEnd (...)
and glEnd (...)
them into an array of vertices if you absolutely need to structure your software this way.
As for glTranslatef (...)
and glOrtho (...)
, this is nothing special. They create translation matrices and spelling projection matrices and multiply the βcurrentβ matrix by them. It is not clear which language you are using, but one possible replacement for these functions may come from using a library like glm
(C ++).
The biggest obstacle will be getting rid of the "current" state mentality, which comes with thinking in terms of a conveyor with a fixed function. With shaders, you have full control over each state, and you do not need to use functions that multiply the "current" matrix or set the "current" color. You can simply convey the exact matrix or color value that you need for your shader. This is the best way to approach these problems, and therefore I honestly think that you should completely abandon the fixed-function approach, and not try to imitate it.
That is why your desire to "use a conveyor with a fixed function, but have the flexibility of shaders" basically does not make much sense.
Having said all this, in OpenGL compatibility mode in GLSL there are reserved words that apply to many fixed function constructs. These include things like gl_MultiTexCoord<N>
, gl_ModelViewProjectionMatrix
, etc. They can be used as transitional assistance, but really should not be relied upon in the end.
source share