mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-11 08:36:38 -04:00
Broken 16 bits per pixel bitmaps
This commit is contained in:
parent
3b0f54bc6a
commit
cadf185cee
12
src/Bitmap.c
12
src/Bitmap.c
@ -35,12 +35,12 @@ void Bitmap_UNSAFE_CopyBlock(int srcX, int srcY, int dstX, int dstY,
|
||||
|
||||
void Bitmap_Allocate(struct Bitmap* bmp, int width, int height) {
|
||||
bmp->width = width; bmp->height = height;
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "bitmap data");
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "bitmap data");
|
||||
}
|
||||
|
||||
void Bitmap_TryAllocate(struct Bitmap* bmp, int width, int height) {
|
||||
bmp->width = width; bmp->height = height;
|
||||
bmp->scan0 = (BitmapCol*)Mem_TryAlloc(width * height, 4);
|
||||
bmp->scan0 = (BitmapCol*)Mem_TryAlloc(width * height, BITMAPCOLOR_SIZE);
|
||||
}
|
||||
|
||||
void Bitmap_Scale(struct Bitmap* dst, struct Bitmap* src,
|
||||
@ -409,9 +409,9 @@ cc_result Png_Decode(struct Bitmap* bmp, struct Stream* stream) {
|
||||
|
||||
for (i = 0; i < dataSize; i += 3) {
|
||||
palette[i / 3] &= BITMAPCOLOR_A_MASK; /* set RGB to 0 */
|
||||
palette[i / 3] |= buffer[i ] << BITMAPCOLOR_R_SHIFT;
|
||||
palette[i / 3] |= buffer[i + 1] << BITMAPCOLOR_G_SHIFT;
|
||||
palette[i / 3] |= buffer[i + 2] << BITMAPCOLOR_B_SHIFT;
|
||||
palette[i / 3] |= BitmapColor_R_Bits(buffer[i ]);
|
||||
palette[i / 3] |= BitmapColor_G_Bits(buffer[i + 1]);
|
||||
palette[i / 3] |= BitmapColor_B_Bits(buffer[i + 2]);
|
||||
}
|
||||
} break;
|
||||
|
||||
@ -434,7 +434,7 @@ cc_result Png_Decode(struct Bitmap* bmp, struct Stream* stream) {
|
||||
/* set alpha component of palette */
|
||||
for (i = 0; i < dataSize; i++) {
|
||||
palette[i] &= BITMAPCOLOR_RGB_MASK; /* set A to 0 */
|
||||
palette[i] |= buffer[i] << BITMAPCOLOR_A_SHIFT;
|
||||
palette[i] |= BitmapColor_A_Bits(buffer[i]);
|
||||
}
|
||||
} else if (colorspace == PNG_COLOR_RGB) {
|
||||
if (dataSize != 6) return PNG_ERR_TRANS_COUNT;
|
||||
|
68
src/Bitmap.h
68
src/Bitmap.h
@ -6,8 +6,15 @@
|
||||
*/
|
||||
struct Stream;
|
||||
|
||||
/* Represents a packed 32 bit RGBA colour, suitable for native graphics API texture pixels. */
|
||||
typedef cc_uint32 BitmapCol;
|
||||
/* Represents a packed RGBA colour, suitable for 3D graphics API textures and 2D window framebuffers. */
|
||||
#ifndef BITMAP_16BPP
|
||||
typedef cc_uint32 BitmapCol;
|
||||
#define BITMAPCOLOR_SIZE 4
|
||||
#else
|
||||
typedef cc_uint16 BitmapCol;
|
||||
#define BITMAPCOLOR_SIZE 2
|
||||
#endif
|
||||
|
||||
#if defined CC_BUILD_WEB || defined CC_BUILD_ANDROID || defined CC_BUILD_PSP || defined CC_BUILD_PSVITA || defined CC_BUILD_PS2
|
||||
#define BITMAPCOLOR_R_SHIFT 0
|
||||
#define BITMAPCOLOR_G_SHIFT 8
|
||||
@ -18,6 +25,11 @@ typedef cc_uint32 BitmapCol;
|
||||
#define BITMAPCOLOR_G_SHIFT 16
|
||||
#define BITMAPCOLOR_B_SHIFT 8
|
||||
#define BITMAPCOLOR_A_SHIFT 0
|
||||
#elif defined BITMAP_16BPP
|
||||
#define BITMAPCOLOR_B_SHIFT 0
|
||||
#define BITMAPCOLOR_G_SHIFT 5
|
||||
#define BITMAPCOLOR_R_SHIFT 10
|
||||
#define BITMAPCOLOR_A_SHIFT 15
|
||||
#else
|
||||
#define BITMAPCOLOR_B_SHIFT 0
|
||||
#define BITMAPCOLOR_G_SHIFT 8
|
||||
@ -25,21 +37,43 @@ typedef cc_uint32 BitmapCol;
|
||||
#define BITMAPCOLOR_A_SHIFT 24
|
||||
#endif
|
||||
|
||||
#define BITMAPCOLOR_R_MASK (0xFFU << BITMAPCOLOR_R_SHIFT)
|
||||
#define BITMAPCOLOR_G_MASK (0xFFU << BITMAPCOLOR_G_SHIFT)
|
||||
#define BITMAPCOLOR_B_MASK (0xFFU << BITMAPCOLOR_B_SHIFT)
|
||||
#define BITMAPCOLOR_A_MASK (0xFFU << BITMAPCOLOR_A_SHIFT)
|
||||
|
||||
/* Extracts just the R/G/B/A component from a bitmap color */
|
||||
#define BitmapCol_R(color) ((cc_uint8)(color >> BITMAPCOLOR_R_SHIFT))
|
||||
#define BitmapCol_G(color) ((cc_uint8)(color >> BITMAPCOLOR_G_SHIFT))
|
||||
#define BitmapCol_B(color) ((cc_uint8)(color >> BITMAPCOLOR_B_SHIFT))
|
||||
#define BitmapCol_A(color) ((cc_uint8)(color >> BITMAPCOLOR_A_SHIFT))
|
||||
|
||||
#define BitmapColor_R_Bits(color) ((cc_uint8)(color) << BITMAPCOLOR_R_SHIFT)
|
||||
#define BitmapColor_G_Bits(color) ((cc_uint8)(color) << BITMAPCOLOR_G_SHIFT)
|
||||
#define BitmapColor_B_Bits(color) ((cc_uint8)(color) << BITMAPCOLOR_B_SHIFT)
|
||||
#define BitmapColor_A_Bits(color) ((cc_uint8)(color) << BITMAPCOLOR_A_SHIFT)
|
||||
#ifndef BITMAP_16BPP
|
||||
/* Masks a packed color to the selected component */
|
||||
#define BITMAPCOLOR_R_MASK (0xFFU << BITMAPCOLOR_R_SHIFT)
|
||||
#define BITMAPCOLOR_G_MASK (0xFFU << BITMAPCOLOR_G_SHIFT)
|
||||
#define BITMAPCOLOR_B_MASK (0xFFU << BITMAPCOLOR_B_SHIFT)
|
||||
#define BITMAPCOLOR_A_MASK (0xFFU << BITMAPCOLOR_A_SHIFT)
|
||||
|
||||
/* Extracts just the R/G/B/A component from a bitmap color */
|
||||
#define BitmapCol_R(color) ((cc_uint8)(color >> BITMAPCOLOR_R_SHIFT))
|
||||
#define BitmapCol_G(color) ((cc_uint8)(color >> BITMAPCOLOR_G_SHIFT))
|
||||
#define BitmapCol_B(color) ((cc_uint8)(color >> BITMAPCOLOR_B_SHIFT))
|
||||
#define BitmapCol_A(color) ((cc_uint8)(color >> BITMAPCOLOR_A_SHIFT))
|
||||
|
||||
/* Converts input value into a packed color component */
|
||||
#define BitmapColor_R_Bits(value) ((cc_uint8)(value) << BITMAPCOLOR_R_SHIFT)
|
||||
#define BitmapColor_G_Bits(value) ((cc_uint8)(value) << BITMAPCOLOR_G_SHIFT)
|
||||
#define BitmapColor_B_Bits(value) ((cc_uint8)(value) << BITMAPCOLOR_B_SHIFT)
|
||||
#define BitmapColor_A_Bits(value) ((cc_uint8)(value) << BITMAPCOLOR_A_SHIFT)
|
||||
#else
|
||||
/* Masks a packed color to the selected component */
|
||||
#define BITMAPCOLOR_R_MASK (0x3FU << BITMAPCOLOR_R_SHIFT)
|
||||
#define BITMAPCOLOR_G_MASK (0x3FU << BITMAPCOLOR_G_SHIFT)
|
||||
#define BITMAPCOLOR_B_MASK (0x3FU << BITMAPCOLOR_B_SHIFT)
|
||||
#define BITMAPCOLOR_A_MASK (0x01U << BITMAPCOLOR_A_SHIFT)
|
||||
|
||||
/* Extracts just the R/G/B/A component from a bitmap color */
|
||||
#define BitmapCol_R(color) (((cc_uint8)(color >> BITMAPCOLOR_R_SHIFT) & 0x3F) << 3)
|
||||
#define BitmapCol_G(color) (((cc_uint8)(color >> BITMAPCOLOR_G_SHIFT) & 0x3F) << 3)
|
||||
#define BitmapCol_B(color) (((cc_uint8)(color >> BITMAPCOLOR_B_SHIFT) & 0x3F) << 3)
|
||||
#define BitmapCol_A(color) (((cc_uint8)(color >> BITMAPCOLOR_A_SHIFT) & 0x01) << 7)
|
||||
|
||||
/* Converts input value into a packed color component */
|
||||
#define BitmapColor_R_Bits(value) (((cc_uint8)(value) >> 3) << BITMAPCOLOR_R_SHIFT)
|
||||
#define BitmapColor_G_Bits(value) (((cc_uint8)(value) >> 3) << BITMAPCOLOR_G_SHIFT)
|
||||
#define BitmapColor_B_Bits(value) (((cc_uint8)(value) >> 3) << BITMAPCOLOR_B_SHIFT)
|
||||
#define BitmapColor_A_Bits(value) (((cc_uint8)(value) >> 7) << BITMAPCOLOR_A_SHIFT)
|
||||
#endif
|
||||
|
||||
#define BitmapCol_Make(r, g, b, a) (BitmapColor_R_Bits(r) | BitmapColor_G_Bits(g) | BitmapColor_B_Bits(b) | BitmapColor_A_Bits(a))
|
||||
#define BitmapColor_RGB(r, g, b) (BitmapColor_R_Bits(r) | BitmapColor_G_Bits(g) | BitmapColor_B_Bits(b) | BITMAPCOLOR_A_MASK)
|
||||
|
@ -163,7 +163,7 @@ void Context2D_Alloc(struct Context2D* ctx, int width, int height) {
|
||||
|
||||
ctx->bmp.width = width;
|
||||
ctx->bmp.height = height;
|
||||
ctx->bmp.scan0 = (BitmapCol*)Mem_AllocCleared(width * height, 4, "bitmap data");
|
||||
ctx->bmp.scan0 = (BitmapCol*)Mem_AllocCleared(width * height, BITMAPCOLOR_SIZE, "bitmap data");
|
||||
}
|
||||
|
||||
void Context2D_Wrap(struct Context2D* ctx, struct Bitmap* bmp) {
|
||||
|
@ -93,7 +93,7 @@ cc_bool Drawer2D_IsWhiteColor(char c);
|
||||
cc_bool Drawer2D_UNSAFE_NextPart(cc_string* left, cc_string* part, char* colorCode);
|
||||
|
||||
/* Divides R/G/B by 4 */
|
||||
#define SHADOW_MASK ((0x3F << BITMAPCOLOR_R_SHIFT) | (0x3F << BITMAPCOLOR_G_SHIFT) | (0x3F << BITMAPCOLOR_B_SHIFT))
|
||||
#define SHADOW_MASK (BitmapColor_R_Bits(0x3F) | BitmapColor_G_Bits(0x3F) | BitmapColor_B_Bits(0x3F))
|
||||
static CC_INLINE BitmapCol GetShadowColor(BitmapCol c) {
|
||||
if (Drawer2D.BlackTextShadows) return BITMAPCOLOR_BLACK;
|
||||
|
||||
|
@ -178,7 +178,7 @@ static void D3D11_DoMipmaps(ID3D11Resource* texture, int x, int y, struct Bitmap
|
||||
if (width > 1) width /= 2;
|
||||
if (height > 1) height /= 2;
|
||||
|
||||
cur = (BitmapCol*)Mem_Alloc(width * height, 4, "mipmaps");
|
||||
cur = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "mipmaps");
|
||||
GenMipmaps(width, height, cur, prev, rowWidth);
|
||||
|
||||
D3D11_BOX box;
|
||||
|
@ -287,7 +287,7 @@ static void D3D9_DoMipmaps(IDirect3DTexture9* texture, int x, int y, struct Bitm
|
||||
if (width > 1) width /= 2;
|
||||
if (height > 1) height /= 2;
|
||||
|
||||
cur = (BitmapCol*)Mem_Alloc(width * height, 4, "mipmaps");
|
||||
cur = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "mipmaps");
|
||||
GenMipmaps(width, height, cur, prev, rowWidth);
|
||||
|
||||
Bitmap_Init(mipmap, width, height, cur);
|
||||
|
@ -98,7 +98,7 @@ static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8
|
||||
|
||||
void Gfx_UpdateTexture(GfxResourceID texId, int x, int y, struct Bitmap* part, int rowWidth, cc_bool mipmaps) {
|
||||
CCTexture* tex = (CCTexture*)texId;
|
||||
cc_uint32* dst = (tex->pixels + x) + y * tex->width;
|
||||
BitmapCol* dst = (tex->pixels + x) + y * tex->width;
|
||||
CopyTextureData(dst, tex->width * 4, part, rowWidth << 2);
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,7 @@ void Gamepads_Process(float delta) {
|
||||
*------------------------------------------------------Framebuffer--------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels");
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
|
||||
bmp->width = width;
|
||||
bmp->height = height;
|
||||
}
|
||||
|
@ -481,7 +481,7 @@ cc_result Window_SaveFileDialog(const struct SaveFileDialogArgs* save_args) {
|
||||
}
|
||||
|
||||
void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels");
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
|
||||
bmp->width = width;
|
||||
bmp->height = height;
|
||||
}
|
||||
|
@ -287,7 +287,7 @@ void Gamepads_Process(float delta) {
|
||||
*------------------------------------------------------Framebuffer--------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels");
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
|
||||
bmp->width = width;
|
||||
bmp->height = height;
|
||||
}
|
||||
|
@ -452,7 +452,7 @@ void Gamepads_Process(float delta) {
|
||||
*------------------------------------------------------Framebuffer--------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels");
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
|
||||
bmp->width = width;
|
||||
bmp->height = height;
|
||||
}
|
||||
|
@ -439,7 +439,7 @@ static PixMapHandle fb_pixmap;
|
||||
|
||||
void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
|
||||
if (!useGWorld) {
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels");
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
|
||||
bmp->width = width;
|
||||
bmp->height = height;
|
||||
return;
|
||||
|
@ -152,7 +152,7 @@ void Gamepads_Process(float delta) {
|
||||
*------------------------------------------------------Framebuffer--------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels");
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
|
||||
bmp->width = width;
|
||||
bmp->height = height;
|
||||
}
|
||||
|
@ -257,7 +257,7 @@ void Gamepads_Process(float delta) {
|
||||
*------------------------------------------------------Framebuffer--------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels");
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
|
||||
bmp->width = width;
|
||||
bmp->height = height;
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
|
||||
PutDispEnv(&disp);
|
||||
SetDispMask(1);
|
||||
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels");
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
|
||||
bmp->width = width;
|
||||
bmp->height = height;
|
||||
|
||||
|
@ -260,7 +260,7 @@ void Gamepads_Process(float delta) {
|
||||
*------------------------------------------------------Framebuffer--------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels");
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
|
||||
bmp->width = width;
|
||||
bmp->height = height;
|
||||
|
||||
|
@ -136,7 +136,7 @@ void Gamepads_Process(float delta) {
|
||||
*------------------------------------------------------Framebuffer--------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels");
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
|
||||
bmp->width = width;
|
||||
bmp->height = height;
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ void Gamepads_Process(float delta) {
|
||||
*#########################################################################################################################*/
|
||||
static struct Bitmap fb_bmp;
|
||||
void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels");
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
|
||||
bmp->width = width;
|
||||
bmp->height = height;
|
||||
fb_bmp = *bmp;
|
||||
|
@ -198,7 +198,7 @@ void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
|
||||
framebufferCreate(&fb, nwindowGetDefault(), DisplayInfo.Width, DisplayInfo.Height, PIXEL_FORMAT_BGRA_8888, 2);
|
||||
framebufferMakeLinear(&fb);
|
||||
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels");
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
|
||||
bmp->width = width;
|
||||
bmp->height = height;
|
||||
}
|
||||
|
@ -529,7 +529,7 @@ cc_result Window_SaveFileDialog(const struct SaveFileDialogArgs* args) {
|
||||
|
||||
|
||||
void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels");
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
|
||||
bmp->width = width;
|
||||
bmp->height = height;
|
||||
}
|
||||
|
@ -374,7 +374,7 @@ void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
|
||||
GX2InitTextureRegs(&fb);
|
||||
|
||||
fb.surface.image = MEMAllocFromDefaultHeapEx(fb.surface.imageSize, fb.surface.alignment);
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels");
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
|
||||
bmp->width = width;
|
||||
bmp->height = height;
|
||||
}
|
||||
|
@ -1133,7 +1133,7 @@ static int fb_fast;
|
||||
void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
|
||||
if (!fb_gc) fb_gc = XCreateGC(win_display, win_handle, 0, NULL);
|
||||
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels");
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
|
||||
bmp->width = width;
|
||||
bmp->height = height;
|
||||
|
||||
@ -1141,7 +1141,7 @@ void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
|
||||
/* Easy for 24/32 bit case, but much trickier with other depths */
|
||||
/* (have to do a manual and slow second blit for other depths) */
|
||||
fb_fast = win_visual.depth == 24 || win_visual.depth == 32;
|
||||
fb_data = fb_fast ? bmp->scan0 : Mem_Alloc(width * height, 4, "window blit");
|
||||
fb_data = fb_fast ? bmp->scan0 : Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window blit");
|
||||
|
||||
fb_image = XCreateImage(win_display, win_visual.visual,
|
||||
win_visual.depth, ZPixmap, 0, fb_data,
|
||||
|
@ -193,7 +193,7 @@ void Gamepads_Process(float delta) {
|
||||
*------------------------------------------------------Framebuffer--------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels");
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
|
||||
bmp->width = width;
|
||||
bmp->height = height;
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ void Gamepads_Process(float delta) {
|
||||
*------------------------------------------------------Framebuffer--------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels");
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
|
||||
bmp->width = width;
|
||||
bmp->height = height;
|
||||
}
|
||||
|
@ -702,7 +702,7 @@ cc_result Window_OpenFileDialog(const struct OpenFileDialogArgs* args) {
|
||||
*#########################################################################################################################*/
|
||||
static struct Bitmap fb_bmp;
|
||||
void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, 4, "window pixels");
|
||||
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
|
||||
bmp->width = width;
|
||||
bmp->height = height;
|
||||
fb_bmp = *bmp;
|
||||
|
@ -79,7 +79,7 @@ static void Gfx_DoMipmaps(int x, int y, struct Bitmap* bmp, int rowWidth, cc_boo
|
||||
if (width > 1) width /= 2;
|
||||
if (height > 1) height /= 2;
|
||||
|
||||
cur = (BitmapCol*)Mem_Alloc(width * height, 4, "mipmaps");
|
||||
cur = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "mipmaps");
|
||||
GenMipmaps(width, height, cur, prev, rowWidth);
|
||||
|
||||
if (partial) {
|
||||
@ -244,7 +244,7 @@ cc_result Gfx_TakeScreenshot(struct Stream* output) {
|
||||
bmp.width = vp[2];
|
||||
bmp.height = vp[3];
|
||||
|
||||
bmp.scan0 = (BitmapCol*)Mem_TryAlloc(bmp.width * bmp.height, 4);
|
||||
bmp.scan0 = (BitmapCol*)Mem_TryAlloc(bmp.width * bmp.height, BITMAPCOLOR_SIZE);
|
||||
if (!bmp.scan0) return ERR_OUT_OF_MEMORY;
|
||||
glReadPixels(0, 0, bmp.width, bmp.height, PIXEL_FORMAT, TRANSFER_FORMAT, bmp.scan0);
|
||||
|
||||
|
@ -1401,7 +1401,7 @@ void LBackend_Redraw(void) {
|
||||
struct Bitmap bmp;
|
||||
bmp.width = max(Window_Main.Width, 1);
|
||||
bmp.height = max(Window_Main.Height, 1);
|
||||
bmp.scan0 = (BitmapCol*)Mem_Alloc(bmp.width * bmp.height, 4, "window pixels");
|
||||
bmp.scan0 = (BitmapCol*)Mem_Alloc(bmp.width * bmp.height, BITMAPCOLOR_SIZE, "window pixels");
|
||||
|
||||
Context2D_Wrap(&ctx, &bmp);
|
||||
win_ctx = CGBitmapContextCreate(bmp.scan0, bmp.width, bmp.height, 8, bmp.width * 4,
|
||||
|
Loading…
x
Reference in New Issue
Block a user