<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Good to hear.<div class=""><br class=""><div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">--------<br class="">Dan Wilcox<br class=""><a href="https://twitter.com/danomatika" class="">@danomatika</a><br class=""><a href="http://danomatika.com" class="">danomatika.com</a><br class=""><div class=""><a href="http://robotcowboy.com" class="">robotcowboy.com</a></div></div>

</div>
<br class=""><div style=""><blockquote type="cite" class=""><div class="">On Feb 18, 2016, at 6:03 PM, 0222445 <<a href="mailto:Luis.Valdivia@stud.sbg.ac.at" class="">Luis.Valdivia@stud.sbg.ac.at</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class=""><div class=""><div class="">Thansk for your help. Yes, you are rigth, the problem was in the interaction between the wxwidgets main loop and the gl context.<br class=""></div>For the Pd-dev list:<br class=""></div>The solution is to write an Idle function, I made the following changes:<br class=""></div>//on WxApp class<br class=""><div class=""><code class="">void MyApp::activateRenderLoop(bool on) {<br class="">    if(on && !render_loop_on) {<br class="">        Connect(wxID_ANY, wxEVT_IDLE, wxIdleEventHandler(MyApp::onIdle));<br class="">        render_loop_on = true;<br class="">    }<br class="">    else if (!on && render_loop_on) {<br class="">        Disconnect(wxEVT_IDLE, wxIdleEventHandler(MyApp::onIdle));<br class="">        render_loop_on = false;<br class="">    }<br class="">}<br class=""><br class=""></code><code class="">void MyApp::onIdle(wxIdleEvent &evt) {<br class="">    activateRenderLoop(glPane->render_on);<br class="">    if(render_loop_on) {<br class="">        std::cout<<"MyApp on Idle, render_loop_on"<<std::endl;<br class="">        glPane->paint_now();<br class="">        evt.RequestMore();<br class="">    }<br class="">}<br class=""><br class=""></code><code class="">//on event table:<br class="">EVT_PAINT(BasicGLPane::paint_rt)<br class=""><br class=""></code></div><div class=""><code class="">//on WxGLCanvas class<br class=""></code></div><div class=""><code class="">void BasicGLPane::rightClick(wxMouseEvent& event) {<br class="">    render_on = true;<br class="">    manager->init();<br class="">    SLEEP(2000);<br class="">    manager->play();<br class="">    wxGetApp().activateRenderLoop(true);    <br class="">}<br class=""><br class="">void BasicGLPane::paint_rt(wxPaintEvent &evt) {<br class="">    wxPaintDC dc(this);<br class="">    render_rt(dc);<br class="">}<br class=""><br class="">void BasicGLPane::paint_now(){<br class="">    wxClientDC dc(this);<br class="">    std::cout<<"paint now() "<<std::endl;<br class="">    render_rt(dc);<br class="">}<br class=""><br class="">void BasicGLPane::render_rt(wxDC &dc) {<br class="">    wxGLCanvas::SetCurrent(*m_context);<br class="">    if(_object->getCounter()>=10) { <br class="">        wxGetApp().activateRenderLoop(false);<br class="">        manager->stop();<br class="">        render_on = false;<br class="">    }<br class="">    else {<br class="">        ctx = CGLGetCurrentContext();<br class="">        err =  CGLEnable( ctx, kCGLCEMPEngine);<br class="">        std::cout<<"render_rt CGLError: "<<err<<std::endl;<br class="">        if (err==0) {<br class="">            glTranslatef(p3->x, p3->y, 0);<br class="">            Refresh(false);<br class="">        }<br class=""><br class="">    }<br class="">}</code><br class=""><div class=""><div class=""><div class=""><div class="gmail_extra">and the synchronisation works now.<br class=""></div><div class="gmail_extra">Regards.<br class=""></div><div class="gmail_extra">Luis<br class=""></div><div class="gmail_extra"><br class=""><div class="gmail_quote">2016-02-18 3:15 GMT+01:00 Dan Wilcox <span dir="ltr" class=""><<a href="mailto:danomatika@gmail.com" target="_blank" class="">danomatika@gmail.com</a>></span>:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word" class="">That shouldn’t make a difference, but you could try it. People haven’t had problems with OpenGL + libpd using ofxPd in open frameworks, so it may be due to how the wx widget mainloop & gl context interact.<div class=""><span class=""><br class=""><div class="">
<div style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; word-wrap: break-word;" class="">--------<br class="">Dan Wilcox<br class=""><a href="https://twitter.com/danomatika" target="_blank" class="">@danomatika</a><br class=""><a href="http://danomatika.com/" target="_blank" class="">danomatika.com</a><br class=""><div class=""><a href="http://robotcowboy.com/" target="_blank" class="">robotcowboy.com</a></div></div>

</div>
<br class=""></span><span class=""><div class=""><blockquote type="cite" class=""><div class="">On Feb 17, 2016, at 7:12 PM, 0222445 <<a href="mailto:Luis.Valdivia@stud.sbg.ac.at" target="_blank" class="">Luis.Valdivia@stud.sbg.ac.at</a>> wrote:</div><br class=""><div class=""><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important" class="">There is no context error in the OpenGL draw now (solved with the call wxGLCanvas::SetCurrent(*m_context) but the draw still doesn't works (the object is moved after the manager->stop() and not during the execution) . I still think RtAudio is owning the CPU and blocking the execution of other threads or process. It will be better to do it with PortAudio?</span></div></blockquote></div><br class=""></span></div></div></blockquote></div><br class=""></div></div></div></div></div></div>
</div></blockquote></div><br class=""></div></body></html>