<br><br><div class="gmail_quote">On Feb 12, 2008 10:23 PM, Igor Stasenko &lt;<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">On 12/02/2008, Michael van der Gulik &lt;<a href="mailto:mikevdg@gmail.com">mikevdg@gmail.com</a>&gt; wrote:<br>&gt;<br>&gt;<br>&gt; Lots, but it depends on what the problem actually is. Could you describe it<br>
&gt; in more detail?<br>&gt;<br></div>well, when you issuing a command like:<br><br>canvas translateBy: offset during: [ ... ].<br><br>canvas does following:<br><br>gl pushMatrix.<br>gl translateBy: offset.<br>aBlock value.<br>
gl popMatrix.<br><br>operations with matrix affecting global state, if you try to draw<br>anything in parallel process, while in current process you evaluating<br>a block, you will be screwed up.<br><br>Another issue is with using glBegin/glEnd pair. These commands can&#39;t<br>
be nested, also a number of valid GL operations inside glBegin/glEnd<br>are limited.<br><br>In general, any code, that doing like:<br><br>gl changeSomeState.<br>..some code..<br>gl revertToPreviousState.<br><br>is potentially leading to nirvana, if you can&#39;t guarantee a proper<br>
order of commands, issued to OpenGL.<br><div class="Ih2E3d"></div></blockquote><div><br><br>I thought being in nirvana was meant to be a good thing?<br><br>Anyway, I understand what you mean now. This looks like an implementation issue of your canvas, so the thread protection should be encapsulated inside it.<br>
<br>I.e. <br>&nbsp;<br>myMutex critical: [<br>&nbsp;&nbsp;&nbsp; gl changeSomeState.<br>&nbsp;&nbsp;&nbsp; ..some code..<br>&nbsp;&nbsp;&nbsp; gl revertToPreviousState.<br>].<br><br>Just make sure that you keep the critical sections as small as possible, and don&#39;t call any outside code (including blocks).<br>
<br>I don&#39;t think there is a large speed issue here by using Semaphores. If you are worried about speed, you could have two canvases: a reentrant one and a non-reentrant one. Somehow they could reuse code, but I&#39;ll leave this as an exercise for you.<br>
</div></div><br>Gulik.<br clear="all"><br>-- <br><a href="http://people.squeakfoundation.org/person/mikevdg">http://people.squeakfoundation.org/person/mikevdg</a><br><a href="http://gulik.pbwiki.com/">http://gulik.pbwiki.com/</a>