From 4039166875da65715e8c49d334638dc9dd1d5f7b Mon Sep 17 00:00:00 2001 From: onelin Date: Sun, 30 Nov 2025 00:41:01 +0100 Subject: Fix retrieving texture dimensions instead of format --- src/include/daw/rendering.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/include') 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; -- cgit v1.3