postprocess is on the way
parent
eaf15046b4
commit
e674819344
include/blt/gfx
renderer/shaders
src/blt/gfx
|
@ -1,6 +1,6 @@
|
|||
cmake_minimum_required(VERSION 3.25)
|
||||
|
||||
set(BLT_GRAPHICS_VERSION 0.13.8)
|
||||
set(BLT_GRAPHICS_VERSION 0.13.9)
|
||||
set(BLT_GRAPHICS_TEST_VERSION 0.0.1)
|
||||
|
||||
project(BLT_WITH_GRAPHICS VERSION ${BLT_GRAPHICS_VERSION})
|
||||
|
|
|
@ -8,9 +8,13 @@
|
|||
#ifndef BLT_GL_INCLUDES_H
|
||||
#define BLT_GL_INCLUDES_H
|
||||
|
||||
#include <blt/std/logging.h>
|
||||
|
||||
// emscripten provides its own gl bindings.
|
||||
#ifndef __EMSCRIPTEN__
|
||||
|
||||
#include <glad/gl.h>
|
||||
|
||||
#else
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES3/gl3.h>
|
||||
|
@ -21,4 +25,40 @@
|
|||
#define EGL_EGLEXT_PROTOTYPES
|
||||
#endif
|
||||
|
||||
namespace blt::gfx
|
||||
{
|
||||
inline std::string get_error_message(GLenum error)
|
||||
{
|
||||
switch (error)
|
||||
{
|
||||
case GL_INVALID_ENUM:
|
||||
return "Invalid Enum";
|
||||
case GL_INVALID_VALUE:
|
||||
return "Invalid Value";
|
||||
case GL_INVALID_OPERATION:
|
||||
return "Invalid Operation";
|
||||
case GL_STACK_OVERFLOW:
|
||||
return "Stack Overflow";
|
||||
case GL_STACK_UNDERFLOW:
|
||||
return "Stack Underflow";
|
||||
case GL_OUT_OF_MEMORY:
|
||||
return "Out Of Memory";
|
||||
case GL_INVALID_FRAMEBUFFER_OPERATION:
|
||||
return "Invalid Framebuffer Operation";
|
||||
case GL_INVALID_INDEX:
|
||||
return "Invalid Index";
|
||||
}
|
||||
return std::string("Unknown Error: ") += std::to_string(error);
|
||||
}
|
||||
|
||||
inline void handle_errors()
|
||||
{
|
||||
GLenum err;
|
||||
while ((err = glGetError()) != GL_NO_ERROR)
|
||||
{
|
||||
BLT_ERROR(get_error_message(err));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif //BLT_GL_INCLUDES_H
|
||||
|
|
|
@ -4,7 +4,7 @@ const std::string shader_pp_screen_frag = R"("
|
|||
#version 300 es
|
||||
precision mediump float;
|
||||
|
||||
out vec4 FragColor;
|
||||
${LAYOUT_STRING} out vec4 FragColor;
|
||||
in vec2 uv;
|
||||
in vec2 pos;
|
||||
|
||||
|
|
|
@ -222,7 +222,7 @@ namespace blt::gfx
|
|||
fbo.create();
|
||||
fbo.bind();
|
||||
|
||||
auto* texture = new texture_gl2D(width, height);
|
||||
auto* texture = new texture_gl2D(width, height, GL_RGBA8);
|
||||
fbo.attachTexture(texture, attachment_t::COLOR0);
|
||||
|
||||
render_buffer_t depth_rbo = render_buffer_t::make_render_buffer(GL_DEPTH24_STENCIL8, width, height);
|
||||
|
|
|
@ -145,20 +145,21 @@ namespace blt::gfx
|
|||
|
||||
void pp_in_place_t::post_draw(frame_buffer_t& previous)
|
||||
{
|
||||
draw_buffer.blitTexture(previous, 0, 0, 0, 0, GL_NEAREST, from, to);
|
||||
// previous.bind();
|
||||
// GLenum buf[32];
|
||||
// auto buff_val = static_cast<GLenum>(to);
|
||||
// auto size = buff_val - GL_COLOR_ATTACHMENT0;
|
||||
// for (GLenum i = 0; i < size; i++)
|
||||
// buf[i] = GL_NONE;
|
||||
// buf[size] = buff_val;
|
||||
// glDrawBuffers(static_cast<int>(size) + 1, buf);
|
||||
// glClear(GL_COLOR_BUFFER_BIT);
|
||||
// shader_pass->bind();
|
||||
// glActiveTexture(GL_TEXTURE0);
|
||||
// draw_buffer.getTexture(frame_buffer_t::attachment_t::COLOR0).bind();
|
||||
// pp_engine_t::render_quad();
|
||||
// draw_buffer.blitTexture(previous, 0, 0, 0, 0, GL_NEAREST, from, to);
|
||||
handle_errors();
|
||||
previous.bind();
|
||||
GLenum buf[32];
|
||||
auto to_val = static_cast<GLenum>(to);
|
||||
auto size = to_val - GL_COLOR_ATTACHMENT0;
|
||||
for (GLenum i = 0; i < size; i++)
|
||||
buf[i] = GL_NONE;
|
||||
buf[size] = to_val;
|
||||
glDrawBuffers(static_cast<int>(size) + 1, buf);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
shader_pass->bind();
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
draw_buffer.getTexture(frame_buffer_t::attachment_t::COLOR0).bind();
|
||||
pp_engine_t::render_quad();
|
||||
}
|
||||
|
||||
void pp_in_place_t::draw(frame_buffer_t& previous)
|
||||
|
|
|
@ -27,6 +27,22 @@ void error_callback(int error, const char* description)
|
|||
std::abort();
|
||||
}
|
||||
|
||||
void gl_error_callback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei, const GLchar* message, const void*)
|
||||
{
|
||||
// do not log performance concerns
|
||||
if (type == GL_DEBUG_TYPE_PERFORMANCE || type == GL_DEBUG_TYPE_OTHER)
|
||||
return;
|
||||
if (type == GL_DEBUG_TYPE_ERROR)
|
||||
{
|
||||
BLT_ERROR("[OpenGL Error] message = '%s', type = 0x%x, severity = 0x%x, source = 0x%x, id = %d",
|
||||
message, type, severity, source, id);
|
||||
} else
|
||||
{
|
||||
BLT_WARN("[OpenGL Error] message = '%s', type = 0x%x, severity = 0x%x, source = 0x%x, id = %d",
|
||||
message, type, severity, source, id);
|
||||
}
|
||||
}
|
||||
|
||||
namespace blt::gfx
|
||||
{
|
||||
struct
|
||||
|
@ -236,6 +252,9 @@ namespace blt::gfx
|
|||
gladLoadGL(glfwGetProcAddress);
|
||||
#endif
|
||||
|
||||
glEnable(GL_DEBUG_OUTPUT);
|
||||
glDebugMessageCallback(gl_error_callback, nullptr);
|
||||
|
||||
/* -- Set up our local callbacks, ImGUI will then call these -- */
|
||||
create_callbacks();
|
||||
|
||||
|
|
Loading…
Reference in New Issue