Sign in to follow this  
SuBG

WIN + wxWidgets + SDL + OGL = MESS!

Recommended Posts

I have a problem integrating SDL_Surface in wxPanel. The SDL_Surface is not in place and i think there is absolutely no way to fit it inside the wx system. 2 days wondering in google, reading wx and sdl sources and banging my head, still no result. The situation is: 1) I have very complex wxWidgets form made with the wxFormBuilder 2) The viewport panel is located as a page of an aui-notebook 3) The application is going to be a level editor 4) I have engine that i build statically with the app. 5) The engine uses SDL+OPENGL setup 6) All OGL functionality is implemented in a dll driver What I do is: 1) I create a custom widget(wxPanel) with overriden events for paint/idle 2) I initialize the engine in Application::OnRun event with the following settings: --- The handle of the custom panel is sent to the engine --- SDL_SetVideoMode( width, height, bpp, window_flags | SDL_OPENGL | SDL_NOFRAME | SDL_RESIZABLE ) is executed on engine side 3) Recieve the SDL_Surface from the engine (SDL_GetVideoSurface();) 4) On idle event i render stuff and generate EVT_PAINT event Problems I encountered: 1) When I include EVT_PAINT function all pending widgets fail to paint until i close the aui page. All other events do not execute but stack... 2) Cant position the SDL_Surface in place Goals: 1) 100.1% portable! Here is the result: http://xs233.xs.to/xs233/08450/mustfithere521.png Here is the source:
bool CApp::OnInit() {
... splash screen and mainframe creation
	if( !Engine.InitSystem( "SIYAL",           g_MainFrame->GetViewport()->GetHandle(), 200, 200, 32 ) )
		return false;
...
}

int CApp::OnRun() {
...
	// generate an initial idle event to start things
	wxIdleEvent event_;
	event_.SetEventObject( g_MainFrame->GetViewport() );
	g_MainFrame->GetViewport()->AddPendingEvent( event_ );

	// start the main loop
	return wxApp::OnRun();
}

void SDLPanel::onIdle(wxIdleEvent &) {
	if( !m_VideoSurface ){
		m_VideoSurface = PLATFORM_SYS.GetVideoSurface();
	}

	if( m_VideoSurface == NULL ) return;

	MODEL_SYS->GetCUSTOM("gizmos")->RenderMesh("axii",MainScreen);
	RENDER_SYS->RenderFrame();

	Refresh();

	// throttle to keep from flooding the event queue
	wxMilliSleep(33);
}
onPaint is excluded because it makes problems
so i wonder if there is any way to fix all this I dug to the bottom of the bottomless internet and dont find anything Is it just a challenge or is it unpossible?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this