Contraz / demosys-py

A light high performance modern OpenGL 3.3+ Python Framework https://demosys-py.readthedocs.io/
ISC License
64 stars 5 forks source link

Shaders: Support loading separate shader files #42

Closed einarf closed 6 years ago

einarf commented 6 years ago

Currently we rely on a single glsl file with preprocessors separating each shader type.

#version 330

#if defined VERTEX_SHADER

// Vertex Shader
in vec3 in_position;
void main() {
    gl_Position = vec4(in_position, 1.0);
}

#elif defined FRAGMENT_SHADER

// Fragment Shader
out vec4 fragColor;
void main() {
    fragColor = vec4(1.0);
}

#endif

There are very good reasons to support mixing and matching different shaders and this would be fairly easy to achieve.

# Single file
shaders.load('test.glsl')
# Multiple files
shaders.load(vertex_shader='test.vert', fragment_shader='test.frag', .... etc)
einarf commented 6 years ago

We should also make shader loading pluggable. Make some base class and implement the standard loader. Then people can customize if needed.

einarf commented 6 years ago

Fixed