Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do we compile shaders at runtime in OpenGL 2?

I have been trying to learn OpenGL, specifically for Android. I have seen various tutorials online, and I noticed that many of the tutorials for OpenGL 1.0, or 1.2 do not require compilation of shader programs, while the only tutorials I could find for OpenGL 2.0 all involve creating a custom shader to render shapes in the view.

The process of using a string to hold code (GLSL) and then compiling and linking this code at run-time feels cumbersome (hacky even). Is this necessary because GPU architectures can vary greatly?

Is there a way to use some kind of default shaders that don't require this step (like a built in shader)? I just want to be able to draw primitives like GL_POINTS, GL_LINES, etc.

like image 916
snapfractalpop Avatar asked Feb 10 '15 05:02

snapfractalpop


1 Answers

Is this necessary because GPU architectures can vary greatly?

Yes indeed and while there has been mentioning of an IR version of shaders there hasn't been a proper consensus about how it should look.

You can use glShaderBinary to precompile the shader in a previous run and reuse the compiled output.

like image 92
ratchet freak Avatar answered Nov 02 '22 17:11

ratchet freak