codenamecpp / carnage3d

Reimplementation of Grand Theft Auto 1 [GTA1]
MIT License
478 stars 38 forks source link

MacOS Support #52

Open marmichalski opened 4 years ago

marmichalski commented 4 years ago

Hi,

I am working on making this work with macOS.

Would you be accepting PR's? If so, my to-do list is as follows:

carmage3d
codenamecpp commented 4 years ago

Hi! Sure, it would be great to support more operating systems :)

naymapl commented 3 years ago

Any news about macos version ??

marmichalski commented 3 years ago

Any news about macos version ??

Hi,

I haven't really found time for it. Making the source compile is quite straightforward. There is no DPI awareness though, but that might not be a problem for you, depends on your configuration. If you have any issues, I can help you either with a patch diff, if I still have the source, or guiding you a bit.

I would love to work on it again, but unfortunately I probably will not have time 😢. If it ever happens, I'll be sure to open a pull request.

marmichalski commented 2 years ago

@naymapl I have opened a PR with macOS support. To see how you can compile it, check the github workflow yaml. There is no DPI awareness, so if you're using the retina display (scaled), the game window will not be rendered on the whole surface.

naymapl commented 2 years ago

@marmichalski thanks for reply. I want to build my own version but I'm not programmer - how to build my own mac version with cmake ? I found this https://github.com/codenamecpp/carnage3d/runs/4388703194?check_suite_focus=true but have no idea how to build it on my own mac. I'm all ready on mac mini m1 12.0.1 macOS but have in home some old mac pro from 2013 and 2015 - Is it run on arm ar I need to build it on Intel machine ? Thank you for any tutorial or code to make it build. Have a nice day Marcin.

marmichalski commented 2 years ago

Hey, I will be adding the instructions to the readme soon. In short, this should be enough:

The workflow file I've mentioned is this one: https://github.com/codenamecpp/carnage3d/pull/70/files#diff-8ec8dd620a1a6790f6910af016dd60b1b41485535d15fe2ebb0265593147e57dR58

naymapl commented 2 years ago

@marmichalski - hey - thanks for reply. I try to make it build but got few errors. Few of them I sorted allready but now I have issue with build:

cmake .. -DCMAKE_RELEASE_TYPE=Release -DWITH_BOX2D=No 

-- The C compiler identification is AppleClang 13.0.0.13000029
-- The CXX compiler identification is AppleClang 13.0.0.13000029
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenAL: /Library/Developer/CommandLineTools/SDKs/MacOSX12.0.sdk/System/Library/Frameworks/OpenAL.framework
-- Found Box2D: /opt/homebrew/lib/libbox2d.a (Required is at least version "2.4.0")
-- Found OpenGL: /Library/Developer/CommandLineTools/SDKs/MacOSX12.0.sdk/System/Library/Frameworks/OpenGL.framework
-- Found GLEW: /opt/homebrew/lib/libGLEW.dylib
-- With bundled Box 2D: NO
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_RELEASE_TYPE

-- Build files have been written to: /Users/naymapl/carnage3d/build

make -j4                                                                                                                                                                                                
[  1%] Building CXX object CMakeFiles/carnage3d.dir/cmake_pch_arm64.hxx.pch
In file included from <built-in>:1:
In file included from /Users/naymapl/carnage3d/build/CMakeFiles/carnage3d.dir/cmake_pch_arm64.hxx:5:
/Users/naymapl/carnage3d/src/stdafx.h:55:10: fatal error: 'GL/gl.h' file not found
#include <GL/gl.h>
         ^~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/carnage3d.dir/cmake_pch_arm64.hxx.pch] Error 1
make[1]: *** [CMakeFiles/carnage3d.dir/all] Error 2
make: *** [all] Error 2
marmichalski commented 2 years ago

Whoops. Sorry, the parameter is CMAKE_BUILD_TYPE.

And about the error, did you checkout to (or download) the PR branch? Because this include is dfifferent when __APPLE__ is defined (https://github.com/codenamecpp/carnage3d/pull/70/files#diff-e9c682daf5243ad471bbc443ec0b31d50b68080d624259af82010df3a8c8436fR56)

naymapl commented 2 years ago

@marmichalski - maybye I'm stupid but When i clone refactore_peds_a branch got this issue:

First i clone branch

git clone --branch refactore_peds_ai https://github.com/codenamecpp/carnage3d.git

then:

cd carnage3d
mkdir build && cd build
cmake .. -DCMAKE_RELEASE_TYPE=Release -DWITH_BOX2D=No

CMake Error: The source directory "/Users/naymapl/carnage3d" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.

I try with -CMAKE_BUILD_TYPE but got error is well:

cmake .. -DCMAKE_RELEASE_TYPE=Release -DWITH_BOX2D=No -CMAKE_BUILD_TYPE                                                                                                                      

loading initial cache file MAKE_BUILD_TYPE
CMake Error: Error processing file: /Users/naymapl/carnage3d/build/MAKE_BUILD_TYPE
CMake Error: The source directory "/Users/naymapl/carnage3d" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.

For sure I make something wrong :D

marmichalski commented 2 years ago

git clone --branch refactore_peds_ai https://github.com/codenamecpp/carnage3d.git

This branch has no macOS support. Either clone my fork and checkout to osx branch, or checkout to the PR https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

codenamecpp commented 2 years ago

I didn't update refactore_peds_ai branch yet, it experimental and maybe broken right now, stick with master branch.

naymapl commented 2 years ago

Hi - I think is build well. Now i need to organize my old gta files and take a look for it. I let you know but looks like will working. Thank you so much for help and have nice day :D

Carnage3D 0.0.4
System initialize
Working directory: '/Users/naymapl/carnage3d/build/gamedata'
Cannot open config file 'config/sys_config.json'
Init MemoryManager
Frame heap memory size: 12582912
GLFW version string: 3.3.5 Cocoa NSGL EGL OSMesa dynamic
OpenGL 3.2 (Core profile)
OpenGL Vendor: Apple
OpenGL Renderer: Apple M1
OpenGL Version: 4.1 Metal - 76.1
GLSL Version: 4.10
Graphics Device caps:
 - max array texture layers: 2048
 - max texture buffer size: 268435456 bytes
Cannot read shader source from shaders/texture_color.glsl
Cannot read shader source from shaders/gui.glsl
Cannot read shader source from shaders/city_mesh.glsl
Cannot read shader source from shaders/sprites.glsl
Cannot read shader source from shaders/particle.glsl
Cannot read shader source from shaders/debug.glsl
Audio device description: Słuchawki zewnętrzne
Audio Device caps:
 - max sources mono: 0
 - max sources stereo: 0
Location of gta gamedata is not specified
Set valid gta gamedata location via sys config param 'g_gtadata'
Cannot open texts file 'ENGLISH.FXT'
Fail to load game texts for current language
Map name is not specified
Fail to start game
Cannot initialize game
System shutdown
marmichalski commented 2 years ago

Run make get_demoversion in root project directory, edit gamedata/config/sys_config.json, set g_gtadata to demoversions/GTAECTS/GTADATA

naymapl commented 2 years ago

Got error:

make get_demoversion                                                                                                                                                               

mkdir -p gamedata/demoversions
cd gamedata/demoversions
wget "https://web.archive.org/web/20200930091556/https://www.rockstargames.com/gta/demos/gtaects.zip" -O gamedata/demoversions/gtaects.zip
/bin/sh: wget: command not found
make: *** [get_demoversion] Error 127
marmichalski commented 2 years ago

brew install wget

naymapl commented 2 years ago

Thanks - I download data but still is missing "config/sys_config.json" file.

Carnage3D 0.0.4
System initialize
Working directory: '/Users/naymapl/carnage3d/gamedata/gamedata'
Cannot open config file 'config/sys_config.json'
Init MemoryManager
Frame heap memory size: 12582912
GLFW version string: 3.3.5 Cocoa NSGL EGL OSMesa dynamic
OpenGL 3.2 (Core profile)
OpenGL Vendor: Apple
OpenGL Renderer: Apple M1
OpenGL Version: 4.1 Metal - 76.1
GLSL Version: 4.10
Graphics Device caps:
 - max array texture layers: 2048
 - max texture buffer size: 268435456 bytes
Program linkage message: 'WARNING: Output of vertex shader 'FragColor' not read by fragment shader
WARNING: Output of vertex shader 'Position' not read by fragment shader
'
Render program loaded shaders/texture_color.glsl
Render program loaded shaders/gui.glsl
Render program loaded shaders/city_mesh.glsl
Program linkage message: 'WARNING: Output of vertex shader 'SpriteTextureSize' not read by fragment shader
WARNING: Output of vertex shader 'Position' not read by fragment shader
WARNING: Output of vertex shader 'SpriteTexelSize' not read by fragment shader
'
Render program loaded shaders/sprites.glsl
Render program loaded shaders/particle.glsl
Render program loaded shaders/debug.glsl
Audio device description: Słuchawki zewnętrzne
Audio Device caps:
 - max sources mono: 0
 - max sources stereo: 0
Location of gta gamedata is not specified
Set valid gta gamedata location via sys config param 'g_gtadata'
Cannot open texts file 'ENGLISH.FXT'
Fail to load game texts for current language
Map name is not specified
Fail to start game
Cannot initialize game
System shutdown
marmichalski commented 2 years ago

Yes. It's covered in README. You have to copy the template file. https://github.com/codenamecpp/carnage3d#configure

naymapl commented 2 years ago

@marmichalski thank you so much - I config everything but now got error:

Carnage3D 0.0.4
System initialize
Working directory: '/Users/naymapl/carnage3d/gamedata/carnage3d'
Init MemoryManager
Frame heap memory size: 12582912
GLFW version string: 3.3.5 Cocoa NSGL EGL OSMesa dynamic
OpenGL 3.2 (Core profile)
OpenGL Vendor: Apple
OpenGL Renderer: Apple M1
OpenGL Version: 4.1 Metal - 76.1
GLSL Version: 4.10
Graphics Device caps:
 - max array texture layers: 2048
 - max texture buffer size: 268435456 bytes
Program linkage message: 'WARNING: Output of vertex shader 'FragColor' not read by fragment shader
WARNING: Output of vertex shader 'Position' not read by fragment shader
'
Render program loaded shaders/texture_color.glsl
Render program loaded shaders/gui.glsl
Render program loaded shaders/city_mesh.glsl
Program linkage message: 'WARNING: Output of vertex shader 'SpriteTextureSize' not read by fragment shader
WARNING: Output of vertex shader 'Position' not read by fragment shader
WARNING: Output of vertex shader 'SpriteTexelSize' not read by fragment shader
'
Render program loaded shaders/sprites.glsl
Render program loaded shaders/particle.glsl
Render program loaded shaders/debug.glsl
Audio device description: Słuchawki zewnętrzne
Audio Device caps:
 - max sources mono: 0
 - max sources stereo: 0

Current gta gamedata location is: '/Users/naymapl/carnage3d/gamedata/demoversions/GTAECTS/'
libc++abi: terminating with uncaught exception of type std::__1::__fs::filesystem::filesystem_error: filesystem error: in directory_iterator::directory_iterator(...): Not a directory [/Users/naymapl/carnage3d/gamedata/carnage3d]
[1]    33583 abort      /Volumes/Macintosh\ HD/Users/naymapl/carnage3d/gamedata/carnage3d
marmichalski commented 2 years ago

Where are you running the binary (carnage3d) from? It looks like you moved it into the gamedata folder? Just run it from the build, bin or root dir. If you are already doing that, I'm not sure why it finds that strange working directory.

Also, your gamedata looks wrong. You probably should not specify an absoulte path, this is what mine spits out: Current gta gamedata location is: 'demoversions/GTAECTS/GTADATA'

codenamecpp commented 2 years ago

Yep, working directory looks odd - it should ends with 'gamedata' but there is extra 'carnage3d' for some reason

naymapl commented 2 years ago

Hi. Now everything runing but I have this same issue like with re3 gta - screen is just for 1/4 of real window:

Zrzut ekranu 2021-12-2 o 11 51 28

codenamecpp commented 2 years ago

Did you set 'r_fullscreen' to 'true' in sys_config.json ?

marmichalski commented 2 years ago

Yes. That's expected and mentioned. This is scale factor / dpi awareness issue (I think, I'm no expert :sunglasses:).

naymapl commented 2 years ago

Even I try diffrent res or full screen still this same. Any Idea how to fix this issue ?

naymapl commented 2 years ago

When I change res for 4k 3840x2160 and full screen -> then run game -> then swith alt-tab to home -> then come back to game runing in correct full screen. This working for me in re3 gta is well. Thank you for help anyway.

Will nice to finish this project - looks nice and smooth.

naymapl commented 2 years ago

Hello @codenamecpp - any new progress with the engine game ?

codenamecpp commented 2 years ago

Hi, @naymapl

Unfortunately I didn't have enough spare time to work on project and now there is war going on in my country so I don't know what will happen next...

Richard-L commented 2 years ago

Many thoughts with you 🙏

naymapl commented 2 years ago

@codenamecpp all the best for you and your family and hope so this war finish quckly.