From 7ab43d517791b43988645440e73be01a6096b2e1 Mon Sep 17 00:00:00 2001 From: Victor Khaustov <3192677+vi3itor@users.noreply.github.com> Date: Fri, 31 Jul 2020 14:59:36 +0900 Subject: [PATCH 1/4] Compile on MacOS To run the game, it is required to move SDL calls to the main thread. --- CMakeLists.txt | 2 +- .../audio/rendering/openal_renderer.hpp | 5 +++ .../graphics/rendering/opengl_renderer3d.cpp | 40 +++++++++++-------- 3 files changed, 30 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 64abca9..a9053cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ set (CMAKE_CXX_STANDARD 14) if(UNIX) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -Wall") # Temporarily suppress warnings during debug - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-unused-variable -Wno-sign-compare -Wno-unused-function -Wno-unused-but-set-variable -Wno-strict-aliasing") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-unused-variable -Wno-sign-compare -Wno-unused-function -Wno-strict-aliasing") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall -O3") endif(UNIX) # SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS} -fPIC -g -O3") diff --git a/src/systems/audio/rendering/openal_renderer.hpp b/src/systems/audio/rendering/openal_renderer.hpp index ff47d1e..2b05bb4 100644 --- a/src/systems/audio/rendering/openal_renderer.hpp +++ b/src/systems/audio/rendering/openal_renderer.hpp @@ -7,8 +7,13 @@ #include "interface_audiorenderer.hpp" +#ifdef __APPLE__ +#include +#include +#else #include #include +#endif namespace blunted { diff --git a/src/systems/graphics/rendering/opengl_renderer3d.cpp b/src/systems/graphics/rendering/opengl_renderer3d.cpp index 10d3d9c..a87c804 100644 --- a/src/systems/graphics/rendering/opengl_renderer3d.cpp +++ b/src/systems/graphics/rendering/opengl_renderer3d.cpp @@ -17,8 +17,14 @@ #include "opengl_renderer3d.hpp" +#ifdef __APPLE__ +#define GL_SILENCE_DEPRECATION +#include +#include +#else #include //#include // can be used to check for core profile only +#endif #include #include @@ -1307,7 +1313,7 @@ struct GLfunctions { } void OpenGLRenderer3D::RenderAABB(std::list &vertexBufferQueue) { - + /* VK: Not used. Delete it mapping.glDisable(GL_LIGHTING); mapping.glPolygonMode(GL_FRONT, GL_FILL); mapping.glColor3f(0, 1, 0); @@ -1360,11 +1366,11 @@ struct GLfunctions { } mapping.glEnd(); - + */ } void OpenGLRenderer3D::RenderAABB(std::list &lightQueue) { - + /* VK: Not used. Delete it mapping.glDisable(GL_LIGHTING); mapping.glPolygonMode(GL_FRONT, GL_FILL); mapping.glColor3f(0, 0, 1); @@ -1417,13 +1423,14 @@ struct GLfunctions { } mapping.glEnd(); + */ } // lights void OpenGLRenderer3D::SetLight(const Vector3 &position, const Vector3 &color, float radius) { - + /* VK: Not used. Delete it Vector3 pos = position; //printf("%f %f %f\n", cameraPos.coords[0], cameraPos.coords[1], cameraPos.coords[2]); @@ -1439,6 +1446,7 @@ struct GLfunctions { mapping.glLightfv(GL_LIGHT0, GL_SPECULAR, specular); mapping.glEnable(GL_LIGHT0); + */ } @@ -1556,6 +1564,18 @@ struct GLfunctions { void OpenGLRenderer3D::ResizeTexture(int textureID, SDL_Surface *source, e_InternalPixelFormat internalPixelFormat, e_PixelFormat pixelFormat, bool alpha, bool mipmaps) { BindTexture(textureID); + int x = 0; + int y = 0; + int width = source->w; + int height = source->h; + + SDL_LockSurface(source); + mapping.glTexImage2D(GL_TEXTURE_2D, 0, GetGLInternalPixelFormat(internalPixelFormat), width, height, 0, GetGLPixelFormat(pixelFormat), GL_UNSIGNED_BYTE, source->pixels); + SDL_UnlockSurface(source); + + if (mipmaps) { + mapping.glGenerateMipmap(GL_TEXTURE_2D); + } bool repeat = false; bool filter = true; @@ -1586,18 +1606,6 @@ struct GLfunctions { //mapping.glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY); } - if (mipmaps) { - mapping.glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); - } - - int x = 0; - int y = 0; - int width = source->w; - int height = source->h; - - SDL_LockSurface(source); - mapping.glTexImage2D(GL_TEXTURE_2D, 0, GetGLInternalPixelFormat(internalPixelFormat), width, height, 0, GetGLPixelFormat(pixelFormat), GL_UNSIGNED_BYTE, source->pixels); - SDL_UnlockSurface(source); //GLclampf prior = (width * height) / 1048576.0; // 1024*1024 tex = max priority //printf("%f\n", (pot(source->w) * pot(source->h)) / 1048576.0); From 8db076295d8b02365f662e0582ae68fa4c0ef9ca Mon Sep 17 00:00:00 2001 From: Victor Khaustov <3192677+vi3itor@users.noreply.github.com> Date: Fri, 6 Nov 2020 22:38:30 +0900 Subject: [PATCH 2/4] Add instructions for Windows and Mac OS --- README.md | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 95 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ed66ec5..bf38046 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ## Gameplay Football -Football game, a fork of discontinued [GameplayFootball]() written by [Bastiaan Konings Schuiling](http://www.properlydecent.com/). +Football game, a fork of discontinued [GameplayFootball](https://github.com/BazkieBumpercar/GameplayFootball) written by [Bastiaan Konings Schuiling](http://www.properlydecent.com/). -In 2019, Google Brain team picked up a game and created a Reinforcement Learning environment based on it - [Google Research Football](https://github.com/google-research/football). They made some improvements to the game, updated the libraries, but threw away everything (e.g. menus) that was not necessary for their task. +In 2019, Google Brain team picked up a game and created a Reinforcement Learning environment based on it - [Google Research Football](https://github.com/google-research/football). They made some improvements to the game, updated the libraries, but threw away everything (e.g. menus, audio effects, etc.) that was not necessary for their task. The goal of this repository is to update the existing code, based on Google Brain's changes (see `google_brain` branch) and other forks, and make it compiling and running on as many platforms as possible. PRs are always welcome. @@ -37,6 +37,99 @@ Run the game: ./gameplayfootball ``` +### MacOS (Work in Progress) +**Important**: Currently, the game can be compiled on Mac OS, but it is not running yet, because rendering must be done on the Main Thread. + +To install required dependencies you need [`brew`](https://brew.sh/) which can be installed in Terminal by running: +```bash +/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" +``` + +```bash +# Install dependencies +brew install git cmake sdl2 sdl2_image sdl2_ttf sdl2_gfx boost openal-soft +# Navigate to the directory where you want to put the repository +cd ~ +# Clone the repository +git clone https://github.com/vi3itor/GameplayFootball.git +cd GameplayFootball +# Copy the contents of `data` directory into `build` +cp -R data/. build + +# Go to `build` directory +cd build +# Generate Makefile +cmake .. +# Compile the game +make -j$(nproc) + +# Run the game (Currently is not working) +./gameplayfootball +``` + + + +### Windows (Work in Progress) + +Download and install: +- [Visual Studio 2019](https://visualstudio.microsoft.com/downloads/), +- [Git](https://git-scm.com/download/win), +- [CMake](https://cmake.org/download/) (make sure to add it to the system PATH). + +Install [`vcpkg`](https://github.com/microsoft/vcpkg) by following their [Quick Start Guide](https://github.com/microsoft/vcpkg#quick-start-windows): +create a directory, e.g. `C:\dev\vcpkg`, open Command Prompt and run the following commands: +```bat +% Navigate to the directory with vcpkg +cd C:\dev\vcpkg + +% Clone vckpg +git clone https://github.com/microsoft/vcpkg + +% Run installation script +.\vcpkg\bootstrap-vcpkg.bat +``` +Install required dependencies (all triplets **must be `x86-windows`**): +```bat +.\vcpkg.exe install --triplet x86-windows boost:x86-windows sdl2 sdl2-image[libjpeg-turbo] sdl2-ttf sdl2-gfx opengl openal-soft +``` + +```bat +% Navigate to the directory where you want to put the repository +cd C:\dev + +% Clone repository +git clone https://github.com/vi3itor/GameplayFootball.git +cd GameplayFootball + +% Switch to windows branch +git switch windows + + +% Copy the contents of `data` directory into `build\Debug` or (and) `build\Release` +xcopy /e /i data build\Debug +xcopy /e /i data build\Release +``` +Go to `build` directory and generate `cmake` files. Make sure that you correctly set the directory for `vcpkg` (in our case it is installed into `C:\dev\vcpkg`): +```bat +cd build + +cmake .. -DCMAKE_GENERATOR_PLATFORM=Win32 -DCMAKE_TOOLCHAIN_FILE=C:/dev/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE +``` +To build `Release` version: +```bat +cmake --build . --parallel --config Release +``` +For `Debug` version: +```bat +cmake --build . --parallel --config Debug +``` + +That's it! Run `gameplayfootball.exe` inside `build\Release` directory (or inside `build\Debug` for `Debug` version) + + +## Problems? +If you have any problems please open an issue. + ### Donate If you want to thank Bastiaan for his great work, consider a donation to his Bitcoin address 1JHnTe2QQj8RL281fXFiyvK9igj2VhPh2t From ffbda89ccd207647e77f4a585e25a1a768e36ca4 Mon Sep 17 00:00:00 2001 From: Victor Khaustov <3192677+vi3itor@users.noreply.github.com> Date: Fri, 6 Nov 2020 22:55:58 +0900 Subject: [PATCH 3/4] Update README --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index bf38046..4c5e498 100644 --- a/README.md +++ b/README.md @@ -76,11 +76,11 @@ Download and install: - [Git](https://git-scm.com/download/win), - [CMake](https://cmake.org/download/) (make sure to add it to the system PATH). -Install [`vcpkg`](https://github.com/microsoft/vcpkg) by following their [Quick Start Guide](https://github.com/microsoft/vcpkg#quick-start-windows): -create a directory, e.g. `C:\dev\vcpkg`, open Command Prompt and run the following commands: +Install [`vcpkg`](https://github.com/microsoft/vcpkg) as explained in [Quick Start Guide](https://github.com/microsoft/vcpkg#quick-start-windows) or simply: +create a directory, e.g. `C:\dev`, open Command Prompt and run the following commands: ```bat -% Navigate to the directory with vcpkg -cd C:\dev\vcpkg +% Navigate to the created directory +cd C:\dev % Clone vckpg git clone https://github.com/microsoft/vcpkg From 80ef59065886704aa0d144e2053132d26996e0a9 Mon Sep 17 00:00:00 2001 From: Alex Huntley Date: Wed, 21 Apr 2021 14:21:07 +0100 Subject: [PATCH 4/4] Implement SDL2 calls to get available display modes --- src/menu/settings.cpp | 43 ++++++++++--------------------------------- 1 file changed, 10 insertions(+), 33 deletions(-) diff --git a/src/menu/settings.cpp b/src/menu/settings.cpp index 1da5468..66126dd 100755 --- a/src/menu/settings.cpp +++ b/src/menu/settings.cpp @@ -1219,42 +1219,19 @@ GraphicsPage::GraphicsPage(Gui2WindowManager *windowManager, const Gui2PageData if (res.bpp == 32) if (!CheckDuplicate(resolutions, res.x, res.y)) resolutions.push_back(res); } #else - SDL_PixelFormat format; - SDL_Rect **modes; - int loops(0); - int bpp(0); - for (int loops = 0; loops < 3; loops++) { - switch(loops) { - case 0://32 bpp - format.BitsPerPixel = 32; - bpp = 32; - break; - case 1://24 bpp - format.BitsPerPixel = 24; - bpp = 24; - break; - case 2://16 bpp - format.BitsPerPixel = 16; - bpp = 16; - break; - } - - // VK: TODO: Use SDL2 calls to get available modes for the display - // - //get available fullscreen/hardware modes - //modes = SDL_ListModes(&format, SDL_FULLSCREEN); - //if (modes) { - //for(int i = 0; modes[i]; ++i) { + int display = 0; + int modes = SDL_GetNumDisplayModes(display); + for (int i = 0; i < modes; ++i) { + SDL_DisplayMode mode = { SDL_PIXELFORMAT_UNKNOWN, 0, 0, 0, 0 }; + SDL_GetDisplayMode(display, i, &mode); Resolution res; - res.x = 1280;//modes[i]->w; - res.y = 1024;//modes[i]->h; - res.bpp = 32;//bpp; + res.x = mode.w; + res.y = mode.h; + res.bpp = SDL_BITSPERPIXEL(mode.format); res.fullscreen = false; - //if (res.bpp == 32) if (!CheckDuplicate(resolutions, res.x, res.y)) + if (!CheckDuplicate(resolutions, res.x, res.y)) resolutions.push_back(res); - //} - //} - } + } #endif // add fullscreen res'es