Shader.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 #ifndef H_DC_SHADER_INCLUDED
34 #define H_DC_SHADER_INCLUDED
35 
36 
37 #include <Dynacoe/Backends/Renderer/Renderer.h>
38 
39 namespace Dynacoe {
40 
41 
51 class Shader{
52  public:
53  Shader();
54  ~Shader();
55 
58  enum class Stage {
60  FragmentProcessor,
61  NotAStage
62  };
63 
66  enum class Status {
67  Invalid,
68  Success,
70  };
71 
76  void AddStage(Stage, const std::string &);
77 
83  void Compile();
84 
88  std::string GetLog();
89 
92  Status GetStatus();
93 
97  std::string GetShaderLanguage();
98 
101  ProgramID GetID(){return id;}
102 
103  private:
104  ProgramID id;
105  Status status;
106  struct StageData {
107  std::string src;
108  Stage stage;
109  };
110  std::string log;
111  StageData stages[(int)Stage::NotAStage];
112 
113 };
114 
115 
116 }
117 
118 
119 #endif
Stage
The stages that sources can be attached to.
Definition: Shader.h:58
std::string GetLog()
Returns any additional logging information from the shader program. If the status Invalid...
ProgramID GetID()
Returns a Renderer::ProgramID refering to this shader.
Definition: Shader.h:101
Compile() was called, but the compilation failed. AddStage() and Copmile() may be called again to fix...
void AddStage(Stage, const std::string &)
Adds a stage to the shader program. If the stage already exists and the program has not been compiled...
Definition: AssetID.h:37
std::string GetShaderLanguage()
Returns a string containing the shader language recognized by the Shaders. This is dependent on the p...
Status
The stauts of the program.
Definition: Shader.h:66
Compile has not yet been called.
First stage of the shader. Processes each vertex.
Status GetStatus()
Returns the current program status.
void Compile()
Finalizes the programs stages. After this call, GetStatus() will either return Success, meaning the program is now usable, or Invalid, meaning compilation failed. In the case of failure, GetLog() may contain more information as to why the compilation failed.
Compile() was successful and the Shader may be used in rendering. See Material.
Allows you to specify rendering programs usually on your GPU.
Definition: Shader.h:51