@@ -610,11 +610,19 @@ SWAPI void swBindTexture(uint32_t id);
610610#define RLSW_IMPLEMENTATION
611611#if defined(RLSW_IMPLEMENTATION )
612612
613- #include <stdalign.h>
614613#include <stdlib.h>
615614#include <stddef.h>
616615#include <math.h> // Required for: floorf(), fabsf()
617616
617+ #if defined(_MSC_VER )
618+ #define ALIGNAS (x ) __declspec(align(x))
619+ #elif defined(__GNUC__ ) || defined(__clang__ )
620+ #define ALIGNAS (x ) __attribute__((aligned(x)))
621+ #else
622+ #include <stdalign.h>
623+ #define ALIGNAS (x ) alignas(x)
624+ #endif
625+
618626#if defined(__FMA__ ) && defined(__AVX2__ )
619627 #define SW_HAS_FMA_AVX2
620628 #include <immintrin.h>
@@ -687,8 +695,8 @@ SWAPI void swBindTexture(uint32_t id);
687695#define SW_DEG2RAD (SW_PI/180.0f)
688696#define SW_RAD2DEG (180.0f/SW_PI)
689697
690- #define SW_COLOR_PIXEL_SIZE (SW_COLOR_BUFFER_BITS/8 )
691- #define SW_DEPTH_PIXEL_SIZE (SW_DEPTH_BUFFER_BITS/8 )
698+ #define SW_COLOR_PIXEL_SIZE 4 // (SW_COLOR_BUFFER_BITS >> 3 )
699+ #define SW_DEPTH_PIXEL_SIZE (SW_DEPTH_BUFFER_BITS >> 3 )
692700
693701#if (SW_COLOR_BUFFER_BITS == 8 )
694702 #define SW_COLOR_TYPE uint8_t
@@ -817,14 +825,15 @@ typedef struct {
817825 float ty ; // Texel height
818826} sw_texture_t ;
819827
820- typedef struct {
821- alignas(SW_COLOR_PIXEL_SIZE )
828+ // Pixel data type
829+ // WARNING: ALIGNAS() macro requires a constant value (not operand)
830+ typedef ALIGNAS (SW_COLOR_PIXEL_SIZE ) struct {
822831 SW_COLOR_TYPE color [SW_COLOR_PACK_COMP ];
823832 SW_DEPTH_TYPE depth [SW_DEPTH_PACK_COMP ];
824833} sw_pixel_t ;
825834
826835typedef struct {
827- sw_pixel_t * pixels ;
836+ sw_pixel_t * pixels ;
828837 int width ;
829838 int height ;
830839 int allocSz ;
0 commit comments