Merge remote-tracking branch 'upstream/master' into MDI7

This commit is contained in:
Julien Valentin
2017-08-24 11:26:23 +02:00
108 changed files with 2569 additions and 415 deletions

View File

@@ -1,6 +1,7 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
* Copyright (C) 2010 Tim Moore
* Copyright (C) 2012 David Callu
* Copyright (C) 2017 Julien Valentin
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
@@ -18,25 +19,31 @@
#include <string.h> // for memcpy
#ifndef GL_DRAW_INDIRECT_BUFFER
#define GL_DRAW_INDIRECT_BUFFER 0x8F3F
#endif
namespace osg {
BufferIndexBinding::BufferIndexBinding(GLenum target, GLuint index)
: _target(target), _index(index), _offset(0), _size(0)
:_target(target), _bufferData(0), _index(index), _offset(0), _size(0)
{
}
BufferIndexBinding::BufferIndexBinding(GLenum target, GLuint index, BufferObject* bo,
BufferIndexBinding::BufferIndexBinding(GLenum target, GLuint index, BufferData* bo,
GLintptr offset, GLsizeiptr size)
: _target(target), _index(index), _bufferObject(bo), _offset(offset), _size(size)
: _target(target), _index(index), _offset(offset), _size(size)
{
setBufferData(bo);
}
BufferIndexBinding::BufferIndexBinding(const BufferIndexBinding& rhs, const CopyOp& copyop)
: StateAttribute(rhs, copyop),
_target(rhs._target), _index(rhs._index),
_bufferObject(static_cast<BufferObject*>(copyop(rhs._bufferObject.get()))),
_offset(rhs._offset),
_size(rhs._size)
BufferIndexBinding::BufferIndexBinding(const BufferIndexBinding& rhs, const CopyOp& copyop):StateAttribute(rhs,copyop),
_target(rhs._target),
_bufferData(static_cast<BufferData*>(copyop(rhs._bufferData.get()))),
_index(rhs._index),
_offset(rhs._offset),
_size(rhs._size)
{
}
@@ -55,15 +62,13 @@ void BufferIndexBinding::setIndex(unsigned int index)
void BufferIndexBinding::apply(State& state) const
{
if (_bufferObject.valid())
if (_bufferData.valid())
{
GLBufferObject* glObject
= _bufferObject->getOrCreateGLBufferObject(state.getContextID());
if (!glObject->_extensions->isUniformBufferObjectSupported)
return;
= _bufferData->getBufferObject()->getOrCreateGLBufferObject(state.getContextID());
if (glObject->isDirty()) glObject->compileBuffer();
glObject->_extensions->glBindBufferRange(_target, _index,
glObject->getGLObjectID(), _offset, _size);
glObject->getGLObjectID(), glObject->getOffset(_bufferData->getBufferIndex())+_offset, _size-_offset);
}
}
@@ -73,30 +78,30 @@ UniformBufferBinding::UniformBufferBinding()
}
UniformBufferBinding::UniformBufferBinding(GLuint index)
: BufferIndexBinding(GL_UNIFORM_BUFFER, index)
: BufferIndexBinding(GL_UNIFORM_BUFFER, index)
{
}
UniformBufferBinding::UniformBufferBinding(GLuint index, BufferObject* bo, GLintptr offset,
GLsizeiptr size)
UniformBufferBinding::UniformBufferBinding(GLuint index, BufferData* bo, GLintptr offset,
GLsizeiptr size)
: BufferIndexBinding(GL_UNIFORM_BUFFER, index, bo, offset, size)
{
}
UniformBufferBinding::UniformBufferBinding(const UniformBufferBinding& rhs,
const CopyOp& copyop)
const CopyOp& copyop)
: BufferIndexBinding(rhs, copyop)
{
}
TransformFeedbackBufferBinding::TransformFeedbackBufferBinding(GLuint index)
: BufferIndexBinding(GL_TRANSFORM_FEEDBACK_BUFFER, index)
: BufferIndexBinding(GL_TRANSFORM_FEEDBACK_BUFFER, index)
{
}
TransformFeedbackBufferBinding::TransformFeedbackBufferBinding(GLuint index, BufferObject* bo, GLintptr offset, GLsizeiptr size)
TransformFeedbackBufferBinding::TransformFeedbackBufferBinding(GLuint index, BufferData* bo, GLintptr offset, GLsizeiptr size)
: BufferIndexBinding(GL_TRANSFORM_FEEDBACK_BUFFER, index, bo, offset, size)
{
@@ -109,11 +114,11 @@ TransformFeedbackBufferBinding::TransformFeedbackBufferBinding(const TransformFe
AtomicCounterBufferBinding::AtomicCounterBufferBinding(GLuint index)
: BufferIndexBinding(GL_ATOMIC_COUNTER_BUFFER, index)
: BufferIndexBinding(GL_ATOMIC_COUNTER_BUFFER, index)
{
}
AtomicCounterBufferBinding::AtomicCounterBufferBinding(GLuint index, BufferObject* bo, GLintptr offset, GLsizeiptr size)
AtomicCounterBufferBinding::AtomicCounterBufferBinding(GLuint index, BufferData* bo, GLintptr offset, GLsizeiptr size)
: BufferIndexBinding(GL_ATOMIC_COUNTER_BUFFER, index, bo, offset, size)
{
@@ -126,9 +131,9 @@ AtomicCounterBufferBinding::AtomicCounterBufferBinding(const AtomicCounterBuffer
void AtomicCounterBufferBinding::readData(osg::State & state, osg::UIntArray & uintArray) const
{
if (!_bufferObject) return;
if (!_bufferData) return;
GLBufferObject* bo = _bufferObject->getOrCreateGLBufferObject( state.getContextID() );
GLBufferObject* bo = _bufferData->getBufferObject()->getOrCreateGLBufferObject( state.getContextID() );
if (!bo) return;
@@ -139,7 +144,7 @@ void AtomicCounterBufferBinding::readData(osg::State & state, osg::UIntArray & u
bo->_extensions->glBindBuffer(GL_ATOMIC_COUNTER_BUFFER, bo->getGLObjectID());
GLubyte* src = (GLubyte*)bo->_extensions->glMapBuffer(GL_ATOMIC_COUNTER_BUFFER,
GL_READ_ONLY_ARB);
GL_READ_ONLY_ARB);
if(src)
{
size_t size = osg::minimum<int>(_size, uintArray.getTotalDataSize());
@@ -157,7 +162,7 @@ ShaderStorageBufferBinding::ShaderStorageBufferBinding(GLuint index)
{
}
ShaderStorageBufferBinding::ShaderStorageBufferBinding(GLuint index, BufferObject* bo, GLintptr offset, GLsizeiptr size)
ShaderStorageBufferBinding::ShaderStorageBufferBinding(GLuint index, BufferData* bo, GLintptr offset, GLsizeiptr size)
: BufferIndexBinding(GL_SHADER_STORAGE_BUFFER, index, bo, offset, size)
{
@@ -168,4 +173,5 @@ ShaderStorageBufferBinding::ShaderStorageBufferBinding(const ShaderStorageBuffer
{
}
} // namespace osg

View File

@@ -41,7 +41,11 @@ void DepthRangeIndexed::apply(State& state) const
const GLExtensions* extensions = state.get<GLExtensions>();
if (extensions->glDepthRangeIndexed)
{
extensions->glDepthRangeIndexed(static_cast<GLuint>(_index), static_cast<GLclampd>(_zNear), static_cast<GLclampd>(_zFar));
extensions->glDepthRangeIndexed(static_cast<GLuint>(_index), static_cast<GLdouble>(_zNear), static_cast<GLdouble>(_zFar));
}
else if (extensions->glDepthRangeIndexedf)
{
extensions->glDepthRangeIndexedf(static_cast<GLuint>(_index), static_cast<GLfloat>(_zNear), static_cast<GLfloat>(_zFar));
}
else
{

View File

@@ -817,7 +817,7 @@ void DisplaySettings::readCommandLine(ArgumentParser& arguments)
if (arguments.getApplicationUsage())
{
arguments.getApplicationUsage()->addCommandLineOption("--display <type>","MONITOR | POWERWALL | REALITY_CENTER | HEAD_MOUNTED_DISPLAY");
arguments.getApplicationUsage()->addCommandLineOption("--stereo","Use default stereo mode which is ANAGLYPHIC if not overriden by environmental variable");
arguments.getApplicationUsage()->addCommandLineOption("--stereo","Use default stereo mode which is ANAGLYPHIC if not overridden by environmental variable");
arguments.getApplicationUsage()->addCommandLineOption("--stereo <mode>","ANAGLYPHIC | QUAD_BUFFER | HORIZONTAL_SPLIT | VERTICAL_SPLIT | LEFT_EYE | RIGHT_EYE | HORIZONTAL_INTERLACE | VERTICAL_INTERLACE | CHECKERBOARD | ON | OFF ");
arguments.getApplicationUsage()->addCommandLineOption("--rgba","Request a RGBA color buffer visual");
arguments.getApplicationUsage()->addCommandLineOption("--stencil","Request a stencil buffer visual");

View File

@@ -47,6 +47,9 @@
#else
#include <dlfcn.h>
#endif
#elif defined(__EMSCRIPTEN__)
// Emscripten ships EGL, which we use to get OpenGL function addresses.
#include <EGL/egl.h>
#else
#include <dlfcn.h>
#endif
@@ -407,6 +410,10 @@ OSG_INIT_SINGLETON_PROXY(GLExtensionDisableStringInitializationProxy, osg::getGL
return dlsym(RTLD_DEFAULT, funcName);
#elif defined(__EMSCRIPTEN__)
// Use EGL to get OpenGL function address for Emscripten.
return convertPointerType<void*, __eglMustCastToProperFunctionPointerType>(eglGetProcAddress(funcName));
#else // all other unixes
return dlsym(0, funcName);
@@ -1164,6 +1171,7 @@ GLExtensions::GLExtensions(unsigned int in_contextID):
osg::setGLExtensionFuncPtr(glScissorIndexedv, "glScissorIndexedv", validContext);
osg::setGLExtensionFuncPtr(glDepthRangeArrayv, "glDepthRangeArrayv", validContext);
osg::setGLExtensionFuncPtr(glDepthRangeIndexed, "glDepthRangeIndexed", validContext);
osg::setGLExtensionFuncPtr(glDepthRangeIndexedf, "glDepthRangeIndexedfOES", "glDepthRangeIndexedfNV", validContext);
osg::setGLExtensionFuncPtr(glGetFloati_v, "glGetFloati_v", validContext);
osg::setGLExtensionFuncPtr(glGetDoublei_v, "glGetDoublei_v", validContext);
osg::setGLExtensionFuncPtr(glGetIntegerIndexedvEXT, "glGetIntegerIndexedvEXT", validContext);

View File

@@ -791,6 +791,9 @@ void Geometry::compileGLObjects(RenderInfo& renderInfo) const
if ((*itr)->getBufferObject()) bufferObjects.insert((*itr)->getBufferObject());
}
if (bufferObjects.empty())
return; // no buffers, nothing to compile
//osg::ElapsedTime timer;
// now compile any buffer objects that require it.
@@ -808,11 +811,7 @@ void Geometry::compileGLObjects(RenderInfo& renderInfo) const
// OSG_NOTICE<<"Time to compile "<<timer.elapsedTime_m()<<"ms"<<std::endl;
// unbind the BufferObjects
extensions->glBindBuffer(GL_ARRAY_BUFFER_ARB,0);
extensions->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB,0);
if (state.useVertexArrayObject(_useVertexArrayObject) && !bufferObjects.empty())
if (state.useVertexArrayObject(_useVertexArrayObject))
{
VertexArrayState* vas = 0;
@@ -826,6 +825,10 @@ void Geometry::compileGLObjects(RenderInfo& renderInfo) const
state.unbindVertexArrayObject();
}
// unbind the BufferObjects
extensions->glBindBuffer(GL_ARRAY_BUFFER_ARB,0);
extensions->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB,0);
}
else
{
@@ -1156,8 +1159,6 @@ Geometry* osg::createTexturedQuadGeometry(const Vec3& corner,const Vec3& widthVe
(*normals)[0].normalize();
geom->setNormalArray(normals, osg::Array::BIND_OVERALL);
#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE)
DrawElementsUByte* elems = new DrawElementsUByte(PrimitiveSet::TRIANGLES);
elems->push_back(0);
elems->push_back(1);
@@ -1167,9 +1168,6 @@ Geometry* osg::createTexturedQuadGeometry(const Vec3& corner,const Vec3& widthVe
elems->push_back(3);
elems->push_back(0);
geom->addPrimitiveSet(elems);
#else
geom->addPrimitiveSet(new DrawArrays(PrimitiveSet::QUADS,0,4));
#endif
return geom;
}

View File

@@ -742,6 +742,41 @@ inline T SGL_ABS(T a)
#define SGL_SWAP(a,b,temp) ((temp)=(a),(a)=(b),(b)=(temp))
#endif
bool Matrix_implementation::transpose(const Matrix_implementation&mat){
if (&mat==this) {
Matrix_implementation tm(mat);
return transpose(tm);
}
_mat[0][1]=mat._mat[1][0];
_mat[0][2]=mat._mat[2][0];
_mat[0][3]=mat._mat[3][0];
_mat[1][0]=mat._mat[0][1];
_mat[1][2]=mat._mat[2][1];
_mat[1][3]=mat._mat[3][1];
_mat[2][0]=mat._mat[0][2];
_mat[2][1]=mat._mat[1][2];
_mat[2][3]=mat._mat[3][2];
_mat[3][0]=mat._mat[0][3];
_mat[3][1]=mat._mat[1][3];
_mat[3][2]=mat._mat[2][3];
return true;
}
bool Matrix_implementation::transpose3x3(const Matrix_implementation&mat){
if (&mat==this) {
Matrix_implementation tm(mat);
return transpose3x3(tm);
}
_mat[0][1]=mat._mat[1][0];
_mat[0][2]=mat._mat[2][0];
_mat[1][0]=mat._mat[0][1];
_mat[1][2]=mat._mat[2][1];
_mat[2][0]=mat._mat[0][2];
_mat[2][1]=mat._mat[1][2];
return true;
}
bool Matrix_implementation::invert_4x4( const Matrix_implementation& mat )
{
if (&mat==this) {
@@ -763,7 +798,7 @@ bool Matrix_implementation::invert_4x4( const Matrix_implementation& mat )
for(i=0;i<4;i++)
{
big=0.0;
for (j=0; j<4; j++)
for (j=0; j<4; ++j)
if (ipiv[j] != 1)
for (k=0; k<4; k++)
{
@@ -781,7 +816,7 @@ bool Matrix_implementation::invert_4x4( const Matrix_implementation& mat )
}
++(ipiv[icol]);
if (irow != icol)
for (l=0; l<4; l++) SGL_SWAP(operator()(irow,l),
for (l=0; l<4; ++l) SGL_SWAP(operator()(irow,l),
operator()(icol,l),
temp);
@@ -792,13 +827,13 @@ bool Matrix_implementation::invert_4x4( const Matrix_implementation& mat )
pivinv = 1.0/operator()(icol,icol);
operator()(icol,icol) = 1;
for (l=0; l<4; l++) operator()(icol,l) *= pivinv;
for (ll=0; ll<4; ll++)
for (l=0; l<4; ++l) operator()(icol,l) *= pivinv;
for (ll=0; ll<4; ++ll)
if (ll != icol)
{
dum=operator()(ll,icol);
operator()(ll,icol) = 0;
for (l=0; l<4; l++) operator()(ll,l) -= operator()(icol,l)*dum;
for (l=0; l<4; ++l) operator()(ll,l) -= operator()(icol,l)*dum;
}
}
for (int lx=4; lx>0; --lx)

View File

@@ -61,6 +61,9 @@ struct NotifyStreamBuffer : public std::stringbuf
{
NotifyStreamBuffer() : _severity(osg::NOTICE)
{
/* reduce the need to reallocate the std::ostream buffer behind osg::Notify (causing multitreading issues) by pre-allocating 4095 bytes */
str(std::string(4095, 0));
pubseekpos(0, std::ios_base::out);
}
void setNotifyHandler(osg::NotifyHandler *handler) { _handler = handler; }

View File

@@ -1634,7 +1634,7 @@ void Texture::computeInternalFormatWithImage(const osg::Image& image) const
{
case(GL_INTENSITY) : internalFormat = GL_RED; break; // should it be swizzled to match RGBA(INTENSITY, INTENSITY, INTENSITY, INTENSITY)?
case(GL_LUMINANCE) : internalFormat = GL_RED; break; // should it be swizzled to match RGBA(LUMINANCE, LUMINANCE, LUMINANCE, 1.0)?
case(1) : internalFormat = GL_RED; break; // or sould this be GL_ALPHA?
case(1) : internalFormat = GL_RED; break; // or should this be GL_ALPHA?
case(2) : internalFormat = GL_RG; break; // should we assume GL_LUMINANCE_ALPHA?
case(GL_LUMINANCE_ALPHA) : internalFormat = GL_RG; break; // should it be swizlled to match RGAB(LUMUNIANCE, LUMINANCE, LUMINANCE, ALPHA)?
case(3) : internalFormat = GL_RGB; break;

View File

@@ -63,7 +63,7 @@ void TextureBuffer::setBufferData(BufferData *bufferdata)
{
_bufferData->addClient(this);
///set BufferObject if not setted by user
///set BufferObject if not set by user
if(!_bufferData->getBufferObject())
{
VertexBufferObject* bo=new VertexBufferObject();

View File

@@ -162,7 +162,7 @@ ENDIF()
IF( ZLIB_FOUND )
ADD_DEFINITIONS( -DUSE_ZLIB )
INCLUDE_DIRECTORIES( ${ZLIB_INCLUDE_DIR} )
SET(COMPRESSION_LIBRARIES ZLIB_LIBRARY)
SET(COMPRESSION_LIBRARIES ZLIB_LIBRARIES)
ENDIF()
################################################################################

View File

@@ -95,6 +95,10 @@ typedef char TCHAR;
#endif
#endif
#if defined(__ANDROID__)
#define stat64 stat
#endif
// set up _S_ISDIR()
#if !defined(S_ISDIR)
# if defined( _S_IFDIR) && !defined( __S_IFDIR)

View File

@@ -17,7 +17,7 @@
/// [EXPERIMENTAL] Disables animation data (and matrix transforms) for compatibility with some 3rd party apps.
/// Animations are not read by all 3DS importers. Thus disabling them may allow some 3rd-party apps, such as Rhinoceros (tested with 4.0) to correctly import 3DS files.
/// However, having proper hierarchy with matrix transforms will become impossible.
///\warning This is still experimental, hence the compile flag. This should become a reader/writer option as soon as it works as intented (maybe "noMatrixTransforms" could become a read/write option?).
///\warning This is still experimental, hence the compile flag. This should become a reader/writer option as soon as it works as intended (maybe "noMatrixTransforms" could become a read/write option?).
#define DISABLE_3DS_ANIMATION 0 // Default = 0
#include <osg/io_utils>

View File

@@ -123,7 +123,7 @@ osgDB::ReaderWriter::WriteResult ReaderWritterOpenCASCADE::writeNode(const osg::
/// \brief heals a opencascade shape
/// \detail http://www.opencascade.org/org/forum/thread_12716/?forum=3
/// Usually IGES files suffer from precision problems (when transfering from
/// Usually IGES files suffer from precision problems (when transferring from
/// one CAD system to another).It might be the case that faces are not sewed
/// properly, or do not have the right precision, and so the tesselator does
/// not treat them like "sewed". this needs to be done for sewing

View File

@@ -91,7 +91,7 @@ class ReaderWritterOpenCASCADE: public osgDB::ReaderWriter
/// \brief heals a opencascade shape
/// \detail http://www.opencascade.org/org/forum/thread_12716/?forum=3
/// Usually IGES files suffer from precision problems (when transfering from
/// Usually IGES files suffer from precision problems (when transferring from
/// one CAD system to another).It might be the case that faces are not sewed
/// properly, or do not have the right precision, and so the tesselator does
/// not treat them like "sewed". this needs to be done for sewing

View File

@@ -24,7 +24,7 @@ SET(TARGET_H
IF(ZLIB_FOUND)
SET(TARGET_LIBRARIES_VARS
CURL_LIBRARY
ZLIB_LIBRARY)
ZLIB_LIBRARIES)
ELSE()
SET(TARGET_LIBRARIES_VARS
CURL_LIBRARY)

View File

@@ -39,7 +39,7 @@ void daeWriter::writeUpdateTransformElements(const osg::Vec3 &pos, const osg::Qu
// Make a three rotate place elements for the euler angles
// TODO decompose quaternion into three euler angles
double angle;
osg::Quat::value_type angle;
osg::Vec3 axis;
q.getRotate( angle, axis );
@@ -154,7 +154,7 @@ void daeWriter::apply( osg::PositionAttitudeTransform &node )
scale->getValue().append3( s.x(), s.y(), s.z() );
}
double angle;
osg::Quat::value_type angle;
osg::Vec3 axis;
q.getRotate( angle, axis );
if ( angle != 0 )

View File

@@ -61,7 +61,7 @@
</p>
<p><b>8. Limitation of Liability</b></p>
<p>UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY WILL EITHER PARTY BE LIABLE TO THE OTHER PARTY OR ANY THIRD PARTY FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, SPECIAL, INCIDENTAL, OR EXEMPLARY DAMAGES WITH RESPECT TO ANY INJURY, LOSS, OR DAMAGE, ARISING UNDER OR IN CONNECTION WITH THIS LETTER AGREEMENT, WHETHER FORESEEABLE OR UNFORESEEABLE, EVEN IF SUCH PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH INJURY, LOSS, OR DAMAGE. THE LIMITATIONS OF LIABILITY SET FORTH IN THIS SECTION SHALL APPLY TO THE FULLEST EXTENT PERMISSIBLE AT LAW OR ANY GOVERMENTAL REGULATIONS.
<p>UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY WILL EITHER PARTY BE LIABLE TO THE OTHER PARTY OR ANY THIRD PARTY FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, SPECIAL, INCIDENTAL, OR EXEMPLARY DAMAGES WITH RESPECT TO ANY INJURY, LOSS, OR DAMAGE, ARISING UNDER OR IN CONNECTION WITH THIS LETTER AGREEMENT, WHETHER FORESEEABLE OR UNFORESEEABLE, EVEN IF SUCH PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH INJURY, LOSS, OR DAMAGE. THE LIMITATIONS OF LIABILITY SET FORTH IN THIS SECTION SHALL APPLY TO THE FULLEST EXTENT PERMISSIBLE AT LAW OR ANY GOVERNMENTAL REGULATIONS.
</p>
<p><b>9. Governing Law and Consent to Jurisdiction</b></p>

View File

@@ -5,7 +5,7 @@ IF (DCMTK_FOUND)
SET(TARGET_SRC ReaderWriterDICOM.cpp )
LINK_LIBRARIES(${DCMTK_LIBRARIES} ${ZLIB_LIBRARY})
LINK_LIBRARIES(${DCMTK_LIBRARIES} ${ZLIB_LIBRARIES})
ADD_DEFINITIONS(-DUSE_DCMTK)

View File

@@ -2,7 +2,7 @@ INCLUDE_DIRECTORIES( ${OPENEXR_INCLUDE_DIR}/OpenEXR )
SET(TARGET_SRC ReaderWriterEXR.cpp )
SET(TARGET_LIBRARIES_VARS ${OPENEXR_LIBRARIES_VARS} ZLIB_LIBRARY)
SET(TARGET_LIBRARIES_VARS ${OPENEXR_LIBRARIES_VARS} ZLIB_LIBRARIES)
IF(CMAKE_COMPILER_IS_GNUCXX)
# Remove -Wshadow flag as it barfs on ffmoeg headers

View File

@@ -61,7 +61,7 @@ protected:
}
bool contains(unsigned int v1) const {
return subvertices.count(v1);
return subvertices.count(v1)!=0;
}
void addTriangle(unsigned int v1, unsigned int v2, unsigned v3) {

View File

@@ -62,8 +62,9 @@ namespace glesUtil {
_geometry = target.getGeometry();
_geometry->setPrimitiveSetList(morph.getPrimitiveSetList());
_hasTexCoord = _geometry->getTexCoordArrayList().size();
if(!_hasTexCoord) {
_hasTexCoord = !_geometry->getTexCoordArrayList().empty();
if(_hasTexCoord)
{
_geometry->setTexCoordArrayList(morph.getTexCoordArrayList());
}
}

View File

@@ -4,7 +4,7 @@ SET(TARGET_SRC
ReaderWriterGZ.cpp
)
SET(TARGET_LIBRARIES_VARS ZLIB_LIBRARY )
SET(TARGET_LIBRARIES_VARS ZLIB_LIBRARIES )
#### end var setup ###

View File

@@ -269,7 +269,7 @@ SET(TARGET_H
SET(TARGET_ADDED_LIBRARIES osgSim osgFX osgText osgTerrain osgVolume)
IF(ZLIB_FOUND)
SET(TARGET_LIBRARIES_VARS ZLIB_LIBRARY)
SET(TARGET_LIBRARIES_VARS ZLIB_LIBRARIES)
ENDIF()
#### end var setup ###

View File

@@ -70,12 +70,14 @@ namespace osgDBJPEG
static int jpegerror = ERR_NO_ERROR;
/* Some versions of jmorecfg.h define boolean, some don't...
Those that do also define HAVE_BOOLEAN, so we can guard using that. */
#ifndef HAVE_BOOLEAN
typedef int boolean;
#define FALSE 0
#define TRUE 1
#if JPEG_LIB_VERSION < 90
/* Some versions of jmorecfg.h define boolean, some don't...
Those that do also define HAVE_BOOLEAN, so we can guard using that. */
#ifndef HAVE_BOOLEAN
typedef int boolean;
#define FALSE 0
#define TRUE 1
#endif
#endif
/* CODE FOR READING/WRITING JPEG FROM STREAMS

View File

@@ -493,7 +493,7 @@
** a single double value, using NaN values to represent non-number
** values. The trick only works on 32-bit machines (ints and pointers
** are 32-bit values) with numbers represented as IEEE 754-2008 doubles
** with conventional endianess (12345678 or 87654321), in CPUs that do
** with conventional endianness (12345678 or 87654321), in CPUs that do
** not produce signaling NaN values (all NaNs are quiet).
*/

View File

@@ -150,7 +150,7 @@ protected:
bool fixBlackMaterials;
bool noReverseFaces;
// This is the order in which the materials will be assigned to texture maps, unless
// otherwise overriden
// otherwise overridden
typedef std::vector< std::pair<int,obj::Material::Map::TextureMapType> > TextureAllocationMap;
TextureAllocationMap textureUnitAllocation;
/// Coordinates precision.

View File

@@ -32,7 +32,7 @@ Purpose:
std::streampos actually points past 32 bit addressable range (2 GiB).
Even if std::streamoff is 32 bit and incapable of representing 64 bit file
positions, original std::streampos may be prefectly able to handle them.
positions, original std::streampos may be perfectly able to handle them.
But, when such situation occurs more elaborate conversion methods from/to
std::streampos are needed. Functions below employ such methods.

View File

@@ -18,6 +18,10 @@
#include <osg/Geode>
#include <osg/io_utils>
#include <osgUtil/SmoothingVisitor>
#include <osg/TexEnv>
#include <osgDB/ReaderWriter>
#include <osgDB/ReadFile>
#include <osg/Texture2D>
using namespace std;
using namespace ply;
@@ -35,6 +39,7 @@ VertexData::VertexData()
_diffuse = NULL;
_ambient = NULL;
_specular = NULL;
_texcoord = NULL;
}
@@ -66,6 +71,8 @@ void VertexData::readVertices( PlyFile* file, const int nVertices,
unsigned char specular_blue;
float specular_coeff;
float specular_power;
float texture_u;
float texture_v;
} vertex;
PlyProperty vertexProps[] =
@@ -74,8 +81,8 @@ void VertexData::readVertices( PlyFile* file, const int nVertices,
{ "y", PLY_FLOAT, PLY_FLOAT, offsetof( _Vertex, y ), 0, 0, 0, 0 },
{ "z", PLY_FLOAT, PLY_FLOAT, offsetof( _Vertex, z ), 0, 0, 0, 0 },
{ "nx", PLY_FLOAT, PLY_FLOAT, offsetof( _Vertex, nx ), 0, 0, 0, 0 },
{ "ny", PLY_FLOAT, PLY_FLOAT, offsetof( _Vertex, ny ), 0, 0, 0, 0 },
{ "nz", PLY_FLOAT, PLY_FLOAT, offsetof( _Vertex, nz ), 0, 0, 0, 0 },
{ "ny", PLY_FLOAT, PLY_FLOAT, offsetof(_Vertex, ny), 0, 0, 0, 0 },
{ "nz", PLY_FLOAT, PLY_FLOAT, offsetof(_Vertex, nz), 0, 0, 0, 0 },
{ "red", PLY_UCHAR, PLY_UCHAR, offsetof( _Vertex, red ), 0, 0, 0, 0 },
{ "green", PLY_UCHAR, PLY_UCHAR, offsetof( _Vertex, green ), 0, 0, 0, 0 },
{ "blue", PLY_UCHAR, PLY_UCHAR, offsetof( _Vertex, blue ), 0, 0, 0, 0 },
@@ -91,6 +98,8 @@ void VertexData::readVertices( PlyFile* file, const int nVertices,
{ "specular_blue", PLY_UCHAR, PLY_UCHAR, offsetof( _Vertex, specular_blue ), 0, 0, 0, 0 },
{ "specular_coeff", PLY_FLOAT, PLY_FLOAT, offsetof( _Vertex, specular_coeff ), 0, 0, 0, 0 },
{ "specular_power", PLY_FLOAT, PLY_FLOAT, offsetof( _Vertex, specular_power ), 0, 0, 0, 0 },
{ "texture_u", PLY_FLOAT, PLY_FLOAT, offsetof(_Vertex, texture_u), 0, 0, 0, 0 },
{ "texture_v", PLY_FLOAT, PLY_FLOAT, offsetof(_Vertex, texture_v), 0, 0, 0, 0 },
};
// use all 6 properties when reading colors, only the first 3 otherwise
@@ -120,6 +129,10 @@ void VertexData::readVertices( PlyFile* file, const int nVertices,
for( int i = 16; i < 21; ++i )
ply_get_property( file, "vertex", &vertexProps[i] );
if (fields & TEXCOORD)
for (int i = 21; i < 23; ++i)
ply_get_property(file, "vertex", &vertexProps[i]);
// check whether array is valid otherwise allocate the space
if(!_vertices.valid())
_vertices = new osg::Vec3Array;
@@ -154,6 +167,11 @@ void VertexData::readVertices( PlyFile* file, const int nVertices,
if(!_specular.valid())
_specular = new osg::Vec4Array;
}
if (fields & TEXCOORD)
{
if (!_texcoord.valid())
_texcoord = new osg::Vec2Array;
}
// read in the vertices
for( int i = 0; i < nVertices; ++i )
@@ -186,6 +204,8 @@ void VertexData::readVertices( PlyFile* file, const int nVertices,
_specular->push_back( osg::Vec4( (unsigned int) vertex.specular_red / 255.0,
(unsigned int) vertex.specular_green / 255.0 ,
(unsigned int) vertex.specular_blue / 255.0, 1.0 ) );
if (fields & TEXCOORD)
_texcoord->push_back(osg::Vec2(vertex.texture_u,vertex.texture_v));
}
}
@@ -291,13 +311,47 @@ osg::Node* VertexData::readPlyFile( const char* filename, const bool ignoreColor
MESHINFO << filename << ": " << nPlyElems << " elements, file type = "
<< fileType << ", version = " << version << endl;
#endif
char *textureFile = NULL;
for( int i = 0; i < nComments; i++ )
{
if( equal_strings( comments[i], "modified by flipply" ) )
{
_invertFaces = true;
}
if (strncmp(comments[i], "TextureFile",11)==0)
{
textureFile = comments[i]+12;
char * path = new char[strlen(const_cast<char*>(filename)) + 1 + strlen(comments[i])];
if (textureFile[0] == '\\' || textureFile[0] == '/' || textureFile[1] == ':')
{
// texture filename is absolute
strcpy(path, textureFile);
}
else
{
// texture filename is relative
// add directory of ply file
strcpy(path, const_cast<char*>(filename));
char *pp = path + strlen(path);
while (pp >= path)
{
if (*pp == '\\' || *pp == '/')
{
pp++;
*pp = '\0';
break;
}
pp--;
}
if (pp == path - 1)
{
pp++;
*pp = '\0';
}
strcat(path, textureFile);
}
textureFile = path;
}
}
for( int i = 0; i < nPlyElems; ++i )
@@ -330,10 +384,10 @@ osg::Node* VertexData::readPlyFile( const char* filename, const bool ignoreColor
// if the string is vertex means vertex data is started
if( equal_strings( elemNames[i], "vertex" ) )
{
int fields = NONE;
int fields = NONE;
// determine if the file stores vertex colors
for( int j = 0; j < nProps; ++j )
{
{
// if the string have the red means color info is there
if( equal_strings( props[j]->name, "x" ) )
fields |= XYZ;
@@ -347,15 +401,19 @@ osg::Node* VertexData::readPlyFile( const char* filename, const bool ignoreColor
fields |= AMBIENT;
if( equal_strings( props[j]->name, "diffuse_red" ) )
fields |= DIFFUSE;
if( equal_strings( props[j]->name, "specular_red" ) )
if (equal_strings(props[j]->name, "specular_red"))
fields |= SPECULAR;
}
if (equal_strings(props[j]->name, "texture_u"))
fields |= TEXCOORD;
if (equal_strings(props[j]->name, "texture_v"))
fields |= TEXCOORD;
}
if( ignoreColors )
{
fields &= ~(XYZ | NORMALS);
MESHINFO << "Colors in PLY file ignored per request." << endl;
}
{
fields &= ~(XYZ | NORMALS);
MESHINFO << "Colors in PLY file ignored per request." << endl;
}
try {
// Read vertices and store in a std::vector array
@@ -363,7 +421,7 @@ osg::Node* VertexData::readPlyFile( const char* filename, const bool ignoreColor
// Check whether all vertices are loaded or not
MESHASSERT( _vertices->size() == static_cast< size_t >( nElems ) );
// Check if all the optional elements were read or not
// Check if all the optional elements were read or not
if( fields & NORMALS )
{
MESHASSERT( _normals->size() == static_cast< size_t >( nElems ) );
@@ -380,9 +438,13 @@ osg::Node* VertexData::readPlyFile( const char* filename, const bool ignoreColor
{
MESHASSERT( _diffuse->size() == static_cast< size_t >( nElems ) );
}
if( fields & SPECULAR )
if (fields & SPECULAR)
{
MESHASSERT( _specular->size() == static_cast< size_t >( nElems ) );
MESHASSERT(_specular->size() == static_cast< size_t >(nElems));
}
if (fields & TEXCOORD)
{
MESHASSERT(_texcoord->size() == static_cast< size_t >(nElems));
}
result = true;
@@ -462,9 +524,9 @@ osg::Node* VertexData::readPlyFile( const char* filename, const bool ignoreColor
geom->addPrimitiveSet(new osg::DrawArrays(GL_POINTS, 0, _vertices->size()));
// Apply the colours to the model; at the moment this is a
// kludge because we only use one kind and apply them all the
// same way. Also, the priority order is completely arbitrary
// Apply the colours to the model; at the moment this is a
// kludge because we only use one kind and apply them all the
// same way. Also, the priority order is completely arbitrary
if(_colors.valid())
{
@@ -478,10 +540,14 @@ osg::Node* VertexData::readPlyFile( const char* filename, const bool ignoreColor
{
geom->setColorArray(_diffuse.get(), osg::Array::BIND_PER_VERTEX );
}
else if(_specular.valid())
else if(_specular.valid())
{
geom->setColorArray(_specular.get(), osg::Array::BIND_PER_VERTEX );
}
else if (_texcoord.valid())
{
geom->setTexCoordArray(0, _texcoord);
}
// If the model has normals, add them to the geometry
if(_normals.valid())
@@ -497,11 +563,26 @@ osg::Node* VertexData::readPlyFile( const char* filename, const bool ignoreColor
// set flage true to activate the vertex buffer object of drawable
geom->setUseVertexBufferObjects(true);
osg::Image *image = NULL;
if (textureFile && (image = osgDB::readImageFile(textureFile)) != NULL)
{
osg::Texture2D *texture = new osg::Texture2D;
texture->setImage(image);
texture->setResizeNonPowerOfTwoHint(false);
osg::TexEnv *texenv = new osg::TexEnv;
texenv->setMode(osg::TexEnv::REPLACE);
osg::StateSet *stateset = geom->getOrCreateStateSet();
stateset->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);
stateset->setTextureAttribute(0, texenv);
delete[] textureFile;
}
osg::Geode* geode = new osg::Geode;
geode->addDrawable(geom);
return geode;
}
}
return NULL;
}

View File

@@ -55,7 +55,8 @@ namespace ply
AMBIENT = 8,
DIFFUSE = 16,
SPECULAR = 32,
RGBA = 64
RGBA = 64,
TEXCOORD = 128
};
// Function which reads all the vertices and colors if color info is
@@ -75,6 +76,7 @@ namespace ply
osg::ref_ptr<osg::Vec4Array> _ambient;
osg::ref_ptr<osg::Vec4Array> _diffuse;
osg::ref_ptr<osg::Vec4Array> _specular;
osg::ref_ptr<osg::Vec2Array> _texcoord;
// Normals in osg format
osg::ref_ptr<osg::Vec3Array> _normals;

View File

@@ -5,7 +5,7 @@ IF(OSG_CPP_EXCEPTIONS_AVAILABLE)
ENDIF()
SET(TARGET_SRC ReaderWriterPNG.cpp )
SET(TARGET_LIBRARIES_VARS PNG_LIBRARY ZLIB_LIBRARY )
SET(TARGET_LIBRARIES_VARS PNG_LIBRARY ZLIB_LIBRARIES )
#### end var setup ###

View File

@@ -174,6 +174,22 @@ static int getInt16(unsigned char *ptr)
return res | (tmp<<8);
}
static int getInt24(unsigned char *ptr)
{
int temp1 = ptr[0];
int temp2 = ptr[1];
int temp3 = ptr[2];
return temp1 | (temp2 << 8) | (temp3 << 16);
}
static int getInt32(unsigned char *ptr)
{
int temp1 = ptr[0];
int temp2 = ptr[1];
int temp3 = ptr[2];
int temp4 = ptr[3];
return temp1 | (temp2 << 8) | (temp3 << 16) | (temp4 << 24);
}
/* */
/* decode a new rle packet */
@@ -257,6 +273,7 @@ int *numComponents_ret)
int flags;
int format;
unsigned char *colormap;
int colormapLen;
int indexsize;
int rleIsCompressed;
int rleRemaining;
@@ -283,10 +300,10 @@ int *numComponents_ret)
flags = header[17];
/* check for reasonable values in case this is not a tga file */
if ((type != 2 && type != 10) ||
if ((type != 1 && type != 2 && type != 10) ||
(width < 0 || width > 4096) ||
(height < 0 || height > 4096) ||
(depth < 2 || depth > 4))
(depth < 1 || depth > 4))
{
tgaerror = ERR_UNSUPPORTED;
return NULL;
@@ -298,18 +315,28 @@ int *numComponents_ret)
colormap = NULL;
if (header[1] == 1) /* there is a colormap */
{
int len = getInt16(&header[5]);
colormapLen = getInt16(&header[5]);
indexsize = header[7]>>3;
colormap = new unsigned char [len*indexsize];
fin.read((char*)colormap,len*indexsize);
}
colormap = new unsigned char [colormapLen*indexsize];
fin.read((char*)colormap,colormapLen*indexsize);
if (depth == 2) /* 16 bits */
{
if (flags & 1) format = 4;
else format = 3;
if (indexsize == 2) /* 16 bits */
{
if (flags & 1) format = 4;
else format = 3;
}
else
format = indexsize;
}
else
{
if (depth == 2) /* 16 bits */
{
if (flags & 1) format = 4;
else format = 3;
}
else format = depth;
}
else format = depth;
/* SoDebugError::postInfo("simage_tga_load", "TARGA file: %d %d %d %d %d\n", */
/* type, width, height, depth, format); */
@@ -331,6 +358,57 @@ int *numComponents_ret)
switch(type)
{
case 1: /* colormap, uncompressed */
{
unsigned char * formattedMap = new unsigned char[colormapLen * format];
for (int i = 0; i < colormapLen; i++)
{
convert_data(colormap, formattedMap, i, indexsize, format);
}
int x, y;
for (y = 0; y < height; y++)
{
fin.read((char*)linebuf, width*depth);
if (fin.gcount() != (std::streamsize) (width*depth))
{
tgaerror = ERR_READ;
break;
}
for (x = 0; x < width; x++)
{
int index;
switch (depth)
{
case 1:
index = linebuf[x];
break;
case 2:
index = getInt16(linebuf + x * 2);
break;
case 3:
index = getInt24(linebuf + x * 3);
break;
case 4:
index = getInt32(linebuf + x * 4);
break;
default:
tgaerror = ERR_UNSUPPORTED;
break;
}
int adjustedX = bLeftToRight ? x : (width - 1) - x;
for (int i = 0; i < format; i++)
(dest + adjustedX * format)[i] = (formattedMap + index * format)[i];
}
dest += lineoffset;
}
if (formattedMap)
delete[] formattedMap;
}
break;
case 2: /* RGB, uncompressed */
{
int x, y;

View File

@@ -14,7 +14,7 @@
* OpenSceneGraph loader for Terrapage format database
* by Boris Bralo 2002
*
* based on/modifed sgl (Scene Graph Library) loader by Bryan Walsh
* based on/modified sgl (Scene Graph Library) loader by Bryan Walsh
*
* This loader is based on/modified from Terrain Experts Performer Loader,
* and was ported to SGL by Bryan Walsh / bryanw at earthlink dot net

View File

@@ -14,7 +14,7 @@
* OpenSceneGraph loader for Terrapage format database
* by Boris Bralo 2002
*
* based on/modifed sgl (Scene Graph Library) loader by Bryan Walsh
* based on/modified sgl (Scene Graph Library) loader by Bryan Walsh
*
* This loader is based on/modified from Terrain Experts Performer Loader,
* and was ported to SGL by Bryan Walsh / bryanw at earthlink dot net

View File

@@ -15,7 +15,7 @@
* OpenSceneGraph loader for Terrapage format database
* by Boris Bralo 2002
*
* based on/modifed sgl (Scene Graph Library) loader by Bryan Walsh
* based on/modified sgl (Scene Graph Library) loader by Bryan Walsh
*
* This loader is based on/modified from Terrain Experts Performer Loader,
* and was ported to SGL by Bryan Walsh / bryanw at earthlink dot net

View File

@@ -14,7 +14,7 @@
* OpenSceneGraph loader for Terrapage format database
* by Boris Bralo 2002
*
* based on/modifed sgl (Scene Graph Library) loader by Bryan Walsh
* based on/modified sgl (Scene Graph Library) loader by Bryan Walsh
*
* This loader is based on/modified from Terrain Experts Performer Loader,
* and was ported to SGL by Bryan Walsh / bryanw at earthlink dot net

View File

@@ -15,7 +15,7 @@
* OpenSceneGraph loader for Terrapage format database
* by Boris Bralo 2002
*
* based on/modifed sgl (Scene Graph Library) loader by Bryan Walsh
* based on/modified sgl (Scene Graph Library) loader by Bryan Walsh
*
* This loader is based on/modified from Terrain Experts Performer Loader,
* and was ported to SGL by Bryan Walsh / bryanw at earthlink dot net

View File

@@ -161,7 +161,7 @@ osg::Group *TXPParser::parseScene(
_root->accept(lv);
//modified by Brad Anderegg May-27-08
//running the optimizer on the terrain fixes some major preformance issues, unfortunately the texture atlas builder seems to get messed up
//running the optimizer on the terrain fixes some major performance issues, unfortunately the texture atlas builder seems to get messed up
//on some of the textures (usually around buildings) and the tri stripper seems to occasionally crash and also mess up the indices on certain buildings.
osgUtil::Optimizer opt;
opt.optimize(_root.get(), (osgUtil::Optimizer::ALL_OPTIMIZATIONS ^ osgUtil::Optimizer::TEXTURE_ATLAS_BUILDER) ^ osgUtil::Optimizer::TRISTRIP_GEOMETRY);
@@ -1433,7 +1433,7 @@ void* geomRead::Parse(trpgToken /*tok*/,trpgReadBuffer &buf)
if (geometry.valid() && top)
{
//modifed by Brad Anderegg on May-27-08
//modified by Brad Anderegg on May-27-08
//using display lists actually increases our framerate by
//a fair amount, on certain laptops it increased by as much as 1000%
geometry->setUseDisplayList(true);

View File

@@ -14,7 +14,7 @@
* OpenSceneGraph loader for Terrapage format database
* by Boris Bralo 2002
*
* based on/modifed sgl (Scene Graph Library) loader by Bryan Walsh
* based on/modified sgl (Scene Graph Library) loader by Bryan Walsh
*
* This loader is based on/modified from Terrain Experts Performer Loader,
* and was ported to SGL by Bryan Walsh / bryanw at earthlink dot net

View File

@@ -15,7 +15,7 @@
* OpenSceneGraph loader for Terrapage format database
* by Boris Bralo 2002
*
* based on/modifed sgl (Scene Graph Library) loader by Bryan Walsh
* based on/modified sgl (Scene Graph Library) loader by Bryan Walsh
*
* This loader is based on/modified from Terrain Experts Performer Loader,
* and was ported to SGL by Bryan Walsh / bryanw at earthlink dot net

View File

@@ -3112,7 +3112,7 @@ public:
// Set the text alignment. See GetAlignmentType() for more information.
void SetAlignment(AlignmentType);
/* Return the alignement type. This controls the alignement of the text
/* Return the alignment type. This controls the alignment of the text
with respect to the label geometry.
*/
AlignmentType GetAlignment(void) const;

View File

@@ -562,7 +562,7 @@ TX_EXDECL class TX_CLDECL trpgCheckable {
public:
trpgCheckable(void);
virtual ~trpgCheckable(void);
// Returns the state of the valid flag, or can be overriden by a subclass to do a more complex check.
// Returns the state of the valid flag, or can be overridden by a subclass to do a more complex check.
bool isValid(void) const;
virtual TeAttrHdl GetHandle() const {
@@ -606,7 +606,7 @@ public:
/* The Write method is a virtual that must be filled in by the subclass.
It takes a trpgWriteBuffer and should return true on success. */
virtual bool Write(trpgWriteBuffer &) = 0;
/* The Read method should be overriden by a subclass. It should read
/* The Read method should be overridden by a subclass. It should read
the contents of the given trpgReadBuffer up to the current limit
into itself. It must return true on success. */
virtual bool Read(trpgReadBuffer &) { return false;};

View File

@@ -338,7 +338,7 @@ bool trpgr_Archive::ReadHeader(bool readAllBlocks)
// Read Tile
// Read a tile into a read buffer
// For version 2.1 only tile with lod=0 are stored in the tile table, so an
// error will be returned if you try to use the table with a differrent lod.
// error will be returned if you try to use the table with a different lod.
bool trpgr_Archive::ReadTile(uint32 x,uint32 y,uint32 lod,trpgMemReadBuffer &buf)
{
if (!isValid())

View File

@@ -4,7 +4,7 @@ INCLUDE_DIRECTORIES(${LIBVNCSERVER_INCLUDE_DIR})
SET(TARGET_EXTERNAL_LIBRARIES
${LIBVNCCLIENT_LIBRARY}
${ZLIB_LIBRARY}
${ZLIB_LIBRARIES}
${JPEG_LIBRARY} )
SET(TARGET_ADDED_LIBRARIES osgWidget )

View File

@@ -199,7 +199,7 @@ static rfbBool rfbInitConnection(rfbClient* client)
return TRUE;
}
void LibVncImage::passwordCheck(rfbClient* client,const char* encryptedPassWord,int len)
void LibVncImage::passwordCheck(rfbClient* /*client*/,const char* /*encryptedPassWord*/,int /*len*/)
{
OSG_NOTICE<<"LibVncImage::passwordCheck"<<std::endl;
}
@@ -319,7 +319,7 @@ rfbBool LibVncImage::resizeImage(rfbClient* client)
return TRUE;
}
void LibVncImage::updateImage(rfbClient* client,int x,int y,int w,int h)
void LibVncImage::updateImage(rfbClient* client, int /*x*/, int /*y*/, int /*w*/, int /*h*/)
{
LibVncImage* image = (LibVncImage*)(rfbClientGetClientData(client, 0));

View File

@@ -25,7 +25,7 @@ IF (WIN32)
OPENVRML_LIBRARY
JPEG_LIBRARY
PNG_LIBRARY
ZLIB_LIBRARY)
ZLIB_LIBRARIES)
SET(TARGET_EXTERNAL_LIBRARIES
Ws2_32.lib)
ELSE()

View File

@@ -294,7 +294,7 @@ void LightSpacePerspectiveShadowMapAlgorithm::operator()
#if 1
// Original LiSPSM Paper suggests that algorithm should work for all light types:
// infinte directional, omnidirectional and spot types may be treated as directional
// infinite directional, omnidirectional and spot types may be treated as directional
// as all computations are performed in post projection light space.
// Frankly, I have my doubts if their error analysis and methodology still works
// in non directional lights post projective space. But since I can't prove it doesn't,

View File

@@ -138,7 +138,7 @@ void MinimalShadowMap::ViewData::aimShadowCastingCamera
if( up.length2() <= 0 )
{
// This is extra step (not really needed but helpful in debuging)
// This is extra step (not really needed but helpful in debugging)
// Compute such lightUp vector that shadow cam is intuitively aligned with eye
// We compute this vector on -ZY view plane, perpendicular to light direction
// Matrix m = ViewToWorld
@@ -234,7 +234,7 @@ void MinimalShadowMap::ViewData::frameShadowCastingCamera
if( bb.valid() )
trimProjection( cameraShadow->getProjectionMatrix(), bb, 1|2|4|8|16|32 );
///// Debuging stuff //////////////////////////////////////////////////////////
///// Debugging stuff //////////////////////////////////////////////////////////
setDebugPolytope( "scene", _sceneReceivingShadowPolytope, osg::Vec4(0,1,0,1) );

View File

@@ -21,12 +21,14 @@ namespace osgText
Text3D::Text3D():
_renderMode(PER_GLYPH)
{
_glyphNormalized = true;
}
Text3D::Text3D(const Text3D & text3D, const osg::CopyOp & copyop):
osgText::TextBase(text3D, copyop),
_renderMode(text3D._renderMode)
{
_glyphNormalized = text3D._glyphNormalized;
computeGlyphRepresentation();
}
@@ -270,7 +272,7 @@ void Text3D::computeGlyphRepresentation()
osg::Vec2 endOfLine_coords(cursor);
String::iterator endOfLine_itr = computeLastCharacterOnLine(endOfLine_coords, itr,_text.end());
// ** position the cursor function to the Layout and the alignement
// ** position the cursor function to the Layout and the alignment
TextBase::positionCursor(endOfLine_coords, cursor, (unsigned int) (endOfLine_itr - startOfLine_itr));

View File

@@ -47,7 +47,8 @@ TextBase::TextBase():
_textBBMargin(0.0f),
_textBBColor(0.0, 0.0, 0.0, 0.5),
_kerningType(KERNING_DEFAULT),
_lineCount(0)
_lineCount(0),
_glyphNormalized(false)
{
setStateSet(Font::getDefaultFont()->getStateSet());
setUseDisplayList(false);
@@ -78,7 +79,8 @@ TextBase::TextBase(const TextBase& textBase,const osg::CopyOp& copyop):
_textBBMargin(textBase._textBBMargin),
_textBBColor(textBase._textBBColor),
_kerningType(textBase._kerningType),
_lineCount(textBase._lineCount)
_lineCount(textBase._lineCount),
_glyphNormalized(textBase._glyphNormalized)
{
initArraysAndBuffers();
}
@@ -537,6 +539,12 @@ bool TextBase::computeMatrix(osg::Matrix& matrix, osg::State* state) const
if (pixelSizeHori == 0.0f)
pixelSizeHori= 1.0f;
if (_glyphNormalized)
{
osg::Vec3 scaleVec(_characterHeight/getCharacterAspectRatio(), _characterHeight, _characterHeight);
matrix.postMultScale(scaleVec);
}
if (_characterSizeMode==SCREEN_COORDS)
{
float scale_font_vert=_characterHeight/pixelSizeVert;
@@ -544,12 +552,12 @@ bool TextBase::computeMatrix(osg::Matrix& matrix, osg::State* state) const
if (P10<0)
scale_font_vert=-scale_font_vert;
matrix.postMultScale(osg::Vec3f(scale_font_hori, scale_font_vert,1.0f));
matrix.postMultScale(osg::Vec3f(scale_font_hori, scale_font_vert, scale_font_hori));
}
else if (pixelSizeVert>getFontHeight())
{
float scale_font = getFontHeight()/pixelSizeVert;
matrix.postMultScale(osg::Vec3f(scale_font, scale_font,1.0f));
matrix.postMultScale(osg::Vec3f(scale_font, scale_font, scale_font));
}
}
@@ -560,17 +568,29 @@ bool TextBase::computeMatrix(osg::Matrix& matrix, osg::State* state) const
}
matrix.postMultTranslate(_position);
}
else if (!_rotation.zeroRotation())
{
matrix.makeRotate(_rotation);
matrix.preMultTranslate(-_offset);
matrix.makeTranslate(-_offset);
if (_glyphNormalized)
{
osg::Vec3 scaleVec(_characterHeight/getCharacterAspectRatio(), _characterHeight, _characterHeight);
matrix.postMultScale(scaleVec);
}
matrix.postMultRotate(_rotation);
matrix.postMultTranslate(_position);
// OSG_NOTICE<<"New Need to rotate "<<matrix<<std::endl;
}
else
{
matrix.makeTranslate(_position-_offset);
matrix.makeTranslate(-_offset);
if (_glyphNormalized)
{
osg::Vec3 scaleVec(_characterHeight/getCharacterAspectRatio(), _characterHeight, _characterHeight);
matrix.postMultScale(scaleVec);
}
matrix.postMultTranslate(_position);
}
if (_matrix!=matrix)

View File

@@ -332,7 +332,7 @@ double IncrementalCompileOperation::CompileList::estimatedTimeForCompile(Compile
{
double estimateTime = 0.0;
for(CompileOps::const_iterator itr = _compileOps.begin();
itr != _compileOps.begin();
itr != _compileOps.end();
++itr)
{
estimateTime += (*itr)->estimatedTimeForCompile(compileInfo);

View File

@@ -468,21 +468,21 @@ namespace PlaneIntersectorUtils
if (numOnPlane==3)
{
// triangle lives wholy in the plane
// triangle lives wholly in the plane
OSG_NOTICE<<"3"<<std::endl;
return;
}
if (numOnPlane==2)
{
// one edge lives wholy in the plane
// one edge lives wholly in the plane
OSG_NOTICE<<"2"<<std::endl;
return;
}
if (numOnPlane==1)
{
// one point lives wholy in the plane
// one point lives wholly in the plane
OSG_NOTICE<<"1"<<std::endl;
return;
}

View File

@@ -1342,40 +1342,42 @@ void RenderStage::drawImplementation(osg::RenderInfo& renderInfo,RenderLeaf*& pr
if (_colorMask.valid()) _colorMask->apply(state);
else glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);
if (_clearMask & GL_COLOR_BUFFER_BIT)
if (_clearMask != 0)
{
glClearColor( _clearColor[0], _clearColor[1], _clearColor[2], _clearColor[3]);
}
if (_clearMask & GL_COLOR_BUFFER_BIT)
{
glClearColor( _clearColor[0], _clearColor[1], _clearColor[2], _clearColor[3]);
}
if (_clearMask & GL_DEPTH_BUFFER_BIT)
{
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE)
glClearDepth( _clearDepth);
#else
glClearDepthf( _clearDepth);
if (_clearMask & GL_DEPTH_BUFFER_BIT)
{
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE)
glClearDepth( _clearDepth);
#else
glClearDepthf( _clearDepth);
#endif
glDepthMask ( GL_TRUE );
state.haveAppliedAttribute( osg::StateAttribute::DEPTH );
}
if (_clearMask & GL_STENCIL_BUFFER_BIT)
{
glClearStencil( _clearStencil);
glStencilMask ( ~0u );
state.haveAppliedAttribute( osg::StateAttribute::STENCIL );
}
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
if (_clearMask & GL_ACCUM_BUFFER_BIT)
{
glClearAccum( _clearAccum[0], _clearAccum[1], _clearAccum[2], _clearAccum[3]);
}
#endif
glDepthMask ( GL_TRUE );
state.haveAppliedAttribute( osg::StateAttribute::DEPTH );
glClear( _clearMask );
}
if (_clearMask & GL_STENCIL_BUFFER_BIT)
{
glClearStencil( _clearStencil);
glStencilMask ( ~0u );
state.haveAppliedAttribute( osg::StateAttribute::STENCIL );
}
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GLES3_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
if (_clearMask & GL_ACCUM_BUFFER_BIT)
{
glClearAccum( _clearAccum[0], _clearAccum[1], _clearAccum[2], _clearAccum[3]);
}
#endif
glClear( _clearMask );
#ifdef USE_SCISSOR_TEST
glDisable( GL_SCISSOR_TEST );
#endif

View File

@@ -173,14 +173,23 @@ ELSE()
# X11 for everybody else
INCLUDE(FindPkgConfig OPTIONAL)
IF(PKG_CONFIG_FOUND)
PKG_CHECK_MODULES(XRANDR xrandr)
IF(XRANDR_FOUND)
OPTION(OSGVIEWER_USE_XRANDR "Set to ON to enable Xrandr support for GraphicsWindowX11." ON)
ELSE()
SET(OSGVIEWER_USE_XRANDR OFF)
ENDIF()
PKG_CHECK_MODULES(XINERAMA xinerama)
IF(XINERAMA_FOUND)
SET(OSGVIEWER_USE_XINERAMA ON)
ELSE()
SET(OSGVIEWER_USE_XINERAMA OFF)
ENDIF()
ELSE()
SET(OSGVIEWER_USE_XRANDR OFF)
SET(OSGVIEWER_USE_XINERAMA OFF)
ENDIF()
SET(TARGET_H_NO_MODULE_INSTALL
@@ -205,6 +214,13 @@ ELSE()
ENDIF()
ENDIF()
IF(OSGVIEWER_USE_XINERAMA)
ADD_DEFINITIONS(-DOSGVIEWER_USE_XINERAMA)
SET(LIB_PRIVATE_HEADERS ${LIB_PRIVATE_HEADERS} ${XINERAMA_INCLUDE_DIRS} )
SET(LIB_EXTRA_LIBS -lXinerama ${LIB_EXTRA_LIBS})
ENDIF()
# X11 on Apple requires X11 library plus OpenGL linking hack on Leopard
IF(APPLE)
# hack for finding the iphone opengl es lib
IF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR)

View File

@@ -886,7 +886,7 @@ bool GraphicsWindowIOS::realizeImplementation()
OSG_DEBUG << "GraphicsWindowIOS::realizeImplementation: INFO: Created UIWindow with bounds '" << window_bounds.size.width << ", " << window_bounds.size.height << "' (points)." << std::endl;
//if the user has requested a differnet screenNum from default 0 get the UIScreen object and
//if the user has requested a different screenNum from default 0 get the UIScreen object and
//apply to our window (this is for IPad external screens, I don't have one, so I've no idea if it works)
//I'm also not sure if we should apply this to external windows also?
if(_traits->screenNum > 0 && screen != nil)

View File

@@ -2556,12 +2556,37 @@ void GraphicsWindowWin32::transformMouseXY( float& x, float& y )
LRESULT GraphicsWindowWin32::handleNativeWindowingEvent( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
if ((GetMessageExtraInfo() & MOUSEEVENTF_FROMTOUCH) == MOUSEEVENTF_FROMTOUCH) return TRUE;
//!@todo adapt windows event time to osgGA event queue time for better resolution
double eventTime = getEventQueue()->getTime();
_timeOfLastCheckEvents = eventTime;
if ((GetMessageExtraInfo() & MOUSEEVENTF_FROMTOUCH) == MOUSEEVENTF_FROMTOUCH)
{
switch(uMsg)
{
/////////////////
case WM_SYSCOMMAND:
/////////////////
{
UINT cmd = LOWORD(wParam);
if (cmd == SC_CLOSE)
getEventQueue()->closeWindow(eventTime);
break;
}
/////////////////
case WM_NCLBUTTONUP:
/////////////////
{
UINT cmd = LOWORD(wParam);
if (cmd == HTCLOSE)
getEventQueue()->closeWindow(eventTime);
break;
}
default: break;
}
return TRUE;
}
switch(uMsg)
{
// Wojtek Lewandowski 2010-09-28:
@@ -2904,14 +2929,6 @@ LRESULT GraphicsWindowWin32::handleNativeWindowingEvent( HWND hwnd, UINT uMsg, W
osg_event->addTouchPoint( ti[i].dwID, osgGA::GUIEventAdapter::TOUCH_BEGAN, pt.x, pt.y);
}
}
else if(ti[i].dwFlags & TOUCHEVENTF_MOVE)
{
if (!osg_event) {
osg_event = getEventQueue()->touchMoved( ti[i].dwID, osgGA::GUIEventAdapter::TOUCH_MOVED, pt.x, pt.y);
} else {
osg_event->addTouchPoint( ti[i].dwID, osgGA::GUIEventAdapter::TOUCH_MOVED, pt.x, pt.y);
}
}
else if(ti[i].dwFlags & TOUCHEVENTF_UP)
{
// No double tap detection with RAW TOUCH Events, sorry.
@@ -2921,6 +2938,14 @@ LRESULT GraphicsWindowWin32::handleNativeWindowingEvent( HWND hwnd, UINT uMsg, W
osg_event->addTouchPoint( ti[i].dwID, osgGA::GUIEventAdapter::TOUCH_ENDED, pt.x, pt.y);
}
}
else if(ti[i].dwFlags & TOUCHEVENTF_MOVE)
{
if (!osg_event) {
osg_event = getEventQueue()->touchMoved( ti[i].dwID, osgGA::GUIEventAdapter::TOUCH_MOVED, pt.x, pt.y);
} else {
osg_event->addTouchPoint( ti[i].dwID, osgGA::GUIEventAdapter::TOUCH_MOVED, pt.x, pt.y);
}
}
}
}
if (closeTouchInputHandleFunc)
@@ -2934,7 +2959,7 @@ LRESULT GraphicsWindowWin32::handleNativeWindowingEvent( HWND hwnd, UINT uMsg, W
/* TOUCH inputs for Win8 and later */
/************************************************************************/
// Note by Riccardo Corsi, 2017-03-16
// Currently only handle the PEN input which is not handled nicely by the
// Currently only handle the PEN input which is not handled nicely by the
// WM_TOUCH framework.
// At the moment the PEN is mapped to the mouse, emulating LEFT button click.
// WM_POINTER* messages could entirely replace the WM_TOUCH framework,
@@ -2946,7 +2971,7 @@ LRESULT GraphicsWindowWin32::handleNativeWindowingEvent( HWND hwnd, UINT uMsg, W
case WM_POINTERDOWN:
/////
{
UINT32 pointerId = GET_POINTERID_WPARAM(wParam);
UINT32 pointerId = GET_POINTERID_WPARAM(wParam);
POINTER_INPUT_TYPE pointerType = PT_POINTER;
// check pointer type
@@ -2960,13 +2985,13 @@ LRESULT GraphicsWindowWin32::handleNativeWindowingEvent( HWND hwnd, UINT uMsg, W
pt.x = GET_X_LPARAM(lParam);
pt.y = GET_Y_LPARAM(lParam);
ScreenToClient(hwnd, &pt);
getEventQueue()->mouseButtonPress(pt.x, pt.y, osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON);
}
// call default implementation to fallback on WM_TOUCH
else
{
if (_ownsWindow)
if (_ownsWindow)
return ::DefWindowProc(hwnd, uMsg, wParam, lParam);
}
}

View File

@@ -38,7 +38,12 @@
#include <X11/extensions/Xrandr.h>
#endif
#ifdef OSGVIEWER_USE_XINERAMA
#include <X11/extensions/Xinerama.h>
#endif
#include <unistd.h>
#include <cstdlib>
using namespace osgViewer;
@@ -322,13 +327,10 @@ bool GraphicsWindowX11::createVisualInfo()
typedef std::vector<int> Attributes;
Attributes attributes;
attributes.push_back(GLX_USE_GL);
attributes.push_back(GLX_RENDER_TYPE); attributes.push_back(GLX_RGBA_BIT);
attributes.push_back(GLX_RGBA);
if (_traits->doubleBuffer) attributes.push_back(GLX_DOUBLEBUFFER);
if (_traits->quadBufferStereo) attributes.push_back(GLX_STEREO);
if (_traits->doubleBuffer) { attributes.push_back(GLX_DOUBLEBUFFER); attributes.push_back(True); }
if (_traits->quadBufferStereo) { attributes.push_back(GLX_STEREO); attributes.push_back(True); }
attributes.push_back(GLX_RED_SIZE); attributes.push_back(_traits->red);
attributes.push_back(GLX_GREEN_SIZE); attributes.push_back(_traits->green);
@@ -336,14 +338,11 @@ bool GraphicsWindowX11::createVisualInfo()
attributes.push_back(GLX_DEPTH_SIZE); attributes.push_back(_traits->depth);
if (_traits->alpha) { attributes.push_back(GLX_ALPHA_SIZE); attributes.push_back(_traits->alpha); }
if (_traits->stencil) { attributes.push_back(GLX_STENCIL_SIZE); attributes.push_back(_traits->stencil); }
#if defined(GLX_SAMPLE_BUFFERS) && defined (GLX_SAMPLES)
if (_traits->sampleBuffers) { attributes.push_back(GLX_SAMPLE_BUFFERS); attributes.push_back(_traits->sampleBuffers); }
if (_traits->samples) { attributes.push_back(GLX_SAMPLES); attributes.push_back(_traits->samples); }
#endif
// TODO
// GLX_AUX_BUFFERS
@@ -352,7 +351,16 @@ bool GraphicsWindowX11::createVisualInfo()
attributes.push_back(None);
_visualInfo = glXChooseVisual( _display, _traits->screenNum, &(attributes.front()) );
int numFbConfigs = 0;
GLXFBConfig* fbConfigs = glXChooseFBConfig(_display, _traits->screenNum, attributes.data(), &numFbConfigs);
if (numFbConfigs > 0)
{
_fbConfig = fbConfigs[0];
}
XFree(fbConfigs);
_visualInfo = glXGetVisualFromFBConfig(_display, _fbConfig);
#endif
}
@@ -382,23 +390,95 @@ bool GraphicsWindowX11::checkAndSendEventFullScreenIfNeeded(Display* display, in
Atom netWMStateAtom = XInternAtom(display, "_NET_WM_STATE", True);
Atom netWMStateFullscreenAtom = XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", True);
OSG_NOTICE<<"GraphicsWindowX11::checkAndSendEventFullScreenIfNeeded()"<<std::endl;
if (netWMStateAtom != None && netWMStateFullscreenAtom != None)
{
XEvent xev;
xev.xclient.type = ClientMessage;
xev.xclient.serial = 0;
xev.xclient.send_event = True;
xev.xclient.window = _window;
xev.xclient.message_type = netWMStateAtom;
xev.xclient.format = 32;
xev.xclient.data.l[0] = isFullScreen ? 1 : 0;
xev.xclient.data.l[1] = netWMStateFullscreenAtom;
xev.xclient.data.l[2] = 0;
// set up full screen
{
XEvent xev;
xev.xclient.type = ClientMessage;
xev.xclient.serial = 0;
xev.xclient.send_event = True;
xev.xclient.window = _window;
xev.xclient.message_type = netWMStateAtom;
xev.xclient.format = 32;
xev.xclient.data.l[0] = isFullScreen ? 1 : 0;
xev.xclient.data.l[1] = netWMStateFullscreenAtom;
xev.xclient.data.l[2] = 0;
XSendEvent(display, RootWindow(display, DefaultScreen(display)),
False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
XSendEvent(display, RootWindow(display, DefaultScreen(display)),
False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
}
#ifdef OSGVIEWER_USE_XINERAMA
// Span all monitors
if( isFullScreen && XineramaIsActive( display ) )
{
int numMonitors;
XineramaScreenInfo* xi = XineramaQueryScreens( display, &numMonitors );
enum {
TopMost,
BottomMost,
LeftMost,
RightMost
};
uint32_t span[4] = { 0, 0, 0, 0 };
int32_t minx = 2147483647; // INT_MAX
int32_t maxx = -2147483648; // INT_MIN
int32_t miny = 2147483647; // INT_MAX
int32_t maxy = -2147483648; // INT_MIN
for( int i = 0; i < numMonitors; i++ )
{
if( xi[i].x_org < minx )
{
span[LeftMost] = xi[i].screen_number;
minx = xi[i].x_org;
}
if( xi[i].x_org > maxx )
{
span[RightMost] = xi[i].screen_number;
maxx = xi[i].x_org;
}
if( xi[i].y_org < miny )
{
span[TopMost] = xi[i].screen_number;
miny = xi[i].y_org;
}
if( xi[i].y_org > maxy )
{
span[BottomMost] = xi[i].screen_number;
maxy = xi[i].y_org;
}
}
XFree(xi);
Atom fullmons = XInternAtom(display, "_NET_WM_FULLSCREEN_MONITORS", True);
if( fullmons != None )
{
XEvent xev;
xev.type = ClientMessage;
xev.xclient.window = _window;
xev.xclient.message_type = fullmons;
xev.xclient.format = 32;
xev.xclient.data.l[0] = span[TopMost];
xev.xclient.data.l[1] = span[BottomMost];
xev.xclient.data.l[2] = span[LeftMost];
xev.xclient.data.l[3] = span[RightMost];
xev.xclient.data.l[4] = 0;
XSendEvent( display, DefaultRootWindow(display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
}
}
#endif
return true;
}
return false;
}
@@ -817,7 +897,58 @@ void GraphicsWindowX11::init()
#else
_context = glXCreateContext( _display, _visualInfo, sharedContext, True );
typedef GLXContext (*glXCreateContextAttribsARBProc)(Display*, GLXFBConfig, GLXContext, Bool, const int*);
const char* glx_str = glXQueryExtensionsString(_display, _traits->screenNum);
std::string glx_string; if (glx_str) glx_string = glx_str;
glXCreateContextAttribsARBProc glXCreateContextAttribsARB = 0;
if (glx_string.find("GLX_ARB_create_context")!=std::string::npos)
{
glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc) glXGetProcAddress((const GLubyte*)"glXCreateContextAttribsARB");
}
bool supportsProfiles = glx_string.find("GLX_ARB_create_context")!=std::string::npos;
if (glXCreateContextAttribsARB)
{
OSG_INFO << "Attempting to create GL context:" << std::endl;
OSG_INFO << " * version: " << _traits->glContextVersion << std::endl;
OSG_INFO << " * context flags: " << _traits->glContextFlags << std::endl;
OSG_INFO << " * profile: " << _traits->glContextProfileMask << std::endl;
std::vector<int> contextAttributes;
std::size_t pos = _traits->glContextVersion.find(".");
int majorVersion = std::atoi(_traits->glContextVersion.substr(0, pos).c_str());
int minorVersion = pos == std::string::npos ? 0 : std::atoi(_traits->glContextVersion.substr(pos + 1).c_str());
contextAttributes.push_back(GLX_CONTEXT_MAJOR_VERSION_ARB);
contextAttributes.push_back(majorVersion);
contextAttributes.push_back(GLX_CONTEXT_MINOR_VERSION_ARB);
contextAttributes.push_back(minorVersion);
// If asking for OpenGL 3.2 or newer we should also specify a profile
float glVersion = static_cast<float>(majorVersion)+static_cast<float>(minorVersion)*0.1f;
if (glVersion>=3.2 && supportsProfiles && _traits->glContextProfileMask != 0)
{
contextAttributes.push_back(GLX_CONTEXT_PROFILE_MASK_ARB);
contextAttributes.push_back(_traits->glContextProfileMask);
}
if (_traits->glContextFlags != 0)
{
contextAttributes.push_back(GLX_CONTEXT_FLAGS_ARB);
contextAttributes.push_back(_traits->glContextFlags);
}
contextAttributes.push_back(None);
_context = glXCreateContextAttribsARB( _display, _fbConfig, sharedContext, True, contextAttributes.data() );
}
else
{
_context = glXCreateContext( _display, _visualInfo, sharedContext, True );
}
if (!_context)
{
@@ -1328,6 +1459,7 @@ bool GraphicsWindowX11::checkEvents()
bool isModifier = keyMapGetKey(modMap, key);
if (!isModifier) forceKey(key, eventTime, false);
}
needNewWindowSize = true;
// release modifier keys
for (unsigned int key = 8; key < 256; key++)
@@ -1367,6 +1499,7 @@ bool GraphicsWindowX11::checkEvents()
bool isPressed = keyMapGetKey(keyMap, key);
if (!isPressed) forceKey(key, eventTime, false);
}
needNewWindowSize = true;
// press/release modifier keys
for (unsigned int key = 8; key < 256; key++)

View File

@@ -767,12 +767,6 @@ struct BlockDrawCallback : public virtual osg::Drawable::DrawCallback
vertices->dirty();
osg::DrawArrays* drawArrays = dynamic_cast<osg::DrawArrays*>(geom->getPrimitiveSet(0));
if(drawArrays)
{
drawArrays->setCount(vi);
}
drawable->drawImplementation(renderInfo);
}

View File

@@ -0,0 +1,86 @@
#include <osg/BufferIndexBinding>
#include <osg/BufferObject>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
#define ADD_GLUINT_SERIALIZER(PROP, DEF) \
wrapper->addSerializer( new osgDB::PropByValSerializer< MyClass, GLuint >( \
#PROP, ((unsigned int)(DEF)), &MyClass::get##PROP, &MyClass::set##PROP), osgDB::BaseSerializer::RW_UINT )
#define GLsizei_ptrSERIALIZER(TYPE,XXX) \
static bool check##XXX( const TYPE& node )\
{ return node.get##XXX()>0;}\
static bool read##XXX( osgDB::InputStream& is, TYPE& node )\
{\
unsigned int size = 0; is >> size ; node.set##XXX(size); return true;\
}\
static bool write##XXX( osgDB::OutputStream& os, const TYPE& node )\
{\
unsigned int size = node.get##XXX(); os << size << std::endl; return true;\
}
GLsizei_ptrSERIALIZER(osg::BufferIndexBinding,Size)
GLsizei_ptrSERIALIZER(osg::BufferIndexBinding,Offset)
namespace wrap_osgBufferIndexBinding
{
REGISTER_OBJECT_WRAPPER( BufferIndexBinding,
/*new osg::BufferIndexBinding*/NULL,
osg::BufferIndexBinding,
"osg::Object osg::StateAttribute osg::BufferIndexBinding" )
{
ADD_GLENUM_SERIALIZER( Target,GLenum, GL_BUFFER); // _target
ADD_OBJECT_SERIALIZER( BufferData, osg::BufferData, NULL ); // _bufferObject
ADD_GLUINT_SERIALIZER( Index, 0); // _index
ADD_USER_SERIALIZER(Size);
ADD_USER_SERIALIZER(Offset);
}
}
namespace wrap_osgUniformBufferBinding
{
REGISTER_OBJECT_WRAPPER( UniformBufferBinding,
new osg::UniformBufferBinding,
osg::UniformBufferBinding,
"osg::Object osg::StateAttribute osg::BufferIndexBinding osg::UniformBufferBinding" )
{
}
}
namespace wrap_osgTransformFeedbackBufferBinding
{
REGISTER_OBJECT_WRAPPER( TransformFeedbackBufferBinding,
new osg::TransformFeedbackBufferBinding,
osg::TransformFeedbackBufferBinding,
"osg::Object osg::StateAttribute osg::BufferIndexBinding osg::TransformFeedbackBufferBinding" )
{
}
}
namespace wrap_osgAtomicCounterBufferBinding
{
REGISTER_OBJECT_WRAPPER( AtomicCounterBufferBinding,
new osg::AtomicCounterBufferBinding,
osg::AtomicCounterBufferBinding,
"osg::Object osg::StateAttribute osg::BufferIndexBinding osg::AtomicCounterBufferBinding" )
{
}
}
namespace wrap_osgShaderStorageBufferBinding
{
REGISTER_OBJECT_WRAPPER( ShaderStorageBufferBinding,
new osg::ShaderStorageBufferBinding,
osg::ShaderStorageBufferBinding,
"osg::Object osg::StateAttribute osg::BufferIndexBinding osg::ShaderStorageBufferBinding" )
{
}
}