Import of '003-basic-texturing'.
This commit is contained in:
parent
a576e82689
commit
6c712579d8
13
CMakeLists.txt
Normal file
13
CMakeLists.txt
Normal file
@ -0,0 +1,13 @@
|
||||
CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
|
||||
|
||||
# project/binary name:
|
||||
PROJECT(basic-texturing)
|
||||
|
||||
# ACGL setup
|
||||
SET(ACGL_OPENGL_SUPPORT CORE_32)
|
||||
ADD_DEFINITIONS(-DACGL_OPENGL_VERSION_32)
|
||||
ADD_DEFINITIONS(-DACGL_OPENGL_PROFILE_CORE)
|
||||
# create the newest availabe OpenGL context, independent of the ACGL version:
|
||||
#ADD_DEFINITIONS(-DGLFW_OPENGL_LATEST_VERSION)
|
||||
|
||||
INCLUDE(${CMAKE_SOURCE_DIR}/../shared/SharedCMakeLists.txt)
|
208354
Geometry/Bunny.ab
Normal file
208354
Geometry/Bunny.ab
Normal file
File diff suppressed because it is too large
Load Diff
347475
Geometry/Bunny.obj
Normal file
347475
Geometry/Bunny.obj
Normal file
File diff suppressed because it is too large
Load Diff
104285
Geometry/BunnyColors.atb
Normal file
104285
Geometry/BunnyColors.atb
Normal file
File diff suppressed because it is too large
Load Diff
8
Geometry/Quad.ab
Normal file
8
Geometry/Quad.ab
Normal file
@ -0,0 +1,8 @@
|
||||
6
|
||||
-1.0 -1.0 0.0 0.0 0.0 1.0 0.0 0.0
|
||||
1.0 -1.0 0.0 0.0 0.0 1.0 1.0 0.0
|
||||
1.0 1.0 0.0 0.0 0.0 1.0 1.0 1.0
|
||||
-1.0 -1.0 0.0 0.0 0.0 1.0 0.0 0.0
|
||||
1.0 1.0 0.0 0.0 0.0 1.0 1.0 1.0
|
||||
-1.0 1.0 0.0 0.0 0.0 1.0 0.0 1.0
|
||||
|
BIN
Geometry/clownfishBunny.png
Normal file
BIN
Geometry/clownfishBunny.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 166 KiB |
3145731
Geometry/clownfishBunny.ppm
Normal file
3145731
Geometry/clownfishBunny.ppm
Normal file
File diff suppressed because it is too large
Load Diff
16
Shader/HelloWorld.fsh
Normal file
16
Shader/HelloWorld.fsh
Normal file
@ -0,0 +1,16 @@
|
||||
#version 150
|
||||
|
||||
in vec3 vNormal;
|
||||
in vec2 vTexCoord;
|
||||
|
||||
out vec4 oColor;
|
||||
|
||||
uniform sampler2D uTexture;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 color = texture(uTexture, vTexCoord).rgb;
|
||||
color *= dot(normalize(vNormal),vec3(0,0,1));
|
||||
|
||||
oColor = vec4( color, 1.0 );
|
||||
}
|
18
Shader/HelloWorld.vsh
Normal file
18
Shader/HelloWorld.vsh
Normal file
@ -0,0 +1,18 @@
|
||||
#version 150
|
||||
|
||||
uniform mat4 uViewMatrix;
|
||||
uniform mat4 uProjectionMatrix;
|
||||
|
||||
in vec3 aNormal;
|
||||
in vec3 aPosition;
|
||||
in vec2 aTexCoord;
|
||||
|
||||
out vec3 vNormal;
|
||||
out vec2 vTexCoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
vNormal = inverse(transpose(mat3(uViewMatrix))) * aNormal;
|
||||
vTexCoord = aTexCoord;
|
||||
gl_Position = uProjectionMatrix * uViewMatrix * vec4(aPosition, 1.0);
|
||||
}
|
109
SharedCMakeLists.txt
Normal file
109
SharedCMakeLists.txt
Normal file
@ -0,0 +1,109 @@
|
||||
#
|
||||
# Included in all examples.
|
||||
#
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Compiler settings, can be simpler if only one compiler should be used.
|
||||
#
|
||||
|
||||
#Enable c++11
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
#on clang we need to find out the version to set stdlib if needed
|
||||
# if clang version is less than 3.3 ( XCode 5.0) you need to set the stdlib
|
||||
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
||||
MESSAGE("Clangversion ${CLANG_VERSION_STRING}")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||
# using Visual Studio C++
|
||||
endif()
|
||||
|
||||
# enable warnings
|
||||
IF(MSVC)
|
||||
# for msvc also set multiple processors
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /W3")
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP /W3")
|
||||
ELSE(MSVC)
|
||||
ADD_DEFINITIONS(-Wall)
|
||||
ENDIF(MSVC)
|
||||
ADD_DEFINITIONS(-DNO_SPACE_NAVIGATOR_SUPPORT)
|
||||
|
||||
#
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Settings for the app.
|
||||
#
|
||||
#
|
||||
# Lets the binary get written to a shared folder (which can be ignored by git).
|
||||
# Will also set the run directory for QTCreator:
|
||||
set(dir ${CMAKE_CURRENT_SOURCE_DIR}/../binaries)
|
||||
set(EXECUTABLE_OUTPUT_PATH ${dir} CACHE PATH "Build directory" FORCE)
|
||||
|
||||
# source and header files
|
||||
FILE(GLOB_RECURSE SOURCE_FILES_SHARED "../shared/*.cc")
|
||||
FILE(GLOB_RECURSE SOURCE_FILES "${CMAKE_SOURCE_DIR}/*.cc")
|
||||
SET(SOURCE_FILES ${SOURCE_FILES} ${SOURCE_FILES_SHARED})
|
||||
|
||||
FILE(GLOB_RECURSE HEADER_FILES_SHARED "../shared/*.hh")
|
||||
FILE(GLOB_RECURSE HEADER_FILES "${CMAKE_SOURCE_DIR}/*.hh")
|
||||
SET(HEADER_FILES ${HEADER_FILES} ${HEADER_FILES_SHARED})
|
||||
|
||||
# shader files
|
||||
FILE(GLOB_RECURSE SHADER_FILES "${CMAKE_SOURCE_DIR}/Shader/*.*")
|
||||
|
||||
# Readme
|
||||
FILE(GLOB_RECURSE README_FILES "${CMAKE_SOURCE_DIR}/../README.TXT")
|
||||
#
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# all we need for ACGL:
|
||||
#
|
||||
ADD_DEFINITIONS(-DACGL_ERROR_LEVEL_EC3)
|
||||
INCLUDE(${CMAKE_SOURCE_DIR}/../extern/acgl/CMakeListsStaticInclude.txt)
|
||||
#
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# GLFW (and some other linker flags)
|
||||
#
|
||||
|
||||
FILE(GLOB_RECURSE HEADER_FILES_GLFW "${CMAKE_SOURCE_DIR}/../extern/glfw/include/*.h")
|
||||
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/../extern/glfw/include)
|
||||
SET(HEADER_FILES ${HEADER_FILES} ${HEADER_FILES_GLFW})
|
||||
|
||||
add_subdirectory(../extern/glfw ${CMAKE_SOURCE_DIR}/../extern/glfw)
|
||||
SET(LIBRARIES glfw ${GLFW_LIBRARIES})
|
||||
|
||||
|
||||
#
|
||||
# MacOS X:
|
||||
#
|
||||
IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
SET(LIBRARIES ${LIBRARIES} -Wl,-framework,Cocoa -Wl,-framework,OpenGL,-framework,IOKit)
|
||||
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
|
||||
#
|
||||
# Linux:
|
||||
#
|
||||
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
SET(LIBRARIES ${LIBRARIES} -lXrandr -lGL -lXi -pthread -lm -lX11 -lXxf86vm)
|
||||
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
#
|
||||
#
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
ADD_EXECUTABLE(${CMAKE_PROJECT_NAME} ${SOURCE_FILES} ${HEADER_FILES} ${SHADER_FILES} ${README_FILES})
|
||||
TARGET_LINK_LIBRARIES(${CMAKE_PROJECT_NAME} ${LIBRARIES})
|
81
basic-texturing.cc
Normal file
81
basic-texturing.cc
Normal file
@ -0,0 +1,81 @@
|
||||
#include "../shared/main.hh"
|
||||
|
||||
#include <ACGL/OpenGL/Creator/ShaderProgramCreator.hh>
|
||||
#include <ACGL/OpenGL/Creator/VertexArrayObjectCreator.hh>
|
||||
#include <ACGL/OpenGL/Creator/Texture2DCreator.hh>
|
||||
#include <ACGL/OpenGL/Objects.hh>
|
||||
#include <ACGL/Base/Settings.hh>
|
||||
#include <ACGL/Math/Math.hh>
|
||||
#include <ACGL/OpenGL/Data/TextureLoadStore.hh>
|
||||
#include <ACGL/OpenGL/Managers.hh>
|
||||
|
||||
using namespace std;
|
||||
using namespace ACGL::OpenGL;
|
||||
using namespace ACGL::Base;
|
||||
using namespace ACGL::Utils;
|
||||
|
||||
SharedVertexArrayObject vaoBunny;
|
||||
SharedShaderProgram normalsAsColorShader;
|
||||
SharedTexture2D bunnyTexture;
|
||||
|
||||
// gets called after the OpenGL window is prepared:
|
||||
void initCustomResources()
|
||||
{
|
||||
// define where shaders and textures can be found:
|
||||
Settings::the()->setResourcePath("../");
|
||||
Settings::the()->setShaderPath("003-basic-texturing/Shader/");
|
||||
Settings::the()->setTexturePath("shared/Geometry/");
|
||||
Settings::the()->setGeometryPath("shared/Geometry/");
|
||||
|
||||
// load the geometry of the stanford bunny and build a VAO:
|
||||
vaoBunny = VertexArrayObjectCreator("Bunny.obj").create();
|
||||
vaoBunny->bind();
|
||||
|
||||
// load a texture:
|
||||
bunnyTexture = Texture2DFileManager::the()->get( Texture2DCreator("clownfishBunny.png"));
|
||||
// alternatively, without the Managers:
|
||||
//bunnyTexture = loadTexture2D( "../shared/Geometry/clownfishBunny.png" );
|
||||
|
||||
// look up all shader files starting with 'HelloWorld' and build a ShaderProgram from it:
|
||||
normalsAsColorShader = ShaderProgramCreator("HelloWorld").attributeLocations( vaoBunny->getAttributeLocations() ).create();
|
||||
normalsAsColorShader->use();
|
||||
|
||||
// set texture uniform and bind texture to the same texture unit:
|
||||
normalsAsColorShader->setTexture( "uTexture", bunnyTexture, 0 );
|
||||
|
||||
// just in case: check for errors
|
||||
openGLCriticalError();
|
||||
}
|
||||
|
||||
void deleteCustomResources()
|
||||
{
|
||||
// we have memory management via reference counting, so nothing to do here
|
||||
}
|
||||
|
||||
void draw( float runTime )
|
||||
{
|
||||
// reload textures every 100 frames:
|
||||
static int frame = 0;
|
||||
frame++;
|
||||
if (frame % 100 == 0) {
|
||||
Texture2DFileManager::the()->updateAll();
|
||||
}
|
||||
|
||||
// clear the framebuffer:
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
// set view and projection matrix:
|
||||
glm::mat4 viewMatrix = glm::translate(glm::vec3(0.0f, -1.0f, -2.0f)) * glm::rotate<float>(1.0472f * runTime, glm::vec3(0.0f, 1.0f, 0.0f)) * glm::scale<float>(glm::vec3(0.25f));
|
||||
normalsAsColorShader->setUniform( "uViewMatrix", viewMatrix );
|
||||
normalsAsColorShader->setUniform( "uProjectionMatrix", buildFrustum(75.0, 0.1, 100.0, (float)g_windowSize.x/(float)g_windowSize.y) );
|
||||
|
||||
// render the bunny:
|
||||
vaoBunny->render();
|
||||
}
|
||||
|
||||
void resizeCallback( GLFWwindow *, int newWidth, int newHeight )
|
||||
{
|
||||
// store the new window size and adjust the viewport:
|
||||
g_windowSize = glm::uvec2( newWidth, newHeight);
|
||||
glViewport( 0, 0, g_windowSize.x, g_windowSize.y );
|
||||
}
|
43
extern/acgl/.gitignore
vendored
Normal file
43
extern/acgl/.gitignore
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
#
|
||||
# files and filetypes that should get ignored by git should get added here
|
||||
#
|
||||
|
||||
#
|
||||
# libraries:
|
||||
#
|
||||
lib/*
|
||||
|
||||
#
|
||||
# binaries:
|
||||
# (add project specific filenames here)
|
||||
#
|
||||
|
||||
#
|
||||
# IDE files:
|
||||
# QT creator:
|
||||
#
|
||||
*.user
|
||||
|
||||
#
|
||||
# build files
|
||||
#
|
||||
build/*
|
||||
*.o
|
||||
|
||||
#
|
||||
# temp cmake files:
|
||||
#
|
||||
cmake_install.cmake
|
||||
CMakeCache.txt
|
||||
CMakeFiles
|
||||
Makefile
|
||||
*.cbp
|
||||
|
||||
#
|
||||
# OS specific temp files:
|
||||
#
|
||||
*~
|
||||
.directory
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
3
extern/acgl/.gitmodules
vendored
Normal file
3
extern/acgl/.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "cmake"]
|
||||
path = cmake
|
||||
url = ../../cmake/
|
100
extern/acgl/CMakeLists.txt
vendored
Normal file
100
extern/acgl/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,100 @@
|
||||
#
|
||||
# Use this to compile ACGL as a library. To include it statically compiled into
|
||||
# your own project you can also just include the CMakeListsStaticInclude.txt:
|
||||
# INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/CMakeListsStaticInclude.txt)
|
||||
#
|
||||
CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
|
||||
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/CMakeMacros.txt)
|
||||
|
||||
################################################################################
|
||||
# Global Settings
|
||||
################################################################################
|
||||
|
||||
# Name of the Project
|
||||
PROJECT(ACGL)
|
||||
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/CompileOptions.txt)
|
||||
|
||||
# Specify dependencies
|
||||
SET(NEED_ACGL_GLOBAL_EXTERN_DIR TRUE)
|
||||
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/GlobalAndLocalExternACGL.txt)
|
||||
|
||||
# OpenGL Support
|
||||
IF(NOT DEFINED ACGL_OPENGL_SUPPORT)
|
||||
SET(ACGL_OPENGL_SUPPORT CORE_42 CACHE STRING "")
|
||||
SET_PROPERTY(CACHE ACGL_OPENGL_SUPPORT PROPERTY STRINGS CORE_32 CORE_33 CORE_40 CORE_41 CORE_42 CORE_43 CORE_42 FULL_21 FULL_30 FULL_31 FULL_32 FULL_33 FULL_40 FULL_41 FULL_42 FULL_43 ES_20)
|
||||
ENDIF()
|
||||
|
||||
# Error Level
|
||||
IF(NOT DEFINED ACGL_ERROR_LEVEL)
|
||||
SET(ACGL_ERROR_LEVEL EC0 CACHE STRING "")
|
||||
SET_PROPERTY(CACHE ACGL_ERROR_LEVEL PROPERTY STRINGS EC0 EC1 EC2 EC3)
|
||||
ENDIF()
|
||||
|
||||
# UseQT
|
||||
IF(NOT DEFINED ACGL_COMPILE_WITH_QT)
|
||||
SET(ACGL_COMPILE_WITH_QT Yes CACHE STRING "")
|
||||
SET_PROPERTY(CACHE ACGL_COMPILE_WITH_QT PROPERTY STRINGS Yes No)
|
||||
ENDIF()
|
||||
|
||||
################################################################################
|
||||
# Basic Configuration
|
||||
################################################################################
|
||||
|
||||
# Where to find the cmake finders?
|
||||
SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
|
||||
|
||||
# Target directory
|
||||
SET(LIBRARY_OUTPUT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/lib")
|
||||
|
||||
################################################################################
|
||||
# Project Files
|
||||
################################################################################
|
||||
|
||||
#
|
||||
# if ACGL should not get compiled as a library, just include the following file
|
||||
# into the projects CMakeList.txt
|
||||
#
|
||||
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/CMakeListsStaticInclude.txt)
|
||||
|
||||
################################################################################
|
||||
# Defines
|
||||
################################################################################
|
||||
|
||||
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DefinesACGL.txt)
|
||||
ADD_DEFINITIONS(${ACGL_DEFINES})
|
||||
|
||||
################################################################################
|
||||
# External Libraries
|
||||
################################################################################
|
||||
|
||||
# Qt
|
||||
IF(ACGL_COMPILE_WITH_QT)
|
||||
#MESSAGE("QT")
|
||||
SET(QT_USE_QTOPENGL TRUE)
|
||||
FIND_PACKAGE(Qt4 REQUIRED)
|
||||
INCLUDE(${QT_USE_FILE})
|
||||
SET(LIBRARIES ${LIBRARIES} ${QT_LIBRARIES})
|
||||
ENDIF()
|
||||
|
||||
# static linking for MSVC
|
||||
IF(ACGL_STATIC_RUNTIME_ENV)
|
||||
if(MSVC)
|
||||
foreach(flag
|
||||
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
||||
if(${flag} MATCHES "/MD")
|
||||
string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
ENDIF()
|
||||
|
||||
################################################################################
|
||||
# Final Definition
|
||||
################################################################################
|
||||
|
||||
# Define the Project, add all required sources and dependencies to it
|
||||
ADD_LIBRARY(ACGL${COMPILE_POSTFIX} STATIC ${SOURCE_FILES} ${HEADER_FILES})
|
||||
TARGET_LINK_LIBRARIES(ACGL${COMPILE_POSTFIX} ${LIBRARIES})
|
||||
#MESSAGE(${LIBRARY_NAME})
|
58
extern/acgl/CMakeListsStaticInclude.txt
vendored
Normal file
58
extern/acgl/CMakeListsStaticInclude.txt
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
#
|
||||
# To build ACGL as a library, use the CMakeLists.txt
|
||||
# To build it statically into a project just include this file,
|
||||
# e.g.: INCLUDE(${CMAKE_SOURCE_DIR}/extern/acgl/CMakeListsStaticInclude.txt)
|
||||
#
|
||||
|
||||
################################################################################
|
||||
# Macro to sort acgl into directories
|
||||
################################################################################
|
||||
|
||||
MACRO (RECURSE_GROUPS dirname)
|
||||
FILE(GLOB_RECURSE allfiles "${dirname}/*.*")
|
||||
SET(ALL_FILES ${ALL_FILES} ${allfiles})
|
||||
STRING(REGEX REPLACE ".*/([^/]*)" "\\1" maindir "${dirname}")
|
||||
|
||||
FOREACH(file ${allfiles})
|
||||
STRING(REGEX REPLACE "${dirname}/(.*)/[^/]*" "\\1" loopdirname "${file}")
|
||||
STRING(REGEX REPLACE "/" "\\\\" loopdirname "${loopdirname}")
|
||||
|
||||
IF(NOT "${file}" MATCHES "${dirname}/(.*)/[^/]*")
|
||||
source_group("${maindir}" FILES ${file})
|
||||
ELSE()
|
||||
source_group("${maindir}\\${loopdirname}" FILES ${file})
|
||||
ENDIF()
|
||||
ENDFOREACH()
|
||||
ENDMACRO (RECURSE_GROUPS)
|
||||
|
||||
SET(ACGL_BASE_DIR "${CMAKE_CURRENT_LIST_DIR}")
|
||||
# Find all used files of certain file-types
|
||||
FILE(GLOB_RECURSE SOURCE_FILES_C "${ACGL_BASE_DIR}/src/*.c")
|
||||
FILE(GLOB_RECURSE SOURCE_FILES_CC "${ACGL_BASE_DIR}/src/*.cc")
|
||||
FILE(GLOB_RECURSE SOURCE_FILES_CPP "${ACGL_BASE_DIR}/src/*.cpp")
|
||||
FILE(GLOB_RECURSE HEADER_FILES_H "${ACGL_BASE_DIR}/include/*.h")
|
||||
FILE(GLOB_RECURSE HEADER_FILES_HH "${ACGL_BASE_DIR}/include/*.hh")
|
||||
FILE(GLOB_RECURSE HEADER_FILES_HPP "${ACGL_BASE_DIR}/include/*.hpp")
|
||||
#group files in msvc
|
||||
RECURSE_GROUPS ("${ACGL_BASE_DIR}/include")
|
||||
RECURSE_GROUPS ("${ACGL_BASE_DIR}/src")
|
||||
|
||||
SET(HEADER_FILES ${HEADER_FILES} ${HEADER_FILES_H} ${HEADER_FILES_HH} ${HEADER_FILES_HPP})
|
||||
SET(SOURCE_FILES ${SOURCE_FILES} ${SOURCE_FILES_C} ${SOURCE_FILES_CC} ${SOURCE_FILES_CPP})
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_LIST_DIR}/include)
|
||||
|
||||
# set debug build with: cmake -DCMAKE_BUILD_TYPE=Debug ...
|
||||
IF(CMAKE_BUILD_TYPE MATCHES Debug)
|
||||
ADD_DEFINITIONS(-DDEBUG)
|
||||
ENDIF(CMAKE_BUILD_TYPE MATCHES Debug)
|
||||
IF(CMAKE_BUILD_TYPE MATCHES debug)
|
||||
ADD_DEFINITIONS(-DDEBUG)
|
||||
ENDIF(CMAKE_BUILD_TYPE MATCHES debug)
|
||||
IF(CMAKE_BUILD_TYPE MATCHES DEBUG)
|
||||
ADD_DEFINITIONS(-DDEBUG)
|
||||
ENDIF(CMAKE_BUILD_TYPE MATCHES DEBUG)
|
||||
|
||||
IF(WIN32)
|
||||
ADD_DEFINITIONS(-DWIN32)
|
||||
ENDIF(WIN32)
|
13
extern/acgl/LICENSE.TXT
vendored
Normal file
13
extern/acgl/LICENSE.TXT
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
ACGL is distributed under the terms of the MIT license stated below.
|
||||
(See README.TXT for further information.)
|
||||
--------------------------------------------------------------------
|
||||
|
||||
Copyright (C) 2011-2012 Computer Graphics Group RWTH Aachen University
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
17
extern/acgl/README.TXT
vendored
Normal file
17
extern/acgl/README.TXT
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
ACGL - Aachen Computer Graphics Library
|
||||
---------------------------------------
|
||||
|
||||
Intended to speed up graphics/OpenGL prototyping. Developed by Lars Krecklau and Robert Menzel with help from Andreas Neu, Janis Born, Kersten Schuster, Ole Untzelmann, based on prior work from Lars Krecklau.
|
||||
|
||||
Included third-party software:
|
||||
* Includes lodepng by Lode Vandevenne, unchanged except for the include path in lodepng.cpp. lodepng is provided as-is, see license text in the lodepng source code.
|
||||
* Includes OpenGL loader code created by a modified glLoadGen by Jason McKesson.
|
||||
* Includes GLM by Christophe Riccio.
|
||||
* Includes data type definitions from libspnav header originally by John Tsiombikas (see mini_spnav.h for details).
|
||||
* Includes RGBE/Radiance image import by Bruce Walter (code provided 'as-is') minimally adjusted to reduce compiler warnings.
|
||||
|
||||
See LICENSE.TXT for licensing information.
|
||||
|
||||
Additional documentation: http://www.graphics.rwth-aachen.de/redmine/projects/acgl/wiki
|
||||
|
||||
|
43
extern/acgl/cmake/.gitignore
vendored
Normal file
43
extern/acgl/cmake/.gitignore
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
#
|
||||
# files and filetypes that should get ignored by git should get added here
|
||||
#
|
||||
|
||||
#
|
||||
# libraries:
|
||||
#
|
||||
lib/*
|
||||
|
||||
#
|
||||
# binaries:
|
||||
# (add project specific filenames here)
|
||||
#
|
||||
|
||||
#
|
||||
# IDE files:
|
||||
# QT creator:
|
||||
#
|
||||
*.user
|
||||
|
||||
#
|
||||
# build files
|
||||
#
|
||||
build/*
|
||||
*.o
|
||||
|
||||
#
|
||||
# temp cmake files:
|
||||
#
|
||||
cmake_install.cmake
|
||||
CMakeCache.txt
|
||||
CMakeFiles
|
||||
Makefile
|
||||
*.cbp
|
||||
|
||||
#
|
||||
# OS specific temp files:
|
||||
#
|
||||
*~
|
||||
.directory
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
20
extern/acgl/cmake/CMakeMacros.txt
vendored
Normal file
20
extern/acgl/cmake/CMakeMacros.txt
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
################################################################################
|
||||
# Macro to sort acgl into directories
|
||||
################################################################################
|
||||
|
||||
MACRO (RECURSE_GROUPS dirname)
|
||||
FILE(GLOB_RECURSE allfiles "${dirname}/*.*")
|
||||
SET(ALL_FILES ${ALL_FILES} ${allfiles})
|
||||
STRING(REGEX REPLACE ".*/([^/]*)" "\\1" maindir "${dirname}")
|
||||
|
||||
FOREACH(file ${allfiles})
|
||||
STRING(REGEX REPLACE "${dirname}/(.*)/[^/]*" "\\1" loopdirname "${file}")
|
||||
STRING(REGEX REPLACE "/" "\\\\" loopdirname "${loopdirname}")
|
||||
|
||||
IF(NOT "${file}" MATCHES "${dirname}/(.*)/[^/]*")
|
||||
source_group("${maindir}" FILES ${file})
|
||||
ELSE()
|
||||
source_group("${maindir}\\${loopdirname}" FILES ${file})
|
||||
ENDIF()
|
||||
ENDFOREACH()
|
||||
ENDMACRO (RECURSE_GROUPS)
|
59
extern/acgl/cmake/CheckCCompilerFlag.cmake
vendored
Normal file
59
extern/acgl/cmake/CheckCCompilerFlag.cmake
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
# - Check if the C source code provided in the SOURCE argument compiles.
|
||||
# CHECK_C_SOURCE_COMPILES(SOURCE VAR)
|
||||
#
|
||||
# FLAG - compiler flag to check
|
||||
# VAR - variable to store whether the source code compiled
|
||||
#
|
||||
# The following variables may be set before calling this macro to
|
||||
# modify the way the check is run:
|
||||
#
|
||||
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
|
||||
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
|
||||
# CMAKE_REQUIRED_INCLUDES = list of include directories
|
||||
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
|
||||
|
||||
MACRO(CHECK_C_COMPILER_FLAG FLAG VAR)
|
||||
IF("${VAR}" MATCHES "^${VAR}$")
|
||||
SET(MACRO_CHECK_FUNCTION_DEFINITIONS
|
||||
"${FLAG} ${CMAKE_REQUIRED_FLAGS}")
|
||||
IF(CMAKE_REQUIRED_LIBRARIES)
|
||||
SET(CHECK_C_COMPILER_FLAG_ADD_LIBRARIES
|
||||
"-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
|
||||
ELSE(CMAKE_REQUIRED_LIBRARIES)
|
||||
SET(CHECK_C_COMPILER_FLAG_ADD_LIBRARIES)
|
||||
ENDIF(CMAKE_REQUIRED_LIBRARIES)
|
||||
IF(CMAKE_REQUIRED_INCLUDES)
|
||||
SET(CHECK_C_COMPILER_FLAG_ADD_INCLUDES
|
||||
"-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
|
||||
ELSE(CMAKE_REQUIRED_INCLUDES)
|
||||
SET(CHECK_C_COMPILER_FLAG_ADD_INCLUDES)
|
||||
ENDIF(CMAKE_REQUIRED_INCLUDES)
|
||||
FILE(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c"
|
||||
"int main() {return 0;}\n")
|
||||
|
||||
MESSAGE(STATUS "Checking if C compiler supports ${FLAG}")
|
||||
TRY_COMPILE(${VAR}
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c
|
||||
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
|
||||
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
|
||||
"${CHECK_C_COMPILER_FLAG_ADD_LIBRARIES}"
|
||||
"${CHECK_C_COMPILER_FLAG_ADD_INCLUDES}"
|
||||
OUTPUT_VARIABLE OUTPUT)
|
||||
IF(${VAR})
|
||||
SET(${VAR} 1 CACHE INTERNAL "Test ${VAR}")
|
||||
MESSAGE(STATUS "Checking if C compiler supports ${FLAG} - Success")
|
||||
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
||||
"Performing C SOURCE FILE Test ${VAR} succeded with the following output:\n"
|
||||
"${OUTPUT}\n"
|
||||
"Source file was:\n${SOURCE}\n")
|
||||
ELSE(${VAR})
|
||||
MESSAGE(STATUS "Checking if C compiler supports ${FLAG} - Failed")
|
||||
SET(${VAR} "" CACHE INTERNAL "Test ${VAR}")
|
||||
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
||||
"Performing C SOURCE FILE Test ${VAR} failed with the following output:\n"
|
||||
"${OUTPUT}\n"
|
||||
"Source file was:\n${SOURCE}\n")
|
||||
ENDIF(${VAR})
|
||||
ENDIF("${VAR}" MATCHES "^${VAR}$")
|
||||
ENDMACRO(CHECK_C_COMPILER_FLAG)
|
35
extern/acgl/cmake/CheckSharedFunctionExists.c
vendored
Normal file
35
extern/acgl/cmake/CheckSharedFunctionExists.c
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
|
||||
#ifdef CHECK_SHARED_FUNCTION_EXISTS
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef CALLSTACK
|
||||
#define CALLSTACK
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef ARGSTACK
|
||||
char __stdcall CHECK_SHARED_FUNCTION_EXISTS(ARGSTACK);
|
||||
#else
|
||||
char __stdcall CHECK_SHARED_FUNCTION_EXISTS(void);
|
||||
#endif
|
||||
#else
|
||||
char CHECK_SHARED_FUNCTION_EXISTS();
|
||||
#endif
|
||||
|
||||
#ifdef __CLASSIC_C__
|
||||
int main(){
|
||||
int ac;
|
||||
char*av[];
|
||||
#else
|
||||
int main(int ac, char*av[]){
|
||||
#endif
|
||||
CHECK_SHARED_FUNCTION_EXISTS(CALLSTACK);
|
||||
if(ac > 1000)
|
||||
{
|
||||
return *av[0];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* CHECK_SHARED_FUNCTION_EXISTS */
|
70
extern/acgl/cmake/CheckSharedLibraryExists.cmake
vendored
Normal file
70
extern/acgl/cmake/CheckSharedLibraryExists.cmake
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
# - Check if the function exists.
|
||||
# CHECK_LIBRARY_EXISTS (LIBRARY FUNCTION LOCATION VARIABLE)
|
||||
#
|
||||
# LIBRARY - the name of the library you are looking for
|
||||
# FUNCTION - the name of the function
|
||||
# ARGCOUNT - number of arguments for stdcall functions
|
||||
# LOCATION - location where the library should be found
|
||||
# VARIABLE - variable to store the result
|
||||
#
|
||||
# The following variables may be set before calling this macro to
|
||||
# modify the way the check is run:
|
||||
#
|
||||
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
|
||||
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
|
||||
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
|
||||
|
||||
MACRO(CHECK_SHARED_LIBRARY_EXISTS LIBRARY FUNCTION ARGCOUNT LOCATION VARIABLE)
|
||||
IF("${VARIABLE}" MATCHES "^${VARIABLE}$")
|
||||
SET(MACRO_CHECK_LIBRARY_EXISTS_DEFINITION
|
||||
"-DCHECK_SHARED_FUNCTION_EXISTS=${FUNCTION} ${CMAKE_REQUIRED_FLAGS}")
|
||||
IF(WIN32)
|
||||
IF(${ARGCOUNT} GREATER 0)
|
||||
SET(ARGSTACK "void*")
|
||||
SET(CALLSTACK "NULL")
|
||||
SET(CURARG 1)
|
||||
WHILE(${ARGCOUNT} GREATER ${CURARG})
|
||||
SET(ARGSTACK "${ARGSTACK},void*")
|
||||
SET(CALLSTACK "${CALLSTACK},NULL")
|
||||
MATH(EXPR CURARG "${CURARG} + 1")
|
||||
ENDWHILE(${ARGCOUNT} GREATER ${CURARG})
|
||||
SET(MACRO_CHECK_LIBRARY_EXISTS_DEFINITION
|
||||
"-D_WIN32 -DARGSTACK=\"${ARGSTACK}\" -DCALLSTACK=\"${CALLSTACK}\" ${MACRO_CHECK_LIBRARY_EXISTS_DEFINITION}")
|
||||
ELSE(${ARGCOUNT} GREATER 0)
|
||||
SET(MACRO_CHECK_LIBRARY_EXISTS_DEFINITION
|
||||
"-D_WIN32 ${MACRO_CHECK_LIBRARY_EXISTS_DEFINITION}")
|
||||
ENDIF(${ARGCOUNT} GREATER 0)
|
||||
ENDIF(WIN32)
|
||||
MESSAGE(STATUS "Looking for ${FUNCTION} in ${LIBRARY}")
|
||||
SET(CHECK_LIBRARY_EXISTS_LIBRARIES ${LIBRARY})
|
||||
IF(CMAKE_REQUIRED_LIBRARIES)
|
||||
SET(CHECK_LIBRARY_EXISTS_LIBRARIES
|
||||
${CHECK_LIBRARY_EXISTS_LIBRARIES} ${CMAKE_REQUIRED_LIBRARIES})
|
||||
ENDIF(CMAKE_REQUIRED_LIBRARIES)
|
||||
TRY_COMPILE(${VARIABLE}
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CheckSharedFunctionExists.c
|
||||
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
|
||||
CMAKE_FLAGS
|
||||
-DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_LIBRARY_EXISTS_DEFINITION}
|
||||
-DLINK_DIRECTORIES:STRING=${LOCATION}
|
||||
"-DLINK_LIBRARIES:STRING=${CHECK_LIBRARY_EXISTS_LIBRARIES}"
|
||||
OUTPUT_VARIABLE OUTPUT)
|
||||
|
||||
IF(${VARIABLE})
|
||||
MESSAGE(STATUS "Looking for ${FUNCTION} in ${LIBRARY} - found")
|
||||
SET(${VARIABLE} 1 CACHE INTERNAL "Have library ${LIBRARY}")
|
||||
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
||||
"Determining if the function ${FUNCTION} exists in the ${LIBRARY} "
|
||||
"passed with the following output:\n"
|
||||
"${OUTPUT}\n\n")
|
||||
ELSE(${VARIABLE})
|
||||
MESSAGE(STATUS "Looking for ${FUNCTION} in ${LIBRARY} - not found")
|
||||
SET(${VARIABLE} "" CACHE INTERNAL "Have library ${LIBRARY}")
|
||||
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
||||
"Determining if the function ${FUNCTION} exists in the ${LIBRARY} "
|
||||
"failed with the following output:\n"
|
||||
"${OUTPUT}\n\n")
|
||||
ENDIF(${VARIABLE})
|
||||
ENDIF("${VARIABLE}" MATCHES "^${VARIABLE}$")
|
||||
ENDMACRO(CHECK_SHARED_LIBRARY_EXISTS)
|
27
extern/acgl/cmake/CompileOptions.txt
vendored
Normal file
27
extern/acgl/cmake/CompileOptions.txt
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
# Define options for compiling:
|
||||
SET_PROPERTY(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS None Release Debug RelWithDebInfo)
|
||||
IF(NOT CMAKE_BUILD_TYPE)
|
||||
SET(CMAKE_BUILD_TYPE Release CACHE STRING "" FORCE)
|
||||
ENDIF()
|
||||
IF(NOT DEFINED COMPILE_POSTFIX)
|
||||
STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} Debug EQ)
|
||||
IF(NOT EQ)
|
||||
STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} RelWithDebInfo EQ)
|
||||
ENDIF()
|
||||
IF(EQ)
|
||||
SET(COMPILE_POSTFIX "_d")
|
||||
ELSEIF()
|
||||
SET(COMPILE_POSTFIX "")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
IF(NOT DEFINED LAST_BUILD_TYPE)
|
||||
SET(LAST_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE INTERNAL "")
|
||||
ENDIF()
|
||||
|
||||
STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} ${LAST_BUILD_TYPE} EQ)
|
||||
IF(NOT EQ)
|
||||
SET(BUILD_TYPE_CHANGED TRUE)
|
||||
SET(LAST_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE INTERNAL "")
|
||||
ENDIF()
|
||||
|
56
extern/acgl/cmake/DefinesACGL.txt
vendored
Normal file
56
extern/acgl/cmake/DefinesACGL.txt
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
# Define error check
|
||||
IF(NOT DEFINED ACGL_ERROR_LEVEL)
|
||||
MESSAGE(FATAL_ERROR "ACGL_ERROR_LEVEL is not defined!")
|
||||
ELSE()
|
||||
SET(ACGL_ERROR_LEVEL_${ACGL_ERROR_LEVEL} True)
|
||||
SET(ACGL_DEFINES ${ACGL_DEFINES} -DACGL_ERROR_LEVEL_${ACGL_ERROR_LEVEL})
|
||||
ENDIF()
|
||||
|
||||
# Define OpenGL Profile and Version:
|
||||
IF(NOT DEFINED ACGL_OPENGL_SUPPORT)
|
||||
MESSAGE(FATAL_ERROR "ACGL_OPENGL_SUPPORT is not defined!")
|
||||
ELSE()
|
||||
STRING(REPLACE "_" ";" ACGL_OPENGL_SUPPORT_SPLIT ${ACGL_OPENGL_SUPPORT})
|
||||
LIST(GET ACGL_OPENGL_SUPPORT_SPLIT 0 ACGL_OPENGL_PROFILE)
|
||||
LIST(GET ACGL_OPENGL_SUPPORT_SPLIT 1 ACGL_OPENGL_VERSION)
|
||||
|
||||
SET(ACGL_OPENGL_PROFILE_${ACGL_OPENGL_PROFILE} True)
|
||||
SET(ACGL_OPENGL_VERSION_${ACGL_OPENGL_VERSION} True)
|
||||
|
||||
SET(ACGL_DEFINES ${ACGL_DEFINES} -DACGL_OPENGL_PROFILE_${ACGL_OPENGL_PROFILE})
|
||||
SET(ACGL_DEFINES ${ACGL_DEFINES} -DACGL_OPENGL_VERSION_${ACGL_OPENGL_VERSION})
|
||||
ENDIF()
|
||||
|
||||
# Set target platform
|
||||
SET(ACGL_PLATFORM DESKTOP)
|
||||
STRING(COMPARE EQUAL ${ACGL_OPENGL_PROFILE} ES EQ)
|
||||
IF(EQ)
|
||||
SET(FIND_GLEW FALSE)
|
||||
SET(ACGL_PLATFORM MOBILE)
|
||||
ELSE()
|
||||
SET(FIND_GLEW TRUE)
|
||||
LIST(FIND ACGL_OPENGL_SUPPORT_SPLIT ES ID)
|
||||
IF(NOT ID EQUAL -1)
|
||||
SET(ACGL_SIMULATE_ES True)
|
||||
SET(ACGL_DEFINES ${ACGL_DEFINES} -DACGL_SIMULATE_ES)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
SET(ACGL_PLATFORM_${ACGL_PLATFORM} True)
|
||||
SET(ACGL_DEFINES ${ACGL_DEFINES} -DACGL_PLATFORM_${ACGL_PLATFORM})
|
||||
|
||||
# Use Qt
|
||||
STRING(COMPARE EQUAL ${ACGL_COMPILE_WITH_QT} Yes EQ)
|
||||
IF(EQ)
|
||||
SET(ACGL_COMPILE_WITH_QT True)
|
||||
SET(ACGL_DEFINES ${ACGL_DEFINES} -DACGL_COMPILE_WITH_QT)
|
||||
SET(FIND_QT TRUE)
|
||||
ELSE()
|
||||
SET(ACGL_COMPILE_WITH_QT False)
|
||||
SET(FIND_QT FALSE)
|
||||
ENDIF()
|
||||
|
||||
#Compile the C runtime environment statically
|
||||
IF(NOT DEFINED ACGL_STATIC_RUNTIME_ENV)
|
||||
SET(ACGL_STATIC_RUNTIME_ENV False)
|
||||
ENDIF()
|
5
extern/acgl/cmake/DefinesFREETYPE.txt
vendored
Normal file
5
extern/acgl/cmake/DefinesFREETYPE.txt
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
SET(FREETYPE_DEFINES -DFT2_BUILD_LIBRARY)
|
||||
SET(FREETYPE_DEFINES ${FREETYPE_DEFINES} -DFT_CONFIG_MODULES_H="${FREETYPE_CONFIG_PATH}/ftmodule.h")
|
||||
SET(FREETYPE_DEFINES ${FREETYPE_DEFINES} -DFT_CONFIG_CONFIG_H="${FREETYPE_CONFIG_PATH}/ftconfig.h")
|
||||
#SET(FREETYPE_DEFINES ${FREETYPE_DEFINES} -DFT_CONFIG_OPTION_SYSTEM_ZLIB)
|
||||
|
1
extern/acgl/cmake/DefinesGLEW.txt
vendored
Normal file
1
extern/acgl/cmake/DefinesGLEW.txt
vendored
Normal file
@ -0,0 +1 @@
|
||||
SET(GLEW_DEFINES -DGLEW_STATIC)
|
4
extern/acgl/cmake/DefinesSLB.txt
vendored
Normal file
4
extern/acgl/cmake/DefinesSLB.txt
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
SET(SLB_DEFINES -DSLB_EXTERNAL_LUA)
|
||||
if(WIN32)
|
||||
SET(SLB_DEFINES ${SLB_DEFINES} -DSLB_LIBRARY)
|
||||
endif()
|
63
extern/acgl/cmake/FindACGL.cmake
vendored
Normal file
63
extern/acgl/cmake/FindACGL.cmake
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
# - Find ACGL
|
||||
# Find the native ACGL headers
|
||||
#
|
||||
# ACGL_INCLUDE_DIR - where to find ACGL.h, etc.
|
||||
# ACGL_LIBRARIES - ACGL library
|
||||
# ACGL_DEFINES - ACGL defines
|
||||
# ACGL_FOUND - True if ACGL found.
|
||||
|
||||
IF(ACGL_FOUND)
|
||||
# Already in cache, be silent
|
||||
SET(ACGL_FIND_QUIETLY TRUE)
|
||||
ENDIF()
|
||||
|
||||
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/DefinesACGL.txt)
|
||||
|
||||
IF(BUILD_ACGL OR ACGL_GLOBAL_EXTERN_DIR_FOUND_FIRST_TIME OR BUILD_TYPE_CHANGED)
|
||||
UNSET(ACGL_INCLUDE_DIR CACHE)
|
||||
UNSET(ACGL_LIBRARIES CACHE)
|
||||
ENDIF()
|
||||
|
||||
IF(BUILD_ACGL)
|
||||
SET(ACGL_INCLUDE_DIR "${ACGL_LOCAL_EXTERN_DIR}/acgl/include")
|
||||
SET(ACGL_LIBRARIES ACGL${COMPILE_POSTFIX})
|
||||
ELSE()
|
||||
# Look for the header file.
|
||||
IF(ACGL_GLOBAL_EXTERN_DIR)
|
||||
FIND_PATH(ACGL_INCLUDE_DIR NAMES ACGL/ACGL.hh PATHS "${ACGL_GLOBAL_EXTERN_DIR}/acgl/include" NO_DEFAULT_PATH)
|
||||
ENDIF()
|
||||
IF(NOT ACGL_INCLUDE_DIR)
|
||||
FIND_PATH(ACGL_INCLUDE_DIR NAMES ACGL/ACGL.hh)
|
||||
ENDIF()
|
||||
|
||||
# Look for the library file.
|
||||
IF(ACGL_GLOBAL_EXTERN_DIR)
|
||||
FIND_LIBRARY(ACGL_LIBRARIES NAMES ACGL${COMPILE_POSTFIX} PATHS "${ACGL_GLOBAL_EXTERN_DIR}/acgl/lib" NO_DEFAULT_PATH)
|
||||
ENDIF()
|
||||
IF(NOT ACGL_LIBRARIES)
|
||||
FIND_LIBRARY(ACGL_LIBRARIES NAMES ACGL${COMPILE_POSTFIX})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
# Copy the results to the output variables.
|
||||
IF(ACGL_INCLUDE_DIR AND ACGL_LIBRARIES)
|
||||
SET(ACGL_FOUND TRUE CACHE INTERNAL "")
|
||||
ELSE()
|
||||
SET(ACGL_FOUND FALSE CACHE INTERNAL "")
|
||||
ENDIF()
|
||||
|
||||
# Report the results.
|
||||
IF(NOT ACGL_FOUND)
|
||||
SET(ACGL_MESSAGE "ACGL was not found. Make sure ACGL_INCLUDE_DIR AND ACGL_LIBRARIES are set correctly.")
|
||||
IF(ACGL_FIND_REQUIRED)
|
||||
MESSAGE(FATAL_ERROR "${ACGL_MESSAGE}")
|
||||
ELSEIF(NOT ACGL_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "${ACGL_MESSAGE}")
|
||||
ENDIF()
|
||||
ELSEIF(NOT ACGL_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Looking for ACGL - found")
|
||||
ENDIF()
|
||||
|
||||
MESSAGE(STATUS "ACGL_INCLUDE_DIR:${ACGL_INCLUDE_DIR}")
|
||||
MESSAGE(STATUS "ACGL_LIBRARIES:${ACGL_LIBRARIES}")
|
||||
|
59
extern/acgl/cmake/FindANGELSCRIPT.cmake
vendored
Normal file
59
extern/acgl/cmake/FindANGELSCRIPT.cmake
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
# Find the native angelscript headers
|
||||
#
|
||||
# ANGELSCRIPT_INCLUDE_DIR - where to find angelscriptenc.h, etc.
|
||||
# ANGELSCRIPT_LIBRARIES - angelscript library
|
||||
# ANGELSCRIPT_FOUND - True if angelscript found.
|
||||
|
||||
IF(ANGELSCRIPT_FOUND)
|
||||
# Already in cache, be silent
|
||||
SET(ANGELSCRIPT_FIND_QUIETLY TRUE)
|
||||
ENDIF()
|
||||
|
||||
IF(BUILD_ANGELSCRIPT OR ACGL_GLOBAL_EXTERN_DIR_FOUND_FIRST_TIME OR BUILD_TYPE_CHANGED)
|
||||
UNSET(ANGELSCRIPT_INCLUDE_DIR CACHE)
|
||||
UNSET(ANGELSCRIPT_LIBRARIES CACHE)
|
||||
ENDIF()
|
||||
|
||||
IF(BUILD_ANGELSCRIPT)
|
||||
SET(ANGELSCRIPT_INCLUDE_DIR "${ACGL_LOCAL_EXTERN_DIR}/angelscript/angelscript/include/")
|
||||
SET(ANGELSCRIPT_LIBRARIES AngelScript${COMPILE_POSTFIX})
|
||||
ELSE()
|
||||
# Look for the header file.
|
||||
IF(ACGL_GLOBAL_EXTERN_DIR)
|
||||
FIND_PATH(ANGELSCRIPT_INCLUDE_DIR NAMES angelscript.h PATHS "${ACGL_GLOBAL_EXTERN_DIR}/angelscript/angelscript/include/" NO_DEFAULT_PATH)
|
||||
ENDIF()
|
||||
IF(NOT ANGELSCRIPT_INCLUDE_DIR)
|
||||
FIND_PATH(ANGELSCRIPT_INCLUDE_DIR NAMES angelscript.h)
|
||||
ENDIF()
|
||||
|
||||
# Look for the library file.
|
||||
IF(ACGL_GLOBAL_EXTERN_DIR)
|
||||
FIND_LIBRARY(ANGELSCRIPT_LIBRARIES NAMES AngelScript${COMPILE_POSTFIX} PATHS "${ACGL_GLOBAL_EXTERN_DIR}/angelscript/lib" NO_DEFAULT_PATH)
|
||||
ENDIF()
|
||||
IF(NOT ANGELSCRIPT_LIBRARIES)
|
||||
FIND_LIBRARY(ANGELSCRIPT_LIBRARIES NAMES AngelScript${COMPILE_POSTFIX})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
# Copy the results to the output variables.
|
||||
IF(ANGELSCRIPT_INCLUDE_DIR AND ANGELSCRIPT_LIBRARIES)
|
||||
SET(ANGELSCRIPT_FOUND TRUE CACHE INTERNAL "")
|
||||
ELSE()
|
||||
SET(ANGELSCRIPT_FOUND FALSE CACHE INTERNAL "")
|
||||
ENDIF()
|
||||
|
||||
# Report the results.
|
||||
IF(NOT ANGELSCRIPT_FOUND)
|
||||
SET(ANGELSCRIPT_MESSAGE "angelscript was not found. Make sure ANGELSCRIPT_INCLUDE_DIR AND ANGELSCRIPT_LIBRARIES are set correctly.")
|
||||
IF(ANGELSCRIPT_FIND_REQUIRED)
|
||||
MESSAGE(FATAL_ERROR "${ANGELSCRIPT_MESSAGE}")
|
||||
ELSEIF(NOT ANGELSCRIPT_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "${ANGELSCRIPT_MESSAGE}")
|
||||
ENDIF()
|
||||
ELSEIF(NOT ANGELSCRIPT_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Looking for angelscript - found")
|
||||
ENDIF()
|
||||
|
||||
MESSAGE(STATUS "ANGELSCRIPT_INCLUDE_DIR:${ANGELSCRIPT_INCLUDE_DIR}")
|
||||
MESSAGE(STATUS "ANGELSCRIPT_LIBRARIES:${ANGELSCRIPT_LIBRARIES}")
|
||||
|
59
extern/acgl/cmake/FindBOX2D.cmake
vendored
Normal file
59
extern/acgl/cmake/FindBOX2D.cmake
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
# Find the native box2d headers
|
||||
#
|
||||
# BOX2D_INCLUDE_DIR - where to find box2denc.h, etc.
|
||||
# BOX2D_LIBRARIES - box2d library
|
||||
# BOX2D_FOUND - True if box2d found.
|
||||
|
||||
IF(BOX2D_FOUND)
|
||||
# Already in cache, be silent
|
||||
SET(BOX2D_FIND_QUIETLY TRUE)
|
||||
ENDIF()
|
||||
|
||||
IF(BUILD_BOX2D OR ACGL_GLOBAL_EXTERN_DIR_FOUND_FIRST_TIME OR BUILD_TYPE_CHANGED)
|
||||
UNSET(BOX2D_INCLUDE_DIR CACHE)
|
||||
UNSET(BOX2D_LIBRARIES CACHE)
|
||||
ENDIF()
|
||||
|
||||
IF(BUILD_BOX2D)
|
||||
SET(BOX2D_INCLUDE_DIR "${ACGL_LOCAL_EXTERN_DIR}/box2d")
|
||||
SET(BOX2D_LIBRARIES Box2D${COMPILE_POSTFIX})
|
||||
ELSE()
|
||||
# Look for the header file.
|
||||
IF(ACGL_GLOBAL_EXTERN_DIR)
|
||||
FIND_PATH(BOX2D_INCLUDE_DIR NAMES Box2D/Box2D.h PATHS "${ACGL_GLOBAL_EXTERN_DIR}/box2d" NO_DEFAULT_PATH)
|
||||
ENDIF()
|
||||
IF(NOT BOX2D_INCLUDE_DIR)
|
||||
FIND_PATH(BOX2D_INCLUDE_DIR NAMES Box2D/Box2D.h)
|
||||
ENDIF()
|
||||
|
||||
# Look for the library file.
|
||||
IF(ACGL_GLOBAL_EXTERN_DIR)
|
||||
FIND_LIBRARY(BOX2D_LIBRARIES NAMES Box2D${COMPILE_POSTFIX} PATHS "${ACGL_GLOBAL_EXTERN_DIR}/box2d/lib" NO_DEFAULT_PATH)
|
||||
ENDIF()
|
||||
IF(NOT BOX2D_LIBRARIES)
|
||||
FIND_LIBRARY(BOX2D_LIBRARIES NAMES Box2D${COMPILE_POSTFIX})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
# Copy the results to the output variables.
|
||||
IF(BOX2D_INCLUDE_DIR AND BOX2D_LIBRARIES)
|
||||
SET(BOX2D_FOUND TRUE CACHE INTERNAL "")
|
||||
ELSE()
|
||||
SET(BOX2D_FOUND FALSE CACHE INTERNAL "")
|
||||
ENDIF()
|
||||
|
||||
# Report the results.
|
||||
IF(NOT BOX2D_FOUND)
|
||||
SET(BOX2D_MESSAGE "box2d was not found. Make sure BOX2D_INCLUDE_DIR AND BOX2D_LIBRARIES are set correctly.")
|
||||
IF(BOX2D_FIND_REQUIRED)
|
||||
MESSAGE(FATAL_ERROR "${BOX2D_MESSAGE}")
|
||||
ELSEIF(NOT BOX2D_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "${BOX2D_MESSAGE}")
|
||||
ENDIF()
|
||||
ELSEIF(NOT BOX2D_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Looking for box2d - found")
|
||||
ENDIF()
|
||||
|
||||
MESSAGE(STATUS "BOX2D_INCLUDE_DIR:${BOX2D_INCLUDE_DIR}")
|
||||
MESSAGE(STATUS "BOX2D_LIBRARIES:${BOX2D_LIBRARIES}")
|
||||
|
59
extern/acgl/cmake/FindBULLET.cmake
vendored
Normal file
59
extern/acgl/cmake/FindBULLET.cmake
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
# Find the native bullet headers
|
||||
#
|
||||
# BULLET_INCLUDE_DIR - where to find bulletenc.h, etc.
|
||||
# BULLET_LIBRARIES - bullet library
|
||||
# BULLET_FOUND - True if bullet found.
|
||||
|
||||
IF(BULLET_FOUND)
|
||||
# Already in cache, be silent
|
||||
SET(BULLET_FIND_QUIETLY TRUE)
|
||||
ENDIF()
|
||||
|
||||
IF(BUILD_BULLET OR ACGL_GLOBAL_EXTERN_DIR_FOUND_FIRST_TIME OR BUILD_TYPE_CHANGED)
|
||||
UNSET(BULLET_INCLUDE_DIR CACHE)
|
||||
UNSET(BULLET_LIBRARIES CACHE)
|
||||
ENDIF()
|
||||
|
||||
IF(BUILD_BULLET)
|
||||
SET(BULLET_INCLUDE_DIR "${ACGL_LOCAL_EXTERN_DIR}/bullet/src")
|
||||
SET(BULLET_LIBRARIES BulletCollision${COMPILE_POSTFIX} BulletDynamics${COMPILE_POSTFIX} BulletMultiThreaded${COMPILE_POSTFIX} BulletSoftBody${COMPILE_POSTFIX} BulletSoftBodySolvers_OpenCL_Mini${COMPILE_POSTFIX} LinearMath${COMPILE_POSTFIX} MiniCL${COMPILE_POSTFIX})
|
||||
ELSE()
|
||||
# Look for the header file.
|
||||
IF(ACGL_GLOBAL_EXTERN_DIR)
|
||||
FIND_PATH(BULLET_INCLUDE_DIR NAMES btBulletCollisionCommon.h PATHS "${ACGL_GLOBAL_EXTERN_DIR}/bullet/src" NO_DEFAULT_PATH)
|
||||
ENDIF()
|
||||
IF(NOT BULLET_INCLUDE_DIR)
|
||||
FIND_PATH(BULLET_INCLUDE_DIR NAMES btBulletCollisionCommon.h)
|
||||
ENDIF()
|
||||
|
||||
# Look for the library file.
|
||||
IF(ACGL_GLOBAL_EXTERN_DIR)
|
||||
FIND_LIBRARY(BULLET_LIBRARIES NAMES BulletCollision${COMPILE_POSTFIX} BulletDynamics${COMPILE_POSTFIX} BulletMultiThreaded${COMPILE_POSTFIX} BulletSoftBody${COMPILE_POSTFIX} BulletSoftBodySolvers_OpenCL_Mini${COMPILE_POSTFIX} LinearMath${COMPILE_POSTFIX} MiniCL${COMPILE_POSTFIX} PATHS "${ACGL_GLOBAL_EXTERN_DIR}/bullet/lib" NO_DEFAULT_PATH)
|
||||
ENDIF()
|
||||
IF(NOT BULLET_LIBRARIES)
|
||||
FIND_LIBRARY(BULLET_LIBRARIES NAMES BulletCollision${COMPILE_POSTFIX} BulletDynamics${COMPILE_POSTFIX} BulletMultiThreaded${COMPILE_POSTFIX} BulletSoftBody${COMPILE_POSTFIX} BulletSoftBodySolvers_OpenCL_Mini${COMPILE_POSTFIX} LinearMath${COMPILE_POSTFIX} MiniCL${COMPILE_POSTFIX})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
# Copy the results to the output variables.
|
||||
IF(BULLET_INCLUDE_DIR AND BULLET_LIBRARIES)
|
||||
SET(BULLET_FOUND TRUE CACHE INTERNAL "")
|
||||
ELSE()
|
||||
SET(BULLET_FOUND FALSE CACHE INTERNAL "")
|
||||
ENDIF()
|
||||
|
||||
# Report the results.
|
||||
IF(NOT BULLET_FOUND)
|
||||
SET(BULLET_MESSAGE "bullet was not found. Make sure BULLET_INCLUDE_DIR AND BULLET_LIBRARIES are set correctly.")
|
||||
IF(BULLET_FIND_REQUIRED)
|
||||
MESSAGE(FATAL_ERROR "${BULLET_MESSAGE}")
|
||||
ELSEIF(NOT BULLET_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "${BULLET_MESSAGE}")
|
||||
ENDIF()
|
||||
ELSEIF(NOT BULLET_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Looking for bullet - found")
|
||||
ENDIF()
|
||||
|
||||
MESSAGE(STATUS "BULLET_INCLUDE_DIR:${BULLET_INCLUDE_DIR}")
|
||||
MESSAGE(STATUS "BULLET_LIBRARIES:${BULLET_LIBRARIES}")
|
||||
|
64
extern/acgl/cmake/FindFREETYPE.cmake
vendored
Normal file
64
extern/acgl/cmake/FindFREETYPE.cmake
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
# - Find FREETYPE
|
||||
# Find the native FREETYPE headers
|
||||
#
|
||||
# FREETYPE_INCLUDE_DIR - where to find FREETYPE.h, etc.
|
||||
# FREETYPE_LIBRARIES - FREETYPE library
|
||||
# FREETYPE_DEFINES - FREETYPE defines
|
||||
# FREETYPE_FOUND - True if FREETYPE found.
|
||||
|
||||
IF(FREETYPE_FOUND)
|
||||
# Already in cache, be silent
|
||||
SET(FREETYPE_FIND_QUIETLY TRUE)
|
||||
ENDIF()
|
||||
|
||||
IF(BUILD_FREETYPE OR ACGL_GLOBAL_EXTERN_DIR_FOUND_FIRST_TIME OR BUILD_TYPE_CHANGED)
|
||||
UNSET(FREETYPE_INCLUDE_DIR CACHE)
|
||||
UNSET(FREETYPE_LIBRARIES CACHE)
|
||||
ENDIF()
|
||||
|
||||
IF(BUILD_FREETYPE)
|
||||
SET(FREETYPE_INCLUDE_DIR "${ACGL_LOCAL_EXTERN_DIR}/freetype/include")
|
||||
SET(FREETYPE_LIBRARIES freetype${COMPILE_POSTFIX})
|
||||
ELSE()
|
||||
# Look for the header file.
|
||||
IF(ACGL_GLOBAL_EXTERN_DIR)
|
||||
FIND_PATH(FREETYPE_INCLUDE_DIR NAMES ft2build.h PATHS "${ACGL_GLOBAL_EXTERN_DIR}/freetype/include" NO_DEFAULT_PATH)
|
||||
ENDIF()
|
||||
IF(NOT FREETYPE_INCLUDE_DIR)
|
||||
FIND_PATH(FREETYPE_INCLUDE_DIR NAMES ft2build.h)
|
||||
ENDIF()
|
||||
|
||||
# Look for the library file.
|
||||
IF(ACGL_GLOBAL_EXTERN_DIR)
|
||||
FIND_LIBRARY(FREETYPE_LIBRARIES NAMES freetype${COMPILE_POSTFIX} PATHS "${ACGL_GLOBAL_EXTERN_DIR}/freetype/lib" NO_DEFAULT_PATH)
|
||||
ENDIF()
|
||||
IF(NOT FREETYPE_LIBRARIES)
|
||||
FIND_LIBRARY(FREETYPE_LIBRARIES NAMES freetype${COMPILE_POSTFIX})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
SET(FREETYPE_CONFIG_PATH ${FREETYPE_INCLUDE_DIR}/freetype/config)
|
||||
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/DefinesFREETYPE.txt)
|
||||
|
||||
# Copy the results to the output variables.
|
||||
IF(FREETYPE_INCLUDE_DIR AND FREETYPE_LIBRARIES)
|
||||
SET(FREETYPE_FOUND TRUE CACHE INTERNAL "")
|
||||
ELSE()
|
||||
SET(FREETYPE_FOUND FALSE CACHE INTERNAL "")
|
||||
ENDIF()
|
||||
|
||||
# Report the results.
|
||||
IF(NOT FREETYPE_FOUND)
|
||||
SET(FREETYPE_MESSAGE "FREETYPE was not found. Make sure FREETYPE_INCLUDE_DIR AND FREETYPE_LIBRARIES are set correctly.")
|
||||
IF(FREETYPE_FIND_REQUIRED)
|
||||
MESSAGE(FATAL_ERROR "${FREETYPE_MESSAGE}")
|
||||
ELSEIF(NOT FREETYPE_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "${FREETYPE_MESSAGE}")
|
||||
ENDIF()
|
||||
ELSEIF(NOT FREETYPE_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Looking for FREETYPE - found")
|
||||
ENDIF()
|
||||
|
||||
MESSAGE(STATUS "FREETYPE_INCLUDE_DIR:${FREETYPE_INCLUDE_DIR}")
|
||||
MESSAGE(STATUS "FREETYPE_LIBRARIES:${FREETYPE_LIBRARIES}")
|
||||
|
72
extern/acgl/cmake/FindGLEW.cmake
vendored
Normal file
72
extern/acgl/cmake/FindGLEW.cmake
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
# - Find GLEW
|
||||
# Find the native GLEW headers
|
||||
#
|
||||
# GLEW_INCLUDE_DIR - where to find glew.h, etc.
|
||||
# GLEW_LIBRARIES - glew library
|
||||
# GLEW_DEFINES - glew defines
|
||||
# GLEW_FOUND - True if GLEW found.
|
||||
|
||||
IF(GLEW_FOUND)
|
||||
# Already in cache, be silent
|
||||
SET(GLEW_FIND_QUIETLY TRUE)
|
||||
ENDIF()
|
||||
|
||||
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/DefinesGLEW.txt)
|
||||
|
||||
IF(BUILD_GLEW OR ACGL_GLOBAL_EXTERN_DIR_FOUND_FIRST_TIME OR BUILD_TYPE_CHANGED)
|
||||
UNSET(GLEW_INCLUDE_DIR CACHE)
|
||||
UNSET(GLEW_LIBRARIES CACHE)
|
||||
ENDIF()
|
||||
|
||||
IF(BUILD_GLEW)
|
||||
SET(GLEW_INCLUDE_DIR "${ACGL_LOCAL_EXTERN_DIR}/glew/include")
|
||||
SET(GLEW_LIBRARIES GLEW${COMPILE_POSTFIX})
|
||||
ELSE()
|
||||
# Look for the header file.
|
||||
IF(ACGL_GLOBAL_EXTERN_DIR)
|
||||
FIND_PATH(GLEW_INCLUDE_DIR NAMES GL/glew.h PATHS "${ACGL_GLOBAL_EXTERN_DIR}/glew/include" NO_DEFAULT_PATH)
|
||||
ENDIF()
|
||||
IF(NOT GLEW_INCLUDE_DIR)
|
||||
FIND_PATH(GLEW_INCLUDE_DIR NAMES GL/glew.h)
|
||||
ENDIF()
|
||||
|
||||
# Look for the library file.
|
||||
IF(WIN32)
|
||||
IF(ACGL_GLOBAL_EXTERN_DIR)
|
||||
FIND_LIBRARY(GLEW_LIBRARIES NAMES glew32${COMPILE_POSTFIX} PATHS "${ACGL_GLOBAL_EXTERN_DIR}/glew/lib" NO_DEFAULT_PATH)
|
||||
ENDIF()
|
||||
IF(NOT GLEW_LIBRARIES)
|
||||
FIND_LIBRARY(GLEW_LIBRARIES NAMES glew32)
|
||||
ENDIF()
|
||||
ELSE()
|
||||
IF(ACGL_GLOBAL_EXTERN_DIR)
|
||||
FIND_LIBRARY(GLEW_LIBRARIES NAMES glew${COMPILE_POSTFIX} GLEW${COMPILE_POSTFIX} PATHS "${ACGL_GLOBAL_EXTERN_DIR}/glew/lib" NO_DEFAULT_PATH)
|
||||
ENDIF()
|
||||
IF(NOT GLEW_LIBRARIES)
|
||||
FIND_LIBRARY(GLEW_LIBRARIES NAMES glew GLEW)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
# Copy the results to the output variables.
|
||||
IF(GLEW_INCLUDE_DIR AND GLEW_LIBRARIES)
|
||||
SET(GLEW_FOUND TRUE CACHE INTERNAL "")
|
||||
ELSE()
|
||||
SET(GLEW_FOUND FALSE CACHE INTERNAL "")
|
||||
ENDIF()
|
||||
|
||||
# Report the results.
|
||||
IF(NOT GLEW_FOUND)
|
||||
SET(GLEW_MESSAGE "GLEW source was not found. Make sure GLEW_INCLUDE_DIR AND GLEW_LIBRARIES are set correctly.")
|
||||
IF(GLEW_FIND_REQUIRED)
|
||||
MESSAGE(FATAL_ERROR "${GLEW_MESSAGE}")
|
||||
ELSEIF(NOT GLEW_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "${GLEW_MESSAGE}")
|
||||
ENDIF()
|
||||
ELSEIF(NOT GLEW_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Looking for GLEW - found")
|
||||
ENDIF()
|
||||
|
||||
MESSAGE(STATUS "GLEW_INCLUDE_DIR:${GLEW_INCLUDE_DIR}")
|
||||
MESSAGE(STATUS "GLEW_LIBRARIES:${GLEW_LIBRARIES}")
|
||||
|
46
extern/acgl/cmake/FindGLM.cmake
vendored
Normal file
46
extern/acgl/cmake/FindGLM.cmake
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
# - Find GLM
|
||||
# Find the native GLM headers
|
||||
#
|
||||
# GLM_INCLUDE_DIR - where to find glm.hpp, etc.
|
||||
# GLM_FOUND - True if GLM found.
|
||||
|
||||
IF(GLM_FOUND)
|
||||
# Already in cache, be silent
|
||||
SET(GLM_FIND_QUIETLY TRUE)
|
||||
ENDIF()
|
||||
|
||||
IF(BUILD_GLM OR ACGL_GLOBAL_EXTERN_DIR_FOUND_FIRST_TIME OR BUILD_TYPE_CHANGED)
|
||||
UNSET(GLM_INCLUDE_DIR CACHE)
|
||||
ENDIF()
|
||||
|
||||
# Look for the header file.
|
||||
IF(BUILD_GLM)
|
||||
SET(GLM_INCLUDE_DIR "${ACGL_LOCAL_EXTERN_DIR}/glm")
|
||||
ELSEIF(ACGL_GLOBAL_EXTERN_DIR)
|
||||
FIND_PATH(GLM_INCLUDE_DIR NAMES glm/glm.hpp PATHS "${ACGL_GLOBAL_EXTERN_DIR}/glm" NO_DEFAULT_PATH)
|
||||
ENDIF()
|
||||
IF(NOT GLM_INCLUDE_DIR)
|
||||
FIND_PATH(GLM_INCLUDE_DIR NAMES glm/glm.hpp)
|
||||
ENDIF()
|
||||
|
||||
# Copy the results to the output variables.
|
||||
IF(GLM_INCLUDE_DIR)
|
||||
SET(GLM_FOUND TRUE CACHE INTERNAL "")
|
||||
ELSE()
|
||||
SET(GLM_FOUND FALSE CACHE INTERNAL "")
|
||||
ENDIF()
|
||||
|
||||
# Report the results.
|
||||
IF(NOT GLM_FOUND)
|
||||
SET(GLM_MESSAGE "GLM was not found. Make sure GLM_INCLUDE_DIR is set to the directories containing the include files for GLM.")
|
||||
IF(GLM_FIND_REQUIRED)
|
||||
MESSAGE(FATAL_ERROR "${GLM_MESSAGE}")
|
||||
ELSEIF(NOT GLM_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "${GLM_MESSAGE}")
|
||||
ENDIF()
|
||||
ELSEIF(NOT GLM_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Looking for GLM - found")
|
||||
ENDIF()
|
||||
|
||||
MESSAGE(STATUS "GLM_INCLUDE_DIR:${GLM_INCLUDE_DIR}")
|
||||
|
59
extern/acgl/cmake/FindGOOGLETEST.cmake
vendored
Normal file
59
extern/acgl/cmake/FindGOOGLETEST.cmake
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
# Find the native googletest headers
|
||||
#
|
||||
# GOOGLETEST_INCLUDE_DIR - where to find googletestenc.h, etc.
|
||||
# GOOGLETEST_LIBRARIES - googletest library
|
||||
# GOOGLETEST_FOUND - True if googletest found.
|
||||
|
||||
IF(GOOGLETEST_FOUND)
|
||||
# Already in cache, be silent
|
||||
SET(GOOGLETEST_FIND_QUIETLY TRUE)
|
||||
ENDIF()
|
||||
|
||||
IF(BUILD_GOOGLETEST OR ACGL_GLOBAL_EXTERN_DIR_FOUND_FIRST_TIME OR BUILD_TYPE_CHANGED)
|
||||
UNSET(GOOGLETEST_INCLUDE_DIR CACHE)
|
||||
UNSET(GOOGLETEST_LIBRARIES CACHE)
|
||||
ENDIF()
|
||||
|
||||
IF(BUILD_GOOGLETEST)
|
||||
SET(GOOGLETEST_INCLUDE_DIR "${ACGL_LOCAL_EXTERN_DIR}/googletest/include")
|
||||
SET(GOOGLETEST_LIBRARIES GoogleTest${COMPILE_POSTFIX})
|
||||
ELSE()
|
||||
# Look for the header file.
|
||||
IF(ACGL_GLOBAL_EXTERN_DIR)
|
||||
FIND_PATH(GOOGLETEST_INCLUDE_DIR NAMES gtest/gtest.h PATHS "${ACGL_GLOBAL_EXTERN_DIR}/googletest/include" NO_DEFAULT_PATH)
|
||||
ENDIF()
|
||||
IF(NOT GOOGLETEST_INCLUDE_DIR)
|
||||
FIND_PATH(GOOGLETEST_INCLUDE_DIR NAMES gtest/gtest.h)
|
||||
ENDIF()
|
||||
|
||||
# Look for the library file.
|
||||
IF(ACGL_GLOBAL_EXTERN_DIR)
|
||||
FIND_LIBRARY(GOOGLETEST_LIBRARIES NAMES GoogleTest${COMPILE_POSTFIX} PATHS "${ACGL_GLOBAL_EXTERN_DIR}/googletest/lib" NO_DEFAULT_PATH)
|
||||
ENDIF()
|
||||
IF(NOT GOOGLETEST_LIBRARIES)
|
||||
FIND_LIBRARY(GOOGLETEST_LIBRARIES NAMES GoogleTest${COMPILE_POSTFIX})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
# Copy the results to the output variables.
|
||||
IF(GOOGLETEST_INCLUDE_DIR AND GOOGLETEST_LIBRARIES)
|
||||
SET(GOOGLETEST_FOUND TRUE CACHE INTERNAL "")
|
||||
ELSE()
|
||||
SET(GOOGLETEST_FOUND FALSE CACHE INTERNAL "")
|
||||
ENDIF()
|
||||
|
||||
# Report the results.
|
||||
IF(NOT GOOGLETEST_FOUND)
|
||||
SET(GOOGLETEST_MESSAGE "googletest was not found. Make sure GOOGLETEST_INCLUDE_DIR AND GOOGLETEST_LIBRARIES are set correctly.")
|
||||
IF(GOOGLETEST_FIND_REQUIRED)
|
||||
MESSAGE(FATAL_ERROR "${GOOGLETEST_MESSAGE}")
|
||||
ELSEIF(NOT GOOGLETEST_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "${GOOGLETEST_MESSAGE}")
|
||||
ENDIF()
|
||||
ELSEIF(NOT GOOGLETEST_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Looking for googletest - found")
|
||||
ENDIF()
|
||||
|
||||
MESSAGE(STATUS "GOOGLETEST_INCLUDE_DIR:${GOOGLETEST_INCLUDE_DIR}")
|
||||
MESSAGE(STATUS "GOOGLETEST_LIBRARIES:${GOOGLETEST_LIBRARIES}")
|
||||
|
60
extern/acgl/cmake/FindLUA.cmake
vendored
Normal file
60
extern/acgl/cmake/FindLUA.cmake
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
# - Find LUA
|
||||
# Find the native LUA headers
|
||||
#
|
||||
# LUA_INCLUDE_DIR - where to find LUA.h, etc.
|
||||
# LUA_LIBRARIES - LUA library
|
||||
# LUA_FOUND - True if LUA found.
|
||||
|
||||
IF(LUA_FOUND)
|
||||
# Already in cache, be silent
|
||||
SET(LUA_FIND_QUIETLY TRUE)
|
||||
ENDIF()
|
||||
|
||||
IF(BUILD_LUA OR ACGL_GLOBAL_EXTERN_DIR_FOUND_FIRST_TIME OR BUILD_TYPE_CHANGED)
|
||||
UNSET(LUA_INCLUDE_DIR CACHE)
|
||||
UNSET(LUA_LIBRARIES CACHE)
|
||||
ENDIF()
|
||||
|
||||
IF(BUILD_LUA)
|
||||
SET(LUA_INCLUDE_DIR "${ACGL_LOCAL_EXTERN_DIR}/lua/src")
|
||||
SET(LUA_LIBRARIES lua${COMPILE_POSTFIX})
|
||||
ELSE()
|
||||
# Look for the header file.
|
||||
IF(ACGL_GLOBAL_EXTERN_DIR)
|
||||
FIND_PATH(LUA_INCLUDE_DIR NAMES lua.h PATHS "${ACGL_GLOBAL_EXTERN_DIR}/lua/src" NO_DEFAULT_PATH)
|
||||
ENDIF()
|
||||
IF(NOT LUA_INCLUDE_DIR)
|
||||
FIND_PATH(LUA_INCLUDE_DIR NAMES lua.h)
|
||||
ENDIF()
|
||||
|
||||
# Look for the library file.
|
||||
IF(ACGL_GLOBAL_EXTERN_DIR)
|
||||
FIND_LIBRARY(LUA_LIBRARIES NAMES lua${COMPILE_POSTFIX} PATHS "${ACGL_GLOBAL_EXTERN_DIR}/lua/lib" NO_DEFAULT_PATH)
|
||||
ENDIF()
|
||||
IF(NOT LUA_LIBRARIES)
|
||||
FIND_LIBRARY(LUA_LIBRARIES NAMES lua)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
# Copy the results to the output variables.
|
||||
IF(LUA_INCLUDE_DIR AND LUA_LIBRARIES)
|
||||
SET(LUA_FOUND TRUE CACHE INTERNAL "")
|
||||
ELSE()
|
||||
SET(LUA_FOUND FALSE CACHE INTERNAL "")
|
||||
ENDIF()
|
||||
|
||||
# Report the results.
|
||||
IF(NOT LUA_FOUND)
|
||||
SET(LUA_MESSAGE "LUA source was not found. Make sure LUA_INCLUDE_DIR AND LUA_LIBRARIES are set correctly.")
|
||||
IF(LUA_FIND_REQUIRED)
|
||||
MESSAGE(FATAL_ERROR "${LUA_MESSAGE}")
|
||||
ELSEIF(NOT LUA_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "${LUA_MESSAGE}")
|
||||
ENDIF()
|
||||
ELSEIF(NOT LUA_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Looking for LUA - found")
|
||||
ENDIF()
|
||||
|
||||
MESSAGE(STATUS "LUA_INCLUDE_DIR:${LUA_INCLUDE_DIR}")
|
||||
MESSAGE(STATUS "LUA_LIBRARIES:${LUA_LIBRARIES}")
|
||||
|
63
extern/acgl/cmake/FindOGG.cmake
vendored
Normal file
63
extern/acgl/cmake/FindOGG.cmake
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
# - Find libogg
|
||||
# Find the native ogg headers
|
||||
#
|
||||
# OGG_INCLUDE_DIR - where to find ogg.h, etc.
|
||||
# OGG_LIBRARIES - ogg library
|
||||
# OGG_DEFINES - ogg defines
|
||||
# OGG_FOUND - True if ogg found.
|
||||
|
||||
IF(OGG_FOUND)
|
||||
# Already in cache, be silent
|
||||
SET(OGG_FIND_QUIETLY TRUE)
|
||||
ENDIF()
|
||||
|
||||
#INCLUDE(${CMAKE_CURRENT_LIST_DIR}/DefinesOGG.txt)
|
||||
|
||||
IF(BUILD_OGG OR ACGL_GLOBAL_EXTERN_DIR_FOUND_FIRST_TIME OR BUILD_TYPE_CHANGED)
|
||||
UNSET(OGG_INCLUDE_DIR CACHE)
|
||||
UNSET(OGG_LIBRARIES CACHE)
|
||||
ENDIF()
|
||||
|
||||
IF(BUILD_OGG)
|
||||
SET(OGG_INCLUDE_DIR "${ACGL_LOCAL_EXTERN_DIR}/ogg/include")
|
||||
SET(OGG_LIBRARIES ogg${COMPILE_POSTFIX})
|
||||
ELSE()
|
||||
# Look for the header file.
|
||||
IF(ACGL_GLOBAL_EXTERN_DIR)
|
||||
FIND_PATH(OGG_INCLUDE_DIR NAMES ogg/ogg.h PATHS "${ACGL_GLOBAL_EXTERN_DIR}/ogg/include" NO_DEFAULT_PATH)
|
||||
ENDIF()
|
||||
IF(NOT OGG_INCLUDE_DIR)
|
||||
FIND_PATH(OGG_INCLUDE_DIR NAMES ogg/ogg.h)
|
||||
ENDIF()
|
||||
|
||||
# Look for the library file.
|
||||
IF(ACGL_GLOBAL_EXTERN_DIR)
|
||||
FIND_LIBRARY(OGG_LIBRARIES NAMES ogg${COMPILE_POSTFIX} PATHS "${ACGL_GLOBAL_EXTERN_DIR}/ogg/lib" NO_DEFAULT_PATH)
|
||||
ENDIF()
|
||||
IF(NOT OGG_LIBRARIES)
|
||||
FIND_LIBRARY(OGG_LIBRARIES NAMES ogg)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
# Copy the results to the output variables.
|
||||
IF(OGG_INCLUDE_DIR AND OGG_LIBRARIES)
|
||||
SET(OGG_FOUND TRUE CACHE INTERNAL "")
|
||||
ELSE()
|
||||
SET(OGG_FOUND FALSE CACHE INTERNAL "")
|
||||
ENDIF()
|
||||
|
||||
# Report the results.
|
||||
IF(NOT OGG_FOUND)
|
||||
SET(OGG_MESSAGE "ogg was not found. Make sure OGG_INCLUDE_DIR AND OGG_LIBRARIES are set correctly.")
|
||||
IF(OGG_FIND_REQUIRED)
|
||||
MESSAGE(FATAL_ERROR "${OGG_MESSAGE}")
|
||||
ELSEIF(NOT OGG_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "${OGG_MESSAGE}")
|
||||
ENDIF()
|
||||
ELSEIF(NOT OGG_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Looking for ogg - found")
|
||||
ENDIF()
|
||||
|
||||
MESSAGE(STATUS "OGG_INCLUDE_DIR:${OGG_INCLUDE_DIR}")
|
||||
MESSAGE(STATUS "OGG_LIBRARIES:${OGG_LIBRARIES}")
|
||||
|
60
extern/acgl/cmake/FindOPENAL.cmake
vendored
Normal file
60
extern/acgl/cmake/FindOPENAL.cmake
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
# - Find OPENAL
|
||||
# Find the native OPENAL headers
|
||||
#
|
||||
# OPENAL_INCLUDE_DIR - where to find OPENAL.h, etc.
|
||||
# OPENAL_LIBRARIES - OPENAL library
|
||||
# OPENAL_FOUND - True if OPENAL found.
|
||||
|
||||
IF(OPENAL_FOUND)
|
||||
# Already in cache, be silent
|
||||
SET(OPENAL_FIND_QUIETLY TRUE)
|
||||
ENDIF()
|
||||
|
||||
IF(BUILD_OPENAL OR ACGL_GLOBAL_EXTERN_DIR_FOUND_FIRST_TIME OR BUILD_TYPE_CHANGED)
|
||||
UNSET(OPENAL_INCLUDE_DIR CACHE)
|
||||
UNSET(OPENAL_LIBRARIES CACHE)
|
||||
ENDIF()
|
||||
|
||||
IF(BUILD_OPENAL)
|
||||
SET(OPENAL_INCLUDE_DIR "${ACGL_LOCAL_EXTERN_DIR}/openal/include")
|
||||
SET(OPENAL_LIBRARIES openal${COMPILE_POSTFIX})
|
||||
ELSE()
|
||||
# Look for the header file.
|
||||
IF(ACGL_GLOBAL_EXTERN_DIR)
|
||||
FIND_PATH(OPENAL_INCLUDE_DIR NAMES AL/al.h PATHS "${ACGL_GLOBAL_EXTERN_DIR}/openal/include" NO_DEFAULT_PATH)
|
||||
ENDIF()
|
||||
IF(NOT OPENAL_INCLUDE_DIR)
|
||||
FIND_PATH(OPENAL_INCLUDE_DIR NAMES AL/al.h)
|
||||
ENDIF()
|
||||
|
||||
# Look for the library file.
|
||||
IF(ACGL_GLOBAL_EXTERN_DIR)
|
||||
FIND_LIBRARY(OPENAL_LIBRARIES NAMES openal${COMPILE_POSTFIX} PATHS "${ACGL_GLOBAL_EXTERN_DIR}/openal/lib" NO_DEFAULT_PATH)
|
||||
ENDIF()
|
||||
IF(NOT OPENAL_LIBRARIES)
|
||||
FIND_LIBRARY(OPENAL_LIBRARIES NAMES openal${COMPILE_POSTFIX})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
# Copy the results to the output variables.
|
||||
IF(OPENAL_INCLUDE_DIR AND OPENAL_LIBRARIES)
|
||||
SET(OPENAL_FOUND TRUE CACHE INTERNAL "")
|
||||
ELSE()
|
||||
SET(OPENAL_FOUND FALSE CACHE INTERNAL "")
|
||||
ENDIF()
|
||||
|
||||
# Report the results.
|
||||
IF(NOT OPENAL_FOUND)
|
||||
SET(OPENAL_MESSAGE "OPENAL was not found. Make sure OPENAL_INCLUDE_DIR AND OPENAL_LIBRARIES are set correctly.")
|
||||
IF(OPENAL_FIND_REQUIRED)
|
||||
MESSAGE(FATAL_ERROR "${OPENAL_MESSAGE}")
|
||||
ELSEIF(NOT OPENAL_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "${OPENAL_MESSAGE}")
|
||||
ENDIF()
|
||||
ELSEIF(NOT OPENAL_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Looking for OPENAL - found")
|
||||
ENDIF()
|
||||
|
||||
MESSAGE(STATUS "OPENAL_INCLUDE_DIR:${OPENAL_INCLUDE_DIR}")
|
||||
MESSAGE(STATUS "OPENAL_LIBRARIES:${OPENAL_LIBRARIES}")
|
||||
|
63
extern/acgl/cmake/FindSLB.cmake
vendored
Normal file
63
extern/acgl/cmake/FindSLB.cmake
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
# - Find SLB
|
||||
# Find the native SLB headers
|
||||
#
|
||||
# SLB_INCLUDE_DIR - where to find SLB.h, etc.
|
||||
# SLB_LIBRARIES - SLB library
|
||||
# SLB_DEFINES - SLB defines
|
||||
# SLB_FOUND - True if SLB found.
|
||||
|
||||
IF(SLB_FOUND)
|
||||
# Already in cache, be silent
|
||||
SET(SLB_FIND_QUIETLY TRUE)
|
||||
ENDIF()
|
||||
|
||||
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/DefinesSLB.txt)
|
||||
|
||||
IF(BUILD_SLB OR ACGL_GLOBAL_EXTERN_DIR_FOUND_FIRST_TIME OR BUILD_TYPE_CHANGED)
|
||||
UNSET(SLB_INCLUDE_DIR CACHE)
|
||||
UNSET(SLB_LIBRARIES CACHE)
|
||||
ENDIF()
|
||||
|
||||
IF(BUILD_SLB)
|
||||
SET(SLB_INCLUDE_DIR "${ACGL_LOCAL_EXTERN_DIR}/slb/include")
|
||||
SET(SLB_LIBRARIES SLB${COMPILE_POSTFIX})
|
||||
ELSE()
|
||||
# Look for the header file.
|
||||
IF(ACGL_GLOBAL_EXTERN_DIR)
|
||||
FIND_PATH(SLB_INCLUDE_DIR NAMES SLB/SLB.hpp PATHS "${ACGL_GLOBAL_EXTERN_DIR}/slb/include" NO_DEFAULT_PATH)
|
||||
ENDIF()
|
||||
IF(NOT SLB_INCLUDE_DIR)
|
||||
FIND_PATH(SLB_INCLUDE_DIR NAMES SLB/SLB.hpp)
|
||||
ENDIF()
|
||||
|
||||
# Look for the library file.
|
||||
IF(ACGL_GLOBAL_EXTERN_DIR)
|
||||
FIND_LIBRARY(SLB_LIBRARIES NAMES SLB${COMPILE_POSTFIX} PATHS "${ACGL_GLOBAL_EXTERN_DIR}/slb/lib" NO_DEFAULT_PATH)
|
||||
ENDIF()
|
||||
IF(NOT SLB_LIBRARIES)
|
||||
FIND_LIBRARY(SLB_LIBRARIES NAMES SLB${COMPILE_POSTFIX})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
# Copy the results to the output variables.
|
||||
IF(SLB_INCLUDE_DIR AND SLB_LIBRARIES)
|
||||
SET(SLB_FOUND TRUE CACHE INTERNAL "")
|
||||
ELSE()
|
||||
SET(SLB_FOUND FALSE CACHE INTERNAL "")
|
||||
ENDIF()
|
||||
|
||||
# Report the results.
|
||||
IF(NOT SLB_FOUND)
|
||||
SET(SLB_MESSAGE "SLB was not found. Make sure SLB_INCLUDE_DIR AND SLB_LIBRARIES are set correctly.")
|
||||
IF(SLB_FIND_REQUIRED)
|
||||
MESSAGE(FATAL_ERROR "${SLB_MESSAGE}")
|
||||
ELSEIF(NOT SLB_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "${SLB_MESSAGE}")
|
||||
ENDIF()
|
||||
ELSEIF(NOT SLB_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Looking for SLB - found")
|
||||
ENDIF()
|
||||
|
||||
MESSAGE(STATUS "SLB_INCLUDE_DIR:${SLB_INCLUDE_DIR}")
|
||||
MESSAGE(STATUS "SLB_LIBRARIES:${SLB_LIBRARIES}")
|
||||
|
63
extern/acgl/cmake/FindVORBIS.cmake
vendored
Normal file
63
extern/acgl/cmake/FindVORBIS.cmake
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
# - Find libvorbis
|
||||
# Find the native vorbis headers
|
||||
#
|
||||
# VORBIS_INCLUDE_DIR - where to find vorbisenc.h, etc.
|
||||
# VORBIS_LIBRARIES - vorbis library
|
||||
# VORBIS_DEFINES - vorbis defines
|
||||
# VORBIS_FOUND - True if vorbis found.
|
||||
|
||||
IF(VORBIS_FOUND)
|
||||
# Already in cache, be silent
|
||||
SET(VORBIS_FIND_QUIETLY TRUE)
|
||||
ENDIF()
|
||||
|
||||
#INCLUDE(${CMAKE_CURRENT_LIST_DIR}/DefinesVORBIS.txt)
|
||||
|
||||
IF(BUILD_VORBIS OR ACGL_GLOBAL_EXTERN_DIR_FOUND_FIRST_TIME OR BUILD_TYPE_CHANGED)
|
||||
UNSET(VORBIS_INCLUDE_DIR CACHE)
|
||||
UNSET(VORBIS_LIBRARIES CACHE)
|
||||
ENDIF()
|
||||
|
||||
IF(BUILD_VORBIS)
|
||||
SET(VORBIS_INCLUDE_DIR "${ACGL_LOCAL_EXTERN_DIR}/vorbis/include")
|
||||
SET(VORBIS_LIBRARIES vorbis${COMPILE_POSTFIX})
|
||||
ELSE()
|
||||
# Look for the header file.
|
||||
IF(ACGL_GLOBAL_EXTERN_DIR)
|
||||
FIND_PATH(VORBIS_INCLUDE_DIR NAMES vorbis/vorbisenc.h PATHS "${ACGL_GLOBAL_EXTERN_DIR}/vorbis/include" NO_DEFAULT_PATH)
|
||||
ENDIF()
|
||||
IF(NOT VORBIS_INCLUDE_DIR)
|
||||
FIND_PATH(VORBIS_INCLUDE_DIR NAMES vorbis/vorbisenc.h)
|
||||
ENDIF()
|
||||
|
||||
# Look for the library file.
|
||||
IF(ACGL_GLOBAL_EXTERN_DIR)
|
||||
FIND_LIBRARY(VORBIS_LIBRARIES NAMES vorbis${COMPILE_POSTFIX} PATHS "${ACGL_GLOBAL_EXTERN_DIR}/vorbis/lib" NO_DEFAULT_PATH)
|
||||
ENDIF()
|
||||
IF(NOT VORBIS_LIBRARIES)
|
||||
FIND_LIBRARY(VORBIS_LIBRARIES NAMES vorbis)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
# Copy the results to the output variables.
|
||||
IF(VORBIS_INCLUDE_DIR AND VORBIS_LIBRARIES)
|
||||
SET(VORBIS_FOUND TRUE CACHE INTERNAL "")
|
||||
ELSE()
|
||||
SET(VORBIS_FOUND FALSE CACHE INTERNAL "")
|
||||
ENDIF()
|
||||
|
||||
# Report the results.
|
||||
IF(NOT VORBIS_FOUND)
|
||||
SET(VORBIS_MESSAGE "vorbis was not found. Make sure VORBIS_INCLUDE_DIR AND VORBIS_LIBRARIES are set correctly.")
|
||||
IF(VORBIS_FIND_REQUIRED)
|
||||
MESSAGE(FATAL_ERROR "${VORBIS_MESSAGE}")
|
||||
ELSEIF(NOT VORBIS_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "${VORBIS_MESSAGE}")
|
||||
ENDIF()
|
||||
ELSEIF(NOT VORBIS_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Looking for vorbis - found")
|
||||
ENDIF()
|
||||
|
||||
MESSAGE(STATUS "VORBIS_INCLUDE_DIR:${VORBIS_INCLUDE_DIR}")
|
||||
MESSAGE(STATUS "VORBIS_LIBRARIES:${VORBIS_LIBRARIES}")
|
||||
|
193
extern/acgl/cmake/GlobalAndLocalExternACGL.txt
vendored
Normal file
193
extern/acgl/cmake/GlobalAndLocalExternACGL.txt
vendored
Normal file
@ -0,0 +1,193 @@
|
||||
IF(NOT DEFINED GLOBAL_AND_LOCAL_EXTERN_ACGL)
|
||||
SET(GLOBAL_AND_LOCAL_EXTERN_ACGL TRUE)
|
||||
|
||||
# Define global and local acgl dependency locations
|
||||
IF(NOT DEFINED ACGL_LOCAL_EXTERN_DIR)
|
||||
SET(ACGL_LOCAL_EXTERN_DIR "${CMAKE_CURRENT_SOURCE_DIR}/extern")
|
||||
ENDIF()
|
||||
|
||||
IF(USE_LOCAL_ACGL)
|
||||
FIND_PATH(LOCAL_EXTERN_ACGL_DIR NAMES acgl PATHS "${ACGL_LOCAL_EXTERN_DIR}" NO_DEFAULT_PATH)
|
||||
IF(LOCAL_EXTERN_ACGL_DIR)
|
||||
SET(BUILD_ACGL TRUE)
|
||||
ELSE()
|
||||
SET(NEED_ACGL_GLOBAL_EXTERN_DIR TRUE)
|
||||
ENDIF()
|
||||
UNSET(LOCAL_EXTERN_ACGL_DIR CACHE)
|
||||
ENDIF()
|
||||
|
||||
IF(USE_LOCAL_ANGELSCRIPT)
|
||||
FIND_PATH(LOCAL_EXTERN_ANGELSCRIPT_DIR NAMES angelscript PATHS "${ACGL_LOCAL_EXTERN_DIR}" NO_DEFAULT_PATH)
|
||||
IF(LOCAL_EXTERN_ANGELSCRIPT_DIR)
|
||||
SET(BUILD_ANGELSCRIPT TRUE)
|
||||
ELSE()
|
||||
SET(NEED_ANGELSCRIPT_GLOBAL_EXTERN_DIR TRUE)
|
||||
ENDIF()
|
||||
UNSET(LOCAL_EXTERN_ANGELSCRIPT_DIR CACHE)
|
||||
ENDIF()
|
||||
|
||||
IF(USE_LOCAL_BOX2D)
|
||||
FIND_PATH(LOCAL_EXTERN_BOX2D_DIR NAMES box2d PATHS "${ACGL_LOCAL_EXTERN_DIR}" NO_DEFAULT_PATH)
|
||||
IF(LOCAL_EXTERN_BOX2D_DIR)
|
||||
SET(BUILD_BOX2D TRUE)
|
||||
ELSE()
|
||||
SET(NEED_BOX2D_GLOBAL_EXTERN_DIR TRUE)
|
||||
ENDIF()
|
||||
UNSET(LOCAL_EXTERN_BOX2D_DIR CACHE)
|
||||
ENDIF()
|
||||
|
||||
IF(USE_LOCAL_BULLET)
|
||||
FIND_PATH(LOCAL_EXTERN_BULLET_DIR NAMES bullet PATHS "${ACGL_LOCAL_EXTERN_DIR}" NO_DEFAULT_PATH)
|
||||
IF(LOCAL_EXTERN_BULLET_DIR)
|
||||
SET(BUILD_BULLET TRUE)
|
||||
ELSE()
|
||||
SET(NEED_BULLET_GLOBAL_EXTERN_DIR TRUE)
|
||||
ENDIF()
|
||||
UNSET(LOCAL_EXTERN_BULLET_DIR CACHE)
|
||||
ENDIF()
|
||||
|
||||
IF(USE_LOCAL_FREETYPE)
|
||||
FIND_PATH(LOCAL_EXTERN_FREETYPE_DIR NAMES freetype PATHS "${ACGL_LOCAL_EXTERN_DIR}" NO_DEFAULT_PATH)
|
||||
IF(LOCAL_EXTERN_FREETYPE_DIR)
|
||||
SET(BUILD_FREETYPE TRUE)
|
||||
ELSE()
|
||||
SET(NEED_ACGL_GLOBAL_EXTERN_DIR TRUE)
|
||||
ENDIF()
|
||||
UNSET(LOCAL_EXTERN_FREETYPE_DIR CACHE)
|
||||
ENDIF()
|
||||
|
||||
IF(USE_LOCAL_GLEW)
|
||||
FIND_PATH(LOCAL_EXTERN_GLEW_DIR NAMES glew PATHS "${ACGL_LOCAL_EXTERN_DIR}" NO_DEFAULT_PATH)
|
||||
IF(LOCAL_EXTERN_GLEW_DIR)
|
||||
SET(BUILD_GLEW TRUE)
|
||||
ELSE()
|
||||
SET(NEED_ACGL_GLOBAL_EXTERN_DIR TRUE)
|
||||
ENDIF()
|
||||
UNSET(LOCAL_EXTERN_GLEW_DIR CACHE)
|
||||
ENDIF()
|
||||
|
||||
IF(USE_LOCAL_GLM)
|
||||
FIND_PATH(LOCAL_EXTERN_GLM_DIR NAMES glm PATHS "${ACGL_LOCAL_EXTERN_DIR}" NO_DEFAULT_PATH)
|
||||
IF(LOCAL_EXTERN_GLM_DIR)
|
||||
SET(BUILD_GLM TRUE)
|
||||
ELSE()
|
||||
SET(NEED_ACGL_GLOBAL_EXTERN_DIR TRUE)
|
||||
ENDIF()
|
||||
UNSET(LOCAL_EXTERN_GLM_DIR CACHE)
|
||||
ENDIF()
|
||||
|
||||
IF(USE_LOCAL_GOOGLETEST)
|
||||
FIND_PATH(LOCAL_EXTERN_GOOGLETEST_DIR NAMES googletest PATHS "${ACGL_LOCAL_EXTERN_DIR}" NO_DEFAULT_PATH)
|
||||
IF(LOCAL_EXTERN_GOOGLETEST_DIR)
|
||||
SET(BUILD_GOOGLETEST TRUE)
|
||||
ELSE()
|
||||
SET(NEED_ACGL_GLOBAL_EXTERN_DIR TRUE)
|
||||
ENDIF()
|
||||
UNSET(LOCAL_EXTERN_GOOGLETEST_DIR CACHE)
|
||||
ENDIF()
|
||||
|
||||
IF(USE_LOCAL_LUA)
|
||||
FIND_PATH(LOCAL_EXTERN_LUA_DIR NAMES lua PATHS "${ACGL_LOCAL_EXTERN_DIR}" NO_DEFAULT_PATH)
|
||||
IF(LOCAL_EXTERN_LUA_DIR)
|
||||
SET(BUILD_LUA TRUE)
|
||||
ELSE()
|
||||
SET(NEED_ACGL_GLOBAL_EXTERN_DIR TRUE)
|
||||
ENDIF()
|
||||
UNSET(LOCAL_EXTERN_LUA_DIR CACHE)
|
||||
ENDIF()
|
||||
|
||||
IF(USE_LOCAL_OGG)
|
||||
FIND_PATH(LOCAL_EXTERN_OGG_DIR NAMES ogg PATHS "${ACGL_LOCAL_EXTERN_DIR}" NO_DEFAULT_PATH)
|
||||
IF(LOCAL_EXTERN_OGG_DIR)
|
||||
SET(BUILD_OGG TRUE)
|
||||
ELSE()
|
||||
SET(NEED_OGG_GLOBAL_EXTERN_DIR TRUE)
|
||||
ENDIF()
|
||||
UNSET(LOCAL_EXTERN_OGG_DIR CACHE)
|
||||
ENDIF()
|
||||
|
||||
IF(USE_LOCAL_OPENAL)
|
||||
FIND_PATH(LOCAL_EXTERN_OPENAL_DIR NAMES openal PATHS "${ACGL_LOCAL_EXTERN_DIR}" NO_DEFAULT_PATH)
|
||||
IF(LOCAL_EXTERN_OPENAL_DIR)
|
||||
SET(BUILD_OPENAL TRUE)
|
||||
ELSE()
|
||||
SET(NEED_ACGL_GLOBAL_EXTERN_DIR TRUE)
|
||||
ENDIF()
|
||||
UNSET(LOCAL_EXTERN_OPENAL_DIR CACHE)
|
||||
ENDIF()
|
||||
|
||||
IF(USE_LOCAL_SLB)
|
||||
FIND_PATH(LOCAL_EXTERN_SLB_DIR NAMES slb PATHS "${ACGL_LOCAL_EXTERN_DIR}" NO_DEFAULT_PATH)
|
||||
IF(LOCAL_EXTERN_SLB_DIR)
|
||||
SET(BUILD_SLB TRUE)
|
||||
ELSE()
|
||||
SET(NEED_ACGL_GLOBAL_EXTERN_DIR TRUE)
|
||||
ENDIF()
|
||||
UNSET(LOCAL_EXTERN_SLB_DIR CACHE)
|
||||
ENDIF()
|
||||
|
||||
IF(USE_LOCAL_VORBIS)
|
||||
FIND_PATH(LOCAL_EXTERN_VORBIS_DIR NAMES vorbis PATHS "${ACGL_LOCAL_EXTERN_DIR}" NO_DEFAULT_PATH)
|
||||
IF(LOCAL_EXTERN_VORBIS_DIR)
|
||||
SET(BUILD_VORBIS TRUE)
|
||||
ELSE()
|
||||
SET(NEED_VORBIS_GLOBAL_EXTERN_DIR TRUE)
|
||||
ENDIF()
|
||||
UNSET(LOCAL_EXTERN_VORBIS_DIR CACHE)
|
||||
ENDIF()
|
||||
|
||||
IF(NEED_ACGL_GLOBAL_EXTERN_DIR)
|
||||
FIND_PATH(ACGL_GLOBAL_EXTERN_DIR NAMES acgl PATHS "${CMAKE_CURRENT_SOURCE_DIR}/../.." "${CMAKE_CURRENT_SOURCE_DIR}/../../SDK" NO_DEFAULT_PATH)
|
||||
ELSE()
|
||||
UNSET(ACGL_GLOBAL_EXTERN_DIR CACHE)
|
||||
UNSET(ACGL_GLOBAL_EXTERN_DIR_FOUND_FIRST_TIME CACHE)
|
||||
ENDIF()
|
||||
|
||||
IF(ACGL_GLOBAL_EXTERN_DIR AND NOT DEFINED ACGL_GLOBAL_EXTERN_DIR_FOUND_FIRST_TIME)
|
||||
SET(ACGL_GLOBAL_EXTERN_DIR_FOUND_FIRST_TIME TRUE CACHE INTERNAL "")
|
||||
ELSEIF(ACGL_GLOBAL_EXTERN_DIR_FOUND_FIRST_TIME)
|
||||
SET(ACGL_GLOBAL_EXTERN_DIR_FOUND_FIRST_TIME FALSE CACHE INTERNAL "")
|
||||
ENDIF()
|
||||
|
||||
IF(BUILD_ACGL)
|
||||
ADD_SUBDIRECTORY("${ACGL_LOCAL_EXTERN_DIR}/acgl")
|
||||
ENDIF()
|
||||
IF(BUILD_ANGELSCRIPT)
|
||||
ADD_SUBDIRECTORY("${ACGL_LOCAL_EXTERN_DIR}/angelscript")
|
||||
ENDIF()
|
||||
IF(BUILD_BOX2D)
|
||||
ADD_SUBDIRECTORY("${ACGL_LOCAL_EXTERN_DIR}/box2d")
|
||||
ENDIF()
|
||||
IF(BUILD_FREETYPE)
|
||||
ADD_SUBDIRECTORY("${ACGL_LOCAL_EXTERN_DIR}/freetype")
|
||||
ENDIF()
|
||||
IF(BUILD_BULLET)
|
||||
ADD_SUBDIRECTORY("${ACGL_LOCAL_EXTERN_DIR}/bullet")
|
||||
ENDIF()
|
||||
IF(BUILD_GLEW)
|
||||
ADD_SUBDIRECTORY("${ACGL_LOCAL_EXTERN_DIR}/glew")
|
||||
ENDIF()
|
||||
IF(BUILD_GLM)
|
||||
ADD_SUBDIRECTORY("${ACGL_LOCAL_EXTERN_DIR}/glm")
|
||||
ENDIF()
|
||||
IF(BUILD_GOOGLETEST)
|
||||
ADD_SUBDIRECTORY("${ACGL_LOCAL_EXTERN_DIR}/googletest")
|
||||
ENDIF()
|
||||
IF(BUILD_LUA)
|
||||
ADD_SUBDIRECTORY("${ACGL_LOCAL_EXTERN_DIR}/lua")
|
||||
ENDIF()
|
||||
IF(BUILD_OGG)
|
||||
ADD_SUBDIRECTORY("${ACGL_LOCAL_EXTERN_DIR}/ogg")
|
||||
ENDIF()
|
||||
IF(BUILD_OPENAL)
|
||||
ADD_SUBDIRECTORY("${ACGL_LOCAL_EXTERN_DIR}/openal")
|
||||
ENDIF()
|
||||
IF(BUILD_SLB)
|
||||
ADD_SUBDIRECTORY("${ACGL_LOCAL_EXTERN_DIR}/slb")
|
||||
ENDIF()
|
||||
IF(BUILD_VORBIS)
|
||||
ADD_SUBDIRECTORY("${ACGL_LOCAL_EXTERN_DIR}/vorbis")
|
||||
ENDIF()
|
||||
|
||||
ENDIF()
|
||||
|
216
extern/acgl/cmake/internal_utils.cmake
vendored
Normal file
216
extern/acgl/cmake/internal_utils.cmake
vendored
Normal file
@ -0,0 +1,216 @@
|
||||
# Defines functions and macros useful for building Google Test and
|
||||
# Google Mock.
|
||||
#
|
||||
# Note:
|
||||
#
|
||||
# - This file will be run twice when building Google Mock (once via
|
||||
# Google Test's CMakeLists.txt, and once via Google Mock's).
|
||||
# Therefore it shouldn't have any side effects other than defining
|
||||
# the functions and macros.
|
||||
#
|
||||
# - The functions/macros defined in this file may depend on Google
|
||||
# Test and Google Mock's option() definitions, and thus must be
|
||||
# called *after* the options have been defined.
|
||||
|
||||
# Tweaks CMake's default compiler/linker settings to suit Google Test's needs.
|
||||
#
|
||||
# This must be a macro(), as inside a function string() can only
|
||||
# update variables in the function scope.
|
||||
macro(fix_default_compiler_settings_)
|
||||
if (MSVC)
|
||||
# For MSVC, CMake sets certain flags to defaults we want to override.
|
||||
# This replacement code is taken from sample in the CMake Wiki at
|
||||
# http://www.cmake.org/Wiki/CMake_FAQ#Dynamic_Replace.
|
||||
foreach (flag_var
|
||||
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
||||
if (NOT BUILD_SHARED_LIBS AND NOT gtest_force_shared_crt)
|
||||
# When Google Test is built as a shared library, it should also use
|
||||
# shared runtime libraries. Otherwise, it may end up with multiple
|
||||
# copies of runtime library data in different modules, resulting in
|
||||
# hard-to-find crashes. When it is built as a static library, it is
|
||||
# preferable to use CRT as static libraries, as we don't have to rely
|
||||
# on CRT DLLs being available. CMake always defaults to using shared
|
||||
# CRT libraries, so we override that default here.
|
||||
string(REPLACE "/MD" "-MT" ${flag_var} "${${flag_var}}")
|
||||
endif()
|
||||
|
||||
# We prefer more strict warning checking for building Google Test.
|
||||
# Replaces /W3 with /W4 in defaults.
|
||||
string(REPLACE "/W3" "-W4" ${flag_var} "${${flag_var}}")
|
||||
endforeach()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# Defines the compiler/linker flags used to build Google Test and
|
||||
# Google Mock. You can tweak these definitions to suit your need. A
|
||||
# variable's value is empty before it's explicitly assigned to.
|
||||
macro(config_compiler_and_linker)
|
||||
if (NOT gtest_disable_pthreads)
|
||||
# Defines CMAKE_USE_PTHREADS_INIT and CMAKE_THREAD_LIBS_INIT.
|
||||
find_package(Threads)
|
||||
endif()
|
||||
|
||||
fix_default_compiler_settings_()
|
||||
if (MSVC)
|
||||
# Newlines inside flags variables break CMake's NMake generator.
|
||||
# TODO(vladl@google.com): Add -RTCs and -RTCu to debug builds.
|
||||
set(cxx_base_flags "-GS -W4 -WX -wd4127 -wd4251 -wd4275 -nologo -J -Zi")
|
||||
set(cxx_base_flags "${cxx_base_flags} -D_UNICODE -DUNICODE -DWIN32 -D_WIN32")
|
||||
set(cxx_base_flags "${cxx_base_flags} -DSTRICT -DWIN32_LEAN_AND_MEAN")
|
||||
set(cxx_exception_flags "-EHsc -D_HAS_EXCEPTIONS=1")
|
||||
set(cxx_no_exception_flags "-D_HAS_EXCEPTIONS=0")
|
||||
set(cxx_no_rtti_flags "-GR-")
|
||||
elseif (CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(cxx_base_flags "-Wall -Wshadow")
|
||||
set(cxx_exception_flags "-fexceptions")
|
||||
set(cxx_no_exception_flags "-fno-exceptions")
|
||||
# Until version 4.3.2, GCC doesn't define a macro to indicate
|
||||
# whether RTTI is enabled. Therefore we define GTEST_HAS_RTTI
|
||||
# explicitly.
|
||||
set(cxx_no_rtti_flags "-fno-rtti -DGTEST_HAS_RTTI=0")
|
||||
set(cxx_strict_flags "-Wextra")
|
||||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
|
||||
set(cxx_exception_flags "-features=except")
|
||||
# Sun Pro doesn't provide macros to indicate whether exceptions and
|
||||
# RTTI are enabled, so we define GTEST_HAS_* explicitly.
|
||||
set(cxx_no_exception_flags "-features=no%except -DGTEST_HAS_EXCEPTIONS=0")
|
||||
set(cxx_no_rtti_flags "-features=no%rtti -DGTEST_HAS_RTTI=0")
|
||||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "VisualAge" OR
|
||||
CMAKE_CXX_COMPILER_ID STREQUAL "XL")
|
||||
# CMake 2.8 changes Visual Age's compiler ID to "XL".
|
||||
set(cxx_exception_flags "-qeh")
|
||||
set(cxx_no_exception_flags "-qnoeh")
|
||||
# Until version 9.0, Visual Age doesn't define a macro to indicate
|
||||
# whether RTTI is enabled. Therefore we define GTEST_HAS_RTTI
|
||||
# explicitly.
|
||||
set(cxx_no_rtti_flags "-qnortti -DGTEST_HAS_RTTI=0")
|
||||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "HP")
|
||||
set(cxx_base_flags "-AA -mt")
|
||||
set(cxx_exception_flags "-DGTEST_HAS_EXCEPTIONS=1")
|
||||
set(cxx_no_exception_flags "+noeh -DGTEST_HAS_EXCEPTIONS=0")
|
||||
# RTTI can not be disabled in HP aCC compiler.
|
||||
set(cxx_no_rtti_flags "")
|
||||
endif()
|
||||
|
||||
if (CMAKE_USE_PTHREADS_INIT) # The pthreads library is available and allowed.
|
||||
set(cxx_base_flags "${cxx_base_flags} -DGTEST_HAS_PTHREAD=1")
|
||||
else()
|
||||
set(cxx_base_flags "${cxx_base_flags} -DGTEST_HAS_PTHREAD=0")
|
||||
endif()
|
||||
|
||||
# For building gtest's own tests and samples.
|
||||
set(cxx_exception "${CMAKE_CXX_FLAGS} ${cxx_base_flags} ${cxx_exception_flags}")
|
||||
set(cxx_no_exception
|
||||
"${CMAKE_CXX_FLAGS} ${cxx_base_flags} ${cxx_no_exception_flags}")
|
||||
set(cxx_default "${cxx_exception}")
|
||||
set(cxx_no_rtti "${cxx_default} ${cxx_no_rtti_flags}")
|
||||
set(cxx_use_own_tuple "${cxx_default} -DGTEST_USE_OWN_TR1_TUPLE=1")
|
||||
|
||||
# For building the gtest libraries.
|
||||
set(cxx_strict "${cxx_default} ${cxx_strict_flags}")
|
||||
endmacro()
|
||||
|
||||
# Defines the gtest & gtest_main libraries. User tests should link
|
||||
# with one of them.
|
||||
function(cxx_library_with_type name type cxx_flags)
|
||||
# type can be either STATIC or SHARED to denote a static or shared library.
|
||||
# ARGN refers to additional arguments after 'cxx_flags'.
|
||||
add_library(${name} ${type} ${ARGN})
|
||||
set_target_properties(${name}
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "${cxx_flags}")
|
||||
if (BUILD_SHARED_LIBS OR type STREQUAL "SHARED")
|
||||
set_target_properties(${name}
|
||||
PROPERTIES
|
||||
COMPILE_DEFINITIONS "GTEST_CREATE_SHARED_LIBRARY=1")
|
||||
endif()
|
||||
if (CMAKE_USE_PTHREADS_INIT)
|
||||
target_link_libraries(${name} ${CMAKE_THREAD_LIBS_INIT})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
########################################################################
|
||||
#
|
||||
# Helper functions for creating build targets.
|
||||
|
||||
function(cxx_shared_library name cxx_flags)
|
||||
cxx_library_with_type(${name} SHARED "${cxx_flags}" ${ARGN})
|
||||
endfunction()
|
||||
|
||||
function(cxx_library name cxx_flags)
|
||||
cxx_library_with_type(${name} "" "${cxx_flags}" ${ARGN})
|
||||
endfunction()
|
||||
|
||||
# cxx_executable_with_flags(name cxx_flags libs srcs...)
|
||||
#
|
||||
# creates a named C++ executable that depends on the given libraries and
|
||||
# is built from the given source files with the given compiler flags.
|
||||
function(cxx_executable_with_flags name cxx_flags libs)
|
||||
add_executable(${name} ${ARGN})
|
||||
if (cxx_flags)
|
||||
set_target_properties(${name}
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "${cxx_flags}")
|
||||
endif()
|
||||
if (BUILD_SHARED_LIBS)
|
||||
set_target_properties(${name}
|
||||
PROPERTIES
|
||||
COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1")
|
||||
endif()
|
||||
# To support mixing linking in static and dynamic libraries, link each
|
||||
# library in with an extra call to target_link_libraries.
|
||||
foreach (lib "${libs}")
|
||||
target_link_libraries(${name} ${lib})
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
# cxx_executable(name dir lib srcs...)
|
||||
#
|
||||
# creates a named target that depends on the given libs and is built
|
||||
# from the given source files. dir/name.cc is implicitly included in
|
||||
# the source file list.
|
||||
function(cxx_executable name dir libs)
|
||||
cxx_executable_with_flags(
|
||||
${name} "${cxx_default}" "${libs}" "${dir}/${name}.cc" ${ARGN})
|
||||
endfunction()
|
||||
|
||||
# Sets PYTHONINTERP_FOUND and PYTHON_EXECUTABLE.
|
||||
find_package(PythonInterp)
|
||||
|
||||
# cxx_test_with_flags(name cxx_flags libs srcs...)
|
||||
#
|
||||
# creates a named C++ test that depends on the given libs and is built
|
||||
# from the given source files with the given compiler flags.
|
||||
function(cxx_test_with_flags name cxx_flags libs)
|
||||
cxx_executable_with_flags(${name} "${cxx_flags}" "${libs}" ${ARGN})
|
||||
add_test(${name} ${name})
|
||||
endfunction()
|
||||
|
||||
# cxx_test(name libs srcs...)
|
||||
#
|
||||
# creates a named test target that depends on the given libs and is
|
||||
# built from the given source files. Unlike cxx_test_with_flags,
|
||||
# test/name.cc is already implicitly included in the source file list.
|
||||
function(cxx_test name libs)
|
||||
cxx_test_with_flags("${name}" "${cxx_default}" "${libs}"
|
||||
"test/${name}.cc" ${ARGN})
|
||||
endfunction()
|
||||
|
||||
# py_test(name)
|
||||
#
|
||||
# creates a Python test with the given name whose main module is in
|
||||
# test/name.py. It does nothing if Python is not installed.
|
||||
function(py_test name)
|
||||
# We are not supporting Python tests on Linux yet as they consider
|
||||
# all Linux environments to be google3 and try to use google3 features.
|
||||
if (PYTHONINTERP_FOUND)
|
||||
# ${CMAKE_BINARY_DIR} is known at configuration time, so we can
|
||||
# directly bind it from cmake. ${CTEST_CONFIGURATION_TYPE} is known
|
||||
# only at ctest runtime (by calling ctest -c <Configuration>), so
|
||||
# we have to escape $ to delay variable substitution here.
|
||||
add_test(${name}
|
||||
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py
|
||||
--build_dir=${CMAKE_CURRENT_BINARY_DIR}/\${CTEST_CONFIGURATION_TYPE})
|
||||
endif()
|
||||
endfunction()
|
156
extern/acgl/include/ACGL/ACGL.hh
vendored
Normal file
156
extern/acgl/include/ACGL/ACGL.hh
vendored
Normal file
@ -0,0 +1,156 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef ACGL_ACGL_HH
|
||||
#define ACGL_ACGL_HH
|
||||
|
||||
/*!
|
||||
* Include this in all ACGL (header)-files. It will include stuff that is used in
|
||||
* almost every file:
|
||||
* the used datatypes
|
||||
* including shared/weak pointers!
|
||||
* macros and defines used at compile-time
|
||||
* logging
|
||||
*
|
||||
* Also the librarys init function is defined here.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* ACGL needs shared and weak pointers that behave like the C++11 smartpointers.
|
||||
* The C++11, TR1 and boost variants should all be fine, you can also plug-in
|
||||
* your own compatible pointers here.
|
||||
*
|
||||
* Place them in the ptr:: namespace with aliases.
|
||||
*
|
||||
* A detection for TR1 is missing, it is assumed that a pre-C++11 compiler has TR1.
|
||||
* In case of porting this to a non-C++11/non-TR1 compiler add a check and e.g.
|
||||
* add the boost shared and smart pointers:
|
||||
*
|
||||
* #include <boost...>
|
||||
* namespace ptr = boost::tr1;
|
||||
*
|
||||
* Or roll your own pointers (in this case, add a compileflag and default to the
|
||||
* std pointers!):
|
||||
*
|
||||
* # include <myOwnAwsomeSharedPointer.hh>
|
||||
* namespace ptr = ACGL::Base;
|
||||
*
|
||||
*/
|
||||
|
||||
// defines a one-macro version number for easy compare functions: e.g. gcc 4.6.2 -> 406020
|
||||
// see http://sourceforge.net/apps/mediawiki/predef/index.php?title=Compilers for macros to detect compilers
|
||||
#if defined(__GNUC__)
|
||||
# if defined(__GNUC_PATCHLEVEL__)
|
||||
# define __GNUC_VERSION__ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
|
||||
# else
|
||||
# define __GNUC_VERSION__ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100)
|
||||
# endif
|
||||
#else
|
||||
# define __GNUC_VERSION__ 0
|
||||
#endif
|
||||
|
||||
// defines a one-macro version number for easy compare functions: e.g. gcc 4.6.2 -> 406020
|
||||
// see http://sourceforge.net/apps/mediawiki/predef/index.php?title=Compilers for macros to detect compilers
|
||||
#if defined(__GNUC__)
|
||||
# if defined(__GNUC_PATCHLEVEL__)
|
||||
# define __GNUC_VERSION__ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
|
||||
# else
|
||||
# define __GNUC_VERSION__ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100)
|
||||
# endif
|
||||
#else
|
||||
# define __GNUC_VERSION__ 0
|
||||
#endif
|
||||
|
||||
#if ((__cplusplus >= 201103L) || (__STDC_VERSION__ >= 201112L) || defined(__GXX_EXPERIMENTAL_CXX0X__))
|
||||
// last C++11 draft or final C++11 standart or C++11 via -std=c++0x on gcc:
|
||||
# include <memory>
|
||||
namespace ptr = std;
|
||||
# define ACGL_UNIQUE_POINTER_SUPPORTED 1
|
||||
# define CORRECT_PTR_INCLUDES_FOUND
|
||||
#endif
|
||||
|
||||
#if (defined (__clang__))
|
||||
// newer llvms on MacOS need this version:
|
||||
# include <memory>
|
||||
namespace ptr = std;
|
||||
# define ACGL_UNIQUE_POINTER_SUPPORTED 1
|
||||
# define CORRECT_PTR_INCLUDES_FOUND
|
||||
#endif
|
||||
|
||||
#if (!defined(CORRECT_PTR_INCLUDES_FOUND) && ((__GNUC_VERSION__ >= 40400) ))
|
||||
// gcc 4.4 or newer without -std=c++0x or clang++
|
||||
# include <tr1/memory>
|
||||
namespace ptr = std::tr1;
|
||||
# define ACGL_UNIQUE_POINTER_SUPPORTED 0
|
||||
# define CORRECT_PTR_INCLUDES_FOUND
|
||||
#endif
|
||||
|
||||
|
||||
#if (!defined(CORRECT_PTR_INCLUDES_FOUND) && (_MSC_VER >= 1600))
|
||||
// VStudio 2010 supports some C++11 features
|
||||
# include <memory>
|
||||
namespace ptr = std;
|
||||
# define ACGL_UNIQUE_POINTER_SUPPORTED 1
|
||||
# define CORRECT_PTR_INCLUDES_FOUND
|
||||
#endif
|
||||
|
||||
|
||||
#if (!defined(CORRECT_PTR_INCLUDES_FOUND) && (_MSC_VER >= 1500))
|
||||
// VStudio 2008 supports some C++11 features
|
||||
# include <memory>
|
||||
namespace ptr = std::tr1;
|
||||
# define ACGL_UNIQUE_POINTER_SUPPORTED 0
|
||||
# define CORRECT_PTR_INCLUDES_FOUND
|
||||
#endif
|
||||
|
||||
|
||||
#if (!defined(CORRECT_PTR_INCLUDES_FOUND) && defined(__INTEL_COMPILER))
|
||||
// intel icpc
|
||||
# include <memory>
|
||||
namespace ptr = std;
|
||||
# define ACGL_UNIQUE_POINTER_SUPPORTED 0
|
||||
# define CORRECT_PTR_INCLUDES_FOUND
|
||||
#endif
|
||||
|
||||
|
||||
#if (!defined CORRECT_PTR_INCLUDES_FOUND)
|
||||
// guessing is needed
|
||||
# warning "can't detect C++ version or shared pointer variant supported by this compiler -> guessing"
|
||||
// hope for TR1 equivalents
|
||||
# include <tr1/memory>
|
||||
namespace ptr = std::tr1;
|
||||
# define ACGL_UNIQUE_POINTER_SUPPORTED 0
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#include <ACGL/Base/CompileTimeSettings.hh>
|
||||
#include <ACGL/Base/Macros.hh>
|
||||
#include <ACGL/Types.hh>
|
||||
#include <ACGL/Utils/Log.hh>
|
||||
|
||||
namespace ACGL
|
||||
{
|
||||
|
||||
/*
|
||||
* This should get called as soon as a valid OpenGL context exists,
|
||||
* it will init glew (if used) or the internal GL function loader.
|
||||
* Call this before calling any OpenGL functions or OpenGL related
|
||||
* ACGL stuff.
|
||||
*
|
||||
* Returns false if a critical error occured, in that case the ACGL behavior is
|
||||
* not defined.
|
||||
*
|
||||
* parameter forDebugging: if true, register a debug callback for OpenGL and simulate
|
||||
* a debug context (slow) in case the application is not running in a native debug
|
||||
* context.
|
||||
*/
|
||||
bool init( bool forceDebuggingContext = true );
|
||||
|
||||
}
|
||||
|
||||
#endif // ACGL_ACGL_HH
|
||||
|
405
extern/acgl/include/ACGL/Animations/Animation.hh
vendored
Normal file
405
extern/acgl/include/ACGL/Animations/Animation.hh
vendored
Normal file
@ -0,0 +1,405 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
// See http://www.graphics.rwth-aachen.de/redmine/projects/acgl/wiki/ACGL_compile_time_settings
|
||||
// for a comment what unsupported means.
|
||||
#ifdef ACGL_INCLUDE_UNSUPPORTED
|
||||
|
||||
#ifndef ACGL_ANIMATIONS_ANIMATION_HH
|
||||
#define ACGL_ANIMATIONS_ANIMATION_HH
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
#include <ACGL/Types.hh>
|
||||
#include <ACGL/Base/Macros.hh>
|
||||
#include <ACGL/Animations/EaseFunctions.hh>
|
||||
#include <ACGL/Animations/Interpolator.hh>
|
||||
|
||||
#include <list>
|
||||
#include <queue>
|
||||
|
||||
namespace ACGL{
|
||||
namespace Animations{
|
||||
|
||||
// Animation *************************************************************************************
|
||||
class Animation
|
||||
{
|
||||
public:
|
||||
enum RepeatMode {Endless = -1, EndlessNoRepeat = -2};
|
||||
|
||||
Animation() :
|
||||
mInited(false),
|
||||
mStopped(false) {}
|
||||
virtual ~Animation() {}
|
||||
|
||||
virtual void init() = 0;
|
||||
virtual long update(uint_t msec) = 0;
|
||||
virtual bool finished() = 0;
|
||||
|
||||
inline const bool& isInited() const;
|
||||
inline const bool& isStopped() const;
|
||||
|
||||
inline void restart();
|
||||
inline void stop();
|
||||
protected:
|
||||
|
||||
bool mInited;
|
||||
bool mStopped;
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(Animation)
|
||||
|
||||
typedef std::list<SharedAnimation> AnimationList;
|
||||
typedef std::queue<SharedAnimation> AnimationQueue;
|
||||
|
||||
class AnimationManager
|
||||
{
|
||||
public:
|
||||
static void push(const SharedAnimation& _animation);
|
||||
static void update(uint_t _msec);
|
||||
|
||||
static void cleanUp();
|
||||
protected:
|
||||
private:
|
||||
static AnimationList mAnimations;
|
||||
|
||||
};
|
||||
|
||||
class AnimationEventCallbackFunction
|
||||
{
|
||||
public:
|
||||
typedef void (*Function)(uint_t);
|
||||
|
||||
AnimationEventCallbackFunction(Function _pFunction,uint_t _id) :
|
||||
mpFunction(_pFunction),
|
||||
mId(_id) { }
|
||||
|
||||
inline void call()
|
||||
{
|
||||
mpFunction(mId);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Function mpFunction;
|
||||
uint_t mId;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class AnimationEventCallbackMemberFunction
|
||||
{
|
||||
public:
|
||||
typedef void (T::*Function)(uint_t);
|
||||
|
||||
AnimationEventCallbackMemberFunction(const T* _pTarget, Function _pFunction,uint_t _id) :
|
||||
mpTarget(_pTarget),
|
||||
mpFunction(_pFunction),
|
||||
mId(_id) { }
|
||||
|
||||
inline void call()
|
||||
{
|
||||
mpTarget->mpFunction(mId);
|
||||
}
|
||||
|
||||
private:
|
||||
const T* mpTarget;
|
||||
Function mpFunction;
|
||||
uint_t mId;
|
||||
};
|
||||
|
||||
// AnimationEvent *************************************************************************************
|
||||
|
||||
template <class Callback>
|
||||
class AnimationEvent : public Animation
|
||||
{
|
||||
public:
|
||||
AnimationEvent(const Callback& _callback) :
|
||||
Animation(),
|
||||
mCallback(_callback),
|
||||
mEventCalled(false) { }
|
||||
|
||||
virtual void init()
|
||||
{
|
||||
mEventCalled = false;
|
||||
|
||||
mInited = true;
|
||||
}
|
||||
|
||||
virtual long update(uint_t _msec)
|
||||
{
|
||||
mCallback.call();
|
||||
mEventCalled = true;
|
||||
|
||||
return _msec;
|
||||
}
|
||||
|
||||
virtual bool finished()
|
||||
{
|
||||
return mEventCalled;
|
||||
}
|
||||
|
||||
Callback& getCallback()
|
||||
{
|
||||
return mCallback;
|
||||
}
|
||||
|
||||
private:
|
||||
Callback mCallback;
|
||||
|
||||
bool mEventCalled;
|
||||
};
|
||||
|
||||
|
||||
// AnimationWait *************************************************************************************
|
||||
|
||||
class AnimationWait : public Animation
|
||||
{
|
||||
public:
|
||||
AnimationWait(const uint_t _duration);
|
||||
|
||||
virtual void init();
|
||||
virtual long update(uint_t _msec);
|
||||
virtual bool finished();
|
||||
|
||||
private:
|
||||
long mTimeLeft;
|
||||
long mDuration;
|
||||
};
|
||||
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(AnimationWait)
|
||||
|
||||
// AnimationSequential *************************************************************************************
|
||||
|
||||
class AnimationSequential : public Animation
|
||||
{
|
||||
public:
|
||||
AnimationSequential(const int_t _loops = 0);
|
||||
virtual ~AnimationSequential();
|
||||
|
||||
virtual void init();
|
||||
virtual long update(uint_t _msec);
|
||||
virtual bool finished();
|
||||
|
||||
void push_animation(const SharedAnimation& _animation);
|
||||
|
||||
private:
|
||||
int_t mLoops;
|
||||
|
||||
AnimationList::iterator mCurrentPosition;
|
||||
AnimationList mAnimations;
|
||||
};
|
||||
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(AnimationSequential)
|
||||
|
||||
// AnimationParallel *************************************************************************************
|
||||
|
||||
class AnimationParallel : public Animation
|
||||
{
|
||||
public:
|
||||
AnimationParallel(const int_t _loops = 0);
|
||||
virtual ~AnimationParallel();
|
||||
|
||||
virtual void init();
|
||||
virtual long update(uint_t _msec);
|
||||
virtual bool finished();
|
||||
|
||||
void push_animation(const SharedAnimation& animation);
|
||||
|
||||
private:
|
||||
int_t mLoops;
|
||||
|
||||
AnimationList mAnimations;
|
||||
uint_t mRunningAnimations;
|
||||
};
|
||||
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(AnimationParallel)
|
||||
|
||||
|
||||
// AnimationVariable *************************************************************************************
|
||||
template <class T, class Interpolator>
|
||||
class AnimationVariable : public Animation
|
||||
{
|
||||
public:
|
||||
|
||||
AnimationVariable(T& _data, uint_t _duration, const SharedEaseFunction& _ease_function, const Interpolator& _interpolator = Interpolator()) :
|
||||
mpEaseFunction(_ease_function),
|
||||
mInterpolator(_interpolator),
|
||||
mCurrentTime(0),
|
||||
mDuration(_duration),
|
||||
mpData(_data) { }
|
||||
|
||||
virtual ~AnimationVariable()
|
||||
{
|
||||
mBlendInterpolators.clear();
|
||||
}
|
||||
|
||||
virtual void init()
|
||||
{
|
||||
mCurrentTime = 0;
|
||||
mInterpolator.init(mpData);
|
||||
|
||||
mInited = true;
|
||||
}
|
||||
|
||||
virtual long update(uint_t _msec)
|
||||
{
|
||||
long time_span;
|
||||
if(mDuration-mCurrentTime >= _msec) time_span = _msec;
|
||||
else time_span = mDuration-mCurrentTime;
|
||||
|
||||
mCurrentTime += time_span;
|
||||
float progress = (float)mCurrentTime/(float)mDuration;
|
||||
|
||||
mpData = mInterpolator.interpolate( mpEaseFunction->value(progress) );
|
||||
|
||||
float sub_progress;
|
||||
|
||||
for(unsigned int i = 0;i < mBlendInterpolators.size();i++)
|
||||
{
|
||||
sub_progress = (progress - mBlendInterpolators[i].start)/(mBlendInterpolators[i].end - mBlendInterpolators[i].start);
|
||||
if(0.0f <= sub_progress && sub_progress <= 1.0f)
|
||||
{
|
||||
mBlendInterpolators[i].mpInterpolator->blend(&mpData, mBlendInterpolators[i].mpEaseFunction->value(sub_progress) );
|
||||
}
|
||||
}
|
||||
|
||||
return _msec-time_span;
|
||||
}
|
||||
|
||||
virtual bool finished()
|
||||
{
|
||||
if(mCurrentTime >= mDuration)
|
||||
mpData = mInterpolator.finish();
|
||||
|
||||
return mCurrentTime >= mDuration;
|
||||
}
|
||||
|
||||
void add_blend_interpolator(const SharedBlendInterpolator& _interpolator, const SharedEaseFunction& _ease_function, float _start = 0.0f, float _end = 1.0f)
|
||||
{
|
||||
mBlendInterpolators.push_back((blend_interpolator_t){_interpolator, _ease_function, _start, _end, false});
|
||||
}
|
||||
|
||||
inline const SharedEaseFunction& get_ease_function(){ return mpEaseFunction;}
|
||||
inline void set_ease_function(const SharedEaseFunction& _ease_function){ mpEaseFunction.reset(); mpEaseFunction = _ease_function;}
|
||||
|
||||
inline Interpolator& get_interpolator(){ return mInterpolator; }
|
||||
//void set_interpolator(Interpolator* interpolator){ this->interpolator = interpolator; }
|
||||
|
||||
protected:
|
||||
private:
|
||||
SharedEaseFunction mpEaseFunction;
|
||||
Interpolator mInterpolator;
|
||||
|
||||
uint_t mCurrentTime;
|
||||
uint_t mDuration;
|
||||
|
||||
T& mpData;
|
||||
|
||||
struct blend_interpolator_t{
|
||||
SharedBlendInterpolator mpInterpolator;
|
||||
SharedEaseFunction mpEaseFunction;
|
||||
float start, end;
|
||||
bool active;
|
||||
};
|
||||
typedef std::vector<blend_interpolator_t> BlendInterpolators;
|
||||
|
||||
BlendInterpolators mBlendInterpolators;
|
||||
|
||||
};
|
||||
|
||||
typedef AnimationVariable<float, LinearInterpolatorFloat > AnimationFloatLinear;
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(AnimationFloatLinear)
|
||||
|
||||
typedef AnimationVariable<glm::vec2, LinearInterpolatorVec2 > AnimationVec2Linear;
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(AnimationVec2Linear)
|
||||
|
||||
typedef AnimationVariable<glm::vec3, LinearInterpolatorVec3 > AnimationVec3Linear;
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(AnimationVec3Linear)
|
||||
|
||||
template <class T, class SpeedInterpolator>
|
||||
class AnimationSpeed : public Animation{
|
||||
public:
|
||||
AnimationSpeed(T& _data, float _targetSpeed, float _acceleration = 1.0f, float _decceleration = 1.0f, float _startSpeed = 0.0f, const SpeedInterpolator& _interpolator = SpeedInterpolator()) :
|
||||
mCurrentSpeed(_startSpeed),
|
||||
mTargetSpeed(_targetSpeed),
|
||||
mAcceleration(_acceleration),
|
||||
mDecceleration(_decceleration),
|
||||
mpData(_data),
|
||||
mInterpolator(_interpolator){ }
|
||||
|
||||
virtual void init()
|
||||
{
|
||||
mInterpolator.init(mpData);
|
||||
mInited = true;
|
||||
}
|
||||
|
||||
virtual long update(uint_t _msec)
|
||||
{
|
||||
//Calculate the distance
|
||||
float distance = mCurrentSpeed*((float)_msec)/1000.0f;
|
||||
|
||||
//Move on that distance
|
||||
float realDistance = mInterpolator.interpolate(mpData, distance);
|
||||
long msecLeft = (uint_t)((distance-realDistance)*1000.0f/mCurrentSpeed);
|
||||
|
||||
//Adjust the speed
|
||||
if(mCurrentSpeed > mTargetSpeed)
|
||||
mCurrentSpeed -= fmin(mCurrentSpeed-mTargetSpeed, mDecceleration*((float)_msec)/1000.0f);
|
||||
else
|
||||
mCurrentSpeed += fmin(mTargetSpeed-mCurrentSpeed, mAcceleration*((float)_msec)/1000.0f);
|
||||
|
||||
return msecLeft;
|
||||
}
|
||||
|
||||
virtual bool finished()
|
||||
{
|
||||
if(mInterpolator.finished())
|
||||
mInited = false;
|
||||
return mInterpolator.finished();
|
||||
}
|
||||
|
||||
SpeedInterpolator& getSpeedInterpolator(){return mInterpolator;}
|
||||
|
||||
void setTargetSpeed(float _value)
|
||||
{
|
||||
mTargetSpeed = _value;
|
||||
}
|
||||
|
||||
void setSpeed(float _value)
|
||||
{
|
||||
mCurrentSpeed = _value;
|
||||
}
|
||||
|
||||
void setAcceleration(float _value)
|
||||
{
|
||||
mAcceleration = _value;
|
||||
}
|
||||
|
||||
void setDecceleration(float _value)
|
||||
{
|
||||
mDecceleration = _value;
|
||||
}
|
||||
|
||||
private:
|
||||
float mCurrentSpeed;
|
||||
float mTargetSpeed;
|
||||
float mAcceleration;
|
||||
float mDecceleration;
|
||||
|
||||
T& mpData;
|
||||
|
||||
SpeedInterpolator mInterpolator;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif // ACGL_ANIMATIONS_ANIMATION_HH
|
||||
|
||||
#endif
|
176
extern/acgl/include/ACGL/Animations/EaseFunctions.hh
vendored
Normal file
176
extern/acgl/include/ACGL/Animations/EaseFunctions.hh
vendored
Normal file
@ -0,0 +1,176 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
// See http://www.graphics.rwth-aachen.de/redmine/projects/acgl/wiki/ACGL_compile_time_settings
|
||||
// for a comment what unsupported means.
|
||||
#ifdef ACGL_INCLUDE_UNSUPPORTED
|
||||
|
||||
#ifndef ACGL_ANIMATIONS_EASEFUNCTIONS_HH
|
||||
#define ACGL_ANIMATIONS_EASEFUNCTIONS_HH
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
|
||||
#include <ACGL/Math/Math.hh>
|
||||
#include <ACGL/Base/Macros.hh>
|
||||
|
||||
namespace ACGL
|
||||
{
|
||||
namespace Animations
|
||||
{
|
||||
|
||||
class EaseFunction
|
||||
{
|
||||
public:
|
||||
virtual ~EaseFunction(){}
|
||||
|
||||
virtual float value(const float _progress) = 0;
|
||||
};
|
||||
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(EaseFunction)
|
||||
|
||||
/*
|
||||
float Linear(float progress, ease_function_parameter& parameter);
|
||||
float InQuad(float progress, ease_function_parameter& parameter);
|
||||
float OutQuad(float progress, ease_function_parameter& parameter);
|
||||
float InOutQuad(float progress, ease_function_parameter& parameter);
|
||||
|
||||
float BlendLinear(float progress, ease_function_parameter& parameter);
|
||||
float BlendSin(float progress, ease_function_parameter& parameter);
|
||||
float BlendCos(float progress, ease_function_parameter& parameter);
|
||||
float BlendSinDamped(float progress, ease_function_parameter& parameter);
|
||||
float BlendCosDamped(float progress, ease_function_parameter& parameter);
|
||||
*/
|
||||
|
||||
|
||||
namespace EaseFunctions{
|
||||
|
||||
class Linear : public EaseFunction
|
||||
{
|
||||
public:
|
||||
Linear(){ }
|
||||
virtual ~Linear(){}
|
||||
|
||||
virtual float value(const float _progress)
|
||||
{
|
||||
return _progress;
|
||||
}
|
||||
};
|
||||
class InQuad : public EaseFunction
|
||||
{
|
||||
public:
|
||||
InQuad(){ }
|
||||
virtual ~InQuad(){}
|
||||
|
||||
virtual float value(const float _progress)
|
||||
{
|
||||
return _progress*_progress;
|
||||
}
|
||||
};
|
||||
class OutQuad : public EaseFunction
|
||||
{
|
||||
public:
|
||||
OutQuad(){ }
|
||||
virtual ~OutQuad(){}
|
||||
|
||||
virtual float value(const float _progress)
|
||||
{
|
||||
return 1.0f-_progress*_progress;
|
||||
}
|
||||
};
|
||||
class InOutQuad : public EaseFunction
|
||||
{
|
||||
public:
|
||||
InOutQuad(){ }
|
||||
virtual ~InOutQuad(){}
|
||||
|
||||
virtual float value(const float _progress)
|
||||
{
|
||||
if(_progress < 0.5)
|
||||
return 2.0f*_progress*_progress;
|
||||
else
|
||||
return 1.0f-2.0f*pow(_progress-1.0f,2.0f);
|
||||
}
|
||||
};
|
||||
|
||||
class Sin : public EaseFunction
|
||||
{
|
||||
public:
|
||||
Sin(float _frequency = 1.0f) :
|
||||
mFrequency(_frequency) { }
|
||||
virtual ~Sin(){}
|
||||
|
||||
virtual float value(const float _progress)
|
||||
{
|
||||
return sin(0.5f*(float)M_PI*mFrequency*_progress);
|
||||
}
|
||||
|
||||
float mFrequency;
|
||||
};
|
||||
|
||||
class BlendLinear : public EaseFunction
|
||||
{
|
||||
public:
|
||||
BlendLinear(){ }
|
||||
virtual ~BlendLinear(){}
|
||||
|
||||
virtual float value(const float _progress)
|
||||
{
|
||||
return 2.0f*Math::Functions::min(_progress, 1.0f-_progress);
|
||||
}
|
||||
};
|
||||
class BlendSin : public EaseFunction
|
||||
{
|
||||
public:
|
||||
BlendSin(){ }
|
||||
virtual ~BlendSin(){}
|
||||
|
||||
virtual float value(const float _progress)
|
||||
{
|
||||
return sin(20*(float)M_PI*_progress);
|
||||
}
|
||||
};
|
||||
class BlendCos : public EaseFunction
|
||||
{
|
||||
public:
|
||||
BlendCos(){ }
|
||||
virtual ~BlendCos(){}
|
||||
|
||||
virtual float value(const float _progress)
|
||||
{
|
||||
return cos(6*(float)M_PI*_progress)-1.0f;
|
||||
}
|
||||
};
|
||||
class BlendSinDamped : public EaseFunction
|
||||
{
|
||||
public:
|
||||
BlendSinDamped(){ }
|
||||
virtual ~BlendSinDamped(){}
|
||||
|
||||
virtual float value(const float _progress)
|
||||
{
|
||||
return 2.0f*Math::Functions::min(_progress, 1.0f-_progress)*sin(10.0f*(float)M_PI*_progress);
|
||||
}
|
||||
};
|
||||
class BlendCosDamped : public EaseFunction
|
||||
{
|
||||
public:
|
||||
BlendCosDamped(){ }
|
||||
virtual ~BlendCosDamped(){}
|
||||
|
||||
virtual float value(const float _progress)
|
||||
{
|
||||
return 2.0f*Math::Functions::min(_progress, 1.0f-_progress)*cos(10.0f*(float)M_PI*_progress);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // ACGL_ANIMATIONS_EASEFUNCTIONS_HH
|
||||
|
||||
#endif
|
301
extern/acgl/include/ACGL/Animations/Interpolator.hh
vendored
Normal file
301
extern/acgl/include/ACGL/Animations/Interpolator.hh
vendored
Normal file
@ -0,0 +1,301 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
// See http://www.graphics.rwth-aachen.de/redmine/projects/acgl/wiki/ACGL_compile_time_settings
|
||||
// for a comment what unsupported means.
|
||||
#ifdef ACGL_INCLUDE_UNSUPPORTED
|
||||
|
||||
#ifndef ACGL_ANIMATIONS_INTERPOLATOR_HH
|
||||
#define ACGL_ANIMATIONS_INTERPOLATOR_HH
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
|
||||
#include <ACGL/Animations/EaseFunctions.hh>
|
||||
#include <ACGL/Scene/NURBSCurve.hh>
|
||||
#include <ACGL/Types.hh>
|
||||
#include <ACGL/Base/Macros.hh>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace ACGL
|
||||
{
|
||||
namespace Animations
|
||||
{
|
||||
|
||||
class BlendInterpolator
|
||||
{
|
||||
public:
|
||||
virtual void blend(const void* value, const float progress) = 0;
|
||||
};
|
||||
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(BlendInterpolator)
|
||||
|
||||
struct interpolator_blend_t
|
||||
{
|
||||
EaseFunction* ease_function;
|
||||
BlendInterpolator* interpolator;
|
||||
float start, end;
|
||||
};
|
||||
|
||||
typedef std::vector<interpolator_blend_t> BlendVector;
|
||||
// Interpolator *************************************************************************************
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
class LinearInterpolator : public BlendInterpolator
|
||||
{
|
||||
public:
|
||||
LinearInterpolator() :
|
||||
mStartValue(),
|
||||
mEndValue(),
|
||||
mDiffValue(),
|
||||
mSetStartPoint(true)
|
||||
{
|
||||
}
|
||||
|
||||
LinearInterpolator(const T& _end_value) :
|
||||
mStartValue(),
|
||||
mEndValue(_end_value),
|
||||
mDiffValue(),
|
||||
mSetStartPoint(true)
|
||||
{
|
||||
}
|
||||
|
||||
LinearInterpolator(const T& _start_value, const T& _end_value) :
|
||||
mStartValue(_start_value),
|
||||
mEndValue(_end_value),
|
||||
mDiffValue(_end_value - _start_value),
|
||||
mSetStartPoint(false)
|
||||
{
|
||||
}
|
||||
|
||||
inline void init(const T& _initValue)
|
||||
{
|
||||
if(mSetStartPoint)
|
||||
{
|
||||
mStartValue = _initValue;
|
||||
mDiffValue = mEndValue-mStartValue;
|
||||
}
|
||||
}
|
||||
|
||||
inline const T interpolate(const float _progress)
|
||||
{
|
||||
return mStartValue + mDiffValue*_progress;
|
||||
}
|
||||
|
||||
inline const T& finish()
|
||||
{
|
||||
return mEndValue;
|
||||
}
|
||||
|
||||
virtual void blend(const void* _value, const float _progress)
|
||||
{
|
||||
*((T*)_value) += mEndValue*_progress;
|
||||
}
|
||||
|
||||
protected:
|
||||
private:
|
||||
|
||||
|
||||
T mStartValue;
|
||||
T mEndValue;
|
||||
|
||||
T mDiffValue;
|
||||
|
||||
bool mSetStartPoint;
|
||||
};
|
||||
|
||||
typedef LinearInterpolator<float> LinearInterpolatorFloat;
|
||||
typedef LinearInterpolator<glm::vec2> LinearInterpolatorVec2;
|
||||
typedef LinearInterpolator<glm::vec3> LinearInterpolatorVec3;
|
||||
|
||||
|
||||
template <class T>
|
||||
class LinearPathInterpolator
|
||||
{
|
||||
|
||||
public:
|
||||
LinearPathInterpolator()
|
||||
{
|
||||
}
|
||||
|
||||
inline void init(const T& init_value)
|
||||
{
|
||||
}
|
||||
|
||||
inline const T interpolate(float _progress)
|
||||
{
|
||||
//TODO: This es very UGLY, implement a better way to find the current keypoint.
|
||||
unsigned int i = 0;
|
||||
for(i = 0 ;i < mKeypoints.size();i++)
|
||||
{
|
||||
if(mKeypoints[i].time >= _progress)
|
||||
break;
|
||||
}
|
||||
|
||||
if(i == 0)
|
||||
{
|
||||
return mKeypoints[0].data;
|
||||
}else if(i < mKeypoints.size())
|
||||
{
|
||||
float val = (_progress-mKeypoints[i-1].time)
|
||||
/(mKeypoints[i].time-mKeypoints[i-1].time);
|
||||
|
||||
return mKeypoints[i-1].data*(1.0f-val)+mKeypoints[i].data*val;
|
||||
}
|
||||
}
|
||||
|
||||
inline const T& finish()
|
||||
{
|
||||
return mKeypoints[mKeypoints.size()-1].data;
|
||||
}
|
||||
|
||||
void insertControlPoint(const T& _data, const float _time)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
while(i < mKeypoints.size() && mKeypoints[i].time < _time) i++;
|
||||
key_point_t keyPoint = {_data, _time};
|
||||
mKeypoints.insert( mKeypoints.begin()+i, keyPoint );
|
||||
}
|
||||
|
||||
protected:
|
||||
private:
|
||||
struct key_point_t{T data;float time;};
|
||||
std::vector<key_point_t> mKeypoints;
|
||||
};
|
||||
|
||||
typedef LinearPathInterpolator<float> LinearPathInterpolatorFloat;
|
||||
typedef LinearPathInterpolator<glm::vec2> LinearPathInterpolatorVec2;
|
||||
typedef LinearPathInterpolator<glm::vec3> LinearPathInterpolatorVec3;
|
||||
|
||||
|
||||
template<class T, ACGL::uint_t DATA_DIMENSION>
|
||||
class NURBSPathInterpolator
|
||||
{
|
||||
public:
|
||||
NURBSPathInterpolator(ACGL::Scene::NURBSCurve<DATA_DIMENSION> curve) :
|
||||
curve(curve)
|
||||
{
|
||||
}
|
||||
|
||||
void init(T& init_value)
|
||||
{
|
||||
// insert_control_point(data, 0.0f);
|
||||
}
|
||||
|
||||
const T interpolate(float progress)
|
||||
{
|
||||
curve.insertKnot(progress);
|
||||
// TODO: Interpolation code is missing
|
||||
return T();
|
||||
}
|
||||
|
||||
const T& finish()
|
||||
{
|
||||
return T();
|
||||
}
|
||||
|
||||
inline ACGL::Scene::NURBSCurve<DATA_DIMENSION>& get_curve()
|
||||
{
|
||||
return curve;
|
||||
}
|
||||
|
||||
protected:
|
||||
private:
|
||||
ACGL::Scene::NURBSCurve<DATA_DIMENSION> curve;
|
||||
};
|
||||
|
||||
template <class T, class OffsetType, class DataOperations>
|
||||
class LinearPathSpeedInterpolator
|
||||
{
|
||||
|
||||
public:
|
||||
LinearPathSpeedInterpolator() :
|
||||
mKeypoints(),
|
||||
mOffset(0.0f, 0.0f),
|
||||
mCurrentPosition(1)
|
||||
{
|
||||
}
|
||||
|
||||
inline void init(const T& init_value)
|
||||
{
|
||||
mCurrentPosition = 0;
|
||||
}
|
||||
|
||||
inline float interpolate(T& _data, const float _distance)
|
||||
{
|
||||
if(mCurrentPosition == mKeypoints.size())
|
||||
return 0.0f;
|
||||
|
||||
//Get the next target point
|
||||
T source, target;
|
||||
|
||||
if(mCurrentPosition == 0)
|
||||
{
|
||||
source = _data;
|
||||
target = DataOperations::applyStartOffset(mKeypoints[mCurrentPosition], mKeypoints[mCurrentPosition+1], mOffset);
|
||||
}else{
|
||||
source = DataOperations::applyStartOffset(mKeypoints[mCurrentPosition-1], mKeypoints[mCurrentPosition], mOffset);
|
||||
if(mCurrentPosition == mKeypoints.size()-1)
|
||||
{
|
||||
target = DataOperations::applyOffset(mKeypoints[mCurrentPosition-1], mKeypoints[mCurrentPosition], mOffset);
|
||||
}else{
|
||||
target = DataOperations::applyOffset(mKeypoints[mCurrentPosition-1], mKeypoints[mCurrentPosition], mKeypoints[mCurrentPosition+1], mOffset);
|
||||
}
|
||||
}
|
||||
|
||||
bool next;
|
||||
T newPosition = DataOperations::getNewPosition(_data, source, target, _distance, next);
|
||||
|
||||
float realDistance = DataOperations::distance(_data, newPosition);
|
||||
|
||||
_data = newPosition;
|
||||
|
||||
//If we reached the next control point and there are keypoints left
|
||||
if(next)
|
||||
{
|
||||
mCurrentPosition++;
|
||||
|
||||
return realDistance+interpolate(_data, _distance-realDistance);
|
||||
}else
|
||||
{
|
||||
return realDistance;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool finished()
|
||||
{
|
||||
return mCurrentPosition == mKeypoints.size();
|
||||
}
|
||||
|
||||
inline OffsetType& getOffset()
|
||||
{
|
||||
return mOffset;
|
||||
}
|
||||
|
||||
void appendControlPoint(const T& _data)
|
||||
{
|
||||
mKeypoints.push_back(_data);
|
||||
}
|
||||
|
||||
protected:
|
||||
private:
|
||||
std::vector<T> mKeypoints;
|
||||
|
||||
OffsetType mOffset;
|
||||
|
||||
unsigned int mCurrentPosition;
|
||||
};
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // INTERPOLATOR_HH
|
||||
|
||||
#endif
|
99
extern/acgl/include/ACGL/Base/CompileTimeSettings.hh
vendored
Normal file
99
extern/acgl/include/ACGL/Base/CompileTimeSettings.hh
vendored
Normal file
@ -0,0 +1,99 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef ACGL_BASE_COMPILETIMESETTINGS_HH
|
||||
#define ACGL_BASE_COMPILETIMESETTINGS_HH
|
||||
|
||||
/*
|
||||
* OpenGL error checking defines
|
||||
*
|
||||
* By default, only critical errors will get checked in release build
|
||||
* and critical&common in debug build.
|
||||
*
|
||||
* This can get overwritten with a compile flag define:
|
||||
* -DACGL_ERROR_LEVEL_EC0
|
||||
* No error checking at all
|
||||
* -DACGL_ERROR_LEVEL_EC1
|
||||
* Places will get checked where errors like out of memory can occur.
|
||||
* This will detect runtime errors which can happen even if the program
|
||||
* is bug free.
|
||||
* Switching this on shouldn't be a performance hit.
|
||||
* -DACGL_ERROR_LEVEL_EC2
|
||||
* Problems that happen more often while developing like typos in uniform
|
||||
* names. All placed where strings are used to call OpenGL objects etc.
|
||||
* -DACGL_ERROR_LEVEL_EC3
|
||||
* Most likely bugs in ACGL itself or wrong usage. If there are strange errors
|
||||
* switch this on to find the reason more quickly. Even normal development
|
||||
* should work without this. Results in a lot of glGetError!
|
||||
*
|
||||
* Note that all error levels also include the higher ones (COMMON also adds CRITICAL).
|
||||
*/
|
||||
|
||||
// try to detect a debug build:
|
||||
#if defined( DEBUG ) || defined (_DEBUG)
|
||||
#define ACGL_DEBUG
|
||||
#endif
|
||||
|
||||
//#error foo
|
||||
|
||||
/*
|
||||
* Map CMake generated error-level defines to internally used, more readable defines
|
||||
*/
|
||||
#ifdef ACGL_ERROR_LEVEL_EC0
|
||||
# define ACGL_CHECK_NO_GL_ERRORS
|
||||
#endif
|
||||
#ifdef ACGL_ERROR_LEVEL_EC1
|
||||
# define ACGL_CHECK_CRITICAL_GL_ERRORS
|
||||
#endif
|
||||
#ifdef ACGL_ERROR_LEVEL_EC2
|
||||
# define ACGL_CHECK_COMMON_GL_ERRORS
|
||||
#endif
|
||||
#ifdef ACGL_ERROR_LEVEL_EC3
|
||||
# define ACGL_CHECK_RARE_GL_ERRORS
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef ACGL_CHECK_NO_GL_ERRORS
|
||||
# ifndef ACGL_CHECK_CRITICAL_GL_ERRORS
|
||||
# ifndef ACGL_CHECK_COMMON_GL_ERRORS
|
||||
# ifndef ACGL_CHECK_RARE_GL_ERRORS
|
||||
// if nothing is defined, use defaults:
|
||||
# ifdef ACGL_DEBUG
|
||||
# define ACGL_CHECK_RARE_GL_ERRORS
|
||||
# else
|
||||
# define ACGL_CHECK_CRITICAL_GL_ERRORS
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
// if rare is set, set also common:
|
||||
#ifdef ACGL_CHECK_RARE_GL_ERRORS
|
||||
# ifndef ACGL_CHECK_COMMON_GL_ERRORS
|
||||
# define ACGL_CHECK_COMMON_GL_ERRORS
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// if common is set, set also critical:
|
||||
#ifdef ACGL_CHECK_COMMON_GL_ERRORS
|
||||
# ifndef ACGL_CHECK_CRITICAL_GL_ERRORS
|
||||
# define ACGL_CHECK_CRITICAL_GL_ERRORS
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// if critical is set, NO must not be set:
|
||||
#ifdef ACGL_CHECK_CRITICAL_GL_ERRORS
|
||||
# ifdef ACGL_CHECK_NO_GL_ERRORS
|
||||
# undef ACGL_CHECK_NO_GL_ERRORS
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif // ACGL_BASE_COMPILETIMESETTINGS_HH
|
||||
|
41
extern/acgl/include/ACGL/Base/Macros.hh
vendored
Normal file
41
extern/acgl/include/ACGL/Base/Macros.hh
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef ACGL_BASE_MACROS_HH
|
||||
#define ACGL_BASE_MACROS_HH
|
||||
|
||||
#ifndef ACGL_ACGL_HH
|
||||
# error "Don't include Macros.hh directly, include ACGL.hh"
|
||||
// some defines below will be set by ACGL.hh!
|
||||
#endif
|
||||
|
||||
//Macro to make a class not copyable
|
||||
#define ACGL_NOT_COPYABLE(Class) \
|
||||
private:\
|
||||
Class(const Class& ){ }\
|
||||
void operator=(Class& ){ }
|
||||
|
||||
|
||||
// creates typedefs for a given class for each smartpointer type
|
||||
# if (ACGL_UNIQUE_POINTER_SUPPORTED == 1)
|
||||
// C++11:
|
||||
# define ACGL_SMARTPOINTER_TYPEDEFS(Class) \
|
||||
typedef ptr::shared_ptr<Class> Shared ## Class; \
|
||||
typedef ptr::shared_ptr<const Class> ConstShared ## Class; \
|
||||
typedef ptr::weak_ptr<Class> Weak ## Class; \
|
||||
typedef ptr::weak_ptr<const Class> ConstWeak ## Class; \
|
||||
typedef ptr::unique_ptr<Class> Unique ## Class; \
|
||||
typedef ptr::unique_ptr<const Class> ConstUnique ## Class;
|
||||
#else
|
||||
// TR1 does not have unique pointers
|
||||
# define ACGL_SMARTPOINTER_TYPEDEFS(Class) \
|
||||
typedef ptr::shared_ptr<Class> Shared ## Class; \
|
||||
typedef ptr::shared_ptr<const Class> ConstShared ## Class; \
|
||||
typedef ptr::weak_ptr<Class> Weak ## Class; \
|
||||
typedef ptr::weak_ptr<const Class> ConstWeak ## Class;
|
||||
#endif
|
||||
|
||||
#endif // MACROS_HH
|
74
extern/acgl/include/ACGL/Base/Settings.hh
vendored
Normal file
74
extern/acgl/include/ACGL/Base/Settings.hh
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef ACGL_BASE_FRAMEWORKSETTINGS_HH
|
||||
#define ACGL_BASE_FRAMEWORKSETTINGS_HH
|
||||
|
||||
/*
|
||||
* This class manages a few runtime settings for the application which can change the
|
||||
* behavior of the ACGL library.
|
||||
*/
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
#include <ACGL/Base/Singleton.hh>
|
||||
#include <string>
|
||||
|
||||
namespace ACGL{
|
||||
namespace Base{
|
||||
|
||||
class Settings : public Singleton<Settings>
|
||||
{
|
||||
friend class Singleton<Settings>;
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ========================================================================= Constructors / Destructors \/
|
||||
// ==================================================================================================== \/
|
||||
protected:
|
||||
//! Constructor is protected => singleton.
|
||||
Settings()
|
||||
: mResourcePath (""),
|
||||
mTexturePath (""),
|
||||
mGeometryPath (""),
|
||||
mShaderPath ("")
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
~Settings(){}
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ METHODS \/
|
||||
// ==================================================================================================== \/
|
||||
public:
|
||||
inline void setResourcePath (const std::string &_path) { mResourcePath = _path; }
|
||||
inline void setTexturePath (const std::string &_path) { mTexturePath = _path; }
|
||||
inline void setGeometryPath (const std::string &_path) { mGeometryPath = _path; }
|
||||
inline void setShaderPath (const std::string &_path) { mShaderPath = _path; }
|
||||
|
||||
inline const std::string& getResourcePath() const { return mResourcePath; }
|
||||
inline const std::string& getTexturePath() const { return mTexturePath; }
|
||||
inline const std::string& getGeometryPath() const { return mGeometryPath; }
|
||||
inline const std::string& getShaderPath() const { return mShaderPath; }
|
||||
|
||||
inline const std::string getFullTexturePath() const { return mResourcePath + mTexturePath; }
|
||||
inline const std::string getFullGeometryPath() const { return mResourcePath + mGeometryPath; }
|
||||
inline const std::string getFullShaderPath() const { return mResourcePath + mShaderPath; }
|
||||
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================= FIELDS \/
|
||||
// ==================================================================================================== \/
|
||||
private:
|
||||
std::string mResourcePath;
|
||||
std::string mTexturePath;
|
||||
std::string mGeometryPath;
|
||||
std::string mShaderPath;
|
||||
};
|
||||
|
||||
} // Base
|
||||
} // ACGL
|
||||
|
||||
#endif // FRAMEWORKSETTINGS_HH
|
55
extern/acgl/include/ACGL/Base/Singleton.hh
vendored
Normal file
55
extern/acgl/include/ACGL/Base/Singleton.hh
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef ACGL_BASE_SINGLETON_HH
|
||||
#define ACGL_BASE_SINGLETON_HH
|
||||
|
||||
/*
|
||||
* A very simple Singleton as a template.
|
||||
* Not thread save etc.
|
||||
*/
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
|
||||
namespace ACGL{
|
||||
namespace Base{
|
||||
|
||||
template<typename CLASS>
|
||||
class Singleton
|
||||
{
|
||||
public:
|
||||
virtual ~Singleton(void) {}
|
||||
|
||||
static ptr::shared_ptr<CLASS> the(void)
|
||||
{
|
||||
if(!spInstance)
|
||||
spInstance.reset(new CLASS());
|
||||
return(spInstance);
|
||||
}
|
||||
|
||||
protected:
|
||||
Singleton(void){}
|
||||
private:
|
||||
Singleton(const Singleton&){}
|
||||
|
||||
private:
|
||||
static ptr::shared_ptr<CLASS> spInstance;
|
||||
|
||||
};
|
||||
|
||||
template<typename CLASS>
|
||||
ptr::shared_ptr<CLASS> Singleton<CLASS>::spInstance = ptr::shared_ptr<CLASS>();
|
||||
|
||||
#define ACGL_SINGLETON(Class) \
|
||||
friend class Base::Singleton< Class >; \
|
||||
private:\
|
||||
Class(const Class& ){ }\
|
||||
void operator=(Class& ){ }
|
||||
|
||||
} // Base
|
||||
} // ACGL
|
||||
|
||||
#endif
|
152
extern/acgl/include/ACGL/HardwareSupport/GamePad.hh
vendored
Normal file
152
extern/acgl/include/ACGL/HardwareSupport/GamePad.hh
vendored
Normal file
@ -0,0 +1,152 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2013 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
#include <string>
|
||||
#include <linuxjoystick/Joystick.h>
|
||||
|
||||
namespace ACGL{
|
||||
namespace HardwareSupport{
|
||||
|
||||
/**
|
||||
* NOTE: Will not work unless ACGL_COMPILE_WITH_GLFW or ACGL_COMPILE_WITH_QT (linux only) is defined!
|
||||
*
|
||||
*
|
||||
* For the known gamepads, all axes start at 0.0f. All trigger go from 0..1 and all joystick-like
|
||||
* analog sticks go from -1..1 while -1 is on the left or bottom / 1 is right or top.
|
||||
*/
|
||||
class GamePad {
|
||||
public:
|
||||
enum GamePadButton {
|
||||
SELECT = 0,
|
||||
START = 1,
|
||||
LEFT_PAD_NORTH = 2,
|
||||
LEFT_PAD_EAST = 3,
|
||||
LEFT_PAD_SOUTH = 4,
|
||||
LEFT_PAD_WEST = 5,
|
||||
RIGHT_PAD_NORTH = 6,
|
||||
RIGHT_PAD_EAST = 7,
|
||||
RIGHT_PAD_SOUTH = 8,
|
||||
RIGHT_PAD_WEST = 9,
|
||||
LEFT_SHOULDER = 10,
|
||||
RIGHT_SHOULDER = 11,
|
||||
LEFT_TRIGGER = 12,
|
||||
RIGHT_TRIGGER = 13,
|
||||
|
||||
// number of elements in this enum (itself not included):
|
||||
GAMEPAD_BUTTON_ENUM_SIZE = 14
|
||||
};
|
||||
|
||||
enum GamePadAxis {
|
||||
LEFT_ANALOG_TRIGGER = 0, // 0..1
|
||||
RIGHT_ANALOG_TRIGGER = 1, // 0..1
|
||||
LEFT_ANALOG_STICK_X = 2, // -1..1 aka left-right
|
||||
LEFT_ANALOG_STICK_Y = 3, // -1..1 aka up-down / front-back
|
||||
RIGHT_ANALOG_STICK_X = 4, // -1..1 aka left-right
|
||||
RIGHT_ANALOG_STICK_Y = 5, // -1..1 aka up-down / front-back
|
||||
|
||||
// number of elements in this enum (itself not included):
|
||||
GAMEPAD_AXIS_ENUM_SIZE = 6
|
||||
};
|
||||
|
||||
|
||||
//! connects to the _n-th joystick, start counting at 1!
|
||||
GamePad( int _n = 1 );
|
||||
~GamePad();
|
||||
|
||||
//! true if the joystick was found, note that unplugging the GamePad at runtime can not be detected!
|
||||
bool ok() { return mGamePadOK; }
|
||||
|
||||
///////////// Buttons
|
||||
|
||||
//! true if the button with the internal number _button is pressed
|
||||
bool isPressedRaw( unsigned int _button );
|
||||
|
||||
//! only returns true if the button was mapped first!
|
||||
bool isPressed( GamePadButton _button );
|
||||
|
||||
//! true if the button was just pressed or released
|
||||
bool buttonStateChanged( unsigned int _button );
|
||||
|
||||
//! true if the button was just pressed or released
|
||||
bool buttonStateChanged( GamePadButton _button );
|
||||
|
||||
//! define the mapping of one button
|
||||
void setButtonMapping( GamePadButton _button, unsigned int _rawButtonNumber );
|
||||
|
||||
///////////// Axes
|
||||
|
||||
//! analog sticks and analog trigger, values are from -1..1. An unknown axis will return 0.0
|
||||
float getAxisRaw( unsigned int _axis );
|
||||
|
||||
float getAxis( GamePadAxis _axis );
|
||||
|
||||
//! define the mapping of one button
|
||||
void setAxisMapping( GamePadAxis _axis, unsigned int _rawAxisNumber );
|
||||
|
||||
//! sets the minimal value an axis has to be pushed to trigger.
|
||||
//! _sensitivity has to be >= 0.0 and < 1.0.
|
||||
//! reported axis values will still be between -1..0..1
|
||||
void setMinAxisSensitivity( float _sensitivity );
|
||||
|
||||
float getMinAxisSensitivity() { return mMinSensitivity; }
|
||||
|
||||
//! set and unset the invertation of an axis (1..-1 -> -1..1)
|
||||
void invertAxis( int _axis, bool _invert = true );
|
||||
|
||||
//! print the button and axes state for debugging:
|
||||
void printState();
|
||||
|
||||
//! print the names of all mapped buttons, in all caps if pressed
|
||||
void printPressedButtons();
|
||||
|
||||
//! fetches the current device state, will do nothing if the joystick is not ok
|
||||
void update();
|
||||
|
||||
private:
|
||||
bool mGamePadOK;
|
||||
int mNumberOfButtons;
|
||||
int mNumberOfAxes;
|
||||
int mButtonMap[GAMEPAD_BUTTON_ENUM_SIZE];
|
||||
int mAxisMap[GAMEPAD_AXIS_ENUM_SIZE];
|
||||
unsigned char *mButtonState; // 0 = released, 1 = pressed
|
||||
unsigned char *mLastButtonState;
|
||||
float *mAxes; // -1..1 (e.g. analog sticks) or 0..1 (analog trigger) per axis - untouched should be 0
|
||||
float *mAxesMultiplier; // used for scaling from the used API to -1..1
|
||||
float *mAxesAdd; // also used for scaling
|
||||
float mMinSensitivity; // a minimal axis value that has to be exceeded before it is evaluated
|
||||
|
||||
std::string mJoystickName;
|
||||
|
||||
// fills mAxis and mButtonState and also stores the old state
|
||||
void getAxisAndButtonValues();
|
||||
|
||||
//
|
||||
// GLFW specifics: replace this to support joysticks with other APIs
|
||||
//
|
||||
#ifdef ACGL_COMPILE_WITH_GLFW
|
||||
const unsigned char *mGLFWButtons; // temp. used as GLFW needs a const array
|
||||
const float *mGLFWAxes; // temp. used as GLFW needs a const array
|
||||
int mGLFWGamePadNumber;
|
||||
#endif
|
||||
|
||||
//
|
||||
// Custom Linux Joystick support:
|
||||
//
|
||||
#ifdef ACGL_OWN_LINUX_JOYSTICK
|
||||
Joystick mLinuxGamePad;
|
||||
#endif
|
||||
|
||||
bool isMapped( GamePadButton _button );
|
||||
void printPressedButtonHelper( GamePadButton _b, const char *_TRUE, const char *_false );
|
||||
};
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(GamePad)
|
||||
|
||||
}
|
||||
}
|
||||
|
66
extern/acgl/include/ACGL/HardwareSupport/OVRWrapper.hh
vendored
Normal file
66
extern/acgl/include/ACGL/HardwareSupport/OVRWrapper.hh
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
/**
|
||||
*
|
||||
* Includes the Oculus Rift LibOVR but tries to suppress as much compiler warnings
|
||||
* as possible.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef ACGL_USE_OCULUS_RIFT
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
// ignore compiler warnings from LibOVR:
|
||||
//
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning( push )
|
||||
#pragma warning ( disable : 4201 )
|
||||
#pragma warning ( disable : 4100 )
|
||||
#pragma warning ( disable : 4996 )
|
||||
#pragma warning ( disable : 4244 )
|
||||
#endif
|
||||
|
||||
#if (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4))
|
||||
#define COMPILER_IS_GCC_4_6_OR_NEWER
|
||||
#endif
|
||||
|
||||
#ifdef __clang__
|
||||
// clang/llvm:
|
||||
# pragma clang diagnostic push
|
||||
# pragma clang diagnostic ignored "-Wuninitialized"
|
||||
# pragma clang diagnostic ignored "-Wunused-parameter"
|
||||
#elif defined __GNUC__
|
||||
# ifdef COMPILER_IS_GCC_4_6_OR_NEWER
|
||||
// gcc >= 4.6:
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wtype-limits"
|
||||
# pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
||||
# pragma GCC diagnostic ignored "-Wattributes"
|
||||
# pragma GCC diagnostic ignored "-Wreorder"
|
||||
# endif
|
||||
// gcc:
|
||||
# pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
#endif
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <OVR.h>
|
||||
#include <OVRVersion.h>
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
// reactivate compiler warnings:
|
||||
//
|
||||
#ifdef __clang__
|
||||
// clang/llvm:
|
||||
# pragma clang diagnostic pop
|
||||
#elif defined COMPILER_IS_GCC_4_6_OR_NEWER
|
||||
// gcc >= 4.6:
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning( pop )
|
||||
#endif
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#endif // ACGL_USE_OCULUS_RIFT
|
223
extern/acgl/include/ACGL/HardwareSupport/SimpleRiftController.hh
vendored
Normal file
223
extern/acgl/include/ACGL/HardwareSupport/SimpleRiftController.hh
vendored
Normal file
@ -0,0 +1,223 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* IMPORTANT: DON'T EXPECT THIS CLASS TO HAVE A FINAL AND STABLE API!
|
||||
*
|
||||
* This class needs the LibOVR version 0.2.4 or higher to work.
|
||||
* Headers of this lib need to be placed in the search path.
|
||||
*
|
||||
* In addition ACGL_USE_OCULUS_RIFT has to be defined.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
#ifdef ACGL_USE_OCULUS_RIFT
|
||||
|
||||
#include <ACGL/Math/Math.hh>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
#include <ACGL/Scene/HMDCamera.hh>
|
||||
|
||||
#include <ACGL/OpenGL/Objects/Texture.hh>
|
||||
#include <ACGL/OpenGL/Managers.hh>
|
||||
|
||||
#include <ACGL/HardwareSupport/OVRWrapper.hh>
|
||||
|
||||
namespace ACGL{
|
||||
namespace HardwareSupport{
|
||||
|
||||
/**
|
||||
* This class provides access to the Oculus Rift. It can read out the orientation and control a HMDCamera
|
||||
* based on this.
|
||||
* Distorted rendering is provided in two ways:
|
||||
* * renderDistorted( texture ) if the input is one side-by-side rendered image
|
||||
* * renderDistorted( texture, texture ) if the input are two seperate textures for the both eyes
|
||||
*
|
||||
* Alternatively the application can implement the distortion on its own (e.g. to add other effects in the
|
||||
* same pass). For this the needed parameters are provided.
|
||||
*
|
||||
* Use the camera provided by this class (getCamera) or provide your own (attachCamera).
|
||||
* This class needs to use a HMDCamera which is derived from GenericCamera!
|
||||
*/
|
||||
class SimpleRiftController
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* _riftnumber: which device to use in case multiple are attached - NOTE: the Rift SDK has problems supporting this yet!
|
||||
* _performAutomaticMagneticCalibration: try to calibrate the magetometer to reduce drift
|
||||
* the user has to look into at least four very different directions
|
||||
* for this to work.
|
||||
*/
|
||||
SimpleRiftController( uint32_t _riftnumber = 0 );
|
||||
~SimpleRiftController();
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Camera and sensor handling:
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//! attach an external camera to manipulate (see updateCamera)
|
||||
//! per default the SimpleRiftController already has a camera which can be used as well
|
||||
//! only one camera can be attached at all times
|
||||
void attachCamera( ACGL::Scene::SharedHMDCamera _camera );
|
||||
|
||||
ACGL::Scene::SharedHMDCamera getCamera() { return mCamera; }
|
||||
|
||||
//! Query the orientation of the Rift and set it as the cameras orientation.
|
||||
//! This will do nothing if no Rift is attached (so the camera can get controlled
|
||||
//! e.g. by a mouse)!
|
||||
void updateCamera();
|
||||
|
||||
//! returns the current orientation as a rotation matrix from the device.
|
||||
//! this can be used as an alternative to updateCamera if the attached camera should not be used.
|
||||
glm::mat3 getCurrentRotation();
|
||||
|
||||
//! sets the amound of seconds to predict the headmovements into the future
|
||||
//! default is 0.03f, should be no more than the rendering latency!
|
||||
void setPrediction( float _seconds );
|
||||
|
||||
void setFoVMultiplier( float _factor ) { mFoVMultiplier = _factor; updateCameraFoV(); }
|
||||
float getFoVMultiplier() { return mFoVMultiplier; }
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Access to direct sensor data as an alternative to the use of the ACGL camera
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//! get the rotation as a quaternion, the native format of the Rift (with sensor fusion):
|
||||
glm::quat getFusedRotationQuaternion();
|
||||
|
||||
//! get the rotation as a quaternion, the native format of the Rift (without sensor fusion):
|
||||
glm::quat getRotationQuaternion();
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// RAW parameters for distortion rendering:
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//! Default is 1.0, larger values result in higher FoVs and larger areas of the Rift being used.
|
||||
//! Note that - depending on the lenses used - the user will not be able to see the whole screen.
|
||||
//! Often 1.75 is enough.
|
||||
//! Increase the offscreen rendering viewport accordingly to counter the decreased image quality.
|
||||
void setDistortionScaleFactor( float _f );
|
||||
float getDistortionScaleFactor() { return mDistortionScaleFactor; }
|
||||
|
||||
//! x,y are the values for the left eye. z,w the values for the right eye
|
||||
glm::vec4 getLensCenter();
|
||||
|
||||
//! x,y are the values for the left eye. z,w the values for the right eye
|
||||
glm::vec4 getScreenCenter();
|
||||
|
||||
//! x,y are the values for both eyes, ignore z,w
|
||||
glm::vec4 getScale();
|
||||
|
||||
//! x,y are the values for both eyes, ignore z,w
|
||||
glm::vec4 getScaleIn();
|
||||
|
||||
//! the four distortion parameters are the same for both eyes
|
||||
glm::vec4 getHmdWarpParam();
|
||||
|
||||
//! the four chromatic aberation parameters are the same for both eyes
|
||||
glm::vec4 getChromAbParam();
|
||||
|
||||
//! the full physical screen resolution, offscreen rendering should get performed at a higher resolution!
|
||||
//! 'full' means it's the size used for both eyes!
|
||||
glm::uvec2 getPhysicalScreenResolution();
|
||||
|
||||
//! returns the stereo projection from the stored camera adjusted for the rift
|
||||
//! returns nonsens in case no camera was set
|
||||
glm::mat4 getProjectionMatrixFromCamera();
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Optional integrated distortion rendering:
|
||||
//
|
||||
// If it's activated and used, make sure the RiftDistort* shader files are located where the
|
||||
// ShaderProgramFileManager can find them.
|
||||
// They may set texture units 0..3 and render to Framebuffer 0 (which will get bound) using the viewport of the
|
||||
// physical dimensions of the rift!
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void renderDistorted( ACGL::OpenGL::ConstSharedTexture2D _sideBySideTexture );
|
||||
void renderDistorted( ACGL::OpenGL::ConstSharedTexture2D _leftTexture, ACGL::OpenGL::ConstSharedTexture2D _rightTexture );
|
||||
void renderDistortedP( ACGL::OpenGL::ConstSharedShaderProgram _program );
|
||||
|
||||
bool getSuccessfulConnected() { return mSuccessfulConnected; }
|
||||
|
||||
//! activate and deactivate the distortion, only works if the renderers above are used, does not change the raw
|
||||
//! distortion parameters!
|
||||
void setDistortion( bool _value ) { mUseDistortion = _value; }
|
||||
bool getDistortion() { return mUseDistortion; }
|
||||
|
||||
//! activate and deactivate the chromatic aberation correction (true to correct the aberation), only works if the renderers
|
||||
//! above are used, does not change the raw distortion parameters!
|
||||
void setChromaticAberation( bool _value ) { mUseChromaticAberation = _value; }
|
||||
bool getChromaticAberation() { return mUseChromaticAberation; }
|
||||
|
||||
//! Sets the size of the final rendering. This should be the size of the window to render into.
|
||||
void setOutputViewportSize( glm::uvec2 _size ) { mOutputViewport = _size; }
|
||||
|
||||
//! Defines that the current HMD orientations should be defined as "no rotation"
|
||||
//! Can be used to "reset" the orientation.
|
||||
//! Note: if the user is just looking in the wrong direction, use setNeutralYaw(), if e.g. looking up should be
|
||||
//! neutral (laying on the ground), this is the way to go.
|
||||
void setNeutralPosition();
|
||||
void resetNeutralRotation() {setNeutralPosition();}
|
||||
|
||||
//! Will define the current view direction as the neutral direction but only takes yaw into account.
|
||||
//! Will also reset the neutral position.
|
||||
//! Basically works as if the Rift was started in the current orientation
|
||||
void setNeutralYaw();
|
||||
|
||||
private:
|
||||
|
||||
// for rendering:
|
||||
ACGL::OpenGL::SharedShaderProgram mDistortShaderSideBySide;
|
||||
ACGL::OpenGL::SharedShaderProgram mDistortShaderTwoTextures;
|
||||
|
||||
ACGL::OpenGL::SharedVertexArrayObject mVAO;
|
||||
GLint uLensCenter;
|
||||
GLint uScreenCenter;
|
||||
GLint uScale;
|
||||
GLint uScaleIn;
|
||||
GLint uHmdWarpParam;
|
||||
GLint uChromAbParam;
|
||||
GLint uDistort;
|
||||
GLint uCorrectChromaticAberation;
|
||||
bool mBuildInShader;
|
||||
|
||||
bool mUseDistortion;
|
||||
bool mUseChromaticAberation;
|
||||
glm::uvec2 mOutputViewport; // if it's 0,0 -> use the Rifts screen dimensions!
|
||||
private:
|
||||
glm::vec4 getShaderValue( int v );
|
||||
void updateCameraFoV();
|
||||
|
||||
bool mSuccessfulConnected;
|
||||
ACGL::Scene::SharedHMDCamera mCamera;
|
||||
float mDistortionScaleFactor;
|
||||
|
||||
// handles to the rift:
|
||||
OVR::Ptr<OVR::DeviceManager> mORManager;
|
||||
OVR::Ptr<OVR::HMDDevice> mORDevice;
|
||||
OVR::Ptr<OVR::SensorDevice> mORSensor;
|
||||
OVR::SensorFusion *mORSensorFusion;
|
||||
OVR::HMDInfo *mORHMDInfo;
|
||||
|
||||
// all rotations are relative to the one the Rift started with:
|
||||
OVR::Quatf mInverseNeutralRotation; // as quaternion
|
||||
|
||||
float mPredictionTime;
|
||||
float mFoVMultiplier;
|
||||
};
|
||||
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(SimpleRiftController)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // ACGL_USE_OCULUS_RIFT
|
37
extern/acgl/include/ACGL/HardwareSupport/SpaceNavControl.hh
vendored
Normal file
37
extern/acgl/include/ACGL/HardwareSupport/SpaceNavControl.hh
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2013 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
#include <ACGL/Scene/GenericCamera.hh>
|
||||
|
||||
namespace ACGL{
|
||||
namespace HardwareSupport{
|
||||
|
||||
/// Controls a GenericCamera with a space navigator
|
||||
class SpaceNavControl
|
||||
{
|
||||
public:
|
||||
SpaceNavControl(Scene::GenericCamera *_cam, const glm::vec3 &_moveSensitivity = glm::vec3(1.0), const glm::vec3 &_rotateSensitivity = glm::vec3(1.0));
|
||||
~SpaceNavControl();
|
||||
|
||||
/// Updates the camera: call this once a frame, it will poll the SpaceNavigator. The elapsed time is used to scale the movement to
|
||||
/// to be framerate independent.
|
||||
void update(float _elapsedSeconds);
|
||||
|
||||
private:
|
||||
/// The referenced camera
|
||||
Scene::GenericCamera *mCamera;
|
||||
|
||||
/// Sensitivity for moving the camera
|
||||
glm::vec3 mMoveSensitivity;
|
||||
/// Sensitivity for rotating the camera
|
||||
glm::vec3 mRotateSensitivity;
|
||||
};
|
||||
|
||||
} // HardwareSupport
|
||||
} // ACGL
|
90
extern/acgl/include/ACGL/HardwareSupport/SpaceNavPollInterface.hh
vendored
Normal file
90
extern/acgl/include/ACGL/HardwareSupport/SpaceNavPollInterface.hh
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2013 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
|
||||
namespace ACGL{
|
||||
namespace HardwareSupport{
|
||||
|
||||
/*
|
||||
* To compile:
|
||||
* Linux: do nothing
|
||||
* MacOS X: link to 3DconnexionClient,
|
||||
* e.g. add 'SET(LIBRARIES -Wl,-framework,3DconnexionClient)' to CMakeLists.txt
|
||||
* define ACGL_SPACE_NAVIGATOR_SUPPORT
|
||||
* Windows: only dummy functionality will get build
|
||||
*/
|
||||
|
||||
// Each listener should call this *once* before starting to poll,
|
||||
// the first listener will start a connection to the driver.
|
||||
// If the connection could be made, true will be returned, false otherwise.
|
||||
// If false gets returned, SpaceNavUnregisterListener() should not get called
|
||||
// and all SpaceNavPollEvent() calls will return 0 events.
|
||||
bool SpaceNavRegisterListener();
|
||||
|
||||
// Each listener should call this *once* when stopping to listen iff the call
|
||||
// to SpaceNavRegisterListener() returned true.
|
||||
// Last unregister call will trigger disconnection from the driver.
|
||||
void SpaceNavUnregisterListener();
|
||||
|
||||
enum SpaceNavEventType {
|
||||
movement,
|
||||
button,
|
||||
other
|
||||
};
|
||||
|
||||
// Values of the buttons:
|
||||
// the 2 button space navigator:
|
||||
static const int SNE_BUTTON_LEFT = 0;
|
||||
static const int SNE_BUTTON_RIGHT = 1;
|
||||
// the larger space pilot:
|
||||
static const int SNE_BUTTON_1 = 0;
|
||||
static const int SNE_BUTTON_2 = 1;
|
||||
static const int SNE_BUTTON_3 = 2;
|
||||
static const int SNE_BUTTON_4 = 3;
|
||||
static const int SNE_BUTTON_5 = 4;
|
||||
static const int SNE_BUTTON_6 = 5;
|
||||
static const int SNE_BUTTON_ESC = 10;
|
||||
static const int SNE_BUTTON_CTRL = 13;
|
||||
static const int SNE_BUTTON_ALT = 11;
|
||||
static const int SNE_BUTTON_SHIFT = 12;
|
||||
static const int SNE_BUTTON_CONFIG = 20;
|
||||
static const int SNE_BUTTON_PANEL = 15;
|
||||
static const int SNE_BUTTON_VOL_DOWN = 17;
|
||||
static const int SNE_BUTTON_VOL_UP = 16;
|
||||
static const int SNE_BUTTON_DOM = 18;
|
||||
static const int SNE_BUTTON_T = 6;
|
||||
static const int SNE_BUTTON_L = 7;
|
||||
static const int SNE_BUTTON_R = 8;
|
||||
static const int SNE_BUTTON_F = 9;
|
||||
static const int SNE_BUTTON_3D = 19;
|
||||
static const int SNE_BUTTON_FIT = 14;
|
||||
|
||||
//
|
||||
// translation and rotation can go from about -500 to 500.
|
||||
// note that the neutral postion might not be 0,0,0
|
||||
// not all axes have the same maximum value (-361 to 441 might be possible)
|
||||
struct SpaceNavEvent {
|
||||
SpaceNavEventType type;
|
||||
int x,y,z; // translation, right-handed-coord-system (right/up/towards the user are positive)
|
||||
int rx,ry,rz; // rotation, pitch-yaw-roll
|
||||
int button; // button number, see values above
|
||||
bool pressed; // button state, pressing the button down and release will create two events
|
||||
};
|
||||
|
||||
// Call this to poll for new events.
|
||||
// Return value is the number of valid events waiting, 0 means no event
|
||||
// is waiting and the eventToFill will not get changed in that situation.
|
||||
// If no device was found or the connection to the driver failed for other
|
||||
// reasons, 0 will get returned.
|
||||
// -> polling for events and only interpreting them if >0 gets returned
|
||||
// should be always save!
|
||||
unsigned int SpaceNavPollEvent( SpaceNavEvent &eventToFill );
|
||||
|
||||
} // HardwareSupport
|
||||
} // ACGL
|
114
extern/acgl/include/ACGL/HardwareSupport/mini_spnav.h
vendored
Normal file
114
extern/acgl/include/ACGL/HardwareSupport/mini_spnav.h
vendored
Normal file
@ -0,0 +1,114 @@
|
||||
/*
|
||||
This file is based on a part of libspnav, part of the spacenav project (spacenav.sf.net)
|
||||
Original file (spnav.h) Copyright (C) 2007-2010 John Tsiombikas <nuclear@member.fsf.org>
|
||||
This file (mini_spnav.h) Copyright (C) 2013 Robert Menzel
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. The name of the author may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef MINI_SPACENAV_H_
|
||||
#define MINI_SPACENAV_H_
|
||||
|
||||
/*
|
||||
* This file can be used as an alternative to spnav.h iff the library should get loaded
|
||||
* dynamically. Add this to your project and the code will compile independent of the
|
||||
* presence of libspnav (and also run independent of it).
|
||||
*/
|
||||
|
||||
#include <dlfcn.h> // for dlopen
|
||||
|
||||
enum {
|
||||
SPNAV_EVENT_ANY, /* used by spnav_remove_events() */
|
||||
SPNAV_EVENT_MOTION,
|
||||
SPNAV_EVENT_BUTTON /* includes both press and release */
|
||||
};
|
||||
|
||||
struct spnav_event_motion {
|
||||
int type;
|
||||
int x, y, z;
|
||||
int rx, ry, rz;
|
||||
unsigned int period;
|
||||
int *data;
|
||||
};
|
||||
|
||||
struct spnav_event_button {
|
||||
int type;
|
||||
int press;
|
||||
int bnum;
|
||||
};
|
||||
|
||||
typedef union spnav_event {
|
||||
int type;
|
||||
struct spnav_event_motion motion;
|
||||
struct spnav_event_button button;
|
||||
} spnav_event;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Open connection to the daemon via AF_UNIX socket.
|
||||
* The unix domain socket interface is an alternative to the original magellan
|
||||
* protocol, and it is *NOT* compatible with the 3D connexion driver. If you wish
|
||||
* to remain compatible, use the X11 protocol (spnav_x11_open, see below).
|
||||
* Returns -1 on failure.
|
||||
*/
|
||||
typedef int (*spnav_open_ptr)(void);
|
||||
|
||||
/* Close connection to the daemon. Use it for X11 or AF_UNIX connections.
|
||||
* Returns -1 on failure
|
||||
*/
|
||||
typedef int (*spnav_close_ptr)(void);
|
||||
|
||||
/* Retrieves the file descriptor used for communication with the daemon, for
|
||||
* use with select() by the application, if so required.
|
||||
* If the X11 mode is used, the socket used to communicate with the X server is
|
||||
* returned, so the result of this function is always reliable.
|
||||
* If AF_UNIX mode is used, the fd of the socket is returned or -1 if
|
||||
* no connection is open / failure occured.
|
||||
*/
|
||||
//int spnav_fd(void);
|
||||
|
||||
/* TODO: document */
|
||||
//int spnav_sensitivity(double sens);
|
||||
|
||||
/* blocks waiting for space-nav events. returns 0 if an error occurs */
|
||||
//int spnav_wait_event(spnav_event *event);
|
||||
|
||||
/* checks the availability of space-nav events (non-blocking)
|
||||
* returns the event type if available, or 0 otherwise.
|
||||
*/
|
||||
typedef int (*spnav_poll_event_ptr)(spnav_event *event);
|
||||
|
||||
/* Removes any pending events from the specified type, or all pending events
|
||||
* events if the type argument is SPNAV_EVENT_ANY. Returns the number of
|
||||
* removed events.
|
||||
*/
|
||||
//int spnav_remove_events(int type);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MINI_SPACENAV_H_ */
|
83
extern/acgl/include/ACGL/Math/Constants.hh
vendored
Normal file
83
extern/acgl/include/ACGL/Math/Constants.hh
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef ACGL_MATH_CONSTANTS_HH
|
||||
#define ACGL_MATH_CONSTANTS_HH
|
||||
|
||||
/*
|
||||
* Some mathmatical constants, for example readable degree to rad conversion.
|
||||
*
|
||||
* DON'T INCLUDE THIS DIRECTLY! Include <ACGL/Math.hh> instead!
|
||||
*/
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
|
||||
#ifndef M_PI
|
||||
// M_PI is not defined on e.g. VS2010 (isn't part of the standart), so in that case it gets defined here
|
||||
// outside of the namespace because some code might expect it to be in math.h which is oviously not in our namespace...
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
namespace ACGL{
|
||||
namespace Math{
|
||||
namespace Constants{
|
||||
|
||||
//some important constants
|
||||
const float INF_FLOAT = std::numeric_limits<float>::infinity();
|
||||
const double INF_DOUBLE = std::numeric_limits<double>::infinity();
|
||||
const int_t INF_INT = std::numeric_limits<int_t>::infinity();
|
||||
const short_t INF_SHORT = std::numeric_limits<short_t>::infinity();
|
||||
|
||||
template<typename T> inline T INF(void) { return T(); }
|
||||
template<> inline float INF<float> (void) { return INF_FLOAT; }
|
||||
template<> inline double INF<double> (void) { return INF_DOUBLE; }
|
||||
template<> inline int_t INF<int_t> (void) { return INF_INT; }
|
||||
template<> inline short_t INF<short_t> (void) { return INF_SHORT; }
|
||||
|
||||
//gets used for some floating-point comparisions
|
||||
const float EPSILON_FLOAT = 0.0005f;
|
||||
const double EPSILON_DOUBLE = 0.0005;
|
||||
const float SQUARED_EPSILON_FLOAT = 0.00000025f;
|
||||
const double SQUARED_EPSILON_DOUBLE = 0.00000025;
|
||||
|
||||
template<typename T> inline T EPSILON(void) { return T(); }
|
||||
template<> inline float EPSILON<float> (void) { return EPSILON_FLOAT; }
|
||||
template<> inline double EPSILON<double>(void) { return EPSILON_DOUBLE; }
|
||||
|
||||
template<typename T> inline T SQUARED_EPSILON(void) { return T(); }
|
||||
template<> inline float SQUARED_EPSILON<float> (void) { return SQUARED_EPSILON_FLOAT; }
|
||||
template<> inline double SQUARED_EPSILON<double>(void) { return SQUARED_EPSILON_DOUBLE; }
|
||||
|
||||
//Sine and Cosine stuff
|
||||
const float PI_FLOAT = (float) M_PI;
|
||||
const double PI_DOUBLE = (double) M_PI;
|
||||
|
||||
template<typename T> inline T PI(void) { return T(); }
|
||||
template<> inline float PI<float> (void) { return PI_FLOAT; }
|
||||
template<> inline double PI<double>(void) { return PI_DOUBLE; }
|
||||
|
||||
//constants to change from degree to radians and back
|
||||
const float DEG_TO_RAD_FLOAT = PI_FLOAT / 180.0f;
|
||||
const double DEG_TO_RAD_DOUBLE = PI_DOUBLE / 180.0 ;
|
||||
const float RAD_TO_DEG_FLOAT = 180.0f / PI_FLOAT;
|
||||
const double RAD_TO_DEG_DOUBLE = 180.0 / PI_DOUBLE;
|
||||
|
||||
template<typename T> inline T DEG_TO_RAD(void) { return T(); }
|
||||
template<> inline float DEG_TO_RAD<float> (void) { return DEG_TO_RAD_FLOAT; }
|
||||
template<> inline double DEG_TO_RAD<double>(void) { return RAD_TO_DEG_DOUBLE; }
|
||||
|
||||
template<typename T> inline T RED_TO_DEG(void) { return T(); }
|
||||
template<> inline float RED_TO_DEG<float> (void) { return DEG_TO_RAD_FLOAT; }
|
||||
template<> inline double RED_TO_DEG<double>(void) { return RAD_TO_DEG_DOUBLE; }
|
||||
|
||||
} // Constants
|
||||
} // Math
|
||||
} // ACGL
|
||||
|
||||
#endif // ACGL_MATH_CONSTANTS_HH
|
168
extern/acgl/include/ACGL/Math/Functions.hh
vendored
Normal file
168
extern/acgl/include/ACGL/Math/Functions.hh
vendored
Normal file
@ -0,0 +1,168 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef ACGL_MATH_FUNCTIONS_HH
|
||||
#define ACGL_MATH_FUNCTIONS_HH
|
||||
|
||||
/*
|
||||
* Some basic math functions.
|
||||
*
|
||||
* DON'T INCLUDE THIS DIRECTLY! Include <ACGL/Math.hh> instead!
|
||||
*/
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
#include <ACGL/Math/Constants.hh>
|
||||
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
#include <algorithm>
|
||||
|
||||
namespace ACGL{
|
||||
namespace Math{
|
||||
namespace Functions{
|
||||
|
||||
//functions to change from degree to radians and back
|
||||
inline float calcDegToRad(float d) {return (d * Constants::DEG_TO_RAD_FLOAT);}
|
||||
inline double calcDegToRad(double d) {return (d * Constants::DEG_TO_RAD_DOUBLE);}
|
||||
inline float calcRadToDeg(float r) {return (r * Constants::RAD_TO_DEG_FLOAT);}
|
||||
inline double calcRadToDeg(double r) {return (r * Constants::RAD_TO_DEG_DOUBLE);}
|
||||
|
||||
//sine, cosine and tangens
|
||||
inline float sinRad(float r) {return (::sinf(r));}
|
||||
inline float cosRad(float r) {return (::cosf(r));}
|
||||
inline float tanRad(float r) {return (::tanf(r));}
|
||||
inline float sinDeg(float d) {return (::sinf(d * Constants::DEG_TO_RAD_FLOAT));}
|
||||
inline float cosDeg(float d) {return (::cosf(d * Constants::DEG_TO_RAD_FLOAT));}
|
||||
inline float tanDeg(float d) {return (::tanf(d * Constants::DEG_TO_RAD_FLOAT));}
|
||||
|
||||
inline double sinRad(double r) {return (::sin(r));}
|
||||
inline double cosRad(double r) {return (::cos(r));}
|
||||
inline double tanRad(double r) {return (::tan(r));}
|
||||
inline double sinDeg(double d) {return (::sin(d * Constants::DEG_TO_RAD_DOUBLE));}
|
||||
inline double cosDeg(double d) {return (::cos(d * Constants::DEG_TO_RAD_DOUBLE));}
|
||||
inline double tanDeg(double d) {return (::tan(d * Constants::DEG_TO_RAD_DOUBLE));}
|
||||
|
||||
//and back! (asin, acos and atan)
|
||||
inline float asinRad (float v) {return (::asinf (v));}
|
||||
inline float acosRad (float v) {return (::acosf (v));}
|
||||
inline float atanRad (float v) {return (::atanf (v));}
|
||||
inline float atan2Rad(float a, float b) {return (::atan2f(a, b));}
|
||||
inline float asinDeg (float v) {return (::asinf (v) * Constants::RAD_TO_DEG_FLOAT);}
|
||||
inline float acosDeg (float v) {return (::acosf (v) * Constants::RAD_TO_DEG_FLOAT);}
|
||||
inline float atanDeg (float v) {return (::atanf (v) * Constants::RAD_TO_DEG_FLOAT);}
|
||||
inline float atan2Deg(float a, float b) {return (::atan2f(a, b) * Constants::RAD_TO_DEG_FLOAT);}
|
||||
|
||||
inline double asinRad(double v) {return (::asin (v));}
|
||||
inline double acosRad(double v) {return (::acos (v));}
|
||||
inline double atanRad(double v) {return (::atan (v));}
|
||||
inline double atan2Rad(double a, double b) {return (::atan2(a, b));}
|
||||
inline double asinDeg(double v) {return (::asin (v) * Constants::RAD_TO_DEG_DOUBLE);}
|
||||
inline double acosDeg(double v) {return (::acos (v) * Constants::RAD_TO_DEG_DOUBLE);}
|
||||
inline double atanDeg(double v) {return (::atan (v) * Constants::RAD_TO_DEG_DOUBLE);}
|
||||
inline double atan2Deg(double a, double b) {return (::atan2(a, b) * Constants::RAD_TO_DEG_DOUBLE);}
|
||||
|
||||
//Helpers
|
||||
inline int32_t round(float a) {return (int32_t) ( (a < 0.5f)? ceil(a-0.5f) : floor(a+0.5f) );}
|
||||
inline int32_t round(double a) {return (int32_t) ( (a < 0.5 )? ceil(a-0.5 ) : floor(a+0.5 ) );}
|
||||
|
||||
inline float pow(float a, float b) { return ::powf(a, b); }
|
||||
inline double pow(double a, double b) { return ::pow(a, b); }
|
||||
|
||||
inline float ceil(float a) {return ::ceilf(a);}
|
||||
inline double ceil(double a) {return ::ceil(a);}
|
||||
|
||||
inline float floor(float a) {return ::floorf(a);}
|
||||
inline double floor(double a) {return ::floor(a);}
|
||||
|
||||
inline float sqrt(float a) {return(::sqrtf(a));}
|
||||
inline double sqrt(double a) {return(::sqrt (a));}
|
||||
|
||||
inline float sig(float a) {return(a < 0.0f ? -1.0f : 1.0f);}
|
||||
inline double sig(double a) {return(a < 0.0 ? -1.0 : 1.0 );}
|
||||
|
||||
inline float abs(float a) {return(a < 0.0f ? -a : a);}
|
||||
inline double abs(double a) {return(a < 0.0 ? -a : a);}
|
||||
inline int_t abs(int_t a) {return(a < 0 ? -a : a);}
|
||||
|
||||
inline double randD (double _from = 0.0, double _to = 1.0) { return (_to - _from) * (double(rand()) / double(RAND_MAX)) + _from; }
|
||||
inline int32_t randI32 (int32_t _from = 0, int32_t _to = 1) { return (rand() % (_to - _from + 1)) + _from; }
|
||||
|
||||
template<typename T>
|
||||
inline T max(T a, T b) {return(a > b ? a : b);}
|
||||
|
||||
template<typename T>
|
||||
inline T min(T a, T b) {return(a < b ? a : b);}
|
||||
|
||||
inline uint_t ring(int_t a, uint_t mod) {bool b = a < 0; a = abs(a) % mod; return(b ? mod - a : a);}
|
||||
|
||||
/**
|
||||
* @brief Returns a rotation matrix that rotates a givn degree around the X-axis.
|
||||
* @param degree is the angle in degree, not radians!
|
||||
* @return The rotation matrix.
|
||||
*/
|
||||
glm::mat3 rotationMatrixX(float degree);
|
||||
|
||||
/**
|
||||
* @brief Returns a rotation matrix that rotates a givn degree around the Y-axis.
|
||||
* @param degree is the angle in degree, not radians!
|
||||
* @return The rotation matrix.
|
||||
*/
|
||||
glm::mat3 rotationMatrixY(float degree);
|
||||
|
||||
/**
|
||||
* @brief Returns a rotation matrix that rotates a givn degree around the Z-axis.
|
||||
* @param degree is the angle in degree, not radians!
|
||||
* @return The rotation matrix.
|
||||
*/
|
||||
glm::mat3 rotationMatrixZ(float degree);
|
||||
|
||||
/**
|
||||
* @brief Returns the inverse transpose of the given matrix to use as a normal matrix.
|
||||
* @param The e.g. modelview matrix.
|
||||
* @return The inverse transposed.
|
||||
*/
|
||||
inline glm::mat3 normalMatrix(const glm::mat4& matrix)
|
||||
{
|
||||
return glm::inverseTranspose( glm::mat3( matrix ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test if two glm vectors are equal with respect to a given epsilon.
|
||||
*/
|
||||
template<typename T>
|
||||
bool isApproxEqual(const T &_v1, const T &_v2, float _eps = .01)
|
||||
{
|
||||
return glm::distance(_v1, _v2) < _eps;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief isApproxEqual returns whether two glm 4x4 matrices are equal with respect to a small epsilon.
|
||||
* @param _v1: first matrix
|
||||
* @param _v2: second matrix
|
||||
* @param _eps: small numerical value
|
||||
* @return true if the sum off the componentwise difference is smaller than _eps.
|
||||
*/
|
||||
bool isApproxEqual(const glm::mat4 &_v1, const glm::mat4 &_v2, float _eps = .01);
|
||||
|
||||
/**
|
||||
* @brief isApproxEqual returns whether two glm 3x3 matrices are equal with respect to a small epsilon.
|
||||
* @param _v1: first matrix
|
||||
* @param _v2: second matrix
|
||||
* @param _eps: small numerical value
|
||||
* @return true if the sum off the componentwise difference is smaller than _eps.
|
||||
*/
|
||||
bool isApproxEqual(const glm::mat3 &_v1, const glm::mat3 &_v2, float _eps = .01);
|
||||
|
||||
/**
|
||||
* @brief Checks if a given matrix is orthonormal.
|
||||
*/
|
||||
bool isOrthonormalMatrix(const glm::mat3 &_matrix);
|
||||
|
||||
} // Functions
|
||||
} // Math
|
||||
} // ACGL
|
||||
|
||||
#endif // ACGL_MATH_FUNCTIONS_HH
|
83
extern/acgl/include/ACGL/Math/Math.hh
vendored
Normal file
83
extern/acgl/include/ACGL/Math/Math.hh
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef ACGL_MATH_HH
|
||||
#define ACGL_MATH_HH
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
|
||||
/*
|
||||
* For our basic vector math we use the GLM library.
|
||||
* This library has the advantage that it was designed to mimic the
|
||||
* syntax of GLSL for datatypes (vectors, matrices etc.) as well as functions.
|
||||
* It also supports swizzling similar to GLSL.
|
||||
*
|
||||
* Swizzling has to be defined before the glm.hpp gets first included, no not forget
|
||||
* this, you should never include glm yourself, but include always our ACGL/Math.hh!
|
||||
*/
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
// ignore compiler warnings from GLM:
|
||||
//
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning( push )
|
||||
#pragma warning ( disable : 4201 )
|
||||
#pragma warning ( disable : 4100 )
|
||||
#pragma warning ( disable : 4996 )
|
||||
#pragma warning ( disable : 4244 )
|
||||
#endif
|
||||
|
||||
#if (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4))
|
||||
#define COMPILER_IS_GCC_4_6_OR_NEWER
|
||||
#endif
|
||||
|
||||
#ifdef __clang__
|
||||
// clang/llvm:
|
||||
# pragma clang diagnostic push
|
||||
# pragma clang diagnostic ignored "-Wuninitialized"
|
||||
# pragma clang diagnostic ignored "-Wunused-parameter"
|
||||
#elif defined __GNUC__
|
||||
# ifdef COMPILER_IS_GCC_4_6_OR_NEWER
|
||||
// gcc >= 4.6:
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wtype-limits"
|
||||
# pragma GCC diagnostic ignored "-Wunused-but-set-variable"
|
||||
# pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
||||
# endif
|
||||
// gcc:
|
||||
# pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
#endif
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define GLM_FORCE_RADIANS
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtx/transform.hpp>
|
||||
#include <glm/ext.hpp>
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
// reactivate compiler warnings:
|
||||
//
|
||||
#ifdef __clang__
|
||||
// clang/llvm:
|
||||
# pragma clang diagnostic pop
|
||||
#elif defined COMPILER_IS_GCC_4_6_OR_NEWER
|
||||
// gcc >= 4.6:
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning( pop )
|
||||
#endif
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <ACGL/Math/Constants.hh>
|
||||
#include <ACGL/Math/Functions.hh>
|
||||
|
||||
#endif // ACGL_MATH_HH
|
13
extern/acgl/include/ACGL/OpenGL/Controller.hh
vendored
Normal file
13
extern/acgl/include/ACGL/OpenGL/Controller.hh
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
#include <ACGL/OpenGL/Controller/ShaderControlFile.hh>
|
||||
#include <ACGL/OpenGL/Controller/ShaderProgramControlFiles.hh>
|
||||
#include <ACGL/OpenGL/Controller/VertexArrayObjectControlFile.hh>
|
||||
|
22
extern/acgl/include/ACGL/OpenGL/Controller/ShaderControlFile.hh
vendored
Normal file
22
extern/acgl/include/ACGL/OpenGL/Controller/ShaderControlFile.hh
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2013 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ACGL/OpenGL/Creator/ShaderCreator.hh>
|
||||
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
typedef ACGL::OpenGL::ShaderCreator ShaderControlFile;
|
||||
#ifdef _MSC_VER
|
||||
#pragma message(__FILE__" : warning: ShaderControlFile is deprecated, use ShaderCreator instead (same interface)")
|
||||
#else
|
||||
#warning "ShaderControlFile is deprecated, use ShaderCreator instead (same interface)"
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
22
extern/acgl/include/ACGL/OpenGL/Controller/ShaderProgramControlFiles.hh
vendored
Normal file
22
extern/acgl/include/ACGL/OpenGL/Controller/ShaderProgramControlFiles.hh
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2013 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ACGL/OpenGL/Creator/ShaderProgramCreator.hh>
|
||||
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
typedef ACGL::OpenGL::ShaderProgramCreator ShaderProgramControlFiles;
|
||||
#ifdef _MSC_VER
|
||||
#pragma message(__FILE__" : warning: ShaderProgramControlFiles is deprecated, use ShaderProgramCreator instead (same interface)")
|
||||
#else
|
||||
#warning "ShaderProgramControlFiles is deprecated, use ShaderProgramCreator instead (same interface)"
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
22
extern/acgl/include/ACGL/OpenGL/Controller/VertexArrayObjectControlFile.hh
vendored
Normal file
22
extern/acgl/include/ACGL/OpenGL/Controller/VertexArrayObjectControlFile.hh
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2013 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ACGL/OpenGL/Creator/VertexArrayObjectCreator.hh>
|
||||
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
typedef ACGL::OpenGL::VertexArrayObjectCreator VertexArrayObjectControlFile;
|
||||
#ifdef _MSC_VER
|
||||
#pragma message(__FILE__" : warning: VertexArrayObjectControlFile is deprecated, use VertexArrayObjectCreator instead (same interface)")
|
||||
#else
|
||||
#warning "VertexArrayObjectControlFile is deprecated, use VertexArrayObjectCreator instead (same interface)"
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
95
extern/acgl/include/ACGL/OpenGL/Creator/ArrayBufferCreator.hh
vendored
Normal file
95
extern/acgl/include/ACGL/OpenGL/Creator/ArrayBufferCreator.hh
vendored
Normal file
@ -0,0 +1,95 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
#include <ACGL/OpenGL/Objects/ArrayBuffer.hh>
|
||||
#include <ACGL/OpenGL/GL.hh>
|
||||
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
class ArrayBufferCreator
|
||||
{
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ STRUCTS \/
|
||||
// ==================================================================================================== \/
|
||||
public:
|
||||
struct AttributeDefine
|
||||
{
|
||||
std::string name;
|
||||
GLenum type;
|
||||
GLint dimension;
|
||||
GLboolean normalized;
|
||||
GLboolean isInteger;
|
||||
};
|
||||
|
||||
// ===================================================================================================== \/
|
||||
// ============================================================================================ TYPEDEFS \/
|
||||
// ===================================================================================================== \/
|
||||
public:
|
||||
typedef std::vector< AttributeDefine > AttributeDefineVec;
|
||||
|
||||
// ========================================================================================================= \/
|
||||
// ============================================================================================ CONSTRUCTORS \/
|
||||
// ========================================================================================================= \/
|
||||
public:
|
||||
ArrayBufferCreator(void)
|
||||
: mUsage(GL_STATIC_DRAW),
|
||||
mElements(0),
|
||||
mpData(NULL),
|
||||
mAttributeDefines()
|
||||
{}
|
||||
virtual ~ArrayBufferCreator() {}
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ METHODS \/
|
||||
// ==================================================================================================== \/
|
||||
public:
|
||||
inline ArrayBufferCreator& usage (GLenum _usage) { mUsage = _usage; return *this; }
|
||||
|
||||
inline ArrayBufferCreator& data (const GLvoid* _pData, GLsizei _elements)
|
||||
{
|
||||
mpData = _pData;
|
||||
mElements = _elements;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline ArrayBufferCreator& attribute (const std::string& _name, GLenum _type, GLint _dimension, GLboolean _normalized = GL_FALSE)
|
||||
{
|
||||
AttributeDefine a = {_name, _type, _dimension, _normalized, GL_FALSE};
|
||||
mAttributeDefines.push_back(a);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline ArrayBufferCreator& integerAttribute (const std::string& _name, GLenum _type, GLint _dimension)
|
||||
{
|
||||
AttributeDefine a = {_name, _type, _dimension, GL_FALSE, GL_TRUE};
|
||||
mAttributeDefines.push_back(a);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// ===================================================================================================== \/
|
||||
// ============================================================================================ OVERRIDE \/
|
||||
// ===================================================================================================== \/
|
||||
public:
|
||||
SharedArrayBuffer create();
|
||||
|
||||
// =================================================================================================== \/
|
||||
// ============================================================================================ FIELDS \/
|
||||
// =================================================================================================== \/
|
||||
protected:
|
||||
GLenum mUsage;
|
||||
GLsizei mElements;
|
||||
const GLvoid* mpData;
|
||||
AttributeDefineVec mAttributeDefines;
|
||||
};
|
||||
|
||||
} // OpenGL
|
||||
} // ACGL
|
||||
|
85
extern/acgl/include/ACGL/OpenGL/Creator/ShaderCreator.hh
vendored
Normal file
85
extern/acgl/include/ACGL/OpenGL/Creator/ShaderCreator.hh
vendored
Normal file
@ -0,0 +1,85 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2013 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* Can create one Shader from one file.
|
||||
* Most of the time using this directly is not useful as the creation
|
||||
* of a whole ShaderProgam is desired.
|
||||
*
|
||||
* See ShaderProgramCreator for more information!
|
||||
*/
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
|
||||
#include <ACGL/Resource/SingleFileBasedCreator.hh>
|
||||
#include <ACGL/Base/Settings.hh>
|
||||
#include <ACGL/OpenGL/Objects/Shader.hh>
|
||||
#include <ACGL/OpenGL/GL.hh>
|
||||
|
||||
#include <ACGL/OpenGL/Creator/ShaderParserFactory.hh>
|
||||
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
class ShaderCreator : public Resource::SingleFileBasedCreator<Shader>
|
||||
{
|
||||
// ========================================================================================================= \/
|
||||
// ============================================================================================ CONSTRUCTORS \/
|
||||
// ========================================================================================================= \/
|
||||
public:
|
||||
ShaderCreator(const std::string& _filename)
|
||||
: Resource::SingleFileBasedCreator<Shader>(_filename, Base::Settings::the()->getFullShaderPath()),
|
||||
mType(GL_INVALID_ENUM)
|
||||
{
|
||||
mShaderParserFactory = SharedShaderParserFactory( new SimpleShaderParserFactory<IncludingShaderParser>() );
|
||||
}
|
||||
virtual ~ShaderCreator() {}
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ METHODS \/
|
||||
// ==================================================================================================== \/
|
||||
public:
|
||||
inline ShaderCreator& type (GLenum _type) { mType = _type; return *this; }
|
||||
|
||||
ShaderCreator& setResourceName(const std::string &_resourceName) { mResourceName = _resourceName; return *this; }
|
||||
|
||||
//
|
||||
// Override shader processing
|
||||
//
|
||||
|
||||
/// Sets the shader parser factory
|
||||
/// For more detailed documentation, see ShaderParser.hh
|
||||
inline ShaderCreator& shaderParserFactory(SharedShaderParserFactory const& _factory) { mShaderParserFactory = _factory; return *this; }
|
||||
|
||||
// ===================================================================================================== \/
|
||||
// ============================================================================================ OVERRIDE \/
|
||||
// ===================================================================================================== \/
|
||||
public:
|
||||
virtual SharedShader create();
|
||||
virtual bool update(SharedShader& shader);
|
||||
|
||||
// =================================================================================================== \/
|
||||
// ============================================================================================ FIELDS \/
|
||||
// =================================================================================================== \/
|
||||
protected:
|
||||
GLenum mType;
|
||||
|
||||
SharedShaderParserFactory mShaderParserFactory;
|
||||
|
||||
struct ImportedShader {
|
||||
std::string fileName;
|
||||
Utils::FileHelpers::FileModificationTime modificatonTime;
|
||||
};
|
||||
|
||||
std::vector< ImportedShader > mImportedShaders; // in case the shader imports additional shaders files
|
||||
};
|
||||
|
||||
} // OpenGL
|
||||
} // ACGL
|
||||
|
||||
|
141
extern/acgl/include/ACGL/OpenGL/Creator/ShaderParser.hh
vendored
Normal file
141
extern/acgl/include/ACGL/OpenGL/Creator/ShaderParser.hh
vendored
Normal file
@ -0,0 +1,141 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
|
||||
#include <ACGL/Base/Macros.hh>
|
||||
#include <ACGL/OpenGL/GL.hh>
|
||||
#include <ACGL/OpenGL/Tools.hh>
|
||||
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
/**
|
||||
* @brief ShaderParser for processing shader source code
|
||||
*
|
||||
* Subclass this and provide alternative ShaderParserFactories to Creators in order to implement custom shader processing
|
||||
* Override processPragma in order to create custom pragma handling
|
||||
*
|
||||
* For an overview and an example, see http://www.graphics.rwth-aachen.de/redmine/projects/acgl/wiki/Custom_shader_parser
|
||||
*/
|
||||
class ShaderParser
|
||||
{
|
||||
//ACGL_NOT_COPYABLE(ShaderParser)
|
||||
|
||||
public:
|
||||
ShaderParser( const std::string &_filename );
|
||||
virtual ~ShaderParser() { }
|
||||
|
||||
std::vector< std::string > getSources() const { return mSources; }
|
||||
std::string getFileNamesPrintable() const;
|
||||
|
||||
//! the imported sources don't count the original file!
|
||||
unsigned int getNumberOfImportedFiles() const { return mSourceFileNames.size()-1; }
|
||||
|
||||
//! 0 == original file
|
||||
std::string getFileName( unsigned int i ) const { return mSourceFileNames[i]; }
|
||||
|
||||
/**
|
||||
* @brief checks if a given Sourcefile name exists
|
||||
* @param _filename filename to check
|
||||
* @return true, iff mSourceFileNames contains _filename
|
||||
*/
|
||||
bool existsSourcefile(std::string const& _filename);
|
||||
|
||||
/**
|
||||
* @brief parses a complete file
|
||||
* @param _filename the file to parse
|
||||
*/
|
||||
void parse(std::string const& _filename);
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* @brief registers a new SourceFile
|
||||
* @param _name name of the file (may be an actual filename or a name that indicates automatic generation)
|
||||
* @return an ID that is to be used in #line statements and getFileName-Index.
|
||||
*/
|
||||
int registerSourceFile(std::string const& _name);
|
||||
|
||||
/**
|
||||
* @brief adds a chunk of source to the shader
|
||||
* @param _source source string
|
||||
*
|
||||
* Does not have to correspond to files
|
||||
*/
|
||||
void addSource(std::string const& _source);
|
||||
|
||||
/**
|
||||
* @brief constructs a line directive
|
||||
* @param _lineNumber line number (starts at 1)
|
||||
* @param _fileID file ID (usually from registerSourceFile)
|
||||
* @return a string with the format "#line lineNr fileID\n"
|
||||
*/
|
||||
std::string lineDirective(int _lineNumber, int _fileID) const;
|
||||
|
||||
/**
|
||||
* @brief processes a custom Pragma directive
|
||||
* @param _tokens vector of tokens after #pragma (e.g. "#pragma myPragma 5" results in _tokens = { "myPragma", "5" })
|
||||
* @param _filename name of the current source file (changes for different includes, does not reflect custom file names)
|
||||
*
|
||||
* Override this function to implement custom pragma handling (no need to call base function)
|
||||
*
|
||||
* Recommended behavior:
|
||||
* - Check if pragma is valid, otherwise call base::processPragma
|
||||
* - Start with lineNumber 1
|
||||
* - Register appropriate source file (using registerSourceFile(...))
|
||||
* - Initialize source content with lineDirective(lineNumber, fileID)
|
||||
* - Add custom source content
|
||||
* - Call addSource(...) with your source content
|
||||
* - Return true
|
||||
*/
|
||||
virtual bool processPragma(std::vector<std::string> const& _tokens, std::string const& _filename);
|
||||
|
||||
/**
|
||||
* @brief reads in a source file from file system
|
||||
* @param _filename filename of the source file
|
||||
*
|
||||
* Override this function to implement custom file reading functionality
|
||||
*/
|
||||
virtual void readin( const std::string &_filename );
|
||||
|
||||
private:
|
||||
bool lineContainsVersion( const std::string &line, unsigned int &version);
|
||||
bool lineContainsImport( const std::string &line, std::string &filename);
|
||||
bool lineContainsPragma( const std::string &line, std::vector<std::string> &pragmaToken);
|
||||
|
||||
std::vector< std::string > mSources;
|
||||
std::vector< std::string > mSourceFileNames; // holds at least one filename
|
||||
unsigned int mMaxVersion;
|
||||
};
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(ShaderParser)
|
||||
|
||||
/**
|
||||
* @brief A ShaderParser that recognizes shader includes
|
||||
*
|
||||
* e.g.
|
||||
* #pragma ACGLimport "matrices.glsl"
|
||||
*/
|
||||
class IncludingShaderParser : public ShaderParser
|
||||
{
|
||||
public:
|
||||
/// c'tor
|
||||
IncludingShaderParser( std::string const& _filename );
|
||||
|
||||
/**
|
||||
* Processes "#pragma ACGLimport filename"
|
||||
*/
|
||||
virtual bool processPragma(std::vector<std::string> const& _tokens, std::string const& _filename);
|
||||
};
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(IncludingShaderParser)
|
||||
|
||||
} // OpenGL
|
||||
} // ACGL
|
69
extern/acgl/include/ACGL/OpenGL/Creator/ShaderParserFactory.hh
vendored
Normal file
69
extern/acgl/include/ACGL/OpenGL/Creator/ShaderParserFactory.hh
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2013 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
|
||||
#include <ACGL/Resource/MultiFileBasedCreator.hh>
|
||||
#include <ACGL/Resource/SingleFileBasedCreator.hh>
|
||||
#include <ACGL/OpenGL/Objects/ShaderProgram.hh>
|
||||
#include <ACGL/OpenGL/GL.hh>
|
||||
#include <ACGL/Base/Settings.hh>
|
||||
|
||||
#include <vector>
|
||||
#include <ACGL/OpenGL/Data/LocationMappings.hh>
|
||||
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
/**
|
||||
* @brief Factory for shader parser
|
||||
*
|
||||
* This can be used in in the shader program creator to create post-processes for shader
|
||||
*
|
||||
* For more detailed documentation, see ShaderParser.hh
|
||||
*/
|
||||
class ShaderParserFactory
|
||||
{
|
||||
ACGL_NOT_COPYABLE(ShaderParserFactory)
|
||||
|
||||
public:
|
||||
ShaderParserFactory() { }
|
||||
virtual ~ShaderParserFactory() { }
|
||||
|
||||
/**
|
||||
* @brief creates a Parser for a given source file
|
||||
* @param _filename filename of the shader that is going to be compiled
|
||||
* @return a new ShaderParser instance
|
||||
*
|
||||
* Returns the a default shader parse that is able to include other shader
|
||||
* Override this function to create your own functionality
|
||||
*/
|
||||
virtual SharedShaderParser createParser(std::string const& _filename) = 0;
|
||||
};
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(ShaderParserFactory)
|
||||
|
||||
|
||||
/**
|
||||
* @brief A simple templated shader parser factory
|
||||
*
|
||||
* calls std::make_shared<ShaderParserT>(_filename), so make sure that the (string const&)-c'tor is publicly accessible
|
||||
*/
|
||||
template<typename ShaderParserT>
|
||||
class SimpleShaderParserFactory : public ShaderParserFactory
|
||||
{
|
||||
public:
|
||||
/// see parent
|
||||
virtual SharedShaderParser createParser(std::string const& _filename)
|
||||
{
|
||||
//return std::make_shared<ShaderParserT>(_filename);
|
||||
return SharedShaderParser( new ShaderParserT(_filename) );
|
||||
}
|
||||
};
|
||||
|
||||
} // OpenGL
|
||||
} // ACGL
|
169
extern/acgl/include/ACGL/OpenGL/Creator/ShaderProgramCreator.hh
vendored
Normal file
169
extern/acgl/include/ACGL/OpenGL/Creator/ShaderProgramCreator.hh
vendored
Normal file
@ -0,0 +1,169 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2013 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* Used to create a ShaderProgram from a given set of file names:
|
||||
* e.g.:
|
||||
* SharedShaderProgram prog = ShaderProgramCreator("file.vsh").andFile("foobar.fsh").create();
|
||||
*
|
||||
* The shadertype will be guessed by the extensions.
|
||||
*/
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
|
||||
#include <ACGL/Resource/MultiFileBasedCreator.hh>
|
||||
#include <ACGL/Resource/SingleFileBasedCreator.hh>
|
||||
#include <ACGL/OpenGL/Objects/ShaderProgram.hh>
|
||||
#include <ACGL/OpenGL/GL.hh>
|
||||
#include <ACGL/Base/Settings.hh>
|
||||
|
||||
#include <vector>
|
||||
#include <ACGL/OpenGL/Data/LocationMappings.hh>
|
||||
|
||||
#include <ACGL/OpenGL/Creator/ShaderParserFactory.hh>
|
||||
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
class ShaderProgramCreator : public Resource::MultiFileBasedCreator<ShaderProgram>
|
||||
{
|
||||
// ========================================================================================================= \/
|
||||
// ============================================================================================ CONSTRUCTORS \/
|
||||
// ========================================================================================================= \/
|
||||
public:
|
||||
//! The filenames (sorted and concatenated) will also be the name of the resource (can be changed by setResourceName() below).
|
||||
//! If the filename has a dot in it (or _type is set), it will be treated as a single file, otherwise all
|
||||
//! files starting with that string will be used.
|
||||
//! The empty c'tor is supported for containers and everything that needs one
|
||||
ShaderProgramCreator(const std::string& _fileName = "", GLenum _type = GL_INVALID_VALUE )
|
||||
: Resource::MultiFileBasedCreator<ShaderProgram>(),
|
||||
mShaderType(),
|
||||
mAttributeLocations(new LocationMappings),
|
||||
mFragmentDataLocations(new LocationMappings),
|
||||
mUniformBufferLocations(new LocationMappings) //,
|
||||
//mShaderParserFactory(std::make_shared<SimpleShaderParserFactory<IncludingShaderParser> >())
|
||||
{
|
||||
mShaderParserFactory = SharedShaderParserFactory( new SimpleShaderParserFactory<IncludingShaderParser>() );
|
||||
|
||||
// the base path is only needed for updating the time stamps, as the shaders itself get loaded via ShaderCreators
|
||||
// which itself will add the base path! (read: mFileNames will _NOT_ store the base path!)
|
||||
mBasePath = Base::Settings::the()->getFullShaderPath();
|
||||
|
||||
if ( _type != GL_INVALID_VALUE ) {
|
||||
andFile( _fileName, _type );
|
||||
return;
|
||||
}
|
||||
// only add the first name if it is a valid file name
|
||||
if ( _fileName.find( "." ) != std::string::npos ) {
|
||||
andFile( _fileName );
|
||||
} else {
|
||||
autoFiles( _fileName );
|
||||
}
|
||||
}
|
||||
|
||||
virtual ~ShaderProgramCreator() {}
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ METHODS \/
|
||||
// ==================================================================================================== \/
|
||||
public:
|
||||
ShaderProgramCreator& setResourceName(const std::string &_resourceName) { mResourceName = _resourceName; return *this; }
|
||||
|
||||
//
|
||||
// Override shader processing
|
||||
//
|
||||
|
||||
/// Sets the shader parser factory
|
||||
/// For more detailed documentation, see ShaderParser.hh
|
||||
inline ShaderProgramCreator& shaderParserFactory(SharedShaderParserFactory const& _factory) { mShaderParserFactory = _factory; return *this; }
|
||||
|
||||
//
|
||||
// Adding files:
|
||||
//
|
||||
//! adds a single file, the shader type will be guessed by the ending:
|
||||
inline ShaderProgramCreator& andFile (const std::string &_fileName) { addFile( _fileName ); mShaderType.push_back( GL_INVALID_VALUE ); return *this; }
|
||||
|
||||
//! adds a single file, the shader type is explicitly given and must be one of:
|
||||
//! GL_VERTEX_SHADER, GL_TESS_CONTROL_SHADER, GL_TESS_EVALUATION_SHADER, GL_GEOMETRY_SHADER, GL_FRAGMENT_SHADER, GL_COMPUTE_SHADER
|
||||
inline ShaderProgramCreator& andFile (const std::string &_fileName, GLenum _type) { addFile( _fileName ); mShaderType.push_back( _type ); return *this; }
|
||||
|
||||
//! adds all files begining with the given name, the shader type will be guessed by the ending:
|
||||
ShaderProgramCreator& autoFiles (const std::string &_fileName);
|
||||
|
||||
//
|
||||
// Adding attribute locations:
|
||||
//
|
||||
//! adds an attribute location to the next free location number:
|
||||
inline ShaderProgramCreator& attributeLocation (const std::string &_attributeName) { mAttributeLocations->setLocation(_attributeName); return *this; }
|
||||
|
||||
//! adds an attribute location to the given location number:
|
||||
inline ShaderProgramCreator& attributeLocation (const std::string &_attributeName, GLuint _location) { mAttributeLocations->setLocation(_attributeName,_location); return *this; }
|
||||
|
||||
//! adds a whole list of mappings
|
||||
inline ShaderProgramCreator& attributeLocations (const SharedLocationMappings &_mapping) { mAttributeLocations->addLocations(_mapping); return *this; }
|
||||
|
||||
//! links to the external mapping object, earlyer mapping definitions get ignored, following
|
||||
//! mappings will also change the external object!
|
||||
inline ShaderProgramCreator& externAttributeLocations (SharedLocationMappings _mapping) { mAttributeLocations = _mapping; return *this; }
|
||||
|
||||
//
|
||||
// Adding fragment output locations:
|
||||
//
|
||||
//! adds a fragment output location to the next free location number:
|
||||
inline ShaderProgramCreator& fragmentDataLocation (const std::string &_fragmentDataName) { mFragmentDataLocations->setLocation(_fragmentDataName); return *this; }
|
||||
|
||||
//! adds a fragment output location to the given location number:
|
||||
inline ShaderProgramCreator& fragmentDataLocation (const std::string &_fragmentDataName, GLuint _location) { mFragmentDataLocations->setLocation(_fragmentDataName,_location); return *this; }
|
||||
|
||||
//! adds a whole list of mappings
|
||||
inline ShaderProgramCreator& fragmentDataLocations(const SharedLocationMappings &_mapping) { mFragmentDataLocations->addLocations(_mapping); return *this; }
|
||||
|
||||
//! links to the external mapping object, earlyer mapping definitions get ignored, following
|
||||
//! mappings will also change the external object!
|
||||
inline ShaderProgramCreator& externFragmentDataLocations (SharedLocationMappings _mapping) { mFragmentDataLocations = _mapping; return *this; }
|
||||
|
||||
//
|
||||
// Adding uniform buffer locations:
|
||||
//
|
||||
//! adds an attribute location to the next free location number:
|
||||
inline ShaderProgramCreator& uniformBufferLocation(const std::string &_uniformBufferName) { mUniformBufferLocations->setLocation(_uniformBufferName); return *this; }
|
||||
|
||||
//! adds an attribute location to the given location number:
|
||||
inline ShaderProgramCreator& uniformBufferLocation(const std::string &_uniformBufferName, GLuint _location){ mUniformBufferLocations->setLocation(_uniformBufferName,_location);return *this; }
|
||||
|
||||
//! adds a whole list of mappings
|
||||
inline ShaderProgramCreator& uniformBufferLocations(SharedLocationMappings _mapping) { mUniformBufferLocations->addLocations(_mapping);return *this; }
|
||||
|
||||
inline ShaderProgramCreator& externUniformBufferLocations(SharedLocationMappings _mapping) { mUniformBufferLocations = _mapping; return *this; }
|
||||
|
||||
// ===================================================================================================== \/
|
||||
// ============================================================================================ OVERRIDE \/
|
||||
// ===================================================================================================== \/
|
||||
public:
|
||||
virtual SharedShaderProgram create();
|
||||
virtual bool update(SharedShaderProgram &_shaderProgram);
|
||||
|
||||
// =================================================================================================== \/
|
||||
// ============================================================================================ FIELDS \/
|
||||
// =================================================================================================== \/
|
||||
protected:
|
||||
std::vector<GLenum> mShaderType;
|
||||
|
||||
SharedLocationMappings mAttributeLocations;
|
||||
SharedLocationMappings mFragmentDataLocations;
|
||||
SharedLocationMappings mUniformBufferLocations;
|
||||
|
||||
SharedShaderParserFactory mShaderParserFactory;
|
||||
|
||||
private:
|
||||
// set attribute, UBO & fragdata locations and links the program
|
||||
bool setBindings(SharedShaderProgram &_shaderProgram);
|
||||
};
|
||||
|
||||
} // OpenGL
|
||||
} // ACGL
|
36
extern/acgl/include/ACGL/OpenGL/Creator/Texture2DCreator.hh
vendored
Normal file
36
extern/acgl/include/ACGL/OpenGL/Creator/Texture2DCreator.hh
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2013 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
|
||||
#include <ACGL/Resource/SingleFileBasedCreator.hh>
|
||||
#include <ACGL/OpenGL/Objects/Texture.hh>
|
||||
#include <ACGL/Base/Settings.hh>
|
||||
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
class Texture2DCreator : public Resource::SingleFileBasedCreator<Texture2D>
|
||||
{
|
||||
public:
|
||||
Texture2DCreator(const std::string& _filename)
|
||||
: Resource::SingleFileBasedCreator<Texture2D>(_filename, Base::Settings::the()->getFullTexturePath() ) {}
|
||||
virtual ~Texture2DCreator() {}
|
||||
|
||||
Texture2DCreator& setResourceName(const std::string &_resourceName) { mResourceName = _resourceName; return *this; }
|
||||
|
||||
//! try to create a 2D mip-mapped texture
|
||||
virtual SharedTexture2D create();
|
||||
|
||||
//! update the texture data, create mipmaps if mipmapping is on. Don't change any other settings
|
||||
//! (e.g. filtering settings)
|
||||
virtual bool update(SharedTexture2D& _texture);
|
||||
};
|
||||
|
||||
} // OpenGL
|
||||
} // ACGL
|
73
extern/acgl/include/ACGL/OpenGL/Creator/VertexArrayObjectCreator.hh
vendored
Normal file
73
extern/acgl/include/ACGL/OpenGL/Creator/VertexArrayObjectCreator.hh
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2013 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* Creates a VAO from a file which contains a mesh, e.g. an *.obj file.
|
||||
*
|
||||
* SharedVertexArrayObject vaoBunny = VertexArrayObjectCreator("Bunny.obj").create();
|
||||
*
|
||||
*/
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
|
||||
#include <ACGL/Resource/SingleFileBasedCreator.hh>
|
||||
#include <ACGL/OpenGL/Objects/VertexArrayObject.hh>
|
||||
#include <ACGL/OpenGL/Data/LocationMappings.hh>
|
||||
#include <ACGL/Base/Settings.hh>
|
||||
|
||||
#ifdef ACGL_SUPPORT_VAO
|
||||
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
class VertexArrayObjectCreator : public Resource::SingleFileBasedCreator<VertexArrayObject>
|
||||
{
|
||||
// ========================================================================================================= \/
|
||||
// ============================================================================================ CONSTRUCTORS \/
|
||||
// ========================================================================================================= \/
|
||||
public:
|
||||
VertexArrayObjectCreator(const std::string& _filename);
|
||||
VertexArrayObjectCreator(const char* _filename);
|
||||
|
||||
VertexArrayObjectCreator& setResourceName(const std::string &_resourceName) { mResourceName = _resourceName; return *this; }
|
||||
|
||||
template<typename CONTROLLER>
|
||||
VertexArrayObjectCreator(const CONTROLLER& _fileController)
|
||||
: Resource::SingleFileBasedCreator<VertexArrayObject>(_fileController.getFilename(), Base::Settings::the()->getFullGeometryPath()),
|
||||
mAttributeLocations()
|
||||
{}
|
||||
virtual ~VertexArrayObjectCreator() {}
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ METHODS \/
|
||||
// ==================================================================================================== \/
|
||||
public:
|
||||
//! links to an external LocationMappings object
|
||||
inline VertexArrayObjectCreator& externAttributeLocations(const SharedLocationMappings& _attributeLocations) { mAttributeLocations = _attributeLocations; return *this; }
|
||||
|
||||
private:
|
||||
bool load(SharedVertexArrayObject& vao);
|
||||
|
||||
// ===================================================================================================== \/
|
||||
// ============================================================================================ OVERRIDE \/
|
||||
// ===================================================================================================== \/
|
||||
public:
|
||||
virtual SharedVertexArrayObject create();
|
||||
virtual bool update(SharedVertexArrayObject& _vao);
|
||||
|
||||
// =================================================================================================== \/
|
||||
// ============================================================================================ FIELDS \/
|
||||
// =================================================================================================== \/
|
||||
protected:
|
||||
SharedLocationMappings mAttributeLocations;
|
||||
};
|
||||
|
||||
} // OpenGL
|
||||
} // ACGL
|
||||
|
||||
#endif // #ifdef ACGL_SUPPORT_VAO
|
27
extern/acgl/include/ACGL/OpenGL/Data/ArrayBufferLoadStore.hh
vendored
Normal file
27
extern/acgl/include/ACGL/OpenGL/Data/ArrayBufferLoadStore.hh
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
#include <ACGL/OpenGL/Objects/ArrayBuffer.hh>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
//! Loads an ArrayBuffer from the given file (e.g. a *.obj file).
|
||||
//! Often not an ArrayBuffer but a complete VAO is needed, in that case,
|
||||
//! see VertexArrayObjectLoadStore.hh !
|
||||
SharedArrayBuffer loadArrayBuffer(const std::string& _filename);
|
||||
|
||||
//! Loads an ArrayBuffer from the given ATB (attribute) file.
|
||||
//! An attribute name can be specified, otherwise it is guessed from the filename.
|
||||
SharedArrayBuffer loadArrayBufferFromATB(const std::string& _filename, const std::string& _attributeName = "");
|
||||
|
||||
}
|
||||
}
|
29
extern/acgl/include/ACGL/OpenGL/Data/ColorSpace.hh
vendored
Normal file
29
extern/acgl/include/ACGL/OpenGL/Data/ColorSpace.hh
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2013 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef ACGL_OPENGL_DATA_COLORSPACE_HH
|
||||
#define ACGL_OPENGL_DATA_COLORSPACE_HH
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
#include <ACGL/OpenGL/GL.hh>
|
||||
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
enum class ColorSpace
|
||||
{
|
||||
AUTO_DETECT,
|
||||
LINEAR,
|
||||
SRGB
|
||||
};
|
||||
|
||||
//! Recommends an OpenGL internal format for a given pair of format and color spaces
|
||||
GLenum recommendedInternalFormat(GLenum _format, ColorSpace _colorSpace);
|
||||
|
||||
} // OpenGL
|
||||
} // ACGL
|
||||
|
||||
#endif // ACGL_OPENGL_DATA_COLORSPACE_HH
|
72
extern/acgl/include/ACGL/OpenGL/Data/GeometryData.hh
vendored
Normal file
72
extern/acgl/include/ACGL/OpenGL/Data/GeometryData.hh
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef ACGL_OPENGL_DATA_GEOMETRYDATA_HH
|
||||
#define ACGL_OPENGL_DATA_GEOMETRYDATA_HH
|
||||
|
||||
/**
|
||||
*/
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
|
||||
#include <ACGL/Base/Macros.hh>
|
||||
#include <ACGL/OpenGL/GL.hh>
|
||||
#include <ACGL/OpenGL/Objects/ArrayBuffer.hh> // get Attribute definition
|
||||
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
class GeometryData
|
||||
{
|
||||
// ========================================================================================================= \/
|
||||
// ============================================================================================ CONSTRUCTORS \/
|
||||
// ========================================================================================================= \/
|
||||
public:
|
||||
GeometryData(void)
|
||||
: mpData(NULL),
|
||||
mSize(0),
|
||||
mStrideSize(0)
|
||||
{}
|
||||
|
||||
virtual ~GeometryData(void)
|
||||
{
|
||||
delete[] mpData;
|
||||
}
|
||||
|
||||
// ========================================================================================================= \/
|
||||
// ================================================================================================= GETTERS \/
|
||||
// ========================================================================================================= \/
|
||||
public:
|
||||
GLubyte *getData (void) const { return mpData; }
|
||||
GLsizei getSize (void) const { return mSize; }
|
||||
GLsizei getStrideSize (void) const { return mStrideSize; }
|
||||
|
||||
// ========================================================================================================= \/
|
||||
// ================================================================================================= SETTERS \/
|
||||
// ========================================================================================================= \/
|
||||
public:
|
||||
void setData (GLubyte *_pData) { mpData = _pData; }
|
||||
void setSize (GLsizei _size) { mSize = _size; }
|
||||
void setStrideSize(GLsizei _strideSize) { mStrideSize = _strideSize; }
|
||||
|
||||
// ========================================================================================================= \/
|
||||
// ================================================================================================== FIELDS \/
|
||||
// ========================================================================================================= \/
|
||||
private:
|
||||
GLubyte *mpData; // raw data, just cast the pointer as needed
|
||||
GLsizei mSize; // size in bytes
|
||||
GLsizei mStrideSize; // size in bytes of a stride
|
||||
|
||||
public:
|
||||
ArrayBuffer::AttributeVec mAttributes;
|
||||
};
|
||||
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(GeometryData)
|
||||
|
||||
} // OpenGL
|
||||
} // ACGL
|
||||
|
||||
#endif // ACGL_OPENGL_DATA_GEOMETRYDATA_HH
|
54
extern/acgl/include/ACGL/OpenGL/Data/GeometryDataLoadStore.hh
vendored
Normal file
54
extern/acgl/include/ACGL/OpenGL/Data/GeometryDataLoadStore.hh
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef ACGL_OPENGL_DATA_GEOMETRYDATALOADSTORE_HH
|
||||
#define ACGL_OPENGL_DATA_GEOMETRYDATALOADSTORE_HH
|
||||
|
||||
/**
|
||||
* Helper function for writing the contents of a TextureData object into a file
|
||||
* and loading them from a file.
|
||||
*/
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
#include <ACGL/OpenGL/Data/GeometryData.hh>
|
||||
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// generic load/save
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//! Generic load function that will use one of the loading functions below based on the file ending
|
||||
SharedGeometryData loadGeometryData(const std::string& _filename);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// library specific load
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//! Loads from a Wavefront OBJ file. If _computeNormals and the mesh had no normals stored,
|
||||
//! face normals are computed from the geometry
|
||||
SharedGeometryData loadGeometryDataFromOBJ(const std::string& _filename, bool _computeNormals = true);
|
||||
|
||||
//! Loads data from an attribute ATB file. If no _attributeName is specified, it will be guessed
|
||||
//! from the filename, e.g. /foo/bar/VertexColor.atb --> aVertexColor
|
||||
SharedGeometryData loadGeometryDataFromATB(const std::string& _filename, const std::string &_attributeName = "");
|
||||
|
||||
//! Loads from a VirtualAachen project (VAP) file. If _computeNormals and the mesh had no normals stored,
|
||||
//! face normals are computed from the geometry
|
||||
SharedGeometryData loadGeometryDataFromVAP(const std::string& _filename, bool _computeNormals = true);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// library specific save
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
} // OpenGL
|
||||
} // ACGL
|
||||
|
||||
#endif // ACGL_OPENGL_DATA_GEOMETRYDATALOADSTORE_HH
|
113
extern/acgl/include/ACGL/OpenGL/Data/LocationMappings.hh
vendored
Normal file
113
extern/acgl/include/ACGL/OpenGL/Data/LocationMappings.hh
vendored
Normal file
@ -0,0 +1,113 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef ACGL_OPENGL_OBJECTS_LOCATIONMAPPINGS_HH
|
||||
#define ACGL_OPENGL_OBJECTS_LOCATIONMAPPINGS_HH
|
||||
|
||||
/**
|
||||
* LocationMappings is a map from strings to GLuints that stores the mappings from
|
||||
*
|
||||
* attribute names to attribute locations
|
||||
* or
|
||||
* fragment outputs to fragdata locations
|
||||
*
|
||||
* (as long as there are no name clashes one map can be used for both)
|
||||
*
|
||||
* Another use is to query
|
||||
* uniform names to uniform buffer offsets
|
||||
*
|
||||
* A mapping like this can be used to init all mappings of multiple ShaderPrograms
|
||||
* in the same way to they can be used with the same VAOs or FBOs. Similar, these
|
||||
* mapping objects can be used to configute VAOs and FBOs!
|
||||
*
|
||||
* To fully automate the mappings in a program the creation of these mappings can
|
||||
* be done automatically by parsing shader sources, querying locations and names from
|
||||
* ShaderPrograms or any other way that best suits the use case of the application.
|
||||
*/
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
#include <ACGL/Base/Macros.hh>
|
||||
#include <ACGL/OpenGL/GL.hh>
|
||||
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
class LocationMappings
|
||||
{
|
||||
// ===================================================================================================== \/
|
||||
// ============================================================================================ TYPEDEFS \/
|
||||
// ===================================================================================================== \/
|
||||
public:
|
||||
typedef std::map< std::string, GLuint > LocationMap;
|
||||
|
||||
// ========================================================================================================= \/
|
||||
// ============================================================================================ CONSTRUCTORS \/
|
||||
// ========================================================================================================= \/
|
||||
public:
|
||||
LocationMappings() {}
|
||||
~LocationMappings() {}
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ GETTERS \/
|
||||
// ==================================================================================================== \/
|
||||
public:
|
||||
//! Returns the stored location for a given name or -1 if the name could not get found (similar to how GL behaves)
|
||||
GLint getLocation(const std::string& _name) const;
|
||||
|
||||
//! Returns the raw location map:
|
||||
const LocationMap& getLocations() const { return mMappings; }
|
||||
|
||||
inline size_t getSize() { return mMappings.size(); }
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ SETTERS \/
|
||||
// ==================================================================================================== \/
|
||||
public:
|
||||
|
||||
//! Adds one location, if the name already exists, the location number gets changed:
|
||||
void setLocation(const std::string& _name, GLuint _location);
|
||||
|
||||
//! Adds one location, uses the next free integer as the location
|
||||
//! this way the locations can get the number of the order they were added (if only this function gets used)
|
||||
void setLocation(const std::string& _name);
|
||||
|
||||
//! Adds all given locations via setLocation:
|
||||
void setLocations( const ptr::shared_ptr<LocationMappings> &_other );
|
||||
|
||||
//! Adds one location, if the name is new! (otherwise keep the old one)
|
||||
//! If the name is new and the location is free, use that, otherwise use a free location
|
||||
//! Useful for merging -> uses as much info from the new location WITHOUT destroying and old information!
|
||||
void addLocation( const std::string& _name, GLuint _location );
|
||||
|
||||
//! Adds all given locations via addLocation:
|
||||
void addLocations( const ptr::shared_ptr<LocationMappings> &_other );
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ METHODS \/
|
||||
// ==================================================================================================== \/
|
||||
public:
|
||||
//! Tells whether a mapping for a given name exists
|
||||
inline bool exists(const std::string& _name) const { return (getLocation(_name) != -1); }
|
||||
|
||||
void printMapping();
|
||||
|
||||
// =================================================================================================== \/
|
||||
// ============================================================================================ FIELDS \/
|
||||
// =================================================================================================== \/
|
||||
protected:
|
||||
//! returns the first unused location number
|
||||
GLuint getFreeLocation();
|
||||
LocationMap mMappings;
|
||||
};
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(LocationMappings)
|
||||
|
||||
} // OpenGL
|
||||
} // ACGL
|
||||
|
||||
#endif // ACGL_OPENGL_OBJECTS_LOCATIONMAPPINGS_HH
|
154
extern/acgl/include/ACGL/OpenGL/Data/TextureData.hh
vendored
Normal file
154
extern/acgl/include/ACGL/OpenGL/Data/TextureData.hh
vendored
Normal file
@ -0,0 +1,154 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef ACGL_OPENGL_DATA_TEXTUREDATA_HH
|
||||
#define ACGL_OPENGL_DATA_TEXTUREDATA_HH
|
||||
|
||||
/**
|
||||
* TextureData holds the data of a 1,2 or 3 dimensional image to be used as a texture.
|
||||
* This structure is used for texture loading.
|
||||
*/
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
|
||||
#include <ACGL/Base/Macros.hh>
|
||||
#include <ACGL/OpenGL/GL.hh>
|
||||
#include <ACGL/OpenGL/Data/ColorSpace.hh>
|
||||
#include <ACGL/OpenGL/Tools.hh>
|
||||
#include <ACGL/Math/Math.hh>
|
||||
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
class TextureData
|
||||
{
|
||||
// ========================================================================================================= \/
|
||||
// ============================================================================================ CONSTRUCTORS \/
|
||||
// ========================================================================================================= \/
|
||||
public:
|
||||
TextureData(void)
|
||||
: mData(NULL),
|
||||
mWidth(0),
|
||||
mHeight(0),
|
||||
mDepth(0),
|
||||
mFormat(GL_RGBA),
|
||||
mType(GL_UNSIGNED_BYTE),
|
||||
mPaddingBytesPerRow(0),
|
||||
mColorSpace(ColorSpace::AUTO_DETECT)
|
||||
{}
|
||||
virtual ~TextureData(void)
|
||||
{
|
||||
delete[] mData;
|
||||
}
|
||||
|
||||
// ========================================================================================================= \/
|
||||
// ================================================================================================= GETTERS \/
|
||||
// ========================================================================================================= \/
|
||||
public:
|
||||
//! pointer to the raw pixel data
|
||||
GLubyte* getData() const { return mData; }
|
||||
|
||||
//! width in pixels
|
||||
GLsizei getWidth() const { return mWidth; }
|
||||
|
||||
//! height in pixels
|
||||
GLsizei getHeight() const { return mHeight; }
|
||||
|
||||
//! depth in pixels
|
||||
GLsizei getDepth() const { return mDepth; }
|
||||
|
||||
//! channels etc. (e.g. GL_RGB)
|
||||
GLenum getFormat() const { return mFormat; }
|
||||
|
||||
//! data type (e.g. GL_BYTE)
|
||||
GLenum getType() const { return mType; }
|
||||
|
||||
//! each line can have a few bytes of padding, number of bytes is returned
|
||||
GLsizei getPadding() const { return mPaddingBytesPerRow; }
|
||||
|
||||
//! the color space in which the data is represented
|
||||
ColorSpace getColorSpace() const { return mColorSpace; }
|
||||
|
||||
//! in pixel
|
||||
glm::uvec3 getSize() const { return glm::uvec3( mWidth, mHeight, mDepth ); }
|
||||
|
||||
//! in bytes
|
||||
size_t getSizeInBytes() const;
|
||||
|
||||
//! the byte alignment of each pixel row, (e.g. 1, 2, 4, 8 bytes)
|
||||
GLsizei getPackAlignment() const;
|
||||
|
||||
//! 1, 2, 3 or 4 based on format
|
||||
GLsizei getNumberOfChannels() const;
|
||||
|
||||
//! A recommended value for the internalFormat enum of a Texture object. Based on the format, type and color space
|
||||
GLenum getRecommendedInternalFormat() const;
|
||||
|
||||
//! flips the image vertically as some image formats have a different coordinate system as OpenGL has. (flip it upside down)
|
||||
void flipVertically();
|
||||
|
||||
//! returns the texel converted to float (0..1 in case the data was int, -1..1 in case it was unsigned int).
|
||||
//! If the Image had less than 4 components it get's filled with (0,0,0,1)
|
||||
//! _texCoord is NOT normalized to 0..1! and gets clamped to the actual image size
|
||||
//! NOTE: this might be slow, for performance get the raw pointer and work on that!
|
||||
glm::vec4 getTexel( glm::uvec2 _texCoord );
|
||||
|
||||
//! sets one texel, if the texture has less color components than 4, the superfluous components get ignored.
|
||||
//! in case the texture is int, the values from 0..1 will get scaled and clamped if needed.
|
||||
void setTexel( glm::uvec2 _texCoord, glm::vec4 _color );
|
||||
|
||||
//! returns true if the data is stored as one of the compressed formats in OpenGL, the compression type is stored in mFormat, mType might be invalid
|
||||
bool dataIsCompressed() const;
|
||||
|
||||
// ========================================================================================================= \/
|
||||
// ================================================================================================= SETTERS \/
|
||||
// ========================================================================================================= \/
|
||||
public:
|
||||
//! mData has to be created by new GLubyte[...] and will get deleted by this TextureData object!
|
||||
void setData (GLubyte* _data) { mData = _data; }
|
||||
void setWidth (GLsizei _width) { mWidth = _width; }
|
||||
void setHeight (GLsizei _height) { mHeight = _height; }
|
||||
void setDepth (GLsizei _depth) { mDepth = _depth; }
|
||||
void setFormat (GLenum _format) { mFormat = _format; }
|
||||
void setType (GLenum _type) { mType = _type; }
|
||||
void setPadding (GLsizei _padding) { mPaddingBytesPerRow = _padding; }
|
||||
void setColorSpace(ColorSpace _colorSpace) { mColorSpace = _colorSpace; }
|
||||
void setSize (const glm::uvec3& _size) { mWidth = _size.x; mHeight = _size.y; mDepth = _size.z; }
|
||||
|
||||
//! deletes the data attached to this object
|
||||
void deleteData() { delete[] mData; mData = NULL; }
|
||||
|
||||
private:
|
||||
size_t getBytesPerScanline() const;
|
||||
|
||||
//! returns the size per texel in bits(!) - bits to support compressed types!
|
||||
size_t getTexelSizeInBits() const;
|
||||
|
||||
// ========================================================================================================= \/
|
||||
// ================================================================================================== FIELDS \/
|
||||
// ========================================================================================================= \/
|
||||
GLubyte* mData; // TODO: make this a std::unique_ptr to allow custom deleters
|
||||
GLsizei mWidth;
|
||||
GLsizei mHeight;
|
||||
GLsizei mDepth;
|
||||
GLenum mFormat; // channel types and count
|
||||
GLenum mType; // data type, invalid if the format is a compressed format
|
||||
GLsizei mPaddingBytesPerRow; // number of padding bytes added per row: glReadPixel can read with padding and
|
||||
// some image writers support/need this as well (e.g. QT)
|
||||
ColorSpace mColorSpace;
|
||||
};
|
||||
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(TextureData)
|
||||
|
||||
//! Converts the texture data in _from to the target format and type given in
|
||||
//! _to. Overwrites width, height, and depth in _to. Old texture data is removed
|
||||
//! and new memory is allocated.
|
||||
void convertTextureData(const SharedTextureData& _from, const SharedTextureData& _to);
|
||||
|
||||
} // OpenGL
|
||||
} // ACGL
|
||||
|
||||
#endif // ACGL_OPENGL_DATA_TEXTUREDATA_HH
|
121
extern/acgl/include/ACGL/OpenGL/Data/TextureDataLoadStore.hh
vendored
Normal file
121
extern/acgl/include/ACGL/OpenGL/Data/TextureDataLoadStore.hh
vendored
Normal file
@ -0,0 +1,121 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef ACGL_OPENGL_DATA_TEXTUREDATALOADSTORE_HH
|
||||
#define ACGL_OPENGL_DATA_TEXTUREDATALOADSTORE_HH
|
||||
|
||||
/**
|
||||
* Helper function for writing the contents of a TextureData object into a file
|
||||
* and loading them from a file.
|
||||
*/
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
#include <ACGL/OpenGL/Tools.hh>
|
||||
#include <ACGL/OpenGL/Data/ColorSpace.hh>
|
||||
#include <ACGL/OpenGL/Data/TextureData.hh>
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// generic load/save
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//! functionpointer which can be used for generic Texture loading
|
||||
typedef SharedTextureData (*TextureLoadFuncPtr)(const std::string&, ColorSpace);
|
||||
|
||||
//! registers a functionpointer to be used for loading specified file types (E.G. provide a load function which loads compressed)
|
||||
void registerTextureLoadFunction(std::vector<std::string> _endings, TextureLoadFuncPtr _function);
|
||||
|
||||
//! remove a registered functionpointer (if you want to use the stock ones again
|
||||
void unregisterTextureLoadFunction(TextureLoadFuncPtr _function);
|
||||
|
||||
//! generic load function that will use one of the loading functions below based on the file ending
|
||||
SharedTextureData loadTextureData(const std::string &_filename, ColorSpace _colorSpace = ColorSpace::AUTO_DETECT);
|
||||
|
||||
//! generic save function that will use one of the saving functions below based on the file ending
|
||||
bool saveTextureData(const SharedTextureData &_textureData, const std::string &_filename);
|
||||
|
||||
//! saves the viewport visible part of the framebuffer 0 to a file named _fileName. The file ending determines the file type
|
||||
bool saveScreenshot( const std::string& _fileName );
|
||||
|
||||
//! saves the viewport visible part of the framebuffer 0 to a file named _prefix_DATE-TIME._fileEnding
|
||||
bool saveScreenshotWithDate( const std::string& _prefix, const std::string& _fileEnding);
|
||||
|
||||
//! saves the viewport visible part of the framebuffer 0 to a file named screenshot_DATE-TIME._fileEnding
|
||||
inline bool saveScreenshotWithDate( const std::string& _fileEnding = "png" ) {
|
||||
return saveScreenshotWithDate( "screenshot", _fileEnding );
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// library specific load
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//! loads from a PNG using the simple lodepng library
|
||||
SharedTextureData loadTextureDataFromLodepng(const std::string& _filename, ColorSpace _colorSpace = ColorSpace::AUTO_DETECT);
|
||||
|
||||
#ifdef ACGL_COMPILE_WITH_QT
|
||||
//! loads various formats from the QT library
|
||||
SharedTextureData loadTextureDataFromQT(const std::string& _filename, ColorSpace _colorSpace = ColorSpace::AUTO_DETECT);
|
||||
#endif
|
||||
|
||||
//! loads RGBE aka Radiance files
|
||||
SharedTextureData loadTextureDataFromRGBE(const std::string& _filename, ColorSpace _colorSpace = ColorSpace::AUTO_DETECT);
|
||||
|
||||
//! loads EXR / OpenEXR files iff the library is present AT RUNTIME (linux only)
|
||||
SharedTextureData loadTextureDataFromEXR(const std::string& _filename, ColorSpace _colorSpace = ColorSpace::AUTO_DETECT);
|
||||
|
||||
//! loads PNM / PPM files:
|
||||
SharedTextureData loadTextureDataFromPNM(const std::string& _filename, ColorSpace _colorSpace = ColorSpace::AUTO_DETECT);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// library specific save
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//! saves to a PPM file
|
||||
bool saveTextureDataToPPM(const SharedTextureData &_textureData, const std::string &_filename);
|
||||
|
||||
//! save to a PNG file with lodepng
|
||||
bool saveTextureDataToLodepng( const SharedTextureData &_data, const std::string &_filename );
|
||||
|
||||
//! save the imagedata raw to a file
|
||||
bool saveTextureDataToRAW( const SharedTextureData &_data, const std::string &_filename );
|
||||
|
||||
#ifdef ACGL_COMPILE_WITH_QT
|
||||
bool saveTextureDataToQT( const SharedTextureData &_data, const std::string &_filename );
|
||||
#endif
|
||||
|
||||
|
||||
// helper for saveTextureDataToLodepng
|
||||
template< typename T>
|
||||
unsigned char *preProcess( const SharedTextureData &_data)
|
||||
{
|
||||
unsigned int channelCount = _data->getNumberOfChannels();
|
||||
|
||||
unsigned int pixelCount = _data->getWidth() * _data->getHeight();
|
||||
T *processedrawdata = new T[pixelCount * channelCount];
|
||||
|
||||
// copy & flip the image:
|
||||
T *originalrawdata = (T*) _data->getData();
|
||||
|
||||
for (int i = 0; i < _data->getHeight(); ++i) {
|
||||
size_t srcOffset = _data->getWidth() * i * channelCount;
|
||||
size_t dstOffset = _data->getWidth() * (_data->getHeight()-i-1) * channelCount;
|
||||
|
||||
memcpy( processedrawdata + dstOffset, originalrawdata + srcOffset, _data->getWidth()*channelCount * sizeof(T) );
|
||||
}
|
||||
|
||||
return (unsigned char *) processedrawdata;
|
||||
}
|
||||
|
||||
} // OpenGL
|
||||
} // ACGL
|
||||
|
||||
#endif // ACGL_OPENGL_DATA_TEXTUREDATALOADSTORE_HH
|
33
extern/acgl/include/ACGL/OpenGL/Data/TextureLoadStore.hh
vendored
Normal file
33
extern/acgl/include/ACGL/OpenGL/Data/TextureLoadStore.hh
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* Helper function for writing the contents of a Texture object into a file
|
||||
* and loading them from a file.
|
||||
*/
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
#include <ACGL/OpenGL/Data/ColorSpace.hh>
|
||||
#include <ACGL/OpenGL/Objects/Texture.hh>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
//! loads the texture and creates mip maps
|
||||
SharedTexture2D loadTexture2D(const std::string& _filename, ColorSpace _colorSpace = ColorSpace::AUTO_DETECT);
|
||||
|
||||
//! loads the texture including mipmaps from a DDS file
|
||||
//! supports DXT1, DXT3 and DXT5 compression
|
||||
SharedTexture2D loadTexture2DFromDDS (const std::string& _filename, ColorSpace _colorSpace = ColorSpace::AUTO_DETECT);
|
||||
SharedTexture3D loadTexture3DFromDDS (const std::string& _filename, ColorSpace _colorSpace = ColorSpace::AUTO_DETECT);
|
||||
SharedTextureCubeMap loadTextureCubeMapFromDDS(const std::string& _filename, ColorSpace _colorSpace = ColorSpace::AUTO_DETECT);
|
||||
|
||||
}
|
||||
}
|
51
extern/acgl/include/ACGL/OpenGL/Data/VertexArrayObjectLoadStore.hh
vendored
Normal file
51
extern/acgl/include/ACGL/OpenGL/Data/VertexArrayObjectLoadStore.hh
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
#include <ACGL/OpenGL/Objects/VertexArrayObject.hh>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// generic load/save
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//! @brief
|
||||
//! Loads geometry data from a file and attaches the loaded array buffer data to a VertexArrayObject
|
||||
//! Tries to guess the file format from the file extension
|
||||
//! @param _filename The name of the file to load relative to the Geometry load path
|
||||
//! @param _caching If true, a disk caching mechanism is used to speed up future reading of the same file.
|
||||
//! When the file is loaded for the first time, a copy of the resulting VAO is stored in
|
||||
//! the binary VAO format next to the original file. Successive loadings of the same file
|
||||
//! will load the cached version if one is present.
|
||||
SharedVertexArrayObject loadVertexArrayObject(const std::string& _filename, bool _caching = false);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// library specific load
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//! Loads a VertexArrayObject from the ACGL binary VAO format, as specified here:
|
||||
//! http://www.graphics.rwth-aachen.de/redmine/projects/acgl/wiki/Vao_File_Format
|
||||
//! A VAO file can contain several named EABs. Only the EAB whose name matches _eabName will be loaded
|
||||
//! and attached to the VAO. If _eabName is left blank, the first defined EAB will be used.
|
||||
SharedVertexArrayObject loadVertexArrayObjectFromVAO(const std::string& _filename, const std::string& _eabName = "");
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// library specific save
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//! Stores a VertexArrayObject in a file using the ACGL binary VAO format
|
||||
//! Each attached ArrayBuffer will be stored entirely in the VAO file but only those attributes which
|
||||
//! are used by _vao will be defined.
|
||||
bool saveVertexArrayObjectToVAO(ConstSharedVertexArrayObject _vao, const std::string& _filename);
|
||||
|
||||
}
|
||||
}
|
36
extern/acgl/include/ACGL/OpenGL/Debug.hh
vendored
Normal file
36
extern/acgl/include/ACGL/OpenGL/Debug.hh
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2013 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
#include <ACGL/OpenGL/GL.hh>
|
||||
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
//! converts a KHR debug source enum to a human readable string
|
||||
const char *debugSourceName( GLenum _source );
|
||||
|
||||
//! converts a KHR debug type enum to a human readable string
|
||||
const char *debugTypeName( GLenum _type );
|
||||
|
||||
//! converts a KHR debug severity enum to a human readable string
|
||||
const char *debugSeverityName( GLenum _type );
|
||||
|
||||
//! tries to register the default debug callback:
|
||||
//! applications can register alternative callbacks with glDebugMessageCallback !
|
||||
void ACGLRegisterDefaultDebugCallback();
|
||||
|
||||
//! default debug callback
|
||||
void APIENTRY ACGL_KHR_default_debug_callback( GLenum _source, GLenum _type, GLuint _id, GLenum _severity, GLsizei _length, const GLchar *_message, void *_userParam);
|
||||
|
||||
} // OpenGL
|
||||
} // ACGL
|
||||
|
||||
|
||||
|
||||
|
238
extern/acgl/include/ACGL/OpenGL/GL.hh
vendored
Normal file
238
extern/acgl/include/ACGL/OpenGL/GL.hh
vendored
Normal file
@ -0,0 +1,238 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef ACGL_OPENGL_GL_HH
|
||||
#define ACGL_OPENGL_GL_HH
|
||||
|
||||
/*
|
||||
* This simple OpenGL wrapper is used to include OpenGL (and if needed GLEW)
|
||||
* on different platforms.
|
||||
*
|
||||
* While these includes are located in a subdirectory of GL/ on most systems,
|
||||
* Apple hides them on different locations.
|
||||
*
|
||||
*
|
||||
* This wrapper can get configured with external defines:
|
||||
* ACGL_OPENGL_PROFILE_CORE : if defined: if possible include/load only core OpenGL functions
|
||||
* if not defined: support for CORE and deprecated functions
|
||||
* (NOTE: the OpenGL context itself is not created by ACGL!)
|
||||
* ACGL_OPENGLES_VERSION_20 : if defined: OpenGL ES 2.0
|
||||
* ACGL_OPENGLES_VERSION_30 : if defined: OpenGL ES 3.0
|
||||
* ACGL_OPENGL_VERSION_41 : (or other versions): minimal OpenGL version that can be assumed to be present.
|
||||
* The app can't run on older contexts and will probably terminate at startup.
|
||||
* Set this to a low version and it will run on lost machines
|
||||
* Set this to a high version and less run-time checks have to be performed to
|
||||
* work around missing features (like querying extensions etc).
|
||||
* ACGL_OPENGL_INCLUDE_LATEST_GL : If this is set and GL function loading is done with the internal loader, all
|
||||
* functions of the latest GL version are loaded (if available) and the header
|
||||
* of the latest version gets included. ACGL however will only assume the version
|
||||
* set by ACGL_OPENGL_VERSION_XY to be present.
|
||||
*
|
||||
* ACGL_USE_GLEW : if this is set, GLEW gets used to load the GL functions,
|
||||
* otherwise an internal GL loader based on glLoadGen gets used on desktop systems.
|
||||
*
|
||||
* Note: If nothing is defined, core 3.2 gets defined but all functions are loaded.
|
||||
* If *just* ACGL_OPENGL_INCLUDE_LATEST_GL is defined, the latest GL version gets defined *and* loaded
|
||||
* (full/compatibility profile).
|
||||
*/
|
||||
|
||||
// Android autodetection:
|
||||
#ifdef __ANDROID__
|
||||
# define ACGL_OPENGL_ES
|
||||
# define PLATFORM_ANDROID
|
||||
#endif
|
||||
|
||||
// If we're compiling for an Apple system we need this to distinquish between Mac and iOS:
|
||||
#ifdef __APPLE__
|
||||
# include <TargetConditionals.h>
|
||||
#endif
|
||||
|
||||
#if (defined(TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR))
|
||||
# if (TARGET_OS_IPHONE == 1)
|
||||
# define PLATFORM_IOS
|
||||
# define ACGL_OPENGL_ES
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// To compare the OpenGL version number we define a new ACGL_OPENGL_VERSION XY define here
|
||||
// analog to ACGL_OPENGL_VERSION_XY
|
||||
|
||||
// OpenGL ES 2.0 is the default for embedded:
|
||||
#ifdef ACGL_OPENGL_ES
|
||||
# if defined (ACGL_OPENGLES_VERSION_30)
|
||||
# define ACGL_OPENGLES_VERSION 30
|
||||
# define ACGL_OPENGL_VERSION 0
|
||||
# else
|
||||
# define ACGL_OPENGLES_VERSION_20
|
||||
# define ACGL_OPENGLES_VERSION 20
|
||||
# define ACGL_OPENGL_VERSION 0
|
||||
# endif
|
||||
#else
|
||||
// Desktop:
|
||||
#if defined (ACGL_OPENGL_VERSION_21)
|
||||
# define ACGL_OPENGL_VERSION 21
|
||||
#elif defined (ACGL_OPENGL_VERSION_30)
|
||||
# define ACGL_OPENGL_VERSION 30
|
||||
#elif defined (ACGL_OPENGL_VERSION_31)
|
||||
# define ACGL_OPENGL_VERSION 31
|
||||
#elif defined (ACGL_OPENGL_VERSION_32)
|
||||
# define ACGL_OPENGL_VERSION 32
|
||||
#elif defined (ACGL_OPENGL_VERSION_33)
|
||||
# define ACGL_OPENGL_VERSION 33
|
||||
#elif defined (ACGL_OPENGL_VERSION_40)
|
||||
# define ACGL_OPENGL_VERSION 40
|
||||
#elif defined (ACGL_OPENGL_VERSION_41)
|
||||
# define ACGL_OPENGL_VERSION 41
|
||||
#elif defined (ACGL_OPENGL_VERSION_42)
|
||||
# define ACGL_OPENGL_VERSION 42
|
||||
#elif defined (ACGL_OPENGL_VERSION_43)
|
||||
# define ACGL_OPENGL_VERSION 43
|
||||
#elif defined (ACGL_OPENGL_VERSION_44)
|
||||
# define ACGL_OPENGL_VERSION 44
|
||||
#else
|
||||
#if defined (ACGL_OPENGL_INCLUDE_LATEST_GL)
|
||||
#define ACGL_OPENGL_VERSION_44
|
||||
#define ACGL_OPENGL_VERSION 44
|
||||
#define ACGL_OPENGL_PROFILE_FULL
|
||||
#else
|
||||
// fallback:
|
||||
#warning "NO ACGL_OPENGL_VERSION_XY SET! Default to 3.2 core (but load all available functions)"
|
||||
// *we* only assume OpenGL 3.2 core...
|
||||
#define ACGL_OPENGL_VERSION_32
|
||||
#define ACGL_OPENGL_VERSION 32
|
||||
#define ACGL_OPENGL_PROFILE_CORE
|
||||
// ... but include the latest header and try to load all function in case the app needs more:
|
||||
// (only if the internal loader gets used, but GLEW will also try to load everything)
|
||||
#define ACGL_OPENGL_INCLUDE_LATEST_GL
|
||||
#endif // latest GL
|
||||
#endif // version checks
|
||||
#endif // OpenGL ES
|
||||
|
||||
|
||||
#if (ACGL_OPENGL_VERSION < 32) && defined(ACGL_OPENGL_PROFILE_CORE)
|
||||
#warning "OpenGL prior to 3.2 did not have core or compatibility profiles"
|
||||
#undef ACGL_OPENGL_PROFILE_CORE
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Include the right headers with the OpenGL functions and defines:
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CHECKGLERROR();
|
||||
|
||||
#ifdef ACGL_OPENGL_ES
|
||||
// ES does not know 64bit ints but we need them for the Buffer class:
|
||||
#include <stdint.h>
|
||||
typedef int64_t GLint64;
|
||||
|
||||
#if (PLATFORM_IOS)
|
||||
//iOS:
|
||||
#if defined (ACGL_OPENGLES_VERSION_20)
|
||||
#import <OpenGLES/ES1/gl.h>
|
||||
#import <OpenGLES/ES1/glext.h>
|
||||
#import <OpenGLES/ES2/gl.h>
|
||||
#import <OpenGLES/ES2/glext.h>
|
||||
#else
|
||||
#error "location of ES 3 headers not known"
|
||||
#endif
|
||||
#elif defined (PLATFORM_ANDROID)
|
||||
// Android:
|
||||
#if defined (ACGL_OPENGLES_VERSION_20)
|
||||
//#include <GLES/gl.h>
|
||||
//#include <GLES/glext.h>
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
#else
|
||||
#include <GLES3/gl3.h>
|
||||
#include <GLES3/gl3ext.h>
|
||||
#endif
|
||||
#else
|
||||
#error "UNKNOWN mobile plattform! Don't know what to include!"
|
||||
#endif
|
||||
#else // ACGL_OPENGL_ES
|
||||
// desktop:
|
||||
#ifndef __glew_h__
|
||||
// if glew was already included, don't include anything else
|
||||
// not the recommended way to do it but possible
|
||||
#if (defined(__APPLE__) || defined(MACOSX)) && defined(ACGL_OPENGL_PROFILE_FULL)
|
||||
#if ACGL_OPENGL_VERSION > 21
|
||||
#warning "On MacOS X only core profile is supported for OpenGL >= 3.2"
|
||||
#undef ACGL_OPENGL_PROFILE_FULL
|
||||
#define ACGL_OPENGL_PROFILE_CORE
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ACGL_USE_GLEW
|
||||
#define ACGL_EXTENSION_LOADER_GLEW
|
||||
#if defined(__APPLE__) || defined(MACOSX)
|
||||
#include <OpenGL/glew.h>
|
||||
#else
|
||||
#include <GL/glew.h>
|
||||
#endif
|
||||
#else
|
||||
// use the internal loader:
|
||||
#define ACGL_EXTENSION_LOADER_GLLOADGEN
|
||||
#if defined(__gl_h_) || defined(__GL_H__) || defined(__glext_h_) || defined(__GLEXT_H_) || defined(__gl_ATI_h_) || defined(__gl3_h_)
|
||||
#error ACGL/GL.hh has to be the first OpenGL related file to include!
|
||||
#endif
|
||||
|
||||
//
|
||||
// Include the right header which has just what is needed to catch compatibility problems at compiletime.
|
||||
// The selection could also be done with some preprocessor magic but it confuses most IDEs.
|
||||
//
|
||||
#ifdef ACGL_OPENGL_PROFILE_CORE
|
||||
#if defined (ACGL_OPENGL_VERSION_32)
|
||||
#include <ACGL/OpenGL/glloaders/gl_core_32.hh>
|
||||
#elif defined (ACGL_OPENGL_VERSION_33)
|
||||
#include <ACGL/OpenGL/glloaders/gl_core_33.hh>
|
||||
#elif defined (ACGL_OPENGL_VERSION_40)
|
||||
#include <ACGL/OpenGL/glloaders/gl_core_40.hh>
|
||||
#elif defined (ACGL_OPENGL_VERSION_41)
|
||||
#include <ACGL/OpenGL/glloaders/gl_core_41.hh>
|
||||
#elif defined (ACGL_OPENGL_VERSION_42)
|
||||
#include <ACGL/OpenGL/glloaders/gl_core_42.hh>
|
||||
#elif defined (ACGL_OPENGL_VERSION_43)
|
||||
#include <ACGL/OpenGL/glloaders/gl_core_43.hh>
|
||||
#elif defined (ACGL_OPENGL_VERSION_44)
|
||||
#include <ACGL/OpenGL/glloaders/gl_core_44.hh>
|
||||
#endif
|
||||
#else
|
||||
// compatibility profile:
|
||||
#if defined (ACGL_OPENGL_VERSION_21)
|
||||
#include <ACGL/OpenGL/glloaders/gl_compatibility_21.hh>
|
||||
#elif defined (ACGL_OPENGL_VERSION_30)
|
||||
#include <ACGL/OpenGL/glloaders/gl_compatibility_30.hh>
|
||||
#elif defined (ACGL_OPENGL_VERSION_31)
|
||||
#include <ACGL/OpenGL/glloaders/gl_compatibility_31.hh>
|
||||
#elif defined (ACGL_OPENGL_VERSION_32)
|
||||
#include <ACGL/OpenGL/glloaders/gl_compatibility_32.hh>
|
||||
#elif defined (ACGL_OPENGL_VERSION_33)
|
||||
#include <ACGL/OpenGL/glloaders/gl_compatibility_33.hh>
|
||||
#elif defined (ACGL_OPENGL_VERSION_40)
|
||||
#include <ACGL/OpenGL/glloaders/gl_compatibility_40.hh>
|
||||
#elif defined (ACGL_OPENGL_VERSION_41)
|
||||
#include <ACGL/OpenGL/glloaders/gl_compatibility_41.hh>
|
||||
#elif defined (ACGL_OPENGL_VERSION_42)
|
||||
#include <ACGL/OpenGL/glloaders/gl_compatibility_42.hh>
|
||||
#elif defined (ACGL_OPENGL_VERSION_43)
|
||||
#include <ACGL/OpenGL/glloaders/gl_compatibility_43.hh>
|
||||
#elif defined (ACGL_OPENGL_VERSION_44)
|
||||
#include <ACGL/OpenGL/glloaders/gl_compatibility_44.hh>
|
||||
#endif
|
||||
#endif // ACGL_OPENGL_PROFILE_CORE
|
||||
// prevent other GL headers from getting included and redefine GL:
|
||||
#define __gl3_h_
|
||||
#endif // ACGL_USE_GLEW
|
||||
#else
|
||||
#define ACGL_USE_GLEW
|
||||
#define ACGL_EXTENSION_LOADER_GLEW
|
||||
#endif // __GLEW__
|
||||
#endif // ACGL_OPENGL_ES
|
||||
|
||||
#endif // ACGL_OPENGL_GL_HH
|
195
extern/acgl/include/ACGL/OpenGL/HiLevelObjects/RenderObject.hh
vendored
Normal file
195
extern/acgl/include/ACGL/OpenGL/HiLevelObjects/RenderObject.hh
vendored
Normal file
@ -0,0 +1,195 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
// See http://www.graphics.rwth-aachen.de/redmine/projects/acgl/wiki/ACGL_compile_time_settings
|
||||
// for a comment what deprecated means.
|
||||
#ifdef ACGL_INCLUDE_DEPRECATED
|
||||
|
||||
#ifndef ACGL_OPENGL_OBJECTS_RENDEROBJECT_HH
|
||||
#define ACGL_OPENGL_OBJECTS_RENDEROBJECT_HH
|
||||
|
||||
/**
|
||||
* A RenderObject combines a FrameBuffer to draw to, a ShaderProgramObject
|
||||
* to draw with and a VertexBufferObject to name what to draw.
|
||||
*
|
||||
* Instead of setting those objects individually and hoping that they match
|
||||
* a RenderObject can take care of that.
|
||||
*
|
||||
* The FBO is optional, if none is set, rendering is performed onscreen.
|
||||
* A Viewport is also optional.
|
||||
*
|
||||
* NOTE: The RenderObject can change the Attributelocation mappings of the VAO
|
||||
* as well as the frag data locations of the ShaderProgram.
|
||||
*/
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
#include <ACGL/OpenGL/GL.hh>
|
||||
#if (ACGL_OPENGL_VERSION >= 30)
|
||||
|
||||
#include <ACGL/OpenGL/Objects/VertexArrayObject.hh>
|
||||
#include <ACGL/OpenGL/HiLevelObjects/ShaderProgramObject.hh>
|
||||
#include <ACGL/OpenGL/Objects/FrameBufferObject.hh>
|
||||
#include <ACGL/OpenGL/HiLevelObjects/Viewport.hh>
|
||||
|
||||
|
||||
namespace ACGL {
|
||||
namespace OpenGL {
|
||||
|
||||
class RenderObject
|
||||
{
|
||||
ACGL_NOT_COPYABLE(RenderObject)
|
||||
|
||||
// ========================================================================================================= \/
|
||||
// ============================================================================================ CONSTRUCTORS \/
|
||||
// ========================================================================================================= \/
|
||||
public:
|
||||
RenderObject(ConstSharedVertexArrayObject _vertexArrayObject,
|
||||
ConstSharedShaderProgramObject _shaderProgramObject,
|
||||
ConstSharedFrameBufferObject _frameBufferObject = ConstSharedFrameBufferObject(),
|
||||
ConstSharedViewport _viewport = ConstSharedViewport())
|
||||
: mpVertexArrayObject(_vertexArrayObject),
|
||||
mpShaderProgramObject(_shaderProgramObject),
|
||||
mpFrameBufferObject(_frameBufferObject),
|
||||
mpViewport(_viewport)
|
||||
{
|
||||
updateMappings();
|
||||
}
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ GETTERS \/
|
||||
// ==================================================================================================== \/
|
||||
public:
|
||||
inline ConstSharedVertexArrayObject getVertexArrayObject() const { return mpVertexArrayObject; }
|
||||
inline ConstSharedFrameBufferObject getFrameBufferObject() const { return mpFrameBufferObject; }
|
||||
inline ConstSharedShaderProgramObject getShaderProgramObject() const { return mpShaderProgramObject; }
|
||||
inline ConstSharedViewport getViewport() const { return mpViewport; }
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ METHODS \/
|
||||
// ==================================================================================================== \/
|
||||
public:
|
||||
//! Assigns the attribute locations of the VAO to the locations of the ShaderProgram where there are matching names
|
||||
void updateMappings();
|
||||
|
||||
//! setup everything for drawing and store old states
|
||||
inline void enable() const
|
||||
{
|
||||
enableFrameBufferObject();
|
||||
enableShaderProgramObject();
|
||||
enableVertexArrayObject();
|
||||
enableViewport();
|
||||
}
|
||||
|
||||
//! restore old states
|
||||
inline void disable() const
|
||||
{
|
||||
disableViewport();
|
||||
disableVertexArrayObject();
|
||||
disableShaderProgramObject();
|
||||
disableFrameBufferObject();
|
||||
}
|
||||
|
||||
//! draws the VAO, call enable() first!
|
||||
inline void draw() const
|
||||
{
|
||||
mpVertexArrayObject->draw();
|
||||
}
|
||||
|
||||
//! draws the VAO, everything needed for drawing is performed by this call
|
||||
inline void render() const
|
||||
{
|
||||
enable();
|
||||
draw();
|
||||
disable();
|
||||
}
|
||||
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ==================================================================== TESTING WAYS TO STAY COMPATIBLE \/
|
||||
// ==================================================================================================== \/
|
||||
public:
|
||||
//! for testing only: the new enable/disable/render sets store the old GL states, so they can't be const
|
||||
//! some old code works with const RenderObjects. don't rely on this function anymore
|
||||
inline void enableC() const
|
||||
{
|
||||
if(mpFrameBufferObject)
|
||||
{
|
||||
mpFrameBufferObject->bind();
|
||||
}
|
||||
else
|
||||
{
|
||||
glBindFramebuffer( GL_FRAMEBUFFER, 0 );
|
||||
}
|
||||
mpShaderProgramObject->use();
|
||||
mpVertexArrayObject->bind();
|
||||
if(mpViewport)
|
||||
{
|
||||
mpViewport->use();
|
||||
} else if (mpFrameBufferObject) {
|
||||
glm::uvec3 size = mpFrameBufferObject->getSize();
|
||||
glViewport( 0, 0, size.x, size.y );
|
||||
}
|
||||
}
|
||||
|
||||
//! for testing only: the new enable/disable/render sets store the old GL states, so they can't be const
|
||||
//! some old code works with const RenderObjects. don't rely on this function anymore
|
||||
inline void disableC() const
|
||||
{
|
||||
glBindVertexArray( 0 );
|
||||
}
|
||||
|
||||
//! for testing only: the new enable/disable/render sets store the old GL states, so they can't be const
|
||||
//! some old code works with const RenderObjects. don't rely on this function anymore
|
||||
inline void renderC() const
|
||||
{
|
||||
enableC();
|
||||
draw();
|
||||
disableC();
|
||||
}
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ METHODS \/
|
||||
// ==================================================================================================== \/
|
||||
private:
|
||||
void enableFrameBufferObject() const;
|
||||
void disableFrameBufferObject() const;
|
||||
|
||||
void enableShaderProgramObject() const;
|
||||
void disableShaderProgramObject() const;
|
||||
|
||||
void enableViewport() const;
|
||||
void disableViewport() const;
|
||||
|
||||
void enableVertexArrayObject() const;
|
||||
void disableVertexArrayObject() const;
|
||||
|
||||
// =================================================================================================== \/
|
||||
// ============================================================================================ FIELDS \/
|
||||
// =================================================================================================== \/
|
||||
protected:
|
||||
ConstSharedVertexArrayObject mpVertexArrayObject; // mandatory
|
||||
ConstSharedShaderProgramObject mpShaderProgramObject; // mandatory
|
||||
ConstSharedFrameBufferObject mpFrameBufferObject; // optional
|
||||
ConstSharedViewport mpViewport; // optional
|
||||
|
||||
//! old states so render() can be side-effect free
|
||||
mutable Viewport mLastViewport;
|
||||
mutable GLint mLastShaderProgram;
|
||||
mutable GLint mLastFBO;
|
||||
mutable GLint mLastVAO;
|
||||
};
|
||||
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(RenderObject)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif // ACGL_OPENGL_OBJECTS_RENDEROBJECT_HH
|
||||
|
||||
|
||||
#endif
|
124
extern/acgl/include/ACGL/OpenGL/HiLevelObjects/ShaderProgramObject.hh
vendored
Normal file
124
extern/acgl/include/ACGL/OpenGL/HiLevelObjects/ShaderProgramObject.hh
vendored
Normal file
@ -0,0 +1,124 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
// See http://www.graphics.rwth-aachen.de/redmine/projects/acgl/wiki/ACGL_compile_time_settings
|
||||
// for a comment what unsupported means.
|
||||
#ifdef deprecated
|
||||
|
||||
#ifndef ACGL_OPENGL_OBJECTS_SHADERPROGRAMOBJECT_HH
|
||||
#define ACGL_OPENGL_OBJECTS_SHADERPROGRAMOBJECT_HH
|
||||
|
||||
/*
|
||||
* A ShaderProgramObject has no direct OpenGL counterpart but it is a combination
|
||||
* of a ShaderProgram an a set of Uniforms which are saved on the client side
|
||||
* until that ShaderProgram gets used.
|
||||
*
|
||||
* This way we can have multiple ShaderProgramOpbjects for the same ShaderProgram
|
||||
* but with different values for the uniforms (think of 5 objects which use the same
|
||||
* material shader but have different ModelviewMatrixes and colors set as uniforms,
|
||||
* in that case we only need one ShaderProgram but 5 descriptions of the different
|
||||
* uniform values. Thats what this class provides).
|
||||
*
|
||||
* You might not use this class directly but as a part of a RenderObject!
|
||||
*/
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
|
||||
#include <ACGL/Base/Macros.hh>
|
||||
#include <ACGL/OpenGL/GL.hh>
|
||||
#include <ACGL/OpenGL/Objects/ShaderProgram.hh>
|
||||
#include <ACGL/OpenGL/HiLevelObjects/Uniform.hh>
|
||||
|
||||
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
class ShaderProgramObject
|
||||
{
|
||||
ACGL_NOT_COPYABLE(ShaderProgramObject)
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ STRUCTS \/
|
||||
// ==================================================================================================== \/
|
||||
public:
|
||||
struct UniformAttachment
|
||||
{
|
||||
GLint location;
|
||||
ConstSharedUniform uniform;
|
||||
};
|
||||
|
||||
struct UniformTextureAttachment
|
||||
{
|
||||
GLint location;
|
||||
ConstSharedUniformTexture uniformTexture;
|
||||
};
|
||||
|
||||
// ===================================================================================================== \/
|
||||
// ============================================================================================ TYPEDEFS \/
|
||||
// ===================================================================================================== \/
|
||||
public:
|
||||
typedef std::vector< UniformAttachment > UniformAttachmentVec;
|
||||
typedef std::vector< UniformTextureAttachment > UniformTextureAttachmentVec;
|
||||
|
||||
// ========================================================================================================= \/
|
||||
// ============================================================================================ CONSTRUCTORS \/
|
||||
// ========================================================================================================= \/
|
||||
public:
|
||||
ShaderProgramObject(const ConstSharedShaderProgram& _shaderProgram)
|
||||
: mpShaderProgram(_shaderProgram)
|
||||
{}
|
||||
|
||||
virtual ~ShaderProgramObject(void) {}
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ GETTERS \/
|
||||
// ==================================================================================================== \/
|
||||
public:
|
||||
inline ConstSharedShaderProgram getShaderProgram (void) const { return mpShaderProgram; }
|
||||
inline UniformAttachmentVec getUniformAttachments (void) const { return mUniformAttachments; }
|
||||
inline UniformTextureAttachmentVec getUniformTextureAttachments (void) const { return mUniformTextureAttachments; }
|
||||
|
||||
// ===================================================================================================== \/
|
||||
// ============================================================================================ WRAPPERS \/
|
||||
// ===================================================================================================== \/
|
||||
public:
|
||||
void use (void) const;
|
||||
void updateUniforms (void) const;
|
||||
|
||||
inline void attachUniform(
|
||||
const std::string& _name,
|
||||
const ConstSharedUniform& _uniform)
|
||||
{
|
||||
UniformAttachment uniformAttachment = { mpShaderProgram->getUniformLocation(_name), _uniform };
|
||||
mUniformAttachments.push_back(uniformAttachment);
|
||||
}
|
||||
|
||||
inline void attachUniformTexture(
|
||||
const std::string& _name,
|
||||
const ConstSharedUniformTexture& _uniformTexture)
|
||||
{
|
||||
UniformTextureAttachment uniformTextureAttachment = { mpShaderProgram->getUniformLocation(_name), _uniformTexture };
|
||||
mUniformTextureAttachments.push_back(uniformTextureAttachment);
|
||||
}
|
||||
|
||||
// =================================================================================================== \/
|
||||
// ============================================================================================ FIELDS \/
|
||||
// =================================================================================================== \/
|
||||
protected:
|
||||
ConstSharedShaderProgram mpShaderProgram;
|
||||
UniformAttachmentVec mUniformAttachments;
|
||||
UniformTextureAttachmentVec mUniformTextureAttachments;
|
||||
};
|
||||
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(ShaderProgramObject)
|
||||
|
||||
} // OpenGL
|
||||
} // ACGL
|
||||
|
||||
#endif // ACGL_OPENGL_OBJECTS_SHADERPROGRAMOBJECT_HH
|
||||
|
||||
|
||||
#endif
|
229
extern/acgl/include/ACGL/OpenGL/HiLevelObjects/Uniform.hh
vendored
Normal file
229
extern/acgl/include/ACGL/OpenGL/HiLevelObjects/Uniform.hh
vendored
Normal file
@ -0,0 +1,229 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
// See http://www.graphics.rwth-aachen.de/redmine/projects/acgl/wiki/ACGL_compile_time_settings
|
||||
// for a comment what unsupported means.
|
||||
#ifdef deprecated
|
||||
|
||||
#ifndef ACGL_OPENGL_OBJECTS_UNIFORM_HH
|
||||
#define ACGL_OPENGL_OBJECTS_UNIFORM_HH
|
||||
|
||||
/*
|
||||
* Uniforms do not map to OpenGL objects directly, to set a uniform value in a
|
||||
* ShaderProgram, use the setUniform() / setProgramUniform() methods there with
|
||||
* the raw values you want to ste.
|
||||
*
|
||||
* This class provides the ability to save uniform values on the client side and
|
||||
* wait with the uploading until the ShaderProgram gets used. It gets used in
|
||||
* combination with the ShaderProgramObject/RenderObject (see there).
|
||||
*/
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
|
||||
#include <ACGL/Base/Macros.hh>
|
||||
#include <ACGL/OpenGL/GL.hh>
|
||||
#include <ACGL/Math/Math.hh>
|
||||
#include <ACGL/OpenGL/Objects/Texture.hh>
|
||||
#include <vector>
|
||||
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
// ================================================================================================== \/
|
||||
// ================================================================================== BASIC INTERFACE \/
|
||||
// ================================================================================================== \/
|
||||
class Uniform
|
||||
{
|
||||
public:
|
||||
//! Apply the uniform to a specified location
|
||||
virtual void apply(GLint) const = 0;
|
||||
};
|
||||
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(Uniform)
|
||||
|
||||
// ================================================================================================= \/
|
||||
// ===================================================================================== C-SIDE DATA \/
|
||||
// ================================================================================================= \/
|
||||
template<typename T>
|
||||
class UniformData
|
||||
{
|
||||
// ===================================================================================================== \/
|
||||
// ============================================================================================ TYPEDEFS \/
|
||||
// ===================================================================================================== \/
|
||||
public:
|
||||
typedef T DATA_TYPE;
|
||||
|
||||
// ========================================================================================================= \/
|
||||
// ============================================================================================ CONSTRUCTORS \/
|
||||
// ========================================================================================================= \/
|
||||
public:
|
||||
UniformData(void) : mValue() {}
|
||||
virtual ~UniformData(void) {}
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ SETTERS \/
|
||||
// ==================================================================================================== \/
|
||||
public:
|
||||
inline void setValue (const T& _value) { mValue = _value; }
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ GETTERS \/
|
||||
// ==================================================================================================== \/
|
||||
public:
|
||||
inline const T& getValue (void) const { return mValue; }
|
||||
|
||||
// =================================================================================================== \/
|
||||
// ============================================================================================ FIELDS \/
|
||||
// =================================================================================================== \/
|
||||
protected:
|
||||
T mValue;
|
||||
};
|
||||
|
||||
// ===================================================================================================== \/
|
||||
// ===================================================================================== IMPLEMENTATIONS \/
|
||||
// ===================================================================================================== \/
|
||||
class Uniform1i : public UniformData<GLint>, public Uniform
|
||||
{
|
||||
public:
|
||||
Uniform1i(void) : UniformData<GLint>() {}
|
||||
virtual ~Uniform1i(void) {}
|
||||
void apply(GLint _location) const { glUniform1i(_location, mValue); }
|
||||
};
|
||||
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(Uniform1i)
|
||||
|
||||
//=========================
|
||||
|
||||
#if (ACGL_OPENGL_VERSION >= 30)
|
||||
class Uniform1ui : public UniformData<GLuint>, public Uniform
|
||||
{
|
||||
public:
|
||||
Uniform1ui(void) : UniformData<GLuint>() {}
|
||||
virtual ~Uniform1ui(void) {}
|
||||
void apply(GLint _location) const { glUniform1ui(_location, mValue); }
|
||||
};
|
||||
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(Uniform1ui)
|
||||
#endif
|
||||
|
||||
//=========================
|
||||
|
||||
class Uniform1f : public UniformData<GLfloat>, public Uniform
|
||||
{
|
||||
public:
|
||||
Uniform1f(void) : UniformData<GLfloat>() {}
|
||||
virtual ~Uniform1f(void) {}
|
||||
void apply(GLint _location) const { glUniform1f(_location, mValue); }
|
||||
};
|
||||
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(Uniform1f)
|
||||
|
||||
//=========================
|
||||
|
||||
class Uniform1fv : public UniformData<std::vector<GLfloat> >, public Uniform
|
||||
{
|
||||
public:
|
||||
virtual ~Uniform1fv(void) {}
|
||||
void apply(GLint _location) const
|
||||
{
|
||||
if(!mValue.empty())
|
||||
glUniform1fv(_location, (GLsizei)mValue.size(), (GLfloat*)&mValue[0]);
|
||||
}
|
||||
};
|
||||
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(Uniform1fv)
|
||||
|
||||
//=========================
|
||||
|
||||
class Uniform2f : public UniformData<glm::vec2>, public Uniform
|
||||
{
|
||||
public:
|
||||
Uniform2f(void) : UniformData<glm::vec2>() {}
|
||||
virtual ~Uniform2f(void) {}
|
||||
void apply(GLint _location) const { glUniform2fv(_location, 1, glm::value_ptr(mValue)); }
|
||||
};
|
||||
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(Uniform2f)
|
||||
|
||||
|
||||
//=========================
|
||||
|
||||
class Uniform3f : public UniformData<glm::vec3>, public Uniform
|
||||
{
|
||||
public:
|
||||
Uniform3f(void) : UniformData<glm::vec3>() {}
|
||||
virtual ~Uniform3f(void) {}
|
||||
void apply(GLint _location) const { glUniform3fv(_location, 1, glm::value_ptr(mValue)); }
|
||||
};
|
||||
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(Uniform3f)
|
||||
|
||||
//=========================
|
||||
|
||||
class Uniform4f : public UniformData<glm::vec4>, public Uniform
|
||||
{
|
||||
public:
|
||||
Uniform4f(void) : UniformData<glm::vec4>() {}
|
||||
virtual ~Uniform4f(void) {}
|
||||
void apply(GLint _location) const { glUniform4fv(_location, 1, glm::value_ptr(mValue)); }
|
||||
};
|
||||
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(Uniform4f)
|
||||
|
||||
//=========================
|
||||
|
||||
class UniformMatrix2f : public UniformData<glm::mat2>, public Uniform
|
||||
{
|
||||
public:
|
||||
UniformMatrix2f(void) : UniformData<glm::mat2>() {}
|
||||
virtual ~UniformMatrix2f(void) {}
|
||||
void apply(GLint _location) const { glUniformMatrix2fv(_location, 1, GL_FALSE, glm::value_ptr(mValue)); }
|
||||
};
|
||||
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(UniformMatrix2f)
|
||||
|
||||
//=========================
|
||||
|
||||
class UniformMatrix3f : public UniformData<glm::mat3>, public Uniform
|
||||
{
|
||||
public:
|
||||
UniformMatrix3f(void) : UniformData<glm::mat3>() {}
|
||||
virtual ~UniformMatrix3f(void) {}
|
||||
void apply(GLint _location) const { glUniformMatrix3fv(_location, 1, GL_FALSE, glm::value_ptr(mValue)); }
|
||||
};
|
||||
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(UniformMatrix3f)
|
||||
|
||||
//=========================
|
||||
|
||||
class UniformMatrix4f : public UniformData<glm::mat4>, public Uniform
|
||||
{
|
||||
public:
|
||||
UniformMatrix4f(void) : UniformData<glm::mat4>() {}
|
||||
virtual ~UniformMatrix4f(void) {}
|
||||
void apply(GLint _location) const { glUniformMatrix4fv(_location, 1, GL_FALSE, glm::value_ptr(mValue)); }
|
||||
};
|
||||
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(UniformMatrix4f)
|
||||
|
||||
//=========================
|
||||
class UniformTexture : public UniformData<ConstSharedTextureBase>
|
||||
{
|
||||
public:
|
||||
UniformTexture(void) : UniformData<ConstSharedTextureBase>() {}
|
||||
virtual ~UniformTexture(void) {}
|
||||
void apply(GLint _location, GLenum _unit) const { glUniform1i(_location, _unit); mValue->bind(_unit); }
|
||||
};
|
||||
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(UniformTexture)
|
||||
|
||||
} // OpenGL
|
||||
} // ACGL
|
||||
|
||||
#endif // ACGL_OPENGL_OBJECTS_UNIFORM_HH
|
||||
|
||||
|
||||
#endif
|
97
extern/acgl/include/ACGL/OpenGL/HiLevelObjects/Viewport.hh
vendored
Normal file
97
extern/acgl/include/ACGL/OpenGL/HiLevelObjects/Viewport.hh
vendored
Normal file
@ -0,0 +1,97 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef ACGL_OPENGL_OBJECTS_VIEWPORT_HH
|
||||
#define ACGL_OPENGL_OBJECTS_VIEWPORT_HH
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
|
||||
#include <ACGL/Base/Macros.hh>
|
||||
#include <ACGL/OpenGL/GL.hh>
|
||||
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
class Viewport
|
||||
{
|
||||
ACGL_NOT_COPYABLE(Viewport)
|
||||
|
||||
// ========================================================================================================= \/
|
||||
// ============================================================================================ CONSTRUCTORS \/
|
||||
// ========================================================================================================= \/
|
||||
public:
|
||||
Viewport(GLint _offsetX = 0,
|
||||
GLint _offsetY = 0,
|
||||
GLsizei _width = 0,
|
||||
GLsizei _height = 0)
|
||||
: mOffsetX(_offsetX),
|
||||
mOffsetY(_offsetY),
|
||||
mWidth(_width),
|
||||
mHeight(_height)
|
||||
{ }
|
||||
|
||||
virtual ~Viewport(void) { }
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ GETTERS \/
|
||||
// ==================================================================================================== \/
|
||||
public:
|
||||
inline GLint getOffsetX (void) const { return mOffsetX; }
|
||||
inline GLint getOffsetY (void) const { return mOffsetY; }
|
||||
inline GLsizei getWidth (void) const { return mWidth; }
|
||||
inline GLsizei getHeight (void) const { return mHeight; }
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ METHODS \/
|
||||
// ==================================================================================================== \/
|
||||
public:
|
||||
inline void use (void) const
|
||||
{
|
||||
glViewport(mOffsetX, mOffsetY, mWidth, mHeight);
|
||||
}
|
||||
|
||||
inline void setOffset (GLint _offsetX, GLint _offsetY)
|
||||
{
|
||||
mOffsetX = _offsetX;
|
||||
mOffsetY = _offsetY;
|
||||
}
|
||||
|
||||
inline void setSize (GLsizei _width, GLsizei _height)
|
||||
{
|
||||
mWidth = _width;
|
||||
mHeight = _height;
|
||||
}
|
||||
|
||||
//! gets the current viewport form OpenGL
|
||||
void setFromGLContext()
|
||||
{
|
||||
GLint viewport[4];
|
||||
glGetIntegerv( GL_VIEWPORT, &(viewport[0]) );
|
||||
setOffset(viewport[0], viewport[1]);
|
||||
setSize( viewport[2], viewport[3]);
|
||||
}
|
||||
|
||||
// =================================================================================================== \/
|
||||
// ============================================================================================ FIELDS \/
|
||||
// =================================================================================================== \/
|
||||
protected:
|
||||
GLint mOffsetX;
|
||||
GLint mOffsetY;
|
||||
GLsizei mWidth;
|
||||
GLsizei mHeight;
|
||||
};
|
||||
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(Viewport)
|
||||
|
||||
} // OpenGL
|
||||
} // ACGL
|
||||
|
||||
#endif // ACGL_OPENGL_OBJECTS_STATE_HH
|
||||
|
35
extern/acgl/include/ACGL/OpenGL/Managers.hh
vendored
Normal file
35
extern/acgl/include/ACGL/OpenGL/Managers.hh
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2013 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
* A shortcut to include all manager of OpenGL objects.
|
||||
*/
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
#include <ACGL/OpenGL/Objects.hh>
|
||||
#include <ACGL/Resource/NameManager.hh>
|
||||
#include <ACGL/Resource/FileManager.hh>
|
||||
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
// useful for automatically updating shader programs:
|
||||
typedef Resource::MultiFileManager<ShaderProgram> ShaderProgramFileManager;
|
||||
|
||||
// same for meshes:
|
||||
typedef Resource::FileManager<VertexArrayObject> VAOFileManager;
|
||||
|
||||
// for simple 2D (mip-mapped) textures
|
||||
typedef Resource::FileManager<Texture2D> Texture2DFileManager;
|
||||
|
||||
// used internally:
|
||||
typedef Resource::FileManager<Shader> ShaderFileManager;
|
||||
|
||||
} // OpenGL
|
||||
} // ACGL
|
||||
|
32
extern/acgl/include/ACGL/OpenGL/Objects.hh
vendored
Normal file
32
extern/acgl/include/ACGL/OpenGL/Objects.hh
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2013 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef ACGL_OPENGL_OBJECTS_HH
|
||||
#define ACGL_OPENGL_OBJECTS_HH
|
||||
|
||||
/*
|
||||
* A shortcut to include all OpenGL objects as well as high-level objects.
|
||||
*/
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
|
||||
// low-level objects (with direct OpenGL counterparts):
|
||||
#include <ACGL/OpenGL/Objects/ArrayBuffer.hh>
|
||||
#include <ACGL/OpenGL/Objects/Buffer.hh>
|
||||
#include <ACGL/OpenGL/Objects/ElementArrayBuffer.hh>
|
||||
#include <ACGL/OpenGL/Objects/FrameBufferObject.hh>
|
||||
#include <ACGL/OpenGL/Objects/ProgramPipeline.hh>
|
||||
#include <ACGL/OpenGL/Objects/Query.hh>
|
||||
#include <ACGL/OpenGL/Objects/RenderBuffer.hh>
|
||||
#include <ACGL/OpenGL/Objects/Sampler.hh>
|
||||
#include <ACGL/OpenGL/Objects/Shader.hh>
|
||||
#include <ACGL/OpenGL/Objects/ShaderProgram.hh>
|
||||
#include <ACGL/OpenGL/Objects/Texture.hh>
|
||||
#include <ACGL/OpenGL/Objects/TextureBuffer.hh>
|
||||
#include <ACGL/OpenGL/Objects/UniformBuffer.hh>
|
||||
#include <ACGL/OpenGL/Objects/VertexArrayObject.hh>
|
||||
|
||||
#endif // ACGL_OPENGL_OBJECTS_HH
|
194
extern/acgl/include/ACGL/OpenGL/Objects/ArrayBuffer.hh
vendored
Normal file
194
extern/acgl/include/ACGL/OpenGL/Objects/ArrayBuffer.hh
vendored
Normal file
@ -0,0 +1,194 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef ACGL_OPENGL_OBJECTS_ARRAYBUFFER_HH
|
||||
#define ACGL_OPENGL_OBJECTS_ARRAYBUFFER_HH
|
||||
|
||||
/**
|
||||
* An ArrayBuffer holds an array of per-vertex data. In its simplest form an
|
||||
* array of one attribute, for example the vertex position or texture-coordinate.
|
||||
* An ArrayBuffer however can also hold multiple attributes in an interleaved
|
||||
* way.
|
||||
*
|
||||
* An ArrayBuffer can be drawn directly or indexed in combination with an
|
||||
* ElementArrayBuffer.
|
||||
*
|
||||
* The combination of (multiple) attributes of (multiple) ArrayBuffers
|
||||
* and one (optional) ElementArrayBuffer is a VertexBufferObject or VertexArrayObject.
|
||||
*
|
||||
* Note: In some documents ArrayBuffers (and sometimes ElementArrayBuffers) are
|
||||
* called VertexBufferObjects, VBOs. The original extension that introduced
|
||||
* these two new buffer types was called ARB_vertex_buffer_object but the buffers
|
||||
* itself are called ArrayBuffer and ElementArrayBuffer.
|
||||
*
|
||||
***************************************************************************************************************
|
||||
* Attributes:
|
||||
*************
|
||||
*
|
||||
* _type is the GL type
|
||||
* _size the number of elements in this attribute (1..4)
|
||||
* _normalized is the attribute normalization for int types
|
||||
*
|
||||
* Want to add tightly packed attributes in order?
|
||||
* -> use defineAttribute()
|
||||
*
|
||||
* Want to add attributes with individual padding in order?
|
||||
* -> use defineAttributeWithPadding()
|
||||
*
|
||||
* Want to add attributes out-of-order?
|
||||
* -> use defineAttributeWithOffset()
|
||||
*
|
||||
* The stride size gets always set to the minimal stride size that covers all defined attributes (/w padding).
|
||||
* All define methods can get mixed!
|
||||
*
|
||||
*
|
||||
* ab->defineAttribute( "pos", GL_FLOAT, 3 ); // stride: 12 bytes
|
||||
* ab->defineAttributeWithPadding( "color", GL_CHAR, 3, 1 ); // stride: 12 + 3 + 1 = 16 bytes
|
||||
* ab->defineAttributeWithOffset( "colorNorm", GL_CHAR, 3, 12, GL_TRUE ); // stride is still 16 as 12+3 <= 16!
|
||||
*
|
||||
**************************************************************************************************************/
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
|
||||
#include <ACGL/Base/Macros.hh>
|
||||
#include <ACGL/OpenGL/GL.hh>
|
||||
#include <ACGL/OpenGL/Tools.hh>
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <ACGL/OpenGL/Objects/Buffer.hh>
|
||||
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
class GeometryData;
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(GeometryData)
|
||||
|
||||
class ArrayBuffer : public Buffer
|
||||
{
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ STRUCTS \/
|
||||
// ==================================================================================================== \/
|
||||
public:
|
||||
//! Each attribute has a size (#components, e.g. normal with x/y/z => 3) and an offset in the stride (in bytes)
|
||||
struct Attribute
|
||||
{
|
||||
std::string name; // human readable name, can be used to match the attribute to shader programs
|
||||
GLenum type; // GL_FLOAT, GL_UNSIGNED_BYTE etc.
|
||||
GLint size; // #elements per attribute, size in bytes would be: size*sizeof(type)
|
||||
GLuint offset; // offset in bytes into the array
|
||||
GLboolean normalized; // int types can get normalzed to 0..1 / -1..1 by GL, useful e.g. for colors
|
||||
GLuint divisor; // vertex divisor for instancing, supported since OpenGL 3.3. Default is 0 (== off)
|
||||
GLboolean isIntegerInShader; // should the data get read as vec or ivec ?
|
||||
};
|
||||
|
||||
// ===================================================================================================== \/
|
||||
// ============================================================================================ TYPEDEFS \/
|
||||
// ===================================================================================================== \/
|
||||
public:
|
||||
typedef std::vector< Attribute > AttributeVec;
|
||||
|
||||
// ========================================================================================================= \/
|
||||
// ============================================================================================ CONSTRUCTORS \/
|
||||
// ========================================================================================================= \/
|
||||
public:
|
||||
//! creates an ArrayBuffer with a new OpenGL Buffer object
|
||||
ArrayBuffer()
|
||||
: Buffer(GL_ARRAY_BUFFER),
|
||||
mStride(0),
|
||||
mAttributes()
|
||||
{}
|
||||
|
||||
//! creates an ArrayBuffer with a pre-existing OpenGL Buffer
|
||||
ArrayBuffer( SharedBufferObject _pBuffer )
|
||||
: Buffer(_pBuffer, GL_ARRAY_BUFFER),
|
||||
mStride(0),
|
||||
mAttributes()
|
||||
{}
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ GETTERS \/
|
||||
// ==================================================================================================== \/
|
||||
public:
|
||||
|
||||
//! elements is the number of vertices or instances (if the divisor is != 0):
|
||||
inline GLsizei getElements (void) const { return (GLsizei) (mStride==0?0:(mSize/mStride)); }
|
||||
|
||||
//! size in bytes of all attributes that make up one element (vertex):
|
||||
inline GLsizei getStride (void) const { return mStride; }
|
||||
|
||||
//! Returns the definitions of the attributes:
|
||||
inline const AttributeVec& getAttributes (void) const { return mAttributes; }
|
||||
|
||||
//! Returns one attribute:
|
||||
inline Attribute getAttribute( uint_t i ) const { return mAttributes[i]; }
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ METHODS \/
|
||||
// ==================================================================================================== \/
|
||||
public:
|
||||
//! Adds the attribute at the end of the existing attributes, stride gets computed automatically
|
||||
void defineAttribute( const std::string& _name, GLenum _type, GLint _size, GLboolean _normalized = GL_FALSE, GLuint _divisor = 0);
|
||||
void defineIntegerAttribute( const std::string& _name, GLenum _type, GLint _size, GLboolean _normalized = GL_FALSE, GLuint _divisor = 0);
|
||||
|
||||
//! Adds the attribute at the end of the existing attributes, stride gets computed automatically
|
||||
//! + extra padding in bytes at the end
|
||||
void defineAttributeWithPadding( const std::string& _name, GLenum _type, GLint _size, GLuint _padding, GLboolean _normalized = GL_FALSE, GLuint _divisor = 0);
|
||||
void defineIntegerAttributeWithPadding( const std::string& _name, GLenum _type, GLint _size, GLuint _padding, GLboolean _normalized = GL_FALSE, GLuint _divisor = 0);
|
||||
|
||||
//! Adds an attribute defined by an offset: this way an attribute can get added at arbitrary
|
||||
//! locations in the stride. If it's added at the end, the stride gets resized. This way attributes can even
|
||||
//! overlap, hope you know what you're doing...
|
||||
void defineAttributeWithOffset( const std::string& _name, GLenum _type, GLint _size, GLuint _offset, GLboolean _normalized = GL_FALSE, GLuint _divisor = 0);
|
||||
void defineIntegerAttributeWithOffset( const std::string& _name, GLenum _type, GLint _size, GLuint _offset, GLboolean _normalized = GL_FALSE, GLuint _divisor = 0);
|
||||
|
||||
//! Takes care of a valid stride size and adds the attribute
|
||||
void defineAttribute( const Attribute &_attribute );
|
||||
|
||||
//! Returns the index of a named attribute
|
||||
int32_t getAttributeIndexByName(const std::string& _nameInArray) const;
|
||||
|
||||
//! Setting of the stride size explicitly is not needed if the attributes are defined correctly (with padding)
|
||||
inline void setStride( GLsizei _stride ) { mStride = _stride; }
|
||||
|
||||
//! Sets all data (attributes, stride, size) to those specified in _geometryData. All previous data are overwritten.
|
||||
void setGeometryData( SharedGeometryData _geometryData );
|
||||
|
||||
//! removes all attributes
|
||||
inline void removeAttributes(void)
|
||||
{
|
||||
mStride = 0;
|
||||
mAttributes.clear();
|
||||
}
|
||||
|
||||
//! Set data for this buffer for a given number of elements (_elements*mStride == size in bytes)
|
||||
//! Use only after all attributes have been defined
|
||||
inline void setDataElements( uint_t _elements, const GLvoid *_pData = NULL, GLenum _usage = GL_STATIC_DRAW ) {
|
||||
setData( mTarget, _elements * mStride, _pData, _usage );
|
||||
}
|
||||
|
||||
//! Overloaded from the base class to _prevent_ redefining of the binding target! (see Buffer)
|
||||
inline void setTarget( GLenum ) {
|
||||
ACGL::Utils::error() << "DON'T redefine the target binding point of an ArrayBuffer" << std::endl;
|
||||
}
|
||||
|
||||
// =================================================================================================== \/
|
||||
// ============================================================================================ FIELDS \/
|
||||
// =================================================================================================== \/
|
||||
protected:
|
||||
GLsizei mStride;
|
||||
AttributeVec mAttributes;
|
||||
};
|
||||
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(ArrayBuffer)
|
||||
|
||||
|
||||
} // OpenGL
|
||||
} // ACGL
|
||||
|
||||
#endif // ACGL_OPENGL_OBJECTS_ARRAYBUFFER_HH
|
340
extern/acgl/include/ACGL/OpenGL/Objects/Buffer.hh
vendored
Normal file
340
extern/acgl/include/ACGL/OpenGL/Objects/Buffer.hh
vendored
Normal file
@ -0,0 +1,340 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef ACGL_OPENGL_OBJECTS_BUFFER_HH
|
||||
#define ACGL_OPENGL_OBJECTS_BUFFER_HH
|
||||
|
||||
/**
|
||||
* A generic OpenGL Buffer Object
|
||||
*
|
||||
* Mostly an OpenGL Buffer Wrapper: names of OpenGL calls are stripped of the
|
||||
* 'gl' and 'Buffer' tokens and setters got a 'set' prefix.
|
||||
*
|
||||
* Calls that give the target the buffer should get bound to have an alternative
|
||||
* call that uses the last used or set target.
|
||||
*
|
||||
* Note: Most methods will bind this buffer!
|
||||
*/
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
|
||||
#include <ACGL/Base/Macros.hh>
|
||||
#include <ACGL/OpenGL/GL.hh>
|
||||
#include <ACGL/OpenGL/Tools.hh>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
|
||||
/**
|
||||
* A minimal(!) wrapper to allow multiple Buffer objects pointing to the same
|
||||
* OpenGL resource (like an ArrayBuffer and a TransformFeedbackBuffer).
|
||||
*
|
||||
* This has to be an extra object so all Buffer types can inherit from Buffer
|
||||
* below to allow a unified API.
|
||||
*/
|
||||
class BufferObject {
|
||||
ACGL_NOT_COPYABLE(BufferObject)
|
||||
public:
|
||||
BufferObject()
|
||||
{
|
||||
mObjectName = 0;
|
||||
glGenBuffers(1, &mObjectName);
|
||||
}
|
||||
|
||||
~BufferObject(void)
|
||||
{
|
||||
// buffer 0 will get ignored by OpenGL
|
||||
glDeleteBuffers(1, &mObjectName);
|
||||
}
|
||||
GLuint mObjectName;
|
||||
|
||||
//! has the side effect of binding this buffer.
|
||||
//! returned value is in bytes
|
||||
GLsizei getSize( GLenum _asTarget ) {
|
||||
glBindBuffer( _asTarget, mObjectName );
|
||||
GLint value;
|
||||
glGetBufferParameteriv( _asTarget, GL_BUFFER_SIZE, &value );
|
||||
return value;
|
||||
}
|
||||
};
|
||||
typedef ptr::shared_ptr<BufferObject> SharedBufferObject;
|
||||
|
||||
|
||||
/**
|
||||
* Buffers are general OpenGL Buffer Wrapper.
|
||||
* The OpenGL resource itself is attached via a shared pointer (GLBufferObject).
|
||||
* This was multiple Buffers can use internaly the same OpenGL resource, this is
|
||||
* useful if one resource should get interpreted as _different_ buffer types
|
||||
* so in that case the same GLBufferObject will get attached to different
|
||||
* Subclass Objects.
|
||||
*
|
||||
* Note: Subclasses should set the mTarget in there constructors!
|
||||
*/
|
||||
class Buffer
|
||||
{
|
||||
// ========================================================================================================= \/
|
||||
// ============================================================================================ CONSTRUCTORS \/
|
||||
// ========================================================================================================= \/
|
||||
public:
|
||||
//! Most common default: a new Buffer corresponds to a new GL resource. You might decide on a binding point
|
||||
//! now or later.
|
||||
Buffer( GLenum _target ) : mSize(0), mTarget(_target)
|
||||
{
|
||||
mBuffer = SharedBufferObject( new BufferObject() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Init with a given, external GL resource.
|
||||
*
|
||||
* Calling this with:
|
||||
* Buffer b( SharedGLBufferObject(NULL) );
|
||||
* Is the way to _explicitly_ state that a real OpenGL resource will get added later.
|
||||
* In this case no GL wrapper calls should ever get called until one gets set!
|
||||
*/
|
||||
Buffer( SharedBufferObject _pBuffer, GLenum _target )
|
||||
: mBuffer( _pBuffer ),
|
||||
mTarget(_target)
|
||||
{
|
||||
mSize = (!mBuffer)?0:mBuffer->getSize( mTarget );
|
||||
}
|
||||
|
||||
virtual ~Buffer(){}
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ GETTERS \/
|
||||
// ==================================================================================================== \/
|
||||
public:
|
||||
inline GLuint getObjectName (void) const { return mBuffer->mObjectName; }
|
||||
inline bool isValid (void) const { return (mBuffer && glIsBuffer( mBuffer->mObjectName ) ); }
|
||||
inline SharedBufferObject getBufferObject () const { return mBuffer; }
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ SETTERS \/
|
||||
// ==================================================================================================== \/
|
||||
|
||||
//! the GL buffer can get changed at any time
|
||||
void setBufferObject( SharedBufferObject _pBuffer ) { mBuffer = _pBuffer; mSize = (!mBuffer)?0:mBuffer->getSize( mTarget ); }
|
||||
|
||||
// ===================================================================================================== \/
|
||||
// ============================================================================================ WRAPPERS \/
|
||||
// ===================================================================================================== \/
|
||||
private:
|
||||
inline GLint getParameter( GLenum _parameter ) const
|
||||
{
|
||||
bind( mTarget );
|
||||
GLint value;
|
||||
glGetBufferParameteriv( mTarget, _parameter, &value );
|
||||
return value;
|
||||
}
|
||||
|
||||
#if ( !defined(ACGL_OPENGL_ES) || (ACGL_OPENGLES_VERSION >= 30))
|
||||
// desktop or ES 3.0 onwards:
|
||||
|
||||
#if (ACGL_OPENGL_VERSION >= 32)
|
||||
inline GLint64 getParameter64( GLenum _parameter ) const
|
||||
{
|
||||
bind( mTarget );
|
||||
GLint64 value;
|
||||
glGetBufferParameteri64v( mTarget, _parameter, &value );
|
||||
return value;
|
||||
}
|
||||
|
||||
public:
|
||||
//! not side effect free! will bind this buffer to it's last target!
|
||||
//! caching of these values on RAM could be a good idea if needed very(!) often (as it's done with the size)!
|
||||
//inline GLint64 getSize() const { return getParameter64( GL_BUFFER_SIZE ); }
|
||||
inline GLint64 getMapOffset() const { return getParameter64( GL_BUFFER_MAP_OFFSET ); }
|
||||
inline GLint64 getMapLength() const { return getParameter64( GL_BUFFER_MAP_LENGTH ); }
|
||||
#else // OpenGL pre 3.2 or OpenGL ES 3.0:
|
||||
|
||||
public:
|
||||
//inline GLint getSize() const { return getParameter ( GL_BUFFER_SIZE ); }
|
||||
inline GLint getMapOffset() const { return getParameter ( GL_BUFFER_MAP_OFFSET ); }
|
||||
inline GLint getMapLength() const { return getParameter ( GL_BUFFER_MAP_LENGTH ); }
|
||||
#endif // OpenGL >= 3.2
|
||||
inline GLenum getAccess() const { return (GLenum) getParameter ( GL_BUFFER_ACCESS ); }
|
||||
inline GLint getAccessFlags() const { return (GLint) getParameter ( GL_BUFFER_ACCESS_FLAGS ); }
|
||||
inline GLboolean isMapped() const { return (GLboolean) getParameter ( GL_BUFFER_MAPPED ); }
|
||||
|
||||
#endif // desktop & ES 3
|
||||
public:
|
||||
inline GLenum getUsage() const { return (GLenum) getParameter ( GL_BUFFER_USAGE ); }
|
||||
|
||||
//! the size is in bytes
|
||||
inline GLint64 getSize() const { return mSize; }
|
||||
|
||||
//! Bind this buffer
|
||||
inline void bind( GLenum _target ) const
|
||||
{
|
||||
glBindBuffer( _target, mBuffer->mObjectName );
|
||||
}
|
||||
|
||||
//! Bind this buffer to its target
|
||||
inline void bind() const
|
||||
{
|
||||
glBindBuffer( mTarget, mBuffer->mObjectName );
|
||||
}
|
||||
|
||||
//! Set data for this buffer. Use only to init the buffer!
|
||||
//! Note: The function is not const, because it changes the corresponding GPU data
|
||||
inline void setData( GLenum _target, GLsizeiptr _sizeInBytes, const GLvoid *_pData = NULL, GLenum _usage = GL_STATIC_DRAW ) {
|
||||
mSize = _sizeInBytes;
|
||||
bind( _target );
|
||||
glBufferData( _target, _sizeInBytes, _pData, _usage );
|
||||
}
|
||||
|
||||
//! Set data for this buffer at the last used target. Use only to init the buffer!
|
||||
inline void setData( GLsizeiptr _sizeInBytes, const GLvoid *_pData = NULL, GLenum _usage = GL_STATIC_DRAW ) {
|
||||
setData( mTarget, _sizeInBytes, _pData, _usage );
|
||||
}
|
||||
|
||||
//! Use this to modify the buffer
|
||||
inline void setSubData( GLenum _target, GLintptr _offset,
|
||||
GLsizeiptr _sizeInBytes, const GLvoid *_pData ) {
|
||||
bind( _target );
|
||||
glBufferSubData( _target, _offset, _sizeInBytes, _pData );
|
||||
}
|
||||
|
||||
//! Use this to modify the buffer
|
||||
inline void setSubData( GLintptr _offset, GLsizeiptr _sizeInBytes, const GLvoid *_pData ) {
|
||||
setSubData( mTarget, _offset, _sizeInBytes, _pData );
|
||||
}
|
||||
|
||||
|
||||
#if ((ACGL_OPENGL_VERSION >= 30) || (ACGL_OPENGLES_VERSION >= 30))
|
||||
/** Map a part of the buffer to client memory
|
||||
* _offset & _length are values in bytes relative to the buffer
|
||||
* _access must contain one (or both) of:
|
||||
* GL_MAP_READ_BIT and GL_MAP_WRITE_BIT
|
||||
* and optionally:
|
||||
* GL_MAP_INVALIDATE_RANGE_BIT GL_MAP_INVALIDATE_BUFFER_BIT
|
||||
* GL_MAP_FLUSH_EXPLICIT_BIT GL_MAP_UNSYNCHRONIZED_BIT
|
||||
*/
|
||||
GLvoid *mapRange( GLenum _target, GLintptr _offset, GLsizeiptr _length, GLbitfield _access ) {
|
||||
bind( _target );
|
||||
GLvoid *ret = glMapBufferRange( _target, _offset, _length, _access );
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline GLvoid *mapRange( GLintptr _offset, GLsizeiptr _length, GLbitfield _access ) {
|
||||
return mapRange( mTarget, _offset, _length, _access );
|
||||
}
|
||||
|
||||
/**
|
||||
* Spec:
|
||||
* If a buffer is mapped with the GL_MAP_FLUSH_EXPLICIT_BIT flag, modifications
|
||||
* to the mapped range may be indicated by calling this.
|
||||
* _offset and _length indicate a modified subrange of the mapping, in byte. The specified
|
||||
* subrange to flush is relative to the start of the currently mapped range of buffer.
|
||||
* This can be called multiple times to indicate distinct subranges
|
||||
* of the mapping which require flushing.
|
||||
*/
|
||||
void flushMappedRange( GLenum _target, GLsizeiptr _offset, GLsizeiptr _length ) {
|
||||
bind( _target );
|
||||
glFlushMappedBufferRange( _target, _offset, _length );
|
||||
}
|
||||
|
||||
inline void flushMappedRange( GLintptr _offset, GLsizeiptr _length ) {
|
||||
flushMappedRange( mTarget, _offset, _length );
|
||||
}
|
||||
|
||||
//! valid targets are only GL_TRANSFORM_FEEDBACK_BUFFER and GL_UNIFORM_BUFFER
|
||||
inline void bindBufferRange( GLenum _target, GLuint _index, GLintptr _offset, GLsizeiptr _size ) {
|
||||
glBindBufferRange( _target, _index, mBuffer->mObjectName, _offset, _size );
|
||||
}
|
||||
|
||||
//! maps a subset of the buffer defined by _offset and _size
|
||||
//! valid targets are only GL_TRANSFORM_FEEDBACK_BUFFER and GL_UNIFORM_BUFFER
|
||||
inline void bindBufferRange( GLuint _index, GLintptr _offset, GLsizeiptr _size ) {
|
||||
glBindBufferRange( mTarget, _index, mBuffer->mObjectName, _offset, _size );
|
||||
}
|
||||
|
||||
//! maps the full buffer to the given index (binding point)
|
||||
//! valid targets are only GL_TRANSFORM_FEEDBACK_BUFFER and GL_UNIFORM_BUFFER
|
||||
inline void bindBufferBase( GLenum _target, GLuint _index ) {
|
||||
glBindBufferBase( _target, _index, mBuffer->mObjectName );
|
||||
}
|
||||
|
||||
//! maps the full buffer to the given index (binding point)
|
||||
//! valid targets are only GL_TRANSFORM_FEEDBACK_BUFFER and GL_UNIFORM_BUFFER
|
||||
inline void bindBufferBase( GLuint _index ) {
|
||||
glBindBufferBase( mTarget, _index, mBuffer->mObjectName );
|
||||
}
|
||||
|
||||
#endif // OpenGL >= 3.0
|
||||
|
||||
#ifndef ACGL_OPENGLES_VERSION_20
|
||||
//! Maps the whole buffer, if using GL 3+, better use mapRange!
|
||||
//! _access is GL_READ_ONLY GL_WRITE_ONLY or GL_READ_WRITE
|
||||
GLvoid *map( GLenum _target, GLenum _access ) {
|
||||
bind( _target );
|
||||
GLvoid *ret = glMapBuffer( _target, _access );
|
||||
return ret;
|
||||
}
|
||||
inline GLvoid *map( GLenum _access ) {
|
||||
return map( mTarget, _access );
|
||||
}
|
||||
|
||||
GLboolean unmap( GLenum _target ) {
|
||||
bind( _target );
|
||||
GLboolean ret = glUnmapBuffer( _target );
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline GLboolean unmap() {
|
||||
return unmap( mTarget );
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO: CopyBufferSubData
|
||||
|
||||
/**
|
||||
* _target must be one of:
|
||||
GL_ARRAY_BUFFER
|
||||
GL_ATOMIC_COUNTER_BUFFER
|
||||
GL_COPY_READ_BUFFER
|
||||
GL_COPY_WRITE_BUFFER
|
||||
GL_DRAW_INDIRECT_BUFFER
|
||||
GL_ELEMENT_ARRAY_BUFFER
|
||||
GL_PIXEL_PACK_BUFFER
|
||||
GL_PIXEL_UNPACK_BUFFER
|
||||
GL_TEXTURE_BUFFER
|
||||
GL_TRANSFORM_FEEDBACK_BUFFER
|
||||
GL_UNIFORM_BUFFER
|
||||
* Can be changed at any time.
|
||||
*
|
||||
* Subclasses should overload this with a non-working function (+ a warning)
|
||||
* because an X-Buffer should not be attached _per default_ to Y!
|
||||
* Subclass buffers can however always use the method calls / binds with an
|
||||
* _explicit_ target (that doesn't match there one ones):
|
||||
*
|
||||
* XBuffer x;
|
||||
* x.bind( Y ); // ok, hope the programmer knowns what s/he does
|
||||
*
|
||||
* x.setTarget( Y ); // this is just calling for unintended side-effects!
|
||||
* x.bind();
|
||||
*/
|
||||
virtual inline void setTarget( GLenum _target ) { mTarget = _target; }
|
||||
|
||||
// =================================================================================================== \/
|
||||
// ============================================================================================ FIELDS \/
|
||||
// =================================================================================================== \/
|
||||
protected:
|
||||
GLint64 mSize; // as this might get queried often (e.g. ArrayBuffer) we will explicitly mirror it in RAM - bytes
|
||||
SharedBufferObject mBuffer;
|
||||
GLenum mTarget;
|
||||
};
|
||||
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(Buffer)
|
||||
|
||||
} // OpenGL
|
||||
} // ACGL
|
||||
|
||||
#endif // ACGL_OPENGL_OBJECTS_BUFFER_HH
|
112
extern/acgl/include/ACGL/OpenGL/Objects/ElementArrayBuffer.hh
vendored
Normal file
112
extern/acgl/include/ACGL/OpenGL/Objects/ElementArrayBuffer.hh
vendored
Normal file
@ -0,0 +1,112 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef ACGL_OPENGL_OBJECTS_ELEMENTBUFFERDATA_HH
|
||||
#define ACGL_OPENGL_OBJECTS_ELEMENTBUFFERDATA_HH
|
||||
|
||||
/**
|
||||
* An ElementArrayBuffer is an index into ArrayBuffers and defines which
|
||||
* elements of that array should be drawn in which order.
|
||||
*
|
||||
* The combination of (multiple) attributes of (multiple) ArrayBuffers
|
||||
* and one (optional) ElementArrayBuffer is a VertexBufferObject or VertexArrayObject.
|
||||
*
|
||||
* Note: In some documents ElementArrayBuffer are called VertexBufferObjects, VBOs
|
||||
* or IndexBufferObjects (IBOs). But ArrayBuffers can also be called VBOs...
|
||||
* The original extension that introduced these two new buffer types was called
|
||||
* ARB_vertex_buffer_object but the buffers itself are called ArrayBuffer and
|
||||
* ElementArrayBuffer.
|
||||
*
|
||||
* WARNING: On word of warning about the EAB: Setting data (e.g. via setData() ) will
|
||||
* of course have to bind this buffer first. The binding of an EAB is a state
|
||||
* of the currently bound VAO, not a global OpenGL state so make sure you bind
|
||||
* the corresponding VAO or VAO 0 first, otherwise there will be a side-effect
|
||||
* of having the wrong EAB bound to some random VAO that just happened to be
|
||||
* bound by chance.
|
||||
* While this behaviour is also true for other buffers and textures, those are
|
||||
* bound to a global OpenGL state that gets changed all the time anyway so you
|
||||
* are probably used to rebind those before using while a VAO does not rebind
|
||||
* its own EAB before drawing as the binding is a state of the VAO.
|
||||
* In debug mode the VAO will check for this kind of inconsistancy that arise
|
||||
* from wrong usage.
|
||||
* Other reasons why a wrong EAB is set to a VAO: Driver bug (some older Intel
|
||||
* drivers did not store the EAB as a VAO state), manual binding (calling of bare
|
||||
* OpenGL commands).
|
||||
*/
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
|
||||
#include <ACGL/Base/Macros.hh>
|
||||
#include <ACGL/OpenGL/GL.hh>
|
||||
#include <ACGL/OpenGL/Tools.hh>
|
||||
#include <ACGL/OpenGL/Objects/Buffer.hh>
|
||||
|
||||
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
class ElementArrayBuffer : public Buffer
|
||||
{
|
||||
// ========================================================================================================= \/
|
||||
// ============================================================================================ CONSTRUCTORS \/
|
||||
// ========================================================================================================= \/
|
||||
public:
|
||||
ElementArrayBuffer( GLenum _type = GL_UNSIGNED_INT)
|
||||
: Buffer(GL_ELEMENT_ARRAY_BUFFER), mType(_type)
|
||||
{}
|
||||
|
||||
ElementArrayBuffer( SharedBufferObject _pBuffer, GLenum _type = GL_UNSIGNED_INT)
|
||||
: Buffer(_pBuffer, GL_ELEMENT_ARRAY_BUFFER), mType(_type)
|
||||
{}
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ GETTERS \/
|
||||
// ==================================================================================================== \/
|
||||
public:
|
||||
//! returns the index data type: GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT
|
||||
inline GLenum getType(void) const { return mType; }
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ SETTERS \/
|
||||
// ==================================================================================================== \/
|
||||
public:
|
||||
//! _type has to be one of GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT and indicates the
|
||||
//! datatype of the indices
|
||||
inline void setType (GLenum _type) { mType = _type; }
|
||||
|
||||
//! set data for this buffer for a given number of elements (size in bytes == _elements * size of mType)
|
||||
inline void setDataElements( uint_t _elements, const GLvoid *_pData = NULL, GLenum _usage = GL_STATIC_DRAW )
|
||||
{
|
||||
setData( mTarget, _elements * getGLTypeSize(mType), _pData, _usage );
|
||||
}
|
||||
|
||||
//! Returns the number of indices:
|
||||
inline GLuint getElements() const
|
||||
{
|
||||
return (GLuint)( getSize() / getGLTypeSize(mType));
|
||||
}
|
||||
|
||||
//! Overloaded from the base class to _prevent_ redefining of the binding target! (see Buffer)
|
||||
inline void setTarget( GLenum )
|
||||
{
|
||||
ACGL::Utils::error() << "DON'T redefine the target binding point of an ElementArrayBuffer" << std::endl;
|
||||
}
|
||||
|
||||
// =================================================================================================== \/
|
||||
// ============================================================================================ FIELDS \/
|
||||
// =================================================================================================== \/
|
||||
protected:
|
||||
//! index data type: GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT
|
||||
GLenum mType;
|
||||
};
|
||||
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(ElementArrayBuffer)
|
||||
|
||||
|
||||
} // OpenGL
|
||||
} // ACGL
|
||||
|
||||
#endif // ACGL_OPENGL_OBJECTS_ELEMENTBUFFERDATA_HH
|
290
extern/acgl/include/ACGL/OpenGL/Objects/FrameBufferObject.hh
vendored
Normal file
290
extern/acgl/include/ACGL/OpenGL/Objects/FrameBufferObject.hh
vendored
Normal file
@ -0,0 +1,290 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef ACGL_OPENGL_OBJECTS_FRAMEBUFFEROBJECT_HH
|
||||
#define ACGL_OPENGL_OBJECTS_FRAMEBUFFEROBJECT_HH
|
||||
|
||||
/**
|
||||
* This FrameBufferObject class encapsulates an OpenGL frame buffer object (FBO).
|
||||
* A FrameBufferObject is a target for rendering and thus consists of different "layers":
|
||||
*
|
||||
* one or no depthbuffer
|
||||
* one or no stencilbuffer
|
||||
* one (OpenGL ES) to many (hardware dependent limit) colorbuffers
|
||||
*
|
||||
* These buffers get attached to the FrameBufferObject.
|
||||
*
|
||||
* There exists one system-provided frame buffer object for rendering to the screen
|
||||
* and optionaly multiple user defined frame buffer objects for offscreen rendering.
|
||||
*
|
||||
* This class does not encapsulate the system-provided FBO.
|
||||
*/
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
|
||||
#include <ACGL/Base/Macros.hh>
|
||||
#include <ACGL/Utils/StringHelpers.hh>
|
||||
#include <ACGL/OpenGL/GL.hh>
|
||||
#include <ACGL/OpenGL/Tools.hh>
|
||||
#include <ACGL/OpenGL/Objects/RenderBuffer.hh>
|
||||
#include <ACGL/OpenGL/Objects/Texture.hh>
|
||||
#include <ACGL/OpenGL/Data/LocationMappings.hh>
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
class FrameBufferObject
|
||||
{
|
||||
ACGL_NOT_COPYABLE(FrameBufferObject)
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ STRUCTS \/
|
||||
// ==================================================================================================== \/
|
||||
public:
|
||||
//! defines a clear color per color buffer
|
||||
struct ClearColor {
|
||||
ClearColor() {
|
||||
mType = Float;
|
||||
mColor.floatColor[0] = mColor.floatColor[1] = mColor.floatColor[2] = mColor.floatColor[3] = 0.0f;
|
||||
}
|
||||
|
||||
enum Type { Integer, UnsignedInteger, Float };
|
||||
union Data {
|
||||
GLint intColor[4];
|
||||
GLuint uintColor[4];
|
||||
GLfloat floatColor[4];
|
||||
} mColor;
|
||||
Type mType; // defines which of the data types of the union to use
|
||||
};
|
||||
|
||||
//! An attachment can be a texture or a render buffer
|
||||
struct Attachment
|
||||
{
|
||||
std::string name; // user defined name that matches the fragment shader out
|
||||
ConstSharedTextureBase texture; // attached color texture, or:
|
||||
ConstSharedRenderBuffer renderBuffer; // attached renderbuffer - only this or the texture should be set!
|
||||
GLuint location; // the frag data location that maps to this attachment
|
||||
Image image; // in case of a texture the image will define which part of the texture to use
|
||||
ClearColor clearColor; // clear color of the attachement
|
||||
};
|
||||
|
||||
// ===================================================================================================== \/
|
||||
// ============================================================================================ TYPEDEFS \/
|
||||
// ===================================================================================================== \/
|
||||
public:
|
||||
typedef std::vector< Attachment > AttachmentVec;
|
||||
|
||||
// ========================================================================================================= \/
|
||||
// ============================================================================================ CONSTRUCTORS \/
|
||||
// ========================================================================================================= \/
|
||||
public:
|
||||
FrameBufferObject(void)
|
||||
: mObjectName(0),
|
||||
mColorAttachments(),
|
||||
mDepthAttachment()
|
||||
{
|
||||
mObjectName = 0;
|
||||
glGenFramebuffers(1, &mObjectName);
|
||||
mDepthAttachment.texture = ConstSharedTextureBase();
|
||||
mDepthAttachment.renderBuffer = ConstSharedRenderBuffer();
|
||||
mDepthAttachment.name = ""; // not useful here
|
||||
mDepthAttachment.location = 0; // not useful here
|
||||
}
|
||||
|
||||
virtual ~FrameBufferObject(void)
|
||||
{
|
||||
// buffer 0 will get ignored by OpenGL
|
||||
glDeleteFramebuffers(1, &mObjectName);
|
||||
}
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ GETTERS \/
|
||||
// ==================================================================================================== \/
|
||||
public:
|
||||
inline GLuint getObjectName (void) const { return mObjectName; }
|
||||
inline const AttachmentVec& getColorAttachments (void) const { return mColorAttachments; }
|
||||
inline const Attachment& getDepthAttachment (void) const { return mDepthAttachment; }
|
||||
|
||||
// ===================================================================================================== \/
|
||||
// ============================================================================================ WRAPPERS \/
|
||||
// ===================================================================================================== \/
|
||||
public:
|
||||
int_t getColorAttachmentIndexByName(const std::string& _name) const;
|
||||
|
||||
void validate (void) const;
|
||||
|
||||
/**
|
||||
* Per default a FrameBufferObject gets used for read/write operations, but we can
|
||||
* bind two different FrameBufferObjects for these operations!
|
||||
*/
|
||||
inline void bind(GLenum _type = GL_FRAMEBUFFER) const
|
||||
{
|
||||
glBindFramebuffer(_type, mObjectName);
|
||||
}
|
||||
|
||||
//! let OpenGL validate the completeness
|
||||
bool isFrameBufferObjectComplete() const;
|
||||
|
||||
/*
|
||||
* Attach another RenderBuffer as a render target. If the name already exists the old target will get replaced.
|
||||
*/
|
||||
inline bool attachColorRenderBuffer(const std::string &_name, const ConstSharedRenderBuffer& _renderBuffer)
|
||||
{
|
||||
Attachment a = {_name, SharedTextureBase(), _renderBuffer, 0xFFFFFFFF, Image(), ClearColor()};
|
||||
return attachColorAttachment( a );
|
||||
}
|
||||
|
||||
inline bool attachColorTexture(const std::string &_name, const ConstSharedTextureBase& _texture, const Image _image = Image() )
|
||||
{
|
||||
Attachment a = {_name, _texture, SharedRenderBuffer(), 0xFFFFFFFF, _image, ClearColor()};
|
||||
return attachColorAttachment( a );
|
||||
}
|
||||
|
||||
inline bool attachColorRenderBuffer(const std::string &_name, const ConstSharedRenderBuffer& _renderBuffer, GLuint _location )
|
||||
{
|
||||
Attachment a = {_name, SharedTextureBase(), _renderBuffer, _location, Image(), ClearColor()};
|
||||
return attachColorAttachment( a );
|
||||
}
|
||||
|
||||
inline bool attachColorTexture(const std::string &_name, const ConstSharedTextureBase& _texture, GLuint _location, const Image _image = Image() )
|
||||
{
|
||||
Attachment a = {_name, _texture, SharedRenderBuffer(), _location, _image, ClearColor()};
|
||||
return attachColorAttachment( a );
|
||||
}
|
||||
|
||||
// if the location within the attachment is larger than the possible number of attachments,
|
||||
// attachColorAttachment will try to find a non-colliding attachment point.
|
||||
// this can be used to say "i don't care about the actual attachment number used"
|
||||
bool attachColorAttachment( const Attachment &_attachment );
|
||||
|
||||
void remapAttachments();
|
||||
|
||||
inline bool setDepthRenderBuffer(const ConstSharedRenderBuffer& _renderBuffer)
|
||||
{
|
||||
bind();
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, _renderBuffer->getObjectName() );
|
||||
#ifdef ACGL_OPENGL_ES
|
||||
if( _renderBuffer->getInternalFormat() == GL_DEPTH24_STENCIL8_OES ||
|
||||
_renderBuffer->getInternalFormat() == GL_DEPTH_STENCIL_OES)
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, _renderBuffer->getObjectName() );
|
||||
#else
|
||||
if( _renderBuffer->getInternalFormat() == GL_DEPTH24_STENCIL8 ||
|
||||
_renderBuffer->getInternalFormat() == GL_DEPTH_STENCIL)
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, _renderBuffer->getObjectName() );
|
||||
#endif
|
||||
mDepthAttachment.renderBuffer = _renderBuffer;
|
||||
return true;
|
||||
}
|
||||
|
||||
//! todo: support mipmap levels
|
||||
inline bool setDepthTexture(const ConstSharedTextureBase& _texture)
|
||||
{
|
||||
bind();
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, _texture->getTarget(), _texture->getObjectName(), 0);
|
||||
#ifdef ACGL_OPENGL_ES
|
||||
if( _texture->getInternalFormat() == GL_DEPTH24_STENCIL8_OES ||
|
||||
_texture->getInternalFormat() == GL_DEPTH_STENCIL_OES)
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, _texture->getTarget(), _texture->getObjectName(), 0);
|
||||
#else
|
||||
if( _texture->getInternalFormat() == GL_DEPTH24_STENCIL8 ||
|
||||
_texture->getInternalFormat() == GL_DEPTH_STENCIL)
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, _texture->getTarget(), _texture->getObjectName(), 0);
|
||||
#endif
|
||||
mDepthAttachment.texture = _texture;
|
||||
return true;
|
||||
}
|
||||
|
||||
//! x,y coordinate is the FBO size in pixels, z coordinate the number of color attachments. x,y are both 0 if the FBO has no useful size
|
||||
//! todo: support mipmap levels
|
||||
glm::uvec3 getSize() const
|
||||
{
|
||||
glm::uvec3 size;
|
||||
|
||||
if (mDepthAttachment.texture) {
|
||||
// use the size of the depth texture
|
||||
size = mDepthAttachment.texture->getSize();
|
||||
} else if (mDepthAttachment.renderBuffer) {
|
||||
// use the size of the depth render buffer
|
||||
size = glm::uvec3( mDepthAttachment.renderBuffer->getSize(), 0 );
|
||||
} else if ( mColorAttachments.size() > 0 ) {
|
||||
if (mColorAttachments[0].texture) {
|
||||
// use the size of the first texture:
|
||||
size = mColorAttachments[0].texture->getSize();
|
||||
} else if (mColorAttachments[0].renderBuffer) {
|
||||
// use the size of the first renderBuffer:
|
||||
size = glm::uvec3( mColorAttachments[0].renderBuffer->getSize(), 0 );
|
||||
}
|
||||
} else {
|
||||
size = glm::uvec3(0);
|
||||
}
|
||||
|
||||
size.z = mColorAttachments.size();
|
||||
return size;
|
||||
}
|
||||
|
||||
// =================================================================================================== \/
|
||||
// =========================================================================================== METHODS \/
|
||||
// =================================================================================================== \/
|
||||
public:
|
||||
//! sets the attachment locations of this FBO where they match the names specified in _locationMappings
|
||||
void setAttachmentLocations(ConstSharedLocationMappings _locationMappings);
|
||||
|
||||
//! get a list of attachment locations and names that can be used to set up a ShaderProgram
|
||||
SharedLocationMappings getAttachmentLocations() const;
|
||||
|
||||
//! returns the current contents of the default FrameBuffer
|
||||
//! the format of the returned TextureData will be GL_RGB, the type will be GL_UNSIGNED_INT
|
||||
//! _readBuffer = GL_INVALID_ENUM will read out the default read buffer
|
||||
static SharedTextureData getImageData(GLsizei _width, GLsizei _height, GLint _x = 0, GLint _y = 0, GLenum _readBuffer = GL_INVALID_ENUM);
|
||||
|
||||
//! get the part of the framebuffer thats part of the current viewport
|
||||
static SharedTextureData getImageData();
|
||||
|
||||
//
|
||||
// clear buffer functions:
|
||||
//
|
||||
|
||||
//! clear only the depth buffer:
|
||||
void clearDepthBuffer();
|
||||
|
||||
//! clear one specific color buffer:
|
||||
void clearBuffer( const std::string &_name );
|
||||
|
||||
//! clear all buffers, color and depth:
|
||||
void clearBuffers();
|
||||
|
||||
//! sets the clear color for one buffer:
|
||||
void setClearColor( const std::string &_name, const glm::vec4 &_color );
|
||||
//! sets the clear color for one buffer:
|
||||
void setClearColor( const std::string &_name, const glm::ivec4 &_color );
|
||||
//! sets the clear color for one buffer:
|
||||
void setClearColor( const std::string &_name, const glm::uvec4 &_color );
|
||||
|
||||
//! sets the clear color for all color buffers:
|
||||
void setClearColor( const glm::vec4 &_color );
|
||||
//! sets the clear color for all color buffers:
|
||||
void setClearColor( const glm::ivec4 &_color );
|
||||
//! sets the clear color for all color buffers:
|
||||
void setClearColor( const glm::uvec4 &_color );
|
||||
|
||||
// =================================================================================================== \/
|
||||
// ============================================================================================ FIELDS \/
|
||||
// =================================================================================================== \/
|
||||
protected:
|
||||
GLuint mObjectName;
|
||||
AttachmentVec mColorAttachments;
|
||||
Attachment mDepthAttachment; // depth and stencil are combined
|
||||
};
|
||||
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(FrameBufferObject)
|
||||
|
||||
} // OpenGL
|
||||
} // ACGL
|
||||
|
||||
#endif // ACGL_OPENGL_OBJECTS_FRAMEBUFFEROBJECT_HH
|
89
extern/acgl/include/ACGL/OpenGL/Objects/ProgramPipeline.hh
vendored
Normal file
89
extern/acgl/include/ACGL/OpenGL/Objects/ProgramPipeline.hh
vendored
Normal file
@ -0,0 +1,89 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef ACGL_OPENGL_OBJECTS_PROGRAMPIPELINE_HH
|
||||
#define ACGL_OPENGL_OBJECTS_PROGRAMPIPELINE_HH
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
|
||||
#include <ACGL/Base/Macros.hh>
|
||||
#include <ACGL/OpenGL/GL.hh>
|
||||
#include <ACGL/OpenGL/Tools.hh>
|
||||
|
||||
#include <ACGL/OpenGL/Objects/ShaderProgram.hh>
|
||||
|
||||
|
||||
#if (ACGL_OPENGL_VERSION >= 41)
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
/**
|
||||
* OpenGL ProgramPipeline Objects (needs OpenGL 4.1)
|
||||
*
|
||||
* Multiple ShaderPrograms that are set to be separable can be attached to one ProgramPipeline.
|
||||
* Uniforms are still a ShaderProgram (not ProgramPipeline) state, so to update them you either have to
|
||||
* select the correct ShaderProgram first (glActiveShaderProgram) or use the setProgramUniform variants.
|
||||
*
|
||||
* When using multiple ShaderPrograms in one ProgramPipeline the varyings don't just match based on
|
||||
* the names any more, look up "Shader Interface Matching", cry, and rethink whether you still want to
|
||||
* play around with ProgramPipeline Objects.
|
||||
*/
|
||||
|
||||
class ProgramPipeline {
|
||||
ACGL_NOT_COPYABLE(ProgramPipeline)
|
||||
public:
|
||||
ProgramPipeline();
|
||||
~ProgramPipeline(void);
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ GETTERS \/
|
||||
// ==================================================================================================== \/
|
||||
public:
|
||||
inline GLuint getObjectName(void) const { return mObjectName; }
|
||||
|
||||
// ===================================================================================================== \/
|
||||
// ============================================================================================ WRAPPERS \/
|
||||
// ===================================================================================================== \/
|
||||
//! Set this ProgramPipeline active, will override active ShaderPrograms!
|
||||
inline void bind() const
|
||||
{
|
||||
glBindProgramPipeline( mObjectName );
|
||||
}
|
||||
|
||||
//! unbinds the ProgramPipeline (if there is one bound), after that, ShaderPrograms can be used again directly
|
||||
inline static void unBind() { glBindProgramPipeline( 0 ); }
|
||||
|
||||
//! Sets the given ShaderProgram (that should be part of the ProgramPipeline, which should be active) as target
|
||||
//! for setUniform() calls. Alternatively use the setProgramUniform calls!
|
||||
inline void setActiveShaderProgram( GLuint _shaderProgram ) { glActiveShaderProgram( mObjectName, _shaderProgram ); }
|
||||
|
||||
//! Sets the given ShaderProgram (that should be part of the ProgramPipeline, which should be active) as target
|
||||
//! for setUniform() calls. Alternatively use the setProgramUniform calls!
|
||||
inline void setActiveShaderProgram( const SharedShaderProgram &_shaderProgram ) { glActiveShaderProgram( mObjectName, _shaderProgram->getObjectName() ); }
|
||||
|
||||
//! _stages is a bitwise OR of GL_TESS_CONTROL_SHADER_BIT, GL_TESS_EVALUATION_SHADER_BIT, GL_VERTEX_SHADER_BIT, GL_GEOMETRY_SHADER_BIT,
|
||||
//! and/or GL_FRAGMENT_SHADER_BIT _or_ GL_ALL_SHADER_BITS
|
||||
void useProgramStages( GLbitfield _stages, SharedShaderProgram _shaderProgram ) {
|
||||
if (_shaderProgram) {
|
||||
glUseProgramStages( mObjectName, _stages, _shaderProgram->getObjectName() );
|
||||
} else {
|
||||
glUseProgramStages( mObjectName, _stages, 0 ); // deactivates that part of the pipeline (defined by _stages)
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
// TODO: save 5 SharedPointer to the 5 ShaderPrograms for the individual stages
|
||||
GLuint mObjectName;
|
||||
};
|
||||
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(ProgramPipeline)
|
||||
|
||||
} // OpenGL
|
||||
} // ACGL
|
||||
|
||||
#endif // OpenGL >= 4.1
|
||||
|
||||
#endif // ACGL_OPENGL_OBJECTS_PROGRAMPIPELINE_HH
|
189
extern/acgl/include/ACGL/OpenGL/Objects/Query.hh
vendored
Normal file
189
extern/acgl/include/ACGL/OpenGL/Objects/Query.hh
vendored
Normal file
@ -0,0 +1,189 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef ACGL_OPENGL_OBJECTS_QUERY_HH
|
||||
#define ACGL_OPENGL_OBJECTS_QUERY_HH
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
|
||||
#include <ACGL/Base/Macros.hh>
|
||||
#include <ACGL/OpenGL/GL.hh>
|
||||
#include <ACGL/OpenGL/Tools.hh>
|
||||
|
||||
#ifndef ACGL_OPENGLES_VERSION_20
|
||||
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
/**
|
||||
* A generic OpenGL asynchronous query, target types can be:
|
||||
* SAMPLES_PASSED
|
||||
* ANY_SAMPLES_PASSED
|
||||
* PRIMITIVES_GENERATED
|
||||
* TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN
|
||||
* TIME_ELAPSED
|
||||
*
|
||||
* See specialized queries below.
|
||||
*
|
||||
* Note: * Indexed queries are not jet supported.
|
||||
* * Only one query per type is alowed to be active at any time.
|
||||
* * Before the result can get read out, the query must end() !
|
||||
*/
|
||||
class AsynchronousQuery {
|
||||
public:
|
||||
AsynchronousQuery( GLenum _defaultTarget )
|
||||
: mTarget(_defaultTarget)
|
||||
{
|
||||
glGenQueries( 1, &mObjectName );
|
||||
}
|
||||
|
||||
virtual ~AsynchronousQuery() {
|
||||
glDeleteQueries( 1, &mObjectName );
|
||||
}
|
||||
|
||||
//! start the query, only one query per type is allowed to be active at any time.
|
||||
void begin(void) {
|
||||
glBeginQuery( mTarget, mObjectName );
|
||||
}
|
||||
|
||||
//! end the query
|
||||
void end(void) {
|
||||
glEndQuery( mTarget );
|
||||
}
|
||||
|
||||
//! returns true if the result of the query is available, if not, trying to get the result will stall the CPU
|
||||
GLboolean isResultAvailable(void) {
|
||||
GLint resultAvailable;
|
||||
glGetQueryObjectiv(mObjectName, GL_QUERY_RESULT_AVAILABLE, &resultAvailable);
|
||||
return (GLboolean) resultAvailable;
|
||||
}
|
||||
|
||||
//! get the query result, what it is depents on the query target
|
||||
GLuint getResult(void) {
|
||||
GLuint queryResult;
|
||||
glGetQueryObjectuiv( mObjectName, GL_QUERY_RESULT, &queryResult );
|
||||
return queryResult;
|
||||
}
|
||||
|
||||
|
||||
//! get the query result in 64 bit, what it is depents on the query target
|
||||
GLuint64 getResult64(void) {
|
||||
#if (ACGL_OPENGL_VERSION >= 33)
|
||||
GLuint64 queryResult;
|
||||
glGetQueryObjectui64v( mObjectName, GL_QUERY_RESULT, &queryResult );
|
||||
return queryResult;
|
||||
#else
|
||||
return (GLuint64) getResult(); // default to 32 bit version on pre GL 3.3 systems
|
||||
#endif
|
||||
}
|
||||
|
||||
//! returns the raw object name to be used directly in OpenGL functions
|
||||
inline GLuint getObjectName(void) const { return mObjectName; }
|
||||
|
||||
protected:
|
||||
GLuint mObjectName;
|
||||
GLenum mTarget;
|
||||
};
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(AsynchronousQuery)
|
||||
|
||||
/**
|
||||
* Occlusion queries count the fragments that pass the z-test.
|
||||
*
|
||||
* There are two variants:
|
||||
* GL_SAMPLES_PASSED - will count the fragments
|
||||
* GL_ANY_SAMPLES_PASSED - will just tell whether fragments have passed the z-test, not how many (0 or any number)
|
||||
*/
|
||||
class OcclusionQuery : public AsynchronousQuery {
|
||||
public:
|
||||
OcclusionQuery() : AsynchronousQuery( GL_SAMPLES_PASSED ) {}
|
||||
OcclusionQuery( GLenum _queryType ) : AsynchronousQuery( _queryType ) {
|
||||
setType( _queryType );
|
||||
}
|
||||
|
||||
//! _queryType has to be GL_SAMPLES_PASSED or GL_ANY_SAMPLES_PASSED
|
||||
void setType( GLenum _queryType ) {
|
||||
#if (ACGL_OPENGL_VERSION >= 33)
|
||||
if (_queryType == GL_ANY_SAMPLES_PASSED) _queryType = GL_SAMPLES_PASSED; // GL_ANY_SAMPLES_PASSED is OpenGL 3.3 or later! But GL_SAMPLES_PASSED is a good substitute
|
||||
#endif
|
||||
if (_queryType != GL_SAMPLES_PASSED) {
|
||||
Utils::error() << "OcclusionQuery type " << _queryType << " not supported" << std::endl;
|
||||
_queryType = GL_SAMPLES_PASSED;
|
||||
}
|
||||
mTarget = _queryType;
|
||||
}
|
||||
|
||||
//! get the actual number of fragments, unless the type is GL_ANY_SAMPLES_PASSED, than it only tells 0 or any value
|
||||
GLuint samplesPassed(void) {
|
||||
return getResult();
|
||||
}
|
||||
};
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(OcclusionQuery)
|
||||
|
||||
|
||||
#if (ACGL_OPENGL_VERSION >= 33)
|
||||
/**
|
||||
* TimerQueries can get the GPU timestamp and measure GPU execution speed.
|
||||
*
|
||||
* Only available since OpenGL 3.3 or GL_ARB_timer_query (on OpenGL 3.2)
|
||||
*/
|
||||
class TimerQuery : public AsynchronousQuery {
|
||||
public:
|
||||
TimerQuery() : AsynchronousQuery( GL_TIME_ELAPSED ) {}
|
||||
|
||||
//! Mark the moment in the pipeline of which the time should get queried.
|
||||
void saveTimestamp(void) {
|
||||
glQueryCounter( mObjectName, GL_TIMESTAMP );
|
||||
}
|
||||
|
||||
//! Get the current GPU timestamp.
|
||||
GLint64 getCurrentTimestamp(void) {
|
||||
GLint64 time;
|
||||
glGetInteger64v( GL_TIMESTAMP, &time );
|
||||
return time;
|
||||
}
|
||||
|
||||
//! Get the timestamp saved by 'saveTimestamp'.
|
||||
GLuint64 getSavedTimestamp(void) {
|
||||
return getResult64();
|
||||
}
|
||||
};
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(TimerQuery)
|
||||
#endif // OpenGL >= 3.3
|
||||
|
||||
#if (ACGL_OPENGL_VERSION >= 31)
|
||||
/**
|
||||
* Primitive queries count the number of processed geometry. Sounds trivial as the app should
|
||||
* know the number from the glDraw* calls, but this query will also count geometry generated
|
||||
* by geometry/tessellation shaders.
|
||||
*
|
||||
* During transform feedback let one query of each type run and compare the results: if more
|
||||
* primitives were generated than written to the TF buffer, the buffer overflowd.
|
||||
*/
|
||||
class PrimitiveQuery : public AsynchronousQuery {
|
||||
public:
|
||||
PrimitiveQuery() : AsynchronousQuery( GL_PRIMITIVES_GENERATED ) {}
|
||||
PrimitiveQuery( GLenum _queryType ) : AsynchronousQuery( _queryType ) {
|
||||
setType( _queryType );
|
||||
}
|
||||
|
||||
//! _queryType has to be GL_PRIMITIVES_GENERATED or GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN
|
||||
void setType( GLenum _queryType ) {
|
||||
if ((_queryType != GL_PRIMITIVES_GENERATED) && (_queryType != GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN)) {
|
||||
Utils::error() << "PrimitiveQuery type " << _queryType << " not supported" << std::endl;
|
||||
_queryType = GL_PRIMITIVES_GENERATED;
|
||||
}
|
||||
mTarget = _queryType;
|
||||
}
|
||||
};
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(PrimitiveQuery)
|
||||
#endif // OpenGL >= 3.1
|
||||
|
||||
} // OpenGL
|
||||
} // ACGL
|
||||
|
||||
#endif // ES 2.0
|
||||
|
||||
#endif // ACGL_OPENGL_OBJECTS_QUERY_HH
|
124
extern/acgl/include/ACGL/OpenGL/Objects/RenderBuffer.hh
vendored
Normal file
124
extern/acgl/include/ACGL/OpenGL/Objects/RenderBuffer.hh
vendored
Normal file
@ -0,0 +1,124 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef ACGL_OPENGL_OBJECTS_RENDERBUFFER_HH
|
||||
#define ACGL_OPENGL_OBJECTS_RENDERBUFFER_HH
|
||||
|
||||
/**
|
||||
* An OpenGL RenderBuffer that can be used with FBOs.
|
||||
*
|
||||
* A RenderBuffer is an alternative to a texture as a render target if the later
|
||||
* usage as a texture is not needed (e.g. as a depth attachment if only the
|
||||
* color attachments are needed from the offscreen renderpass).
|
||||
*/
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
|
||||
#include <ACGL/Base/Macros.hh>
|
||||
#include <ACGL/OpenGL/GL.hh>
|
||||
#include <ACGL/OpenGL/Tools.hh>
|
||||
#include <ACGL/Math/Math.hh>
|
||||
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
class RenderBuffer
|
||||
{
|
||||
ACGL_NOT_COPYABLE(RenderBuffer)
|
||||
|
||||
// ========================================================================================================= \/
|
||||
// ============================================================================================ CONSTRUCTORS \/
|
||||
// ========================================================================================================= \/
|
||||
public:
|
||||
RenderBuffer(
|
||||
GLenum _internalFormat)
|
||||
: mObjectName(0),
|
||||
mInternalFormat(_internalFormat),
|
||||
mWidth(0),
|
||||
mHeight(0)
|
||||
{
|
||||
mObjectName = 0;
|
||||
glGenRenderbuffers(1, &mObjectName);
|
||||
}
|
||||
|
||||
virtual ~RenderBuffer(void)
|
||||
{
|
||||
// buffer 0 will get ignored by OpenGL
|
||||
glDeleteRenderbuffers(1, &mObjectName);
|
||||
}
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ GETTERS \/
|
||||
// ==================================================================================================== \/
|
||||
public:
|
||||
inline GLuint getObjectName (void) const { return mObjectName; }
|
||||
inline GLenum getInternalFormat (void) const { return mInternalFormat; }
|
||||
inline GLsizei getWidth (void) const { return mWidth; }
|
||||
inline GLsizei getHeight (void) const { return mHeight; }
|
||||
inline glm::uvec2 getSize (void) const { return glm::uvec2( mWidth, mHeight ); }
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ METHODS \/
|
||||
// ==================================================================================================== \/
|
||||
public:
|
||||
//! Get the actual number of samples
|
||||
#ifdef ACGL_OPENGL_ES
|
||||
inline int_t getSamples(void) const { return 1; }
|
||||
#else
|
||||
inline int_t getSamples(void) const
|
||||
{
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, mObjectName);
|
||||
GLint samples;
|
||||
glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_SAMPLES, &samples);
|
||||
return (int_t)samples;
|
||||
}
|
||||
#endif
|
||||
|
||||
// ===================================================================================================== \/
|
||||
// ============================================================================================ WRAPPERS \/
|
||||
// ===================================================================================================== \/
|
||||
public:
|
||||
//! Bind the renderbuffer
|
||||
inline void bind(void) const
|
||||
{
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, mObjectName);
|
||||
}
|
||||
|
||||
//! Set texture size and NULL data
|
||||
inline void setSize(
|
||||
GLsizei _width,
|
||||
GLsizei _height,
|
||||
GLsizei _samples = 0)
|
||||
{
|
||||
mWidth = _width;
|
||||
mHeight = _height;
|
||||
// the sample count will not get saved as the real samples returned by GL might differ this number anyway!
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, mObjectName);
|
||||
|
||||
#if (ACGL_OPENGL_VERSION >= 30)
|
||||
glRenderbufferStorageMultisample(GL_RENDERBUFFER, _samples, mInternalFormat, mWidth, mHeight);
|
||||
#else // OpenGL ES, as Desktop GL didn't have renderbuffers pre 3.0 anyway
|
||||
glRenderbufferStorage(GL_RENDERBUFFER, mInternalFormat, mWidth, mHeight);
|
||||
#endif // OpenGL >= 3.0
|
||||
|
||||
}
|
||||
|
||||
// =================================================================================================== \/
|
||||
// ============================================================================================ FIELDS \/
|
||||
// =================================================================================================== \/
|
||||
protected:
|
||||
GLuint mObjectName;
|
||||
GLenum mInternalFormat;
|
||||
GLsizei mWidth;
|
||||
GLsizei mHeight;
|
||||
};
|
||||
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(RenderBuffer)
|
||||
|
||||
} // OpenGL
|
||||
} // ACGL
|
||||
|
||||
#endif // ACGL_OPENGL_OBJECTS_RENDERBUFFER_HH
|
121
extern/acgl/include/ACGL/OpenGL/Objects/Sampler.hh
vendored
Normal file
121
extern/acgl/include/ACGL/OpenGL/Objects/Sampler.hh
vendored
Normal file
@ -0,0 +1,121 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef ACGL_OPENGL_OBJECTS_SAMPLER_HH
|
||||
#define ACGL_OPENGL_OBJECTS_SAMPLER_HH
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
|
||||
#include <ACGL/Base/Macros.hh>
|
||||
#include <ACGL/OpenGL/GL.hh>
|
||||
#include <ACGL/OpenGL/Tools.hh>
|
||||
|
||||
#include <ACGL/Math/Math.hh>
|
||||
|
||||
#if (ACGL_OPENGL_VERSION >= 33)
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
/**
|
||||
* OpenGL Sampler Objects (needs OpenGL 3.3)
|
||||
*
|
||||
* A Sampler holds information about how to sample in textures (bi-linear, anisotrophic, wrap modes etc).
|
||||
* Instead of setting these informations for each texture, a sampler object can be used and bound to
|
||||
* the texture units, this will overwrite the sampling information in the texture object itself.
|
||||
* This way, one texture can be bound to two texture units and two different samplers can be bound to those
|
||||
* units to provide different sampling behavior from the same texture in one shaderpass.
|
||||
* Similar, different textures can use the same sampler so only one object has to be changed if for example
|
||||
* the number of anisotrophic filter-samples should get changed (instead of changing all texture objects).
|
||||
*
|
||||
* All default parameters of the setters used to change the sampling behavior are the OpenGL defaults as well.
|
||||
*
|
||||
* If needed, getters could be added that query the settings from GL, so no caching is needed here (that might
|
||||
* be something for a derived class with larger memory footprint but faster access to the settings).
|
||||
*/
|
||||
|
||||
|
||||
class Sampler {
|
||||
ACGL_NOT_COPYABLE(Sampler)
|
||||
public:
|
||||
Sampler();
|
||||
~Sampler(void);
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ GETTERS \/
|
||||
// ==================================================================================================== \/
|
||||
public:
|
||||
inline GLuint getObjectName(void) const { return mObjectName; }
|
||||
|
||||
// ===================================================================================================== \/
|
||||
// ============================================================================================ WRAPPERS \/
|
||||
// ===================================================================================================== \/
|
||||
//! _textureUnit is in the range 0..n (not GL_TEXTURE0..GL_TEXTUREn)
|
||||
inline void bind(GLuint _textureUnit) const
|
||||
{
|
||||
glBindSampler( _textureUnit, mObjectName ); // yes, no adding of GL_TEXTURE0 !
|
||||
}
|
||||
|
||||
//! unbinds the texture sampler (if there is one bound) from _textureUnit
|
||||
inline static void unBind( GLuint _textureUnit ) { glBindSampler( _textureUnit, 0 ); }
|
||||
|
||||
//! generic parameter setting
|
||||
inline void parameter( GLenum _parameterName, GLint _parameter ) { glSamplerParameteri( mObjectName, _parameterName, _parameter ); }
|
||||
inline void parameter( GLenum _parameterName, GLfloat _parameter ) { glSamplerParameterf( mObjectName, _parameterName, _parameter ); }
|
||||
|
||||
inline void setBorderColor( glm::vec4 _color = glm::vec4(0.0f,0.0f,0.0f,0.0f) ) {
|
||||
glSamplerParameterfv( mObjectName, GL_TEXTURE_BORDER_COLOR, glm::value_ptr(_color) );
|
||||
}
|
||||
inline void setMinFilter(GLenum _value = GL_NEAREST_MIPMAP_LINEAR) { glSamplerParameteri( mObjectName, GL_TEXTURE_MIN_FILTER, _value); }
|
||||
inline void setMagFilter(GLenum _value = GL_LINEAR) { glSamplerParameteri( mObjectName, GL_TEXTURE_MAG_FILTER, _value); }
|
||||
|
||||
void setWrap( GLenum _wrapS );
|
||||
void setWrap( GLenum _wrapS, GLenum _wrapT );
|
||||
void setWrap( GLenum _wrapS, GLenum _wrapT, GLenum _wrapR );
|
||||
inline void setWrapS( GLenum _wrapS = GL_REPEAT ) { glSamplerParameteri( mObjectName, GL_TEXTURE_WRAP_S, _wrapS); }
|
||||
inline void setWrapT( GLenum _wrapT = GL_REPEAT ) { glSamplerParameteri( mObjectName, GL_TEXTURE_WRAP_T, _wrapT); }
|
||||
inline void setWrapR( GLenum _wrapR = GL_REPEAT ) { glSamplerParameteri( mObjectName, GL_TEXTURE_WRAP_R, _wrapR); }
|
||||
|
||||
inline void setMinLOD( GLint _lod = -1000 ) { glSamplerParameteri( mObjectName, GL_TEXTURE_MIN_LOD, _lod); }
|
||||
inline void setMaxLOD( GLint _lod = 1000 ) { glSamplerParameteri( mObjectName, GL_TEXTURE_MAX_LOD, _lod); }
|
||||
inline void setLODBias( GLfloat _bias = 0.0f ) { glSamplerParameterf( mObjectName, GL_TEXTURE_LOD_BIAS, _bias); }
|
||||
inline void setCompareMode( GLenum _mode = GL_NONE ) { glSamplerParameteri( mObjectName, GL_TEXTURE_COMPARE_MODE, _mode); }
|
||||
inline void setCompareFunc( GLenum _func = GL_LEQUAL ) { glSamplerParameteri( mObjectName, GL_TEXTURE_COMPARE_FUNC, _func); }
|
||||
|
||||
//! _sampleCount = 1.0 to deactivate anisotrop filtering, maximum is often 16. If a value is too high it will get clamped to the maximum
|
||||
void setMaxAnisotropy( GLfloat _sampleCount = 1.0f );
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
// getter
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
//! generic getter
|
||||
GLint getParameterI( GLenum _parameterName );
|
||||
GLfloat getParameterF( GLenum _parameterName );
|
||||
|
||||
GLenum getMinFilter() { return (GLenum) getParameterI( GL_TEXTURE_MIN_FILTER ); }
|
||||
GLenum getMagFilter() { return (GLenum) getParameterI( GL_TEXTURE_MAG_FILTER ); }
|
||||
GLenum getWrapS() { return (GLenum) getParameterI( GL_TEXTURE_WRAP_S ); }
|
||||
GLenum getWrapT() { return (GLenum) getParameterI( GL_TEXTURE_WRAP_T ); }
|
||||
GLenum getWrapR() { return (GLenum) getParameterI( GL_TEXTURE_WRAP_R ); }
|
||||
GLfloat getMinLOD() { return getParameterF( GL_TEXTURE_MIN_LOD ); }
|
||||
GLfloat getMaxLOD() { return getParameterF( GL_TEXTURE_MAX_LOD ); }
|
||||
GLfloat getLODBias() { return getParameterF( GL_TEXTURE_LOD_BIAS ); }
|
||||
GLint getCompareMode() { return getParameterI( GL_TEXTURE_COMPARE_MODE ); }
|
||||
GLint getCompareFunc() { return getParameterI( GL_TEXTURE_COMPARE_FUNC ); }
|
||||
|
||||
glm::vec4 getBorderColor();
|
||||
|
||||
private:
|
||||
GLuint mObjectName;
|
||||
};
|
||||
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(Sampler)
|
||||
|
||||
} // OpenGL
|
||||
} // ACGL
|
||||
|
||||
#endif // OpenGL >= 3.3
|
||||
|
||||
#endif // ACGL_OPENGL_OBJECTS_SAMPLER_HH
|
96
extern/acgl/include/ACGL/OpenGL/Objects/Shader.hh
vendored
Normal file
96
extern/acgl/include/ACGL/OpenGL/Objects/Shader.hh
vendored
Normal file
@ -0,0 +1,96 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef ACGL_OPENGL_OBJECTS_SHADER_HH
|
||||
#define ACGL_OPENGL_OBJECTS_SHADER_HH
|
||||
|
||||
/**
|
||||
* A Shader ist just one OpenGL shader like a fragment or vertex shader. To use these
|
||||
* a ShaderProgram is needed that links together multiple Shaders for the different
|
||||
* pipelinestages.
|
||||
*
|
||||
* So normally you want to work with ShaderPrograms instead of Shaders (switch Programs,
|
||||
* set uniforms etc).
|
||||
*
|
||||
* Custimizing shader parsing is done via custom ShaderParser classes, see Creator/ShaderParser.hh
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
|
||||
#include <ACGL/Base/Macros.hh>
|
||||
#include <ACGL/OpenGL/GL.hh>
|
||||
#include <ACGL/OpenGL/Tools.hh>
|
||||
#include <ACGL/OpenGL/Creator/ShaderParser.hh>
|
||||
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
class Shader
|
||||
{
|
||||
ACGL_NOT_COPYABLE(Shader)
|
||||
|
||||
// ========================================================================================================= \/
|
||||
// ============================================================================================ CONSTRUCTORS \/
|
||||
// ========================================================================================================= \/
|
||||
public:
|
||||
Shader(GLenum _type)
|
||||
: mObjectName(0),
|
||||
mType(_type)
|
||||
{
|
||||
mObjectName = glCreateShader(mType);
|
||||
if (mObjectName == 0) {
|
||||
ACGL::Utils::error() << "couldn't create Shader object! Requested type = " << (unsigned int) mType << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
virtual ~Shader(void)
|
||||
{
|
||||
// "DeleteShader will silently ignore the value zero." - GL Spec
|
||||
glDeleteShader(mObjectName);
|
||||
}
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ GETTERS \/
|
||||
// ==================================================================================================== \/
|
||||
public:
|
||||
inline GLuint getObjectName(void) const { return mObjectName; }
|
||||
inline GLenum getType (void) const { return mType; }
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ METHODS \/
|
||||
// ==================================================================================================== \/
|
||||
public:
|
||||
bool setFromFile (SharedShaderParser const& _sp);
|
||||
bool setSource (const std::string &_source, bool _checkForCompileErrors = true);
|
||||
bool setSources (const std::vector<std::string> &_sources, bool _checkForCompileErrors = true );
|
||||
|
||||
protected:
|
||||
// could get reactivated if needed, might get removed later (thus protected):
|
||||
bool setFromFileNoImportParsing(const std::string& _filename);
|
||||
|
||||
bool compile () const;
|
||||
// get a log and a bool whether the log contains an error (or just a warning), not done
|
||||
// automatically by compile() but called by all public source setting functions:
|
||||
void getCompileLog( std::string &_log, bool &_wasErrorLog ) const;
|
||||
|
||||
// =================================================================================================== \/
|
||||
// ============================================================================================ FIELDS \/
|
||||
// =================================================================================================== \/
|
||||
protected:
|
||||
GLuint mObjectName;
|
||||
GLenum mType;
|
||||
};
|
||||
|
||||
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(Shader)
|
||||
|
||||
} // OpenGL
|
||||
} // ACGL
|
||||
|
||||
#endif // ACGL_OPENGL_OBJECTS_SHADER_HH
|
373
extern/acgl/include/ACGL/OpenGL/Objects/ShaderProgram.hh
vendored
Normal file
373
extern/acgl/include/ACGL/OpenGL/Objects/ShaderProgram.hh
vendored
Normal file
@ -0,0 +1,373 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef ACGL_OPENGL_OBJECTS_SHADERPROGRAM_HH
|
||||
#define ACGL_OPENGL_OBJECTS_SHADERPROGRAM_HH
|
||||
|
||||
/**
|
||||
* A ShaderProgram is a wrapper around an OpenGL Program: A combination of Shaders
|
||||
* that are linked together to controll the programmable pipeline stages.
|
||||
*
|
||||
* A ShaderProgram is still quite low-level and just wraps the OpenGL object itself.
|
||||
*
|
||||
* One note on uniforms:
|
||||
* There are basically four ways to set uniform values here:
|
||||
*
|
||||
* setUniform( GLint _location, VALUE );
|
||||
* setUniform( std::string _location, VALUE );
|
||||
* setProgramUniform( GLint _location, VALUE );
|
||||
* setProgramUniform( std::string _location, VALUE );
|
||||
*
|
||||
* The versions with a std::string as a location are easy to use, just provide the name
|
||||
* the uniform is called in the shaderfile. But it will have to query the uniform location
|
||||
* each call and thus is inefficient! It would be faster to query the location once using
|
||||
* getUniformLocation( std::string ); and use the returned value in combination with the
|
||||
* set*Uniform( GLint, ...) versions.
|
||||
*
|
||||
* Both are provided as setUniform and setProgramUniform:
|
||||
* In order for setUniform(...) to work as intendet the ShaderProgram has to be active ( use() ),
|
||||
* setProgramUniform(...) does not have this limitation and is based on direct state access
|
||||
* (via an extension or a basic simulation of the extension).
|
||||
* Use setProgramUniform if you can't know which program is in use right now, setUniform should
|
||||
* be prefered for performance critical parts of your app.
|
||||
*
|
||||
* In short: setProgramUniform( std::string _location, VALUE ); is the most error proof option
|
||||
* and good for testing out new stuff
|
||||
* setUniform( GLint _location, VALUE ); is best for performance critical code thats
|
||||
* well tested
|
||||
*
|
||||
*/
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
|
||||
#include <ACGL/Base/Macros.hh>
|
||||
#include <ACGL/OpenGL/GL.hh>
|
||||
#include <ACGL/OpenGL/Objects/Shader.hh>
|
||||
#include <ACGL/OpenGL/Objects/Texture.hh>
|
||||
#include <ACGL/OpenGL/Data/LocationMappings.hh>
|
||||
#include <ACGL/Math/Math.hh>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
class ShaderProgram
|
||||
{
|
||||
ACGL_NOT_COPYABLE(ShaderProgram)
|
||||
|
||||
// ===================================================================================================== \/
|
||||
// ============================================================================================ TYPEDEFS \/
|
||||
// ===================================================================================================== \/
|
||||
public:
|
||||
typedef std::vector< ConstSharedShader > ConstSharedShaderVec;
|
||||
|
||||
// ========================================================================================================= \/
|
||||
// ============================================================================================ CONSTRUCTORS \/
|
||||
// ========================================================================================================= \/
|
||||
public:
|
||||
ShaderProgram(void)
|
||||
: mObjectName(0),
|
||||
mShaders()
|
||||
{
|
||||
mObjectName = glCreateProgram();
|
||||
}
|
||||
|
||||
virtual ~ShaderProgram(void)
|
||||
{
|
||||
// "DeleteProgram will silently ignore the value zero." - GL Spec
|
||||
glDeleteProgram(mObjectName);
|
||||
}
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ GETTERS \/
|
||||
// ==================================================================================================== \/
|
||||
public:
|
||||
inline GLuint getObjectName(void) const { return mObjectName; }
|
||||
inline const ConstSharedShaderVec& getShaders (void) const { return mShaders; }
|
||||
|
||||
// ===================================================================================================== \/
|
||||
// ============================================================================================ WRAPPERS \/
|
||||
// ===================================================================================================== \/
|
||||
public:
|
||||
//! use, or activate it for rendering, also needed to set uniforms:
|
||||
inline void use(void) const { glUseProgram(mObjectName); }
|
||||
|
||||
//! attach a single shader, don't forget to relink!
|
||||
inline void attachShader(const ConstSharedShader& _shader)
|
||||
{
|
||||
mShaders.push_back(_shader);
|
||||
glAttachShader( mObjectName, _shader->getObjectName() );
|
||||
}
|
||||
|
||||
//! link the program, has to be redone after changing input or output locations:
|
||||
bool link (void) const;
|
||||
|
||||
#if (ACGL_OPENGL_VERSION >= 41)
|
||||
//! set the program separable to be used in a program pipeline object
|
||||
inline bool setSeparable( GLboolean _b = GL_TRUE ) {
|
||||
glProgramParameteri( mObjectName, GL_PROGRAM_SEPARABLE, _b );
|
||||
return link();
|
||||
}
|
||||
#endif
|
||||
|
||||
// ===================================================================================================== \/
|
||||
// =========================================================================================== LOCATIONS \/
|
||||
// ===================================================================================================== \/
|
||||
public:
|
||||
//////////// uniform (block) locations:
|
||||
inline GLint getUniformLocation (const std::string& _nameInShader) const { return glGetUniformLocation (mObjectName, _nameInShader.c_str()); }
|
||||
|
||||
#if (ACGL_OPENGL_VERSION >= 31)
|
||||
//! if the block name does not exist, GL_INVALID_INDEX will get returned
|
||||
inline GLuint getUniformBlockIndex (const std::string& _nameInShader) const { return glGetUniformBlockIndex(mObjectName, _nameInShader.c_str()); }
|
||||
|
||||
//! binds a uniform block, the string version will ignore a non-existent block
|
||||
inline void setUniformBlockBinding( GLuint _blockIndex, GLuint _bindingPoint ) const { glUniformBlockBinding( mObjectName, _blockIndex, _bindingPoint ); openGLCommonError(); }
|
||||
inline void setUniformBlockBinding( const std::string& _blockName, GLuint _bindingPoint ) const {
|
||||
GLuint blockIndex = getUniformBlockIndex(_blockName);
|
||||
if (blockIndex != GL_INVALID_INDEX) glUniformBlockBinding( mObjectName, blockIndex, _bindingPoint );
|
||||
}
|
||||
|
||||
GLint getUniformBlockBinding( const std::string& _blockName ) const { return getUniformBlockBinding( getUniformBlockIndex(_blockName)); }
|
||||
GLint getUniformBlockBinding( GLuint _blockIndex ) const {
|
||||
GLint bindingPoint;
|
||||
glGetActiveUniformBlockiv( mObjectName, _blockIndex, GL_UNIFORM_BLOCK_BINDING, &bindingPoint );
|
||||
return bindingPoint;
|
||||
}
|
||||
|
||||
//! returns a mapping from the uniforms in a given block to the offset within the block
|
||||
SharedLocationMappings getUniformOffsetsOfBlock( const std::string &_blockName ) const { return getUniformOffsetsOfBlock(getUniformBlockIndex(_blockName)); }
|
||||
SharedLocationMappings getUniformOffsetsOfBlock( GLuint _blockIndex ) const;
|
||||
|
||||
//! returns the size in bytes of the uniform block, can be used to allocate the right amount of memory
|
||||
GLsizeiptr getUniformBlockSize( const std::string &_blockName ) const { return getUniformBlockSize(getUniformBlockIndex(_blockName)); }
|
||||
GLsizeiptr getUniformBlockSize( GLuint _blockIndex ) const ;
|
||||
|
||||
#endif // OpenGL >= 3.1
|
||||
|
||||
//////////// attribute locations:
|
||||
inline GLint getAttributeLocation (const std::string& _nameInShader) const { return glGetAttribLocation (mObjectName, _nameInShader.c_str()); }
|
||||
inline void bindAttributeLocation (const std::string& _nameInShader, GLuint _location) const { glBindAttribLocation (mObjectName, _location, _nameInShader.c_str()); }
|
||||
|
||||
//! Sets the attribute locations of this ShaderProgram according to the mappings specified in _locationMappings
|
||||
void setAttributeLocations( ConstSharedLocationMappings _locationMappings );
|
||||
//! Get all attribute names with there locations:
|
||||
SharedLocationMappings getAttributeLocations() const;
|
||||
|
||||
//////////// fragdata locations:
|
||||
#if (ACGL_OPENGL_VERSION >= 30)
|
||||
//! if the location does not exist, -1 will get returned
|
||||
inline GLint getFragmentDataLocation (const std::string& _nameInShader) const { return glGetFragDataLocation(mObjectName, _nameInShader.c_str()); }
|
||||
inline void bindFragmentDataLocation (const std::string& _nameInShader, GLuint _location) const { glBindFragDataLocation (mObjectName, _location, _nameInShader.c_str()); }
|
||||
|
||||
//! Sets the fragment data locations of this ShaderProgram according to the mappings specified in
|
||||
void setFragmentDataLocations( ConstSharedLocationMappings _locationMappings );
|
||||
//! Get all fragdata names with there locations:
|
||||
SharedLocationMappings getFragmentDataLocations();
|
||||
#endif // OpenGL >= 3.0
|
||||
|
||||
// ===================================================================================================== \/
|
||||
// ============================================================================================ UNIFORMS \/
|
||||
// ===================================================================================================== \/
|
||||
public:
|
||||
// int by location
|
||||
inline void setUniform (GLint _location, GLint _v) const { glUniform1i (_location, _v); }
|
||||
inline void setUniform (GLint _location, GLsizei _n, GLint *_v)const { glUniform1iv(_location, _n, _v); }
|
||||
inline void setUniform (GLint _location, const glm::ivec2& _v) const { glUniform2iv(_location, 1, glm::value_ptr(_v)); }
|
||||
inline void setUniform (GLint _location, const glm::ivec3& _v) const { glUniform3iv(_location, 1, glm::value_ptr(_v)); }
|
||||
inline void setUniform (GLint _location, const glm::ivec4& _v) const { glUniform4iv(_location, 1, glm::value_ptr(_v)); }
|
||||
|
||||
#if (ACGL_OPENGL_VERSION >= 30)
|
||||
// unsigned int by location
|
||||
inline void setUniform (GLint _location, GLuint _v) const { glUniform1ui (_location, _v); }
|
||||
inline void setUniform (GLint _location, GLsizei _n, GLuint*_v)const { glUniform1uiv(_location, _n, _v); }
|
||||
inline void setUniform (GLint _location, const glm::uvec2& _v) const { glUniform2uiv(_location, 1, glm::value_ptr(_v)); }
|
||||
inline void setUniform (GLint _location, const glm::uvec3& _v) const { glUniform3uiv(_location, 1, glm::value_ptr(_v)); }
|
||||
inline void setUniform (GLint _location, const glm::uvec4& _v) const { glUniform4uiv(_location, 1, glm::value_ptr(_v)); }
|
||||
|
||||
#endif // OpenGL >= 3.0
|
||||
|
||||
// float by location
|
||||
inline void setUniform (GLint _location, GLfloat _v) const { glUniform1f (_location, _v); }
|
||||
inline void setUniform (GLint _location, GLsizei _n, GLfloat*_v)const{ glUniform1fv(_location, _n, _v); }
|
||||
inline void setUniform (GLint _location, const glm::vec2& _v) const { glUniform2fv(_location, 1, glm::value_ptr(_v)); }
|
||||
inline void setUniform (GLint _location, const glm::vec3& _v) const { glUniform3fv(_location, 1, glm::value_ptr(_v)); }
|
||||
inline void setUniform (GLint _location, const glm::vec4& _v) const { glUniform4fv(_location, 1, glm::value_ptr(_v)); }
|
||||
#if (ACGL_OPENGL_VERSION >= 40)
|
||||
|
||||
// double by location
|
||||
inline void setUniform (GLint _location, GLdouble _v) const { glUniform1d (_location, _v); }
|
||||
inline void setUniform (GLint _location, GLsizei _n, GLdouble*_v)const{ glUniform1dv(_location, _n, _v); }
|
||||
inline void setUniform (GLint _location, const glm::dvec2& _v) const { glUniform2dv(_location, 1, glm::value_ptr(_v)); }
|
||||
inline void setUniform (GLint _location, const glm::dvec3& _v) const { glUniform3dv(_location, 1, glm::value_ptr(_v)); }
|
||||
inline void setUniform (GLint _location, const glm::dvec4& _v) const { glUniform4dv(_location, 1, glm::value_ptr(_v)); }
|
||||
#endif // OpenGL >= 4.0
|
||||
|
||||
// float matrix by location
|
||||
#ifndef ACGL_OPENGLES_VERSION_20
|
||||
// ES 2 only has square matrices, so omit these:
|
||||
inline void setUniform (GLint _location, const glm::mat2x3& _v, GLboolean _transpose = GL_FALSE) const { glUniformMatrix2x3fv(_location, 1, _transpose, glm::value_ptr(_v)); }
|
||||
inline void setUniform (GLint _location, const glm::mat2x4& _v, GLboolean _transpose = GL_FALSE) const { glUniformMatrix2x4fv(_location, 1, _transpose, glm::value_ptr(_v)); }
|
||||
inline void setUniform (GLint _location, const glm::mat3x2& _v, GLboolean _transpose = GL_FALSE) const { glUniformMatrix3x2fv(_location, 1, _transpose, glm::value_ptr(_v)); }
|
||||
inline void setUniform (GLint _location, const glm::mat3x4& _v, GLboolean _transpose = GL_FALSE) const { glUniformMatrix3x4fv(_location, 1, _transpose, glm::value_ptr(_v)); }
|
||||
inline void setUniform (GLint _location, const glm::mat4x2& _v, GLboolean _transpose = GL_FALSE) const { glUniformMatrix4x2fv(_location, 1, _transpose, glm::value_ptr(_v)); }
|
||||
inline void setUniform (GLint _location, const glm::mat4x3& _v, GLboolean _transpose = GL_FALSE) const { glUniformMatrix4x3fv(_location, 1, _transpose, glm::value_ptr(_v)); }
|
||||
#endif
|
||||
inline void setUniform (GLint _location, const glm::mat2& _v, GLboolean _transpose = GL_FALSE) const { glUniformMatrix2fv (_location, 1, _transpose, glm::value_ptr(_v)); }
|
||||
inline void setUniform (GLint _location, const glm::mat3& _v, GLboolean _transpose = GL_FALSE) const { glUniformMatrix3fv (_location, 1, _transpose, glm::value_ptr(_v)); }
|
||||
inline void setUniform (GLint _location, const glm::mat4& _v, GLboolean _transpose = GL_FALSE) const { glUniformMatrix4fv (_location, 1, _transpose, glm::value_ptr(_v)); }
|
||||
|
||||
// float matrix array by location
|
||||
#ifndef ACGL_OPENGLES_VERSION_20
|
||||
// ES 2 only has square matrices, so omit these:
|
||||
inline void setUniform (GLint _location, const glm::mat2x3* _v, GLsizei _n, GLboolean _transpose = GL_FALSE) const { glUniformMatrix2x3fv(_location, _n, _transpose, glm::value_ptr(*_v)); }
|
||||
inline void setUniform (GLint _location, const glm::mat2x4* _v, GLsizei _n, GLboolean _transpose = GL_FALSE) const { glUniformMatrix2x4fv(_location, _n, _transpose, glm::value_ptr(*_v)); }
|
||||
inline void setUniform (GLint _location, const glm::mat3x2* _v, GLsizei _n, GLboolean _transpose = GL_FALSE) const { glUniformMatrix3x2fv(_location, _n, _transpose, glm::value_ptr(*_v)); }
|
||||
inline void setUniform (GLint _location, const glm::mat3x4* _v, GLsizei _n, GLboolean _transpose = GL_FALSE) const { glUniformMatrix3x4fv(_location, _n, _transpose, glm::value_ptr(*_v)); }
|
||||
inline void setUniform (GLint _location, const glm::mat4x2* _v, GLsizei _n, GLboolean _transpose = GL_FALSE) const { glUniformMatrix4x2fv(_location, _n, _transpose, glm::value_ptr(*_v)); }
|
||||
inline void setUniform (GLint _location, const glm::mat4x3* _v, GLsizei _n, GLboolean _transpose = GL_FALSE) const { glUniformMatrix4x3fv(_location, _n, _transpose, glm::value_ptr(*_v)); }
|
||||
#endif
|
||||
inline void setUniform (GLint _location, const glm::mat2* _v, GLsizei _n, GLboolean _transpose = GL_FALSE) const { glUniformMatrix2fv (_location, _n, _transpose, glm::value_ptr(*_v)); }
|
||||
inline void setUniform (GLint _location, const glm::mat3* _v, GLsizei _n, GLboolean _transpose = GL_FALSE) const { glUniformMatrix3fv (_location, _n, _transpose, glm::value_ptr(*_v)); }
|
||||
inline void setUniform (GLint _location, const glm::mat4* _v, GLsizei _n, GLboolean _transpose = GL_FALSE) const { glUniformMatrix4fv (_location, _n, _transpose, glm::value_ptr(*_v)); }
|
||||
|
||||
#if (ACGL_OPENGL_VERSION >= 40)
|
||||
// double matrix by location
|
||||
inline void setUniform (GLint _location, const glm::dmat2& _v, GLboolean _transpose = GL_FALSE) const { glUniformMatrix2dv(_location, 1, _transpose, glm::value_ptr(_v)); }
|
||||
inline void setUniform (GLint _location, const glm::dmat2x3& _v, GLboolean _transpose = GL_FALSE) const { glUniformMatrix2x3dv(_location, 1, _transpose, glm::value_ptr(_v)); }
|
||||
inline void setUniform (GLint _location, const glm::dmat2x4& _v, GLboolean _transpose = GL_FALSE) const { glUniformMatrix2x4dv(_location, 1, _transpose, glm::value_ptr(_v)); }
|
||||
inline void setUniform (GLint _location, const glm::dmat3x2& _v, GLboolean _transpose = GL_FALSE) const { glUniformMatrix3x2dv(_location, 1, _transpose, glm::value_ptr(_v)); }
|
||||
inline void setUniform (GLint _location, const glm::dmat3& _v, GLboolean _transpose = GL_FALSE) const { glUniformMatrix3dv (_location, 1, _transpose, glm::value_ptr(_v)); }
|
||||
inline void setUniform (GLint _location, const glm::dmat3x4& _v, GLboolean _transpose = GL_FALSE) const { glUniformMatrix3x4dv(_location, 1, _transpose, glm::value_ptr(_v)); }
|
||||
inline void setUniform (GLint _location, const glm::dmat4x2& _v, GLboolean _transpose = GL_FALSE) const { glUniformMatrix4x2dv(_location, 1, _transpose, glm::value_ptr(_v)); }
|
||||
inline void setUniform (GLint _location, const glm::dmat4x3& _v, GLboolean _transpose = GL_FALSE) const { glUniformMatrix4x3dv(_location, 1, _transpose, glm::value_ptr(_v)); }
|
||||
inline void setUniform (GLint _location, const glm::dmat4& _v, GLboolean _transpose = GL_FALSE) const { glUniformMatrix4dv (_location, 1, _transpose, glm::value_ptr(_v)); }
|
||||
#endif // OpenGL >= 4.0
|
||||
|
||||
//! sets a texture uniform to a given texture unit and also binds the texture to the same unit
|
||||
inline void setTexture (GLint _location, const ConstSharedTextureBase& _texture, GLint _unit) const { glUniform1i(_location, _unit); _texture->bind(_unit); }
|
||||
inline void setTexture (const std::string& _nameInShader, const ConstSharedTextureBase& _texture, GLint _unit) const { setUniform( getUniformLocation(_nameInShader), (GLint) _unit); _texture->bind(_unit); }
|
||||
|
||||
#if (ACGL_OPENGL_VERSION >= 41)
|
||||
// DSA versions:
|
||||
|
||||
// int DSA by location
|
||||
inline void setProgramUniform (GLint _location, GLint _v) const { glProgramUniform1i (mObjectName, _location, _v); }
|
||||
inline void setProgramUniform (GLint _location, GLsizei _n, GLint *_v)const { glProgramUniform1iv(mObjectName, _location, _n, _v); }
|
||||
inline void setProgramUniform (GLint _location, const glm::ivec2& _v) const { glProgramUniform2iv(mObjectName, _location, 1, glm::value_ptr(_v)); }
|
||||
inline void setProgramUniform (GLint _location, const glm::ivec3& _v) const { glProgramUniform3iv(mObjectName, _location, 1, glm::value_ptr(_v)); }
|
||||
inline void setProgramUniform (GLint _location, const glm::ivec4& _v) const { glProgramUniform4iv(mObjectName, _location, 1, glm::value_ptr(_v)); }
|
||||
|
||||
// unsigned int DSA by location
|
||||
inline void setProgramUniform (GLint _location, GLuint _v) const { glProgramUniform1ui (mObjectName, _location, _v); }
|
||||
inline void setProgramUniform (GLint _location, GLsizei _n, GLuint*_v)const { glProgramUniform1uiv(mObjectName, _location, _n, _v); }
|
||||
inline void setProgramUniform (GLint _location, const glm::uvec2& _v) const { glProgramUniform2uiv(mObjectName, _location, 1, glm::value_ptr(_v)); }
|
||||
inline void setProgramUniform (GLint _location, const glm::uvec3& _v) const { glProgramUniform3uiv(mObjectName, _location, 1, glm::value_ptr(_v)); }
|
||||
inline void setProgramUniform (GLint _location, const glm::uvec4& _v) const { glProgramUniform4uiv(mObjectName, _location, 1, glm::value_ptr(_v)); }
|
||||
|
||||
// float DSA by location
|
||||
inline void setProgramUniform (GLint _location, GLfloat _v) const { glProgramUniform1f (mObjectName, _location, _v); }
|
||||
inline void setProgramUniform (GLint _location, GLsizei _n, GLfloat*_v)const{ glProgramUniform1fv(mObjectName, _location, _n, _v); }
|
||||
inline void setProgramUniform (GLint _location, const glm::vec2& _v) const { glProgramUniform2fv(mObjectName, _location, 1, glm::value_ptr(_v)); }
|
||||
inline void setProgramUniform (GLint _location, const glm::vec3& _v) const { glProgramUniform3fv(mObjectName, _location, 1, glm::value_ptr(_v)); }
|
||||
inline void setProgramUniform (GLint _location, const glm::vec4& _v) const { glProgramUniform4fv(mObjectName, _location, 1, glm::value_ptr(_v)); }
|
||||
|
||||
// double DSA by location
|
||||
inline void setProgramUniform (GLint _location, GLdouble _v) const { glProgramUniform1d (mObjectName, _location, _v); }
|
||||
inline void setProgramUniform (GLint _location, GLsizei _n, GLdouble*_v)const{glProgramUniform1dv(mObjectName, _location, _n, _v); }
|
||||
inline void setProgramUniform (GLint _location, const glm::dvec2& _v) const { glProgramUniform2dv(mObjectName, _location, 1, glm::value_ptr(_v)); }
|
||||
inline void setProgramUniform (GLint _location, const glm::dvec3& _v) const { glProgramUniform3dv(mObjectName, _location, 1, glm::value_ptr(_v)); }
|
||||
inline void setProgramUniform (GLint _location, const glm::dvec4& _v) const { glProgramUniform4dv(mObjectName, _location, 1, glm::value_ptr(_v)); }
|
||||
|
||||
// float matrix DSA by location
|
||||
inline void setProgramUniform (GLint _location, const glm::mat2& _v, GLboolean _transpose = GL_FALSE) const { glProgramUniformMatrix2fv (mObjectName, _location, 1, _transpose, glm::value_ptr(_v)); }
|
||||
inline void setProgramUniform (GLint _location, const glm::mat2x3& _v, GLboolean _transpose = GL_FALSE) const { glProgramUniformMatrix2x3fv(mObjectName, _location, 1, _transpose, glm::value_ptr(_v)); }
|
||||
inline void setProgramUniform (GLint _location, const glm::mat2x4& _v, GLboolean _transpose = GL_FALSE) const { glProgramUniformMatrix2x4fv(mObjectName, _location, 1, _transpose, glm::value_ptr(_v)); }
|
||||
inline void setProgramUniform (GLint _location, const glm::mat3x2& _v, GLboolean _transpose = GL_FALSE) const { glProgramUniformMatrix3x2fv(mObjectName, _location, 1, _transpose, glm::value_ptr(_v)); }
|
||||
inline void setProgramUniform (GLint _location, const glm::mat3& _v, GLboolean _transpose = GL_FALSE) const { glProgramUniformMatrix3fv (mObjectName, _location, 1, _transpose, glm::value_ptr(_v)); }
|
||||
inline void setProgramUniform (GLint _location, const glm::mat3x4& _v, GLboolean _transpose = GL_FALSE) const { glProgramUniformMatrix3x4fv(mObjectName, _location, 1, _transpose, glm::value_ptr(_v)); }
|
||||
inline void setProgramUniform (GLint _location, const glm::mat4x2& _v, GLboolean _transpose = GL_FALSE) const { glProgramUniformMatrix4x2fv(mObjectName, _location, 1, _transpose, glm::value_ptr(_v)); }
|
||||
inline void setProgramUniform (GLint _location, const glm::mat4x3& _v, GLboolean _transpose = GL_FALSE) const { glProgramUniformMatrix4x3fv(mObjectName, _location, 1, _transpose, glm::value_ptr(_v)); }
|
||||
inline void setProgramUniform (GLint _location, const glm::mat4& _v, GLboolean _transpose = GL_FALSE) const { glProgramUniformMatrix4fv (mObjectName, _location, 1, _transpose, glm::value_ptr(_v)); }
|
||||
|
||||
|
||||
// double matrix DSA by location
|
||||
inline void setProgramUniform (GLint _location, const glm::dmat2& _v, GLboolean _transpose = GL_FALSE) const { glProgramUniformMatrix2dv (mObjectName, _location, 1, _transpose, glm::value_ptr(_v)); }
|
||||
inline void setProgramUniform (GLint _location, const glm::dmat2x3& _v, GLboolean _transpose = GL_FALSE) const { glProgramUniformMatrix2x3dv(mObjectName, _location, 1, _transpose, glm::value_ptr(_v)); }
|
||||
inline void setProgramUniform (GLint _location, const glm::dmat2x4& _v, GLboolean _transpose = GL_FALSE) const { glProgramUniformMatrix2x4dv(mObjectName, _location, 1, _transpose, glm::value_ptr(_v)); }
|
||||
inline void setProgramUniform (GLint _location, const glm::dmat3x2& _v, GLboolean _transpose = GL_FALSE) const { glProgramUniformMatrix3x2dv(mObjectName, _location, 1, _transpose, glm::value_ptr(_v)); }
|
||||
inline void setProgramUniform (GLint _location, const glm::dmat3& _v, GLboolean _transpose = GL_FALSE) const { glProgramUniformMatrix3dv (mObjectName, _location, 1, _transpose, glm::value_ptr(_v)); }
|
||||
inline void setProgramUniform (GLint _location, const glm::dmat3x4& _v, GLboolean _transpose = GL_FALSE) const { glProgramUniformMatrix3x4dv(mObjectName, _location, 1, _transpose, glm::value_ptr(_v)); }
|
||||
inline void setProgramUniform (GLint _location, const glm::dmat4x2& _v, GLboolean _transpose = GL_FALSE) const { glProgramUniformMatrix4x2dv(mObjectName, _location, 1, _transpose, glm::value_ptr(_v)); }
|
||||
inline void setProgramUniform (GLint _location, const glm::dmat4x3& _v, GLboolean _transpose = GL_FALSE) const { glProgramUniformMatrix4x3dv(mObjectName, _location, 1, _transpose, glm::value_ptr(_v)); }
|
||||
inline void setProgramUniform (GLint _location, const glm::dmat4& _v, GLboolean _transpose = GL_FALSE) const { glProgramUniformMatrix4dv (mObjectName, _location, 1, _transpose, glm::value_ptr(_v)); }
|
||||
|
||||
inline void setProgramTexture (GLint _location, const ConstSharedTextureBase& _texture, GLint _unit) const { glProgramUniform1i(mObjectName, _location, _unit); _texture->bind(_unit); }
|
||||
inline void setProgramTexture (const std::string& _nameInShader, const ConstSharedTextureBase& _texture, GLint _unit) const { setProgramUniform( getUniformLocation(_nameInShader), (GLint) _unit); _texture->bind(_unit); }
|
||||
|
||||
#endif
|
||||
|
||||
// ======================================================================================================= \/
|
||||
// ============================================================================================ HIGH LEVEL \/
|
||||
// ======================================================================================================= \/
|
||||
public:
|
||||
// normal:
|
||||
template <typename T>
|
||||
inline void setUniform (const std::string& _nameInShader, T _v) const
|
||||
{
|
||||
setUniform( getUniformLocation(_nameInShader), _v);
|
||||
}
|
||||
|
||||
// DSA:
|
||||
template <typename T>
|
||||
inline void setProgramUniform (const std::string& _nameInShader, T _v) const
|
||||
{
|
||||
setProgramUniform( getUniformLocation(_nameInShader), _v);
|
||||
}
|
||||
|
||||
// normal for arrays:
|
||||
template <typename T>
|
||||
inline void setUniform (const std::string& _nameInShader, GLsizei _n, T _v) const
|
||||
{
|
||||
setUniform( getUniformLocation(_nameInShader), _n, _v);
|
||||
}
|
||||
|
||||
// DSA for arrays:
|
||||
template <typename T>
|
||||
inline void setProgramUniform (const std::string& _nameInShader, GLsizei _n, T _v) const
|
||||
{
|
||||
setProgramUniform( getUniformLocation(_nameInShader), _n, _v);
|
||||
}
|
||||
|
||||
// normal for matrices with additional transpose parameter
|
||||
template <typename T>
|
||||
inline void setUniform (const std::string& _nameInShader, T _v, GLboolean _transpose) const
|
||||
{
|
||||
setUniform( getUniformLocation(_nameInShader), _v, _transpose);
|
||||
}
|
||||
|
||||
// DSA for matrices with additional transpose parameter
|
||||
template <typename T>
|
||||
inline void setProgramUniform (const std::string& _nameInShader, T _v, GLboolean _transpose) const
|
||||
{
|
||||
setProgramUniform( getUniformLocation(_nameInShader), _v, _transpose);
|
||||
}
|
||||
|
||||
// =================================================================================================== \/
|
||||
// ============================================================================================ FIELDS \/
|
||||
// =================================================================================================== \/
|
||||
protected:
|
||||
GLuint mObjectName;
|
||||
ConstSharedShaderVec mShaders;
|
||||
};
|
||||
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(ShaderProgram)
|
||||
|
||||
} // OpenGL
|
||||
} // ACGL
|
||||
|
||||
#endif // ACGL_OPENGL_OBJECTS_SHADERPROGRAM_HH
|
456
extern/acgl/include/ACGL/OpenGL/Objects/Texture.hh
vendored
Normal file
456
extern/acgl/include/ACGL/OpenGL/Objects/Texture.hh
vendored
Normal file
@ -0,0 +1,456 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef ACGL_OPENGL_OBJECTS_TEXTURE_HH
|
||||
#define ACGL_OPENGL_OBJECTS_TEXTURE_HH
|
||||
|
||||
/**
|
||||
* A Texture wrapps the OpenGL texture. To fill these with data from image files a
|
||||
* matching TextureControllerFile* is needed.
|
||||
*/
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
|
||||
#include <ACGL/Base/Macros.hh>
|
||||
#include <ACGL/OpenGL/GL.hh>
|
||||
#include <ACGL/OpenGL/Tools.hh>
|
||||
#include <ACGL/OpenGL/Data/TextureData.hh>
|
||||
#include <ACGL/Math/Math.hh>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
// the combination of Image and SharedTextureBase will identify a Rendertarget etc.:
|
||||
struct Image {
|
||||
Image() : mipmapLevel(0), layer(0), cubeMapFace(GL_INVALID_ENUM) {}
|
||||
unsigned int mipmapLevel; // always 0 if texture has no mipmaps
|
||||
unsigned int layer; // array layer or slice in a 3D texture, always 0 if texture is 1D or 2D
|
||||
GLenum cubeMapFace; // GL_INVALID_ENUM if texture is not a cube map
|
||||
};
|
||||
|
||||
/**
|
||||
* A Texture consists of:
|
||||
* 1. 1..N Images (e.g. mipmap layers)
|
||||
* 2. an internal data format (datatype and number of channels on the GPU)
|
||||
* 3. a sampling mode (alternatively a sampler object can be used)
|
||||
*
|
||||
* The TextureBase class holds the methods to define 2 & 3, the Images (incl. getter and setter)
|
||||
* vary between different texture types, so subclasses will take care if that.
|
||||
*
|
||||
* Every subclass of TextureBase has:
|
||||
* A constructor which defines the internal format (data layout in GPU memory)
|
||||
(this can't be changed later)
|
||||
* A constructor that reserves memory for a certain texture size.
|
||||
* A setImageData with a SharedTextureData and optinally additional parameters
|
||||
about which layer/mipmap-level/slice etc. should be set
|
||||
|
||||
* Some might also have:
|
||||
* A resize function which differs in the dimensionality from subclass to subclass.
|
||||
*/
|
||||
class TextureBase
|
||||
{
|
||||
ACGL_NOT_COPYABLE(TextureBase)
|
||||
|
||||
// ========================================================================================================= \/
|
||||
// ============================================================================================ CONSTRUCTORS \/
|
||||
// ========================================================================================================= \/
|
||||
public:
|
||||
//!
|
||||
/*!
|
||||
Default texture parameters taken from: http://www.opengl.org/sdk/docs/man/xhtml/glTexParameter.xml
|
||||
*/
|
||||
TextureBase(GLenum _target)
|
||||
: mObjectName(0),
|
||||
mTarget(_target),
|
||||
mWidth(0),
|
||||
mHeight(1),
|
||||
mDepth(1),
|
||||
mInternalFormat(GL_RGBA)
|
||||
{
|
||||
glGenTextures(1, &mObjectName);
|
||||
}
|
||||
|
||||
TextureBase(GLenum _target, GLenum _internalFormat)
|
||||
: mObjectName(0),
|
||||
mTarget(_target),
|
||||
mWidth(0),
|
||||
mHeight(1),
|
||||
mDepth(1),
|
||||
mInternalFormat(_internalFormat)
|
||||
{
|
||||
glGenTextures(1, &mObjectName);
|
||||
}
|
||||
|
||||
virtual ~TextureBase(void)
|
||||
{
|
||||
// object name 0 will get ignored by OpenGL
|
||||
glDeleteTextures(1, &mObjectName);
|
||||
}
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ GETTERS \/
|
||||
// ==================================================================================================== \/
|
||||
public:
|
||||
inline GLuint getObjectName (void) const { return mObjectName; }
|
||||
inline GLenum getTarget (void) const { return mTarget; }
|
||||
inline GLsizei getWidth (void) const { return mWidth; }
|
||||
inline GLsizei getHeight (void) const { return mHeight; }
|
||||
inline GLsizei getDepth (void) const { return mDepth; }
|
||||
inline GLenum getInternalFormat (void) const { return mInternalFormat; }
|
||||
inline GLint getMinFilter (void) const { return getParameterI(GL_TEXTURE_MIN_FILTER); }
|
||||
inline GLint getMagFilter (void) const { return getParameterI(GL_TEXTURE_MAG_FILTER); }
|
||||
inline GLint getBaseLevel (void) const { return getParameterI(GL_TEXTURE_BASE_LEVEL); }
|
||||
inline GLint getMaxLevel (void) const { return getParameterI(GL_TEXTURE_MAX_LEVEL); }
|
||||
inline GLint getMinLOD (void) const { return getParameterI(GL_TEXTURE_MIN_LOD); }
|
||||
inline GLint getMaxLOD (void) const { return getParameterI(GL_TEXTURE_MAX_LOD); }
|
||||
inline GLfloat getLODBias (void) const { return getParameterF(GL_TEXTURE_LOD_BIAS); }
|
||||
inline GLenum getCompareMode (void) const { return (GLenum) getParameterI(GL_TEXTURE_COMPARE_MODE); }
|
||||
inline GLenum getCompareFunc (void) const { return (GLenum) getParameterI(GL_TEXTURE_COMPARE_FUNC); }
|
||||
inline glm::vec4 getBorderColor (void) const { return getParameter4F(GL_TEXTURE_BORDER_COLOR); }
|
||||
#ifndef ACGL_OPENGLES_VERSION_20
|
||||
inline GLenum getWrapS (void) const { return (GLenum) getParameterI(GL_TEXTURE_WRAP_S); }
|
||||
inline GLenum getWrapT (void) const { return (GLenum) getParameterI(GL_TEXTURE_WRAP_T); }
|
||||
inline GLenum getWrapR (void) const { return (GLenum) getParameterI(GL_TEXTURE_WRAP_R); }
|
||||
#endif // ACGL_OPENGLES_VERSION_20
|
||||
inline glm::uvec3 getSize (void) const { return glm::uvec3( mWidth, mHeight, mDepth ); }
|
||||
|
||||
// ===================================================================================================== \/
|
||||
// ============================================================================================ WRAPPERS \/
|
||||
// ===================================================================================================== \/
|
||||
public:
|
||||
//! Activate texture unit and bind this texture to it. _textureUnit starts at 0!
|
||||
inline void bind(GLuint _textureUnit) const
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + _textureUnit);
|
||||
glBindTexture(mTarget, mObjectName);
|
||||
}
|
||||
|
||||
//! Bind this texture to the currently active texture unit.
|
||||
inline void bind(void) const
|
||||
{
|
||||
glBindTexture(mTarget, mObjectName);
|
||||
}
|
||||
|
||||
//! sets the minification filter
|
||||
void setMinFilter(GLint _value = GL_NEAREST_MIPMAP_LINEAR );
|
||||
|
||||
//! sets the magnification filter
|
||||
void setMagFilter(GLint _value = GL_LINEAR);
|
||||
|
||||
#ifndef ACGL_OPENGLES_VERSION_20
|
||||
void setWrapS( GLenum _wrapS = GL_REPEAT );
|
||||
void setWrapT( GLenum _wrapT = GL_REPEAT );
|
||||
void setWrapR( GLenum _wrapR = GL_REPEAT );
|
||||
|
||||
//! Note: The function will bind this texture!
|
||||
void setWrap(GLenum _wrapS, GLenum _wrapT = 0, GLenum _wrapR = 0);
|
||||
#endif
|
||||
|
||||
//! lowest defined mipmap level
|
||||
void setBaseLevel( GLint _level = -1000 );
|
||||
|
||||
//! highest defined mipmap level
|
||||
void setMaxLevel( GLint _level = 1000 );
|
||||
|
||||
//! lowest mipmap level to use
|
||||
void setMinLOD( GLint _lod = -1000 );
|
||||
|
||||
//! highest mipmap level to use
|
||||
void setMaxLOD( GLint _lod = 1000 );
|
||||
|
||||
//! offset to add to the mipmap level calculation
|
||||
void setLODBias( GLfloat _bias = 0.0f );
|
||||
|
||||
//! for usage of a texture with depth data
|
||||
void setCompareMode( GLenum _mode = GL_NONE );
|
||||
|
||||
//! for usage of a texture with depth data
|
||||
void setCompareFunc( GLenum _func = GL_LEQUAL );
|
||||
|
||||
//! color that is sampled outside range if wrap is set to GL_CLAMP_TO_BORDER
|
||||
void setBorderColor(const glm::vec4& _color = glm::vec4(0.0));
|
||||
|
||||
//! _sampleCount = 1.0 to deactivate anisotrop filtering, maximum is often 16. If a value is too high it will get clamped to the maximum
|
||||
void setAnisotropicFilter( GLfloat _sampleCount );
|
||||
|
||||
//! Generate mipmaps from the current base texture (i.e. the texture from level 0)
|
||||
void generateMipmaps(void);
|
||||
|
||||
void resize(const glm::uvec3& _size) { resizeI(glm::uvec3(_size.x, _size.y, _size.z)); }
|
||||
void resize(const glm::uvec2& _size) { resizeI(glm::uvec3(_size.x, _size.y, 1 )); }
|
||||
void resize(const glm::uvec1& _size) { resizeI(glm::uvec3(_size.x, 1, 1 )); }
|
||||
void resize( GLuint _size) { resizeI(glm::uvec3(_size, 1, 1 )); }
|
||||
|
||||
#ifndef ACGL_OPENGLES_VERSION_20
|
||||
//! get one texture image:
|
||||
TextureData *getTextureImageRAW( const Image &_image = Image(), GLenum _format = GL_RGBA, GLenum _type = GL_UNSIGNED_BYTE ) const;
|
||||
SharedTextureData getTextureImage( const Image &_image = Image(), GLenum _format = GL_RGBA, GLenum _type = GL_UNSIGNED_BYTE ) const {
|
||||
return SharedTextureData( getTextureImageRAW(_image, _format, _type) );
|
||||
}
|
||||
#endif // ES 2
|
||||
|
||||
// =================================================================================================== \/
|
||||
// ============================================================================================ FIELDS \/
|
||||
// =================================================================================================== \/
|
||||
protected:
|
||||
GLuint mObjectName;
|
||||
|
||||
// kind of texture data:
|
||||
GLenum mTarget;
|
||||
GLsizei mWidth; // width
|
||||
GLsizei mHeight; // height or 1 in case of a 1D texture
|
||||
GLsizei mDepth; // depth or #of layer in a 2D array, 1 otherwise
|
||||
GLenum mInternalFormat; // often used, so store it here
|
||||
|
||||
// Checks what texture is currently bound at the texture target used by this texture
|
||||
// to be later used to restore that texture (to be side effect free). Then binds this texture.
|
||||
GLuint bindAndGetOldTexture() const;
|
||||
|
||||
// generic get parameter functions:
|
||||
GLint getParameterI ( GLenum _name ) const;
|
||||
GLfloat getParameterF ( GLenum _name ) const;
|
||||
glm::vec4 getParameter4F( GLenum _name ) const;
|
||||
|
||||
//! returns a format compatible with the internal, only used to
|
||||
//! reserve memory, not to upload actual data!
|
||||
GLenum getCompatibleFormat( GLenum _internalFormat );
|
||||
GLenum getCompatibleType( GLenum _internalFormat );
|
||||
|
||||
|
||||
//! to be used by subclasses, will not check if usage is meaningfull for the
|
||||
//! texture target, this has to be checked by the subclass (this is why this
|
||||
//! function is private here)
|
||||
void texImage1D( const SharedTextureData &_data, GLint _mipmapLevel );
|
||||
void texSubImage1D( const SharedTextureData &_data, GLint _mipmapLevel, uint32_t _offset = 0 );
|
||||
|
||||
void texImage2D( const SharedTextureData &_data, GLint _mipmapLevel );
|
||||
void texSubImage2D( const SharedTextureData &_data, GLint _mipmapLevel, glm::uvec2 _offset = glm::uvec2(0) );
|
||||
|
||||
void texImage3D( const SharedTextureData &_data, GLint _mipmapLevel );
|
||||
void texSubImage3D( const SharedTextureData &_data, GLint _mipmapLevel, glm::uvec3 _offset = glm::uvec3(0) );
|
||||
|
||||
//! returns true if space for the texture was allocated
|
||||
bool textureStorageIsAllocated()
|
||||
{
|
||||
return (mWidth != 0);
|
||||
}
|
||||
|
||||
//! Resizes the texture. Subclasses implementing this method may use only use the first entries of _size if they are of lower dimension
|
||||
virtual void resizeI(const glm::uvec3& _size) = 0;
|
||||
};
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(TextureBase)
|
||||
|
||||
// missing classes:
|
||||
// GL_TEXTURE_1D x
|
||||
// GL_TEXTURE_2D x
|
||||
// GL_TEXTURE_3D x
|
||||
// GL_TEXTURE_1D_ARRAY x
|
||||
// GL_TEXTURE_2D_ARRAY x
|
||||
// GL_TEXTURE_RECTANGLE x
|
||||
// GL_TEXTURE_2D_MULTISAMPLE
|
||||
// GL_TEXTURE_2D_MULTISAMPLE_ARRAY
|
||||
// GL_TEXTURE_BINDING_CUBE_MAP x
|
||||
// GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
|
||||
|
||||
/**
|
||||
* In contrast to 'normal' textures these can't have mipmaps and are accessed in the shader by
|
||||
* pixel-coordinates instead of texture coordinates from 0 to 1.
|
||||
* Ths makes them a good choice for multiple renderpasses (no mipmaps needed and texture access
|
||||
* can be done via gl_FragCoord).
|
||||
* For all other cases use Texture2D.
|
||||
*/
|
||||
class TextureRectangle : public TextureBase
|
||||
{
|
||||
public:
|
||||
TextureRectangle( GLenum _internalFormat = GL_RGBA ) : TextureBase( GL_TEXTURE_RECTANGLE, _internalFormat )
|
||||
{
|
||||
setMinFilter( GL_LINEAR ); // default would be MipMapped but that's not supported for Rect Textures!
|
||||
}
|
||||
|
||||
TextureRectangle( const glm::uvec2 &_size, GLenum _internalFormat = GL_RGBA ) : TextureBase( GL_TEXTURE_RECTANGLE, _internalFormat )
|
||||
{
|
||||
setMinFilter( GL_LINEAR ); // default would be MipMapped but that's not supported for Rect Textures!
|
||||
resize( _size );
|
||||
}
|
||||
|
||||
//! sets the content to the given TextureData, might resize the texture
|
||||
void setImageData( const SharedTextureData &_data );
|
||||
|
||||
protected:
|
||||
//! content of the texture is undefined after this, this texture will be bound to the active binding point
|
||||
//! nothing should be bound to the pixel unpack buffer when calling this
|
||||
void resizeI( const glm::uvec3 &_newSize );
|
||||
|
||||
private:
|
||||
void generateMipmaps(void) { ACGL::Utils::error() << "Rectangle Textures don't support MipMaps!" << std::endl; }
|
||||
};
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(TextureRectangle)
|
||||
|
||||
|
||||
/**
|
||||
* 1D textures.
|
||||
* can be used as general purpose data for a shader if texture filtering is wanted, otherwise look
|
||||
* at TextureBuffers!
|
||||
* 1D textures can have mipmaps, TextureBuffers can't.
|
||||
*/
|
||||
class Texture1D : public TextureBase
|
||||
{
|
||||
public:
|
||||
Texture1D( GLenum _internalFormat = GL_RGBA ) : TextureBase( GL_TEXTURE_1D, _internalFormat ) {}
|
||||
Texture1D( const uint32_t _size, GLenum _internalFormat = GL_RGBA ) : TextureBase( GL_TEXTURE_1D, _internalFormat )
|
||||
{
|
||||
resize( _size );
|
||||
}
|
||||
|
||||
//! sets the content to the given TextureData, might resize the texture
|
||||
void setImageData( const SharedTextureData &_data, uint32_t _mipmapLayer = 0 );
|
||||
|
||||
protected:
|
||||
//! content of the texture is undefined after this, this texture will be bound to the active binding point
|
||||
//! nothing should be bound to the pixel unpack buffer when calling this
|
||||
void resizeI( const glm::uvec3 &_newSize );
|
||||
};
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(Texture1D)
|
||||
|
||||
|
||||
/**
|
||||
* "Normal" 2D texture.
|
||||
*/
|
||||
class Texture2D : public TextureBase
|
||||
{
|
||||
public:
|
||||
Texture2D( GLenum _internalFormat = GL_RGBA ) : TextureBase( GL_TEXTURE_2D, _internalFormat ) {}
|
||||
Texture2D( const glm::uvec2 &_size, GLenum _internalFormat = GL_RGBA ) : TextureBase( GL_TEXTURE_2D, _internalFormat )
|
||||
{
|
||||
resize( _size );
|
||||
}
|
||||
|
||||
//! sets the content to the given TextureData, might resize the texture
|
||||
void setImageData( const SharedTextureData &_data, uint32_t _mipmapLayer = 0 );
|
||||
|
||||
protected:
|
||||
//! content of the texture is undefined after this, this texture will be bound to the active binding point
|
||||
//! nothing should be bound to the pixel unpack buffer when calling this
|
||||
void resizeI( const glm::uvec3 &_newSize );
|
||||
};
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(Texture2D)
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 3D volume texture.
|
||||
*/
|
||||
class Texture3D : public TextureBase
|
||||
{
|
||||
public:
|
||||
Texture3D( GLenum _internalFormat = GL_RGBA ) : TextureBase( GL_TEXTURE_3D, _internalFormat ) {}
|
||||
Texture3D( const glm::uvec3 &_size, GLenum _internalFormat = GL_RGBA ) : TextureBase( GL_TEXTURE_3D, _internalFormat )
|
||||
{
|
||||
resize( _size );
|
||||
}
|
||||
|
||||
//! sets the content of one slice to the given TextureData
|
||||
void setImageData( const SharedTextureData &_data, uint32_t _slice, uint32_t _mipmapLayer );
|
||||
|
||||
//! sets the content of all slices to the given TextureData
|
||||
void setImageData( const SharedTextureData &_data, uint32_t _mipmapLayer = 0 );
|
||||
|
||||
protected:
|
||||
//! content of the texture is undefined after this, this texture will be bound to the active binding point
|
||||
//! nothing should be bound to the pixel unpack buffer when calling this
|
||||
void resizeI( const glm::uvec3 &_newSize );
|
||||
};
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(Texture3D)
|
||||
|
||||
|
||||
/**
|
||||
* Array of 1D textures, technically a 2D texture but without filtering between array layers.
|
||||
*/
|
||||
class Texture1DArray : public TextureBase
|
||||
{
|
||||
public:
|
||||
Texture1DArray( GLenum _internalFormat = GL_RGBA ) : TextureBase( GL_TEXTURE_1D_ARRAY, _internalFormat ) {}
|
||||
Texture1DArray( const glm::uvec2 &_size, GLenum _internalFormat = GL_RGBA ) : TextureBase( GL_TEXTURE_1D_ARRAY, _internalFormat )
|
||||
{
|
||||
resize( _size );
|
||||
}
|
||||
|
||||
//! sets the content to the given TextureData to one layer of the texture
|
||||
void setImageData( const SharedTextureData &_data, uint32_t _layer, uint32_t _mipmapLayer );
|
||||
|
||||
//! sets the content to the given TextureData to fill all layers
|
||||
void setImageData( const SharedTextureData &_data, uint32_t _mipmapLayer = 0 );
|
||||
|
||||
protected:
|
||||
//! content of the texture is undefined after this, this texture will be bound to the active binding point
|
||||
//! nothing should be bound to the pixel unpack buffer when calling this
|
||||
void resizeI( const glm::uvec3 &_newSize );
|
||||
};
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(Texture1DArray)
|
||||
|
||||
|
||||
/**
|
||||
* A "stack" of 2D textures. Each must have the same size.
|
||||
* Can be used to access many texture in a shader without having to deal with the
|
||||
* texture unit limit.
|
||||
* Technically a 3D texture but there is no filtering in between the levels (Z-axis of
|
||||
* the 3D texture).
|
||||
*/
|
||||
class Texture2DArray : public TextureBase
|
||||
{
|
||||
public:
|
||||
Texture2DArray( GLenum _internalFormat = GL_RGBA ) : TextureBase( GL_TEXTURE_2D_ARRAY, _internalFormat ) {}
|
||||
Texture2DArray( const glm::uvec3 &_size, GLenum _internalFormat = GL_RGBA ) : TextureBase( GL_TEXTURE_2D_ARRAY, _internalFormat )
|
||||
{
|
||||
resize( _size );
|
||||
}
|
||||
|
||||
//! sets the content to the given TextureData, might resize the texture
|
||||
void setImageData( const SharedTextureData &_data, uint32_t _arrayLayer = 0, uint32_t _mipmapLayer = 0 );
|
||||
|
||||
protected:
|
||||
//! content of the texture is undefined after this, this texture will be bound to the active binding point
|
||||
//! nothing should be bound to the pixel unpack buffer when calling this
|
||||
void resizeI( const glm::uvec3 &_newSize );
|
||||
};
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(Texture2DArray)
|
||||
|
||||
|
||||
/**
|
||||
* For environmant mapping.
|
||||
*/
|
||||
class TextureCubeMap : public TextureBase
|
||||
{
|
||||
public:
|
||||
TextureCubeMap( GLenum _internalFormat = GL_RGBA ) : TextureBase( GL_TEXTURE_CUBE_MAP, _internalFormat ) {}
|
||||
TextureCubeMap( const glm::uvec2 &_size, GLenum _internalFormat = GL_RGBA ) : TextureBase( GL_TEXTURE_CUBE_MAP, _internalFormat )
|
||||
{
|
||||
resize( _size );
|
||||
}
|
||||
|
||||
//! sets the content to the given TextureData, might resize the texture
|
||||
void setImageData( const SharedTextureData &_data, GLenum _cubeSide, uint32_t _mipmapLayer = 0 );
|
||||
|
||||
protected:
|
||||
//! content of the texture is undefined after this, this texture will be bound to the active binding point
|
||||
//! nothing should be bound to the pixel unpack buffer when calling this
|
||||
void resizeI( const glm::uvec3 &_newSize );
|
||||
|
||||
private:
|
||||
bool cubeSideIsValid( const GLenum _cubeSide ) const;
|
||||
void texImage2DCube( const SharedTextureData &_data, GLenum _cubeSide, GLint _mipmapLevel );
|
||||
void texSubImage2DCube( const SharedTextureData &_data, GLenum _cubeSide, GLint _mipmapLevel, glm::ivec2 _offset = glm::ivec2(0) );
|
||||
};
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(TextureCubeMap)
|
||||
|
||||
|
||||
|
||||
} // OpenGL
|
||||
} // ACGL
|
||||
|
||||
#endif // ACGL_OPENGL_OBJECTS_TEXTURE_HH
|
112
extern/acgl/include/ACGL/OpenGL/Objects/TextureBuffer.hh
vendored
Normal file
112
extern/acgl/include/ACGL/OpenGL/Objects/TextureBuffer.hh
vendored
Normal file
@ -0,0 +1,112 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef ACGL_OPENGL_OBJECTS_TEXTUREBUFFER_HH
|
||||
#define ACGL_OPENGL_OBJECTS_TEXTUREBUFFER_HH
|
||||
|
||||
/**
|
||||
* A Texture wrapps the OpenGL texture buffer.
|
||||
*
|
||||
* TextureBuffers are 1D textures which store there data in a Buffer.
|
||||
* They are useful to access large chunks of data from within a shader.
|
||||
* Technically they are accessed as textures (uniform samplerBuffer) via texelFetch
|
||||
* with a 1D coordinate (int coordinate, so no filtering). This means they benefit from
|
||||
* texture caches.
|
||||
* Use these if the data doesn't fit into a UniformBufferObject.
|
||||
*
|
||||
* Data gets stored in the Buffer, no glTexImage calles are allowed!
|
||||
*/
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
#include <ACGL/Base/Macros.hh>
|
||||
#include <ACGL/OpenGL/GL.hh>
|
||||
#include <ACGL/OpenGL/Tools.hh>
|
||||
#include <ACGL/OpenGL/Objects/Buffer.hh>
|
||||
|
||||
#if (ACGL_OPENGL_VERSION >= 31)
|
||||
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
class TextureBuffer : public Buffer
|
||||
{
|
||||
public:
|
||||
// create a new BufferObject with _reservedMemory space (in bytes!)
|
||||
TextureBuffer( GLenum _dataType, size_t _reservedMemory = 1 ) : Buffer(GL_TEXTURE_BUFFER) {
|
||||
mTextureObjectName = 0;
|
||||
glGenTextures(1, &mTextureObjectName);
|
||||
mDataType = _dataType;
|
||||
Buffer::setData( _reservedMemory );
|
||||
attachBufferToTexture();
|
||||
}
|
||||
|
||||
// use an existing BufferObject
|
||||
TextureBuffer( GLenum _dataType, SharedBufferObject _pBuffer ) : Buffer(_pBuffer, GL_TEXTURE_BUFFER) {
|
||||
mTextureObjectName = 0;
|
||||
glGenTextures(1, &mTextureObjectName);
|
||||
mDataType = _dataType;
|
||||
attachBufferToTexture();
|
||||
}
|
||||
|
||||
~TextureBuffer() {
|
||||
setBufferObject( SharedBufferObject() ); // detach the Buffer
|
||||
glDeleteTextures(1, &mTextureObjectName);
|
||||
}
|
||||
|
||||
//! the GL buffer can get changed at any time
|
||||
void setBufferObject( SharedBufferObject _pBuffer ) {
|
||||
Buffer::setBufferObject( _pBuffer );
|
||||
if (!_pBuffer) {
|
||||
// detach all buffers:
|
||||
glTexBuffer( GL_TEXTURE_BUFFER, mDataType, 0 );
|
||||
} else {
|
||||
attachBufferToTexture();
|
||||
}
|
||||
}
|
||||
|
||||
//! Bind the texture part to access it from a shader
|
||||
void bindTexture(GLuint _textureUnit = 0) const {
|
||||
glActiveTexture(GL_TEXTURE0 + _textureUnit);
|
||||
glBindTexture(GL_TEXTURE_BUFFER, mTextureObjectName);
|
||||
}
|
||||
|
||||
//! Bind the buffer part to change the data
|
||||
void bindBuffer() const {
|
||||
Buffer::bind();
|
||||
}
|
||||
|
||||
inline GLuint getTextureObjectName() const { return mTextureObjectName; }
|
||||
inline GLuint getBufferObjectName() const { return Buffer::getObjectName(); }
|
||||
|
||||
private:
|
||||
//! private to prevent it from being called -> it's not clear whether the texture or the buffer should get bound, call
|
||||
//! bindBuffer() or bindTexture() directly!
|
||||
void bind() {}
|
||||
|
||||
void attachBufferToTexture() {
|
||||
if (!mBuffer) {
|
||||
// the buffer was in fact detached
|
||||
bindTexture();
|
||||
glTexBuffer( GL_TEXTURE_BUFFER, mDataType, 0 );
|
||||
} else {
|
||||
assert( Buffer::getSize() > 0 && "glTexBuffer will fail if the buffer is empty" );
|
||||
bindTexture();
|
||||
glTexBuffer( GL_TEXTURE_BUFFER, mDataType, Buffer::getObjectName() );
|
||||
}
|
||||
}
|
||||
|
||||
GLenum mDataType;
|
||||
GLuint mTextureObjectName;
|
||||
};
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(TextureBuffer)
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
#endif // OpenGL 3.0+
|
||||
|
||||
|
||||
#endif // ACGL_OPENGL_OBJECTS_TEXTUREBUFFER_HH
|
153
extern/acgl/include/ACGL/OpenGL/Objects/UniformBuffer.hh
vendored
Normal file
153
extern/acgl/include/ACGL/OpenGL/Objects/UniformBuffer.hh
vendored
Normal file
@ -0,0 +1,153 @@
|
||||
/***********************************************************************
|
||||
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
|
||||
* All rights reserved. *
|
||||
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef ACGL_OPENGL_OBJECTS_UNIFORM_BUFFER_HH
|
||||
#define ACGL_OPENGL_OBJECTS_UNIFORM_BUFFER_HH
|
||||
|
||||
/**
|
||||
* A uniform buffer is an OpenGL buffer object bound to a uniform buffer location.
|
||||
* It can be used:
|
||||
* provide the same set of uniforms to different ShaderPrograms without setting
|
||||
the values multiple times
|
||||
* set multiple uniform variables at once by mapping the buffer into the CPU
|
||||
memory, memset all values and unmap it (quickest way to change a lot of uniforms).
|
||||
* quick switching between multiple sets of uniforms (e.g. material properties).
|
||||
*
|
||||
* To be used, uniforms must be organized in a uniform block, this block has to be bound
|
||||
* to the same location the uniform buffer gets bound to (quite similar to textures).
|
||||
*
|
||||
* If only advantage one is requested, the individual offsets along with the uniform names
|
||||
* can be saved in a uniform buffer to set the uniforms by setUniform() as it would be done
|
||||
* for normal uniforms in a ShaderProgram.
|
||||
* Otherwise the exact memory layout must be known, which can be queried by OpenGL, but which
|
||||
* is also well defined in the case of std140-blocks (see OpenGL spec).
|
||||
*
|
||||
* In contrast to ShaderPrograms, nothing has to be activated before setUniform can be called
|
||||
* here.
|
||||
*/
|
||||
|
||||
#include <ACGL/ACGL.hh>
|
||||
|
||||
#include <ACGL/Base/Macros.hh>
|
||||
#include <ACGL/OpenGL/GL.hh>
|
||||
#include <ACGL/OpenGL/Tools.hh>
|
||||
#include <ACGL/OpenGL/Objects/Buffer.hh>
|
||||
|
||||
#include <ACGL/OpenGL/Data/LocationMappings.hh>
|
||||
#include <ACGL/Math/Math.hh>
|
||||
|
||||
#if (ACGL_OPENGL_VERSION >= 31)
|
||||
namespace ACGL{
|
||||
namespace OpenGL{
|
||||
|
||||
class ShaderProgram;
|
||||
|
||||
class UniformBuffer : public Buffer
|
||||
{
|
||||
// ========================================================================================================= \/
|
||||
// ============================================================================================ CONSTRUCTORS \/
|
||||
// ========================================================================================================= \/
|
||||
public:
|
||||
UniformBuffer()
|
||||
: Buffer(GL_UNIFORM_BUFFER)
|
||||
{}
|
||||
|
||||
UniformBuffer( SharedBufferObject _pBuffer )
|
||||
: Buffer(_pBuffer, GL_UNIFORM_BUFFER)
|
||||
{}
|
||||
|
||||
//! inits the uniformbuffer to be used with the given shaderprogram, _uboName is the name of this buffer in the shader
|
||||
UniformBuffer( const ptr::shared_ptr<const ShaderProgram> &_shaderProgram, const std::string &_uboName );
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ GETTERS \/
|
||||
// ==================================================================================================== \/
|
||||
public:
|
||||
/** returns the byte offset of a uniform within the buffer
|
||||
* Needed to upload the new value of the uniform.
|
||||
* Initially the UniformBuffer does not know any locations as it is just unstructured memory with no
|
||||
* intrinsic meaning, so the locations have to be queried from the matching ShaderProgram and provided
|
||||
* to the UniformBuffer. This is optional, the application can also know the layout and upload the data
|
||||
* without storing/querying the mappings to/from the buffer.
|
||||
*/
|
||||
GLint getUniformOffset (const std::string& _nameInShader) const {
|
||||
if (!uniformNameToOffsetMap) return -1;
|
||||
return uniformNameToOffsetMap->getLocation(_nameInShader);
|
||||
}
|
||||
void setUniformOffsets (SharedLocationMappings _uniformNameToOffsetMap) { uniformNameToOffsetMap = _uniformNameToOffsetMap; }
|
||||
|
||||
// ==================================================================================================== \/
|
||||
// ============================================================================================ SETTERS \/
|
||||
// ==================================================================================================== \/
|
||||
public:
|
||||
//! reserve a number of bytes on the GPU for uniforms
|
||||
inline void reserveMemory(GLsizeiptr _size){ setData( _size, NULL, GL_STREAM_DRAW ); }
|
||||
|
||||
//! uniform setters for scalar types: can only work if the offset-uniformname mapping was set before via setUniformOffsets()
|
||||
inline void setUniform (const std::string &_nameInShader, GLfloat _v) { setUniformScalar<GLfloat> (_nameInShader, _v); }
|
||||
inline void setUniform (const std::string &_nameInShader, GLint _v) { setUniformScalar<GLint> (_nameInShader, _v); }
|
||||
inline void setUniform (const std::string &_nameInShader, GLuint _v) { setUniformScalar<GLuint> (_nameInShader, _v); }
|
||||
inline void setUniform (const std::string &_nameInShader, GLboolean _v) { setUniformScalar<GLboolean>(_nameInShader, _v); }
|
||||
inline void setUniform (const std::string &_nameInShader, GLdouble _v) { setUniformScalar<GLdouble> (_nameInShader, _v); }
|
||||
|
||||
//! asuming std140 layout, add padding:
|
||||
void setUniform(const std::string &_nameInShader, glm::mat2x2 _v) { setUniform(_nameInShader, glm::mat2x4(_v)); }
|
||||
void setUniform(const std::string &_nameInShader, glm::mat3x2 _v) { setUniform(_nameInShader, glm::mat3x4(_v)); }
|
||||
void setUniform(const std::string &_nameInShader, glm::mat4x2 _v) { setUniform(_nameInShader, glm::mat4x4(_v)); }
|
||||
void setUniform(const std::string &_nameInShader, glm::mat2x3 _v) { setUniform(_nameInShader, glm::mat2x4(_v)); }
|
||||
void setUniform(const std::string &_nameInShader, glm::mat3x3 _v) { setUniform(_nameInShader, glm::mat3x4(_v)); }
|
||||
void setUniform(const std::string &_nameInShader, glm::mat4x3 _v) { setUniform(_nameInShader, glm::mat4x4(_v)); }
|
||||
|
||||
//! uniform setters for glm types: can only work if the offset-uniformname mapping was set before via setUniformOffsets()
|
||||
template <typename T>
|
||||
void setUniform (const std::string &_nameInShader, T _v) {
|
||||
GLint offset = getUniformOffset( _nameInShader );
|
||||
if (offset == -1) {
|
||||
// hack for MacOS bug:
|
||||
offset = getUniformOffset( mBlockName+"."+_nameInShader );
|
||||
//ACGL::Utils::debug() << "testing " + mBlockName+"."+_nameInShader << std::endl;
|
||||
}
|
||||
if (offset == -1) {
|
||||
ACGL::Utils::error() << "UniformBuffer does not know uniform " << _nameInShader << std::endl;
|
||||
return;
|
||||
}
|
||||
setSubData( offset, sizeof(T), glm::value_ptr(_v) );
|
||||
}
|
||||
|
||||
// =================================================================================================== \/
|
||||
// ============================================================================================ FIELDS \/
|
||||
// =================================================================================================== \/
|
||||
private:
|
||||
// template for scalar types: private as the setUniform() functions above map to this
|
||||
template <typename T>
|
||||
void setUniformScalar (const std::string &_nameInShader, T _v) {
|
||||
GLint offset = getUniformOffset( _nameInShader );
|
||||
if (offset == -1) {
|
||||
// hack for MacOS bug:
|
||||
offset = getUniformOffset( mBlockName+"."+_nameInShader );
|
||||
//ACGL::Utils::debug() << "testing " + mBlockName+"."+_nameInShader << std::endl;
|
||||
}
|
||||
if (offset == -1) {
|
||||
ACGL::Utils::error() << "UniformBuffer does not know uniform " << _nameInShader << std::endl;
|
||||
return;
|
||||
}
|
||||
setSubData( offset, sizeof(T), &_v );
|
||||
}
|
||||
|
||||
SharedLocationMappings uniformNameToOffsetMap;
|
||||
|
||||
public: // for mac bug
|
||||
std::string mBlockName;
|
||||
};
|
||||
|
||||
ACGL_SMARTPOINTER_TYPEDEFS(UniformBuffer)
|
||||
|
||||
} // OpenGL
|
||||
} // ACGL
|
||||
|
||||
#endif // OpenGL >= 3.1
|
||||
|
||||
#endif // ACGL_OPENGL_OBJECTS_UNIFORM_BUFFER_HH
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user