Make graphics interface more cohesive. Remove texture functionality that was broken, add more debug printouts and debug levels

This commit is contained in:
rexy712 2020-10-05 11:27:03 -07:00
parent 026b3c129a
commit e44a577ff0
15 changed files with 230 additions and 101 deletions

View File

@ -25,29 +25,43 @@
#ifdef OUR_DICK_DEBUG
#define OUR_DICK_ENABLE_DEBUG_OUTPUT_LEVEL OUR_DICK_DEBUG
#if OUR_DICK_DEBUG > 1
#define OUR_DICK_ENABLE_DEBUG_CONTEXT
#endif
#else
#define OUR_DICK_ENABLE_DEBUG_OUTPUT_LEVEL 0
#endif
//Debug output section
#if OUR_DICK_ENABLE_DEBUG_OUTPUT_LEVEL > 0
#define OUR_DICK_ENABLE_DEBUG_OUTPUT
#endif
#if OUR_DICK_ENABLE_DEBUG_OUTPUT_LEVEL > 1
#if OUR_DICK_ENABLE_DEBUG_OUTPUT_LEVEL > 2
#define OUR_DICK_ENABLE_DEBUG_VERBOSE_OUTPUT
#endif
#ifdef OUR_DICK_ENABLE_DEBUG_OUTPUT
#include <cstdio>
#define debug_print(...) (fprintf(stderr, __FILE__":%s:%d: ", __func__, __LINE__), fprintf(stderr, __VA_ARGS__))
#define debug_print(...) do{fprintf(stderr, __FILE__ ":%s:%d: ", __func__, __LINE__); fprintf(stderr, __VA_ARGS__);}while(0)
#ifdef OUR_DICK_ENABLE_DEBUG_VERBOSE_OUTPUT
#define debug_print_verbose(...) debug_print(__VA_ARGS__)
#else
#define debug_print_verbose(...)
#endif
#ifdef OUR_DICK_ENABLE_COLOR_DEBUG
#define OUR_DICK_DEBUG_PRINT_RED "\033[38;5;9m"
#define OUR_DICK_DEBUG_PRINT_YELLOW "\033[38;5;11m"
#define OUR_DICK_DEBUG_PRINT_GREEN "\033[38;5;2m"
#define OUR_DICK_DEBUG_PRINT_CLEAR "\033[0m"
#define debug_print_error(...) (fprintf(stderr, OUR_DICK_DEBUG_PRINT_RED __FILE__ ":%s:%d: ", __func__, __LINE__), fprintf(stderr, __VA_ARGS__), fprintf(stderr, OUR_DICK_DEBUG_PRINT_CLEAR))
#define debug_print_warn(...) (fprintf(stderr, OUR_DICK_DEBUG_PRINT_YELLOW __FILE__ ":%s:%d: ", __func__, __LINE__), fprintf(stderr, __VA_ARGS__), fprintf(stderr, OUR_DICK_DEBUG_PRINT_CLEAR))
#define debug_print_succ(...) (fprintf(stderr, OUR_DICK_DEBUG_PRINT_GREEN __FILE__ ":%s:%d: ", __func__, __LINE__), fprintf(stderr, __VA_ARGS__), fprintf(stderr, OUR_DICK_DEBUG_PRINT_CLEAR))
#define debug_print_color_base(color, ...) do{fprintf(stderr, color); debug_print(__VA_ARGS__); fprintf(stderr, OUR_DICK_DEBUG_PRINT_CLEAR);}while(0)
#define debug_print_warn(...) debug_print_color_base(OUR_DICK_DEBUG_PRINT_YELLOW, __VA_ARGS__)
#define debug_print_error(...) debug_print_color_base(OUR_DICK_DEBUG_PRINT_RED, __VA_ARGS__)
#define debug_print_succ(...) debug_print_color_base(OUR_DICK_DEBUG_PRINT_GREEN, __VA_ARGS__)
#else
#define debug_print_error(...) debug_print(__VA_ARGS__)
#define debug_print_warn(...) debug_print(__VA_ARGS__)
@ -59,6 +73,7 @@
#define debug_print_error(...)
#define debug_print_warn(...)
#define debug_print_succ(...)
#define debug_print_verbose(...)
#endif
#endif

View File

@ -30,6 +30,7 @@ namespace gfx{
GLenum m_format;
GLsizei m_width;
GLsizei m_height;
GLsizei m_samples;
public:
rbo(GLsizei width, GLsizei height, GLenum format, GLsizei samples = 0);
@ -46,6 +47,7 @@ namespace gfx{
void unbind()const;
void resize(GLsizei w, GLsizei h);
void resize(GLsizei w, GLsizei h, GLenum format, GLsizei samples);
void reformat(GLenum format);
GLuint release();

View File

@ -63,8 +63,7 @@ namespace gfx{
type get_type()const;
//raw access to shader handle
operator GLuint()const;
GLuint get_id()const;
GLuint raw()const;
//get most recently generated error from this shader's infolog
std::string get_error()const;

View File

@ -70,8 +70,7 @@ namespace gfx{
GLint get_uniform_loc(const char* u)const;
//raw access to the program handle
GLuint get_id()const;
operator GLuint()const;
GLuint raw()const;
//check if an error exists after a link attempt
bool has_link_error()const;
@ -209,6 +208,8 @@ namespace gfx{
//Texture
void set_uniform(const char* name, const texture&, GLuint tex_unit = 0);
void set_uniform(GLuint loc, const texture&, GLuint tex_unit = 0);
void set_uniform(const char* name, const weak_texture_handle&, GLuint tex_unit = 0);
void set_uniform(GLuint loc, const weak_texture_handle&, GLuint tex_unit = 0);
//Float vectors
void set_uniform(const char* name, const vec2<GLfloat>&);

View File

@ -21,9 +21,34 @@
#include "image.hpp"
#include "gl_include.hpp"
#include "math/vec.hpp"
namespace gfx{
class texture;
class weak_texture_handle
{
private:
const texture* m_texture;
public:
weak_texture_handle(const texture& tex);
weak_texture_handle(const weak_texture_handle&) = default;
weak_texture_handle(weak_texture_handle&&) = default;
~weak_texture_handle() = default;
weak_texture_handle& operator=(const weak_texture_handle&) = default;
weak_texture_handle& operator=(weak_texture_handle&&) = default;
GLuint raw()const;
GLsizei get_width()const;
GLsizei get_height()const;
void bind()const;
void bind_unit(GLuint tunit)const;
};
//class representing an opengl 2D texture
class texture
{
@ -52,16 +77,18 @@ namespace gfx{
};
private:
GLuint m_tex_id = 0; //handle to texture object
int m_width = 0;
int m_height = 0;
GLsizei m_width = 0;
GLsizei m_height = 0;
GLenum m_format = GL_RGBA;
GLenum m_type = GL_UNSIGNED_BYTE;
public:
//create the texture with no image data
texture();
texture(const unsigned char* data, GLenum format, GLsizei w, GLsizei h, GLenum type);
texture(GLenum format, GLsizei w, GLsizei h, GLenum type);
//create the texture with image data from 'i'
texture(const image& i);
//TODO image data from raw unsigned char array
texture(const texture&) = delete;
texture(texture&&);
~texture();
@ -73,12 +100,6 @@ namespace gfx{
//overwrite the current image data with 'i'
bool set_image(const image& i);
void resize(GLenum format, GLsizei w, GLsizei h, GLenum type);
//set the size of the texture, will wrap the image according to the chosen wrap mode
void set_width(int w);
void set_height(int h);
void set_size(int w, int h);
//change wrap mode for both x and y
void set_wrap_mode(wrap w);
@ -92,8 +113,15 @@ namespace gfx{
void set_mag_filter(magfilter m);
void set_min_filter(minfilter m);
int get_width()const;
int get_height()const;
magfilter get_mag_filter()const;
minfilter get_min_filter()const;
math::vec4<GLfloat> get_border_color()const;
wrap get_wrap_x()const;
wrap get_wrap_y()const;
GLsizei get_width()const;
GLsizei get_height()const;
//release ownership of this texture object
GLuint release();
@ -102,6 +130,8 @@ namespace gfx{
void bind()const;
//bind to given texture unit and load into given program uniform location
void bind_unit(GLuint tunit)const;
weak_texture_handle create_handle()const;
};
}

View File

@ -58,6 +58,7 @@ namespace gfx{
public:
//create a buffer with given capacity with predicted usage case 't'
vbo(size_t cap, usage t);
vbo(const void* data, size_t datasize, usage t);
vbo(const vbo&);
vbo(vbo&&);
~vbo();

View File

@ -28,7 +28,7 @@ INCLUDE_DIRS::=include
CFLAGS::=-std=c18 -Wall -pedantic -Wextra
CXXFLAGS::=-std=c++17 -Wall -pedantic -Wextra
DEBUG_CFLAGS::=
DEBUG_CXXFLAGS::=-DOUR_DICK_DEBUG=1
DEBUG_CXXFLAGS::=-DOUR_DICK_DEBUG=2
EXT::=cpp
LANG::=$(EXT)
MAIN_EXECUTABLE::=tester

View File

@ -18,6 +18,7 @@
#include "graphics/image.hpp"
#include "graphics/stb_include.hpp"
#include "config.hpp"
#include <cstring> //memcpy
#include <utility> //exchange
@ -26,6 +27,8 @@ namespace gfx{
image::image(const char* file, bool flip, int req_chan){
stbi_set_flip_vertically_on_load(flip);
m_data = stbi_load(file, &m_width, &m_height, &m_channels, req_chan);
if(!m_data)
debug_print_error("Unable to load image file %s\n", file);
}
image::image(const image& i):
m_width(i.m_width), m_height(i.m_height), m_channels(i.m_channels),

View File

@ -24,12 +24,11 @@ namespace gfx{
rbo::rbo(GLsizei width, GLsizei height, GLenum format, GLsizei samples):
m_format(format),
m_width(width),
m_height(height)
m_height(height),
m_samples(samples)
{
glGenRenderbuffers(1, &m_buffer);
bind();
glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, m_format, m_width, m_height);
unbind();
glCreateRenderbuffers(1, &m_buffer);
glNamedRenderbufferStorageMultisample(m_buffer, m_samples, m_format, m_width, m_height);
}
rbo::rbo(rbo&& r):
m_buffer(std::exchange(r.m_buffer, 0)),
@ -61,10 +60,20 @@ namespace gfx{
}
void rbo::resize(GLsizei w, GLsizei h){
*this = rbo(w, h, m_format);
m_width = w;
m_height = h;
glNamedRenderbufferStorageMultisample(m_buffer, m_samples, m_format, m_width, m_height);
}
void rbo::resize(GLsizei w, GLsizei h, GLenum format, GLsizei samples){
m_width = w;
m_height = h;
m_format = format;
m_samples = samples;
glNamedRenderbufferStorageMultisample(m_buffer, m_samples, m_format, m_width, m_height);
}
void rbo::reformat(GLenum format){
*this = rbo(m_width, m_height, format);
m_format = format;
glNamedRenderbufferStorageMultisample(m_buffer, m_samples, m_format, m_width, m_height);
}
GLuint rbo::release(){

View File

@ -17,6 +17,7 @@
*/
#include "graphics/shader.hpp"
#include "config.hpp"
#include <utility> //exchange, swap
#include <string>
@ -35,12 +36,14 @@ namespace gfx{
{
GLint len;
GLsizei retlen;
glGetShaderiv(s.get_id(), GL_SHADER_SOURCE_LENGTH, &len);
if(!len)
glGetShaderiv(s.raw(), GL_SHADER_SOURCE_LENGTH, &len);
if(!len){
debug_print_error("Refusing to compile empty shader source\n");
return;
}
std::string data;
data.resize(len - 1);
glGetShaderSource(s.get_id(), len, &retlen, data.data());
glGetShaderSource(s.raw(), len, &retlen, data.data());
load(data.data());
}
shader::shader(shader&& s):
@ -77,11 +80,7 @@ namespace gfx{
glGetShaderiv(m_shader_id, GL_SHADER_TYPE, &t);
return static_cast<type>(t);
}
GLuint shader::get_id()const{
return m_shader_id;
}
shader::operator GLuint()const{
GLuint shader::raw()const{
return m_shader_id;
}
@ -89,8 +88,10 @@ namespace gfx{
GLint len;
GLsizei retlen;
glGetShaderiv(m_shader_id, GL_INFO_LOG_LENGTH, &len);
if(!len)
if(!len){
debug_print_error("Attempt to read shader error log when no error exists\n");
return{};
}
std::string retval;
retval.resize(len - 1); //exclude null terminator from length
glGetShaderInfoLog(m_shader_id, len, &retlen, retval.data());

View File

@ -17,6 +17,7 @@
*/
#include "graphics/shader_program.hpp"
#include "config.hpp"
#include <utility> //exchange, swap
#include <string>
@ -42,7 +43,7 @@ namespace gfx{
}
void shader_program::attach_shader(const shader& s){
glAttachShader(m_shader_id, s);
glAttachShader(m_shader_id, s.raw());
}
bool shader_program::link(){
glLinkProgram(m_shader_id);
@ -57,10 +58,7 @@ namespace gfx{
return glGetUniformLocation(m_shader_id, u);
}
GLuint shader_program::get_id()const{
return m_shader_id;
}
shader_program::operator GLuint()const{
GLuint shader_program::raw()const{
return m_shader_id;
}
@ -73,8 +71,10 @@ namespace gfx{
GLint len;
GLsizei retlen;
glGetProgramiv(m_shader_id, GL_INFO_LOG_LENGTH, &len);
if(!len)
if(!len){
debug_print_error("Attempt to read shader program error log when no error exists\n");
return{};
}
std::string retval;
retval.resize(len - 1); //exclude null terminator from length
glGetProgramInfoLog(m_shader_id, len, &retlen, retval.data());
@ -494,6 +494,13 @@ namespace gfx{
t.bind_unit(tex_unit);
glProgramUniform1i(m_shader_id, loc, tex_unit);
}
void shader_program::set_uniform(const char* name, const weak_texture_handle& t, GLuint tex_unit){
set_uniform(get_uniform_loc(name), t, tex_unit);
}
void shader_program::set_uniform(GLuint loc, const weak_texture_handle& t, GLuint tex_unit){
t.bind_unit(tex_unit);
glProgramUniform1i(m_shader_id, loc, tex_unit);
}
void shader_program::set_uniform(const char* name, const vec2<GLfloat>& v){
set_uniform(get_uniform_loc(name), v);

View File

@ -17,6 +17,7 @@
*/
#include "graphics/texture.hpp"
#include "config.hpp"
#include <utility> //exchange, swap
@ -25,12 +26,30 @@ namespace gfx{
texture::texture(){
glCreateTextures(GL_TEXTURE_2D, 1, &m_tex_id);
}
texture::texture(GLenum format, GLsizei w, GLsizei h, GLenum type):
m_width(w), m_height(h)
texture::texture(const unsigned char* data, GLenum format, GLsizei w, GLsizei h, GLenum type):
m_width(w), m_height(h),
m_format(format), m_type(type)
{
glCreateTextures(GL_TEXTURE_2D, 1, &m_tex_id);
resize(format, w, h, type);
switch(m_format){
case GL_RED:
glTextureStorage2D(m_tex_id, 1, GL_R8, m_width, m_height);
break;
case GL_RG:
glTextureStorage2D(m_tex_id, 1, GL_RG8, m_width, m_height);
break;
case GL_RGB:
glTextureStorage2D(m_tex_id, 1, GL_RGB8, m_width, m_height);
break;
case GL_RGBA:
glTextureStorage2D(m_tex_id, 1, GL_RGBA8, m_width, m_height);
break;
};
glTextureSubImage2D(m_tex_id, 0, 0, 0, m_width, m_height, m_format, m_type, data);
glGenerateTextureMipmap(m_tex_id);
}
texture::texture(GLenum format, GLsizei w, GLsizei h, GLenum type):
texture(nullptr, format, w, h, type){}
texture::texture(const image& i):
texture()
{
@ -51,65 +70,42 @@ namespace gfx{
}
bool texture::set_image(const image& i){
if(!i)
if(!i){
debug_print_error("Image is invalid\n");
return false;
}
if(!m_tex_id)
if(!m_tex_id){
debug_print("Generating texture after texture construction\n");
glCreateTextures(GL_TEXTURE_2D, 1, &m_tex_id);
}
m_width = i.get_width();
m_height = i.get_height();
switch(i.get_channels()){
case 1:
m_format = GL_RED;
glTextureStorage2D(m_tex_id, 1, GL_R8, m_width, m_height);
glTextureSubImage2D(m_tex_id, 0, 0, 0, m_width, m_height, GL_RED, GL_UNSIGNED_BYTE, i.data());
break;
case 2:
m_format = GL_RG;
glTextureStorage2D(m_tex_id, 1, GL_RG8, m_width, m_height);
glTextureSubImage2D(m_tex_id, 0, 0, 0, m_width, m_height, GL_RG, GL_UNSIGNED_BYTE, i.data());
break;
case 3:
m_format = GL_RGB;
glTextureStorage2D(m_tex_id, 1, GL_RGB8, m_width, m_height);
glTextureSubImage2D(m_tex_id, 0, 0, 0, m_width, m_height, GL_RGB, GL_UNSIGNED_BYTE, i.data());
break;
case 4:
m_format = GL_RGBA;
glTextureStorage2D(m_tex_id, 1, GL_RGBA8, m_width, m_height);
glTextureSubImage2D(m_tex_id, 0, 0, 0, m_width, m_height, GL_RGBA, GL_UNSIGNED_BYTE, i.data());
break;
default:
debug_print_error("Invalid format for texture\n");
return false;
}
glTextureSubImage2D(m_tex_id, 0, 0, 0, m_width, m_height, m_format, GL_UNSIGNED_BYTE, i.data());
glGenerateTextureMipmap(m_tex_id);
return true;
}
void texture::resize(GLenum format, GLsizei w, GLsizei h, GLenum type){
switch(format){
case GL_RED:
glTextureStorage2D(m_tex_id, 1, GL_R8, w, h);
break;
case GL_RG:
glTextureStorage2D(m_tex_id, 1, GL_RG8, w, h);
break;
case GL_RGB:
glTextureStorage2D(m_tex_id, 1, GL_RGB8, w, h);
break;
case GL_RGBA:
glTextureStorage2D(m_tex_id, 1, GL_RGBA8, w, h);
break;
};
glTextureSubImage2D(m_tex_id, 0, 0, 0, w, h, format, type, NULL);
glGenerateTextureMipmap(m_tex_id);
}
void texture::set_width(int w){
m_width = w;
}
void texture::set_height(int h){
m_height = h;
}
void texture::set_size(int w, int h){
m_width = w;
m_height = h;
}
void texture::set_wrap_mode(wrap w){
glTextureParameteri(m_tex_id, GL_TEXTURE_WRAP_S, static_cast<GLint>(w));
@ -140,11 +136,35 @@ namespace gfx{
void texture::set_min_filter(minfilter m){
glTextureParameteri(m_tex_id, GL_TEXTURE_MIN_FILTER, static_cast<GLint>(m));
}
int texture::get_width()const{
auto texture::get_mag_filter()const -> magfilter{
GLint filter;
glGetTextureParameteriv(m_tex_id, GL_TEXTURE_MAG_FILTER, &filter);
return static_cast<magfilter>(filter);
}
auto texture::get_min_filter()const -> minfilter{
GLint filter;
glGetTextureParameteriv(m_tex_id, GL_TEXTURE_MIN_FILTER, &filter);
return static_cast<minfilter>(filter);
}
math::vec4<GLfloat> texture::get_border_color()const{
math::vec4<GLfloat> color;
glGetTextureParameterfv(m_tex_id, GL_TEXTURE_BORDER_COLOR, color);
return color;
}
auto texture::get_wrap_x()const -> wrap{
GLint w;
glGetTextureParameteriv(m_tex_id, GL_TEXTURE_WRAP_S, &w);
return static_cast<wrap>(w);
}
auto texture::get_wrap_y()const -> wrap{
GLint w;
glGetTextureParameteriv(m_tex_id, GL_TEXTURE_WRAP_T, &w);
return static_cast<wrap>(w);
}
GLsizei texture::get_width()const{
return m_width;
}
int texture::get_height()const{
GLsizei texture::get_height()const{
return m_height;
}
@ -158,6 +178,29 @@ namespace gfx{
void texture::bind_unit(GLuint tunit)const{
glBindTextureUnit(tunit, m_tex_id);
}
weak_texture_handle texture::create_handle()const{
return weak_texture_handle(*this);
}
weak_texture_handle::weak_texture_handle(const texture& tex):
m_texture(&tex){}
GLuint weak_texture_handle::raw()const{
return m_texture->raw();
}
GLsizei weak_texture_handle::get_width()const{
return m_texture->get_width();
}
GLsizei weak_texture_handle::get_height()const{
return m_texture->get_height();
}
void weak_texture_handle::bind()const{
m_texture->bind();
}
void weak_texture_handle::bind_unit(GLuint tunit)const{
m_texture->bind_unit(tunit);
}
}

View File

@ -32,28 +32,28 @@ namespace gfx{
}
void vertex_attribute::set_float_array(GLint size, GLsizei offset){
glVertexArrayAttribFormat(m_vao, m_index, size, GL_FLOAT, GL_FALSE, sizeof(GLfloat) * offset);
glVertexArrayAttribFormat(m_vao, m_index, size, GL_FLOAT, GL_FALSE, offset);
}
void vertex_attribute::set_double_array(GLint size, GLsizei offset){
glVertexArrayAttribFormat(m_vao, m_index, size, GL_DOUBLE, GL_FALSE, sizeof(GLdouble) * offset);
glVertexArrayAttribFormat(m_vao, m_index, size, GL_DOUBLE, GL_FALSE, offset);
}
void vertex_attribute::set_byte_array(GLint size, GLsizei offset){
glVertexArrayAttribFormat(m_vao, m_index, size, GL_BYTE, GL_FALSE, sizeof(GLbyte) * offset);
glVertexArrayAttribFormat(m_vao, m_index, size, GL_BYTE, GL_FALSE, offset);
}
void vertex_attribute::set_ubyte_array(GLint size, GLsizei offset){
glVertexArrayAttribFormat(m_vao, m_index, size, GL_UNSIGNED_BYTE, GL_FALSE, sizeof(GLubyte) * offset);
glVertexArrayAttribFormat(m_vao, m_index, size, GL_UNSIGNED_BYTE, GL_FALSE, offset);
}
void vertex_attribute::set_short_array(GLint size, GLsizei offset){
glVertexArrayAttribFormat(m_vao, m_index, size, GL_SHORT, GL_FALSE, sizeof(GLshort) * offset);
glVertexArrayAttribFormat(m_vao, m_index, size, GL_SHORT, GL_FALSE, offset);
}
void vertex_attribute::set_ushort_array(GLint size, GLsizei offset){
glVertexArrayAttribFormat(m_vao, m_index, size, GL_UNSIGNED_SHORT, GL_FALSE, sizeof(GLushort) * offset);
glVertexArrayAttribFormat(m_vao, m_index, size, GL_UNSIGNED_SHORT, GL_FALSE, offset);
}
void vertex_attribute::set_int_array(GLint size, GLsizei offset){
glVertexArrayAttribFormat(m_vao, m_index, size, GL_INT, GL_FALSE, sizeof(GLint) * offset);
glVertexArrayAttribFormat(m_vao, m_index, size, GL_INT, GL_FALSE, offset);
}
void vertex_attribute::set_uint_array(GLint size, GLsizei offset){
glVertexArrayAttribFormat(m_vao, m_index, size, GL_UNSIGNED_INT, GL_FALSE, sizeof(GLuint) * offset);
glVertexArrayAttribFormat(m_vao, m_index, size, GL_UNSIGNED_INT, GL_FALSE, offset);
}

View File

@ -29,6 +29,12 @@ namespace gfx{
glCreateBuffers(1, &m_buffer);
glNamedBufferData(m_buffer, size, NULL, static_cast<GLenum>(t));
}
vbo::vbo(const void* data, size_t size, usage t):
m_buffer_size(size)
{
glCreateBuffers(1, &m_buffer);
glNamedBufferData(m_buffer, size, data, static_cast<GLenum>(t));
}
vbo::vbo(const vbo& v):
m_buffer_size(v.m_buffer_size)
{

View File

@ -25,7 +25,7 @@
namespace gfx{
#ifdef OUR_DICK_ENABLE_DEBUG_OUTPUT
#ifdef OUR_DICK_ENABLE_DEBUG_CONTEXT
static void APIENTRY our_dick_gl_debug_output(GLenum source, GLenum type, unsigned int /*id*/, GLenum severity,
GLsizei /*length*/, const char* message, const void* /*user_ptr*/)
{
@ -113,9 +113,9 @@ static void enable_opengl_debug_context(){
glDebugMessageCallback(our_dick_gl_debug_output, nullptr);
glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, nullptr, GL_TRUE);
}else if(GLAD_GL_ARB_debug_output){
debug_print("Debug output enabled using opengl extensions\n");
glDebugMessageCallbackARB(our_dick_gl_debug_output, nullptr);
glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, nullptr, GL_TRUE);
debug_print_warn("Debug output enabled using GL_ARB_debug_output extension\n");
glDebugMessageCallback(our_dick_gl_debug_output, nullptr);
glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, nullptr, GL_TRUE);
}
}
#endif
@ -124,7 +124,15 @@ static void enable_opengl_debug_context(){
if(GLAD_GL_VERSION_4_5){
return true;
}
if(GLAD_GL_ARB_direct_state_access){
if(GLAD_GL_VERSION_4_3){
if(GLAD_GL_ARB_direct_state_access){
debug_print_warn("Using GL_ARB_direct_state_access extension\n");
return true;
}
}
if(GLAD_GL_ARB_direct_state_access && GLAD_GL_ARB_explicit_uniform_location){
debug_print_warn("Using GL_ARB_direct_state_access extension\n");
debug_print_warn("Using GL_ARB_explicit_uniform_location extension\n");
return true;
}
return false;
@ -152,7 +160,7 @@ static void enable_opengl_debug_context(){
GLFWwindow* current_context = glfwGetCurrentContext();
#ifdef OUR_DICK_ENABLE_DEBUG_OUTPUT
#ifdef OUR_DICK_ENABLE_DEBUG_CONTEXT
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE);
#else
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_FALSE);
@ -186,8 +194,10 @@ static void enable_opengl_debug_context(){
}
debug_print("Using opengl profile version %s\n", glGetString(GL_VERSION));
#ifdef OUR_DICK_ENABLE_DEBUG_OUTPUT
#ifdef OUR_DICK_ENABLE_DEBUG_CONTEXT
enable_opengl_debug_context();
#else
debug_print("OpenGL debug context is disabled\n");
#endif
glfwMakeContextCurrent(m_window);
m_root_fbo.set_viewport(0, 0, width, height);
@ -207,7 +217,7 @@ static void enable_opengl_debug_context(){
GLFWwindow* current_context = glfwGetCurrentContext();
#ifdef OUR_DICK_ENABLE_DEBUG_OUTPUT
#ifdef OUR_DICK_ENABLE_DEBUG_CONTEXT
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE);
#else
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_FALSE);
@ -237,8 +247,10 @@ static void enable_opengl_debug_context(){
}
debug_print("Using opengl profile version %s\n", glGetString(GL_VERSION));
#ifdef OUR_DICK_ENABLE_DEBUG_OUTPUT
#ifdef OUR_DICK_ENABLE_DEBUG_CONTEXT
enable_opengl_debug_context();
#else
debug_print("OpenGL debug context is disabled\n");
#endif
glfwMakeContextCurrent(m_window);