Allolib  1.0
C++ Components For Interactive Multimedia
al_DefaultShaderString.hpp
1 #ifndef INCLUDE_AL_GRAPHICS_DEFAULT_SHADER_STRING_HPP
2 #define INCLUDE_AL_GRAPHICS_DEFAULT_SHADER_STRING_HPP
3 
4 #include <string>
5 
6 namespace al {
7 
8 struct ShaderSources {
9  std::string vert;
10  std::string frag;
11 };
12 
13 // should be higher than 3.3
14 const char* shaderVersionString(int major, int minor);
15 
16 // signature of the function is:
17 // `vec4 stereoDisplace (vec4 vertex, float eyeOffset, float focalLength)`
18 const char* stereoVertexDisplaceFunctionString(bool isOmni);
19 
20 // P: position
21 // C: color
22 // T: texcoord
23 //
24 // layout (location = 0) in vec3 vertexPosition;
25 // layout (location = 1) in vec4 vertexColor;
26 // layout (location = 2) in vec2 vertexTexcoord;
27 // layout (location = 3) in vec3 vertexNormal;
28 // uniform mat4 alModelViewMatrix;
29 // uniform mat4 alProjectrionMatrix;
30 // uniform mat4 alNormalMatrix;
31 // uniform float eyeOffset;
32 // uniform float focalLength;
33 std::string vertexShaderStringP(int major, int minor, bool isStereo,
34  bool isOmni, bool doLighting);
35 std::string vertexShaderStringPC(int major, int minor, bool isStereo,
36  bool isOmni, bool doLighting);
37 std::string vertexShaderStringPT(int major, int minor, bool isStereo,
38  bool isOmni, bool doLighting);
39 
40 // U: uniform color,
41 // C: per vertex color,
42 // T: per vertex texture sampling,
43 //
44 // uniform vec4 uColor;
45 // uniform sampler2D tex0;
46 // uniform vec4 lightPositionEyeCoord;
47 std::string fragShaderStringU(int major, int minor, bool doLighting);
48 std::string fragShaderStringC(int major, int minor, bool doLighting);
49 std::string fragShaderStringT(int major, int minor, bool doLighting);
50 
51 // convenience functions
52 // assumes version 3.3
53 // example usage:
54 // auto src = defaultShaderUniformColor(true, false, 3);
55 // myShader.compile(src.vert.str, src.frag.str);
56 ShaderSources defaultShaderUniformColor(bool isStereo, bool isOmni,
57  bool doLighting);
58 ShaderSources defaultShaderVertexColor(bool isStereo, bool isOmni,
59  bool doLighting);
60 ShaderSources defaultShaderTextureColor(bool isStereo, bool isOmni,
61  bool doLighting);
62 
63 } // namespace al
64 
65 #endif
Definition: al_App.hpp:23