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

Replace GLEW with glbinding #89

Merged
merged 23 commits into from
Aug 17, 2016
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
95e69ac
Replace GLEW with glbinding
9prady9 May 9, 2016
06e1ef3
Add glbinding dependency for cmake target, forge
9prady9 May 18, 2016
eea8099
Fix glbinding shared library postfix on windows platform
9prady9 May 18, 2016
3d309a6
Corrected the order of GL header inclusion for CUDA examples
9prady9 May 18, 2016
f8fdb68
Merge branch 'devel' into glew_to_glbinding
9prady9 Jul 5, 2016
4d012a8
Fix typos in macro based conditionals
9prady9 Jul 5, 2016
7c93806
Use glbinding static libs instead of shared libs
9prady9 Jul 5, 2016
33cff2b
Fix syntax errors in sdl toolkit backend for windowing system
9prady9 Jul 21, 2016
493aa67
Fix Virtual Trackball rotations for 3d objects(charts)
9prady9 Jul 27, 2016
7313c52
Update C-API documentation
9prady9 Jul 27, 2016
f07f44f
Fix data transformation equations for surface & plot
9prady9 Jul 28, 2016
6aaf3e7
Fix memory leak in Shader maintenance code
9prady9 Aug 15, 2016
4ddebdd
change glbinding cmake build script to be consistent with others
9prady9 Aug 15, 2016
e2558b1
Add warning related flags to all examples
9prady9 Aug 15, 2016
d07ae62
Move ForgeConfig files into CMakeModules
shehzan10 Aug 15, 2016
c26386d
Move all internal namespaces into global namespace forge
9prady9 Aug 15, 2016
aa92b8d
Merge branch 'devel' into glew_to_glbinding
9prady9 Aug 16, 2016
b2da6f0
fix opencl helper functions
9prady9 Aug 16, 2016
4ef9c6d
Remove dead code from font_impl object
9prady9 Aug 16, 2016
27a7c3a
fix osx specific code flow
9prady9 Aug 17, 2016
f6a578f
Explicitly set the GLFW library variables for glbinding
shehzan10 Aug 17, 2016
b24529d
Add gl.h before cuda_gl_interop.h
shehzan10 Aug 17, 2016
adb16af
Compilation fixes on OSX
shehzan10 Aug 17, 2016
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
21 changes: 3 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
PROJECT(FORGE)

SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
Expand Down Expand Up @@ -51,27 +51,12 @@ ENDIF(UNIX)

INCLUDE(${CMAKE_MODULE_PATH}/Version.cmake)

FIND_PACKAGE(OpenGL REQUIRED)
FIND_PACKAGE(GLEWmx REQUIRED)
FIND_PACKAGE(FreeImage REQUIRED)
IF(GLEWmx_FOUND AND OPENGL_FOUND AND FREEIMAGE_FOUND)
ADD_DEFINITIONS(-DGLEW_MX)
ELSE()
IF(NOT GLEWmx_FOUND)
MESSAGE(FATAL_ERROR "GLEW-MX not found")
ENDIF()
IF(NOT OPENGL_FOUND)
MESSAGE(FATAL_ERROR "OpenGL not found")
ENDIF()
IF(NOT FREEIMAGE_FOUND)
MESSAGE(FATAL_ERROR "FreeImage not found")
ENDIF()
ENDIF()
FIND_PACKAGE(OpenGL REQUIRED)

INCLUDE_DIRECTORIES(
"${PROJECT_SOURCE_DIR}/include"
${OPENGL_INCLUDE_DIR}
${GLEW_INCLUDE_DIR}
${FREEIMAGE_INCLUDE_PATH}
)

Expand Down Expand Up @@ -100,7 +85,7 @@ ENDIF(BUILD_DOCUMENTATION)
#--------------------------------------------------------------------
INCLUDE(CMakePackageConfigHelpers)

configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/ForgeConfig.cmake.in"
configure_package_config_file("${CMAKE_MODULE_PATH}/ForgeConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/ForgeConfig.cmake"
INSTALL_DESTINATION ${FG_INSTALL_CMAKE_DIR}
PATH_VARS CMAKE_INSTALL_PREFIX
Expand Down
File renamed without changes.
File renamed without changes.
55 changes: 55 additions & 0 deletions CMakeModules/build_glbinding.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
INCLUDE(ExternalProject)

SET(prefix ${CMAKE_BINARY_DIR}/third_party/glb)

SET(LIB_POSTFIX "")
IF (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
SET(LIB_POSTFIX "d")
ENDIF()

SET(glbinding_location ${prefix}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}glbinding${LIB_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX})

IF(CMAKE_VERSION VERSION_LESS 3.2)
IF(CMAKE_GENERATOR MATCHES "Ninja")
MESSAGE(WARNING "Building with Ninja has known issues with CMake older than 3.2")
endif()
SET(byproducts)
ELSE()
SET(byproducts BYPRODUCTS ${glbinding_location})
ENDIF()

IF(UNIX)
SET(CXXFLAGS "${CMAKE_CXX_FLAGS} -w -fPIC")
SET(CFLAGS "${CMAKE_C_FLAGS} -w -fPIC")
ENDIF(UNIX)

ExternalProject_Add(
glb-ext
GIT_REPOSITORY https://github.com/cginternals/glbinding.git
GIT_TAG v2.1.1
UPDATE_COMMAND ""
PREFIX "${prefix}"
INSTALL_DIR "${prefix}"
CONFIGURE_COMMAND ${CMAKE_COMMAND} -Wno-dev "-G${CMAKE_GENERATOR}" <SOURCE_DIR>
-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_FLAGS:STRING=${CXXFLAGS}
-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS:STRING=${CFLAGS}
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
-DBUILD_SHARED_LIBS:BOOL=OFF
-DOPTION_BUILD_TESTS:BOOL=OFF
Copy link
Member

@shehzan10 shehzan10 Aug 15, 2016

Choose a reason for hiding this comment

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

Use these:

+    PREFIX "${prefix}"
+    INSTALL_DIR "${prefix}"
-    -DCMAKE_INSTALL_PREFIX:STRING=${prefix}
+    -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>

${byproducts}
)

Copy link
Member

Choose a reason for hiding this comment

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

Insert:

ExternalProject_Get_Property(glb-ext install_dir)

ADD_LIBRARY(glbinding IMPORTED STATIC)

ExternalProject_Get_Property(glb-ext install_dir)

SET_TARGET_PROPERTIES(glbinding PROPERTIES IMPORTED_LOCATION ${glbinding_location})

ADD_DEPENDENCIES(glbinding glb-ext)

SET(GLBINDING_INCLUDE_DIRS ${install_dir}/include CACHE INTERNAL "" FORCE)
SET(GLBINDING_LIBRARIES ${glbinding_location} CACHE INTERNAL "" FORCE)
SET(GLBINDING_FOUND ON CACHE INTERNAL "" FORCE)
Copy link
Member

Choose a reason for hiding this comment

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

Fill the "" with comments about the variables.
Use ${install_dir} instead of ${prefix}.

11 changes: 10 additions & 1 deletion docs/pages/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ goal of Forge is to provide high performance OpenGL visualizations for C/C++
applications that use CUDA/OpenCL.

## Upstream dependencies
* [GLEW](http://glew.sourceforge.net/)
* [glbinding](https://github.com/cginternals/glbinding)
* [GLFW](http://www.glfw.org/)
* [freetype](http://www.freetype.org/)
* [FreeImage](http://freeimage.sourceforge.net/)
Copy link
Member

Choose a reason for hiding this comment

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

Is FreeImage necessary for the library or is it necessary for the demos ?

Copy link
Member Author

Choose a reason for hiding this comment

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

It is needed to save frame buffers to disks.

* On `Linux` and `OS X`, [fontconfig](http://www.freedesktop.org/wiki/Software/fontconfig/) is required.

Above dependecies are available through package managers on most of the
Expand All @@ -30,5 +31,13 @@ Currently supported alternatives:
Alternatives to GLFW which are currently under consideration are given below:
* [Qt5](https://wiki.qt.io/Qt_5)

## Example Dependencies
* CPU examples doesn't need any additional dependencies.
* CUDA Interop examples requires [CUDA toolkit](https://developer.nvidia.com/cuda-toolkit)
* OpenCL Interop examples requires OpenCL libraries.
- [AMD](http://developer.amd.com/tools-and-sdks/opencl-zone/)
- [INTEL](https://software.intel.com/en-us/intel-opencl)
- [NVIDIA](https://developer.nvidia.com/opencl)

#### Email
* Engineering: [email protected]
43 changes: 27 additions & 16 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,35 @@ MACRO(BUILD_EXAMPLE EX_NAME EX_SRC COMPUTE_NAME FG_LIBS COMPUTE_LIBS)
ENDMACRO()

IF(TARGET forge)

# Building with Forge Source
SET(FORGE_FOUND False)

ELSE(TARGET forge)

SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
FIND_PACKAGE(GLEWmx REQUIRED)
FIND_PACKAGE(FreeImage REQUIRED)
Copy link
Member

Choose a reason for hiding this comment

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

Is FreeImage required for compiling the examples too? Do we call any API directly?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ya, i noticed that too, it may not be needed i think. Will check on that.

FIND_PACKAGE(OpenGL REQUIRED)
FIND_PACKAGE(Forge REQUIRED)

SET(X11_LIBS "")
IF(APPLE)
FIND_PACKAGE(X11 REQUIRED)
INCLUDE_DIRECTORIES(${X11_INCLUDE_DIR})
ENDIF(APPLE)

INCLUDE_DIRECTORIES(
${FORGE_INCLUDE_DIRS}
${OPENGL_INCLUDE_DIR}
${GLEW_INCLUDE_DIR}
${FREEIMAGE_INCLUDE_PATH}
)
ADD_DEFINITIONS(-DGLEW_MX)

# OS Definitions
IF(UNIX)
ADD_DEFINITIONS(-Wall -std=c++11 -fvisibility=hidden)

# GCC 5.3 and above give errors for mempcy from <string.h>
# This is a (temporary) fix for that
IF("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "5.3.0")
ADD_DEFINITIONS(-D_FORCE_INLINES)
ENDIF()

# MacOS specific environment settings
IF(APPLE)
ADD_DEFINITIONS(-DOS_MAC)
SET(CMAKE_MACOSX_RPATH ON)
Expand All @@ -62,6 +68,10 @@ ELSE(TARGET forge)
IF("${isSystemDir}" STREQUAL "-1")
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}")
ENDIF("${isSystemDir}" STREQUAL "-1")

FIND_PACKAGE(X11 REQUIRED)
INCLUDE_DIRECTORIES(${X11_INCLUDE_DIR})

ELSE(APPLE)
ADD_DEFINITIONS(-DOS_LNX)
ENDIF(APPLE)
Expand All @@ -70,6 +80,10 @@ ELSE(TARGET forge)
ENDIF(UNIX)
ENDIF(TARGET forge)

IF(UNIX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations -Wno-unused-function")
Copy link
Member

Choose a reason for hiding this comment

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

You missed adding -pthread.

ENDIF()

FILE(GLOB CPU_EXAMPLE_SRC_FILES "cpu/*.cpp")
FOREACH(FILE ${CPU_EXAMPLE_SRC_FILES})
GET_FILENAME_COMPONENT(EXAMPLE ${FILE} NAME_WE)
Expand All @@ -78,10 +92,10 @@ FOREACH(FILE ${CPU_EXAMPLE_SRC_FILES})

IF(TARGET forge)
BUILD_EXAMPLE(${EXAMPLE} ${FILE} ${DIR_NAME} forge
"${FREEIMAGE_LIBRARY};${GLEWmx_LIBRARY};${OPENGL_gl_LIBRARY}")
"${FREEIMAGE_LIBRARY};${OPENGL_gl_LIBRARY}")
ELSE(TARGET forge)
BUILD_EXAMPLE(${EXAMPLE} ${FILE} ${DIR_NAME} ${FORGE_LIBRARIES}
"${FREEIMAGE_LIBRARY};${GLEWmx_LIBRARY};${OPENGL_gl_LIBRARY};${X11_LIBS};")
"${FREEIMAGE_LIBRARY};${OPENGL_gl_LIBRARY};${X11_LIBS};")
ENDIF()
ENDFOREACH()

Expand Down Expand Up @@ -116,7 +130,7 @@ IF (BUILD_EXAMPLES_CUDA)
"${FREEIMAGE_LIBRARY};${CUDA_LIBRARIES}")
ELSE(TARGET forge)
BUILD_EXAMPLE(${EXAMPLE} ${FILE} ${DIR_NAME} ${FORGE_LIBRARIES}
"${FREEIMAGE_LIBRARY};${GLEWmx_LIBRARY};${OPENGL_gl_LIBRARY};${X11_LIBS};${CUDA_LIBRARIES}")
"${FREEIMAGE_LIBRARY};${OPENGL_gl_LIBRARY};${X11_LIBS};${CUDA_LIBRARIES}")
ENDIF()
Copy link
Member

@shehzan10 shehzan10 Aug 15, 2016

Choose a reason for hiding this comment

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

I have a commit locally that moves

IF(UNIX)
             SET(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations -Wno-unused-function")
ENDIF()

to the outside of any build conditions from line ~130. This is currently under BUILD_EXAMPLES_OPENCL.

It also adds -pthread to the CMAKE_CXX_FLAGS.

I am unable to add a comment on the specific line so adding it here.

ENDFOREACH()
ELSE()
Expand All @@ -127,9 +141,6 @@ ENDIF()
IF (BUILD_EXAMPLES_OPENCL)
FIND_PACKAGE(OpenCL QUIET)
IF(OpenCL_FOUND)
IF(UNIX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations -Wno-unused-function")
ENDIF()
FILE(GLOB OpenCL_EXAMPLE_SRC_FILES "opencl/*.cpp")
INCLUDE_DIRECTORIES(
"${CMAKE_CURRENT_SOURCE_DIR}/opencl"
Expand All @@ -143,10 +154,10 @@ IF (BUILD_EXAMPLES_OPENCL)

IF(TARGET forge)
BUILD_EXAMPLE(${EXAMPLE} ${FILE} ${DIR_NAME} forge
"${FREEIMAGE_LIBRARY};${GLEWmx_LIBRARY};${OPENGL_gl_LIBRARY};${OpenCL_LIBRARIES}")
"${FREEIMAGE_LIBRARY};${OPENGL_gl_LIBRARY};${OpenCL_LIBRARIES}")
ELSE(TARGET forge)
BUILD_EXAMPLE(${EXAMPLE} ${FILE} ${DIR_NAME} ${FORGE_LIBRARIES}
"${FREEIMAGE_LIBRARY};${GLEWmx_LIBRARY};${OPENGL_gl_LIBRARY};${X11_LIBS};${OpenCL_LIBRARIES}")
"${FREEIMAGE_LIBRARY};${OPENGL_gl_LIBRARY};${X11_LIBS};${OpenCL_LIBRARIES}")
ENDIF()
ENDFOREACH()
ELSE()
Expand Down
12 changes: 6 additions & 6 deletions examples/cpu/bubblechart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,20 @@ int main(void)
/*
* First Forge call should be a window creation call
* so that necessary OpenGL context is created for any
* other fg::* object to be created successfully
* other forge::* object to be created successfully
*/
fg::Window wnd(DIMX, DIMY, "Bubble chart with Transparency Demo");
forge::Window wnd(DIMX, DIMY, "Bubble chart with Transparency Demo");
wnd.makeCurrent();

fg::Chart chart(FG_CHART_2D);
forge::Chart chart(FG_CHART_2D);
chart.setAxesLimits(FRANGE_START, FRANGE_END, -1.0f, 1.0f);

/* Create several plot objects which creates the necessary
* vertex buffer objects to hold the different plot types
*/
fg::Plot plt1 = chart.plot(cosData.size()/2, fg::f32,
forge::Plot plt1 = chart.plot(cosData.size()/2, forge::f32,
FG_PLOT_LINE, FG_MARKER_TRIANGLE); //or specify a specific plot type
fg::Plot plt2 = chart.plot(tanData.size()/2, fg::f32,
forge::Plot plt2 = chart.plot(tanData.size()/2, forge::f32,
FG_PLOT_LINE, FG_MARKER_CIRCLE); //last parameter specifies marker shape

/* Set plot colors */
Expand All @@ -94,7 +94,7 @@ int main(void)
/* set plot global marker size */
plt1.setMarkerSize(20);
/* copy your data into the opengl buffer object exposed by
* fg::Plot class and then proceed to rendering.
* forge::Plot class and then proceed to rendering.
* To help the users with copying the data from compute
* memory to display memory, Forge provides copy headers
* along with the library to help with this task
Expand Down
10 changes: 5 additions & 5 deletions examples/cpu/field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,21 @@ int main(void)
/*
* First Forge call should be a window creation call
* so that necessary OpenGL context is created for any
* other fg::* object to be created successfully
* other forge::* object to be created successfully
*/
fg::Window wnd(DIMX, DIMY, "Vector Field Demo");
forge::Window wnd(DIMX, DIMY, "Vector Field Demo");
wnd.makeCurrent();

fg::Chart chart(FG_CHART_2D);
forge::Chart chart(FG_CHART_2D);
chart.setAxesLimits(MINIMUM-1.0f, MAXIMUM, MINIMUM-1.0f, MAXIMUM);
chart.setAxesTitles("x-axis", "y-axis");

fg::Plot divPoints = chart.plot(4, fg::u32, FG_PLOT_SCATTER, FG_MARKER_CIRCLE);
forge::Plot divPoints = chart.plot(4, forge::u32, FG_PLOT_SCATTER, FG_MARKER_CIRCLE);
divPoints.setColor(0.9f, 0.9f, 0.0f, 1.f);
divPoints.setLegend("Convergence Points");
divPoints.setMarkerSize(24);

fg::VectorField field = chart.vectorField(NELEMS*NELEMS, fg::f32);
forge::VectorField field = chart.vectorField(NELEMS*NELEMS, forge::f32);
field.setColor(0.f, 0.6f, 0.3f, 1.f);

std::vector<float> points;
Expand Down
10 changes: 5 additions & 5 deletions examples/cpu/fractal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ int main(void)
/*
* First Forge call should be a window creation call
* so that necessary OpenGL context is created for any
* other fg::* object to be created successfully
* other forge::* object to be created successfully
*/
fg::Window wnd(DIMX, DIMY, "Fractal Demo");
forge::Window wnd(DIMX, DIMY, "Fractal Demo");
wnd.makeCurrent();

/* create an font object and load necessary font
Expand All @@ -45,7 +45,7 @@ int main(void)
*
* NOTE: THIS IS OPTIONAL STEP, BY DEFAULT WINDOW WILL
* HAVE FONT ALREADY SETUP*/
fg::Font fnt;
forge::Font fnt;
#ifdef OS_WIN
fnt.loadSystemFont("Calibri");
#else
Expand All @@ -56,9 +56,9 @@ int main(void)
/* Create an image object which creates the necessary
* textures and pixel buffer objects to hold the image
* */
fg::Image img(DIMX, DIMY, FG_RGBA, fg::u8);
forge::Image img(DIMX, DIMY, FG_RGBA, forge::u8);
/* copy your data into the pixel buffer object exposed by
* fg::Image class and then proceed to rendering.
* forge::Image class and then proceed to rendering.
* To help the users with copying the data from compute
* memory to display memory, Forge provides copy headers
* along with the library to help with this task
Expand Down
14 changes: 7 additions & 7 deletions examples/cpu/histogram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,19 @@ int main(void)
/*
* First Forge call should be a window creation call
* so that necessary OpenGL context is created for any
* other fg::* object to be created successfully
* other forge::* object to be created successfully
*/
fg::Window wnd(DIMX, DIMY, "Histogram Demo");
forge::Window wnd(DIMX, DIMY, "Histogram Demo");
wnd.makeCurrent();

/*
* Split the window into grid regions
*/
wnd.grid(WIN_ROWS, WIN_COLS);

fg::Image img(IMGW, IMGH, FG_RGBA, fg::u8);
forge::Image img(IMGW, IMGH, FG_RGBA, forge::u8);

fg::Chart chart(FG_CHART_2D);
forge::Chart chart(FG_CHART_2D);
/* set x axis limits to maximum and minimum values of data
* and y axis limits to range [0, number of pixels ideally]
* but practically total number of pixels as y range will skew
Expand All @@ -80,7 +80,7 @@ int main(void)
/*
* Create histogram object specifying number of bins
*/
fg::Histogram hist = chart.histogram(NBINS, fg::s32);
forge::Histogram hist = chart.histogram(NBINS, forge::s32);
/*
* Set histogram colors
*/
Expand All @@ -101,10 +101,10 @@ int main(void)

copyToGLBuffer(handles[0], (ComputeResourceHandle)bmp.ptr, img.size());

//fg::copy(img, (const void*)bmp.ptr);
//forge::copy(img, (const void*)bmp.ptr);

/* copy your data into the vertex buffer object exposed by
* fg::Histogram class and then proceed to rendering.
* forge::Histogram class and then proceed to rendering.
* To help the users with copying the data from compute
* memory to display memory, Forge provides copy headers
* along with the library to help with this task
Expand Down
Loading