Skip to content
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

[opengl] add GLEW 2.1.0 as a submodule #768

Closed
wants to merge 13 commits into from

Conversation

archibate
Copy link
Collaborator

@archibate archibate requested a review from yuanming-hu April 13, 2020 02:38
@archibate
Copy link
Collaborator Author

archibate commented Apr 13, 2020

I found them using registry repo to do auto glew.c generation: https://github.com/nigels-com/glfixes
I.E. We need make -C auto before cmake.

@archibate archibate changed the title [opengl] add GLEW 2.2.0 as a submodule [opengl] add GLEW 2.1.0 as a submodule Apr 13, 2020
@archibate
Copy link
Collaborator Author

archibate commented Apr 13, 2020

I made a ready-for-cmake version for glew, see https://github.com/archibate/glew-ready.

It is highly recommended to build from a tgz or zip release snapshot. The code generation workflow is a complex brew of gnu make, perl and python, that works best on Linux or Mac.

So I just extract their snapshot.tgz and toggle that to be a brand-new git repo.

@archibate
Copy link
Collaborator Author

fatal error C1083: Cannot open include file: 'GL/glew.h': No such file or directory [C:\taichi\build\taichi_core.vcxproj]

Because you didn't add target_include_dirs.

@archibate
Copy link
Collaborator Author

Bad news:

In file included from /home/bate/Develop/taichi/taichi/backends/opengl/opengl_api.cpp:8:
/home/bate/Develop/taichi/external/glew-ready/include/GL/glew.h:1219:14: fatal error: 'GL/glu.h' file not found
#    include <GL/glu.h>
             ^~~~~~~~~~
1 error generated.
[3/4] Building CXX object CMakeFiles/taichi_core.dir/taichi/core/core.cpp.o
ninja: build stopped: subcommand failed.

GLEW deps GLU.

@yuanming-hu
Copy link
Member

Bad news:

In file included from /home/bate/Develop/taichi/taichi/backends/opengl/opengl_api.cpp:8:
/home/bate/Develop/taichi/external/glew-ready/include/GL/glew.h:1219:14: fatal error: 'GL/glu.h' file not found
#    include <GL/glu.h>
             ^~~~~~~~~~
1 error generated.
[3/4] Building CXX object CMakeFiles/taichi_core.dir/taichi/core/core.cpp.o
ninja: build stopped: subcommand failed.

GLEW deps GLU.

I see. Is there an option to remove this dependency? Or a more lightweight alternative to GLEW is glad (https://glad.dav1d.de/) which only generates a few portable cpp and header files. (Not sure how easy it is to replace GLEW with glad though...)

@archibate
Copy link
Collaborator Author

I still suggest to let user install glew them self... If they don't know how to install, even apt install tired them, I'll tell them NOT_TO_USE_OPENGL_BACKEND_AND_JUST_GO_FOR_CUDA_PLEASE.

@archibate
Copy link
Collaborator Author

archibate commented Apr 13, 2020

Actually I just found glad is in a deps dir of glfw...,

@yuanming-hu
Copy link
Member

Does -DGLEW_NO_GLU work for you? See nigels-com/glew#192

@archibate
Copy link
Collaborator Author

Cmake bug: not building GLEW even if I specied add_sub_directory.

@archibate
Copy link
Collaborator Author

tmr to add_sub_directory happy


message("Building with GLFW")
add_subdirectory(external/glfw)
target_link_libraries(${LIBRARY_NAME} glfw)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I find is that adding this line enforces cmake to build GLFW for libglfw3.a.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You find this enfocing on your machine? Did you install glfw in your /usr/include?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and I removed usr/lib/libglfw3.a. Maybe you can try it on your Arch machine as well.

add_subdirectory(external/glfw glfw.out)
target_include_directories(${LIBRARY_NAME} PUBLIC external/glfw/include)
target_link_directories(${LIBRARY_NAME} PUBLIC external/glfw/src)
target_link_libraries(${LIBRARY_NAME} glfw3)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On my end I find we should use glfw instead of glfw3 here. On my computer glfw3 goes to the system /usr/local/lib/libglfw3.a, but glfw indeed goes to the submodule. Not sure what the reason is.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually external/glfw generates libglfw3.a too... in external/glfw/src/libglfw3.a.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true, but for some reason using glfw seems to be fine.

@archibate
Copy link
Collaborator Author

cmake phucks me too hurt, let's give up it and say apt install glew now, it's not hard after all.

@archibate
Copy link
Collaborator Author

tbh I'm now screen 30deg tilt to make my nose happy while making cmake happy at the same time :( won't work tnt, cu tmr.

@yuanming-hu
Copy link
Member

Sounds good. Thanks for your hard work! Good night.

@yuanming-hu
Copy link
Member

I find target_link_libraries(${LIBRARY_NAME} glew_s) triggers GLEW to build, but this leads to a different problem, i.e.

[  0%] Linking C static library ../../../../lib/libGLEW.a
[ 12%] Built target glfw
/usr/bin/ar: ../../../../lib/libGLEW.a: No error
external/glew-ready/build/cmake/CMakeFiles/glew_s.dir/build.make:83: recipe for target 'lib/libGLEW.a' failed
make[3]: *** [lib/libGLEW.a] Error 1
CMakeFiles/Makefile2:200: recipe for target 'external/glew-ready/build/cmake/CMakeFiles/glew_s.dir/all' failed

Maybe their CMake script has a bug or something...

@yuanming-hu
Copy link
Member

If it's too hard to make cmake work, we have to fall back to the binary approach:

  • Ask developers to install glew in the documentation
  • Statically link libglew_s.a and glew_s_w32.lib into taichi_core, so that end-users don't have to install them.
  • CI: I'll set up GLEW on the Linux built bot - could you help with AppVeyor?

@archibate
Copy link
Collaborator Author

Statically link libglew_s.a

or ignore TIWITHOPENGL if not found.

CI: I'll set up GLEW on the Linux built bot - could you help with AppVeyor?

Yes, we'll use the package: in yml?

@archibate archibate marked this pull request as draft April 16, 2020 16:33
@yuanming-hu
Copy link
Member

Replaced by #819

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants