Fix windows and headless build

This commit is contained in:
Thomas Geymayer 2012-11-05 12:58:21 +01:00
parent 509d064286
commit f83c8828f0
9 changed files with 78 additions and 32 deletions

View File

@ -406,6 +406,8 @@ typedef enum {
/* Function Prototypes */ /* 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(_WIN32) || defined(__VC32__)
# if defined(VG_API_EXPORT) # if defined(VG_API_EXPORT)
# define VG_API_CALL __declspec(dllexport) # define VG_API_CALL __declspec(dllexport)
@ -415,6 +417,9 @@ typedef enum {
#else #else
# define VG_API_CALL extern # define VG_API_CALL extern
#endif #endif
#else
# define VG_API_CALL
#endif
#if defined (__cplusplus) #if defined (__cplusplus)
extern "C" { extern "C" {

View File

@ -1,27 +1,30 @@
include(SimGearComponent) include(SimGearComponent)
#add_definitions(-DVG_API_EXPORT) set(HEADERS
../include/vg/openvg.h
set(ShivaVG_Src ../include/vg/vgu.h
${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
) )
simgear_scene_component(ShivaVG canvas/ShivaVG "${ShivaVG_Src}" "") 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}")

View File

@ -18,6 +18,8 @@
#ifndef SGVec2_H #ifndef SGVec2_H
#define SGVec2_H #define SGVec2_H
#include <iosfwd>
/// 2D Vector Class /// 2D Vector Class
template<typename T> template<typename T>
class SGVec2 { class SGVec2 {

View File

@ -18,6 +18,8 @@
#ifndef SGVec3_H #ifndef SGVec3_H
#define SGVec3_H #define SGVec3_H
#include <iosfwd>
/// 3D Vector Class /// 3D Vector Class
template<typename T> template<typename T>
class SGVec3 { class SGVec3 {

View File

@ -18,6 +18,8 @@
#ifndef SGVec4_H #ifndef SGVec4_H
#define SGVec4_H #define SGVec4_H
#include <iosfwd>
/// 4D Vector Class /// 4D Vector Class
template<typename T> template<typename T>
class SGVec4 { class SGVec4 {

View File

@ -27,10 +27,10 @@ namespace simgear
{ {
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool parseColor(std::string str, osg::Vec4& result) bool parseColor(std::string str, SGVec4f& result)
{ {
boost::trim(str); boost::trim(str);
osg::Vec4 color(0,0,0,1); SGVec4f color(0,0,0,1);
if( str.empty() ) if( str.empty() )
return false; return false;
@ -49,7 +49,7 @@ namespace simgear
tok != tokens.end() && comp < 4; tok != tokens.end() && comp < 4;
++tok, ++comp ) ++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) // rgb(r,g,b)
@ -75,7 +75,7 @@ namespace simgear
tok != tokens.end() && comp < 4; tok != tokens.end() && comp < 4;
++tok, ++comp ) ++tok, ++comp )
{ {
color._v[comp] = boost::lexical_cast<float>(*tok) color[comp] = boost::lexical_cast<float>(*tok)
// rgb = [0,255], a = [0,1] // rgb = [0,255], a = [0,1]
/ (comp < 3 ? 255 : 1); / (comp < 3 ? 255 : 1);
} }
@ -87,4 +87,16 @@ namespace simgear
return true; 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 } // namespace simgear

View File

@ -19,7 +19,14 @@
#ifndef PARSE_COLOR_HXX_ #ifndef PARSE_COLOR_HXX_
#define PARSE_COLOR_HXX_ #define PARSE_COLOR_HXX_
#include <simgear/math/SGLimits.hxx>
#include <simgear/math/SGMathFwd.hxx>
#include <simgear/math/SGVec4.hxx>
#ifndef SIMGEAR_HEADLESS
# include <osg/Vec4> # include <osg/Vec4>
#endif
#include <string> #include <string>
namespace simgear namespace simgear
@ -33,7 +40,19 @@ namespace simgear
* *
* @return Whether str contained a valid color (and result has been modified) * @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); bool parseColor(std::string str, osg::Vec4& result);
#endif
} // namespace simgear } // namespace simgear

View File

@ -20,11 +20,11 @@
#define VERIFY_COLOR(str, r, g, b, a) \ #define VERIFY_COLOR(str, r, g, b, a) \
VERIFY(simgear::parseColor(str, color)) \ 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) int main (int ac, char ** av)
{ {
osg::Vec4 color; SGVec4f color;
VERIFY_COLOR("#ff0000", 1,0,0,1); VERIFY_COLOR("#ff0000", 1,0,0,1);
VERIFY_COLOR("#00ff00", 0,1,0,1); VERIFY_COLOR("#00ff00", 0,1,0,1);
VERIFY_COLOR("#0000ff", 0,0,1,1); VERIFY_COLOR("#0000ff", 0,0,1,1);

View File

@ -21,3 +21,4 @@
#cmakedefine SYSTEM_EXPAT #cmakedefine SYSTEM_EXPAT
#cmakedefine ENABLE_SOUND #cmakedefine ENABLE_SOUND
#cmakedefine SIMGEAR_HEADLESS