mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-15 06:04:49 +01:00
only update textures if necessary
This commit is contained in:
parent
4c2272a54e
commit
a40392e11a
@ -73,6 +73,8 @@ typedef struct IDirectDrawImpl
|
||||
DEVMODE mode;
|
||||
struct { int width; int height; int x; int y; } viewport;
|
||||
|
||||
LONG paletteUpdated;
|
||||
LONG surfaceUpdated;
|
||||
} render;
|
||||
|
||||
HWND hWnd;
|
||||
|
@ -62,6 +62,7 @@ HRESULT __stdcall ddraw_palette_SetEntries(IDirectDrawPaletteImpl *This, DWORD d
|
||||
/* FIXME: only refresh the screen when the primary palette is changed */
|
||||
if(ddraw->primary && ddraw->render.run)
|
||||
{
|
||||
InterlockedExchange(&ddraw->render.paletteUpdated, TRUE);
|
||||
ReleaseSemaphore(ddraw->render.sem, 1, NULL);
|
||||
}
|
||||
|
||||
|
12
src/render.c
12
src/render.c
@ -477,10 +477,18 @@ DWORD WINAPI render_main(void)
|
||||
if (paletteConvProgram)
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, paletteTexId);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 256, 1, GL_RGBA, GL_UNSIGNED_BYTE, ddraw->primary->palette->data_bgr);
|
||||
if (InterlockedExchange(&ddraw->render.paletteUpdated, FALSE))
|
||||
{
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 256, 1, GL_RGBA, GL_UNSIGNED_BYTE,
|
||||
ddraw->primary->palette->data_bgr);
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, surfaceTexId);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, ddraw->width, ddraw->height, surfaceFormat, GL_UNSIGNED_BYTE, ddraw->primary->surface);
|
||||
if (InterlockedExchange(&ddraw->render.surfaceUpdated, FALSE))
|
||||
{
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, ddraw->width, ddraw->height, surfaceFormat, GL_UNSIGNED_BYTE,
|
||||
ddraw->primary->surface);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -107,11 +107,12 @@ HRESULT __stdcall ddraw_surface_Blt(IDirectDrawSurfaceImpl *This, LPRECT lpDestR
|
||||
int dst_w = lpDestRect->right - lpDestRect->left;
|
||||
int dst_h = lpDestRect->bottom - lpDestRect->top;
|
||||
|
||||
for (int y = 0; y < dst_h; y++)
|
||||
int y, x;
|
||||
for (y = 0; y < dst_h; y++)
|
||||
{
|
||||
int ydst = This->width * (y + lpDestRect->top);
|
||||
|
||||
for (int x = 0; x < dst_w; x++)
|
||||
for (x = 0; x < dst_w; x++)
|
||||
{
|
||||
((unsigned char *)This->surface)[x + lpDestRect->left + ydst] = lpDDBltFx->dwFillColor;
|
||||
}
|
||||
@ -169,6 +170,7 @@ HRESULT __stdcall ddraw_surface_Blt(IDirectDrawSurfaceImpl *This, LPRECT lpDestR
|
||||
|
||||
if(This->caps & DDSCAPS_PRIMARYSURFACE && !(This->flags & DDSD_BACKBUFFERCOUNT) && ddraw->render.run)
|
||||
{
|
||||
InterlockedExchange(&ddraw->render.surfaceUpdated, TRUE);
|
||||
ReleaseSemaphore(ddraw->render.sem, 1, NULL);
|
||||
if (ddraw->renderer != render_main)
|
||||
{
|
||||
@ -255,6 +257,7 @@ HRESULT __stdcall ddraw_surface_Flip(IDirectDrawSurfaceImpl *This, LPDIRECTDRAWS
|
||||
|
||||
if(This->caps & DDSCAPS_PRIMARYSURFACE && ddraw->render.run)
|
||||
{
|
||||
InterlockedExchange(&ddraw->render.surfaceUpdated, TRUE);
|
||||
ReleaseSemaphore(ddraw->render.sem, 1, NULL);
|
||||
if (ddraw->renderer != render_main)
|
||||
{
|
||||
@ -430,6 +433,7 @@ HRESULT __stdcall ddraw_surface_Unlock(IDirectDrawSurfaceImpl *This, LPVOID lpRe
|
||||
|
||||
if(This->caps & DDSCAPS_PRIMARYSURFACE && !(This->flags & DDSD_BACKBUFFERCOUNT) && ddraw->render.run)
|
||||
{
|
||||
InterlockedExchange(&ddraw->render.surfaceUpdated, TRUE);
|
||||
ReleaseSemaphore(ddraw->render.sem, 1, NULL);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user