Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/vi3itor/GameplayFootball
Browse files Browse the repository at this point in the history
…into windows
  • Loading branch information
vi3itor committed Jun 14, 2021
2 parents 336cf43 + 80ef590 commit 7940dd4
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 67 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
104 changes: 87 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -37,28 +37,98 @@ Run the game:
./gameplayfootball
```

### Windows (In progress)
1) Install Visual Studio 2019
2) Install CMake
3) Install vcpkg
4) Install dependencies using vcpkg (all triplets must be x86-windows)
### 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
```
.\vcpkg.exe install boost:x86-windows sdl2 sdl2-image[libjpeg-turbo] sdl2-ttf sdl2-gfx opengl openal-soft



### 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) 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 created directory
cd C:\dev
% 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
```

5) :
```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
```
mkdir build
cd build
cmake .. -DCMAKE_GENERATOR_PLATFORM=Win32 -DCMAKE_TOOLCHAIN_FILE=C:/repo/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE
# For debug build
cmake --build . --parallel
# For release build:
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
```
Copy everything from `data` inside debug/release directory
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)


Run `gameplayfootball.exe`
## 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
43 changes: 10 additions & 33 deletions src/menu/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/systems/audio/rendering/openal_renderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@

#include "interface_audiorenderer.hpp"

#ifdef __APPLE__
#include <OpenAL/al.h>
#include <OpenAL/alc.h>
#else
#include <AL/al.h>
#include <AL/alc.h>
#endif

namespace blunted {

Expand Down
40 changes: 24 additions & 16 deletions src/systems/graphics/rendering/opengl_renderer3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@

#include "opengl_renderer3d.hpp"

#ifdef __APPLE__
#define GL_SILENCE_DEPRECATION
#include <OpenGL/gl3.h>
#include <OpenGL/gl3ext.h>
#else
#include <GL/gl.h>
//#include <GL/glcorearb.h> // can be used to check for core profile only
#endif

#ifdef WIN32
#include <SDL2/SDL_opengl_glext.h>
Expand Down Expand Up @@ -1311,7 +1317,7 @@ struct GLfunctions {
}

void OpenGLRenderer3D::RenderAABB(std::list<VertexBufferQueueEntry> &vertexBufferQueue) {

/* VK: Not used. Delete it
mapping.glDisable(GL_LIGHTING);
mapping.glPolygonMode(GL_FRONT, GL_FILL);
mapping.glColor3f(0, 1, 0);
Expand Down Expand Up @@ -1364,11 +1370,11 @@ struct GLfunctions {
}
mapping.glEnd();

*/
}

void OpenGLRenderer3D::RenderAABB(std::list<LightQueueEntry> &lightQueue) {

/* VK: Not used. Delete it
mapping.glDisable(GL_LIGHTING);
mapping.glPolygonMode(GL_FRONT, GL_FILL);
mapping.glColor3f(0, 0, 1);
Expand Down Expand Up @@ -1421,13 +1427,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]);
Expand All @@ -1443,6 +1450,7 @@ struct GLfunctions {
mapping.glLightfv(GL_LIGHT0, GL_SPECULAR, specular);
mapping.glEnable(GL_LIGHT0);
*/
}


Expand Down Expand Up @@ -1560,6 +1568,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;
Expand Down Expand Up @@ -1590,18 +1610,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);
Expand Down

0 comments on commit 7940dd4

Please sign in to comment.