增加GLBuffer::Create实现
This commit is contained in:
parent
514a4b37ca
commit
c960f74204
@ -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)
|
||||||
|
|
||||||
|
@ -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); ///<修改数据
|
||||||
@ -71,7 +71,7 @@ namespace hgl
|
|||||||
* @param user_pattern 数据存储区使用模式(GL_STATIC_DRAW,GL_DYNAMIC_DRAW等)
|
* @param user_pattern 数据存储区使用模式(GL_STATIC_DRAW,GL_DYNAMIC_DRAW等)
|
||||||
* @param buf 数据缓冲区
|
* @param buf 数据缓冲区
|
||||||
*/
|
*/
|
||||||
template<typename BO,typename BD>
|
template<typename BO,typename BD>
|
||||||
inline BO *_CreateBufferObject(BD *buf=nullptr,const GLenum &user_pattern=GL_STATIC_DRAW)
|
inline BO *_CreateBufferObject(BD *buf=nullptr,const GLenum &user_pattern=GL_STATIC_DRAW)
|
||||||
{
|
{
|
||||||
BO *obj=new BO();
|
BO *obj=new BO();
|
||||||
@ -151,7 +151,7 @@ namespace hgl
|
|||||||
return _CreateBufferObject<buffer_class_name>(data,size,user_pattern); \
|
return _CreateBufferObject<buffer_class_name>(data,size,user_pattern); \
|
||||||
}
|
}
|
||||||
|
|
||||||
//ps.在这里用宏了再用模板本是多此一举,但使用模板函数易于调试器中进行逐行调试,同时因为INLINE编译编译器也会自动展开代码,不用担心效率
|
//ps.在这里用宏了再用模板本是多此一举,但使用模板函数易于调试器中进行逐行调试,同时因为INLINE编译编译器也会自动展开代码,不用担心效率
|
||||||
|
|
||||||
VBCLASS_DEF(GL_ARRAY_BUFFER, ArrayBuffer, VertexBufferObject, VertexBufferData, VBO)
|
VBCLASS_DEF(GL_ARRAY_BUFFER, ArrayBuffer, VertexBufferObject, VertexBufferData, VBO)
|
||||||
VBCLASS_DEF(GL_ELEMENT_ARRAY_BUFFER, ElementBuffer, VertexBufferObject, VertexBufferData, EBO)
|
VBCLASS_DEF(GL_ELEMENT_ARRAY_BUFFER, ElementBuffer, VertexBufferObject, VertexBufferData, EBO)
|
||||||
|
@ -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)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user