增加GLBuffer::Create实现

This commit is contained in:
hyzboy 2019-03-31 21:16:57 +08:00
parent 514a4b37ca
commit c960f74204
3 changed files with 22 additions and 9 deletions

View File

@ -1,4 +1,5 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE)
PROJECT(ULRE) PROJECT(ULRE)

View File

@ -37,7 +37,7 @@ namespace hgl
public: public:
// bool Create (GLsizeiptr,GLenum up); ///<创建数据区 bool Create (GLsizeiptr); ///<创建数据区
bool Submit (void *,GLsizeiptr,GLenum up=GL_STATIC_DRAW); ///<提交数据 bool Submit (void *,GLsizeiptr,GLenum up=GL_STATIC_DRAW); ///<提交数据
bool Submit (const BufferData *,GLenum up=GL_STATIC_DRAW); ///<提交数据 bool Submit (const BufferData *,GLenum up=GL_STATIC_DRAW); ///<提交数据
bool Change (void *,GLsizeiptr,GLsizeiptr); ///<修改数据 bool Change (void *,GLsizeiptr,GLsizeiptr); ///<修改数据

View File

@ -18,7 +18,7 @@ namespace hgl
void BufferAlloc(GLenum type,GLuint index,GLsizeiptr size) void BufferAlloc(GLenum type,GLuint index,GLsizeiptr size)
{ {
glNamedBufferStorage(type,size,nullptr,GL_MAP_WRITE_BIT); glNamedBufferStorage(index,size,nullptr,GL_MAP_WRITE_BIT);
} }
void BufferData(GLenum type,GLuint index,void *data,GLsizeiptr size,GLenum user_pattern) void BufferData(GLenum type,GLuint index,void *data,GLsizeiptr size,GLenum user_pattern)
@ -66,6 +66,12 @@ namespace hgl
return index; return index;
} }
void BufferAlloc(GLenum type,GLuint index,GLsizeiptr size)
{
glBindBuffer(type,index);
glBufferStorage(type,size,nullptr,GL_MAP_WRITE_BIT);
}
void BufferData(GLenum type,GLuint index,void *data,GLsizeiptr size,GLenum user_pattern) void BufferData(GLenum type,GLuint index,void *data,GLsizeiptr size,GLenum user_pattern)
{ {
glBindBuffer(type,index); glBindBuffer(type,index);
@ -80,6 +86,7 @@ namespace hgl
} }
static GLuint(*CreateBuffer)(); static GLuint(*CreateBuffer)();
static void(*BufferAlloc)(GLenum type,GLuint index,GLsizeiptr size);
static void(*BufferData)(GLenum type,GLuint index,void *data,GLsizeiptr size,GLenum user_pattern); static void(*BufferData)(GLenum type,GLuint index,void *data,GLsizeiptr size,GLenum user_pattern);
static void(*BufferSubData)(GLenum type,GLuint index,void *data,GLsizeiptr start,GLsizeiptr size); static void(*BufferSubData)(GLenum type,GLuint index,void *data,GLsizeiptr start,GLsizeiptr size);
@ -90,6 +97,7 @@ namespace hgl
||glNamedBufferSubData) //dsa ||glNamedBufferSubData) //dsa
{ {
hgl::graph::gl::CreateBuffer=dsa::CreateBuffer; hgl::graph::gl::CreateBuffer=dsa::CreateBuffer;
hgl::graph::gl::BufferAlloc=dsa::BufferAlloc;
hgl::graph::gl::BufferData=dsa::BufferData; hgl::graph::gl::BufferData=dsa::BufferData;
hgl::graph::gl::BufferSubData=dsa::BufferSubData; hgl::graph::gl::BufferSubData=dsa::BufferSubData;
} }
@ -98,12 +106,14 @@ namespace hgl
||glNamedBufferSubDataEXT) ||glNamedBufferSubDataEXT)
{ {
hgl::graph::gl::CreateBuffer=bind::CreateBuffer; hgl::graph::gl::CreateBuffer=bind::CreateBuffer;
hgl::graph::gl::BufferAlloc=dsa_ext::BufferAlloc;
hgl::graph::gl::BufferData=dsa_ext::BufferData; hgl::graph::gl::BufferData=dsa_ext::BufferData;
hgl::graph::gl::BufferSubData=dsa_ext::BufferSubData; hgl::graph::gl::BufferSubData=dsa_ext::BufferSubData;
} }
else else
{ {
hgl::graph::gl::CreateBuffer=bind::CreateBuffer; hgl::graph::gl::CreateBuffer=bind::CreateBuffer;
hgl::graph::gl::BufferAlloc=bind::BufferAlloc;
hgl::graph::gl::BufferData=bind::BufferData; hgl::graph::gl::BufferData=bind::BufferData;
hgl::graph::gl::BufferSubData=bind::BufferSubData; hgl::graph::gl::BufferSubData=bind::BufferSubData;
} }
@ -127,12 +137,14 @@ namespace hgl
glDeleteBuffers(1,&buffer_index); glDeleteBuffers(1,&buffer_index);
} }
//bool BufferObject::Create(GLsizeiptr size,GLenum up) bool BufferObject::Create(GLsizeiptr size)
//{ {
// if(size<=0)return(false); if(size<=0)return(false);
// return true; gl::BufferAlloc(buffer_type,buffer_index,size);
//}
return true;
}
bool BufferObject::Submit(void *data,GLsizeiptr size,GLenum up) bool BufferObject::Submit(void *data,GLsizeiptr size,GLenum up)
{ {