OpenGL accross multiple threads in C#.NET

S

sarah_c_clough

Hi,

I have an application (written in C#.NET with the 2.0 framework and
OpenGL) that runs several display lists. It's currently a little
slow, so thought it would be a good idea to initialise the most
important display lists first and display them. Then while the user
is able to play with the rest of the interface (scroll and pan options
etc.), initialise the rest of the display lists in a BackgroundWorker
thread.

If I run the application, it runs fine, except the second set of
display lists aren't visible after they've created. If I close the
application down and open it without about 10 mins of closing it, I
get the following error:

"Attempting to read or write protected memory. This is often an
indication that the other memory is corrupt", which occurs on my call
to glNewList. I've tried putting a lock or a mutex around the call to
glNewList, but it doesn't make a difference, I still get the error.

So I have two questions:
1) When my application works after having had a break, why aren't the
second set of display lists visible?
2) Why do I get the error if I run it up again too soon after closing
it down?

Thanks,
Sarah
 
W

Wolfgang Draxinger

Hi,

I have an application (written in C#.NET with the 2.0 framework
and
OpenGL) that runs several display lists. It's currently a
little slow, so thought it would be a good idea to initialise
the most important display lists first and display them. Then
while the user is able to play with the rest of the interface
(scroll and pan options etc.), initialise the rest of the
display lists in a BackgroundWorker thread.

No, it's a bad idea having multiple threads accessing/drawing
into the same window/OpenGL context simulatanously. Don't do
this.

If you want a snappy user interface put the whole OpenGL window
into it's own thread, do the UI in a separate one and use Vertex
Array, VBOs instead of display lists. DLs must be initialized,
VA/VBO not.

Wolfgang Draxinger
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top