- Improved sc function binder.

- Improved GLGSRender.
This commit is contained in:
DH 2013-06-30 11:46:29 +03:00
parent 3bb7a299ca
commit 5753edf6ef
133 changed files with 13624 additions and 3898 deletions

View file

@ -2,52 +2,118 @@
#include "GLBuffers.h"
#include "GLGSRender.h"
BufferObject::BufferObject()
: m_id(0)
, m_type(0)
GLBufferObject::GLBufferObject()
{
}
BufferObject::BufferObject(u32 type)
: m_id(0)
, m_type(0)
GLBufferObject::GLBufferObject(u32 type)
{
Create(type);
}
void BufferObject::Create(u32 type)
GLBufferObject::~GLBufferObject()
{
if(m_id) return;
glGenBuffers(1, &m_id);
Delete();
}
void GLBufferObject::Create(GLuint type, u32 count)
{
if(IsCreated()) return;
m_id.InsertRoomEnd(count);
glGenBuffers(count, &m_id[0]);
m_type = type;
}
void BufferObject::Delete()
void GLBufferObject::Delete()
{
if(!m_id) return;
glDeleteBuffers(1, &m_id);
m_id = 0;
if(!IsCreated()) return;
glDeleteBuffers(m_id.GetCount(), &m_id[0]);
m_id.Clear();
m_type = 0;
}
void BufferObject::Bind()
void GLBufferObject::Bind(u32 type, u32 num)
{
if(m_id) glBindBuffer(m_type, m_id);
glBindBuffer(type, m_id[num]);
}
void BufferObject::UnBind()
void GLBufferObject::UnBind(u32 type)
{
glBindBuffer(m_type, 0);
glBindBuffer(type, 0);
}
void BufferObject::SetData(const void* data, u32 size, u32 type)
void GLBufferObject::Bind(u32 num)
{
if(!m_type) return;
Bind();
glBufferData(m_type, size, data, type);
Bind(m_type, num);
}
void VBO::Create()
void GLBufferObject::UnBind()
{
BufferObject::Create(GL_ARRAY_BUFFER);
UnBind(m_type);
}
void GLBufferObject::SetData(u32 type, const void* data, u32 size, u32 usage)
{
glBufferData(type, size, data, usage);
}
void GLBufferObject::SetData(const void* data, u32 size, u32 usage)
{
SetData(m_type, data, size, usage);
}
void GLBufferObject::SetAttribPointer(int location, int size, int type, int pointer, int stride, bool normalized)
{
if(location < 0) return;
glVertexAttribPointer(location, size, type, normalized ? GL_TRUE : GL_FALSE, stride, (const GLvoid*)pointer);
glEnableVertexAttribArray(location);
}
bool GLBufferObject::IsCreated() const
{
return m_id.GetCount() != 0;
}
GLvbo::GLvbo()
{
}
void GLvbo::Create(u32 count)
{
GLBufferObject::Create(GL_ARRAY_BUFFER, count);
}
GLvao::GLvao() : m_id(0)
{
}
GLvao::~GLvao()
{
Delete();
}
void GLvao::Create()
{
if(!IsCreated()) glGenVertexArrays(1, &m_id);
}
void GLvao::Bind() const
{
glBindVertexArray(m_id);
}
void GLvao::Delete()
{
if(!IsCreated()) return;
glDeleteVertexArrays(1, &m_id);
m_id = 0;
}
bool GLvao::IsCreated() const
{
return m_id != 0;
}