postprocess is on the way
parent
eaf15046b4
commit
e674819344
|
@ -1,6 +1,6 @@
|
||||||
cmake_minimum_required(VERSION 3.25)
|
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)
|
set(BLT_GRAPHICS_TEST_VERSION 0.0.1)
|
||||||
|
|
||||||
project(BLT_WITH_GRAPHICS VERSION ${BLT_GRAPHICS_VERSION})
|
project(BLT_WITH_GRAPHICS VERSION ${BLT_GRAPHICS_VERSION})
|
||||||
|
|
|
@ -8,9 +8,13 @@
|
||||||
#ifndef BLT_GL_INCLUDES_H
|
#ifndef BLT_GL_INCLUDES_H
|
||||||
#define BLT_GL_INCLUDES_H
|
#define BLT_GL_INCLUDES_H
|
||||||
|
|
||||||
|
#include <blt/std/logging.h>
|
||||||
|
|
||||||
// emscripten provides its own gl bindings.
|
// emscripten provides its own gl bindings.
|
||||||
#ifndef __EMSCRIPTEN__
|
#ifndef __EMSCRIPTEN__
|
||||||
|
|
||||||
#include <glad/gl.h>
|
#include <glad/gl.h>
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#include <GLES2/gl2.h>
|
#include <GLES2/gl2.h>
|
||||||
#include <GLES3/gl3.h>
|
#include <GLES3/gl3.h>
|
||||||
|
@ -21,4 +25,40 @@
|
||||||
#define EGL_EGLEXT_PROTOTYPES
|
#define EGL_EGLEXT_PROTOTYPES
|
||||||
#endif
|
#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
|
#endif //BLT_GL_INCLUDES_H
|
||||||
|
|
|
@ -4,7 +4,7 @@ const std::string shader_pp_screen_frag = R"("
|
||||||
#version 300 es
|
#version 300 es
|
||||||
precision mediump float;
|
precision mediump float;
|
||||||
|
|
||||||
out vec4 FragColor;
|
${LAYOUT_STRING} out vec4 FragColor;
|
||||||
in vec2 uv;
|
in vec2 uv;
|
||||||
in vec2 pos;
|
in vec2 pos;
|
||||||
|
|
||||||
|
|
|
@ -222,7 +222,7 @@ namespace blt::gfx
|
||||||
fbo.create();
|
fbo.create();
|
||||||
fbo.bind();
|
fbo.bind();
|
||||||
|
|
||||||
auto* texture = new texture_gl2D(width, height);
|
auto* texture = new texture_gl2D(width, height, GL_RGBA8);
|
||||||
fbo.attachTexture(texture, attachment_t::COLOR0);
|
fbo.attachTexture(texture, attachment_t::COLOR0);
|
||||||
|
|
||||||
render_buffer_t depth_rbo = render_buffer_t::make_render_buffer(GL_DEPTH24_STENCIL8, width, height);
|
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)
|
void pp_in_place_t::post_draw(frame_buffer_t& previous)
|
||||||
{
|
{
|
||||||
draw_buffer.blitTexture(previous, 0, 0, 0, 0, GL_NEAREST, from, to);
|
// draw_buffer.blitTexture(previous, 0, 0, 0, 0, GL_NEAREST, from, to);
|
||||||
// previous.bind();
|
handle_errors();
|
||||||
// GLenum buf[32];
|
previous.bind();
|
||||||
// auto buff_val = static_cast<GLenum>(to);
|
GLenum buf[32];
|
||||||
// auto size = buff_val - GL_COLOR_ATTACHMENT0;
|
auto to_val = static_cast<GLenum>(to);
|
||||||
// for (GLenum i = 0; i < size; i++)
|
auto size = to_val - GL_COLOR_ATTACHMENT0;
|
||||||
// buf[i] = GL_NONE;
|
for (GLenum i = 0; i < size; i++)
|
||||||
// buf[size] = buff_val;
|
buf[i] = GL_NONE;
|
||||||
// glDrawBuffers(static_cast<int>(size) + 1, buf);
|
buf[size] = to_val;
|
||||||
// glClear(GL_COLOR_BUFFER_BIT);
|
glDrawBuffers(static_cast<int>(size) + 1, buf);
|
||||||
// shader_pass->bind();
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
// glActiveTexture(GL_TEXTURE0);
|
shader_pass->bind();
|
||||||
// draw_buffer.getTexture(frame_buffer_t::attachment_t::COLOR0).bind();
|
glActiveTexture(GL_TEXTURE0);
|
||||||
// pp_engine_t::render_quad();
|
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)
|
void pp_in_place_t::draw(frame_buffer_t& previous)
|
||||||
|
|
|
@ -27,6 +27,22 @@ void error_callback(int error, const char* description)
|
||||||
std::abort();
|
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
|
namespace blt::gfx
|
||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
|
@ -236,6 +252,9 @@ namespace blt::gfx
|
||||||
gladLoadGL(glfwGetProcAddress);
|
gladLoadGL(glfwGetProcAddress);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
glEnable(GL_DEBUG_OUTPUT);
|
||||||
|
glDebugMessageCallback(gl_error_callback, nullptr);
|
||||||
|
|
||||||
/* -- Set up our local callbacks, ImGUI will then call these -- */
|
/* -- Set up our local callbacks, ImGUI will then call these -- */
|
||||||
create_callbacks();
|
create_callbacks();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue