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 */
#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" {

View File

@ -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}" "")
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
#define SGVec2_H
#include <iosfwd>
/// 2D Vector Class
template<typename T>
class SGVec2 {

View File

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

View File

@ -18,6 +18,8 @@
#ifndef SGVec4_H
#define SGVec4_H
#include <iosfwd>
/// 4D Vector Class
template<typename T>
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);
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<float>(*tok)
// rgb = [0,255], a = [0,1]
/ (comp < 3 ? 255 : 1);
color[comp] = boost::lexical_cast<float>(*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

View File

@ -19,7 +19,14 @@
#ifndef PARSE_COLOR_HXX_
#define PARSE_COLOR_HXX_
#include <osg/Vec4>
#include <simgear/math/SGLimits.hxx>
#include <simgear/math/SGMathFwd.hxx>
#include <simgear/math/SGVec4.hxx>
#ifndef SIMGEAR_HEADLESS
# include <osg/Vec4>
#endif
#include <string>
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

View File

@ -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);

View File

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