From f83c8828f0dc81363d2dbc5c06e449e4fb465cb8 Mon Sep 17 00:00:00 2001 From: Thomas Geymayer Date: Mon, 5 Nov 2012 12:58:21 +0100 Subject: [PATCH] Fix windows and headless build --- simgear/canvas/ShivaVG/include/vg/openvg.h | 5 +++ simgear/canvas/ShivaVG/src/CMakeLists.txt | 49 ++++++++++++---------- simgear/math/SGVec2.hxx | 2 + simgear/math/SGVec3.hxx | 2 + simgear/math/SGVec4.hxx | 2 + simgear/misc/parse_color.cxx | 24 ++++++++--- simgear/misc/parse_color.hxx | 21 +++++++++- simgear/misc/parse_color_test.cxx | 4 +- simgear/simgear_config_cmake.h.in | 1 + 9 files changed, 78 insertions(+), 32 deletions(-) diff --git a/simgear/canvas/ShivaVG/include/vg/openvg.h b/simgear/canvas/ShivaVG/include/vg/openvg.h index 795d66e8..186f2f5b 100644 --- a/simgear/canvas/ShivaVG/include/vg/openvg.h +++ b/simgear/canvas/ShivaVG/include/vg/openvg.h @@ -406,6 +406,8 @@ typedef enum { /* Function Prototypes */ +#if 0 // We are including ShivaVG directly into libSimGearScene and only using + // inside the library so there is no need for any dll import/export stuff #if defined(_WIN32) || defined(__VC32__) # if defined(VG_API_EXPORT) # define VG_API_CALL __declspec(dllexport) @@ -415,6 +417,9 @@ typedef enum { #else # define VG_API_CALL extern #endif +#else +# define VG_API_CALL +#endif #if defined (__cplusplus) extern "C" { diff --git a/simgear/canvas/ShivaVG/src/CMakeLists.txt b/simgear/canvas/ShivaVG/src/CMakeLists.txt index 1e36635c..98f9cabc 100644 --- a/simgear/canvas/ShivaVG/src/CMakeLists.txt +++ b/simgear/canvas/ShivaVG/src/CMakeLists.txt @@ -1,27 +1,30 @@ include(SimGearComponent) -#add_definitions(-DVG_API_EXPORT) - -set(ShivaVG_Src - ${SRCROOT}/shArrays.c - ${SRCROOT}/shArrays.h - ${SRCROOT}/shContext.c - ${SRCROOT}/shContext.h - ${SRCROOT}/shExtensions.c - ${SRCROOT}/shExtensions.h - ${SRCROOT}/shGeometry.c - ${SRCROOT}/shGeometry.h - ${SRCROOT}/shImage.c - ${SRCROOT}/shImage.h - ${SRCROOT}/shPaint.c - ${SRCROOT}/shPaint.h - ${SRCROOT}/shParams.c - ${SRCROOT}/shPath.c - ${SRCROOT}/shPath.h - ${SRCROOT}/shPipeline.c - ${SRCROOT}/shVectors.c - ${SRCROOT}/shVectors.h - ${SRCROOT}/shVgu.c +set(HEADERS + ../include/vg/openvg.h + ../include/vg/vgu.h ) -simgear_scene_component(ShivaVG canvas/ShivaVG "${ShivaVG_Src}" "") \ No newline at end of file +set(SOURCES + shArrays.c + shArrays.h + shContext.c + shContext.h + shExtensions.c + shExtensions.h + shGeometry.c + shGeometry.h + shImage.c + shImage.h + shPaint.c + shPaint.h + shParams.c + shPath.c + shPath.h + shPipeline.c + shVectors.c + shVectors.h + shVgu.c +) + +simgear_scene_component(ShivaVG canvas/ShivaVG "${SOURCES}" "${HEADERS}") \ No newline at end of file diff --git a/simgear/math/SGVec2.hxx b/simgear/math/SGVec2.hxx index 68e74c17..0695cded 100644 --- a/simgear/math/SGVec2.hxx +++ b/simgear/math/SGVec2.hxx @@ -18,6 +18,8 @@ #ifndef SGVec2_H #define SGVec2_H +#include + /// 2D Vector Class template class SGVec2 { diff --git a/simgear/math/SGVec3.hxx b/simgear/math/SGVec3.hxx index 56775d3e..dbc8af54 100644 --- a/simgear/math/SGVec3.hxx +++ b/simgear/math/SGVec3.hxx @@ -18,6 +18,8 @@ #ifndef SGVec3_H #define SGVec3_H +#include + /// 3D Vector Class template class SGVec3 { diff --git a/simgear/math/SGVec4.hxx b/simgear/math/SGVec4.hxx index 6e42d957..301aaca3 100644 --- a/simgear/math/SGVec4.hxx +++ b/simgear/math/SGVec4.hxx @@ -18,6 +18,8 @@ #ifndef SGVec4_H #define SGVec4_H +#include + /// 4D Vector Class template class SGVec4 { diff --git a/simgear/misc/parse_color.cxx b/simgear/misc/parse_color.cxx index 722ccfa2..4bcc20b6 100644 --- a/simgear/misc/parse_color.cxx +++ b/simgear/misc/parse_color.cxx @@ -27,10 +27,10 @@ namespace simgear { //---------------------------------------------------------------------------- - bool parseColor(std::string str, osg::Vec4& result) + bool parseColor(std::string str, SGVec4f& result) { boost::trim(str); - osg::Vec4 color(0,0,0,1); + SGVec4f color(0,0,0,1); if( str.empty() ) return false; @@ -49,7 +49,7 @@ namespace simgear tok != tokens.end() && comp < 4; ++tok, ++comp ) { - color._v[comp] = strtol(std::string(*tok).c_str(), 0, 16) / 255.f; + color[comp] = strtol(std::string(*tok).c_str(), 0, 16) / 255.f; } } // rgb(r,g,b) @@ -75,9 +75,9 @@ namespace simgear tok != tokens.end() && comp < 4; ++tok, ++comp ) { - color._v[comp] = boost::lexical_cast(*tok) - // rgb = [0,255], a = [0,1] - / (comp < 3 ? 255 : 1); + color[comp] = boost::lexical_cast(*tok) + // rgb = [0,255], a = [0,1] + / (comp < 3 ? 255 : 1); } } else @@ -87,4 +87,16 @@ namespace simgear return true; } +#ifndef SIMGEAR_HEADLESS + bool parseColor(std::string str, osg::Vec4& result) + { + SGVec4f color; + if( !parseColor(str, color) ) + return false; + + result.set(color[0], color[1], color[2], color[3]); + return true; + } +#endif + } // namespace simgear diff --git a/simgear/misc/parse_color.hxx b/simgear/misc/parse_color.hxx index d4ecad3c..d74bffca 100644 --- a/simgear/misc/parse_color.hxx +++ b/simgear/misc/parse_color.hxx @@ -19,7 +19,14 @@ #ifndef PARSE_COLOR_HXX_ #define PARSE_COLOR_HXX_ -#include +#include +#include +#include + +#ifndef SIMGEAR_HEADLESS +# include +#endif + #include namespace simgear @@ -33,7 +40,19 @@ namespace simgear * * @return Whether str contained a valid color (and result has been modified) */ + bool parseColor(std::string str, SGVec4f& result); + +#ifndef SIMGEAR_HEADLESS + /** + * Parse a (CSS) color into an osg::Vec4 + * + * @param str Text to parse + * @param result Output for parse color + * + * @return Whether str contained a valid color (and result has been modified) + */ bool parseColor(std::string str, osg::Vec4& result); +#endif } // namespace simgear diff --git a/simgear/misc/parse_color_test.cxx b/simgear/misc/parse_color_test.cxx index c41b2645..c3795e65 100644 --- a/simgear/misc/parse_color_test.cxx +++ b/simgear/misc/parse_color_test.cxx @@ -20,11 +20,11 @@ #define VERIFY_COLOR(str, r, g, b, a) \ VERIFY(simgear::parseColor(str, color)) \ - COMPARE(color, osg::Vec4(r, g, b, a)) + COMPARE(color, SGVec4f(r, g, b, a)) int main (int ac, char ** av) { - osg::Vec4 color; + SGVec4f color; VERIFY_COLOR("#ff0000", 1,0,0,1); VERIFY_COLOR("#00ff00", 0,1,0,1); VERIFY_COLOR("#0000ff", 0,0,1,1); diff --git a/simgear/simgear_config_cmake.h.in b/simgear/simgear_config_cmake.h.in index bb6d092b..34af5094 100644 --- a/simgear/simgear_config_cmake.h.in +++ b/simgear/simgear_config_cmake.h.in @@ -21,3 +21,4 @@ #cmakedefine SYSTEM_EXPAT #cmakedefine ENABLE_SOUND +#cmakedefine SIMGEAR_HEADLESS