Skip to content

Commit

Permalink
Added a define for activating support for 'new' video code.
Browse files Browse the repository at this point in the history
Vanilla Conquer had internal changes to how it handled frame
rendering when SDL support was added. This code is only active for
SDL builds, and not for builds with the legacy Windows video code
enabled. However, this code should be used for all new video code
implementations and not just SDL, so hiding it behind the SDL_BUILD
is misleading and also makes it harder to add support for other
platforms.

Changed the compile time checks for SDL_BUILD into NEW_VIDEO_BUILD
where those checks guard code that is not SDL-specific.
  • Loading branch information
isojalka authored and OmniBlade committed Jun 12, 2024
1 parent 33b76ad commit aede515
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ if(BUILD_VANILLATD OR BUILD_VANILLARA)
target_compile_definitions(commonv PUBLIC OPENAL_BUILD)
endif()
if(SDL2)
target_compile_definitions(commonv PUBLIC SDL_BUILD SDL2_BUILD)
target_compile_definitions(commonv PUBLIC SDL_BUILD SDL2_BUILD NEW_VIDEO_BUILD)
endif()
if(SDL1)
target_compile_definitions(commonv PUBLIC SDL_BUILD SDL1_BUILD)
target_compile_definitions(commonv PUBLIC SDL_BUILD SDL1_BUILD NEW_VIDEO_BUILD)
endif()
if(NETWORKING)
target_compile_definitions(commonv PUBLIC WINSOCK_IPX NETWORKING)
Expand Down
6 changes: 3 additions & 3 deletions common/framelimit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@

extern WWMouseClass* WWMouse;

#ifdef SDL_BUILD
#ifdef NEW_VIDEO_BUILD
void Video_Render_Frame();
#endif

void Frame_Limiter(FrameLimitFlags flags)
{
static auto frame_start = std::chrono::steady_clock::now();
#ifdef SDL_BUILD
#ifdef NEW_VIDEO_BUILD
static auto render_avg = 0;

auto render_start = std::chrono::steady_clock::now();
Expand All @@ -43,7 +43,7 @@ void Frame_Limiter(FrameLimitFlags flags)
#endif

if (Settings.Video.FrameLimit > 0 && !(flags & FrameLimitFlags::FL_NO_BLOCK)) {
#ifdef SDL_BUILD
#ifdef NEW_VIDEO_BUILD
auto frame_end = render_end;
#else
auto frame_end = std::chrono::steady_clock::now();
Expand Down
14 changes: 7 additions & 7 deletions common/wwmouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void WWMouseClass::Unblock_Mouse(GraphicBufferClass* buffer)

void WWMouseClass::Process_Mouse(void)
{
#if !defined(REMASTER_BUILD) && !defined(SDL_BUILD)
#if !defined(REMASTER_BUILD) && !defined(NEW_VIDEO_BUILD)
int x, y;

//
Expand Down Expand Up @@ -288,7 +288,7 @@ void* WWMouseClass::Set_Cursor(int xhotspot, int yhotspot, void* cursor)
void WWMouseClass::Low_Hide_Mouse()
{
// ST - 1/3/2019 10:50AM
#if !defined(REMASTER_BUILD) && !defined(SDL_BUILD)
#if !defined(REMASTER_BUILD) && !defined(NEW_VIDEO_BUILD)
if (!State) {
if (MouseBuffX != -1 || MouseBuffY != -1) {
if (Screen->Lock()) {
Expand Down Expand Up @@ -322,7 +322,7 @@ void WWMouseClass::Low_Show_Mouse(int x, int y)
State--;

// ST - 1/3/2019 10:50AM
#if !defined(REMASTER_BUILD) && !defined(SDL_BUILD)
#if !defined(REMASTER_BUILD) && !defined(NEW_VIDEO_BUILD)

//
// If the mouse is completely visible then draw it at its current
Expand Down Expand Up @@ -450,7 +450,7 @@ void WWMouseClass::Conditional_Show_Mouse(void)

void WWMouseClass::Draw_Mouse(GraphicViewPortClass* scr)
{
#if defined(REMASTER_BUILD) || defined(SDL_BUILD)
#if defined(REMASTER_BUILD) || defined(NEW_VIDEO_BUILD)
scr;
return;
// ST - 1/3/2019 10:50AM
Expand Down Expand Up @@ -511,7 +511,7 @@ void WWMouseClass::Draw_Mouse(GraphicViewPortClass* scr)

void WWMouseClass::Erase_Mouse(GraphicViewPortClass* scr, int forced)
{
#if defined(REMASTER_BUILD) || defined(SDL_BUILD)
#if defined(REMASTER_BUILD) || defined(NEW_VIDEO_BUILD)
// ST - 1/3/2019 10:50AM
scr;
forced;
Expand Down Expand Up @@ -618,7 +618,7 @@ int WWMouseClass::Get_Mouse_Y(void)
*=============================================================================================*/
void WWMouseClass::Get_Mouse_XY(int& x, int& y)
{
#if defined(SDL_BUILD)
#ifdef NEW_VIDEO_BUILD
Get_Video_Mouse(x, y);
#elif defined(_WIN32)
POINT pt;
Expand Down Expand Up @@ -854,7 +854,7 @@ void* WWMouseClass::Set_Mouse_Cursor(int hotspotx, int hotspoty, Cursor* cursor)
result = PrevCursor;
PrevCursor = cursor;

#ifdef SDL_BUILD
#ifdef NEW_VIDEO_BUILD
Set_Video_Cursor(MouseCursor, CursorWidth, CursorHeight, MouseXHot, MouseYHot);
#endif

Expand Down
2 changes: 1 addition & 1 deletion redalert/globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ int AllDone;
** This is true if the game is the currently in focus windows app
**
*/
#ifdef SDL_BUILD
#ifdef NEW_VIDEO_BUILD
bool GameInFocus = true;
#else
bool GameInFocus = false;
Expand Down
2 changes: 1 addition & 1 deletion redalert/startup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ int main(int argc, char* argv[])
HiddenPage.Clear();
Memory_Error_Exit = Print_Error_Exit;

#ifdef SDL_BUILD
#ifdef NEW_VIDEO_BUILD
Reset_Video_Mode();
#endif

Expand Down
2 changes: 1 addition & 1 deletion tiberiandawn/startup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ int main(int argc, char** argv)

CCDebugString("C&C95 - About to exit.\n");

#if defined(SDL_BUILD)
#ifdef NEW_VIDEO_BUILD
Reset_Video_Mode();
#endif

Expand Down

0 comments on commit aede515

Please sign in to comment.