Commit 0129eeb352d3d6efb800fe507e50e464fb1eda73
1 parent
8b7d6f9a
updated type checking in stim::image
Showing
2 changed files
with
128 additions
and
71 deletions
Show diff stats
cmake/FindGLEW.cmake
1 | +# Copyright (c) 2012-2016 DreamWorks Animation LLC | ||
2 | +# | ||
3 | +# All rights reserved. This software is distributed under the | ||
4 | +# Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ ) | ||
5 | +# | ||
6 | +# Redistributions of source code must retain the above copyright | ||
7 | +# and license notice and the following restrictions and disclaimer. | ||
8 | +# | ||
9 | +# * Neither the name of DreamWorks Animation nor the names of | ||
10 | +# its contributors may be used to endorse or promote products derived | ||
11 | +# from this software without specific prior written permission. | ||
12 | +# | ||
13 | +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
14 | +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
15 | +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
16 | +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
17 | +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY INDIRECT, INCIDENTAL, | ||
18 | +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
19 | +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
20 | +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
21 | +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
22 | +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
23 | +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
24 | +# IN NO EVENT SHALL THE COPYRIGHT HOLDERS' AND CONTRIBUTORS' AGGREGATE | ||
25 | +# LIABILITY FOR ALL CLAIMS REGARDLESS OF THEIR BASIS EXCEED US$250.00. | ||
1 | # | 26 | # |
2 | -# Windows users: define the GLEW_PATH environment variable to point | ||
3 | -# to the root glew directory, which contains: | ||
4 | -# lib/Release/Win32/glew32.lib AND/OR lib/Release/x64/glew32.lib | ||
5 | -# include/GL/glew.h | ||
6 | 27 | ||
7 | -#Try to find GLEW library and include path. | ||
8 | -# Once done this will define | 28 | +#-*-cmake-*- |
29 | +# - Find GLEW | ||
30 | +# | ||
31 | +# Author : Nicholas Yue yue.nicholas@gmail.com | ||
32 | +# | ||
33 | +# This auxiliary CMake file helps in find the GLEW headers and libraries | ||
9 | # | 34 | # |
10 | -# GLEW_FOUND | ||
11 | -# GLEW_INCLUDE_DIR | ||
12 | -# GLEW_LIBRARY | ||
13 | -# | 35 | +# GLEW_FOUND set if Glew is found. |
36 | +# GLEW_INCLUDE_DIR GLEW's include directory | ||
37 | +# GLEW_glew_LIBRARY GLEW libraries | ||
38 | +# GLEW_glewmx_LIBRARY GLEWmx libraries (Mulitple Rendering Context) | ||
39 | + | ||
40 | +FIND_PACKAGE ( PackageHandleStandardArgs ) | ||
41 | + | ||
42 | +FIND_PATH( GLEW_LOCATION include/GL/glew.h | ||
43 | + "$ENV{GLEW_ROOT}" | ||
44 | + NO_DEFAULT_PATH | ||
45 | + NO_SYSTEM_ENVIRONMENT_PATH | ||
46 | + ) | ||
47 | + | ||
48 | +FIND_PACKAGE_HANDLE_STANDARD_ARGS ( GLEW | ||
49 | + REQUIRED_VARS GLEW_LOCATION | ||
50 | + ) | ||
51 | + | ||
52 | +IF ( GLEW_LOCATION ) | ||
53 | + | ||
54 | + SET( GLEW_INCLUDE_DIR "${GLEW_LOCATION}/include" CACHE STRING "GLEW include path") | ||
14 | 55 | ||
15 | -IF (WIN32) | ||
16 | - FIND_PATH( GLEW_INCLUDE_DIR GL/glew.h | ||
17 | - $ENV{GLEW_PATH}/include | ||
18 | - $ENV{PROGRAMFILES}/GLEW/include | ||
19 | - ${PROJECT_SOURCE_DIR}/src/nvgl/glew/include | ||
20 | - DOC "The directory where GL/glew.h resides") | ||
21 | - if( CMAKE_SIZEOF_VOID_P EQUAL 8 ) | ||
22 | - FIND_LIBRARY( GLEW_LIBRARY | ||
23 | - NAMES glew GLEW glew32 glew32s | ||
24 | - PATHS | ||
25 | - $ENV{GLEW_PATH}/lib/Release/x64 | ||
26 | - $ENV{PROGRAMFILES}/GLEW/lib | ||
27 | - ${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin | ||
28 | - ${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib | ||
29 | - DOC "The GLEW library") | ||
30 | - else( CMAKE_SIZEOF_VOID_P EQUAL 8 ) | ||
31 | - FIND_LIBRARY( GLEW_LIBRARY | ||
32 | - NAMES glew GLEW glew32 glew32s | ||
33 | - PATHS | ||
34 | - $ENV{GLEW_PATH}/lib/Release/Win32 | ||
35 | - $ENV{PROGRAMFILES}/GLEW/lib | ||
36 | - ${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin | ||
37 | - ${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib | ||
38 | - DOC "The GLEW library") | ||
39 | - endif( CMAKE_SIZEOF_VOID_P EQUAL 8 ) | ||
40 | -ELSE (WIN32) | ||
41 | - FIND_PATH( GLEW_INCLUDE_DIR GL/glew.h | ||
42 | - /usr/include | ||
43 | - /usr/local/include | ||
44 | - /sw/include | ||
45 | - /opt/local/include | ||
46 | - DOC "The directory where GL/glew.h resides") | ||
47 | - FIND_LIBRARY( GLEW_LIBRARY | ||
48 | - NAMES GLEW glew | ||
49 | - PATHS | ||
50 | - /usr/lib64 | ||
51 | - /usr/lib | ||
52 | - /usr/local/lib64 | ||
53 | - /usr/local/lib | ||
54 | - /sw/lib | ||
55 | - /opt/local/lib | ||
56 | - DOC "The GLEW library") | ||
57 | -ENDIF (WIN32) | 56 | + SET ( ORIGINAL_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) |
57 | + IF (GLEW_USE_STATIC_LIBS) | ||
58 | + IF (APPLE) | ||
59 | + SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a") | ||
60 | + FIND_LIBRARY ( GLEW_LIBRARY_PATH GLEW PATHS ${GLEW_LOCATION}/lib | ||
61 | + NO_DEFAULT_PATH | ||
62 | + NO_SYSTEM_ENVIRONMENT_PATH | ||
63 | + ) | ||
64 | + FIND_LIBRARY ( GLEWmx_LIBRARY_PATH GLEWmx PATHS ${GLEW_LOCATION}/lib | ||
65 | + NO_DEFAULT_PATH | ||
66 | + NO_SYSTEM_ENVIRONMENT_PATH | ||
67 | + ) | ||
68 | + # MESSAGE ( "APPLE STATIC" ) | ||
69 | + # MESSAGE ( "GLEW_LIBRARY_PATH = " ${GLEW_LIBRARY_PATH} ) | ||
70 | + ELSEIF (WIN32) | ||
71 | + # Link library | ||
72 | + SET(CMAKE_FIND_LIBRARY_SUFFIXES ".lib") | ||
73 | + FIND_LIBRARY ( GLEW_LIBRARY_PATH GLEW32S PATHS ${GLEW_LOCATION}/lib ) | ||
74 | + FIND_LIBRARY ( GLEWmx_LIBRARY_PATH GLEW32MXS PATHS ${GLEW_LOCATION}/lib ) | ||
75 | + ELSE (APPLE) | ||
76 | + SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a") | ||
77 | + FIND_LIBRARY ( GLEW_LIBRARY_PATH GLEW PATHS ${GLEW_LOCATION}/lib | ||
78 | + NO_DEFAULT_PATH | ||
79 | + NO_SYSTEM_ENVIRONMENT_PATH | ||
80 | + ) | ||
81 | + FIND_LIBRARY ( GLEWmx_LIBRARY_PATH GLEWmx PATHS ${GLEW_LOCATION}/lib | ||
82 | + NO_DEFAULT_PATH | ||
83 | + NO_SYSTEM_ENVIRONMENT_PATH | ||
84 | + ) | ||
85 | + # MESSAGE ( "LINUX STATIC" ) | ||
86 | + # MESSAGE ( "GLEW_LIBRARY_PATH = " ${GLEW_LIBRARY_PATH} ) | ||
87 | + ENDIF (APPLE) | ||
88 | + ELSE () | ||
89 | + IF (APPLE) | ||
90 | + SET(CMAKE_FIND_LIBRARY_SUFFIXES ".dylib") | ||
91 | + FIND_LIBRARY ( GLEW_LIBRARY_PATH GLEW PATHS ${GLEW_LOCATION}/lib ) | ||
92 | + FIND_LIBRARY ( GLEWmx_LIBRARY_PATH GLEWmx PATHS ${GLEW_LOCATION}/lib ) | ||
93 | + ELSEIF (WIN32) | ||
94 | + # Link library | ||
95 | + SET(CMAKE_FIND_LIBRARY_SUFFIXES ".lib") | ||
96 | + FIND_LIBRARY ( GLEW_LIBRARY_PATH GLEW32 PATHS ${GLEW_LOCATION}/lib ) | ||
97 | + FIND_LIBRARY ( GLEWmx_LIBRARY_PATH GLEW32mx PATHS ${GLEW_LOCATION}/lib ) | ||
98 | + # Load library | ||
99 | + SET(CMAKE_FIND_LIBRARY_SUFFIXES ".dll") | ||
100 | + FIND_LIBRARY ( GLEW_DLL_PATH GLEW32 PATHS ${GLEW_LOCATION}/bin | ||
101 | + NO_DEFAULT_PATH | ||
102 | + NO_SYSTEM_ENVIRONMENT_PATH | ||
103 | + ) | ||
104 | + FIND_LIBRARY ( GLEWmx_DLL_PATH GLEW32mx PATHS ${GLEW_LOCATION}/bin | ||
105 | + NO_DEFAULT_PATH | ||
106 | + NO_SYSTEM_ENVIRONMENT_PATH | ||
107 | + ) | ||
108 | + ELSE (APPLE) | ||
109 | + # Unices | ||
110 | + FIND_LIBRARY ( GLEW_LIBRARY_PATH GLEW PATHS ${GLEW_LOCATION}/lib | ||
111 | + NO_DEFAULT_PATH | ||
112 | + NO_SYSTEM_ENVIRONMENT_PATH | ||
113 | + ) | ||
114 | + FIND_LIBRARY ( GLEWmx_LIBRARY_PATH GLEWmx PATHS ${GLEW_LOCATION}/lib | ||
115 | + NO_DEFAULT_PATH | ||
116 | + NO_SYSTEM_ENVIRONMENT_PATH | ||
117 | + ) | ||
118 | + ENDIF (APPLE) | ||
119 | + ENDIF () | ||
120 | + # MUST reset | ||
121 | + SET(CMAKE_FIND_LIBRARY_SUFFIXES ${ORIGINAL_CMAKE_FIND_LIBRARY_SUFFIXES}) | ||
58 | 122 | ||
59 | -IF (GLEW_INCLUDE_DIR) | ||
60 | - SET( GLEW_FOUND 1 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise") | ||
61 | -ELSE (GLEW_INCLUDE_DIR) | ||
62 | - SET( GLEW_FOUND 0 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise") | ||
63 | -ENDIF (GLEW_INCLUDE_DIR) | 123 | + SET( GLEW_GLEW_LIBRARY ${GLEW_LIBRARY_PATH} CACHE STRING "GLEW library") |
124 | + SET( GLEW_GLEWmx_LIBRARY ${GLEWmx_LIBRARY_PATH} CACHE STRING "GLEWmx library") | ||
64 | 125 | ||
65 | -MARK_AS_ADVANCED( | ||
66 | - GLEW_FOUND | ||
67 | - GLEW_INCLUDE_DIR | ||
68 | - GLEW_LIBRARY | ||
69 | -) | ||
70 | \ No newline at end of file | 126 | \ No newline at end of file |
127 | +ENDIF () |
stim/image/image.h
@@ -74,14 +74,14 @@ class image{ | @@ -74,14 +74,14 @@ class image{ | ||
74 | #endif | 74 | #endif |
75 | /// Returns the value for "white" based on the dynamic range (assumes white is 1.0 for floating point images) | 75 | /// Returns the value for "white" based on the dynamic range (assumes white is 1.0 for floating point images) |
76 | T white(){ | 76 | T white(){ |
77 | - | ||
78 | - if(typeid(T) == typeid(unsigned char)) return UCHAR_MAX; | ||
79 | - if(typeid(T) == typeid(unsigned short)) return SHRT_MAX; | ||
80 | - if(typeid(T) == typeid(unsigned)) return UINT_MAX; | ||
81 | - if(typeid(T) == typeid(unsigned long)) return ULONG_MAX; | ||
82 | - if(typeid(T) == typeid(unsigned long long)) return ULLONG_MAX; | ||
83 | - if(typeid(T) == typeid(float)) return 1.0f; | ||
84 | - if(typeid(T) == typeid(double)) return 1.0; | 77 | + return std::numeric_limits<T>::max(); |
78 | + //if(typeid(T) == typeid(unsigned char)) return UCHAR_MAX; | ||
79 | + //if(typeid(T) == typeid(unsigned short)) return SHRT_MAX; | ||
80 | + //if(typeid(T) == typeid(unsigned)) return UINT_MAX; | ||
81 | + //if(typeid(T) == typeid(unsigned long)) return ULONG_MAX; | ||
82 | + //if(typeid(T) == typeid(unsigned long long)) return ULLONG_MAX; | ||
83 | + //if(typeid(T) == typeid(float)) return 1.0f; | ||
84 | + //if(typeid(T) == typeid(double)) return 1.0; | ||
85 | 85 | ||
86 | std::cout<<"ERROR in stim::image::white - no white value known for this data type"<<std::endl; | 86 | std::cout<<"ERROR in stim::image::white - no white value known for this data type"<<std::endl; |
87 | exit(1); | 87 | exit(1); |