diff options
Diffstat (limited to 'src/libjin/Graphics/Shader')
-rw-r--r-- | src/libjin/Graphics/Shader/Shader.h | 112 |
1 files changed, 93 insertions, 19 deletions
diff --git a/src/libjin/Graphics/Shader/Shader.h b/src/libjin/Graphics/Shader/Shader.h index b9f83e7..d1d843a 100644 --- a/src/libjin/Graphics/Shader/Shader.h +++ b/src/libjin/Graphics/Shader/Shader.h @@ -1,10 +1,12 @@ #ifndef __LIBJIN_SHADER_H #define __LIBJIN_SHADER_H + #include "../../jin_configuration.h" -#if LIBJIN_MODULES_RENDER +#if defined(jin_graphics) && defined(jin_graphics_shader) #include <string> #include <map> + #include "../../3rdparty/GLee/GLee.h" #include "../color.h" #include "../texture.h" @@ -16,98 +18,169 @@ namespace jin namespace graphics { /// - /// @details Built in shader program. + /// Built in shader program. + /// + /// Built in shader program written with custom shading language called JSL + /// (jin shading language). A JSL program is compiled into glsl, so most glsl + /// built in functions and structs are available in JSL. /// class Shader { public: /// - /// @brief Create shader program from source code. + /// Create shader program from source code. /// /// @param source The shader source code. /// static Shader* createShader(const std::string& source); /// - /// @brief Get current shader. + /// Get current shader. + /// + /// @return Current used shader program. /// static inline Shader* getCurrentShader() { return CurrentShader; } /// - /// @brief Unuse current shader + /// Unuse current shader. /// static void unuse(); /// - /// + /// Destructor of shader. /// virtual ~Shader(); /// - /// + /// Use specific shader. /// void use(); /// + /// Send float value to shader. /// + /// @param name Name of the uniform variable to be assigned. + /// @param number Value of uniform variable to be sent. /// void sendFloat(const char* name, float number); /// + /// Send texture to shader. + /// + /// @param name Name of the uniform variable to be assigned. + /// @param texture Texture to be sent. /// - /// - void sendTexture(const char* name, const Texture* image); + void sendTexture(const char* name, const Texture* texture); /// + /// Send integer value to shader /// + /// @param name Name of the uniform variable to be assigned. + /// @param value Value to be sent. /// void sendInt(const char* name, int value); /// + /// Send 2D vector to shader. /// + /// @param name Name of the uniform variable to be assigned. + /// @param x X value of the vector to be sent. + /// @param y Y value of the vector to be sent. /// void sendVec2(const char* name, float x, float y); - /// /// + /// Send 3D vector to shader. /// + /// @param name Name of the uniform variable to be assigned. + /// @param x X value of the vector to be sent. + /// @param y Y value of the vector to be sent. + /// @param z Z value of the vector to be sent. + /// void sendVec3(const char* name, float x, float y, float z); /// + /// Send 4D vector to shader. /// - /// + /// @param name Name of the uniform variable to be assigned. + /// @param x X value of the vector to be sent. + /// @param y Y value of the vector to be sent. + /// @param z Z value of the vector to be sent. + /// @param w W value of the vector to be sent. + /// void sendVec4(const char* name, float x, float y, float z, float w); /// - /// + /// Send canvas to shader. + /// + /// @param name Name of the uniform variable to be assigned. + /// @param canvas Canvas to be sent. /// void sendCanvas(const char* name, const Canvas* canvas); /// + /// Send color to shader. + /// + /// @param name Name of the uniform variable to be assigned. + /// @param color Color to be sent. /// - /// - void sendColor(const char* name, const Color* col); + void sendColor(const char* name, const Color* color); /// - /// - /// + /// Send 4 by 4 matrix to shader. + /// + /// @param name Name of the uniform variable to be assigned. + /// @param mat4 Matrix to be sent. + /// void sendMatrix4(const char* name, const math::Matrix* mat4); /// - /// + /// Set vertices value. + /// + /// @param n Number of vertices. + /// @param type Data type of each component in the array. + /// @param stride Byte offset between consecutive generic vertex attributes. + /// @param pointers Pointer to the first component of the first generic vertex + /// attribute in the array. /// void bindVertexPointer(int n, GLenum type, GLsizei stride, const GLvoid * pointers); /// - /// + /// Set texture UV coordinates. + /// + /// @param n Number of vertices. + /// @param type Data type of each component in the array. + /// @param stride Byte offset between consecutive generic vertex attributes. + /// @param pointers Pointer to the first component of the first generic vertex + /// attribute in the array. /// void bindUVPointer(int n, GLenum type, GLsizei stride, const GLvoid * pointers); protected: + /// + /// Reference of current used shader. + /// static Shader* CurrentShader; + /// + /// Get texture unit of the uniform texture. If not, assign one. + /// + /// @param name Name of the texture uniform variable. + /// @return Texture unit which texture variable be assigned. + /// GLint claimTextureUnit(const std::string& name); + + /// + /// Shader constructor. + /// Shader(const std::string& program); + + /// + /// Compile JSL program into GLSL source. + /// + /// @param program JSL source code. + /// @return Return true if compile successed, otherwise return false. + /// bool compile(const std::string& program); GLuint mPID; @@ -119,5 +192,6 @@ namespace jin } // namespace graphics } // namespace jin -#endif // LIBJIN_MODULES_RENDER +#endif // jin_graphics && jin_graphics_shader + #endif // __LIBJIN_SHADER_H
\ No newline at end of file |