Re: [osg-users] Blank screen

2015-01-30 Thread Robert Osfield
Hi Clement,

My guess is that way you hacking the screen size change by creating a new
context is screwing up the way context ID's and OpenGL objects are managed.

My recommendation would be to just switch off window decoration and change
the window size of the context rather than creating a new one.

Robert.

On 30 January 2015 at 16:04, clement@csiro.au wrote:

 Hi all,

   I am trying to output my volume image on full screen with MFC by
 changing GraphicsContext in camera.  First I get GraphicsContext from
 camera and then close it.  Then I created a new GraphicsContext with
 setting screen number and size of full screen and then set it to camera.
 It works to show full screen and also restore back to mfc window, but the
 image cannot show probably.  There is no image on screen (volume data) and
 show the axes I drawn only.  If I changed the display setting to stereo
 (Anaglyphic) and set grayscale on and off.  Then the image will come out.
 I am not sure how to fix it.  See if anyone can help me.  Thanks.


 Regards,
 Clement



 ___
 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] Blank screen

2015-01-30 Thread Clement.Chu
Hi all,

  I am trying to output my volume image on full screen with MFC by changing 
GraphicsContext in camera.  First I get GraphicsContext from camera and then 
close it.  Then I created a new GraphicsContext with setting screen number and 
size of full screen and then set it to camera.  It works to show full screen 
and also restore back to mfc window, but the image cannot show probably.  There 
is no image on screen (volume data) and show the axes I drawn only.  If I 
changed the display setting to stereo (Anaglyphic) and set grayscale on and 
off.  Then the image will come out.  I am not sure how to fix it.  See if 
anyone can help me.  Thanks.


Regards,
Clement



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


[osg-users] Problem with bump map/shadowing and osg 3.1.1 to 3.2.0

2015-01-30 Thread Alexandre Vaillancourt
Hello

We've just noticed that we had issues with bump map and shadowing after
upgrading from 3.1.1 to 3.2.0 and I was wondering if it was a known issue
and if there were some ways to fix it. The issue is that the nodes that use
both features (bump map AND shadowing) are not visible.

I'm not familiar with the techniques used to do these two features (this
includes shaders, I'm clueless about this), and the person who implemented
them in our software is no longer with us.

I think the shadow is produced by using osgShadow/ViewDependentShadowMap,
and a shader is used for bump mapping. (Originates from there:
http://www.ozone3d.net/tutorials/bump_mapping_p4.php -- I'll add the code
at the bottom of the email.)

So, is this a known issue and is there a fix for it? Or any pointers on
where I should start looking to fix it? (I'm aware that no one but us know
our software is done so it's quite not feasible to really pinpoint where
the issue is coming from.)

If you need more information I'd be glad to come back to you with it.

Thanks!

[code]

[Vertex_Shader]

varying vec3 lightVec;
varying vec3 eyeVec;
varying vec2 texCoord;
attribute vec3 vTangent;


void main(void)
{
gl_Position = ftransform();
texCoord = gl_MultiTexCoord0.xy;

vec3 n = normalize(gl_NormalMatrix * gl_Normal);
vec3 t = normalize(gl_NormalMatrix * vTangent);
vec3 b = cross(n, t);

vec3 vVertex = vec3(gl_ModelViewMatrix * gl_Vertex);
vec3 tmpVec = gl_LightSource[0].position.xyz - vVertex;

lightVec.x = dot(tmpVec, t);
lightVec.y = dot(tmpVec, b);
lightVec.z = dot(tmpVec, n);

tmpVec = -vVertex;
eyeVec.x = dot(tmpVec, t);
eyeVec.y = dot(tmpVec, b);
eyeVec.z = dot(tmpVec, n);
}

[Pixel_Shader]

varying vec3 lightVec;
varying vec3 eyeVec;
varying vec2 texCoord;
uniform sampler2D colorMap;
uniform sampler2D normalMap;
uniform float invRadius;

void main (void)
{
float distSqr = dot(lightVec, lightVec);
float att = clamp(1.0 - invRadius * sqrt(distSqr), 0.0, 1.0);
vec3 lVec = lightVec * inversesqrt(distSqr);

vec3 vVec = normalize(eyeVec);

vec4 base = texture2D(colorMap, texCoord);

vec3 bump = normalize( texture2D(normalMap, texCoord).xyz * 2.0 - 1.0);

vec4 vAmbient = gl_LightSource[0].ambient * gl_FrontMaterial.ambient;

float diffuse = max( dot(lVec, bump), 0.0 );

vec4 vDiffuse = gl_LightSource[0].diffuse * gl_FrontMaterial.diffuse *
diffuse;

float specular = pow(clamp(dot(reflect(-lVec, bump), vVec), 0.0, 1.0),
 gl_FrontMaterial.shininess );

vec4 vSpecular = gl_LightSource[0].specular * gl_FrontMaterial.specular 
*
 specular;  

gl_FragColor = ( vAmbient*base +
 vDiffuse*base +
 vSpecular) * att;
}


[/code]

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


Re: [osg-users] Aborting frames that take too long

2015-01-30 Thread Ben Strukus
I did some more research into what's going on and, on a hunch, changed my 
threading model from ThreadPerCamera (default for my PC) to SingleThreaded and 
ThreadPerContext. I found that setAbortRenderPtr does indeed lock up the camera 
thread on ThreadPerCamera, however it seems to behave 100% correctly (in not 
rendering anything when enabled) under the SingleThreaded and ThreadPerContext 
models.

An easy way to reproduce it would be to add a keyboard input event handler that 
calls setAbortRenderPtr on the viewer state. With ThreadPerCamera, the scene 
should lock up. With the other models, it should just stop rendering though 
still remain responsive.

From: osg-users [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf 
Of Ben Strukus
Sent: Monday, January 19, 2015 4:08 PM
To: OpenSceneGraph Users
Subject: [osg-users] Aborting frames that take too long

Hi,

I'm having a problem trying to use OSG for a specific scenario. My simulation 
contains several screens all showing the same scene at different angles (think 
projector setup). I'd like to synchronize the frames among them so that tearing 
between screens is minimal. Due to the nature of my scenes, some screens will 
have more to render than others and, as a result, take longer to render (ground 
vs sky). I'm looking for a way to interrupt a render loop and restart it if I 
detect it's taking too long for my liking.

I've looked at a few proposed solutions by others with a similar problem and 
I've found about the osg::State::setAbortRenderingPtr(bool*). That indeed 
cancels the current frame, but it causes the viewer to get locked up waiting 
for a mutex to become available in the Renderer::ThreadSafeQueue::takeFront() 
function called from the Renderer::draw() function.

I've tried setting the abortRenderPtr to NULL every frame (using the FRAME 
event on osgGA::GUIEventAdapter) and setting it to NULL immediately after it's 
been checked in RenderLeaf::render, though that doesn't seem to change 
anything. The wait function still takes control.

I've read that the setAbortRenderingPtr function is old, but is there any 
knowledge about how it's supposed to be used?

Also, if that doesn't seem like the solution for my scenario, does anyone have 
any suggestions?

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


Re: [osg-users] compositeView in multithreaded Win32 MFC MDI application

2015-01-30 Thread Dan Shebounin
Well, I have tried a strategy 1 Viewer per 1 ClientWnd. I'm not using Doc/View 
model. It works pretty well for me.

The only thing I have discovered so far: you shouldn't initialize OSG and 
render thread in WM_CREATE handler. This will cause a crash.

Because of this, I have to initialize OSG and render thread in first call to 
WM_PAINT. Of course, it could be done from MainFrame OnNew method, but then I 
have to traverse all chain MainFrame-ChildFrame-ClientWnd. I don't like this 
kind of dependencies.

More disturbing is a very slippery glitch with app hang. I have discovered this 
in my current version of 3d-module, which have been written using Ogre3D. After 
transferring to Windows 7, application hangs in about 50% of runs in Ogre's 
Present method. This method swaps backbuffer to show it on a display. Usually 
app hangs somewhere deep inside video driver or Windows ntdll. My current app 
using a somewhat complicated threading model, so I decided, that it is 
something completely wrong with it.

But today I have experienced a similar hang in my new version of 3D-module, 
written using OSG. In render thread's call to viewer-frame() method. As I 
understand, this method swaps a backbuffer. Not this again! It happened once so 
far, but I don't like this.

Something have changed seriously in Windows 7 graphics. So, multithreaded 
rendering using accelerated 3D graphics should be done in a different way. 
Maybe someone know the issue?

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





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


[osg-users] 答复: Blank screen

2015-01-30 Thread Clement.Chu
Hi Robert,

  This is the code for showing image in MFC window. (I followed the 
osgviewerMFC example).

osg::ref_ptrosg::GraphicsContext::Traits traits = new 
osg::GraphicsContext::Traits;
traits-x = 0;
traits-y = 0;
traits-windowDecoration = false;
traits-doubleBuffer = true;
traits-sharedContext = 0;
traits-setInheritedWindowPixelFormat = true;
traits-width = rect.right - rect.left;
traits-height = rect.bottom - rect.top;
traits-inheritedWindowData = new 
osgViewer::GraphicsWindowWin32::WindowData(m_hWnd); 
osg::ref_ptrosg::GraphicsContext gc = 
osg::GraphicsContext::createGraphicsContext(traits.get());
osgCamera-setGraphicsContext(gc.get());

It requires to set window handle (HWND) into Trait to show image into MFC 
window.  The window decoration is already set to false.  If I changed the size, 
the osgViewer is still inside the MFC window.  I would like to switch the 
osgviewer to display on external monitor (full screen) programmatically.  I 
tried many methods and seems I can do it with creating a new GraphicsContext 
and new Trait without assign any HWND and specify the screen number, such as...

osg::GraphicsContext::WindowingSystemInterface* wsi = 
osg::GraphicsContext::getWindowingSystemInterface();
osg::GraphicsContext::ScreenIdentifier si;
si.readDISPLAY();
traits-hostName = si.hostName;
traits-displayNum = si.displayNum;
traits-screenNum = si.screenNum;


The method seems working fine, but the image is already blank at the first.  
Once I changed DisplaySettings with grayscale and stereo mode, the image will 
come out properly.  I would like to know why replaced a new GraphicsContext 
with existing camera will cause the blank problem and why the image can show up 
again after changing some display settings.  Or I already did a wrong way to 
switch the current viewer to show on full screen.  Please advise.  Thanks.



Regards,
Clement





发件人: osg-users [osg-users-boun...@lists.openscenegraph.org] 代表 Robert Osfield 
[robert.osfi...@gmail.com]
发送时间: 2015年1月31日 03:18
收件人: OpenSceneGraph Users
主题: Re: [osg-users] Blank screen

Hi Clement,

My guess is that way you hacking the screen size change by creating a new 
context is screwing up the way context ID's and OpenGL objects are managed.

My recommendation would be to just switch off window decoration and change the 
window size of the context rather than creating a new one.

Robert.

On 30 January 2015 at 16:04, 
clement@csiro.aumailto:clement@csiro.au wrote:
Hi all,

  I am trying to output my volume image on full screen with MFC by changing 
GraphicsContext in camera.  First I get GraphicsContext from camera and then 
close it.  Then I created a new GraphicsContext with setting screen number and 
size of full screen and then set it to camera.  It works to show full screen 
and also restore back to mfc window, but the image cannot show probably.  There 
is no image on screen (volume data) and show the axes I drawn only.  If I 
changed the display setting to stereo (Anaglyphic) and set grayscale on and 
off.  Then the image will come out.  I am not sure how to fix it.  See if 
anyone can help me.  Thanks.


Regards,
Clement



___
osg-users mailing list
osg-users@lists.openscenegraph.orgmailto: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] [osgPlugins] plugin v8 in version 3.3.1

2015-01-30 Thread nguyen duy nam
Hi,
what is  version v8 used in osg 3.3.1, i dont know
anyone can tell me.
because, im build plugin v8 with v8 newer 3.28 or 3.20 it error
1-- Build started: Project: Plugins v8, Configuration: Debug Win32 --
1  V8ScriptEngine.cpp
1G:\Buildnew\OpenSceneGraph-3.3.1\src\osgPlugins\V8\V8ScriptEngine.cpp(55): 
error C2248: 'v8::Persistentv8::Context::operator =' : cannot access private 
member declared in class 'v8::Persistentv8::Context'
1  G:\V8_buildscript\v8\include\v8.h(766) : see declaration of 
'v8::Persistentv8::Context::operator ='
1G:\Buildnew\OpenSceneGraph-3.3.1\src\osgPlugins\V8\V8ScriptEngine.cpp(56): 
error C2660: 'v8::PersistentT::New' : function does not take 1 arguments
1  with
1  [
1  T=v8::ObjectTemplate
1  ]
1G:\Buildnew\OpenSceneGraph-3.3.1\src\osgPlugins\V8\V8ScriptEngine.cpp(63): 
error C2664: 'v8::Context::Scope::Scope(const v8::Context::Scope )' : cannot 
convert argument 1 from 'v8::Persistentv8::Context' to 
'v8::Handlev8::Context'
1  No user-defined-conversion operator available that can perform this 
conversion, or the operator cannot be called
... 

Thank you!

Cheers,
nguyen

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





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


Re: [osg-users] compositeView in multithreaded Win32 MFC MDI application

2015-01-30 Thread Émeric MASCHINO
Hi,

 It is an app in OSG examples, named osgviewerMFC, that demonstrates almost 
 exactly what I need.

 The app doesn't use CompositeView class. And things are much simpler then.

Yep, there's no really problem replacing the Viewer by a
CompositeViewer in the osgviewerMFC example, except for the
StatsHandler that's messing the focus of the osgViewer::Views attached
to the CompositeViewer, as you'll probably discover.

But where things are really becoming funny is when trying to play
efficiently with the osgViewer::Views attached to the CompositeViewer,
when in a MFC context (read context here as general application
context, not as graphics context).

Ideally, I would like not to have one Viewer per CView as in the cOSG
class of the osgviewerMFC example, but one CompositeViewer shared by
all the CViews of the active CChildFrame/opened CDocument. As an
attempt, I thus put the CompositeViewer, OSG root node/group and
render thread in the CChildFrame class, but couldn't get this to run
smoothly (have a look at
http://forum.openscenegraph.org/viewtopic.php?p=62278, most notably my
two last comments about inserting a CSplitterWnd).

Performance-wise, I don't know if this makes sense, but I also tried
putting a unique CompositeViewer (and render thread) in the CWinApp,
holding the osgViewer::Views of the various CViews of the various
opened CChildFrames/CDocuments. I obviously kept the OSG root
nodes/groups in the CChildFrames (keeping them in the the CDocuments
may have been more appropriate). Not better: random crashes IIRC,
potentially thread-related.

If you have other MFC/OSG architectures in mind to share, welcome, as
it seems we're only a few in this boat ;-)

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


Re: [osg-users] [osgPlugins] plugin v8 in version 3.3.1

2015-01-30 Thread Robert Osfield
Hi Nguyen,

It's about 15 months since I wrote the experiment V8 and Python plugins.
This plugins were written as a initial test how easy it would be to support
JavaScript and Python respectively - they simply link to the 3rd party
library and run the script but there isn't any OSG scene graph
integration.  I didn't take this work anything further as I concentrated on
the Lua plugin as it was far easier to work with and integrate with the OSG
scene graph.

I haven't tried the V8 plugin recently, and have no plans to develop it
further in the OSG-3.4 time frame so it's probably best for me to just
remove or disable this plugin.  I don't recall the V8 version I originally
compiled it with, but it would have been pulled in from Ubuntu repositories
back in 2013.  Porting it to newer versions should be possible, but for 3.4
disabling it would be my preference.

Do you have a need for V8 support?

Robert.

Do you have a specific need.

On 30 January 2015 at 01:18, nguyen duy nam namd...@gmail.com wrote:

 Hi,
 what is  version v8 used in osg 3.3.1, i dont know
 anyone can tell me.
 because, im build plugin v8 with v8 newer 3.28 or 3.20 it error
 1-- Build started: Project: Plugins v8, Configuration: Debug Win32
 --
 1  V8ScriptEngine.cpp
 1G:\Buildnew\OpenSceneGraph-3.3.1\src\osgPlugins\V8\V8ScriptEngine.cpp(55):
 error C2248: 'v8::Persistentv8::Context::operator =' : cannot access
 private member declared in class 'v8::Persistentv8::Context'
 1  G:\V8_buildscript\v8\include\v8.h(766) : see declaration of
 'v8::Persistentv8::Context::operator ='
 1G:\Buildnew\OpenSceneGraph-3.3.1\src\osgPlugins\V8\V8ScriptEngine.cpp(56):
 error C2660: 'v8::PersistentT::New' : function does not take 1 arguments
 1  with
 1  [
 1  T=v8::ObjectTemplate
 1  ]
 1G:\Buildnew\OpenSceneGraph-3.3.1\src\osgPlugins\V8\V8ScriptEngine.cpp(63):
 error C2664: 'v8::Context::Scope::Scope(const v8::Context::Scope )' :
 cannot convert argument 1 from 'v8::Persistentv8::Context' to
 'v8::Handlev8::Context'
 1  No user-defined-conversion operator available that can perform
 this conversion, or the operator cannot be called
 ...

 Thank you!

 Cheers,
 nguyen

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





 ___
 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