summaryrefslogtreecommitdiff
path: root/source/modules/asura-core/graphics/gl.h
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-04-02 21:45:33 +0800
committerchai <chaifix@163.com>2019-04-02 21:45:33 +0800
commitaf7bdaa10ee71a319dc55c3c7556fa43a95c9dc9 (patch)
tree58611985001b78c5a76b78ae146fdb07dde31c1d /source/modules/asura-core/graphics/gl.h
parent250e30d73f09e9da2b5a81d0fbae63744ae12a73 (diff)
*misc
Diffstat (limited to 'source/modules/asura-core/graphics/gl.h')
-rw-r--r--source/modules/asura-core/graphics/gl.h40
1 files changed, 26 insertions, 14 deletions
diff --git a/source/modules/asura-core/graphics/gl.h b/source/modules/asura-core/graphics/gl.h
index 4d21a5a..9ca1f44 100644
--- a/source/modules/asura-core/graphics/gl.h
+++ b/source/modules/asura-core/graphics/gl.h
@@ -1,21 +1,28 @@
#ifndef __ASURA_ENGINE_OPENGL_H__
#define __ASURA_ENGINE_OPENGL_H__
-#include <asura-utils/math/rect.hpp>
+#include <stack>
#include <glad/glad.h>
+#include <asura-utils/math/rect.hpp>
+#include <asura-utils/math/matrix44.h>
+
+#include "matrix_stack.h"
+
namespace AsuraEngine
{
namespace Graphics
{
class Profiler;
+ class Shader;
///
- /// ÓÃÀ´×öһЩopengl״̬µÄ×·×Ù¡£Ôڱ༭Æ÷¶à´°¿Ú»·¾³Ï£¬Ò»¸ö´°¿Ú¶ÔÓ¦Ò»¸öhwnd£¬Ò»¸öhdc£¬ÒÔ¼°
- /// Êý¸öopengl context£¬Èç¹ûʹÓÃwglMakeCurrent(hdc, glc)Ö¸¶¨µ±Ç°Ï̶߳ú¶ääÖȾ´°¿ÚhdcºÍ
- /// openglÉÏÏÂÎÄglc£¬glÖмǼµÄ¾ÍÊÇÈÎÒâÒ»¸öÏ̵߳ÄÈÎÒâÒ»¸ö´°¿ÚµÄÈÎÒâÒ»¸öopenglÉÏÏÂÎĵÄ״̬£¬
+ /// OpenGLÉÏÏÂÎÄ£¬ÓÃÀ´×öһЩopengl״̬µÄ×·×Ù¡£Ôڱ༭Æ÷¶à´°¿Ú»·¾³Ï£¬Ò»¸ö´°¿Ú¶ÔÓ¦Ò»¸öhwnd£¬
+ /// Ò»¸öhdc£¬ÒÔ¼°Êý¸öopengl context£¬Èç¹ûʹÓÃwglMakeCurrent(hdc, glc)Ö¸¶¨µ±Ç°Ï̶߳ú¶ä
+ /// äÖȾ´°¿ÚhdcºÍopenglÉÏÏÂÎÄglc£¬glÖмǼµÄ¾ÍÊÇÈÎÒâÒ»¸öÏ̵߳ÄÈÎÒâÒ»¸ö´°¿ÚµÄÈÎÒâÒ»¸öOpenGL
+ /// ÉÏÏÂÎĵÄ״̬£¬
///
class OpenGL
{
@@ -26,23 +33,28 @@ namespace AsuraEngine
void SetViewport(const AEMath::Recti viewport);
AEMath::Recti GetViewport();
- private:
-
- friend class Profiler;
+ void UseShader(Shader* shader);
+ void UnuseShader();
- ///
- /// ¿ØÖÆopenglµ¥Àý¡£
///
- static bool instantiated;
-
- ///
- /// ¼Ç¼opengl״̬¡£
+ /// OpenGL3.0ÒÔºóÓÉÓû§¹ÜÀí¾ØÕó±ä»»¡¢ÊÓ¿Ú¡¢shaderµÈ²ÎÊý£¬ÕâÀï±£´æÒ»Ð©OpenGL״̬¡£×¢Òâ
+ /// ËÆºõÈ«½ø³ÌµÄ£¬Ò²¾ÍÊÇ˵£¬Asura²»Ö§³Ö¶àÏß³ÌäÖȾ¡£OpenGLÉÏÏÂÎĵĴ´½¨Ê¹µÃÒ»¸öÉÏÏÂ
+ /// Îİó¶¨ÔÚÒ»¸öHDC\´°¿ÚÉÏ£¬ÓÉÓÚ´°¿ÚÊÇÔÚÌØ¶¨Ï̴߳´½¨µÄ£¬ËùÒÔOpenGLÉÏÏÂÎÄÒ²°ó¶¨ÁËÒ»¸ö
+ /// ÌØ¶¨µÄÏ̡߳£Í¬Ò»¸öÏ̵߳IJ»Í¬HDC\´°¿Ú¿ÉÒÔ¹²Ïíͬһ¸öOpenGLÉÏÏÂÎÄ¡£¹²ÏíÉÏÏÂÎÄÊÇΪÁË
+ /// ¹²ÏíÉÏÏÂÎÄÖд´½¨µÄtextuer\shaderµÈhandle¡£
///
struct
{
- AEMath::Recti viewport;
+ Shader* shader; ///< µ±Ç°Ê¹ÓõÄshader
+ AEMath::Recti viewport; ///< µ±Ç°µÄÊÓÇø£¬ÔÚÇл»HDC»òÕß±¾´°¿Ú´óС¸Ä±ä»òÕß²¿·ÖË¢ÐÂʱ±ä¶¯
+ MatrixStack projectionMatrix; ///< ͶӰ¾ØÕó
+ MatrixStack modelViewMatrix; ///< ±ä»»¾ØÕó
} state;
+ private:
+
+ friend class Profiler;
+
};
///