[osg-users] StateSet UpdateCallback on a camera

2012-07-06 Thread Christian Schulte

  
  
Hi everyone,

I'm facing a problem in our flight simulation environment, where we
want to make the fog camera dependent ( in order to have cameras
without fog for simulation control). I tried to follow the 2009
thread "[osg-users] Set fog in the canera StateSet" and succeded to
implement a non variyng fog. But in our case we have a
statesetcallback for changing the parameter of the fog and one for
activating disactivating the fog. 

This is how was set the fog before (one fog for all views) : 

 /*
 * Fog
 */
 Fog * fog = pe-getFog(); // pe is a
osgParticle::PrecipitationEffect
 root-getOrCreateStateSet()-setAttributeAndModes(fog,
osg::StateAttribute::ON);
 fog-setUpdateCallback(new vesaFogUpdateCallback);
 root-getOrCreateStateSet()-setUpdateCallback(new
vesaFogEnableUpdateCallback);

But, adding the fog to our different views, neither the
vesaFogUpdateCallback nor the vesaFogEnableUpdateCallback are
accessed anymore... This is the code I tryed to implement : 

  BOOST_FOREACH(propTreeNode  v,
arbreUtile-getOptionalChildProperties("graphic.windows.views"))
  {
   propTreeHolder pView(v.second);
   if(pView.empty() || v.first.compare("msgFile")==0 ||
v.first.compare("activeView")==0)
continue;

   std::string name = v.first;
   osgViewer::View* view = new osgViewer::View;
   view-setName(name);
   addView(view);
   view-setSceneData(root);
   view-getCamera()-setName(name);
  
view-getCamera()-setClearColor(fog-getColor());

   view-getCamera()-setViewport(
new osg::Viewport(
 traits-width * 
pView.getPropValuefloat("xMin",0.0),
 traits-height * 
pView.getPropValuefloat("yMin",0.0),
 traits-width * 
pView.getPropValuefloat("sizeX",1.0),
 traits-height * 
pView.getPropValuefloat("sizeY",1.0)
)
   );

   view-getCamera()-setGraphicsContext(gc.get());
   view-getCamera()-setCullSettings(cs);
   if
(arbreUtile-getPropValuebool("graphic.windows.views."+name+
".effects.withFog",true))
   {
osg::ref_ptrosg::Fog fog = new osg::Fog();
 floatvarNear  = 0.0f;
floatend   = 0.0f;
floatdensity  = 0.0f;
std::string  tmp   = "";
osg::Fog::Mode mode;
osg::Vec4f   color;
/*
 * Get values
 */
varNear  =
arbreUtile-getPropValuefloat("sim.environement.fog.start",
1.);
end   =
arbreUtile-getPropValuefloat("sim.environement.fog.end",
2.);
density  =
arbreUtile-getPropValuefloat("sim.environement.fog.density",
0.1);
color   =
arbreUtile-getPropValueosg::Vec4f("sim.environement.fog.color",
osg::Vec4f(0.7,0.7,0.7,1.0));
if((tmp =
arbreUtile-getPropValuestd::string("sim.environement.fog.mode",std::string("exp2")))
== "linear" )
 mode = osg::Fog::LINEAR;
else if(tmp == "exp")
 mode = osg::Fog::EXP;
else if(tmp == "exp2")
 mode = osg::Fog::EXP2;
else
 mode = osg::Fog::EXP2;
fog-setMode(mode);
fog-setStart(varNear);
fog-setEnd(end);
fog-setDensity(density);
fog-setColor(color);

view-getCamera()-getOrCreateStateSet()-setAttributeAndModes(fog,
osg::StateAttribute::ON);
fog-setUpdateCallback(new
vesaFogUpdateCallback);
   
view-getCamera()-getOrCreateStateSet()-setUpdateCallback(new
vesaFogEnableUpdateCallback);
   }
  }

The solution I found is to create an UpdateCallback for each camera
which implements the code present in both my old Fog callbacks.

Does anyone have an idea of why the UpdateCallBack of the stateset
does not work when associated to a camera ? What am I doing wrong ?

Moreover, I initially tried to activate desactivate the osf::Fog,
the osg::Light and the osgParticle::PrecipitationEffect using a
NodeMask/CullMask logic for each camera. It works for the
PrecipitationEffect, but doesn't for the Fog and the Light. Is it a
normal behaviour or is there something wrong in my code (in which
case I would show you the code).

Thankyou for your help,

  SCHULTE
Christian
Research
Engineer
in charge of the Simulation Laboratory
System Control and Flight Dynamics Department
Simulation and Flight Testing Unit
  ONERA - The French Aerospace Lab
  Ecole de l'Air - BA 701
  13661 SALON cedex AIR
  FRANCE



  

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Multi LOD in Multi Camera

2012-07-06 Thread Tolga Yilmaz
Hi,
I have a earth view loaded with map in my main scenegraph and have four 
widgets(windows) with each has their own camera. I mean this four window share 
one scenegraph. The problem is when i open this four widgets or three or two 
with different view distances (one is setted over zoom in one is setted over 
zoom out or zooming until to enable application loading different LODs) all 
views' maps are deteriorating and shaking just like changing between different 
LODs. (Is there a bug about in OSG?)
Is there a way to overcome this issue without creating each views scenegraph 
seperately? (because of the memory status)
... 

Thank you!

Cheers,
Tolga

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=48724#48724





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Creating flare or shining star with osg

2012-07-06 Thread Tolga Yilmaz

Alberto Luaces wrote:
 Tolga Yilmaz writes:
 
 
  Do not really tell me that nobody has needed such a thing in its
  entire life in with its graphics projects... :( 
  
 
 Hi Tolga,
 
 what about this proposal?
 
 http://osdir.com/ml/OpenSceneGraph-Users/2012-01/msg00088.html
 
 -- 
 Alberto
 
 ___
 osg-users mailing list
 
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
 
  --
 Post generated by Mail2Forum


That is not actually did what i needed, i need more bright particles and ieach 
particle has its own smoke trail.

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=48726#48726





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] constant size overlay

2012-07-06 Thread Sergey Polischuk
Hi, Michael

Alpha to coverage have any effect only when drawing to csaa or msaa 
multisampled render target or fb.

Cheers,
Sergey.

06.07.2012, 03:00, Michael Schanne michael.scha...@gmail.com:
 Alpha to coverage didn't have any visible effect, but using alpha testing 
 instead seems to work:

 Code:

 osg::AlphaFunc *af = new osg::AlphaFunc();
 af-setFunction(osg::AlphaFunc::GEQUAL, 0.75f);
 ss-setAttributeAndModes(af, osg::StateAttribute::ON);

 Cheers,
 Michael[/code]

 --
 Read this topic online here:
 http://forum.openscenegraph.org/viewtopic.php?p=48719#48719

 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] StateSet UpdateCallback on a camera

2012-07-06 Thread Tim Moore
Salut,

On Fri, Jul 6, 2012 at 10:13 AM, Christian Schulte
christian.schu...@onera.fr wrote:
 Hi everyone,

 I'm facing a problem in our flight simulation environment, where we want to
 make the fog camera dependent ( in order to have cameras without fog for
 simulation control). I tried to follow the 2009 thread [osg-users] Set fog
 in the canera StateSet and succeded to implement a non variyng fog. But in
 our case we have a statesetcallback for changing the parameter of the fog
 and one for activating disactivating the fog.

...
 But, adding the fog to our different views, neither the
 vesaFogUpdateCallback nor the vesaFogEnableUpdateCallback are accessed
 anymore... This is the code I tryed to implement :

 BOOST_FOREACH(propTreeNode  v,
 arbreUtile-getOptionalChildProperties(graphic.windows.views))
 {
 propTreeHolder pView(v.second);
 if(pView.empty() || v.first.compare(msgFile)==0 ||
 v.first.compare(activeView)==0)
 continue;

 std::string name = v.first;
 osgViewer::View* view = new osgViewer::View;
I don't know if this is pseudo-code or not, but generally you don't
create more than one Viewer per application; instead you use
CompositeViewer or slave cameras in one Viewer. However, if this is
working for you, who am I to say different :)
 view-setName(name);
 addView(view);
 view-setSceneData(root);
 view-getCamera()-setName(name);
 view-getCamera()-setClearColor(fog-getColor());
...
 view-getCamera()-getOrCreateStateSet()-setAttributeAndModes(fog,
 osg::StateAttribute::ON);
 fog-setUpdateCallback(new vesaFogUpdateCallback);

 view-getCamera()-getOrCreateStateSet()-setUpdateCallback(new
 vesaFogEnableUpdateCallback);
 }
 }

 The solution I found is to create an UpdateCallback for each camera which
 implements the code present in both my old Fog callbacks.

 Does anyone have an idea of why the UpdateCallBack of the stateset does not
 work when associated to a camera ? What am I doing wrong ?
Viewer only runs an UpdateVisitor on a camera if it has an update
callback. This may be a small bug, as you have discovered, as it
ignores the possibility that the camera's state set could have update
callbacks. I believe you will find that your state set update callback
will get run even if you install an empty callback on the camera node.

Tim

 Moreover, I initially tried to activate desactivate the osf::Fog, the
 osg::Light and the osgParticle::PrecipitationEffect using a
 NodeMask/CullMask logic for each camera. It works for the
 PrecipitationEffect, but doesn't for the Fog and the Light. Is it a normal
 behaviour or is there something wrong in my code (in which case I would show
 you the code).
I'm not sure what you mean, as Fog and Light aren't scene graph nodes.
Be sure that any StateAttribute objects have their data variance set
to DYNAMIC.

Tim

 Thankyou for your help,

 SCHULTE Christian
 Research  Engineer
 in charge of the Simulation Laboratory
 System Control and Flight Dynamics Department
 Simulation and Flight Testing Unit
 ONERA - The French Aerospace Lab
 Ecole de l'Air - BA 701
 13661 SALON cedex AIR
 FRANCE
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] behavior of osg Tesselator with alpha transparency

2012-07-06 Thread Christian Buchner
Hi,

I was trying to generate a textured halo around a flat (2D) geometric
shape that is supposed to fade with distance without using any GLSL.
The shape is a convex polygon.

My approach is to create a polygon with a hole, where the vertices on
the outer ring has alpha transparency 0 and those on the inner ring
have alpha transparency 1. The hole is exactly centered and has half
the size of the outer shape.

The polygon is run through the osg tesselator and then displayed, but
the result is unexpected and seems to hint at some weird behavior of
the tesselator when alpha values are present.

I am attaching a self contained example, maybe someone can point out
whether I am doing something wrong, or whether the osg tesselator
cannot really handle per-vertex colors. Is anyone aware of an approach
that will produce the result I expect?

Christian

#include limits
#include osgDB/ReadFile
#include osgUtil/Optimizer
#include osgViewer/Viewer
#include osg/Projection
#include osg/MatrixTransform
#include osgUtil/Tessellator

#define SQRT3   1.732050807f
#define SQRT3_2 0.866025403f

class HoleGeometry: public osg::Geometry
{
public:
HoleGeometry(osg::Vec2Array outer, osg::Vec2Array inner, char *filename, float insidealpha, float outsidealpha);
};

HoleGeometry::HoleGeometry(osg::Vec2Array outer, osg::Vec2Array inner, char *filename, float insidealpha, float outsidealpha)
{
int i, nstart = 0;
osg::Vec3Array *coords = new osg::Vec3Array;
osg::Vec3Array *nrms = new osg::Vec3Array;
osg::Vec2Array *tcs = new osg::Vec2Array;
osg::Vec4Array *colors = new osg::Vec4Array;
osg::Vec3 nrm(0,-1,0);

setVertexArray(coords);
setNormalArray(nrms);
setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
setTexCoordArray(0,tcs);
setColorArray(colors);
setColorBinding(osg::Geometry::BIND_PER_VERTEX);

// compute the bounds of outer shape
osg::Vec2 minpos(+std::numeric_limitsdouble::infinity(),+std::numeric_limitsdouble::infinity());
osg::Vec2 maxpos(-std::numeric_limitsdouble::infinity(),-std::numeric_limitsdouble::infinity());
for (int i = 0; i  outer.getNumElements(); i++) {
if (outer[i].x()  minpos.x()) minpos.x() = outer[i].x();
if (outer[i].x()  maxpos.x()) maxpos.x() = outer[i].x();
if (outer[i].y()  minpos.y()) minpos.y() = outer[i].y();
if (outer[i].y()  maxpos.y()) maxpos.y() = outer[i].y();
}

// get the original outer shape
osg::Vec2 texscale(1.0/(maxpos.x()-minpos.x()), 1.0/(maxpos.y()-minpos.y()));
for (i = 0; i  outer.size(); i++) {
coords-push_back(osg::Vec3(outer[i].x(), 0, outer[i].y()));
tcs-push_back( osg::Vec2((outer[i].x()-minpos.x())*texscale.x(), (outer[i].y()-minpos.y())*texscale.y()) );
nrms-push_back(nrm);
colors-push_back(osg::Vec4(1.0,1.0,1.0,outsidealpha));
}
addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::POLYGON,nstart, outer.size()));nstart+=outer.size();

// now add an inner ring shape
for (i = 0; i  inner.size(); i++) {
coords-push_back(osg::Vec3(inner[i].x(), 0, inner[i].y()));
tcs-push_back( osg::Vec2((inner[i].x()-minpos.x())*texscale.x(), (inner[i].y()-minpos.y())*texscale.y()) );
nrms-push_back(nrm);
colors-push_back(osg::Vec4(1.0,1.0,1.0,insidealpha));
}
addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::POLYGON,nstart, inner.size()));nstart+=inner.size();

// set texture and enable blending
osg::StateSet* stateset = getOrCreateStateSet();
osg::Image* image = osgDB::readImageFile(filename);
if (image) {
osg::Texture2D* texture = new osg::Texture2D;
texture-setImage(image);
stateset-setTextureAttributeAndModes(0,texture,osg::StateAttribute::ON);
}
stateset-setMode(GL_BLEND,osg::StateAttribute::ON);

// We use a Tessellator to produce the tessellation required
osg::ref_ptrosgUtil::Tessellator tscx=new osgUtil::Tessellator; // the v1.2 multi-contour Tessellator.
tscx-setTessellationType(osgUtil::Tessellator::TESS_TYPE_GEOMETRY);
tscx-setBoundaryOnly(false);
tscx-setWindingType( osgUtil::Tessellator::TESS_WINDING_ODD); // so that first change in wind type makes the commonest tessellation - ODD.

tscx-retessellatePolygons(*this);
}


int main( int argc, char **argv )
{
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(argc,argv);

// construct the viewer.
osgViewer::Viewer viewer;

// read the scene from the list of file specified commandline args.
osg::ref_ptrosg::Node loadedModel = osgDB::readNodeFiles(arguments);

// if no model has been successfully loaded report failure.
if (!loadedModel) 
{
osg::Vec2Array *outer = new osg::Vec2Array();
osg::Vec2Array *inner = new osg::Vec2Array();

// some concave shape consisting of 3 hexagons
float R = 100.0;
float o = 1.5*R / 2;

Re: [osg-users] Animate Nathan

2012-07-06 Thread Héctor Martínez
Hi Cedric,

 

thank you for your hints. In fact I have a little idea about skeletal
animation, but I’m new with this in OSG. I am reading and looking for info,
but it’s still a bit messy for me. Is there any simple (as simple as this
topic can be) example or tutorial anywhere?

 

Thank you.

 

From: osg-users-boun...@lists.openscenegraph.org
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Cedric
Pinson
Sent: viernes, 06 de julio de 2012 1:59
To: OpenSceneGraph Users
Subject: Re: [osg-users] Animate Nathan

 

Hi ,

 

First you need to understand how bone animations works, else you will not be
able to manipulate the character.
http://en.wikipedia.org/wiki/Skeletal_animation then you can try to touch
osgAnimation::Bone it's the node used to control part of the skeleton.

 

Cedric Pinson
Provide OpenGL, WebGL services
+33 659 598 614 - 
http://cedricpinson.com http://plopbyte.com/  - http://osgjs.org
http://osgjs.org/  - http://sketchfab.com http://showwebgl.com/ 

 

On Jul 5, 2012, at 15:01 , Héctor Martínez wrote:





Hi,

 

I am starting to play with animation in OSG. I would like to animate
Nathan.osg model. The aim is to have control over the different parts of the
body and get, for example, a rotating arm. I don’t know where to start. I
have been trying to use DOFTransform, but I can’t convert any of the
children to DOFTransform (I am getting NULL casting). I have also tried to
create a child DOFTransform node and add the arm as a child but not working
either.

 

Could someone give me some hints on where to concentrate? Tutorial, example
or just the right classes to do it. Or maybe if it is not possible with that
model, some clues about the right models to do that.

 

Thank you in advance.

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

 

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Osg Trac updates

2012-07-06 Thread Jordi Torres
Hi all,

We have been changing some things at the server side in order to try to
improve the efficiency of trac. Now we are serving trac through mod_wsgi
instead of mod_python. Please check it out during the weekend and report
any problems you find.  We expect a better uptime and throughput.

Thank you.


-- 
Jordi Torres Fabra

gvSIG 3D blog
http://gvsig3d.blogspot.com
Instituto de Automática e Informática Industrial
http://www.ai2.upv.es
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] StateSet UpdateCallback on a camera

2012-07-06 Thread Christian Schulte

Thanks Tim for your response,

I will try your solution with an empty UpdateCallBack for the camera.
Concerning multiples views in my application, I didn't post my whole 
code, but we are in a class derived from osgViewer::CompositeViewer.
I understand that Fog and Light are not SceneGraphNodes, but in my case 
I associated my osg::Light to an osg::LightSource whihc is a node, and 
it is this lightSource that I tried to cull, in order to have a view 
without any light.


Thanks,

Christian

Le 06/07/2012 11:46, Tim Moore a écrit :

Salut,

On Fri, Jul 6, 2012 at 10:13 AM, Christian Schulte
christian.schu...@onera.fr wrote:

Hi everyone,

I'm facing a problem in our flight simulation environment, where we want to
make the fog camera dependent ( in order to have cameras without fog for
simulation control). I tried to follow the 2009 thread [osg-users] Set fog
in the canera StateSet and succeded to implement a non variyng fog. But in
our case we have a statesetcallback for changing the parameter of the fog
and one for activating disactivating the fog.


...

But, adding the fog to our different views, neither the
vesaFogUpdateCallback nor the vesaFogEnableUpdateCallback are accessed
anymore... This is the code I tryed to implement :

 BOOST_FOREACH(propTreeNode  v,
arbreUtile-getOptionalChildProperties(graphic.windows.views))
 {
 propTreeHolder pView(v.second);
 if(pView.empty() || v.first.compare(msgFile)==0 ||
v.first.compare(activeView)==0)
 continue;

 std::string name = v.first;
 osgViewer::View* view = new osgViewer::View;

I don't know if this is pseudo-code or not, but generally you don't
create more than one Viewer per application; instead you use
CompositeViewer or slave cameras in one Viewer. However, if this is
working for you, who am I to say different :)

 view-setName(name);
 addView(view);
 view-setSceneData(root);
 view-getCamera()-setName(name);
 view-getCamera()-setClearColor(fog-getColor());

...

view-getCamera()-getOrCreateStateSet()-setAttributeAndModes(fog,
osg::StateAttribute::ON);
 fog-setUpdateCallback(new vesaFogUpdateCallback);

view-getCamera()-getOrCreateStateSet()-setUpdateCallback(new
vesaFogEnableUpdateCallback);
 }
 }

The solution I found is to create an UpdateCallback for each camera which
implements the code present in both my old Fog callbacks.

Does anyone have an idea of why the UpdateCallBack of the stateset does not
work when associated to a camera ? What am I doing wrong ?

Viewer only runs an UpdateVisitor on a camera if it has an update
callback. This may be a small bug, as you have discovered, as it
ignores the possibility that the camera's state set could have update
callbacks. I believe you will find that your state set update callback
will get run even if you install an empty callback on the camera node.

Tim

Moreover, I initially tried to activate desactivate the osf::Fog, the
osg::Light and the osgParticle::PrecipitationEffect using a
NodeMask/CullMask logic for each camera. It works for the
PrecipitationEffect, but doesn't for the Fog and the Light. Is it a normal
behaviour or is there something wrong in my code (in which case I would show
you the code).

I'm not sure what you mean, as Fog and Light aren't scene graph nodes.
Be sure that any StateAttribute objects have their data variance set
to DYNAMIC.

Tim

Thankyou for your help,

SCHULTE Christian
Research  Engineer
in charge of the Simulation Laboratory
System Control and Flight Dynamics Department
Simulation and Flight Testing Unit
ONERA - The French Aerospace Lab
Ecole de l'Air - BA 701
13661 SALON cedex AIR
FRANCE

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Alternate display of text and Image

2012-07-06 Thread Maia Randria
Hi,

I'd like to have some advice on the best way to do the following algorithm with 
OSG.

I have two lists of objects (a first list of images and a second list of texts).

My algorithm is:
- display an image from the first list for a fixed time duration (suppose t 
seconds)
- once t seconds is elapsed, display the first text of the second list and wait 
until the user clicks on the screen with a mouse
- once the mouse event is detected, show a second image for a fixed t seconds.
- after t seconds, display the second text of the second list and wait again 
until the user clicks on the screen with a mouse
etc...

I have looked at osg::Animation and osg::Sequence but I am not sure they are 
the way to go (in addition to GuiEventHandler).


Sorry if this is obvious but I am a beginner in OSG. 
Best regards,

Thank you!

Cheers,
Maia

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=48736#48736





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Saving and restoring GL state with OpenSceneGraph

2012-07-06 Thread Frank Kane
From what I've read, captureCurrentState just returns the current state 
attributes in OSG - it's not actually capturing the current GL state.

But, you could flip the problem on its head and capture the actual OpenGL state 
just prior to calling your library, and then restoring it when your library is 
done with its drawing. Here is some code to start from that catches most of the 
stuff that's likely to change; for completeness, you'd want to capture all of 
the state documented at 
http://www.khronos.org/opengles/sdk/1.1/docs/man/glGet.xml as well.


Code:

typedef struct glState_S {
GLboolean depthTest, blend, cullFace;
GLboolean dither, colorLogicOp, polygonOffsetLine, polygonOffsetFill;
GLboolean polygonOffsetPoint, polygonSmooth, scissorTest, stencilTest;
} glState;

static std::stackglState stateStack;

SILVERLININGDLL_API bool PushAllState(void)
{
glState state;

state.blend = glIsEnabled(GL_BLEND);
state.depthTest = glIsEnabled(GL_DEPTH_TEST);
state.cullFace = glIsEnabled(GL_CULL_FACE);
state.dither = glIsEnabled(GL_DITHER);
state.polygonOffsetFill = glIsEnabled(GL_POLYGON_OFFSET_FILL);
state.scissorTest = glIsEnabled(GL_SCISSOR_TEST);
state.stencilTest = glIsEnabled(GL_STENCIL_TEST);

stateStack.push(state);

CheckError(__LINE__);

return true;
}

SILVERLININGDLL_API bool PopAllState(void)
{
if (!stateStack.empty()) {
glState state = stateStack.top();

if (state.blend) glEnable(GL_BLEND); else glDisable(GL_BLEND);
if (state.depthTest) glEnable(GL_DEPTH_TEST); else 
glDisable(GL_DEPTH_TEST);
if (state.cullFace) glEnable(GL_CULL_FACE); else 
glDisable(GL_CULL_FACE);
if (state.dither) glEnable(GL_DITHER); else glDisable(GL_DITHER);
if (state.polygonOffsetFill) glEnable(GL_POLYGON_OFFSET_FILL); else 
glDisable(GL_POLYGON_OFFSET_FILL);
if (state.scissorTest) glEnable(GL_SCISSOR_TEST); else 
glDisable(GL_SCISSOR_TEST);
if (state.stencilTest) glEnable(GL_STENCIL_TEST); else 
glDisable(GL_STENCIL_TEST);

stateStack.pop();
}

CheckError(__LINE__);

return true;
}




Best regards,
Frank Kane
Founder, Sundog Software LLC

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=48737#48737





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] OpenScenegraph Siggraph 2012 BOF second Call for Presentations

2012-07-06 Thread John Richardson
Greetings and Salutations,

The OpenScenegraph Siggraph 2012 BOF will be held in the Los Angeles 
Convention Center on 8 August 2012 at 10AM.

This is the second Call for Presentations [32 days until the BOF]

Highlight your work.
Show off your institution.
Hawk your consulting skills.

As long as it is OSG related. Step up now and be virtual.

Notes: Robert will get a default 10-15 minute slot to give a state of OSG 
report or whatever he wants to give and presented by whoever he designates. 
That leaves 3 15 minutes slots [more if we get enough presenters but no slot  
10 minutes]. First come first allocated. More time if less presenters.

John F. Richardson


smime.p7s
Description: S/MIME cryptographic signature
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Saving and restoring GL state with OpenSceneGraph

2012-07-06 Thread Preet
Hi Frank,

Thanks for the reply! I'll try setting up something similar in my application.

On Fri, Jul 6, 2012 at 3:52 PM, Frank Kane fk...@sundog-soft.com wrote:
 From what I've read, captureCurrentState just returns the current state 
 attributes in OSG - it's not actually capturing the current GL state.

 But, you could flip the problem on its head and capture the actual OpenGL 
 state just prior to calling your library, and then restoring it when your 
 library is done with its drawing. Here is some code to start from that 
 catches most of the stuff that's likely to change; for completeness, you'd 
 want to capture all of the state documented at 
 http://www.khronos.org/opengles/sdk/1.1/docs/man/glGet.xml as well.


 Code:

 typedef struct glState_S {
 GLboolean depthTest, blend, cullFace;
 GLboolean dither, colorLogicOp, polygonOffsetLine, polygonOffsetFill;
 GLboolean polygonOffsetPoint, polygonSmooth, scissorTest, stencilTest;
 } glState;

 static std::stackglState stateStack;

 SILVERLININGDLL_API bool PushAllState(void)
 {
 glState state;

 state.blend = glIsEnabled(GL_BLEND);
 state.depthTest = glIsEnabled(GL_DEPTH_TEST);
 state.cullFace = glIsEnabled(GL_CULL_FACE);
 state.dither = glIsEnabled(GL_DITHER);
 state.polygonOffsetFill = glIsEnabled(GL_POLYGON_OFFSET_FILL);
 state.scissorTest = glIsEnabled(GL_SCISSOR_TEST);
 state.stencilTest = glIsEnabled(GL_STENCIL_TEST);

 stateStack.push(state);

 CheckError(__LINE__);

 return true;
 }

 SILVERLININGDLL_API bool PopAllState(void)
 {
 if (!stateStack.empty()) {
 glState state = stateStack.top();

 if (state.blend) glEnable(GL_BLEND); else glDisable(GL_BLEND);
 if (state.depthTest) glEnable(GL_DEPTH_TEST); else 
 glDisable(GL_DEPTH_TEST);
 if (state.cullFace) glEnable(GL_CULL_FACE); else 
 glDisable(GL_CULL_FACE);
 if (state.dither) glEnable(GL_DITHER); else glDisable(GL_DITHER);
 if (state.polygonOffsetFill) glEnable(GL_POLYGON_OFFSET_FILL); else 
 glDisable(GL_POLYGON_OFFSET_FILL);
 if (state.scissorTest) glEnable(GL_SCISSOR_TEST); else 
 glDisable(GL_SCISSOR_TEST);
 if (state.stencilTest) glEnable(GL_STENCIL_TEST); else 
 glDisable(GL_STENCIL_TEST);

 stateStack.pop();
 }

 CheckError(__LINE__);

 return true;
 }




 Best regards,
 Frank Kane
 Founder, Sundog Software LLC

 --
 Read this topic online here:
 http://forum.openscenegraph.org/viewtopic.php?p=48737#48737





 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org