sparrowrenderer now successfully compiles with the cmake template
This commit is contained in:
parent
dbd8ba5dd0
commit
4f946d34df
@ -1,52 +1,19 @@
|
||||
project(SparrowRenderer)
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
find_package(OpenGL REQUIRED)
|
||||
# choose source file
|
||||
file(GLOB LIB_SRC_LIST src/*.cpp)
|
||||
file(GLOB LIB_HEAD_LIST src/*.h)
|
||||
|
||||
set(LIB_SRC_LIST
|
||||
src/glew.c
|
||||
src/sparrowrenderer.cpp
|
||||
src/framebuffer.cpp
|
||||
src/meshbuilder.cpp
|
||||
src/phongmaterial.cpp
|
||||
src/crappymodule.cpp
|
||||
src/shader.cpp
|
||||
src/skyboxmodule.cpp
|
||||
src/parametricmesh.cpp
|
||||
src/texture.cpp
|
||||
src/scene.cpp
|
||||
src/deferredmodule.cpp
|
||||
src/forwardmodule.cpp
|
||||
src/shadersource.cpp
|
||||
src/light.cpp
|
||||
src/posteffectmodule.cpp
|
||||
src/textureblur.cpp
|
||||
src/textureredux.cpp
|
||||
src/mesh.cpp
|
||||
)
|
||||
|
||||
set(LIBRARY_NAME ${PROJECT_NAME})
|
||||
|
||||
set(DEPENDENCIES_ROOT ${PROJECT_SOURCE_DIR}/../cpp_dependencies)
|
||||
set(INCLUDE_ROOT ${DEPENDENCIES_ROOT}/include)
|
||||
set(LIB_ROOT ${DEPENDENCIES_ROOT}/lib/${SYSTEM_LIB_PATH})
|
||||
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIB_ROOT}) #for STATIC
|
||||
#set compilation option
|
||||
set(IS_LIBRARY True)
|
||||
set(USE_OPENGL True)
|
||||
|
||||
add_definitions(-Wno-comment -DGLEW_BUILD -DGLEW_STATIC)
|
||||
if(CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||
set(CPP_DEFINES -DRENDER_DEBUG)
|
||||
add_definitions(-DRENDER_DEBUG)
|
||||
endif()
|
||||
|
||||
file(GLOB LIBRARY_RES_FILES src/*.h shaders/*.glsl)
|
||||
file(GLOB RESOURCES_FILES src/*.h shaders/*.glsl)
|
||||
|
||||
add_library(${LIBRARY_NAME} STATIC ${LIB_SRC_LIST} ${LIBRARY_RES_FILES})
|
||||
add_definitions(-std=c++11 -Wno-comment -DGLEW_BUILD -DGLEW_STATIC ${CPP_DEFINES})
|
||||
|
||||
include_directories(
|
||||
${INCLUDE_ROOT}
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
${LIBRARY_NAME}
|
||||
${OPENGL_LIBRARIES}
|
||||
)
|
||||
include(template.cmake)
|
@ -1,21 +1,18 @@
|
||||
|
||||
basic features :
|
||||
|
||||
mipmaps
|
||||
pipeline class
|
||||
configurable bloom
|
||||
instancing
|
||||
billboards
|
||||
2D rendering
|
||||
cubemap framebuffer
|
||||
point light shadows
|
||||
dynamic HDR
|
||||
deferred shading
|
||||
mipmaps
|
||||
pipeline class
|
||||
configurable bloom
|
||||
billboards
|
||||
2D rendering
|
||||
cubemap framebuffer
|
||||
point light shadows
|
||||
dynamic HDR
|
||||
deferred shading
|
||||
|
||||
advanced features :
|
||||
|
||||
water shader
|
||||
|
||||
ssao
|
||||
|
||||
mesh animation
|
||||
water shader
|
||||
ssao
|
||||
mesh animation
|
||||
|
@ -227,10 +227,10 @@ void PostEffectModule::setShaders(const std::string &luminanceFragSource,
|
||||
|
||||
glm::vec3 PostEffectModule::getObjectInfo(int x, int y)
|
||||
{
|
||||
fbo->getTexture(1)->bind(0);
|
||||
glm::vec3 *val = new glm::vec3[w*h];
|
||||
frameBuffers[INPUT_FBO].getTexture(1)->bind(0);
|
||||
glm::vec3 *val = new glm::vec3[width*height];
|
||||
glAssert(glGetTexImage(GL_TEXTURE_RECTANGLE, 0, GL_RGB, GL_FLOAT, val));
|
||||
glm::vec3 ret = val[x + (h-y)*w];
|
||||
glm::vec3 ret = val[x + (height-y)*width];
|
||||
ret.z -= 1; // clearColor compensation
|
||||
delete[] val;
|
||||
return ret;
|
||||
|
210
template.cmake
Normal file
210
template.cmake
Normal file
@ -0,0 +1,210 @@
|
||||
# Variable that you need to define to use this template
|
||||
# USE_SFML, USE_RENDERER, USE_INPUT, USE_BULLET, USE_OPENGL, USE_QT5
|
||||
#
|
||||
# Container for list of file to be compiled :
|
||||
# LIB_SRC_LIST, LIB_HEAD_LIST, EXEC_SRC_LIST, EXEC_HEAD_LIST
|
||||
#
|
||||
# If you want to specify a supplementary folder for include, use :
|
||||
# EXTRA_INCLUDE_PATHS
|
||||
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
#detect system and version
|
||||
if(WIN32)
|
||||
set(LIB_DEBUG_FOLDER "libDebug/mingw32")
|
||||
set(LIB_RELEASE_FOLDER "libRelease/mingw32")
|
||||
elseif(UNIX)
|
||||
if(${CMAKE_SYSTEM_VERSION} MATCHES "i686")
|
||||
set(LIB_DEBUG_FOLDER "libDebug/i686")
|
||||
set(LIB_RELEASE_FOLDER "libRelease/i686")
|
||||
elseif(${CMAKE_SYSTEM_VERSION} MATCHES "x86_64")
|
||||
set(LIB_DEBUG_FOLDER "libDebug/x86_64")
|
||||
set(LIB_RELEASE_FOLDER "libRelease/x86_64")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#set dependencies paths
|
||||
set(DEPENDENCIES_ROOT ${PROJECT_SOURCE_DIR}/../cpp_dependencies)
|
||||
set(INCLUDE_ROOT ${DEPENDENCIES_ROOT}/include)
|
||||
|
||||
set(LIB_DEBUG_PATH ${DEPENDENCIES_ROOT}/${LIB_DEBUG_FOLDER})
|
||||
set(LIB_RELEASE_PATH ${DEPENDENCIES_ROOT}/${LIB_RELEASE_FOLDER})
|
||||
|
||||
if(${CMAKE_BUILD_TYPE} MATCHES "Debug")
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIB_DEBUG_PATH}) #for STATIC
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIB_DEBUG_PATH}) #for SHARED
|
||||
|
||||
list(APPEND LIB_PATHS ${LIB_DEBUG_PATH})
|
||||
list(APPEND LIB_PATHS "\n" ${LIB_RELEASE_PATH})
|
||||
else()
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIB_RELEASE_PATH}) #for STATIC
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIB_RELEASE_PATH}) #for SHARED
|
||||
|
||||
list(APPEND LIB_PATHS ${LIB_RELEASE_PATH})
|
||||
endif()
|
||||
|
||||
#create library and executable
|
||||
if(LIB_SRC_LIST)
|
||||
set(IS_LIBRARY True)
|
||||
set(LIBRARY_NAME ${PROJECT_NAME})
|
||||
add_library(${LIBRARY_NAME} STATIC ${LIB_SRC_LIST} ${RESOURCES_FILES})
|
||||
if(EXEC_SRC_LIST)
|
||||
set(EXECUTABLE_NAME "test${PROJECT_NAME}")
|
||||
add_executable(${EXECUTABLE_NAME} ${EXEC_SRC_LIST} ${RESOURCES_FILES})
|
||||
endif()
|
||||
elseif(EXEC_SRC_LIST)
|
||||
set(EXECUTABLE_NAME "${PROJECT_NAME}")
|
||||
add_executable(${EXECUTABLE_NAME} ${EXEC_SRC_LIST} ${RESOURCES_FILES})
|
||||
else()
|
||||
message(WARNING "NO SOURCE FILE PROVIDED")
|
||||
endif()
|
||||
|
||||
|
||||
add_definitions(-std=c++11)
|
||||
|
||||
#find libraries
|
||||
set(LIB_DEPENDENCIES_LIST "")
|
||||
set(INCLUDE_PATHS ${INCLUDE_ROOT})
|
||||
|
||||
# not used for now
|
||||
# foreach(EXTENSION ${INCLUDE_PATHS_EXTENSION})
|
||||
# LIST(APPEND INCLUDE_PATHS ${INCLUDE_ROOT}${EXTENSION} " ")
|
||||
# endforeach()
|
||||
|
||||
# TODO: Complete SFML
|
||||
if(USE_SFML)
|
||||
find_library(SFML_LIBRARY_WINDOW
|
||||
NAMES
|
||||
sfml-window
|
||||
PATHS
|
||||
${LIB_PATHS}
|
||||
)
|
||||
|
||||
find_library(SFML_LIBRARY_SYSTEM
|
||||
NAMES
|
||||
sfml-system
|
||||
PATHS
|
||||
${LIB_PATHS}
|
||||
)
|
||||
find_library(SFML_LIBRARY_AUDIO
|
||||
NAMES
|
||||
sfml-audio
|
||||
PATHS
|
||||
${LIB_PATHS}
|
||||
)
|
||||
find_library(SFML_LIBRARY_GRAPHICS
|
||||
NAMES
|
||||
sfml-graphics
|
||||
PATHS
|
||||
${LIB_PATHS}
|
||||
)
|
||||
LIST(APPEND LIB_DEPENDENCIES_LIST ${SFML_LIBRARY_WINDOW} ${SFML_LIBRARY_SYSTEM} ${SFML_LIBRARY_AUDIO} ${SFML_LIBRARY_GRAPHICS})
|
||||
endif()
|
||||
|
||||
if(USE_RENDERER)
|
||||
find_library(SPARROW_RENDERER_LIBRARY
|
||||
NAMES
|
||||
sparrowrenderer
|
||||
PATHS
|
||||
${LIB_PATHS}
|
||||
)
|
||||
LIST(APPEND LIB_DEPENDENCIES_LIST ${SPARROW_RENDERER_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(USE_INPUT)
|
||||
find_library(SPARROW_INPUT_LIBRARY
|
||||
NAMES
|
||||
SparrowInput
|
||||
PATHS
|
||||
${LIB_PATHS}
|
||||
)
|
||||
LIST(APPEND LIB_DEPENDENCIES_LIST ${SPARROW_INPUT_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(USE_BULLET)
|
||||
find_library(BULLET_COLLISION_LIBRARY
|
||||
NAMES
|
||||
BulletCollision
|
||||
PATHS
|
||||
${LIB_PATHS}
|
||||
)
|
||||
|
||||
find_library(BULLET_DYNAMICS_LIBRARY
|
||||
NAMES
|
||||
BulletDynamics
|
||||
PATHS
|
||||
${LIB_PATHS}
|
||||
)
|
||||
|
||||
find_library(LINEAR_MATH_LIBRARY
|
||||
NAMES
|
||||
LinearMath
|
||||
PATHS
|
||||
${LIB_PATHS}
|
||||
)
|
||||
LIST(APPEND LIB_DEPENDENCIES_LIST ${BULLET_COLLISION_LIBRARY} ${BULLET_DYNAMICS_LIBRARY} ${LINEAR_MATH_LIBRARY})
|
||||
LIST(APPEND INCLUDE_PATHS "\n" ${INCLUDE_ROOT}/bullet)
|
||||
endif()
|
||||
|
||||
if(USE_OPENGL)
|
||||
find_package(OpenGL REQUIRED)
|
||||
if(OPENGL_FOUND)
|
||||
LIST(APPEND LIB_DEPENDENCIES_LIST ${OPENGL_LIBRARIES})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# TODO: Complete QT5
|
||||
if(USE_QT5)
|
||||
if(${QT_MODULE} MATCHES "core")
|
||||
|
||||
endif()
|
||||
if(${QT_MODULE} MATCHES "gui")
|
||||
|
||||
endif()
|
||||
if(${QT_MODULE} MATCHES "opengl")
|
||||
find_package(Qt5OpenGL REQUIRED)
|
||||
if(QT5OPENGL_FOUND)
|
||||
LIST(APPEND LIB_DEPENDENCIES_LIST ${Qt5OpenGL_LIBRARIES})
|
||||
add_definitions(${Qt5OpenGL_DEFINITIONS})
|
||||
LIST(APPEND INCLUDE_PATHS "\n" ${Qt5OpenGL_INCLUDES})
|
||||
endif()
|
||||
endif()
|
||||
if(${QT_MODULE} MATCHES "widgets")
|
||||
find_package(Qt5Widgets REQUIRED)
|
||||
if(QT5WIDGETS_FOUND)
|
||||
LIST(APPEND LIB_DEPENDENCIES_LIST ${Qt5Widgets_LIBRARIES})
|
||||
add_definitions(${Qt5Widgets_DEFINITIONS})
|
||||
LIST(APPEND INCLUDE_PATHS "\n" ${Qt5Widgets_INCLUDES})
|
||||
endif()
|
||||
endif()
|
||||
if(${QT_MODULE} MATCHES "network")
|
||||
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
${INCLUDE_PATHS}
|
||||
${EXTRA_INCLUDE}
|
||||
)
|
||||
|
||||
if(LIB_SRC_LIST)
|
||||
target_link_libraries(
|
||||
${LIBRARY_NAME}
|
||||
${LIB_DEPENDENCIES_LIST}
|
||||
)
|
||||
if(EXEC_SRC_LIST)
|
||||
target_link_libraries(
|
||||
${EXECUTABLE_NAME}
|
||||
${LIBRARY_NAME}
|
||||
)
|
||||
endif()
|
||||
elseif(EXEC_SRC_LIST)
|
||||
target_link_libraries(
|
||||
${EXECUTABLE_NAME}
|
||||
${LIB_DEPENDENCIES_LIST}
|
||||
)
|
||||
endif()
|
Loading…
x
Reference in New Issue
Block a user