Hi there, I'm still with my multithreading questions :-)

I'm testing two scenarios :

1) First case: (witness case)

- I create a thread 1, create a Producer::RenderSurface, but do NOT realize
it.
- In thread 1, I start an other Thread 2.


- In thread 2, I realize the previous RenderSurface, I call the init()
function of an associated osgUtil::SceneView (this point is optional, the
automatic call for init() works in this case), then I call cull() and draw()
in a loop.


==> With this scenario, everything works well.

2) Second case: (problem)

- I create a thread 1, create a producer::RenderSurface and DO realize it in
this thread, I also call the init() function of my associated SceneView()
[otherwise it would be called in the cull() function, and would crash in my
second thread...], then I start my Thread 2.

- In thread 2, I (try to...) call cull() and draw() in a loop...

==> I solved a first crash in cull() by calling SceneView::init() in the
first thread, but now, I have a crash in the draw() function: when first
applying a LightModel attribute to the state apparently in this function:


void LightModel::apply(State&) const

{

glLightModelfv(GL_LIGHT_MODEL_AMBIENT,_ambient.ptr());

//static bool s_separateSpecularSupported = strcmp((const char
*)glGetString(GL_VERSION),"1.2")>=0;

static bool s_separateSpecularSupported = (std::string((const
char*)glGetString(GL_VERSION)) == "
1.2");

if (s_separateSpecularSupported)

{

if (_colorControl==SEPARATE_SPECULAR_COLOR)

{

glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR);

}

else

{

glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SINGLE_COLOR);

}

}

glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER,_localViewer);

glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,_twoSided);

}

==> the function glGetString(GL_VERSION)  returns NULL :'( !!!

... I guess it has something to do with OpenGL not being aware of its
initialization in the second thread... but I really have no clue how to
solve this (if it's even possible... !).



I think using the new osgViewer implementation might help, but I'm not ready
yet to take this change, any idea how to do this another way ?

regards,

Emmanuel.



PS: using OSG 1.2, WinXP, Nvidia Geforce 7900 GS.
_______________________________________________
osg-users mailing list
osg-users@openscenegraph.net
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to