diff options
author | chai <chaifix@163.com> | 2020-02-11 11:29:07 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2020-02-11 11:29:07 +0800 |
commit | 160e1299ef3d95f8e8c48706d7f61dd3dc6c6b60 (patch) | |
tree | abe5ae5242d9cc6caf6edf103e662c44e978fca0 /src/libjin/graphics/opengl.h | |
parent | e095043485d1d298571af6d9eca7f0db9009ea7a (diff) |
Diffstat (limited to 'src/libjin/graphics/opengl.h')
-rw-r--r-- | src/libjin/graphics/opengl.h | 412 |
1 files changed, 206 insertions, 206 deletions
diff --git a/src/libjin/graphics/opengl.h b/src/libjin/graphics/opengl.h index e97ebb6..c0a8a5d 100644 --- a/src/libjin/graphics/opengl.h +++ b/src/libjin/graphics/opengl.h @@ -13,258 +13,258 @@ namespace JinEngine { - namespace Graphics - { - // Wrap OpenGL API. + namespace Graphics + { + // Wrap OpenGL API. - namespace Shaders { class Shader; }; - namespace Fonts { class Font; }; + namespace Shaders { class Shader; }; + namespace Fonts { class Font; }; - class Texture; + class Texture; - class Canvas; + class Canvas; - class OpenGL - { - public: - /// - /// Blend mode. - /// https://www.andersriggelsen.dk/glblendfunc.php - /// - enum class BlendMode - { - ALPHA = 1, - ADDITIVE = 2, - PREMULTIPLIEDALPHA = 3, - }; + class OpenGL + { + public: + /// + /// Blend mode. + /// https://www.andersriggelsen.dk/glblendfunc.php + /// + enum class BlendMode + { + ALPHA = 1, + ADDITIVE = 2, + PREMULTIPLIEDALPHA = 3, + }; - struct Stats - { - int drawCalls; - //int drawCallsBatched; - int canvasSwitches; - int shaderSwitches; - int fontSwitches; - int textures; - int canvases; - int fonts; - //int64 textureMemory; - }; + struct Stats + { + int drawCalls; + //int drawCallsBatched; + int canvasSwitches; + int shaderSwitches; + int fontSwitches; + int textures; + int canvases; + int fonts; + //int64 textureMemory; + }; - static Canvas* const SCREEN; + static Canvas* const SCREEN; - OpenGL(); - ~OpenGL(); + OpenGL(); + ~OpenGL(); - bool loadGL(); + bool loadGL(); - void init(); + void init(); - void enable(GLenum cap); + void enable(GLenum cap); - void disable(GLenum cap); + void disable(GLenum cap); - void setClearColor(GLubyte r, GLubyte g, GLubyte b, GLubyte a); + void setClearColor(GLubyte r, GLubyte g, GLubyte b, GLubyte a); - void pushColor(GLubyte r, GLubyte g, GLubyte b, GLubyte a = 255); + void pushColor(GLubyte r, GLubyte g, GLubyte b, GLubyte a = 255); - void popColor(); - - void flushError(); - - GLuint genTexture(); - - void deleteTexture(GLuint texture); - - void bindTexture2D(GLuint texture = 0); - - void setTexParameter(GLenum pname, GLint param); - - void texImage(GLint internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels = NULL); - - void texSubImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); - - void activeTextureUnit(unsigned int unit = 0); + void popColor(); + + void flushError(); + + GLuint genTexture(); + + void deleteTexture(GLuint texture); + + void bindTexture2D(GLuint texture = 0); + + void setTexParameter(GLenum pname, GLint param); + + void texImage(GLint internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels = NULL); + + void texSubImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); + + void activeTextureUnit(unsigned int unit = 0); - void drawArrays(GLenum mode, GLint first, GLsizei count); + void drawArrays(GLenum mode, GLint first, GLsizei count); - void drawBuffer(GLenum mode); + void drawBuffer(GLenum mode); - void drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); + void drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); - void enableClientState(GLenum arr); + void enableClientState(GLenum arr); - void disableClientState(GLenum arr); + void disableClientState(GLenum arr); - GLuint genFrameBuffer(); + GLuint genFrameBuffer(); - void bindFrameBuffer(GLuint fbo); + void bindFrameBuffer(GLuint fbo); - void ortho(int w, float radio); + void ortho(int w, float radio); - void orthox(int w, int h); + void orthox(int w, int h); - void setColor(Channel r, Channel g, Channel b, Channel a); + void setColor(Channel r, Channel g, Channel b, Channel a); - void setColor(Color c); + void setColor(Color c); - Color getColor(); + Color getColor(); - void clearMatrix(); + void clearMatrix(); - void pushMatrix(); + void pushMatrix(); - void translate(float x, float y); + void translate(float x, float y); - void scale(float sx, float sy); + void scale(float sx, float sy); - void rotate(float r); + void rotate(float r); - void popMatrix(); + void popMatrix(); - /// - /// - /// - Math::Matrix getModelViewMatrix(const Math::Transform& tansform); - - /// - /// Get model view matrix. - /// - Math::Matrix getModelViewMatrix(float x, float y, float sx, float sy, float r, float ox, float oy); + /// + /// + /// + Math::Matrix getModelViewMatrix(const Math::Transform& tansform); + + /// + /// Get model view matrix. + /// + Math::Matrix getModelViewMatrix(float x, float y, float sx, float sy, float r, float ox, float oy); - /// - /// Get model view matrix. - /// - Math::Matrix getModelViewMatrix(); + /// + /// Get model view matrix. + /// + Math::Matrix getModelViewMatrix(); - /// - /// Set orthogonal matrix. - /// - void setProjectionMatrix(float l, float r, float b, float t, float n, float f); + /// + /// Set orthogonal matrix. + /// + void setProjectionMatrix(float l, float r, float b, float t, float n, float f); - /// - /// Get orthogonal matrix. - /// - const Math::Matrix& getProjectionMatrix(); + /// + /// Get orthogonal matrix. + /// + const Math::Matrix& getProjectionMatrix(); - /// - /// - /// - void useShader(Shaders::Shader* shader); + /// + /// + /// + void useShader(Shaders::Shader* shader); - /// - /// - /// - void unuseShader(); + /// + /// + /// + void unuseShader(); - /// - /// - /// - Shaders::Shader* getShader(); + /// + /// + /// + Shaders::Shader* getShader(); - /// - /// - /// - void setFont(Fonts::Font* font); + /// + /// + /// + void setFont(Fonts::Font* font); - /// - /// - /// - void unsetFont(); + /// + /// + /// + void unsetFont(); - /// - /// - /// - Fonts::Font* getFont(); + /// + /// + /// + Fonts::Font* getFont(); - /// - /// - /// - void bindCanvas(Canvas* canvas); + /// + /// + /// + void bindCanvas(Canvas* canvas); - /// - /// - /// - void unbindCanvas(); - - /// - /// - /// - Canvas* getCanvas(); + /// + /// + /// + void unbindCanvas(); + + /// + /// + /// + Canvas* getCanvas(); - /// - /// - /// - void setBlendMode(BlendMode mode); + /// + /// + /// + void setBlendMode(BlendMode mode); - /// - /// - /// - BlendMode getBlendMode(); - - /// - /// - /// - void resetStats(); - - /// - /// - /// - Stats& getStats(); - - private: - - /// - /// - /// - std::vector<Math::Matrix> mModelViewMatrices; - - /// - /// - /// - Math::Matrix mModelViewMatrix; - - /// - /// - /// - Math::Matrix mProjectionMatrix; - - /// - /// - /// - BlendMode mBlendMode; - - /// - /// - /// - Color mColor; - - /// - /// - /// - Canvas* mCanvas; - - /// - /// - /// - Shaders::Shader* mShader; - - /// - /// - /// - Fonts::Font* mFont; - - /// - /// - /// - Stats mStats; - - }; - - // Singleton. - extern OpenGL gl; - - } // namespace Graphics + /// + /// + /// + BlendMode getBlendMode(); + + /// + /// + /// + void resetStats(); + + /// + /// + /// + Stats& getStats(); + + private: + + /// + /// + /// + std::vector<Math::Matrix> mModelViewMatrices; + + /// + /// + /// + Math::Matrix mModelViewMatrix; + + /// + /// + /// + Math::Matrix mProjectionMatrix; + + /// + /// + /// + BlendMode mBlendMode; + + /// + /// + /// + Color mColor; + + /// + /// + /// + Canvas* mCanvas; + + /// + /// + /// + Shaders::Shader* mShader; + + /// + /// + /// + Fonts::Font* mFont; + + /// + /// + /// + Stats mStats; + + }; + + // Singleton. + extern OpenGL gl; + + } // namespace Graphics } // namespace JinEngine #endif // __JE_OPENGL_H__
\ No newline at end of file |