Make the option ShivaVG or ShaderVG a Cmake option: USE_SHADERVG
This commit is contained in:
parent
6451e505d8
commit
b157f9cb9f
@ -95,6 +95,7 @@ option(ENABLE_RTI "Set to ON to build SimGear with RTI support" OFF)
|
||||
option(ENABLE_GDAL "Set to ON to build SimGear with GDAL support" OFF)
|
||||
option(ENABLE_TESTS "Set to OFF to disable building SimGear's test applications" ON)
|
||||
option(ENABLE_SOUND "Set to OFF to disable building SimGear's sound support" ON)
|
||||
option(USE_SHADERVG "Set to ON to use SHaderVG instead of ShivaVG" OFF)
|
||||
option(USE_AEONWAVE "Set to ON to use AeonWave instead of OpenAL" ON)
|
||||
option(USE_OPENALSOFT "Set to ON to use OpenAL from OpenAL-soft" OFF)
|
||||
|
||||
@ -108,6 +109,14 @@ if (NOT ENABLE_SIMD AND ENABLE_SIMD_CODE)
|
||||
set(ENABLE_SIMD_CODE OFF)
|
||||
endif()
|
||||
|
||||
if (USE_SHADERVG)
|
||||
set(OPENVG ShaderVG)
|
||||
find_package(GLEW REQUIRED)
|
||||
else()
|
||||
set(OPENVG ShivaVG)
|
||||
endif()
|
||||
message(STATUS "OpenVG: ${OPENVG}")
|
||||
|
||||
include (DetectArch)
|
||||
include (ExportDebugSymbols)
|
||||
|
||||
|
@ -12,6 +12,11 @@ set(SIMGEAR_SOUND @ENABLE_SOUND@)
|
||||
set(USE_AEONWAVE @USE_AEONWAVE@)
|
||||
set(SG_SOUND_USES_OPENALSOFT @SG_SOUND_USES_OPENALSOFT@)
|
||||
|
||||
set(USE_SHADERVG @USE_SHADERVG@)
|
||||
if (USE_SHADERVG)
|
||||
find_dependency(GLEW REQUIRED)
|
||||
endif()
|
||||
|
||||
set(ENABLE_ASAN @ENABLE_ASAN@)
|
||||
set(SIMGEAR_SHARED @SIMGEAR_SHARED@)
|
||||
|
||||
|
@ -154,7 +154,7 @@ target_link_libraries(SimGearCore PRIVATE
|
||||
${WINSOCK_LIBRARY})
|
||||
|
||||
if(NOT SIMGEAR_HEADLESS)
|
||||
target_include_directories(SimGearScene PRIVATE ${PROJECT_SOURCE_DIR}/simgear/canvas/ShivaVG/include)
|
||||
target_include_directories(SimGearScene PRIVATE ${PROJECT_SOURCE_DIR}/simgear/canvas/${OPENVG}/include)
|
||||
|
||||
target_link_libraries(SimGearScene PUBLIC
|
||||
SimGearCore
|
||||
@ -162,7 +162,7 @@ if(NOT SIMGEAR_HEADLESS)
|
||||
)
|
||||
|
||||
if(HAVE_INTTYPES_H)
|
||||
# ShivaVG needs inttypes.h
|
||||
# ShivaVG/ShaderVG needs inttypes.h
|
||||
target_compile_definitions(SimGearScene PRIVATE HAVE_INTTYPES_H)
|
||||
endif()
|
||||
|
||||
@ -173,6 +173,10 @@ if(NOT SIMGEAR_HEADLESS)
|
||||
${FFMPEG_LIBRARIES}
|
||||
FGTinyGLTF)
|
||||
|
||||
if (USE_SHADERVG)
|
||||
target_link_libraries(SimGearScene PRIVATE GLEW::GLEW)
|
||||
endif()
|
||||
|
||||
# ToDo: define an ALIAS target for the sound backend, to get
|
||||
# rid of this logic here
|
||||
if (ENABLE_SOUND)
|
||||
|
@ -29,7 +29,7 @@ set(SOURCES
|
||||
VGInitOperation.cxx
|
||||
)
|
||||
|
||||
add_subdirectory(ShivaVG/src)
|
||||
add_subdirectory(${OPENVG}/src)
|
||||
add_subdirectory(elements)
|
||||
add_subdirectory(events)
|
||||
add_subdirectory(layout)
|
||||
|
@ -20,4 +20,4 @@ set(SOURCES
|
||||
shVgu.c
|
||||
)
|
||||
|
||||
simgear_scene_component(ShivaVG canvas/ShivaVG "${SOURCES}" "${HEADERS}")
|
||||
simgear_scene_component(ShaderVG canvas/ShaderVG "${SOURCES}" "${HEADERS}")
|
||||
|
@ -1,31 +0,0 @@
|
||||
lib_LTLIBRARIES = libOpenVG.la
|
||||
libOpenVG_la_CFLAGS = -pedantic -I$(top_builddir)/include/vg
|
||||
libOpenVG_la_SOURCES =\
|
||||
shDefs.h\
|
||||
shExtensions.h\
|
||||
shArrayBase.h\
|
||||
shArrays.h\
|
||||
shVectors.h\
|
||||
shPath.h\
|
||||
shImage.h\
|
||||
shPaint.h\
|
||||
shGeometry.h\
|
||||
shContext.h\
|
||||
shaders.h\
|
||||
shExtensions.c\
|
||||
shArrays.c\
|
||||
shVectors.c\
|
||||
shPath.c\
|
||||
shImage.c\
|
||||
shPaint.c\
|
||||
shGeometry.c\
|
||||
shPipeline.c\
|
||||
shParams.c\
|
||||
shContext.c\
|
||||
shaders.c\
|
||||
shVgu.c
|
||||
|
||||
VG_includedir = $(includedir)/vg
|
||||
VG_include_HEADERS =\
|
||||
$(top_builddir)/include/vg/openvg.h\
|
||||
$(top_builddir)/include/vg/vgu.h
|
@ -23,8 +23,6 @@
|
||||
|
||||
/* Standard headers */
|
||||
|
||||
#include "shConfig.h"
|
||||
|
||||
#ifdef VG_API_WINDOWS
|
||||
# include <windows.h>
|
||||
#endif
|
||||
@ -156,17 +154,14 @@ SHfloat getMaxFloat();
|
||||
|
||||
/* OpenGL headers */
|
||||
|
||||
#if defined(VG_API_LINUX) || defined(VG_API_FREEBSD) || defined(VG_API_OPENBSD)
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glx.h>
|
||||
#elif defined(VG_API_MACOSX)
|
||||
#if defined(VG_API_MACOSX)
|
||||
# include <OpenGL/gl.h>
|
||||
#elif defined(VG_API_WINDOWS)
|
||||
#include <GL/gl.h>
|
||||
# define GL_GLEXT_PROTOTYPES
|
||||
# include <GL/glcorearb.h>
|
||||
#else
|
||||
#define GL_GLEXT_LEGACY /* don't include glext.h */
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glx.h>
|
||||
# define GL_GLEXT_PROTOTYPES
|
||||
# include <GL/glcorearb.h>
|
||||
#endif
|
||||
|
||||
#include "shExtensions.h"
|
||||
|
@ -38,7 +38,6 @@
|
||||
#define _ARRAY_DEFINE
|
||||
#include "shArrayBase.h"
|
||||
|
||||
#ifndef SH_NO_IMAGE
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Prepares the proper pixel pack/unpack info for the given
|
||||
@ -446,8 +445,6 @@ void shLoadColor(SHColor *c, const void *data, SHImageFormatDesc *f)
|
||||
if (f->rmask == 0x0) { c->r = 1.0f; c->g = 1.0f; c->b = 1.0f; }
|
||||
}
|
||||
|
||||
#endif // SH_NO_IMAGE
|
||||
|
||||
|
||||
/*----------------------------------------------
|
||||
* Color and Image constructors and destructors
|
||||
@ -469,11 +466,7 @@ void SHImage_ctor(SHImage *i)
|
||||
i->data = NULL;
|
||||
i->width = 0;
|
||||
i->height = 0;
|
||||
#ifdef SH_NO_IMAGE
|
||||
printf("ShaderVG: images not supported!");
|
||||
#else
|
||||
glGenTextures(1, &i->texture);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SHImage_dtor(SHImage *i)
|
||||
@ -481,15 +474,10 @@ void SHImage_dtor(SHImage *i)
|
||||
if (i->data != NULL)
|
||||
free(i->data);
|
||||
|
||||
#ifdef SH_NO_IMAGE
|
||||
printf("ShaderVG: images not supported!");
|
||||
#else
|
||||
if (glIsTexture(i->texture))
|
||||
glDeleteTextures(1, &i->texture);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef SH_NO_IMAGE
|
||||
/*--------------------------------------------------------
|
||||
* Finds appropriate OpenGL texture size for the size of
|
||||
* the given image
|
||||
@ -531,7 +519,6 @@ void shUpdateImageTexture(SHImage *i, VGContext *c)
|
||||
i->texwidth, i->texheight, 0,
|
||||
i->fd.glformat, i->fd.gltype, i->data);
|
||||
}
|
||||
#endif // SH_NO_IMAGE
|
||||
|
||||
/*----------------------------------------------------------
|
||||
* Creates a new image object and returns the handle to it
|
||||
@ -541,10 +528,6 @@ VG_API_CALL VGImage vgCreateImage(VGImageFormat format,
|
||||
VGint width, VGint height,
|
||||
VGbitfield allowedQuality)
|
||||
{
|
||||
#ifdef SH_NO_IMAGE
|
||||
printf("ShaderVG: images not supported!");
|
||||
return VG_INVALID_HANDLE;
|
||||
#else
|
||||
SHImage *i = NULL;
|
||||
SHImageFormatDesc fd;
|
||||
VG_GETCONTEXT(VG_INVALID_HANDLE);
|
||||
@ -599,14 +582,10 @@ VG_API_CALL VGImage vgCreateImage(VGImageFormat format,
|
||||
shImageArrayPushBack(&context->images, i);
|
||||
|
||||
VG_RETURN((VGImage)i);
|
||||
#endif // SH_NO_IMAGE
|
||||
}
|
||||
|
||||
VG_API_CALL void vgDestroyImage(VGImage image)
|
||||
{
|
||||
#ifdef SH_NO_IMAGE
|
||||
printf("ShaderVG: images not supported!");
|
||||
#else
|
||||
SHint index;
|
||||
VG_GETCONTEXT(VG_NO_RETVAL);
|
||||
|
||||
@ -619,7 +598,6 @@ VG_API_CALL void vgDestroyImage(VGImage image)
|
||||
shImageArrayRemoveAt(&context->images, index);
|
||||
|
||||
VG_RETURN(VG_NO_RETVAL);
|
||||
#endif // SH_NO_IMAGE
|
||||
}
|
||||
|
||||
/*---------------------------------------------------
|
||||
@ -630,9 +608,6 @@ VG_API_CALL void vgDestroyImage(VGImage image)
|
||||
VG_API_CALL void vgClearImage(VGImage image,
|
||||
VGint x, VGint y, VGint width, VGint height)
|
||||
{
|
||||
#ifdef SH_NO_IMAGE
|
||||
printf("ShaderVG: images not supported!");
|
||||
#else
|
||||
SHImage *i;
|
||||
SHColor clear;
|
||||
SHuint8 *data;
|
||||
@ -674,11 +649,8 @@ VG_API_CALL void vgClearImage(VGImage image,
|
||||
|
||||
shUpdateImageTexture(i, context);
|
||||
VG_RETURN(VG_NO_RETVAL);
|
||||
#endif // SH_NO_IMAGE
|
||||
}
|
||||
|
||||
#ifndef SH_NO_IMAGE
|
||||
|
||||
/*------------------------------------------------------------
|
||||
* Generic function for copying a rectangle area of pixels
|
||||
* of size (width,height) among two data buffers. The size of
|
||||
@ -789,8 +761,6 @@ void shCopyPixels(SHuint8 *dst, VGImageFormat dstFormat, SHint dstStride,
|
||||
}
|
||||
}
|
||||
|
||||
#endif // SH_NO_IMAGE
|
||||
|
||||
/*---------------------------------------------------------
|
||||
* Copies a rectangle area of pixels of size (width,height)
|
||||
* from given data buffer to image surface at destination
|
||||
@ -802,9 +772,6 @@ VG_API_CALL void vgImageSubData(VGImage image,
|
||||
VGImageFormat dataFormat,
|
||||
VGint x, VGint y, VGint width, VGint height)
|
||||
{
|
||||
#ifdef SH_NO_IMAGE
|
||||
printf("ShaderVG: images not supported!");
|
||||
#else
|
||||
SHImage *i;
|
||||
VG_GETCONTEXT(VG_NO_RETVAL);
|
||||
|
||||
@ -836,7 +803,6 @@ VG_API_CALL void vgImageSubData(VGImage image,
|
||||
|
||||
shUpdateImageTexture(i, context);
|
||||
VG_RETURN(VG_NO_RETVAL);
|
||||
#endif // SH_NO_IMAGE
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------
|
||||
@ -851,9 +817,6 @@ VG_API_CALL void vgGetImageSubData(VGImage image,
|
||||
VGint x, VGint y,
|
||||
VGint width, VGint height)
|
||||
{
|
||||
#ifdef SH_NO_IMAGE
|
||||
printf("ShaderVG: images not supported!");
|
||||
#else
|
||||
SHImage *i;
|
||||
VG_GETCONTEXT(VG_NO_RETVAL);
|
||||
|
||||
@ -884,7 +847,6 @@ VG_API_CALL void vgGetImageSubData(VGImage image,
|
||||
0,0,x,x,width,height);
|
||||
|
||||
VG_RETURN(VG_NO_RETVAL);
|
||||
#endif // SH_NO_IMAGE
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------
|
||||
@ -898,9 +860,6 @@ VG_API_CALL void vgCopyImage(VGImage dst, VGint dx, VGint dy,
|
||||
VGint width, VGint height,
|
||||
VGboolean dither)
|
||||
{
|
||||
#ifdef SH_NO_IMAGE
|
||||
printf("ShaderVG: images not supported!");
|
||||
#else
|
||||
SHImage *s, *d;
|
||||
SHuint8 *pixels;
|
||||
|
||||
@ -941,7 +900,6 @@ VG_API_CALL void vgCopyImage(VGImage dst, VGint dx, VGint dy,
|
||||
|
||||
shUpdateImageTexture(d, context);
|
||||
VG_RETURN(VG_NO_RETVAL);
|
||||
#endif // SH_NO_IMAGE
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------
|
||||
@ -954,9 +912,6 @@ VG_API_CALL void vgSetPixels(VGint dx, VGint dy,
|
||||
VGImage src, VGint sx, VGint sy,
|
||||
VGint width, VGint height)
|
||||
{
|
||||
#ifdef SH_NO_IMAGE
|
||||
printf("ShaderVG: images not supported!");
|
||||
#else
|
||||
SHImage *i;
|
||||
SHuint8 *pixels;
|
||||
SHImageFormatDesc winfd;
|
||||
@ -1001,7 +956,6 @@ VG_API_CALL void vgSetPixels(VGint dx, VGint dy,
|
||||
free(pixels);
|
||||
|
||||
VG_RETURN(VG_NO_RETVAL);
|
||||
#endif // SH_NO_IMAGE
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------
|
||||
@ -1015,9 +969,6 @@ VG_API_CALL void vgWritePixels(const void * data, VGint dataStride,
|
||||
VGint dx, VGint dy,
|
||||
VGint width, VGint height)
|
||||
{
|
||||
#ifdef SH_NO_IMAGE
|
||||
printf("ShaderVG: images not supported!");
|
||||
#else
|
||||
SHuint8 *pixels;
|
||||
SHImageFormatDesc winfd;
|
||||
|
||||
@ -1067,7 +1018,6 @@ VG_API_CALL void vgWritePixels(const void * data, VGint dataStride,
|
||||
free(pixels);
|
||||
|
||||
VG_RETURN(VG_NO_RETVAL);
|
||||
#endif // SH_NO_IMAGE
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
@ -1080,9 +1030,6 @@ VG_API_CALL void vgGetPixels(VGImage dst, VGint dx, VGint dy,
|
||||
VGint sx, VGint sy,
|
||||
VGint width, VGint height)
|
||||
{
|
||||
#ifdef SH_NO_IMAGE
|
||||
printf("ShaderVG: images not supported!");
|
||||
#else
|
||||
SHImage *i;
|
||||
SHuint8 *pixels;
|
||||
SHImageFormatDesc winfd;
|
||||
@ -1121,7 +1068,6 @@ VG_API_CALL void vgGetPixels(VGImage dst, VGint dx, VGint dy,
|
||||
|
||||
shUpdateImageTexture(i, context);
|
||||
VG_RETURN(VG_NO_RETVAL);
|
||||
#endif // SH_NO_IMAGE
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
@ -1135,9 +1081,6 @@ VG_API_CALL void vgReadPixels(void * data, VGint dataStride,
|
||||
VGint sx, VGint sy,
|
||||
VGint width, VGint height)
|
||||
{
|
||||
#ifdef SH_NO_IMAGE
|
||||
printf("ShaderVG: images not supported!");
|
||||
#else
|
||||
SHuint8 *pixels;
|
||||
SHImageFormatDesc winfd;
|
||||
VG_GETCONTEXT(VG_NO_RETVAL);
|
||||
@ -1179,7 +1122,6 @@ VG_API_CALL void vgReadPixels(void * data, VGint dataStride,
|
||||
free(pixels);
|
||||
|
||||
VG_RETURN(VG_NO_RETVAL);
|
||||
#endif // SH_NO_IMAGE
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------
|
||||
|
@ -37,9 +37,6 @@
|
||||
#define _ARRAY_DEFINE
|
||||
#include "shArrayBase.h"
|
||||
|
||||
// We currently do not use gradients which need textures, so disable them to
|
||||
// prevent freeing resources outside the correct OpenGL thread/context.
|
||||
#define SH_NO_PAINT_TEXTURE
|
||||
|
||||
void SHPaint_ctor(SHPaint *p)
|
||||
{
|
||||
@ -56,16 +53,12 @@ void SHPaint_ctor(SHPaint *p)
|
||||
for (i=0; i<5; ++i) p->radialGradient[i] = 0.0f;
|
||||
p->pattern = VG_INVALID_HANDLE;
|
||||
|
||||
#ifndef SH_NO_PAINT_TEXTURE
|
||||
glGenTextures(1, &p->texture);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
glBindTexture(GL_TEXTURE_2D, p->texture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, SH_GRADIENT_TEX_WIDTH, SH_GRADIENT_TEX_HEIGHT, 0,
|
||||
GL_RGBA, GL_FLOAT, NULL);
|
||||
GL_CEHCK_ERROR;
|
||||
#else
|
||||
p->texture = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void SHPaint_dtor(SHPaint *p)
|
||||
@ -73,10 +66,8 @@ void SHPaint_dtor(SHPaint *p)
|
||||
SH_DEINITOBJ(SHStopArray, p->instops);
|
||||
SH_DEINITOBJ(SHStopArray, p->stops);
|
||||
|
||||
#ifndef SH_NO_PAINT_TEXTURE
|
||||
if (glIsTexture(p->texture))
|
||||
glDeleteTextures(1, &p->texture);
|
||||
#endif
|
||||
}
|
||||
|
||||
VG_API_CALL VGPaint vgCreatePaint(void)
|
||||
@ -155,7 +146,6 @@ VG_API_CALL void vgPaintPattern(VGPaint paint, VGImage pattern)
|
||||
|
||||
void shUpdateColorRampTexture(SHPaint *p)
|
||||
{
|
||||
#ifndef SH_NO_PAINT_TEXTURE
|
||||
SHint s=0;
|
||||
SHStop *stop1, *stop2;
|
||||
SHfloat rgba[SH_GRADIENT_TEX_COORDSIZE];
|
||||
@ -199,9 +189,6 @@ void shUpdateColorRampTexture(SHPaint *p)
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, i, SH_GRADIENT_TEX_WIDTH, 1, GL_RGBA, GL_FLOAT, rgba);
|
||||
|
||||
GL_CEHCK_ERROR;
|
||||
#else
|
||||
printf("ShaderVG: gradients not supported!");
|
||||
#endif
|
||||
}
|
||||
|
||||
void shValidateInputStops(SHPaint *p)
|
||||
@ -363,7 +350,6 @@ void shGenerateStops(SHPaint *p, SHfloat minOffset, SHfloat maxOffset,
|
||||
|
||||
void shSetGradientTexGLState(SHPaint *p)
|
||||
{
|
||||
#ifndef SH_NO_PAINT_TEXTURE
|
||||
glBindTexture(GL_TEXTURE_2D, p->texture);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
@ -376,9 +362,6 @@ void shSetGradientTexGLState(SHPaint *p)
|
||||
case VG_COLOR_RAMP_SPREAD_REFLECT:
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT); break;
|
||||
}
|
||||
#else
|
||||
printf("ShaderVG: gradients not supported!");
|
||||
#endif
|
||||
}
|
||||
|
||||
void shSetPatternTexGLState(SHPaint *p, VGContext *c)
|
||||
|
@ -418,7 +418,7 @@ VG_API_CALL void vgDrawImage(VGImage image)
|
||||
SHImage *i;
|
||||
SHfloat mgl[16];
|
||||
SHPaint *fill;
|
||||
SHVector2 min, max;
|
||||
//SHVector2 min, max;
|
||||
SHRectangle *rect;
|
||||
|
||||
VG_GETCONTEXT(VG_NO_RETVAL);
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#cmakedefine GCC_ATOMIC_BUILTINS_FOUND
|
||||
|
||||
#cmakedefine OPENVG
|
||||
#cmakedefine SYSTEM_EXPAT
|
||||
#cmakedefine ENABLE_SOUND
|
||||
#cmakedefine USE_AEONWAVE
|
||||
|
Loading…
Reference in New Issue
Block a user