Compare commits
2 commits
5bcb4cfdd3
...
ae236efe2b
Author | SHA1 | Date | |
---|---|---|---|
ae236efe2b | |||
38cabb6b32 |
5 changed files with 26 additions and 15 deletions
|
@ -7,7 +7,7 @@ namespace lt {
|
||||||
|
|
||||||
//==================== CONSTANT_BUFFER ====================//
|
//==================== CONSTANT_BUFFER ====================//
|
||||||
glConstantBuffer::glConstantBuffer(ConstantBufferIndex index, unsigned int size)
|
glConstantBuffer::glConstantBuffer(ConstantBufferIndex index, unsigned int size)
|
||||||
: m_buffer_id()
|
: m_buffer_id(NULL)
|
||||||
, m_index(static_cast<int>(index))
|
, m_index(static_cast<int>(index))
|
||||||
{
|
{
|
||||||
glCreateBuffers(1, &m_buffer_id);
|
glCreateBuffers(1, &m_buffer_id);
|
||||||
|
@ -40,7 +40,7 @@ void glConstantBuffer::un_map()
|
||||||
|
|
||||||
//==================== VERTEX_BUFFER ====================//
|
//==================== VERTEX_BUFFER ====================//
|
||||||
glVertexBuffer::glVertexBuffer(float *vertices, unsigned int stride, unsigned int count)
|
glVertexBuffer::glVertexBuffer(float *vertices, unsigned int stride, unsigned int count)
|
||||||
: m_buffer_id()
|
: m_buffer_id(NULL)
|
||||||
{
|
{
|
||||||
glCreateBuffers(1, &m_buffer_id);
|
glCreateBuffers(1, &m_buffer_id);
|
||||||
glNamedBufferData(
|
glNamedBufferData(
|
||||||
|
@ -63,7 +63,7 @@ void glVertexBuffer::bind()
|
||||||
|
|
||||||
void glVertexBuffer::un_bind()
|
void glVertexBuffer::un_bind()
|
||||||
{
|
{
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, {});
|
glBindBuffer(GL_ARRAY_BUFFER, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto glVertexBuffer::map() -> void *
|
auto glVertexBuffer::map() -> void *
|
||||||
|
@ -78,7 +78,7 @@ void glVertexBuffer::un_map()
|
||||||
//==================== VERTEX_BUFFER ====================//
|
//==================== VERTEX_BUFFER ====================//
|
||||||
|
|
||||||
//==================== INDEX_BUFFER ====================//
|
//==================== INDEX_BUFFER ====================//
|
||||||
glIndexBuffer::glIndexBuffer(unsigned int *indices, unsigned int count): m_buffer_id()
|
glIndexBuffer::glIndexBuffer(unsigned int *indices, unsigned int count): m_buffer_id(NULL)
|
||||||
{
|
{
|
||||||
// generate indices if not provided
|
// generate indices if not provided
|
||||||
auto hasIndices = !!indices;
|
auto hasIndices = !!indices;
|
||||||
|
@ -132,7 +132,7 @@ void glIndexBuffer::bind()
|
||||||
|
|
||||||
void glIndexBuffer::un_bind()
|
void glIndexBuffer::un_bind()
|
||||||
{
|
{
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, {});
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, NULL);
|
||||||
}
|
}
|
||||||
//==================== INDEX_BUFFER ====================//
|
//==================== INDEX_BUFFER ====================//
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,9 @@ namespace lt {
|
||||||
|
|
||||||
glFramebuffer::glFramebuffer(const FramebufferSpecification &specification)
|
glFramebuffer::glFramebuffer(const FramebufferSpecification &specification)
|
||||||
: m_specification(specification)
|
: m_specification(specification)
|
||||||
, m_buffer_id()
|
, m_buffer_id(NULL)
|
||||||
, m_color_attachment_id()
|
, m_color_attachment_id(NULL)
|
||||||
, m_depth_stencil_attachment_id()
|
, m_depth_stencil_attachment_id(NULL)
|
||||||
{
|
{
|
||||||
resize({ specification.width, specification.height });
|
resize({ specification.width, specification.height });
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ void glFramebuffer::resize(const glm::uvec2 &size)
|
||||||
GL_RGBA8,
|
GL_RGBA8,
|
||||||
m_specification.width,
|
m_specification.width,
|
||||||
m_specification.height,
|
m_specification.height,
|
||||||
{},
|
NULL,
|
||||||
GL_RGBA,
|
GL_RGBA,
|
||||||
GL_UNSIGNED_BYTE,
|
GL_UNSIGNED_BYTE,
|
||||||
nullptr
|
nullptr
|
||||||
|
@ -74,6 +74,17 @@ void glFramebuffer::resize(const glm::uvec2 &size)
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// glTextureStorage2D(m_color_attachment_id, 0, GL_RGBA8, m_specification.width,
|
||||||
|
// m_specification.height);
|
||||||
|
|
||||||
|
// glCreateTextures(GL_TEXTURE_2D, 1, &m_depth_stencil_attachment_id);
|
||||||
|
// glBindTexture(GL_TEXTURE_2D, m_depth_stencil_attachment_id);
|
||||||
|
// glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, m_specification.width,
|
||||||
|
// m_specification.height, NULL, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, nullptr);
|
||||||
|
// // glTextureStorage2D(m_depth_stencil_attachment_id, 0, GL_DEPTH24_STENCIL8,
|
||||||
|
// m_specification.width, m_specification.height); glFramebufferTexture2D(GL_FRAMEBUFFER,
|
||||||
|
// GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_depth_stencil_attachment_id, 0);
|
||||||
|
|
||||||
ensure(
|
ensure(
|
||||||
(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE),
|
(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE),
|
||||||
"Framebuffer is incomplete"
|
"Framebuffer is incomplete"
|
||||||
|
|
|
@ -33,7 +33,7 @@ void glRenderCommand::draw_indexed(unsigned int count)
|
||||||
|
|
||||||
void glRenderCommand::default_target_framebuffer()
|
void glRenderCommand::default_target_framebuffer()
|
||||||
{
|
{
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, {});
|
glBindFramebuffer(GL_FRAMEBUFFER, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void glRenderCommand::set_viewport(
|
void glRenderCommand::set_viewport(
|
||||||
|
|
|
@ -56,7 +56,7 @@ void glShader::bind()
|
||||||
|
|
||||||
void glShader::un_bind()
|
void glShader::un_bind()
|
||||||
{
|
{
|
||||||
glUseProgram({});
|
glUseProgram(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto glShader::compile_shader(const std::string &source, Shader::Stage stage) -> unsigned int
|
auto glShader::compile_shader(const std::string &source, Shader::Stage stage) -> unsigned int
|
||||||
|
@ -67,7 +67,7 @@ auto glShader::compile_shader(const std::string &source, Shader::Stage stage) ->
|
||||||
stage == Shader::Stage::vertex ? GL_VERTEX_SHADER :
|
stage == Shader::Stage::vertex ? GL_VERTEX_SHADER :
|
||||||
stage == Shader::Stage::pixel ? GL_FRAGMENT_SHADER :
|
stage == Shader::Stage::pixel ? GL_FRAGMENT_SHADER :
|
||||||
stage == Shader::Stage::geometry ? GL_GEOMETRY_SHADER :
|
stage == Shader::Stage::geometry ? GL_GEOMETRY_SHADER :
|
||||||
0
|
NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
// compile
|
// compile
|
||||||
|
@ -91,7 +91,7 @@ auto glShader::compile_shader(const std::string &source, Shader::Stage stage) ->
|
||||||
errorLog
|
errorLog
|
||||||
);
|
);
|
||||||
|
|
||||||
return {};
|
return NULL;
|
||||||
}
|
}
|
||||||
#define LIGHT_OPENGL_ENABLE_SHADER_INFO_LOG
|
#define LIGHT_OPENGL_ENABLE_SHADER_INFO_LOG
|
||||||
#ifdef LIGHT_OPENGL_ENABLE_SHADER_INFO_LOG
|
#ifdef LIGHT_OPENGL_ENABLE_SHADER_INFO_LOG
|
||||||
|
|
|
@ -9,7 +9,7 @@ glVertexLayout::glVertexLayout(
|
||||||
const Ref<VertexBuffer> &buffer,
|
const Ref<VertexBuffer> &buffer,
|
||||||
const std::vector<std::pair<std::string, VertexElementType>> &elements
|
const std::vector<std::pair<std::string, VertexElementType>> &elements
|
||||||
)
|
)
|
||||||
: m_array_id()
|
: m_array_id(NULL)
|
||||||
{
|
{
|
||||||
// check
|
// check
|
||||||
ensure(
|
ensure(
|
||||||
|
@ -65,7 +65,7 @@ void glVertexLayout::bind()
|
||||||
|
|
||||||
void glVertexLayout::un_bind()
|
void glVertexLayout::un_bind()
|
||||||
{
|
{
|
||||||
glBindVertexArray({});
|
glBindVertexArray(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto glVertexLayout::get_element_desc(VertexElementType type, unsigned int offset)
|
auto glVertexLayout::get_element_desc(VertexElementType type, unsigned int offset)
|
||||||
|
|
Loading…
Add table
Reference in a new issue