I would *really* like to use wxWidgets for this, but things don't look good based on what I've read through the wiki + forums. Perhaps I missed something?
I'm working on a simple visualization app that needs to have an OpenGL window draw a simple GL scene. However, I need the OpenGL window/wxGLCanvas be updating constantly - even when no events are happening. Basically, I need the machine to be drawing as often as possible (high fps), but also be able to handle gui/keyboard events too.
In win32, you'd do this in the WinMain:
winmain()
{
TranslateMessage();
DispatchMessage();
MyDrawingRoutine();
}
But from what I see in the forums - you can't get access to the main message pump like this.
So, can I make my wxApp to do the UI stuff, and then start a thread that will do the wxGLCanvas drawing loop? Can GL window live in the same physical window as the wxApp if the GLCanvas is in another thread? Has anyone got this working in another way?
Here's what I have tried and doesn't work:
1. draw on wxTimer events - all animation stops when another event such as click/drag or keyboard events happen
2. OnPaint() invalidate - the last line of the OnPaint function invalidates the OpenGL rect so another draw command is issued. Unfortunately, keyboard input/mouse input gets lost or greatly delayed - very sluggish. App often can't exit as side effect.
Help? Thanks!
Can you do it? wxGLCanvas
-
- In need of some credit
- Posts: 4
- Joined: Mon Sep 17, 2007 11:30 pm
-
- Earned some good credits
- Posts: 128
- Joined: Sat Sep 25, 2004 9:11 pm
- Location: Nuremberg, Germany
- Contact:
I have done it this way:
It works just fine. I don't know how much load GLCanvas can handle, but I am just drawing primitives for designing OpenGL-Shader. But GLSL and Textures work .
Hope this helps.
rya.
Code: Select all
m_timer = new wxTimer(this, ID_RENDERTIMER);
if (m_timer != NULL){
m_timer->Start(40, false);
}
void CCanvas::OnMyTimer(wxTimerEvent &event)
{
if (m_plugin == NULL)
{
return;
}
m_plugin->OnTimer();
this->Refresh(false);
}
Hope this helps.
rya.