/* 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)
#else
# define VG_API_CALL extern
#endif
+#else
+# define VG_API_CALL
+#endif
#if defined (__cplusplus)
extern "C" {
include(SimGearComponent)
-#add_definitions(-DVG_API_EXPORT)
+set(HEADERS
+ ../include/vg/openvg.h
+ ../include/vg/vgu.h
+)
-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(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 "${ShivaVG_Src}" "")
\ No newline at end of file
+simgear_scene_component(ShivaVG canvas/ShivaVG "${SOURCES}" "${HEADERS}")
\ No newline at end of file
#ifndef SGVec2_H
#define SGVec2_H
+#include <iosfwd>
+
/// 2D Vector Class
template<typename T>
class SGVec2 {
#ifndef SGVec3_H
#define SGVec3_H
+#include <iosfwd>
+
/// 3D Vector Class
template<typename T>
class SGVec3 {
#ifndef SGVec4_H
#define SGVec4_H
+#include <iosfwd>
+
/// 4D Vector Class
template<typename T>
class SGVec4 {
{
//----------------------------------------------------------------------------
- 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;
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)
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
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
#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
*
* @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
#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);
#cmakedefine SYSTEM_EXPAT
#cmakedefine ENABLE_SOUND
+#cmakedefine SIMGEAR_HEADLESS