diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/daw.c | 2 | ||||
| -rw-r--r-- | src/include/daw/rendering.h | 9 | ||||
| -rw-r--r-- | src/rendering.c | 26 |
3 files changed, 27 insertions, 10 deletions
@@ -249,7 +249,7 @@ i32 engine_run(Instance* p, StateType initial_state, void* state_arg) { {.num_attached_buffers = 1, {200,200}}, }; u32 t[] = { - BUFFERPARAMETER_SET_PARAMETER(BUFFERPARAMETER_SET_TYPE(0, BufferType_texture), BUFFERPARAMETER_TEXTURE_2D) + BUFFERPARAMETER_SET_PARAMETER(BUFFERPARAMETER_SET_TYPE(0, BufferType_texture), BUFFERPARAMETER_TEXTURE_2D | BUFFERPARAMETER_TEXTURE_FMT_RGBA8) }; window_init_renderstack(w, 1, 1, p, t); //w->render_targets->cam[0] = &default_renderbuffer_camera; diff --git a/src/include/daw/rendering.h b/src/include/daw/rendering.h index a26310e..d9ad6c1 100644 --- a/src/include/daw/rendering.h +++ b/src/include/daw/rendering.h @@ -208,14 +208,14 @@ typedef enum { // Buffer parameter: Frame buffer // Buffer parameter: Texture buffer -#define BUFFERPARAMETER_TEXTURE_GET_DIMENSION(bufferparam) (BUFFERPARAMETER_GET_PARAMETER(bufferparam) & 7) +#define BUFFERPARAMETER_TEXTURE_GET_DIMENSION(bufferparam) (BUFFERPARAMETER_GET_PARAMETER(bufferparam) & ((1 << 3) - 1)) #define BUFFERPARAMETER_TEXTURE_1D 1 #define BUFFERPARAMETER_TEXTURE_2D 2 #define BUFFERPARAMETER_TEXTURE_3D 3 #define BUFFERPARAMETER_TEXTURE_4D 4 // TODO: Change `2` once we add support for more formats -#define BUFFERPARAMETER_TEXTURE_GET_FORMAT(bufferparam) (BUFFERPARAMETER_GET_PARAMETER(bufferparam) >> 3 & 2) +#define BUFFERPARAMETER_TEXTURE_GET_FORMAT(bufferparam) (BUFFERPARAMETER_GET_PARAMETER(bufferparam) & (((1 << 2) - 1) << 3)) #define BUFFERPARAMETER_TEXTURE_FMT_RGBA8 (1 << 4) #define BUFFERPARAMETER_TEXTURE_FMT_SRGB8 (2 << 4) #define BUFFERPARAMETER_TEXTURE_FMT_SRGBA8 (3 << 4) @@ -234,12 +234,13 @@ typedef enum { #define BUFFERPARAMETER_GET_TYPE(bufferparam) \ (BufferType)(bufferparam & BUFFERPARAMETER_MASK_TYPE) #define BUFFERPARAMETER_GET_PARAMETER(bufferparam) \ - ((bufferparam & BUFFERPARAMETER_MASK_TYPE) >> 4) + ((bufferparam & BUFFERPARAMETER_MASK_PARAMETER) >> 4) +// SET operations clear the masked bits that you're setting #define BUFFERPARAMETER_SET_TYPE(bufferparam, type) \ (BufferType)((bufferparam & ~BUFFERPARAMETER_MASK_TYPE) | type) #define BUFFERPARAMETER_SET_PARAMETER(bufferparam, param) \ - ((bufferparam & ~BUFFERPARAMETER_MASK_PARAMETER) | (param << 4)) + ((bufferparam & ~BUFFERPARAMETER_MASK_PARAMETER) | ((param) << 4)) typedef struct { i32 num_attached_buffers; diff --git a/src/rendering.c b/src/rendering.c index 8f7104e..2c63c71 100644 --- a/src/rendering.c +++ b/src/rendering.c @@ -714,7 +714,7 @@ void r_create_textures(void* restrict ctx, u32* restrict texture_array, const GladGLContext* gl = (GladGLContext*)ctx; u32 texture_dim = BUFFERPARAMETER_TEXTURE_GET_DIMENSION(texture_parameters[0]); - u32 texture_format = BUFFERPARAMETER_TEXTURE_GET_DIMENSION(texture_parameters[0]); + u32 texture_format = BUFFERPARAMETER_TEXTURE_GET_FORMAT(texture_parameters[0]); u32 gl_texture_format; u32 err; @@ -736,22 +736,25 @@ void r_create_textures(void* restrict ctx, u32* restrict texture_array, switch (texture_dim) { case BUFFERPARAMETER_TEXTURE_1D: gl->CreateTextures(GL_TEXTURE_1D, num_targets, texture_array); + ASSERT(!gl->GetError()); for (usize i = 0; i < num_targets; i++) { - gl->TextureStorage1D(texture_array[i], 1, gl_texture_format, *texture_size[0]); + gl->TextureStorage1D(texture_array[i], 1, gl_texture_format, (*texture_size)[0]); } break; case BUFFERPARAMETER_TEXTURE_2D: gl->CreateTextures(GL_TEXTURE_2D, num_targets, texture_array); + ASSERT(!gl->GetError()); for (usize i = 0; i < num_targets; i++) { - gl->TextureStorage2D(texture_array[i], 1, gl_texture_format, *texture_size[0], *texture_size[1]); + gl->TextureStorage2D(texture_array[i], 1, gl_texture_format, (*texture_size)[0], (*texture_size)[1]); } break; case BUFFERPARAMETER_TEXTURE_3D: gl->CreateTextures(GL_TEXTURE_3D, num_targets, texture_array); + ASSERT(!gl->GetError()); for (usize i = 0; i < num_targets; i++) { - gl->TextureStorage3D(texture_array[i], 1, gl_texture_format, *texture_size[0], *texture_size[1], *texture_size[2]); + gl->TextureStorage3D(texture_array[i], 1, gl_texture_format, (*texture_size)[0], (*texture_size)[1], (*texture_size)[2]); } break; @@ -766,7 +769,20 @@ void r_create_textures(void* restrict ctx, u32* restrict texture_array, err = gl->GetError(); if (err) { - ERROR("Failed to create textures!"); + switch (err) { + case GL_INVALID_OPERATION: + ERROR("Failed to create textures! GL_INVALID_OPERATION"); + break; + case GL_INVALID_ENUM: + ERROR("Failed to create textures! GL_INVALID_ENUM"); + break; + case GL_INVALID_VALUE: + ERROR("Failed to create textures! GL_INVALID_VALUE"); + break; + default: + ERROR("Failed to create textures!"); + break; + } } // This should probably be changed in the future |
