1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the libgltf project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  */
9 
10 #ifndef SHADERS_H
11 #define SHADERS_H
12 
13 #include <glm/glm.hpp>
14 
15 namespace libgltf
16 {
17 
18 class ShaderProgram
19 {
20 public:
21     // Setting integers
22     void setUniform(unsigned int uProgId, const char* name, int* iValues);
23     void setUniform(unsigned int uProgId, const char* name, const int iValue);
24     // Setting floats
25     void setUniform(unsigned int uProgId, const char* name, float* fValues);
26     void setUniform(unsigned int uProgId, const char* name,
27                     const float fValue);
28     // Setting vectors
29     void setUniform(unsigned int uProgId, const char* name,
30                     glm::vec2* vVectors);
31     void setUniform(unsigned int uProgId, const char* name,
32                     const glm::vec2 vVector);
33     void setUniform(unsigned int uProgId, const char* name,
34                     glm::vec3* vVectors);
35     void setUniform(unsigned int uProgId, const char* name,
36                     const glm::vec3 vVector);
37     void setUniform(unsigned int uProgId, const char* name,
38                     glm::vec4* vVectors);
39     void setUniform(unsigned int uProgId, const char* name,
40                     const glm::vec4 vVector);
41     // Setting 3x3 matrices
42     void setUniform(unsigned int uProgId, const char* name,
43                     glm::mat3* mMatrices);
44     void setUniform(unsigned int uProgId, const char* name,
45                     const glm::mat3 mMatrix);
46     // Setting 4x4 matrices
47     void setUniform(unsigned int uProgId, const char* name,
48                     glm::mat4* mMatrices);
49     void setUniform(unsigned int uProgId, const char* name,
50                     const glm::mat4 mMatrix);
51 
52     unsigned int createProgram(const char* pvShader, size_t ivShaderSize,
53                                const char* pfShader, size_t ifShaderSize);
54 
55     void deleteProgram(unsigned int programId);
56 
57     void useProgram(unsigned int programId);
58 
59     bool loadShader(unsigned int programId, const char* pShader, size_t iSize,
60                     int type);
61 private:
62 
63     bool compileShader(const char* pShader, size_t iSize,
64                        unsigned int shaderId);
65 
66     bool linkProgram(unsigned int programId, unsigned int shaderId);
67 
68     void deleteShader(unsigned int shaderId);
69 };
70 
71 } // namespace libgltf
72 
73 #endif
74 
75 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
76