Fixes Atlas on Linux with SDL2 by reordering OpenGL init, based on patch by yashi, fixes #2847

This was SVN commit r16356.
This commit is contained in:
historic_bruno 2015-02-20 05:46:24 +00:00
parent 6b364ad240
commit d644845ae5
3 changed files with 13 additions and 4 deletions

View File

@ -521,6 +521,7 @@ ScenarioEditor::ScenarioEditor(wxWindow* parent)
// Need to make sure the canvas is realised, so that its context is valid
// this solves the "invalid drawable" error
Show(true);
Raise();
#endif
#ifdef __WXGTK__
// TODO: wxSafeYield causes issues on wxOSX 2.9, is it necessary?
@ -529,6 +530,8 @@ ScenarioEditor::ScenarioEditor(wxWindow* parent)
// Send setup messages to game engine:
POST_MESSAGE(InitSDL, ());
POST_MESSAGE(SetCanvas, (static_cast<wxGLCanvas*>(canvas),
canvas->GetClientSize().GetWidth(), canvas->GetClientSize().GetHeight()));

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2014 Wildfire Games.
/* Copyright (C) 2015 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -62,11 +62,10 @@ MESSAGEHANDLER(Init)
g_VideoMode.InitNonSDL();
}
MESSAGEHANDLER(InitGraphics)
MESSAGEHANDLER(InitSDL)
{
UNUSED2(msg);
#if OS_UNIX || (OS_WIN && !CONFIG2_WSDL)
// When using GLX (Linux), SDL has to load the GL library to find
// glXGetProcAddressARB before it can load any extensions.
// When running in Atlas, we skip the SDL video initialisation code
@ -80,7 +79,11 @@ MESSAGEHANDLER(InitGraphics)
SDL_InitSubSystem(SDL_INIT_VIDEO);
SDL_GL_LoadLibrary(NULL); // NULL = use default
// (it shouldn't hurt if this is called multiple times, I think)
#endif
}
MESSAGEHANDLER(InitGraphics)
{
UNUSED2(msg);
ogl_Init();

View File

@ -32,6 +32,9 @@
// Initialise some engine code. Must be called before anything else.
MESSAGE(Init, );
// Initialise SDL-related code. Must be called before SetCanvas and InitGraphics.
MESSAGE(InitSDL, );
// Initialise graphics-related code. Must be called after the first SetCanvas,
// and before much else.
MESSAGE(InitGraphics, );