Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>OpenGL and multithreading are on difficult terms. It can be done, but it requires some care. First and foremost, a OpenGL context can be active in only one thread at a time. And on some systems, like Windows extension function pointers are per context, so with different contexts in different threads you may end up with different extension function pointers, which must be provisioned for.</p> <p>So there's problem number one: You've probably got no OpenGL context on this thread, but this should not crash on calling a non-extension function, it would just do nothing.</p> <p>If it really crashes on the line you indicated, then the <code>dh</code> pointer <em>is invalid</em> for sure. It's the only explanation. A pointer in C is just some number that's interpreted in a special way. If you pass around pointers – especially if used as a parameter to a callback, or thread function – then the object to pointer points to must not go invalid until it's made sure this pointer can no longer be accessed. Which means: You must not use this on things you create on the stack, i.e. in C auto storage.</p> <p>This will break:</p> <pre><code>void foo(void) { struct drawhandle dh_tmp; pthread_create(&amp;posixThreadID, NULL, (void*(*)(void*))ShowThread, &amp;dh_tmp); } </code></pre> <p>why? Because the moment <code>foo</code> returns the object <code>dh_tmp</code> goes invalid. But <code>&amp;dh_tmp</code> (the pointer to it) is just a number and this number will not "magically" turn zero, the moment <code>dh_tmp</code> gets invalid.</p> <p>You must allocate it on the heap for this to work. Of course there's the problem, when to free the memory again.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload