StaticProgram_GL2_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_GL2_1_INCLUDED
36 #define H_DC_STATICPROGRAM_GL2_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_GL2_1 : public StaticProgram {
47  public:
48  StaticProgram_GL2_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 
69  int MaxLights() { return 128; }
70  int MaxTextures() { return 64; }
71 
72  private:
73  bool FailSet();
74 
75 
76  void UpdateUniforms(RenderBuffer * model, RenderBuffer * material);
77 
78  void printShaderLog(int shaderID);
79  void printProgramLog(int program);
80 
81  int progID;
82  int vertID;
83  int fragID;
84  int uniformIndex;
85 
86  bool passedTexture;
87  int baseTextureActiveIndex;
88 
89 
90  std::string progName;
91  std::string log;
92  bool incomplete;
93 
94  RenderBuffer * viewUniform;
95  RenderBuffer * projectionUniform;
96  RenderBuffer * textureUniform;
97  RenderBuffer * lightingUniform;
98  RenderBuffer * textureUniformInfo;
99  RenderBuffer * lightingUniformInfo;
100 
101  int viewUniform_location;
102  int projectionUniform_location;
103  int textureInfoUniform_location;
104  int lightingDataUniform_location;
105  int lightingInfoUniform_location;
106  int textureDataUniform_location;
107 
108  int lightingHeightUniform_location;
109  int textureHeightUniform_location;
110  int materialUniform_location;
111  int materialDataUniform_location;
112  int modelUniform_location;
113 
114  int fbTexture_location;
115  int baseTexture_location;
116  int hasFbTexture_location;
117 
118 };
119 
120 StaticProgram * CreateStaticProgram();
121 }
122 
123 
124 #endif
125 #endif
Definition: AssetID.h:37