Move everything from global namespace to "sp" namespace
When writing the X11 (linux) implementation there was a problem with X11 defining a "Display" type and we also have a Display class in the engine. So to fix that problem and minimize the risk for running into other name conflicts. We move everything from global namespace.
This commit is contained in:
parent
9da8addeb2
commit
e10daeaaa6
120 changed files with 551 additions and 105 deletions
|
|
@ -2,6 +2,8 @@
|
|||
#ifndef SPECTRE_PLATFORM_H
|
||||
#define SPECTRE_PLATFORM_H
|
||||
|
||||
namespace sp {
|
||||
|
||||
class PlatformInput;
|
||||
class PlatformDisplay;
|
||||
class MessageQueue;
|
||||
|
|
@ -22,4 +24,6 @@ public :
|
|||
virtual void update() = 0;
|
||||
};
|
||||
|
||||
} // namespace sp
|
||||
|
||||
#endif /* SPECTRE_PLATFORM_H */
|
||||
|
|
@ -4,11 +4,13 @@
|
|||
|
||||
#ifdef _WIN32
|
||||
#include <Platform/Win32/Win32Display.h>
|
||||
typedef Win32Display DisplayType;
|
||||
typedef sp::Win32Display DisplayType;
|
||||
#else
|
||||
#error "No Display implementation exists"
|
||||
#endif
|
||||
|
||||
namespace sp {
|
||||
|
||||
PlatformDisplay* PlatformDisplay::make(Display* parent)
|
||||
{
|
||||
DisplayType* disp = new DisplayType();
|
||||
|
|
@ -29,4 +31,6 @@ void PlatformDisplay::onReshape(int width, int height)
|
|||
{
|
||||
// Forward to parent.
|
||||
m_parent->onReshape(width, height);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace sp
|
||||
|
|
@ -8,6 +8,8 @@
|
|||
// Low-level platform dependant API.
|
||||
#include <string>
|
||||
|
||||
namespace sp {
|
||||
|
||||
class Display;
|
||||
|
||||
class PlatformDisplay
|
||||
|
|
@ -46,7 +48,9 @@ protected :
|
|||
|
||||
private :
|
||||
|
||||
Display* m_parent;
|
||||
Display * m_parent;
|
||||
};
|
||||
|
||||
} // namespace sp
|
||||
|
||||
#endif /* SPECTRE_PLATFORM_DISPLAY_H */
|
||||
|
|
@ -2,6 +2,8 @@
|
|||
#ifndef PLATFORM_INPUT_H
|
||||
#define PLATFORM_INPUT_H
|
||||
|
||||
namespace sp {
|
||||
|
||||
class Keyboard;
|
||||
class Mouse;
|
||||
|
||||
|
|
@ -15,4 +17,6 @@ public :
|
|||
virtual void update() = 0;
|
||||
};
|
||||
|
||||
} // namespace sp
|
||||
|
||||
#endif /* PLATFORM_INPUT_H */
|
||||
|
|
|
|||
|
|
@ -3,9 +3,10 @@
|
|||
#define PLATFORM_MISC_H
|
||||
|
||||
#include <Spectre/Display/DisplayMode.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace sp {
|
||||
|
||||
class DisplayMode;
|
||||
|
||||
class PlatformMisc
|
||||
|
|
@ -16,4 +17,6 @@ public:
|
|||
static DisplayMode GetDesktopMode();
|
||||
};
|
||||
|
||||
} // namespace sp
|
||||
|
||||
#endif /* PLATFORM_MISC_H */
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
#include "Win32Mouse.h"
|
||||
#include "Win32Application.h"
|
||||
|
||||
namespace sp {
|
||||
|
||||
void Win32Application::init()
|
||||
{
|
||||
}
|
||||
|
|
@ -94,3 +96,5 @@ LRESULT Win32Application::processMessage(MSG msg)
|
|||
// Message was not intercepted. Pass down to window.
|
||||
return DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
} // namespace sp
|
||||
|
|
@ -9,6 +9,8 @@
|
|||
#include <Spectre/System/MessageQueue.h>
|
||||
#include <Platform/PlatformApplication.h>
|
||||
|
||||
namespace sp {
|
||||
|
||||
class Win32Application : public PlatformApplication
|
||||
{
|
||||
public :
|
||||
|
|
@ -35,4 +37,6 @@ protected :
|
|||
MessageQueue m_messageQueue;
|
||||
};
|
||||
|
||||
} // namespace sp
|
||||
|
||||
#endif /* WIN32_PLATFORM_H */
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@
|
|||
#include "Win32Internal.h"
|
||||
#include "Win32Display.h"
|
||||
|
||||
namespace sp {
|
||||
|
||||
#define WND_CLASSNAME "SPECTRE_WIN32_WNDCLASS"
|
||||
|
||||
static bool firstTime = true;
|
||||
|
|
@ -258,3 +260,5 @@ LRESULT CALLBACK Win32Display::staticWndProc(HWND handle, UINT message, WPARAM w
|
|||
}
|
||||
return DefWindowProc(handle, message, wParam, lParam);
|
||||
}
|
||||
|
||||
} // namespace sp
|
||||
|
|
@ -6,6 +6,8 @@
|
|||
#include <Platform/PlatformDisplay.h>
|
||||
#include <Windows.h>
|
||||
|
||||
namespace sp {
|
||||
|
||||
class Win32Display : public PlatformDisplay
|
||||
{
|
||||
public :
|
||||
|
|
@ -63,4 +65,6 @@ protected :
|
|||
Vector2u m_minSize;
|
||||
};
|
||||
|
||||
} // namespace sp
|
||||
|
||||
#endif /* PLATFORM_WIN32_DISPLAY_H */
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
#include "Win32Internal.h"
|
||||
#include "Win32GLContext.h"
|
||||
|
||||
namespace sp {
|
||||
|
||||
// Ensure that OpenGL extensions are loaded.
|
||||
static void ensureExtensionsLoaded(HDC dc)
|
||||
{
|
||||
|
|
@ -175,4 +177,6 @@ bool Win32GLContext::setPixelFormat()
|
|||
return ::SetPixelFormat(m_deviceContext, format, &pfd);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace sp
|
||||
|
|
@ -7,6 +7,8 @@
|
|||
#include <Windows.h>
|
||||
#include <Spectre/Display/GLContext.h>
|
||||
|
||||
namespace sp {
|
||||
|
||||
class Win32GLContext : public GLContext
|
||||
{
|
||||
public :
|
||||
|
|
@ -45,4 +47,6 @@ private :
|
|||
HGLRC m_renderContext;
|
||||
};
|
||||
|
||||
} // namespace sp
|
||||
|
||||
#endif /* PLATFORM_WIN32_GLCONTEXT_H */
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
#include "Win32Mouse.h"
|
||||
#include "Win32Input.h"
|
||||
|
||||
namespace sp {
|
||||
|
||||
Win32InputMsgBuffer Win32Input::inputMsgBuffer;
|
||||
|
||||
Win32InputMsgBuffer::Win32InputMsgBuffer() :
|
||||
|
|
@ -24,4 +26,6 @@ Mouse* Win32Input::createMouse()
|
|||
|
||||
void Win32Input::update()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace sp
|
||||
|
|
@ -5,6 +5,8 @@
|
|||
#include <Windows.h>
|
||||
#include <Platform/PlatformInput.h>
|
||||
|
||||
namespace sp {
|
||||
|
||||
#define WIN32_INPUT_BUFFER_QUEUE_MAX_SIZE 64
|
||||
|
||||
struct Win32InputMsgBuffer {
|
||||
|
|
@ -29,4 +31,6 @@ public :
|
|||
static Win32InputMsgBuffer inputMsgBuffer;
|
||||
};
|
||||
|
||||
} // namespace sp
|
||||
|
||||
#endif /* PLATFORM_WIN32_INPUT_H */
|
||||
|
|
@ -7,6 +7,8 @@
|
|||
#include "Win32Keyboard.h"
|
||||
#include "Win32MsgBuffer.h"
|
||||
|
||||
namespace sp {
|
||||
|
||||
static Win32MsgBuffer msg_buf;
|
||||
|
||||
static const Key::Type deviceToKey[256] = {
|
||||
|
|
@ -117,3 +119,5 @@ bool Win32Keyboard::handleMessage(MSG message)
|
|||
{
|
||||
return msg_buf.postMessage(message);
|
||||
}
|
||||
|
||||
} // namespace sp
|
||||
|
|
@ -5,6 +5,8 @@
|
|||
#include <windows.h>
|
||||
#include <Spectre/Input/Keyboard.h>
|
||||
|
||||
namespace sp {
|
||||
|
||||
class Win32Keyboard : public Keyboard
|
||||
{
|
||||
public :
|
||||
|
|
@ -25,4 +27,6 @@ protected :
|
|||
bool m_hasFocus;
|
||||
};
|
||||
|
||||
} // namespace sp
|
||||
|
||||
#endif /* PLATFORM_WIN32_KEYBOARD_H */
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
#include <Windows.h>
|
||||
#include <Platform/PlatformMisc.h>
|
||||
|
||||
namespace sp {
|
||||
|
||||
void PlatformMisc::GetDisplayModes(std::vector<DisplayMode>& modes)
|
||||
{
|
||||
DEVMODE dev;
|
||||
|
|
@ -20,3 +22,5 @@ DisplayMode PlatformMisc::GetDesktopMode()
|
|||
}
|
||||
return DisplayMode();
|
||||
}
|
||||
|
||||
} // namespace sp
|
||||
|
|
@ -6,6 +6,8 @@
|
|||
#include "Win32Input.h"
|
||||
#include "Win32Mouse.h"
|
||||
|
||||
namespace sp {
|
||||
|
||||
static Win32MsgBuffer msg_buf;
|
||||
|
||||
static Vector2f _normalizePos(int x, int y, RECT area)
|
||||
|
|
@ -112,4 +114,6 @@ void Win32Mouse::update(InputModule *input)
|
|||
bool Win32Mouse::handleMessage(MSG message)
|
||||
{
|
||||
return msg_buf.postMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace sp
|
||||
|
|
@ -5,6 +5,8 @@
|
|||
#include <Windows.h>
|
||||
#include <Spectre/Input/Mouse.h>
|
||||
|
||||
namespace sp {
|
||||
|
||||
class Win32Mouse : public Mouse
|
||||
{
|
||||
public :
|
||||
|
|
@ -31,4 +33,6 @@ protected :
|
|||
bool m_tracked;
|
||||
};
|
||||
|
||||
} // namespace sp
|
||||
|
||||
#endif /* PLATFORM_WIN32_MOUSE_H */
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
#include <Spectre/System/Log.h>
|
||||
#include "Win32MsgBuffer.h"
|
||||
|
||||
namespace sp {
|
||||
|
||||
Win32MsgBuffer::Win32MsgBuffer() :
|
||||
index (0)
|
||||
{
|
||||
|
|
@ -15,4 +17,6 @@ bool Win32MsgBuffer::postMessage(MSG msg)
|
|||
}
|
||||
log("Win32MsgBuffer: Queue overflow\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace sp
|
||||
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
#include <Windows.h>
|
||||
|
||||
namespace sp {
|
||||
|
||||
#define WIN32_MSG_BUFFER_MAX_SIZE 64
|
||||
|
||||
struct Win32MsgBuffer {
|
||||
|
|
@ -15,4 +17,6 @@ struct Win32MsgBuffer {
|
|||
bool postMessage(MSG msg);
|
||||
};
|
||||
|
||||
} // namespace sp
|
||||
|
||||
#endif /* PLATFORM_WIN32_MSG_BUFFER_H */
|
||||
|
|
@ -9,9 +9,11 @@ static LARGE_INTEGER getFrequency() {
|
|||
return freq;
|
||||
}
|
||||
|
||||
unsigned long System::getMilliseconds()
|
||||
namespace sp {
|
||||
|
||||
unsigned long system::getMilliseconds()
|
||||
{
|
||||
static LARGE_INTEGER freq = getFrequency();
|
||||
static LARGE_INTEGER freq = ::getFrequency();
|
||||
|
||||
LARGE_INTEGER cnt;
|
||||
::QueryPerformanceCounter(&cnt);
|
||||
|
|
@ -19,10 +21,12 @@ unsigned long System::getMilliseconds()
|
|||
cnt.QuadPart *= 1000;
|
||||
cnt.QuadPart /= freq.QuadPart;
|
||||
|
||||
return (unsigned long) cnt.QuadPart;
|
||||
return (unsigned long)cnt.QuadPart;
|
||||
}
|
||||
|
||||
void System::sleep(int milliseconds)
|
||||
void system::sleep(int milliseconds)
|
||||
{
|
||||
::Sleep(milliseconds);
|
||||
}
|
||||
|
||||
} // namespace sp
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue