# Made the Atlas scenario editor partly work on Linux.

- Made the canvas get shown before it's used.
 - Added some bits of SDL initialisation so that SDL_GL_GetProcAddress
is happy.
SnapSplitterWindow: fixed virtual override.

This was SVN commit r4735.
This commit is contained in:
Ykkrosh 2007-01-03 15:45:13 +00:00
parent fffc32f8ad
commit 0bdc1c22c8
6 changed files with 43 additions and 15 deletions

View File

@ -85,7 +85,7 @@ function package_set_build_flags()
if options["icc"] then if options["icc"] then
tinsert(package.buildoptions, { tinsert(package.buildoptions, {
"-w1", "-w1",
"-Wabi", -- "-Wabi",
-- "-Wp64", -- complains about OBJECT_TO_JSVAL which is annoying -- "-Wp64", -- complains about OBJECT_TO_JSVAL which is annoying
"-Wpointer-arith", "-Wpointer-arith",
"-Wreturn-type", "-Wreturn-type",

View File

@ -29,14 +29,18 @@ void SnapSplitterWindow::SetDefaultSashPosition(int sashPosition)
SetSashGravity(0.0); SetSashGravity(0.0);
} }
bool SnapSplitterWindow::SplitVertically(wxWindow *window1, wxWindow *window2) bool SnapSplitterWindow::SplitVertically(wxWindow *window1, wxWindow *window2, int sashPosition)
{ {
return wxSplitterWindow::SplitVertically(window1, window2, m_DefaultSashPosition); if (sashPosition == 0)
sashPosition = m_DefaultSashPosition;
return wxSplitterWindow::SplitVertically(window1, window2, sashPosition);
} }
bool SnapSplitterWindow::SplitHorizontally(wxWindow *window1, wxWindow *window2) bool SnapSplitterWindow::SplitHorizontally(wxWindow *window1, wxWindow *window2, int sashPosition)
{ {
return wxSplitterWindow::SplitHorizontally(window1, window2, m_DefaultSashPosition); if (sashPosition == 0)
sashPosition = m_DefaultSashPosition;
return wxSplitterWindow::SplitHorizontally(window1, window2, sashPosition);
} }
void SnapSplitterWindow::OnSashPosChanging(wxSplitterEvent& evt) void SnapSplitterWindow::OnSashPosChanging(wxSplitterEvent& evt)

View File

@ -5,8 +5,8 @@ class SnapSplitterWindow : public wxSplitterWindow
public: public:
SnapSplitterWindow(wxWindow* parent, long style = wxSP_3D); SnapSplitterWindow(wxWindow* parent, long style = wxSP_3D);
void SetDefaultSashPosition(int sashPosition); void SetDefaultSashPosition(int sashPosition);
virtual bool SplitVertically(wxWindow* window1, wxWindow* window2); virtual bool SplitVertically(wxWindow* window1, wxWindow* window2, int sashPosition = 0);
virtual bool SplitHorizontally(wxWindow* window1, wxWindow* window2); virtual bool SplitHorizontally(wxWindow* window1, wxWindow* window2, int sashPosition = 0);
private: private:
void OnSashPosChanging(wxSplitterEvent& evt); void OnSashPosChanging(wxSplitterEvent& evt);

View File

@ -383,17 +383,24 @@ ScenarioEditor::ScenarioEditor(wxWindow* parent)
Canvas* canvas = new GameCanvas(m_SectionLayout.GetCanvasParent(), glAttribList); Canvas* canvas = new GameCanvas(m_SectionLayout.GetCanvasParent(), glAttribList);
m_SectionLayout.SetCanvas(canvas); m_SectionLayout.SetCanvas(canvas);
#ifdef __WXMSW__ // Set up sidebars:
m_SectionLayout.Build();
#if defined(__WXMSW__)
// The canvas' context gets made current on creation; but it can only be // The canvas' context gets made current on creation; but it can only be
// current for one thread at a time, and it needs to be current for the // current for one thread at a time, and it needs to be current for the
// thread that is doing the draw calls, so disable it for this one. // thread that is doing the draw calls, so disable it for this one.
wglMakeCurrent(NULL, NULL); wglMakeCurrent(NULL, NULL);
#elif defined(__WXGTK__)
// Need to make sure the canvas is realized by GTK, so that its context is valid
Show(true);
wxSafeYield();
assert(canvas->GetContext() != NULL);
assert(glXGetCurrentContext() == NULL);
#endif #endif
// Set up sidebars:
m_SectionLayout.Build();
// Send setup messages to game engine: // Send setup messages to game engine:
POST_MESSAGE(SetCanvas, (static_cast<wxGLCanvas*>(canvas))); POST_MESSAGE(SetCanvas, (static_cast<wxGLCanvas*>(canvas)));

View File

@ -11,6 +11,7 @@
#include "gui/CGUI.h" #include "gui/CGUI.h"
#include "gui/GUIbase.h" #include "gui/GUIbase.h"
#include "lib/res/file/vfs.h" #include "lib/res/file/vfs.h"
#include "lib/sdl.h"
#include "maths/MathUtil.h" #include "maths/MathUtil.h"
#include "ps/CConsole.h" #include "ps/CConsole.h"
#include "ps/Game.h" #include "ps/Game.h"
@ -26,6 +27,22 @@ MESSAGEHANDLER(Init)
{ {
UNUSED2(msg); UNUSED2(msg);
#if OS_LINUX
// 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
// which loads the library, and so SDL_GL_GetProcAddress fails (in
// ogl.cpp importExtensionFunctions).
// (TODO: I think this is meant to be context-independent, i.e. it
// doesn't matter that we're getting extensions from SDL-initialised
// GL stuff instead of from the wxWidgets-initialised GL stuff, but that
// should be checked.)
// So, make sure it's loaded:
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
oglInit(); oglInit();
g_Quickstart = true; g_Quickstart = true;

View File

@ -75,9 +75,9 @@ public:
public: \ public: \
enum { TypeIsShareable = 1 }; \ enum { TypeIsShareable = 1 }; \
Shareable() {} \ Shareable() {} \
Shareable(T const& rhs) { m = rhs; } \ Shareable(T const& rhs) : m(rhs) {} \
operator const T() const { return m; } \ operator T() const { return m; } \
const T _Unwrap() const { return m; } \ T _Unwrap() const { return m; } \
} }
SHAREABLE_PRIMITIVE(unsigned char); SHAREABLE_PRIMITIVE(unsigned char);