<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
Aashish,<br>
<br>
Thanks for your reply. I am visualizing wave propagation over time
using imageData, i require to be able to rotate and zoom using the
mouse while the image data is being constantly updated and rendered
on screen. It is the mouse interaction that is very jerky. I am
using the new GTX 480 (so I know that my system is not the problem
here - as my test case is very small as well).<br>
<br>
So yes I need two threads, the main thread and myThread, as the user
interaction is an important aspect here. Although I take your point
that it is easier not to use threads, but in that case I lose the
ability to interact with the scene while the simulation is running.<br>
<br>
With regards the link you sent me.... im really not sure how to
apply that to my own problem, could you or anyone else elaborate?<br>
<br>
Thanks<br>
Alex<br>
<br>
On 14.12.2010 16:24, Aashish Chaudhary wrote:
<blockquote
cite="mid:AANLkTimogG901mY0s5CR-bvWgLEZ0txSzZ2hT1GFbrha@mail.gmail.com"
type="cite">
<div>Hi Alex, </div>
<div><br>
</div>
You context is not shared between threads as its indicated in the
error. This is nothing new and you can find lot more information
if you google for
<div><br>
</div>
<div>"OpenGL share context between threads" </div>
<div><br>
</div>
<div>It works in second case because Qt is doing the job of
signalling the function in other thread in thread safe manner. </div>
<div><br>
</div>
<div>But looking at your sample code, I am not sure what kind of
interaction issues you are having... </div>
<div><br>
</div>
<div>Do you really need two threads? If you do (as I guess you
might be loading data in one and displaying in other), there
could be ways around it.. </div>
<div><br>
</div>
<div>May be this link helps giving you more insight: </div>
<div><br>
</div>
<div>
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
<a moz-do-not-send="true"
href="http://hacksoflife.blogspot.com/2009/08/creating-opengl-textures-or-vbos-on.html">http://hacksoflife.blogspot.com/2009/08/creating-opengl-textures-or-vbos-on.html</a> </div>
<div><br>
</div>
<div><br>
</div>
<div><br>
<div class="gmail_quote">On Tue, Dec 14, 2010 at 8:45 AM, Alex
Southern <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:mrapsouthern@gmail.com">mrapsouthern@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
0.8ex; border-left: 1px solid rgb(204, 204, 204);
padding-left: 1ex;">
Hi,<br>
<br>
Im running a QThread event loop and trying to execute a
vtkInteractorWindow->Render() command after each
iteration. I have tried two approaches so far but neither
work well.<br>
<br>
The First approach, gives a VTK error and is based on
something like this:<br>
At the initialization stage I pass a pointer to iren. Then
in the run() function I execute iren->Render();<br>
<br>
class myThread : public QThread<br>
{<br>
Q_OBJECT<br>
<br>
public:<br>
vtkRenderWindowInteractor *iren;<br>
void run();<br>
{<br>
for (int i = 0; i < 2000; i++)<br>
{<br>
// process some data<br>
iren->Render();<br>
}<br>
}<br>
};<br>
<br>
This compiles but gives the error in the vtkOutputWindow on
each call of Render()....<br>
<br>
ERROR: In
..\..\Source\VTKGit\Rendering\vtkWin32OpenGLRenderWindow.cxx,
line 247<br>
vtkWin32OpenGLRenderWindow (05153168): wglMakeCurrent failed
in MakeCurrent(), error: The requested resource is in use.<br>
<br>
The second approach gives no errors, but results in a very
jerky interaction. It is implemented by emitting a signal
from the for loop after every iteration. The threads
myRender() signal is connected to a updateRenderWindow()
slot function i.e.<br>
<br>
class myThread : public QThread<br>
{<br>
Q_OBJECT<br>
<br>
public:<br>
void run()<br>
{<br>
for (int i = 0; i < 2000; i++)<br>
{<br>
// process some data<br>
emit myRender();<br>
}<br>
}<br>
signals:<br>
void myRender();<br>
};<br>
<br>
class myWindow : public QMainWindow<br>
{<br>
Q_OBJECT<br>
<br>
public:<br>
myThread Td;<br>
vtkRenderWindowInteractor *iren;<br>
<br>
public slots:<br>
void updateRenderWindow()<br>
{<br>
iren->Render();<br>
}<br>
}<br>
<br>
<br>
Does anyone have any suggestions as to how I can improve
either of these methods to give a better interaction?<br>
<br>
Thanks<br>
Alex<br>
<br>
<br>
<br>
_______________________________________________<br>
Powered by <a moz-do-not-send="true"
href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a
moz-do-not-send="true"
href="http://www.kitware.com/opensource/opensource.html"
target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a
moz-do-not-send="true"
href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a moz-do-not-send="true"
href="http://www.vtk.org/mailman/listinfo/vtkusers"
target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</blockquote>
</div>
<br>
<br clear="all">
<br>
-- <br>
| Aashish Chaudhary <br>
| R&D Engineer <br>
| Kitware Inc. <br>
| <a moz-do-not-send="true" href="http://www.kitware.com">www.kitware.com</a>
<br>
</div>
</blockquote>
<br>
</body>
</html>