Thansk for your help. Yes, you are rigth, the problem was in the interaction between the wxwidgets main loop and the gl context. For the Pd-dev list: The solution is to write an Idle function, I made the following changes: //on WxApp class void MyApp::activateRenderLoop(bool on) { if(on && !render_loop_on) { Connect(wxID_ANY, wxEVT_IDLE, wxIdleEventHandler(MyApp::onIdle)); render_loop_on = true; } else if (!on && render_loop_on) { Disconnect(wxEVT_IDLE, wxIdleEventHandler(MyApp::onIdle)); render_loop_on = false; } }
void MyApp::onIdle(wxIdleEvent &evt) { activateRenderLoop(glPane->render_on); if(render_loop_on) { std::cout<<"MyApp on Idle, render_loop_on"<<std::endl; glPane->paint_now(); evt.RequestMore(); } }
//on event table: EVT_PAINT(BasicGLPane::paint_rt)
//on WxGLCanvas class void BasicGLPane::rightClick(wxMouseEvent& event) { render_on = true; manager->init(); SLEEP(2000); manager->play(); wxGetApp().activateRenderLoop(true); }
void BasicGLPane::paint_rt(wxPaintEvent &evt) { wxPaintDC dc(this); render_rt(dc); }
void BasicGLPane::paint_now(){ wxClientDC dc(this); std::cout<<"paint now() "<<std::endl; render_rt(dc); }
void BasicGLPane::render_rt(wxDC &dc) { wxGLCanvas::SetCurrent(*m_context); if(_object->getCounter()>=10) { wxGetApp().activateRenderLoop(false); manager->stop(); render_on = false; } else { ctx = CGLGetCurrentContext(); err = CGLEnable( ctx, kCGLCEMPEngine); std::cout<<"render_rt CGLError: "<<err<<std::endl; if (err==0) { glTranslatef(p3->x, p3->y, 0); Refresh(false); }
} } and the synchronisation works now. Regards. Luis
2016-02-18 3:15 GMT+01:00 Dan Wilcox danomatika@gmail.com:
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.
Dan Wilcox @danomatika https://twitter.com/danomatika danomatika.com robotcowboy.com
On Feb 17, 2016, at 7:12 PM, 0222445 Luis.Valdivia@stud.sbg.ac.at wrote:
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?
Good to hear.
-------- Dan Wilcox @danomatika https://twitter.com/danomatika danomatika.com http://danomatika.com/ robotcowboy.com http://robotcowboy.com/
On Feb 18, 2016, at 6:03 PM, 0222445 Luis.Valdivia@stud.sbg.ac.at wrote:
Thansk for your help. Yes, you are rigth, the problem was in the interaction between the wxwidgets main loop and the gl context. For the Pd-dev list: The solution is to write an Idle function, I made the following changes: //on WxApp class void MyApp::activateRenderLoop(bool on) { if(on && !render_loop_on) { Connect(wxID_ANY, wxEVT_IDLE, wxIdleEventHandler(MyApp::onIdle)); render_loop_on = true; } else if (!on && render_loop_on) { Disconnect(wxEVT_IDLE, wxIdleEventHandler(MyApp::onIdle)); render_loop_on = false; } }
void MyApp::onIdle(wxIdleEvent &evt) { activateRenderLoop(glPane->render_on); if(render_loop_on) { std::cout<<"MyApp on Idle, render_loop_on"<<std::endl; glPane->paint_now(); evt.RequestMore(); } }
//on event table: EVT_PAINT(BasicGLPane::paint_rt)
//on WxGLCanvas class void BasicGLPane::rightClick(wxMouseEvent& event) { render_on = true; manager->init(); SLEEP(2000); manager->play(); wxGetApp().activateRenderLoop(true); }
void BasicGLPane::paint_rt(wxPaintEvent &evt) { wxPaintDC dc(this); render_rt(dc); }
void BasicGLPane::paint_now(){ wxClientDC dc(this); std::cout<<"paint now() "<<std::endl; render_rt(dc); }
void BasicGLPane::render_rt(wxDC &dc) { wxGLCanvas::SetCurrent(*m_context); if(_object->getCounter()>=10) { wxGetApp().activateRenderLoop(false); manager->stop(); render_on = false; } else { ctx = CGLGetCurrentContext(); err = CGLEnable( ctx, kCGLCEMPEngine); std::cout<<"render_rt CGLError: "<<err<<std::endl; if (err==0) { glTranslatef(p3->x, p3->y, 0); Refresh(false); }
}
} and the synchronisation works now. Regards. Luis
2016-02-18 3:15 GMT+01:00 Dan Wilcox <danomatika@gmail.com mailto:danomatika@gmail.com>: 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.
Dan Wilcox @danomatika https://twitter.com/danomatika danomatika.com http://danomatika.com/ robotcowboy.com http://robotcowboy.com/
On Feb 17, 2016, at 7:12 PM, 0222445 <Luis.Valdivia@stud.sbg.ac.at mailto:Luis.Valdivia@stud.sbg.ac.at> wrote:
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?