Jump to content
  • Advertisement
Sign in to follow this  
maxest

How to repaint every frame with wxWidgets?

This topic is 3241 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I got a simple rendering function written in OGL. It's used in GLCanvas::OnPaint(wxPaintEvent &event) event, which is declared as: EVT_PAINT(GLCanvas::OnPaint). But this causes OGL rendering only when window needs to be repainted. How/where should I call my OnPaint to make it rendering all the time? (since I don't have access to program's main rendering loop because of wxWidgets)

Share this post


Link to post
Share on other sites
Advertisement
Honestly.. I don't understand. What event (EVT_) should I actually use?

I think I found a way around - I'll simply use timer :)

EDIT: NumberXaero: I got it :). I just misundestood you because of "OnInternalIdle" instead of "OnIdle" - thought there's a separate EVT_ for OnInternalIdle :). Works nice without timer. Thanks for help

Share this post


Link to post
Share on other sites
Yeah, probably should have been more descriptive, I posted quick just to point you in the right direction. You seemed to know what you were after.
OnInternalIdle() can be overridden from base wxWindow, OnEraseBackground() is called on events using the event table. Sorry about that.

Share this post


Link to post
Share on other sites

void GLCanvas::OnIdle(wxIdleEvent &event)
{
Render();
/* Force the redraw immediately, gets the gfx card to its max */
event.RequestMore();
}


Share this post


Link to post
Share on other sites
Now I've got problem with initilization. I want to call some init OGL functions that sets initial states, creates additional framebuffer objects and so on. I want to call that function in my wxGLCanvas-derived class constructor. However, before I can call my CRenderer::init I need to have context set. But I can't set it since I don't have window's DC. And this can be created only in OnPaint event! Here's the code:

MapRender::MapRender(wxWindow *parent, wxWindowID id, int *attribList, const wxPoint &position, const wxSize &size):
wxGLCanvas(parent, id, attribList, position, size)
{
wxGLContext context(this); // problem here
SetCurrent(context);
CRenderer::init();
}

void MapRender::OnPaint(wxPaintEvent &event)
{
wxPaintDC dc(this);
wxGLContext context(this);
SetCurrent(context);
Render();
SwapBuffers();
}

In line with "problem here" I need DC to make the context. How can I get this DC in constructor?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!