carnage3d icon indicating copy to clipboard operation
carnage3d copied to clipboard

MacOS Support

Open marmichalski opened this issue 3 years ago • 29 comments

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:

  • [x] Make the source compile on mac (#70)
  • [ ] Add DPI awareness (currently hardcoded for testing purposes 😛)
  • [x] Prepare build env for mac, either with premake or cmake (#68)
carmage3d

marmichalski avatar Oct 05 '20 13:10 marmichalski

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

codenamecpp avatar Oct 05 '20 16:10 codenamecpp

Any news about macos version ??

naymapl avatar Nov 09 '21 20:11 naymapl

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 avatar Nov 09 '21 20:11 marmichalski

@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.

marmichalski avatar Dec 01 '21 23:12 marmichalski

@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.

naymapl avatar Dec 02 '21 08:12 naymapl

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

  • Setup homebrew:
    • https://brew.sh/
  • Install dependencies (and cmake):
    • brew install cmake glew glfw3 glm box2d
  • Setup and cd into build dir
    • mkdir build && cd build
  • Generate build files:
    • cmake .. -DCMAKE_BUILD_TYPE=Release -DWITH_BOX2D=No
  • Compile:
    • make -j4 (Where 4 is the threads count you want to use, you can check available with sysctl -n hw.logicalcpu)
  • Done. You should have your carnage3d binary compiled

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

marmichalski avatar Dec 02 '21 08:12 marmichalski

@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

naymapl avatar Dec 02 '21 09:12 naymapl

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)

marmichalski avatar Dec 02 '21 09:12 marmichalski

@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

naymapl avatar Dec 02 '21 09:12 naymapl

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

marmichalski avatar Dec 02 '21 09:12 marmichalski

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

codenamecpp avatar Dec 02 '21 09:12 codenamecpp

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

naymapl avatar Dec 02 '21 09:12 naymapl

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

marmichalski avatar Dec 02 '21 09:12 marmichalski

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

naymapl avatar Dec 02 '21 09:12 naymapl

brew install wget

marmichalski avatar Dec 02 '21 09:12 marmichalski

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

naymapl avatar Dec 02 '21 10:12 naymapl

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

marmichalski avatar Dec 02 '21 10:12 marmichalski

@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

naymapl avatar Dec 02 '21 10:12 naymapl

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'

marmichalski avatar Dec 02 '21 10:12 marmichalski

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

codenamecpp avatar Dec 02 '21 10:12 codenamecpp

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

naymapl avatar Dec 02 '21 10:12 naymapl

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

codenamecpp avatar Dec 02 '21 10:12 codenamecpp

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

marmichalski avatar Dec 02 '21 10:12 marmichalski

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

naymapl avatar Dec 02 '21 11:12 naymapl

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 avatar Dec 02 '21 11:12 naymapl

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

naymapl avatar Feb 27 '22 20:02 naymapl

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...

codenamecpp avatar Feb 27 '22 22:02 codenamecpp

Many thoughts with you 🙏

Richard-L avatar Feb 27 '22 22:02 Richard-L

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

naymapl avatar Feb 28 '22 21:02 naymapl