StaticProgram_GL3_1.h
1 /*
2 
3 Copyright (c) 2018, Johnathan Corkery. (jcorkery@umich.edu)
4 All rights reserved.
5 
6 This file is part of the Dynacoe project (https://github.com/jcorks/Dynacoe)
7 Dynacoe was released under the MIT License, as detailed below.
8 
9 
10 
11 Permission is hereby granted, free of charge, to any person obtaining a copy
12 of this software and associated documentation files (the "Software"), to deal
13 in the Software without restriction, including without limitation the rights
14 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 copies of the Software, and to permit persons to whom the Software is furnished
16 to do so, subject to the following conditions:
17 
18 The above copyright notice and this permission notice shall
19 be included in all copies or substantial portions of the Software.
20 
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 DEALINGS IN THE SOFTWARE.
28 
29 
30 
31 */
32 
33 #if ( defined DC_BACKENDS_SHADERGL_X11 || defined DC_BACKENDS_SHADERGL_WIN32 )
34 
35 #ifndef H_DC_STATICPROGRAM_GL3_1_INCLUDED
36 #define H_DC_STATICPROGRAM_GL3_1_INCLUDED
37 
38 #include <Dynacoe/Backends/Renderer/ShaderGL_Multi.h>
39 #include <Dynacoe/Backends/Renderer/ShaderGL/StaticProgram.h>
40 #include <string>
41 
42 namespace Dynacoe {
43 
44 
45 
46 class StaticProgram_GL3_1 : public StaticProgram {
47  public:
48  StaticProgram_GL3_1();
49 
50 
51 
52  bool Set(const char * vertexShader,
53  const char * fragShader,
54 
55  const std::string & name,
56  RenderBuffer * DynacoeView_uniformID,
57  RenderBuffer * Projection_uniformID,
58  RenderBuffer * DynacoeTexturePos_uniformID, // 4 components: xy pos, zw dims 0 -> GUT,
59  RenderBuffer * DynacoeTextureInfo_uniformID, // 4 component: x- enabled
60  RenderBuffer * DynacoeLighting_uniformID, // 4 components: xyz position, w intensity
61  RenderBuffer * DynacoeLightingInfo_uniformID // 4 components: xyz color, w type
62  );
63 
64  std::string GetLog();
65 
66  void Run(uint32_t *, uint32_t, RenderBuffer *, RenderBuffer *, RenderBuffer *, GLuint, GLuint);
67 
68  int MaxLights() { return 1024; }
69  int MaxTextures() { return 1022; }
70  private:
71  bool FailSet();
72 
73  void SetUniformBindings(RenderBuffer *, RenderBuffer *);
74  void SetVertexBinding(int);
75 
76  void printShaderLog(int shaderID);
77  void printProgramLog(int program);
78 
79 
80 
81  bool passedTexture;
82  int baseTextureActiveIndex;
83 
84  RenderBuffer * viewUniform;
85  RenderBuffer * projectionUniform;
86  RenderBuffer * textureUniformData;
87  RenderBuffer * lightUniformData;
88  RenderBuffer * textureUniformInfo;
89  RenderBuffer * lightUniformInfo;
90 
91  GLuint viewBindingIndex;
92  GLuint projectionBindingIndex;
93  GLuint textureBindingIndex;
94  GLuint lightingBindingIndex;
95 
96 
97 
98  std::string progName;
99  std::string log;
100  GLuint progID;
101  GLuint fragID;
102  GLuint vertID;
103 
104 };
105 
106 StaticProgram * CreateStaticProgram();
107 }
108 
109 
110 #endif
111 #endif
Definition: AssetID.h:37