Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] Port the vectorwar example application to Linux using libSDL2, based on PR 52 #57

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,5 @@ if(GGPO_BUILD_SDK)
endif()

if(GGPO_BUILD_VECTORWAR)
# Vector War is Windows only.
if(WIN32)
add_subdirectory(src/apps/vectorwar)
else()
message(WARNING "The Vector War app only supports Windows, skipping...")
endif()
add_subdirectory(src/apps/vectorwar)
endif()
17 changes: 17 additions & 0 deletions bin/start_vectorwar_2p.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#! /bin/env sh

# Test the vectorwar sample by starting 2 clients connected
# back to each other.
#
# Controls: Arrows to move
# Press 'D' to fire
# Press 'P' to show performance monitor
# Shift to strafe

cd ../src/apps/vectorwar/
rm *.log

./VectorWar 7000 2 local 127.0.0.1:7001 &
./VectorWar 7001 2 127.0.0.1:7000 local &

cd -
31 changes: 31 additions & 0 deletions bin/start_vectorwar_2p_4s.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#! /bin/env sh

# Test the vectorwar sample by starting 2 clients connected
# back to each other.
#
# Controls: Arrows to move
# Press 'D' to fire
# Press 'P' to show performance monitor
# Shift to strafe

cd ../src/apps/vectorwar/
rm *.log

# no spectators
#start VectorWar.exe 7000 2 local 127.0.0.1:7001
#start VectorWar.exe 7001 2 127.0.0.1:7000 local

# 1 spectator
#start VectorWar.exe 7000 2 local 127.0.0.1:7001 127.0.0.1:7005
#start VectorWar.exe 7001 2 127.0.0.1:7000 local
#start VectorWar.exe 7005 2 spectate 127.0.0.1:7000

# 4 spectators
./VectorWar 7000 2 local 127.0.0.1:7001 127.0.0.1:7005 127.0.0.1:7006 127.0.0.1:7007 127.0.0.1:7008 &
./VectorWar 7001 2 127.0.0.1:7000 local &
./VectorWar 7005 2 spectate 127.0.0.1:7000 &
./VectorWar 7006 2 spectate 127.0.0.1:7000 &
./VectorWar 7007 2 spectate 127.0.0.1:7000 &
./VectorWar 7008 2 spectate 127.0.0.1:7000 &

cd -
18 changes: 18 additions & 0 deletions bin/start_vectorwar_3p.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#! /bin/env sh

# Test the vectorwar sample by starting 2 clients connected
# back to each other.
#
# Controls: Arrows to move
# Press 'D' to fire
# Press 'P' to show performance monitor
# Shift to strafe

cd ../src/apps/vectorwar/
rm *.log

./VectorWar 7000 3 local 127.0.0.1:7001 127.0.0.1:7002 &
./VectorWar 7001 3 127.0.0.1:7000 local 127.0.0.1:7002 &
./VectorWar 7002 3 127.0.0.1:7000 127.0.0.1:7001 local &

cd -
19 changes: 19 additions & 0 deletions bin/start_vectorwar_4p.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#! /bin/env sh

# Test the vectorwar sample by starting 2 clients connected
# back to each other.
#
# Controls: Arrows to move
# Press 'D' to fire
# Press 'P' to show performance monitor
# Shift to strafe

cd ../src/apps/vectorwar/
rm *.log

./VectorWar 7000 4 local 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 &
./VectorWar 7001 4 127.0.0.1:7000 local 127.0.0.1:7002 127.0.0.1:7003 &
./VectorWar 7002 4 127.0.0.1:7000 127.0.0.1:7001 local 127.0.0.1:7003 &
./VectorWar 7003 4 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 local &

cd -
19 changes: 17 additions & 2 deletions src/CMakeSources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,24 @@ set(GGPO_LIB_SRC_NOFILTER
)

if(UNIX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

if(APPLE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdeclspec")
endif(APPLE)

set(GGPO_LIB_SRC_NOFILTER
${GGPO_LIB_SRC_NOFILTER}
"lib/ggpo/platform_unix.h"
"lib/ggpo/platform_unix.cpp"
"lib/ggpo/pevents.h"
"lib/ggpo/pevents.cpp"
)
else(WIN32)
set(GGPO_LIB_SRC_NOFILTER
${GGPO_LIB_SRC_NOFILTER}
"lib/ggpo/platform_linux.cpp"
"lib/ggpo/platform_windows.h"
"lib/ggpo/platform_windows.cpp"
)
endif()

Expand Down Expand Up @@ -71,4 +86,4 @@ set(GGPO_LIB_SRC
${GGPO_LIB_INC_BACKENDS}
${GGPO_LIB_SRC_BACKENDS}
${GGPO_PUBLIC_INC}
)
)
15 changes: 13 additions & 2 deletions src/apps/vectorwar/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,16 @@ add_common_flags(VectorWar)
# Change the character set to unicode.
add_definitions(-D_UNICODE -DUNICODE)

# Link against GGPO, winmm (Windows Multimedia API), and ws2_32 (Winsock).
target_link_libraries(VectorWar LINK_PUBLIC GGPO winmm.lib ws2_32.lib)
set_target_properties(VectorWar PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
)

# Link against GGPO, libSDL2, winmm (Windows Multimedia API), and ws2_32
# (Winsock).
if(WIN32 AND BUILD_SHARED_LIBS)
target_link_libraries(VectorWar LINK_PUBLIC GGPO SDL2 SDL2main winmm ws2_32)
else()
target_link_libraries(VectorWar LINK_PUBLIC GGPO SDL2)
endif()
19 changes: 13 additions & 6 deletions src/apps/vectorwar/CMakeSources.cmake
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
set(GGPO_EXAMPLES_VECTORWAR_INC_NOFILTER
"font.h"
"gamestate.h"
"gdi_renderer.h"
"ggpo_perfmon.h"
"sdl_renderer.h"
# "ggpo_perfmon.h"
"nongamestate.h"
"renderer.h"
"Resource.h"
"targetver.h"
"vectorwar.h"
"platform_helpers.h"
)

set(GGPO_EXAMPLES_VECTORWAR_SRC_NOFILTER
"gamestate.cpp"
"gdi_renderer.cpp"
"ggpo_perfmon.cpp"
"sdl_renderer.cpp"
# "ggpo_perfmon.cpp"
"main.cpp"
"vectorwar.cpp"
)

if(WIN32)
set(GGPO_EXAMPLES_VECTORWAR_SRC_NOFILTER ${GGPO_EXAMPLES_VECTORWAR_SRC_NOFILTER} "platform_helpers_windows.cpp")
else()
set(GGPO_EXAMPLES_VECTORWAR_SRC_NOFILTER ${GGPO_EXAMPLES_VECTORWAR_SRC_NOFILTER} "platform_helpers_unix.cpp")
endif()

set(GGPO_EXAMPLES_VECTORWAR_WIN32RES
"VectorWar.rc"
)
Expand All @@ -27,4 +34,4 @@ set(GGPO_EXAMPLES_VECTORWAR_SRC
${GGPO_EXAMPLES_VECTORWAR_INC_NOFILTER}
${GGPO_EXAMPLES_VECTORWAR_SRC_NOFILTER}
${GGPO_EXAMPLES_VECTORWAR_WIN32RES}
)
)
Loading