Skip to content
Permalink
Browse files

Merge branch 'master' into fix_custom_query_geometry

  • Loading branch information...
openscenegraph committed Aug 22, 2019
2 parents aff574b + af7d647 commit eb980136a0ffba11ea03421f8c5c6a9e7eb49493
@@ -0,0 +1,98 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
#[[=======================================================================.rst:
FindFontconfig
--------------

Find Fontconfig headers and library.

Imported Targets
^^^^^^^^^^^^^^^^

``Fontconfig::Fontconfig``
The Fontconfig library, if found.

Result Variables
^^^^^^^^^^^^^^^^

This will define the following variables in your project:

``FONTCONFIG_FOUND``
true if (the requested version of) Fontconfig is available.
``FONTCONFIG_VERSION``
the version of Fontconfig.
``FONTCONFIG_LIBRARIES``
the libraries to link against to use Fontconfig.
``FONTCONFIG_INCLUDE_DIRS``
where to find the Fontconfig headers.
``FONTCONFIG_COMPILE_OPTIONS``
this should be passed to target_compile_options(), if the
target is not used for linking
=======================================================================]]

# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
find_package(PkgConfig QUIET)
pkg_check_modules(PKG_FONTCONFIG QUIET fontconfig)
set(FONTCONFIG_COMPILE_OPTIONS ${PKG_FONTCONFIG_CFLAGS_OTHER})
set(FONTCONFIG_VERSION ${PKG_FONTCONFIG_VERSION})

find_path( FONTCONFIG_INCLUDE_DIR
NAMES
fontconfig/fontconfig.h
HINTS
${PKG_FONTCONFIG_INCLUDE_DIRS}
/usr/X11/include
)

find_library( FONTCONFIG_LIBRARY
NAMES
fontconfig
PATHS
${PKG_FONTCONFIG_LIBRARY_DIRS}
)

if (FONTCONFIG_INCLUDE_DIR AND NOT FONTCONFIG_VERSION)
file(STRINGS ${FONTCONFIG_INCLUDE_DIR}/fontconfig/fontconfig.h _contents REGEX "^#define[ \t]+FC_[A-Z]+[ \t]+[0-9]+$")
unset(FONTCONFIG_VERSION)
foreach(VPART MAJOR MINOR REVISION)
foreach(VLINE ${_contents})
if(VLINE MATCHES "^#define[\t ]+FC_${VPART}[\t ]+([0-9]+)$")
set(FONTCONFIG_VERSION_PART "${CMAKE_MATCH_1}")
if(FONTCONFIG_VERSION)
string(APPEND FONTCONFIG_VERSION ".${FONTCONFIG_VERSION_PART}")
else()
set(FONTCONFIG_VERSION "${FONTCONFIG_VERSION_PART}")
endif()
endif()
endforeach()
endforeach()
endif ()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Fontconfig
FOUND_VAR
FONTCONFIG_FOUND
REQUIRED_VARS
FONTCONFIG_LIBRARY
FONTCONFIG_INCLUDE_DIR
VERSION_VAR
FONTCONFIG_VERSION
)


if(FONTCONFIG_FOUND AND NOT TARGET Fontconfig::Fontconfig)
add_library(Fontconfig::Fontconfig UNKNOWN IMPORTED)
set_target_properties(Fontconfig::Fontconfig PROPERTIES
IMPORTED_LOCATION "${FONTCONFIG_LIBRARY}"
INTERFACE_COMPILE_OPTIONS "${FONTCONFIG_COMPILE_OPTIONS}"
INTERFACE_INCLUDE_DIRECTORIES "${FONTCONFIG_INCLUDE_DIR}"
)
endif()

mark_as_advanced(FONTCONFIG_LIBRARY FONTCONFIG_INCLUDE_DIR)

if(FONTCONFIG_FOUND)
set(FONTCONFIG_LIBRARIES ${FONTCONFIG_LIBRARY})
set(FONTCONFIG_INCLUDE_DIRS ${FONTCONFIG_INCLUDE_DIR})
endif()
@@ -101,5 +101,8 @@ if(LIBLAS_LIBRARY AND LIBLAS_INCLUDE_DIR)
if(Boost_FOUND)
set(LIBLAS_LIBRARIES ${LIBLAS_LIBRARY} )
set(LIBLAS_FOUND "YES")
if(WIN32)
link_directories(${Boost_LIBRARY_DIRS})
endif()
endif()
endif()
@@ -99,6 +99,7 @@ FIND_OPENCASCADE_LIBRARY(OPENCASCADE_TKXml TKXml)
FIND_OPENCASCADE_LIBRARY(OPENCASCADE_TKXmlTObj TKXmlTObj)
FIND_OPENCASCADE_LIBRARY(OPENCASCADE_TKXmlXCAF TKXmlXCAF)
FIND_OPENCASCADE_LIBRARY(OPENCASCADE_TKXSBase TKXSBase)
FIND_OPENCASCADE_LIBRARY(OPENCASCADE_TKXCAF TKXCAF)

set (OPENCASCADE_LIBRARY_TYPE_DESCR
"Specifies the type of library to be used. 'Shared' libraries
@@ -66,7 +66,6 @@ class MakeString
inline operator std::string () const { return sstream.str(); }

inline std::string str() const { return sstream.str(); }
inline const char* c_str() const { return sstream.str().c_str(); }
};


@@ -586,7 +586,7 @@ bool OcclusionQueryNode::getPassed( const Camera* camera, NodeVisitor& nv )

void OcclusionQueryNode::traverseQuery( const Camera* camera, NodeVisitor& nv )
{
if (!isQueryGeometryValid())
if (!_validQueryGeometry || ! _enabled)
return;

bool issueQuery;
@@ -77,6 +77,8 @@ DynamicLibrary* DynamicLibrary::loadLibrary(const std::string& libraryName)

HANDLE handle = NULL;

OSG_DEBUG << "DynamicLibrary::try to load library \"" << libraryName << "\"" << std::endl;

std::string fullLibraryName = osgDB::findLibraryFile(libraryName);
if (!fullLibraryName.empty()) handle = getLibraryHandle( fullLibraryName ); // try the lib we have found
else handle = getLibraryHandle( libraryName ); // haven't found a lib ourselves, see if the OS can find it simply from the library name.
@@ -222,6 +222,7 @@ struct DXT1TexelsBlock
//
#define DDPF_ALPHAPIXELS 0x00000001l
#define DDPF_FOURCC 0x00000004l // Compressed formats
#define DDPF_PALETTEINDEXED8 0x00000020l
#define DDPF_RGB 0x00000040l // Uncompressed formats
#define DDPF_ALPHA 0x00000002l
#define DDPF_COMPRESSED 0x00000080l
@@ -944,6 +945,12 @@ osg::Image* ReadDDSFile(std::istream& _istream, bool flipDDSRead)
internalFormat = GL_ALPHA;
pixelFormat = GL_ALPHA;
}
else if (ddsd.ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED8)
{
OSG_INFO << "ReadDDSFile info : format = PALETTEINDEXED8" << std::endl;
// The indexed data needs to first be loaded as a single-component image.
pixelFormat = GL_RED;
}
else
{
OSG_WARN << "ReadDDSFile warning: unhandled pixel format (ddsd.ddpfPixelFormat.dwFlags"
@@ -984,6 +991,16 @@ osg::Image* ReadDDSFile(std::istream& _istream, bool flipDDSRead)

OSG_INFO<<"ReadDDS, dataType = 0x"<<std::hex<<dataType<<std::endl;

unsigned char palette [1024];
if (ddsd.ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED8)
{
if (!_istream.read((char*)palette, 1024))
{
OSG_WARN << "ReadDDSFile warning: couldn't read palette" << std::endl;
return NULL;
}
}

unsigned char* imageData = new unsigned char [sizeWithMipmaps];
if(!imageData)
{
@@ -1010,7 +1027,28 @@ osg::Image* ReadDDSFile(std::istream& _istream, bool flipDDSRead)
// this memory will not be used but it will not cause leak in worst meaning of this word.
}

osgImage->setImage(s,t,r, internalFormat, pixelFormat, dataType, imageData, osg::Image::USE_NEW_DELETE, packing);
if (ddsd.ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED8)
{
// Now we need to substitute the indexed image data with full RGBA image data.
unsigned char* convertedData = new unsigned char [sizeWithMipmaps * 4];
for (unsigned int i = 0; i < sizeWithMipmaps; i++)
{
convertedData[i * 4 + 0] = palette[imageData[i] * 4 + 0];
convertedData[i * 4 + 1] = palette[imageData[i] * 4 + 1];
convertedData[i * 4 + 2] = palette[imageData[i] * 4 + 2];
convertedData[i * 4 + 3] = palette[imageData[i] * 4 + 3];
}
delete [] imageData;
for (unsigned int i = 0; i < mipmap_offsets.size(); i++)
mipmap_offsets[i] *= 4;
internalFormat = GL_RGBA;
pixelFormat = GL_RGBA;
osgImage->setImage(s,t,r, internalFormat, pixelFormat, dataType, convertedData, osg::Image::USE_NEW_DELETE, packing);
}
else
{
osgImage->setImage(s,t,r, internalFormat, pixelFormat, dataType, imageData, osg::Image::USE_NEW_DELETE, packing);
}

if (mipmap_offsets.size()>0) osgImage->setMipmapLevels(mipmap_offsets);

@@ -308,7 +308,7 @@ tiff_error(const char*, const char* fmt, va_list ap)
{
// values are (const char* module, const char* fmt, va_list list)
/* FIXME: store error message ? */
OSG_WARN << "TIFF rader: " << doFormat(fmt, ap) << std::endl;
OSG_WARN << "TIFF reader: " << doFormat(fmt, ap) << std::endl;
}


@@ -317,7 +317,7 @@ tiff_warn(const char*, const char* fmt, va_list ap)
{
// values are (const char* module, const char* fmt, va_list list)
/* FIXME: notify? */
OSG_NOTICE << "TIFF rader: " << doFormat(fmt, ap) << std::endl;
OSG_NOTICE << "TIFF reader: " << doFormat(fmt, ap) << std::endl;
}


0 comments on commit eb98013

Please sign in to comment.
You can’t perform that action at this time.