Fix accidentally copying too much data for textures on systems that only use 16 bits per pixel

This commit is contained in:
UnknownShadow200 2025-01-10 18:10:07 +11:00
parent 1055c7b5be
commit 80957f9668
3 changed files with 7 additions and 4 deletions

View File

@ -95,7 +95,7 @@ BitmapCol BitmapColor_Scale(BitmapCol a, float t);
/* A 2D array of BitmapCol pixels */
struct Bitmap { BitmapCol* scan0; int width, height; };
/* Returns number of bytes a bitmap consumes. */
#define Bitmap_DataSize(width, height) ((cc_uint32)(width) * (cc_uint32)(height) * 4)
#define Bitmap_DataSize(width, height) ((cc_uint32)(width) * (cc_uint32)(height) * BITMAPCOLOR_SIZE)
/* Gets the yth row of the given bitmap. */
#define Bitmap_GetRow(bmp, y) ((bmp)->scan0 + (y) * (bmp)->width)
/* Gets the pixel at (x,y) in the given bitmap. */

View File

@ -124,6 +124,9 @@ CC_API cc_bool DynamicLib_DescribeError(cc_string* dst);
/* The default file extension used for dynamic libraries on this platform. */
extern const cc_string DynamicLib_Ext;
CC_API cc_result DynamicLib_Load(const cc_string* path, void** lib); /* OBSOLETE */
CC_API cc_result DynamicLib_Get(void* lib, const char* name, void** symbol); /* OBSOLETE */
#define DYNAMICLIB_QUOTE(x) #x
#define DynamicLib_Sym(sym) { DYNAMICLIB_QUOTE(sym), (void**)&_ ## sym }
#define DynamicLib_Sym2(name, sym) { name, (void**)&_ ## sym }
@ -131,8 +134,6 @@ extern const cc_string DynamicLib_Ext;
#define DynamicLib_SymC(sym) { DYNAMICLIB_QUOTE(_ ## sym), (void**)&_ ## sym }
#endif
CC_API cc_result DynamicLib_Load(const cc_string* path, void** lib); /* OBSOLETE */
CC_API cc_result DynamicLib_Get(void* lib, const char* name, void** symbol); /* OBSOLETE */
/* Contains a name and a pointer to variable that will hold the loaded symbol */
/* static int (APIENTRY *_myGetError)(void); --- (for example) */
/* static struct DynamicLibSym sym = { "myGetError", (void**)&_myGetError }; */

View File

@ -824,8 +824,10 @@ void Window_DisableRawMouse(void) {
#if CC_GFX_BACKEND_IS_GL() && !defined CC_BUILD_EGL
static HGLRC ctx_handle;
static HDC ctx_DC;
typedef BOOL (WINAPI *FP_SWAPINTERVAL)(int interval);
static FP_SWAPINTERVAL wglSwapIntervalEXT;
static void* gl_lib;
static void GLContext_SelectGraphicsMode(struct GraphicsMode* mode) {
@ -885,7 +887,7 @@ void GLContext_Free(void) {
ctx_handle = NULL;
}
static PROC (WINAPI *_wglGetProcAddress)(LPCSTR);
static PROC (WINAPI *_wglGetProcAddress)(LPCSTR func);
/* https://www.khronos.org/opengl/wiki/Load_OpenGL_Functions#Windows */
#define GLContext_IsInvalidAddress(ptr) (ptr == (void*)0 || ptr == (void*)1 || ptr == (void*)-1 || ptr == (void*)2)