Skip to content
Snippets Groups Projects
Commit 6cbac12e authored by Ansgar Philippsen's avatar Ansgar Philippsen
Browse files

fixes to allow compilation against Mesa rendering lib instead of system GL

parent 8104b689
Branches
Tags
No related merge requests found
...@@ -33,6 +33,8 @@ option(ENABLE_GUI "whether the graphical user interface should be enabled" ...@@ -33,6 +33,8 @@ option(ENABLE_GUI "whether the graphical user interface should be enabled"
ON) ON)
option(ENABLE_GFX "whether graphics support should be enabled" option(ENABLE_GFX "whether graphics support should be enabled"
ON) ON)
option(USE_MESA "use software rendered Mesa instead of hardware GL"
OFF)
option(ENABLE_IMG "whether the image processing module should be compiled" option(ENABLE_IMG "whether the image processing module should be compiled"
ON) ON)
option(ENABLE_INFO "whether openstructure should be compiled with support for the info library" option(ENABLE_INFO "whether openstructure should be compiled with support for the info library"
...@@ -187,7 +189,13 @@ if (ENABLE_INFO) ...@@ -187,7 +189,13 @@ if (ENABLE_INFO)
endif() endif()
if (ENABLE_GFX) if (ENABLE_GFX)
find_package(OpenGL REQUIRED) if(USE_MESA)
find_package(Mesa REQUIRED)
set(_USE_MESA ON)
else()
find_package(OpenGL REQUIRED)
set(_USE_MESA OFF)
endif()
endif() endif()
if (ENABLE_IMG OR ENABLE_GFX) if (ENABLE_IMG OR ENABLE_GFX)
...@@ -283,6 +291,7 @@ message(STATUS ...@@ -283,6 +291,7 @@ message(STATUS
" Info support (-DENABLE_INFO) : ${_INFO}\n" " Info support (-DENABLE_INFO) : ${_INFO}\n"
" Graphical interface (-DENABLE_GUI) : ${_UI}\n" " Graphical interface (-DENABLE_GUI) : ${_UI}\n"
" OpenGL support (-DENABLE_GFX) : ${_OPENGL}\n" " OpenGL support (-DENABLE_GFX) : ${_OPENGL}\n"
" OpenGL via Mesa (-DUSE_MESA) : ${_USE_MESA}\n"
" Image Processing support (-DENABLE_IMG) : ${_IMG}\n" " Image Processing support (-DENABLE_IMG) : ${_IMG}\n"
" Shader support (-DUSE_SHADER) : ${_SHADER}\n" " Shader support (-DUSE_SHADER) : ${_SHADER}\n"
" Numpy support (-DUSE_NUMPY) : ${_NUMPY}\n" " Numpy support (-DUSE_NUMPY) : ${_NUMPY}\n"
......
...@@ -16,6 +16,12 @@ else() ...@@ -16,6 +16,12 @@ else()
set(shader_support 0) set(shader_support 0)
endif() endif()
if (USE_MESA)
set(mesa_support 1)
else()
set(mesa_support 0)
endif()
if (USE_NUMPY) if (USE_NUMPY)
set(numpy_support 1) set(numpy_support 1)
else() else()
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
*/ */
#define OST_SHADER_SUPPORT_ENABLED @shader_support@ #define OST_SHADER_SUPPORT_ENABLED @shader_support@
#define OST_MESA_SUPPORT_ENABLED @mesa_support@
#define OST_PROFILING_ENABLED @profiling_enabled@ #define OST_PROFILING_ENABLED @profiling_enabled@
#define OST_ANIMATIONS_ENABLED @animations_enabled@ #define OST_ANIMATIONS_ENABLED @animations_enabled@
#define OST_IMG_ENABLED @img_enabled@ #define OST_IMG_ENABLED @img_enabled@
......
...@@ -180,8 +180,13 @@ else() ...@@ -180,8 +180,13 @@ else()
endif() endif()
if (UNIX AND NOT APPLE) if (UNIX AND NOT APPLE)
list(APPEND OST_GFX_SOURCES impl/glx_offscreen_buffer.cc) if(USE_MESA)
list(APPEND OST_GFX_IMPL_HEADERS glx_offscreen_buffer.hh) list(APPEND OST_GFX_SOURCES impl/mesa_offscreen_buffer.cc)
list(APPEND OST_GFX_IMPL_HEADERS mesa_offscreen_buffer.hh)
else()
list(APPEND OST_GFX_SOURCES impl/glx_offscreen_buffer.cc)
list(APPEND OST_GFX_IMPL_HEADERS glx_offscreen_buffer.hh)
endif()
endif() endif()
if (APPLE) if (APPLE)
...@@ -200,13 +205,15 @@ if (USE_SHADER) ...@@ -200,13 +205,15 @@ if (USE_SHADER)
list(APPEND OST_GFX_SOURCES impl/scene_fx.cc) list(APPEND OST_GFX_SOURCES impl/scene_fx.cc)
list(APPEND OST_GFX_IMPL_HEADERS scene_fx.hh) list(APPEND OST_GFX_IMPL_HEADERS scene_fx.hh)
if (NOT APPLE) if (NOT APPLE)
set(OST_GLEW_HEADERS if (NOT USE_MESA)
glew.h set(OST_GLEW_HEADERS
glxew.h glew.h
wglew.h IN_DIR GL glxew.h
) wglew.h IN_DIR GL
list(APPEND OST_GFX_SOURCES GL/glew.c) )
include_directories("${STAGE_DIR}/include/ost/gfx") list(APPEND OST_GFX_SOURCES GL/glew.c)
include_directories("${STAGE_DIR}/include/ost/gfx")
endif()
endif() endif()
endif() endif()
...@@ -226,6 +233,9 @@ module(NAME gfx SOURCES ${OST_GFX_SOURCES} ${OST_GFX_MAP_SOURCES} ...@@ -226,6 +233,9 @@ module(NAME gfx SOURCES ${OST_GFX_SOURCES} ${OST_GFX_MAP_SOURCES}
include_directories(${PNG_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR}) include_directories(${PNG_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR})
# link against OpenGL and PNG libraries # link against OpenGL and PNG libraries
if(USE_MESA)
link_directories(${OPENGL_LIBRARY_DIR})
endif()
target_link_libraries(ost_gfx ${OPENGL_LIBRARIES} ${PNG_LIBRARIES}) target_link_libraries(ost_gfx ${OPENGL_LIBRARIES} ${PNG_LIBRARIES})
if (USE_SHADER) if (USE_SHADER)
......
...@@ -29,6 +29,12 @@ ...@@ -29,6 +29,12 @@
#include <ost/config.hh> #include <ost/config.hh>
#if OST_SHADER_SUPPORT_ENABLED #if OST_SHADER_SUPPORT_ENABLED
#ifdef OST_MESA_SUPPORT_ENABLED
# define OST_GL_VERSION_2_0 1
# define GL_GLEXT_PROTOTYPES 1
# include <GL/gl.h>
# include <GL/glext.h>
#else
# if OST_MODULE==OST_GFX # if OST_MODULE==OST_GFX
# define GLEW_BUILD # define GLEW_BUILD
# endif # endif
...@@ -39,6 +45,7 @@ ...@@ -39,6 +45,7 @@
# include <ost/gfx/GL/wglew.h> # include <ost/gfx/GL/wglew.h>
# endif # endif
#endif #endif
#endif
#include <ost/gfx/gl_include.hh> #include <ost/gfx/gl_include.hh>
...@@ -53,3 +60,4 @@ ...@@ -53,3 +60,4 @@
#endif #endif
#endif #endif
#endif #endif
...@@ -59,7 +59,11 @@ public: ...@@ -59,7 +59,11 @@ public:
*/ */
#if defined(__linux__) #if defined(__linux__)
#if OST_MESA_SUPPORT_ENABLED
#include "impl/mesa_offscreen_buffer.hh"
#else
#include "impl/glx_offscreen_buffer.hh" #include "impl/glx_offscreen_buffer.hh"
#endif
#elif defined(__APPLE__) #elif defined(__APPLE__)
#include "impl/cgl_offscreen_buffer.hh" #include "impl/cgl_offscreen_buffer.hh"
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
......
...@@ -59,12 +59,14 @@ Shader::Shader(): ...@@ -59,12 +59,14 @@ Shader::Shader():
void Shader::PreGLInit() void Shader::PreGLInit()
{ {
#if !defined(__APPLE__) #if !defined(__APPLE__)
#if !defined(OST_MESA_SUPPORT_ENABLED)
GLenum err = glewInit(); GLenum err = glewInit();
if (GLEW_OK != err) { if (GLEW_OK != err) {
LOG_ERROR("glew failure: " << glewGetErrorString(err)); LOG_ERROR("glew failure: " << glewGetErrorString(err));
assert(false); assert(false);
} }
#endif #endif
#endif
} }
bool Shader::Compile(std::string shader_name, std::string shader_code, bool Shader::Compile(std::string shader_name, std::string shader_code,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment