adbrown85/glycerin — Issue #5: Add a shader builder
Author: adbrown85
Created: 2012-02-08 02:43:31+00:00
State: open

OpenGL is very open-ended when it comes to shaders, which means it takes several steps to make one. For that reason it would be great to have a low-level utility for creating shaders. To keep it in line with traditional design patterns, we would like to call it *ShaderBuilder*.

To maintain the flexibility of the OpenGL shader API, *ShaderBuilder* will try to be as low-level as possible yet extremely easy-to-use. For that reason it will basically have two methods. One to add lines, and another to make the shader. Here is a simple UML stub for the class:

> ShaderBuilder
> + addLine(line : string)
> + toShader(type : GLenum) : GLuint

To make it even simpler, there will be no *clear* method. When *toShader* is called it will just make the shader and then clear all its state automatically.

OpenGL is of course meant to be used with C so the user is required to check errors explicitly. Again, to make things easy *ShaderBuilder* will not require that. When *toShader* is called it will check that the shader compiled successfully. If it did not it will throw an exception with the log message.

----

Some issues that are worth considering:

- Should we append newline characters to the lines that are added?
- Should we allow empty lines?