aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/Graphics/Shader/Shader.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/libjin/Graphics/Shader/Shader.h')
-rw-r--r--src/libjin/Graphics/Shader/Shader.h123
1 files changed, 123 insertions, 0 deletions
diff --git a/src/libjin/Graphics/Shader/Shader.h b/src/libjin/Graphics/Shader/Shader.h
new file mode 100644
index 0000000..b9f83e7
--- /dev/null
+++ b/src/libjin/Graphics/Shader/Shader.h
@@ -0,0 +1,123 @@
+#ifndef __LIBJIN_SHADER_H
+#define __LIBJIN_SHADER_H
+#include "../../jin_configuration.h"
+#if LIBJIN_MODULES_RENDER
+
+#include <string>
+#include <map>
+#include "../../3rdparty/GLee/GLee.h"
+#include "../color.h"
+#include "../texture.h"
+#include "../canvas.h"
+#include "base.shader.h"
+
+namespace jin
+{
+ namespace graphics
+ {
+ ///
+ /// @details Built in shader program.
+ ///
+ class Shader
+ {
+ public:
+ ///
+ /// @brief Create shader program from source code.
+ ///
+ /// @param source The shader source code.
+ ///
+ static Shader* createShader(const std::string& source);
+
+ ///
+ /// @brief Get current shader.
+ ///
+ static inline Shader* getCurrentShader() { return CurrentShader; }
+
+ ///
+ /// @brief Unuse current shader
+ ///
+ static void unuse();
+
+ ///
+ ///
+ ///
+ virtual ~Shader();
+
+ ///
+ ///
+ ///
+ void use();
+
+ ///
+ ///
+ ///
+ void sendFloat(const char* name, float number);
+
+ ///
+ ///
+ ///
+ void sendTexture(const char* name, const Texture* image);
+
+ ///
+ ///
+ ///
+ void sendInt(const char* name, int value);
+
+ ///
+ ///
+ ///
+ void sendVec2(const char* name, float x, float y);
+
+ ///
+ ///
+ ///
+ void sendVec3(const char* name, float x, float y, float z);
+
+ ///
+ ///
+ ///
+ void sendVec4(const char* name, float x, float y, float z, float w);
+
+ ///
+ ///
+ ///
+ void sendCanvas(const char* name, const Canvas* canvas);
+
+ ///
+ ///
+ ///
+ void sendColor(const char* name, const Color* col);
+
+ ///
+ ///
+ ///
+ void sendMatrix4(const char* name, const math::Matrix* mat4);
+
+ ///
+ ///
+ ///
+ void bindVertexPointer(int n, GLenum type, GLsizei stride, const GLvoid * pointers);
+
+ ///
+ ///
+ ///
+ void bindUVPointer(int n, GLenum type, GLsizei stride, const GLvoid * pointers);
+
+ protected:
+ static Shader* CurrentShader;
+
+ GLint claimTextureUnit(const std::string& name);
+ Shader(const std::string& program);
+ bool compile(const std::string& program);
+
+ GLuint mPID;
+ GLint mCurrentTextureUnit;
+ std::map<std::string, GLint> mTextureUnits;
+
+ };
+
+ } // namespace graphics
+} // namespace jin
+
+#endif // LIBJIN_MODULES_RENDER
+#endif // __LIBJIN_SHADER_H \ No newline at end of file