Commit Graph

9850 Commits

Author SHA1 Message Date
Robert Osfield
3c8fe13194 Quitened down debug info 2009-12-02 12:37:45 +00:00
Robert Osfield
f1009763fc Added osggpx example to demonstate how to use the XmlParser and create line models.
To use :

  osggpx myterrainmodel.ive -t mytrack.gpx
2009-12-02 12:37:22 +00:00
Robert Osfield
2be82dd8d7 Quiten down debugging message 2009-12-01 19:40:29 +00:00
Robert Osfield
4d762a81a6 Updated wrappers 2009-11-30 13:44:41 +00:00
Robert Osfield
3a71cd80fa Attempted compile fix. 2009-11-27 18:14:27 +00:00
Robert Osfield
41ba8ce585 From Christian Ehrlicher, "during profiling my program I found out that there's a lot of memory
(de)allocation going on in OverlayNode::cut().

So instead creating inner-loop variables 'distances' and 'newVertices'
every time, I moved the creation out of the loop and just do a clear() +
reserve() inside the loop. This allows std::vector<> to reuse the old
memory instead allocating new when the new size <= oldsize."
2009-11-27 16:47:38 +00:00
Robert Osfield
9b3e02f4e9 From Jason Daly, "The DDS reader test for DXT1 images with 1-bit alpha wasn't thorough enough. It performed the first check (color_0 <= color_1), but it didn't actually scan the texel block to see if the transparent color (0x03) was there. As a result, DXT1 files without any alpha were getting switched to RGBA format (instead of being left just RGB).
The attached code fixes this problem."
2009-11-27 15:48:57 +00:00
Robert Osfield
b4562b0393 From Jean-Sebastien Guay, Explanation:
Currently osg2cpp removes "\n" line endings to replace them with a textual equivalent ("\\n") in order for the string representing the shader to contain line endings in the string. But if the file that was read contained Windows line endings ("\r\n"), the resulting file looked really weird (the \r were left there and editors interpreted that as an additional newline). Also, I can imagine that if the shader file that was read had Mac line endings ("\r") then the output shader would all end up in one long line since there are no "\n"...

What I've done:

I've added a search and replace of "\r\n" to "\n", and then "\r" to "\n" (note that the order is important).

I've also changed the filename handling so that the output file will be put in the same directory as the input file in case it was specified with a path. Previous functionality is retained for files specified with the filename only.""
2009-11-27 15:39:07 +00:00
Robert Osfield
6ff21888f3 From Wang Rui, "I just successfully built the pdf plugin on Windows XP and MSVC and
fixed a small bug then:

ReaderWriterPDF.cpp, line 133, change:

std::string uri = std::string("file:") + foundFile;

to:

#if defined(WIN32) && !defined(__CYGWIN__)
           std::string uri = std::string("file:///") + foundFile;
#else
           std::string uri = std::string("file:") + foundFile;
#endif


That's because glib accepts "file:///C:\\data\\file.pdf" as URIs on
Windows, as well as "file:/home/data/file.pdf" on Unix, but
"file:C:\\data\\file.pdf" is not recognized.

Now I could read my Chinese translation of OSGQSG with osgpdf. :P"
2009-11-27 15:35:57 +00:00
Robert Osfield
36b5e59019 From Paul Martz, "This change address the following issue: an app opens a Viewer on a multidisplay system, configured to setUpViewAcrossAllDisplays, with a non-default clear mask. In this case, OSG failed to propagate the clear mask to the slave Cameras, resulting in the clear mask being ignored. To fix this issue, this revision adds a new CullSettings::VariablesMask bit, CLEAR_MASK, to explicitly control inheritance of the clear mask. This bit is set by default, which means that the clear mask now inherits by default, whereas previously it did not." 2009-11-27 15:32:43 +00:00
Robert Osfield
9ce90775c2 From Chris Denham, "I discovered what seems to be a missing call to FreeLibrary for osgDB.dll The result of this is that it prevents me from dynamically unloading my DLL (which uses OSG). This is because initialisation of the osg::Registry instance results in a call to GetModuleHandleEx (to get the filename of the DLL). This call to GetModuleHandleEx increments the module refcount, but there was no matching call to FreeLibrary for the returned handle. Unlike the old GetModuleHandle function, GetModuleHandle does (by default) increment the refcount.
I have added the missing call to FreeLibrary in osgDB::FileUtils., and now my the runtime unload of MY dll is working properly. It has also cured some related problems I was having with memory leak checks being reported.

I have attached a fix to osgDB/FileUtils.cpp based on version 2.9.5 svn revision 10374
"
2009-11-27 12:21:44 +00:00
Robert Osfield
5d6ce1a25f From Cory Riddell, "Small edit to ReaderWriterDOT.cpp. It wasn't checking the file extension
and so, if the .dot plugin was loaded, it would happily handle any file
name extension.

To reproduce the bug, first save a scene to a dot file (to load the dot
plugin), then try to write the scene to an osg file. If you look at the
osg file, you will see that it is a dot file."
2009-11-27 12:17:20 +00:00
Robert Osfield
980db2c772 Updated wrappers 2009-11-27 11:48:21 +00:00
Robert Osfield
6ebeff658a Implement deleteAllTextureObject/BufferObjects functionality.
Cleaned up warnings.
2009-11-27 11:43:18 +00:00
Robert Osfield
ab8d93a181 Introduced preliminary osg::deleteAllGLObjects() and osg::discardAllGLObjects() functions and associated support into Texture and BufferObjects 2009-11-26 12:33:07 +00:00
Robert Osfield
7146f8a62f Added check for Geometry pointer being valid 2009-11-26 10:12:38 +00:00
Robert Osfield
e5b76975a9 For testing purposes added code path and options for testing viewer creation in series, including with enabling of VBO's. Options are:
osgcamera -r 5 --vbo cow.osg

Which repeats construction of the viewer 5 times in a row, and enables VBO, and on each repeat a new model is loaded.

  osgcamera -r 2 --vbo --shared cow.osg

Which repeats construction of the viewer 2 times in a row, and enables VBO, and on each loads the model once and shares it between each instance of the viewer.
2009-11-25 16:31:14 +00:00
Robert Osfield
90bd49100f Added support for repeating viewer construction 2009-11-25 16:20:25 +00:00
Robert Osfield
2f72c29bd4 From Sergey Leontyev, example for testing of DatabasePaging and CompositeView usage 2009-11-25 11:31:52 +00:00
Robert Osfield
7255941cf6 Updated wrappers 2009-11-24 15:26:54 +00:00
Robert Osfield
a3adc3d07c From Martin Scheffler, "osgParticle: method to set start and end tile for particle texture (for animated particles). I also updated examples/osgParticle to show the feature.
The texture in data/Images should be copied to osg-data. I created the texture myself with the help of an explosion generator, so no license issues there.
"
2009-11-24 15:00:11 +00:00
Robert Osfield
f79f465467 From Farshid Lashkari,
"I've attached a small fix to osgUtil::SceneView so that is uses a scissor test when clearing the stencil buffer for stencil based stereo."

and

"I've added another small change for stencil based stereo, so please use this newer version. This newer version simplifies the calls to glOrtho and glRecti when drawing the stipple pattern. This change also happens to fix an issue where the stencil stereo would not work with certain viewport settings. I'm not exactly sure why this was happening, it might be a graphics driver issue, but either way I think the changes should be fine."
2009-11-24 14:32:51 +00:00
Robert Osfield
49d6a96a5a From Lilin Xiong, "when using stlport5.3 (vc 2003) , this line cann't be compiled:
_instances[0] = new WGLExtensions;
    change to:
   _instances[HGLRC(0)] = new WGLExtensions;"
2009-11-24 14:22:12 +00:00
Robert Osfield
5f04576abd Updated wrappers 2009-11-24 14:20:59 +00:00
Robert Osfield
6d3e7f83e2 From Terry Welsh, "As I mentioned here
http://www.mail-archive.com/osg-users@lists.openscenegraph.org/msg33967.html
, interpolating through HSV space gives a rainbow color effect which
does not mimic the simple RGB color interpolation that OpenGL does.
It's overkill and causes unexpected visual artifacts.  In the attached
files I've removed the conversion to HSV so that interpolation happens
in RGB space."
2009-11-24 14:12:54 +00:00
Robert Osfield
383a5222bd Rewrote the Vec *= Vec and Vec /= Vec implementations using inline Vec componentMultiply(Vec,Vec) and Vec componentDivide(Vec,Vec) to avoid confusion about the what the operation does. 2009-11-24 13:28:07 +00:00
Robert Osfield
3599be9708 From Wojciech Lewandowski, "I have extended a list of texture targets that can be used with shadow comparison. These targets are avaialble in in OpenGL 3.x shadow sampler variants. Changes are based on current SVN." 2009-11-24 13:24:30 +00:00
Robert Osfield
b3abc0842f From Chris Hanson, " Add support for "OutputTextureFiles" option to IVE plugin to permit creation of external
.dds texture files from internally-embedded textures during IVE writes."

From Robert Osfield, fixed a bug in the above submission, and changed the way that the filename of the file is passed into DataOutputStream to avoid issues with the .ive's plugins ability to read from istreams.
2009-11-23 11:00:07 +00:00
Robert Osfield
d09323f93e From Chris Hanson, " Add support for requesting and setting the current directory (a la getcwd/chdir) via a
C++-friendly string-class API.

 Prevent osgDB::concatPaths from faulting if the supplied "left" path string is empty."
2009-11-23 10:19:37 +00:00
Robert Osfield
87452fe1b9 From Chris Hanson, " Adds support for Vec /= Vec and Vec *= Vec operators to Vec2/Vec3/Vec4 double and float
classes."
2009-11-23 10:01:44 +00:00
Robert Osfield
d81d71fd97 Updated version 2009-11-23 09:54:28 +00:00
Robert Osfield
6365810f8b From Paul Martz, typo fixes 2009-11-23 09:53:08 +00:00
Robert Osfield
71af49f934 Added missing createContextImplementation(). 2009-11-22 17:27:13 +00:00
Robert Osfield
4759cb951e From Colin MacDonald, "In my application I have a custom graphics context class, derived from
osg::GraphicsContext, in order to give good integration with the
application's GUI toolkit.  This works really well.

However, I need to share OpenGL texture resources with the standard
osgViewer GraphicsContext implementations, in particular the
PixelBuffers.  This is essential for my application to conserve graphics
memory on low-end hardware.  Currently the standard osg implementations
will not share resources with another derived osg::GraphicsContext,
other than the pre-defined osgViewer classes e.g. PixelBufferX11 is
hardcoded to only share resources with GraphicsWindowX11 and
PixelBufferX11 objects, and no other osg::GraphicsContext object.

To address this in the cleanest way I could think of, I have moved the
OpenGL handle variables for each platform into a small utility class,
e.g. GraphicsHandleX11 for unix.  Then GraphicsWindowX11, PixelBufferX11
and any other derived osg::GraphicsContext class can inherit from
GraphicsHandleX11 to share OpenGL resources.

I have updated the X11, Win32 and Carbon implementations to use this.
The changes are minor.  I haven't touched the Cocoa implmentation as
I'm not familiar with it at all and couldn't test it - it will work
unchanged.

Without this I had some horrible hacks in my application, this greatly
simplifies things for me.  It also simplifies the osgViewer
implementations slightly.  Perhaps it may help with other users'
desires to share resources with external graphics contexts, as was
discussed on the user list recently."

Notes from Robert Osfield, adapted Colin's submission to work with the new EGL related changes.
2009-11-21 16:41:02 +00:00
Robert Osfield
40d46a8687 From Chris Hanson, " Remove vestigial (and because it was undocumented, potentially harmful) code to ignore
filenames starting with a dash "-" character from the (std::vector<std::string>&) version
of osgDB::readNodeFiles. Handling of argument strings is properly implemented in the
osgDB::readNodeFiles(osg::ArgumentParser& arguments,const Options* options)
variant, which most code uses. The (std::vector<std::string>&) version is only called by
the osgconv utility, which does its own argument handling and stripping prior to calling
readNodeFiles().

 Also, documented this behaviour in the header comments.

 I believe this code removal is a meritful change because leavign the code in causes an
unexpected and undocumented behaviour (ignoring any filename starting with a dash) that
could bite users in the future. This behaviour is not needed for existing functionality
because existing code uses other APIs to handle dash-prefixed arguments anyway.

"
2009-11-20 14:51:43 +00:00
Robert Osfield
255f6dda41 Moved the ImagePager update to before the main scene graph update traversal 2009-11-20 14:40:58 +00:00
Robert Osfield
d9c1f45231 From Wang Rui, "I've made a small fix to osgViewer/Scene.cpp, which is already attached. I would like to explain what I've done and why.
In Scene::updateSceneGraph(), change:

if (getSceneData())
{
        updateVisitor.setImageRequestHandler(getImagePager());
        getSceneData()->accept(updateVisitor);
}
if (getDatabasePager())
{
        // synchronize changes required by the DatabasePager thread to the scene graph
        getDatabasePager()->updateSceneGraph((*updateVisitor.getFrameStamp()));
}

to

if (getDatabasePager())
{
        // synchronize changes required by the DatabasePager thread to the scene graph
        getDatabasePager()->updateSceneGraph((*updateVisitor.getFrameStamp()));
}
if (getSceneData())
{
        updateVisitor.setImageRequestHandler(getImagePager());
        getSceneData()->accept(updateVisitor);
}

That is, just swap the positions of two 'if () {...}' segments.

While working on a paged terrain, I need to collect every newly allocated PagedLODs and make them temporarily unrenderable in the next frame, which are all done in a update callback. But I found that these PagedLODs will always be shown before collecting them, because of the unsuitable sequence in Scene::updateSceneGraph(). DatabasePager is synchronized AFTER the user updating traversal, that is, user cannot IMMEDIATELY find out changes made by DatabasePager.
 "
2009-11-20 14:39:15 +00:00
Robert Osfield
3ef770a9ff From Rafa Gaitan, "Current ffmpeg plugin didn't support pause and seek, I have added this
functionality and I also modified osgmovie example to support "seek"."

Note from Robert Osfield, changes osgmovie to use '>' for the seek as '+' was already used in a separate submission that had been merged.
2009-11-20 14:31:11 +00:00
Robert Osfield
733431004a Updated wrappers 2009-11-20 14:15:42 +00:00
Robert Osfield
e107c86e1a From Farshid Lashkari, "I noticed that the code for rendering vertical interlace, horizontal interlace, and checkerboard stereo are practically identical, except for the stipple pattern. I combined the code blocks for rendering the 3 stereo modes into a single block. I also fixed a small issue with retrieving stats in checkerboard stereo mode." 2009-11-20 12:32:51 +00:00
Robert Osfield
010411e535 From David Callu, "I have a Segfault with xine plugin, when I load a video, then delete the XineStreamImage,
then reload a video and finally delete the second XineStreamImage.

In src/osgPlugins/xine/video_out_rgb.c, many code is ASM code, and 'clear()' function is one of them.
If OSG is compiled without the flag COMPILE_ASSEMBLY (default behaviours) the clear() function is an empty
function and allocated memory is never initialized to 0. So a structure which contain pointer haven't its pointer set to NULL.
And when we need to delete this pointer, all go bad.

I join the fixed file."
2009-11-20 11:46:20 +00:00
Robert Osfield
d55f447188 From Colin McDonald, "Reading from a stream the 3ds plugin crashes if the options are null." 2009-11-20 11:43:53 +00:00
Robert Osfield
f5b61191ad From Himar Carmona, " this submission resolves an issue regarding the setup of a slave camera with an (incorrect) coding style. Sharing the same instance of osg::Viewport with a camera and a slave camera causes incorrect rescaling in GraphicsContext::resizedImplementation, due to the viewport being rescaled twice (once per camera). Though viewports sharing is not intentional, it can be done with the current version of OSG and be a potential pitfall for anyone.
As Robert pointed out, i opted for modifying the resize code where the break is to minimize code changes, avoiding the duplicate resize of the viewport with the use of a vector and a search for duplicates. Not very elegant (avoiding an effect of a cause), another approach could be ripping out the method osg::Camera::setViewport(osg::Viewport*) which is more inline with Roberts rationale behind not to share viewports between cameras and left only its overloaded method setViewport(x,y,width,height). But this approach need some refactoring due to the intense use of the method. Notice also that the resize works well without this change if no sharing occurs, and the user of the method can opt for always call setViewport with a new instance.
 "

Note from Robert Osfield, changed this submission to use an std::set<Viewport*> rather than an std::vector<> as it keeps the code a bit cleaner and more compact.
2009-11-20 11:39:10 +00:00
Robert Osfield
57319d72af From Stewart Andreason, "When I open the Window Attributes (in WindowManager in X on linux) I am unable to save any changes to the attributes in the resource database, because the osg window does not have a class defined. The Window Specification and Save buttons are greyed out.
For example, when running FlightGear, I want the window to always have no title, so it opens full-screen without using the --full-screen option, which would prevent other windows from moving above the osg window.

I am attaching a patch I made to fix this problem."
2009-11-20 11:25:49 +00:00
Robert Osfield
c73e53297d From Nico Kruithof, "This patch makes sure that FindOSG.cmake finds OSG when it is compiled
as a 64 bit library, as the libraries are installed in the lib64
directory and not lib"
2009-11-20 11:18:28 +00:00
Robert Osfield
5cd4faf05b From Jason Beverage, "I posted a question on osg users about resources not being properly released when using osgTerrain databases and multiple viewers are used a few weeks ago and I've found that at least part of the problem comes down to the fact that the nodes that are traversed by the GeometryTechnique are never actually added to the scene graph, and thus don't have releaseGLObjects called on them. I'm submitting a few changes that takes care of this by allowing the TerrainTechnique to provide a releaseGLObjects implementation. I've applied these changes in osgEarth and this example program no longer crashes on the second run, although I get corrupt geometry (see attached shot) which could be down to a driver issue. If I increment the context ID for the second viewer, I no longer get the corrupt geometry.
The attached changes are against OpenSceneGraph 2.8.2.

//Sample program.  Run against an osgEarth or VPB database based on osgTerrain.
#include <osgDB/ReadFile>
#include <osgViewer/Viewer>

int main(int argc, char** argv)
{
   osg::ArgumentParser arguments(&argc,argv);

   osgViewer::Viewer* viewer = new osgViewer::Viewer();
   viewer->setUpViewInWindow(100,
100,500,500);
   osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
   viewer->setSceneData( loadedModel.get() );
   viewer->run();
   delete viewer;

   viewer = new osgViewer::Viewer();
   viewer->setUpViewInWindow(100,100,500,500);
   loadedModel = osgDB::readNodeFiles(arguments);
   viewer->setSceneData( loadedModel.get() );
   viewer->run();
   delete viewer;
}"
2009-11-20 11:08:40 +00:00
Robert Osfield
833e79a79a From Jeremy Moles, "Somehow, the SVG reader plugin has gone all this time without actually
being able to accurately provide the cool stuff that SVG is good for. :)
There is a one-line bug on line 68 in the
src/osgPlugins/svg/ReaderWriterSVG.cpp file where you can set the width
in the Options string, but not the height."
2009-11-20 10:56:54 +00:00
Robert Osfield
e15006b194 From Cedric Pinson, "here an update of osgmovie example with the following features:
- play and pause now stop and play all streams given in the command line
(not only the first)
- add key + - to increase decrease the speed of all streams
- add key o to display all stream frame rate
"
2009-11-20 10:54:39 +00:00
Robert Osfield
7552954ef3 From Cedric Pinson, "Here an update of the directshow plugin. It fixes issues with
synchronization, improve capture device support.

here how to use it to display a capture device:

osg::Options* options = new osg::Options;
options->setPluginStringData("captureWantedWidth", "800");
options->setPluginStringData("captureWantedHeight", "600");
options->setPluginStringData("captureWantedFps", "30");
options->setPluginStringData("captureVideoDevice", "USB Video Device" );
options->setPluginStringData("captureSoundDevice", "");
then
osgDB::readImageFile("capture.directshow", options)
you can use a graphedit application to list devices available in
directshow.


for classic avi file you just need to do a
osgDB::readImageFile("file.avi.directshow");
You will need of course to install the codec needed by directshow to
read the avi files.

I recommand this tool http://avicodec.duby.info/, that check which
video/sound codec is needed to play an avi file.


You can test it with the osgmovie example.
"
2009-11-20 10:48:51 +00:00
Robert Osfield
f45ae6a4d8 From David Fries, "I was trying to create a lot of threads under 32 bit Linux, but could
only create 376, then the program would hang.
376 * 8MB stack per thread = 3008 MB
The stack size allocated per thread blew the process address stack.
To get more threads you have to specify a smaller per thread stack,
but while the Thread::start says it will limit the stack size to the
smallest allowable stack size, it won't let it be smaller than the
default.  I included the limits.h header to use PTHREAD_STACK_MIN as
the minimum stack size.

As for the deadlock, if the pthread_create failed, the new thread
doesn't exist and doesn't call threadStartedBlock.release(), so the
existing thread deadlocks on threadStartedBlock.block().  Only block
if the thread was started."
2009-11-20 10:27:43 +00:00