mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 11:06:06 -04:00
Saturn: WIP textures
This commit is contained in:
parent
e493d80671
commit
197e440f1c
@ -72,10 +72,12 @@ static GfxResourceID white_square;
|
||||
void Gfx_RestoreState(void) {
|
||||
InitDefaultResources();
|
||||
|
||||
// 2x2 dummy white texture
|
||||
struct Bitmap bmp;
|
||||
BitmapCol pixels[4] = { BitmapColor_RGB(255, 0, 0), BITMAPCOLOR_WHITE, BITMAPCOLOR_WHITE, BITMAPCOLOR_WHITE };
|
||||
Bitmap_Init(bmp, 2, 2, pixels);
|
||||
BitmapCol pixels[8 * 8];
|
||||
Mem_Set(pixels, 0xFF, sizeof(pixels));
|
||||
pixels[0] = BitmapColor_RGB(255, 0, 0);
|
||||
|
||||
Bitmap_Init(bmp, 8, 8, pixels);
|
||||
white_square = Gfx_CreateTexture(&bmp, 0, false);
|
||||
}
|
||||
|
||||
@ -98,8 +100,8 @@ void Gfx_Create(void) {
|
||||
|
||||
Gfx.MinTexWidth = 8;
|
||||
Gfx.MinTexHeight = 8;
|
||||
Gfx.MaxTexWidth = 128;
|
||||
Gfx.MaxTexHeight = 128;
|
||||
Gfx.MaxTexWidth = 16; // 128
|
||||
Gfx.MaxTexHeight = 16; // 128
|
||||
Gfx.Created = true;
|
||||
}
|
||||
|
||||
@ -114,14 +116,19 @@ void Gfx_Free(void) {
|
||||
#define BGRA8_to_SATURN(src) \
|
||||
((src[2] & 0xF8) >> 3) | ((src[1] & 0xF8) << 2) | ((src[0] & 0xF8) << 7) | ((src[3] & 0x80) << 8)
|
||||
|
||||
typedef struct CCTexture {
|
||||
int width, height;
|
||||
cc_uint16 pixels[];
|
||||
} CCTexture;
|
||||
|
||||
static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
|
||||
cc_uint16* tmp = Mem_TryAlloc(bmp->width * bmp->height, 2);
|
||||
if (!tmp) return NULL;
|
||||
CCTexture* tex = Mem_TryAlloc(4 + bmp->width * bmp->height, 2);
|
||||
if (!tex) return NULL;
|
||||
|
||||
for (int y = 0; y < bmp->height; y++)
|
||||
{
|
||||
cc_uint32* src = bmp->scan0 + y * rowWidth;
|
||||
cc_uint16* dst = tmp + y * bmp->width;
|
||||
cc_uint16* dst = tex->pixels + y * bmp->width;
|
||||
|
||||
for (int x = 0; x < bmp->width; x++)
|
||||
{
|
||||
@ -130,17 +137,21 @@ static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8
|
||||
dst[x] = 0xFEEE;
|
||||
}
|
||||
}
|
||||
|
||||
scu_dma_transfer(0, _vdp1_vram_partitions.texture_base, tmp, bmp->width * bmp->height * 2);
|
||||
scu_dma_transfer_wait(0);
|
||||
Mem_Free(tmp);
|
||||
return (void*)1;
|
||||
return tex;
|
||||
}
|
||||
|
||||
void Gfx_BindTexture(GfxResourceID texId) {
|
||||
if (!texId) return;
|
||||
CCTexture* tex = (CCTexture*)texId;
|
||||
|
||||
scu_dma_transfer(0, _vdp1_vram_partitions.texture_base, tex->pixels, tex->width * tex->height * 2);
|
||||
scu_dma_transfer_wait(0);
|
||||
}
|
||||
|
||||
void Gfx_DeleteTexture(GfxResourceID* texId) {
|
||||
CCTexture* tex = *texId;
|
||||
if (tex) Mem_Free(tex);
|
||||
*texId = NULL;
|
||||
}
|
||||
|
||||
void Gfx_UpdateTexture(GfxResourceID texId, int x, int y, struct Bitmap* part, int rowWidth, cc_bool mipmaps) {
|
||||
@ -377,18 +388,21 @@ static void DrawTexturedQuads2D(int verticesCount, int startVertex) {
|
||||
|
||||
vdp1_cmdt_t* cmd;
|
||||
|
||||
|
||||
cmd = NextPrimitive();
|
||||
vdp1_cmdt_polygon_set(cmd);
|
||||
vdp1_cmdt_color_set(cmd, RGB1555(1, R >> 3, G >> 3, B >> 3));
|
||||
vdp1_cmdt_draw_mode_set(cmd, color_draw_mode);
|
||||
vdp1_cmdt_vtx_set(cmd, points);
|
||||
|
||||
/*cmd = NextPrimitive();
|
||||
/*
|
||||
cmd = NextPrimitive();
|
||||
vdp1_cmdt_distorted_sprite_set(cmd);
|
||||
vdp1_cmdt_char_size_set(cmd, 8, 8);
|
||||
vdp1_cmdt_char_base_set(cmd, (vdp1_vram_t)_vdp1_vram_partitions.texture_base);
|
||||
vdp1_cmdt_draw_mode_set(cmd, texture_draw_mode);
|
||||
vdp1_cmdt_vtx_set(cmd, points);*/
|
||||
vdp1_cmdt_vtx_set(cmd, points);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user