-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support of MacOS #36
base: master
Are you sure you want to change the base?
Add support of MacOS #36
Conversation
m_internalFormat = format.first; | ||
m_dataFormat = format.second; | ||
|
||
// if (info.Multisampled) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Multisampled textures are not supported in OpenGL 4.1 explicitly, so not sure if there is an equivalent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be supported according to this documentation (btw, useful reference for available functions). Try the following code (worked for me):
glCheck(glGenTextures(1, &m_id));
glCheck(glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, m_id));
glCheck(glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 4, m_internalFormat, width, height, GL_TRUE));
glCheck(glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0));
Also don't forget to set a correct texture type in OpenGL41RenderTarget::InitAttachments -> glFramebufferTexture2D
@@ -74,7 +74,9 @@ class ComponentPool final : public IComponentPool { | |||
ComponentType& AddComponent(Entity entity, Args&&... args) | |||
{ | |||
m_entityToComponentIndex.insert({ entity, m_components.size() }); | |||
m_components.emplace_back(std::forward<Args>(args)...); | |||
ComponentType component { std::forward<Args>(args)... }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was very annoying - emplace_back here caused my compiler to spit out unreadable errors complaining about "construct_at" internal method, and according to some info online, this may be a bug in compiler itself or MacOS SDK. So had to use the old way here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved. Just remove the comment, please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I've debugged a little bit. This is now causing a "white texture" problem for the models. Because StaticMeshComponent is subscribed on the model-loaded event in the constructor pushing a copy of the created object invalidates this pointer in the event handler. I'm not sure how to fix it for now, but creating a copy is not a good idea here.
Lastly, there are few open points not really related to code:
uniform sampler2D u_Textures[32]; However my system supports only 16 of them (this was printed as a specific message from shader compiler), so I had to lower it to 16. Not sure what we should do about it.
|
This comment was marked as off-topic.
This comment was marked as off-topic.
@denyskryvytskyi I have pushed changes to CMakeLists configuration, and have successfully achieved Sandbox3D app running on Windows 10 (VS 2022), with irrklang too. During this I have also found that post-build things like copying irrklang dlls are configured in each project separately, i.e. only the Sandbox3D cmakelists are correct now. Can we somehow maybe move this to Engine build script itself, so the engine-projects will only have to copy their assets? |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
@MrOnlineCoder Here is my thoughts about different moments:
|
m_internalFormat = format.first; | ||
m_dataFormat = format.second; | ||
|
||
// if (info.Multisampled) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be supported according to this documentation (btw, useful reference for available functions). Try the following code (worked for me):
glCheck(glGenTextures(1, &m_id));
glCheck(glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, m_id));
glCheck(glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 4, m_internalFormat, width, height, GL_TRUE));
glCheck(glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0));
Also don't forget to set a correct texture type in OpenGL41RenderTarget::InitAttachments -> glFramebufferTexture2D
@@ -74,7 +74,9 @@ class ComponentPool final : public IComponentPool { | |||
ComponentType& AddComponent(Entity entity, Args&&... args) | |||
{ | |||
m_entityToComponentIndex.insert({ entity, m_components.size() }); | |||
m_components.emplace_back(std::forward<Args>(args)...); | |||
ComponentType component { std::forward<Args>(args)... }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved. Just remove the comment, please.
@denyskryvytskyi thanks for the link on multisample textures, I'll try implementing that (interesting that I didn't find that on official Khronos wiki for some reason), and will test on my Mac machine I just have two clarifications:
Thanks in advance |
|
@denyskryvytskyi I've pushed some changes:
|
@@ -74,7 +74,9 @@ class ComponentPool final : public IComponentPool { | |||
ComponentType& AddComponent(Entity entity, Args&&... args) | |||
{ | |||
m_entityToComponentIndex.insert({ entity, m_components.size() }); | |||
m_components.emplace_back(std::forward<Args>(args)...); | |||
ComponentType component { std::forward<Args>(args)... }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I've debugged a little bit. This is now causing a "white texture" problem for the models. Because StaticMeshComponent is subscribed on the model-loaded event in the constructor pushing a copy of the created object invalidates this pointer in the event handler. I'm not sure how to fix it for now, but creating a copy is not a good idea here.
glFramebufferTexture2D( | ||
GL_FRAMEBUFFER, | ||
GL_COLOR_ATTACHMENT0, | ||
GL_TEXTURE_2D, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to write m_isMultisampled ? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D,
here and set info.Multisample
. It works for me for OpenGL41 API. If it doesn't work on Mac, then I think we can skip MSAA for opengl41.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK, I have tried exactly that and didn't succeed. Although the pre-debugcallback error messages are not very descriptive (and not always documented), so maybe I missed something - I will try again, and if not, no MSAA would be available for opengl41 for now.
Thoughts about shaders: it's better to make a separate folder for older version of shaders and adapt code for that. |
I am a bit weak on newer C++ features and typing system, so I really can't help there directly. I will try researching for a way to get this compilation error fixed on MacOS (maybe by changing the build toolchain)
Would you like me to try doing that in current PR, or do you have any specific vision on the implementation itself? |
Well, I don't think shaders duplication/adaptation has any meaning out of this PR.
Anyway, both points involve C++ code adaptation, so the first one is better if It doesn't require a lot of downgrade. |
@denyskryvytskyi sorry for delay, having a very busy week, I will try to push some changes closer to the weekend |
This is a one-hell a huge PR that includes 3 features at once:
I am attaching the screenshot that it's working.
I am sorry in advance for a) big PR b) I maybe written some code or made changes that do not fit your code style and conventions, in this case please let me know what to fix.
This PR is still a WIP/draft because for example I've got the PrimitivesSandbox running, but failed to get MeshModelSandbox up.
I will leave all my questions/concerns that require some discussion from you (@denyskryvytskyi) as comments
P.S. even if this does not get merged - it was fun at least as a challenge :D