diff options
Diffstat (limited to 'src/libjin/graphics/je_gl.h')
-rw-r--r-- | src/libjin/graphics/je_gl.h | 127 |
1 files changed, 120 insertions, 7 deletions
diff --git a/src/libjin/graphics/je_gl.h b/src/libjin/graphics/je_gl.h index 134cfee..60b2396 100644 --- a/src/libjin/graphics/je_gl.h +++ b/src/libjin/graphics/je_gl.h @@ -7,7 +7,6 @@ #include "../math/je_transform.h" #include "GLee/GLee.h" -#include "ogl/OpenGL.h" #include "je_color.h" @@ -16,18 +15,112 @@ namespace JinEngine namespace Graphics { - /*class Canvas; + // Wrap OpenGL API. +/* + class Canvas; class Shader; class Font; */ - class OpenGL - : public ogl2d::OpenGL + + class OpenGL { public: /// + /// Blend mode. + /// https://www.andersriggelsen.dk/glblendfunc.php /// - /// + enum class BlendMode + { + NONE = 0, + ALPHA, + ADDITIVE, + PREMULTIPLIEDALPHA, + }; + OpenGL(); + ~OpenGL(); + + inline void enable(GLenum cap) + { + glEnable(cap); + } + + inline void disable(GLenum cap) + { + glDisable(cap); + } +/* + inline void setBlendFunc(GLenum sfactor, GLenum dfactor) + { + glBlendFunc(sfactor, dfactor); + } +*/ + inline void setClearColor(GLubyte r, GLubyte g, GLubyte b, GLubyte a) + { + glClearColor(r / 255.f, g / 255.f, b / 255.f, a / 255.f); + } + + void pushColor(GLubyte r, GLubyte g, GLubyte b, GLubyte a = 255); + void popColor(); + void flushError(); + GLuint genTexture(); + void deleteTexture(GLuint texture); + void bindTexture(GLuint texture = 0); + inline GLuint curTexture() + { + return mTexture; + } + 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 activeTexUnit(unsigned int unit = 0); + + inline void drawArrays(GLenum mode, GLint first, GLsizei count) + { + glDrawArrays(mode, first, count); + } + + inline void drawBuffer(GLenum mode) + { + + } + + inline void drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) + { + + } + + inline void enableClientState(GLenum arr) + { + glEnableClientState(arr); + } + + inline void disableClientState(GLenum arr) + { + glDisableClientState(arr); + } + + inline GLuint genFrameBuffer() + { + GLuint fbo; + glGenFramebuffers(1, &fbo); + return fbo; + } + + inline void bindFrameBuffer(GLuint fbo) + { + glBindFramebuffer(GL_FRAMEBUFFER, fbo); + } + + inline void ortho(int w, float radio) + { + glOrtho(0, w, w*radio, 0, -1, 1); + } + + inline void orthox(int w, int h) + { + glOrtho(0, w, h, 0, -1, 1); + } void setColor(Channel r, Channel g, Channel b, Channel a); @@ -37,7 +130,7 @@ namespace JinEngine void clearMatrix(); - void push(); + void pushMatrix(); void translate(float x, float y); @@ -45,7 +138,7 @@ namespace JinEngine void rotate(float r); - void pop(); + void popMatrix(); /// /// @@ -92,6 +185,16 @@ namespace JinEngine /// void unUseShader(); + /// + /// + /// + void setBlendMode(BlendMode mode); + + /// + /// + /// + BlendMode getBlendMode(); + private: /// @@ -113,6 +216,16 @@ namespace JinEngine /// /// Color mCurrentColor; + + /// + /// + /// + BlendMode mBlendMode; + + struct { GLubyte r, g, b, a; } mColor; // current draw color + struct { GLubyte r, g, b, a; } mPrecolor; // previous draw color + GLuint mTexture; // current binded texture + /* /// /// |