- [Psy-X] added GR_ClearVRAM to separate from GR_Clear

This commit is contained in:
Ilya Shurumov 2021-05-19 11:33:03 +06:00 committed by InspirationByte
parent 2524968f6a
commit 5ee512e200
3 changed files with 19 additions and 8 deletions

View File

@ -191,6 +191,7 @@ extern void GR_SetWireframe(int enable);
extern void GR_DestroyTexture(TextureID texture);
extern void GR_Clear(int x, int y, int w, int h, unsigned char r, unsigned char g, unsigned char b);
extern void GR_ClearVRAM(int x, int y, int w, int h, unsigned char r, unsigned char g, unsigned char b);
extern void GR_UpdateVertexBuffer(const GrVertex* vertices, int count);
extern void GR_DrawTriangles(int start_vertex, int triangles);

View File

@ -27,12 +27,18 @@ void(*drawsync_callback)(void) = NULL;
int ClearImage(RECT16* rect, u_char r, u_char g, u_char b)
{
GR_ClearVRAM(rect->x, rect->y, rect->w, rect->h, r, g, b);
// TODO: clear all affected backbuffers
GR_Clear(rect->x, rect->y, rect->w, rect->h, r, g, b);
return 0;
}
int ClearImage2(RECT16* rect, u_char r, u_char g, u_char b)
{
GR_ClearVRAM(rect->x, rect->y, rect->w, rect->h, r, g, b);
// TODO: clear all affected backbuffers
GR_Clear(rect->x, rect->y, rect->w, rect->h, r, g, b);
return 0;
}

View File

@ -1326,18 +1326,17 @@ void GR_DestroyTexture(TextureID texture)
#endif
}
void GR_Clear(int x, int y, int w, int h, unsigned char r, unsigned char g, unsigned char b)
void GR_ClearVRAM(int x, int y, int w, int h, unsigned char r, unsigned char g, unsigned char b)
{
vram_need_update = 1;
framebuffer_need_update = 1;
u_short* dst = vram + x + y * VRAM_WIDTH;
if (x+w > VRAM_WIDTH)
if (x + w > VRAM_WIDTH)
w = VRAM_WIDTH - x;
if (y+h > VRAM_HEIGHT)
h = VRAM_HEIGHT-y;
if (y + h > VRAM_HEIGHT)
h = VRAM_HEIGHT - y;
// clear VRAM region with given color
for (int i = 0; i < h; i++)
@ -1349,6 +1348,11 @@ void GR_Clear(int x, int y, int w, int h, unsigned char r, unsigned char g, unsi
dst += VRAM_WIDTH;
}
}
void GR_Clear(int x, int y, int w, int h, unsigned char r, unsigned char g, unsigned char b)
{
framebuffer_need_update = 1;
#if defined(USE_OPENGL)
glClearColor(r / 255.0f, g / 255.0f, b / 255.0f, 1.0f);