From bb3009c5fb6bc9e438225f35762cd9f7be442b91 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Sat, 8 Dec 2018 19:32:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AE=8C=E6=95=B4=E7=9A=84ds?= =?UTF-8?q?a=E6=89=A9=E5=B1=95=E6=A3=80=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/hgl/graph/RenderDriver.h | 20 +--------- src/RenderDriver/CMakeLists.txt | 4 +- src/RenderDriver/OpenGLExt.cpp | 62 ++++++++++++++++++++++++++++++- src/RenderDriver/Texture1D.cpp | 3 +- src/RenderDriver/VertexBuffer.cpp | 3 +- 5 files changed, 69 insertions(+), 23 deletions(-) diff --git a/inc/hgl/graph/RenderDriver.h b/inc/hgl/graph/RenderDriver.h index f50cbd1e..6f1aca39 100644 --- a/inc/hgl/graph/RenderDriver.h +++ b/inc/hgl/graph/RenderDriver.h @@ -6,25 +6,9 @@ namespace hgl { namespace graph { - /** - * 渲染驱动 - * 用于对真实渲染API的交接管理 - */ - class RenderDriver - { - private: - - RenderStatus current_status; - - public: - - virtual void SetCurStatus(const RenderStatus &)=0; - - virtual void ClearColorBuffer()=0; - virtual void ClearDepthBuffer()=0; - };//class RenderDriver - void InitOpenGLDebug(); + + bool IsSupportDSA(); }//namespace graph }//namespace hgl #endif//HGL_RENDER_DRIVER_INCLUDE diff --git a/src/RenderDriver/CMakeLists.txt b/src/RenderDriver/CMakeLists.txt index 0ddfb4db..cf4fdb1d 100644 --- a/src/RenderDriver/CMakeLists.txt +++ b/src/RenderDriver/CMakeLists.txt @@ -1,11 +1,11 @@ -add_library(ULRE.RenderDriver STATIC GLCore/RenderDriverGLCore.cpp +add_library(ULRE.RenderDriver STATIC OpenGLDebug.cpp + OpenGLExt.cpp GLSL.cpp Shader.cpp VertexArray.cpp VertexBuffer.cpp VertexBufferControlDSA.cpp VertexBufferControlBind.cpp - OpenGLDebug.cpp TextureFormat.cpp Texture1D.cpp Texture1DDSA.cpp diff --git a/src/RenderDriver/OpenGLExt.cpp b/src/RenderDriver/OpenGLExt.cpp index 324c8ccb..df659075 100644 --- a/src/RenderDriver/OpenGLExt.cpp +++ b/src/RenderDriver/OpenGLExt.cpp @@ -1,6 +1,66 @@ -#include +#include namespace hgl { + namespace graph + { + namespace + { + enum GLAPI_SUPPORT + { + gasNoSupport=-1, + gasNoCheck=0, + gasSupport=1 + }; + static GLAPI_SUPPORT support_dsa=gasNoCheck; + } + + bool IsSupportDSA() + { + if(support_dsa==gasSupport)return(true); + + //texture api + if(glCreateTextures + &&glGenerateTextureMipmap + &&glGetTextureLevelParameteriv + &&glGetTextureParameteriv + &&glGetCompressedTextureImage + &&glGetTextureImage + &&glBindTextureUnit + &&glCompressedTextureSubImage1D + &&glCompressedTextureSubImage2D + &&glTextureSubImage1D + &&glTextureSubImage2D + + //sampler object + &&glGenSamplers + &&glBindSampler + &&glSamplerParameteri + &&glSamplerParameterfv + + //vbo + &&glCreateBuffers + &&glNamedBufferData + &&glNamedBufferSubData + + //vao + &&glCreateVertexArrays + &&glDeleteVertexArrays + &&glVertexArrayAttribBinding + &&glVertexArrayAttribFormat + &&glVertexArrayAttribIFormat + &&glVertexArrayAttribLFormat + &&glEnableVertexArrayAttrib + &&glVertexArrayVertexBuffer + ) + { + support_dsa=gasSupport; + return(true); + } + + support_dsa=gasNoSupport; + return(false); + } + } }//namespace hgl diff --git a/src/RenderDriver/Texture1D.cpp b/src/RenderDriver/Texture1D.cpp index aabd69b7..b4d823ab 100644 --- a/src/RenderDriver/Texture1D.cpp +++ b/src/RenderDriver/Texture1D.cpp @@ -1,5 +1,6 @@ #include #include +#include namespace hgl { @@ -63,7 +64,7 @@ namespace hgl Texture1D *CreateTexture1D() { -// if(GLEW_VERSION_4_5||GLEW_ARB_direct_state_access||GL_EXT_direct_state_access) +// if(IsSupportDSA()) return CreateTexture1DDSA(); // else // return CreateTexture1DBind(); diff --git a/src/RenderDriver/VertexBuffer.cpp b/src/RenderDriver/VertexBuffer.cpp index c0d59bd2..be993b20 100644 --- a/src/RenderDriver/VertexBuffer.cpp +++ b/src/RenderDriver/VertexBuffer.cpp @@ -2,6 +2,7 @@ #include #include #include"VertexBufferControl.h" +#include namespace hgl { @@ -16,7 +17,7 @@ namespace hgl void InitVertexBufferAPI() { - if(GLEW_VERSION_4_5||GLEW_ARB_direct_state_access) + if(IsSupportDSA()) CreateVertexBufferControl=CreateVertexBufferControlDSA; else CreateVertexBufferControl=CreateVertexBufferControlBind;