JoeyDeVries / LearnOpenGL

Code repository of all OpenGL chapters from the book and its accompanying website https://learnopengl.com
https://learnopengl.com
Other
10.86k stars 2.78k forks source link

macOS support is good #98

Open hyperknot opened 6 years ago

hyperknot commented 6 years ago

As of today, I've just cloned and built this on macOS 10.13.3 (Haswell Intell GPU) and most examples seems to work perfectly fine.

Building was really simple:

mkdir build
cd build
cmake ../.
make -j8

All it required was assimp, which was as simple as brew install assimp.

The linked stephane-lb/LearnOpenGL repo on the other hand doesn't even run cmake, as it's looking for X11, which it cannot find. Also that repo is 179 commits behind this one.

So I think you can say macOS is supported, with the above lines added to the readme.

I don't see any value in complicating things with Xcode projects, as this is an amazing resource to learning from / reading code, using your favourite text editor, and simply starting the examples from terminal.

hyperknot commented 6 years ago

I started going through all the examples.

Everything from chapers 1..4 is working perfectly, even the geometry shaders, except possibly 4.5.1 where the framebuffer is skewed, but it might be on purpose.

In chapter 5:

I'll report as I find other issues.

JoeyDeVries commented 6 years ago

Thank you! I've updated the readme to reflect your instructions. It's good to hear most samples work straight out of the box; I can't fix them as I don't have a Mac to test them on. Thanks for the effort so far!

hyperknot commented 6 years ago

Thanks! I think I'll just post some screenshots here as a reference, this way other developers can also possibly fix them. Or maybe the bug is very obvious just by visual design.

// note: On the Readme, you made a typo in my name and I think people will obviously need cmake, glm glfw I think. These are all quite standard libs on brew, so the full install command should be like this:

brew install cmake assimp glm glfw
mkdir build
cd build
cmake ../.
make -j8
hyperknot commented 6 years ago

OK, here is the visual report of the problematic examples. I think (just an idea) what might be the bug in all of them is that 2x Retina / HiDPI resolution is not calculated right for framebuffers.

4.5.1 framebuffer skewing: https://youtu.be/lt7rZQnur6M

5.6 hdr skewing, super slow adjustments: https://youtu.be/aktRX3FicKk

5.7 bloom (no bloom difference for on/off): https://youtu.be/pXyF65cZRpk

5.8 deferred: lower left quarter for lights mixed with full screen scene: https://youtu.be/0IKmyZrgEy4

5.9 ssao glitch: https://youtu.be/diUZ-qJFby4

5.3 shadow examples in lower left quarter of the screen

Just if anyone happens to know how to fix these.

JoeyDeVries commented 6 years ago

This is great stuff, thank you! (and apologies for the typo, it's fixed now :)). Most of them appear to be related to the retina resolution not being taken into account (including the skewing); not sure about the heavy zoom, this might suggest that the GLM version for Mac OS X is still using degrees as its default angle unit? I'll leave the ticket open, thank you!

hyperknot commented 6 years ago

glm is definitely not using degrees, or otherwise all the examples would be broken as well :-)

hyperknot commented 6 years ago

OK, I just tested, using an open source tool RDM (https://github.com/avibrazil/RDM), if you set your screen to non-Retina resolution all the above mentioned examples work perfectly.

So right now, people can run the examples in non-Retina resolution, and in the future hopefully we can implement an easy fix.

(OK, in Bloom there is an issue with the color lights, but I guess that's probably an issue on other platforms as well).

JoeyDeVries commented 6 years ago

Sweeet, that's great to know; thanks for all the effort @hyperknot !

rarest commented 6 years ago

Using CMake client(3.11.0) to generate a Xcode project, when built, the binary file was outputted into the sub bin dir added Debug or Release as parent dir, not the same dir with shader resources, the binary file wouldn't find the shader resources.

For example: resource location: .../XcodeBuild/bin/1.getting_started/3.3.shader.fs binary location: .../XcodeBuild/bin/1.getting_started/Debug/1.getting_started__3.3.shaders_class

I pushed a pull request, please check. By the way, i am not familiar with CMake, maybe there are also better resolutions.

dadidzf commented 5 years ago

MacOS generate xcode project

cmake -G "Xcode" ../.

I think if you can add another choice (tips) as above in readme file, it will be helpful for user not familiar with cmake, just like me (don't know how to generate Xcode project)

Because what the "cmake ../. " generate, every time i modify and run, i need to the bin dir, and type "./1.getting_started__2.1.hello_triangle" , to start the window. i think the Xcode is more clearly.

Thanks

chaiyujin commented 5 years ago

@hyperknot @JoeyDeVries I replace (SCR_WIDTH, SCR_HEIGHT) with (BUF_WIDTH, BUF_HEIGHT) got by glfwGetFramebufferSize(winPtr, &BUF_WIDTH, &BUF_HEIGHT ) in frame buffer related functions glTexImage2D and glRenderbufferStorage.

It works fine for 9.ssao with retina. It might be a general solution for all screens.

ssao

caochao commented 4 years ago

how to generate Xcode project? I'm not familiar with cmake

zinwalin commented 3 years ago

how to generate Xcode project? I'm not familiar with cmake

mkdir build cd build cmake -GXcode ../