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

Support Modern OpenGL #38

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ include(eigen)
include(ceres)
include(gtsam)
include(pangolin)
include(glad)
include(glfw)
include(utils)
#include(...)

Expand All @@ -41,7 +43,6 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)

find_package (Eigen3 3.3 REQUIRED NO_MODULE)
set(BIN_FILE solution)
set(BIN_FOLDER_PATH bin/)
set(3RDPARTY_PATH 3rdParty/)
Expand All @@ -50,7 +51,6 @@ include_directories(
include/
${CMAKE_CURRENT_SOURCE_DIR}/src
include/fast-cpp-csv-parser/
${Eigen3_INCLUDE_DIRS}
)

add_executable(${BIN_FILE}
Expand All @@ -68,5 +68,8 @@ target_link_libraries(
${CERES_LIBS}
${GTSAM_LIBS}
${SPDLOG_LIBS}
${Pangolin_LIBRARIES}
${PANGOLIN_LIBS}
OpenGL::GL
${GLFW_LIBS}
glad
)
11 changes: 11 additions & 0 deletions cmake/glad.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# GLAD

find_package(OpenGL)

add_library(glad
${CMAKE_CURRENT_SOURCE_DIR}/third_party/glad/install/include/glad/glad.h
${CMAKE_CURRENT_SOURCE_DIR}/third_party/glad/install/src/glad.c
)
include_directories(
glad PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/third_party/glad/install/include/
)
19 changes: 19 additions & 0 deletions cmake/glfw.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# GLFW

find_package(OpenGL)

find_package(glfw3 PATHS ${CMAKE_SOURCE_DIR}/third_party/glfw/install)

if (${GLFW_FOUND})
message(STATUS "Found GLFW")
add_definitions(-DGLFW_DEVELOP)

include_directories(
${GLFW_INCLUDE_DIRS}
)

set(GLFW_LIBS glfw)

else (${GLFW_FOUND})
message(STATUS "Could not support GLFW")
endif (${GLFW_FOUND})
2 changes: 2 additions & 0 deletions cmake/pangolin.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ if (${Pangolin_FOUND})
${PANGOLIN_INCLUDE_DIRS}
)

set(PANGOLIN_LIBS ${Pangolin_LIBRARIES})

else (${Pangolin_FOUND})
message(STATUS "Could not support Pangolin")
endif (${Pangolin_FOUND})
Empty file.
47 changes: 47 additions & 0 deletions scripts/third_party_clone/glad/install_glad.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import os
import multiprocessing


class install_glad:
def __init__(self, d, version_num, linux_password):
self.d = d
self.version_num = version_num
self.install_dir = "./third_party/glad"
self.pw = linux_password

def run(self):
self.pw.redeem()

# Remove any pre-installed GLAD
os.system("sudo rm -rf ./third_party/glad")

# Download GLAD source code
os.system("mkdir " + self.install_dir)
os.system("git clone https://github.com/Dav1dde/glad.git " + self.install_dir + "/glad")

# CMake configure
os.system("mkdir " + self.install_dir + "/build")
os.system("mkdir " + self.install_dir + "/install")
os.chdir(self.install_dir + "/build")

exec_string = "cmake ../glad -DCMAKE_INSTALL_PREFIX=../install"

if self.d:
exec_string += " -DCMAKE_BUILD_TYPE=Debug"

return_code = os.system(exec_string)
if return_code != 0:
print("Error occured in building GLAD!")
return

# Build
self.pw.redeem()
num_cpu_cores = multiprocessing.cpu_count()
os.system("make -j" + str(num_cpu_cores-1)) # No sudo make install here.

os.system("cp -r include ../install/include")
os.system("cp -r src ../install/src")
os.system("cp libglad.a ../install/libglad.a")

# Delete source files
os.chdir("../../../")
Empty file.
52 changes: 52 additions & 0 deletions scripts/third_party_clone/glfw/install_glfw.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import os
import multiprocessing


class install_glfw:
def __init__(self, d, version_num, linux_password):
self.d = d
self.version_num = version_num
self.install_dir = "./third_party/glfw"
self.pw = linux_password

def run(self):
self.pw.redeem()

# Install dependency - pkg-config, libxrandr-dev, libxinerama-dev, libxcursor-dev libxi-dev
os.system("sudo apt install pkg-config libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev")

# Remove any pre-installed GLFW
os.system("sudo rm -rf ./third_party/glfw")

# Download GLFW source code
os.system("mkdir " + self.install_dir)
os.system("wget -O " + self.install_dir + "/glfw.zip https://github.com/glfw/glfw/archive/refs/tags/" + self.version_num + ".zip")
os.system("unzip " + self.install_dir + "/glfw.zip -d " + self.install_dir)

# CMake configure
os.system("mkdir " + self.install_dir + "/build")
os.system("mkdir " + self.install_dir + "/install")
os.chdir(self.install_dir + "/build")

exec_string = "cmake ../glfw-" + self.version_num + " -DCMAKE_INSTALL_PREFIX=../install"

if self.d:
exec_string += " -DCMAKE_BUILD_TYPE=Debug"

return_code = os.system(exec_string)
if return_code != 0:
print("Error occured in building GLFW!")
return

# Build
self.pw.redeem()
num_cpu_cores = multiprocessing.cpu_count()
os.system("make -j" + str(num_cpu_cores-1))
self.pw.redeem()
os.system("sudo make install -j" + str(num_cpu_cores-1))

# Delete source files
os.chdir("../")
os.system("rm -rf glfw.zip")

os.chdir("../../")
15 changes: 15 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from scripts.third_party_clone.gtsam.install_gtsam import install_gtsam
from scripts.third_party_clone.pcl.install_pcl import install_pcl
from scripts.third_party_clone.pangolin.install_pangolin import install_pangolin
from scripts.third_party_clone.glfw.install_glfw import install_glfw
from scripts.third_party_clone.glad.install_glad import install_glad

class Password:
def __init__(self):
Expand Down Expand Up @@ -52,6 +54,8 @@ def __init__(self, file_path):
self.ceres = line["ceres"]
self.gtsam = line["gtsam"]
self.pangolin = line["pangolin"]
self.glfw = line["glfw"]
self.glad = line["glad"]

if key_L1 == "library-python":
self.python3 = line["python3"]
Expand Down Expand Up @@ -139,6 +143,16 @@ def main():
installer.run()
status_str += "--pangolin, "

if cfg.glad != "":
installer = install_glad(cfg.build_debug, cfg.glad, pw)
installer.run()
status_str += "--glad, "

if cfg.glfw != "":
installer = install_glfw(cfg.build_debug, cfg.glfw, pw)
installer.run()
status_str += "--glfw, "

if cfg.python3 or cfg.open3d or cfg.opencv_python:
pw.redeem()

Expand Down Expand Up @@ -170,3 +184,4 @@ def main():

if __name__ == '__main__':
main()

5 changes: 4 additions & 1 deletion setup_config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# =================================================================
# Compile options
# =================================================================
Expand All @@ -17,6 +18,8 @@ library-cpp:
ceres: "2.0.0"
gtsam: "4.0.3"
pangolin: "0.6"
glfw: "3.3.4"
glad: true

# =================================================================
# External Python Libraries
Expand All @@ -25,4 +28,4 @@ library-python:
python3: true
open3d: false
opencv-python: false
opencv-contrib-python: false
opencv-contrib-python: false
12 changes: 11 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include <iostream>
#include <pangolin/config.h>

#ifdef EIGEN_DEVELOP
#include <Eigen/Dense>
Expand Down Expand Up @@ -33,6 +32,13 @@
#include <pangolin/pangolin.h>
#endif

#ifdef GLFW_DEVELOP
#ifndef PANGOLIN_DEVELOP
#include <glad/glad.h>
#endif
#include <GLFW/glfw3.h>
#endif

int main()
{
std::cout << "Hello World!" << std::endl;
Expand Down Expand Up @@ -61,6 +67,10 @@ int main()
std::cout << "Pangolin Version: " << PANGOLIN_VERSION_STRING << std::endl;
#endif

#ifdef GLFW_DEVELOP
std::cout << "GLFW Version: " << GLFW_VERSION_MAJOR << "." << GLFW_VERSION_MINOR << "." << GLFW_VERSION_REVISION << std::endl;
#endif

#ifdef SPDLOG_DEVELOP
std::cout << "spdlog Version: " << SPDLOG_VER_MAJOR << "." << SPDLOG_VER_MINOR << "." << SPDLOG_VER_PATCH << std::endl;

Expand Down