Browse Source

Clean up gpBufEnd initialization

Initialization of `gpBufEnd` was done in a convoluted way
that only happened to work.

Cleans up initialization and moves it to dx.cpp.
pull/1085/head
Gleb Mazovetskiy 5 years ago committed by Anders Jenbo
parent
commit
21bb021641
  1. 1
      Source/init.cpp
  2. 5
      SourceX/dx.cpp

1
Source/init.cpp

@ -181,7 +181,6 @@ void init_create_window()
app_fatal("Unable to create main window");
dx_init();
gbActive = true;
gpBufEnd = (BYTE *)(BUFFER_WIDTH * (SCREEN_HEIGHT + SCREEN_Y));
SDL_DisableScreenSaver();
}

5
SourceX/dx.cpp

@ -44,6 +44,7 @@ static void dx_create_back_buffer()
}
gpBuffer = (BYTE *)pal_surface->pixels;
gpBufEnd = gpBuffer;
#ifndef USE_SDL1
// In SDL2, `pal_surface` points to the global `palette`.
@ -93,7 +94,7 @@ static void lock_buf_priv()
}
gpBuffer = (BYTE *)pal_surface->pixels;
gpBufEnd += (uintptr_t)(BYTE *)pal_surface->pixels;
gpBufEnd = (BYTE *)pal_surface->pixels + pal_surface->pitch * pal_surface->h;
sgdwLockCount++;
}
@ -114,7 +115,7 @@ static void unlock_buf_priv()
sgdwLockCount--;
if (sgdwLockCount == 0) {
gpBufEnd -= (uintptr_t)gpBuffer;
gpBufEnd = gpBuffer;
}
sgMemCrit.Leave();
}

Loading…
Cancel
Save