/****************************************************************************** * File - DefaultShaders.h * Author - Joey Pollack * Date - 2018/01/12 (y/m/d) * Mod Date - 2018/01/12 (y/m/d) * Description - String definitions with default shader source code. * ******************************************************************************/ #ifndef DEFAULT_SHADERS_H_ #define DEFAULT_SHADERS_H_ namespace lunarium { struct { friend class OglGraphics; private: const char* DefaultShapeVertex = "#version 330 core\n\ layout(location = 0) in vec4 vertex;\ \ uniform mat4 model;\ uniform mat4 projection;\ \ void main()\ {\ gl_Position = projection * vec4(vertex.xy, 0.0, 1.0);\ }"; const char* DefaultShapeFragment = "#version 330 core\n\ in vec2 TexCoords;\ out vec4 color;\ \ uniform vec4 shapeColor;\ \ void main()\ {\ color = shapeColor;\ }"; const char* DefaultSpriteVertex = "#version 330 core\n\ layout(location = 0) in vec4 vertex;\ \ out vec2 TexCoords;\ \ uniform vec4 uvManip;\ uniform mat4 model;\ uniform mat4 projection;\ \ void main()\ {\ TexCoords = vec2(vertex.z * uvManip.x + uvManip.y, vertex.w * uvManip.z + uvManip.w);\ gl_Position = projection * model * vec4(vertex.xy, 0.0, 1.0);\ }"; const char* DefaultSpriteFragment = "#version 330 core\n\ in vec2 TexCoords;\ out vec4 color;\ \ uniform sampler2D image;\ uniform vec4 spriteColor;\ \ void main()\ {\ color = vec4(spriteColor) * texture(image, TexCoords);\ }"; const char* DefaultTextVertex = "#version 330 core\n\ layout(location = 0) in vec4 vertex; \ out vec2 TexCoords;\ \ uniform mat4 projection;\ \ void main()\ {\ gl_Position = projection * vec4(vertex.xy, 0.0, 1.0);\ TexCoords = vertex.zw;\ } "; const char* DefaultTextFragment = "#version 330 core\n\ in vec2 TexCoords;\ out vec4 color;\ \ uniform sampler2D text;\ uniform vec4 textColor;\ \ void main()\ {\ vec4 sampled = vec4(1.0, 1.0, 1.0, texture(text, TexCoords).r);\ color = vec4(textColor) * sampled;\ }"; } OGLDefaultShaders; } #endif // DEFAULT_SHADERS_H_