aboutsummaryrefslogtreecommitdiffstats
path: root/Samples/CommonSrc/Platform
diff options
context:
space:
mode:
Diffstat (limited to 'Samples/CommonSrc/Platform')
-rw-r--r--Samples/CommonSrc/Platform/Linux_Platform.cpp53
-rw-r--r--Samples/CommonSrc/Platform/OSX_Platform.mm2
-rw-r--r--Samples/CommonSrc/Platform/Platform.h20
-rw-r--r--Samples/CommonSrc/Platform/Platform_Default.h11
-rw-r--r--Samples/CommonSrc/Platform/Win32_Platform.cpp5
5 files changed, 45 insertions, 46 deletions
diff --git a/Samples/CommonSrc/Platform/Linux_Platform.cpp b/Samples/CommonSrc/Platform/Linux_Platform.cpp
index c9d3e40..e94b37f 100644
--- a/Samples/CommonSrc/Platform/Linux_Platform.cpp
+++ b/Samples/CommonSrc/Platform/Linux_Platform.cpp
@@ -24,7 +24,7 @@ otherwise accompanies this software in either electronic or hard copy form.
// Renderers
#include "../Render/Render_GL_Device.h"
-#include <X11/extensions/Xinerama.h>
+#include <X11/extensions/Xrandr.h>
namespace OVR { namespace Platform { namespace Linux {
@@ -156,7 +156,7 @@ void PlatformCore::SetWindowTitle(const char* title)
{
XStoreName(Disp, Win, title);
}
-
+
void PlatformCore::ShowWindow(bool show)
{
if (show)
@@ -227,12 +227,12 @@ static KeyCode MapXKToKeyCode(unsigned vk)
{
key = vk - XK_F1 + Key_F1;
}
- else
+ else
{
for (unsigned i = 0; i< (sizeof(KeyMap) / sizeof(KeyMap[1])); i++)
{
if (vk == KeyMap[i][0])
- {
+ {
key = KeyMap[i][1];
break;
}
@@ -311,7 +311,7 @@ void PlatformCore::processEvent(XEvent& event)
case MapNotify:
if (MMode == Mouse_Relative)
- {
+ {
XWarpPointer(Disp, Win, Win, 0,0,Width,Height, Width/2, Height/2);
showCursor(false);
}
@@ -323,7 +323,7 @@ void PlatformCore::processEvent(XEvent& event)
//grab
if (MMode == Mouse_RelativeEscaped)
- {
+ {
XWarpPointer(Disp, Win, Win, 0,0,Width,Height, Width/2, Height/2);
showCursor(false);
MMode = Mouse_Relative;
@@ -333,7 +333,7 @@ void PlatformCore::processEvent(XEvent& event)
case FocusOut:
if (MMode == Mouse_Relative)
- {
+ {
MMode = Mouse_RelativeEscaped;
showCursor(true);
}
@@ -370,28 +370,23 @@ int PlatformCore::Run()
bool PlatformCore::determineScreenOffset(int screenId, int* screenOffsetX, int* screenOffsetY)
{
- Display* display = XOpenDisplay(NULL);
-
- bool foundScreen = false;
-
- if (display)
- {
- int numberOfScreens;
- XineramaScreenInfo* screens = XineramaQueryScreens(display, &numberOfScreens);
-
- if (screenId < numberOfScreens)
- {
- XineramaScreenInfo screenInfo = screens[screenId];
- *screenOffsetX = screenInfo.x_org;
- *screenOffsetY = screenInfo.y_org;
-
- foundScreen = true;
+ bool result = false;
+ if (screenId) {
+ Display* display = XOpenDisplay(NULL);
+ XRRScreenResources *screen = XRRGetScreenResources(display, DefaultRootWindow(display));
+ XRROutputInfo * info = XRRGetOutputInfo (display, screen, screenId);
+ if (info->crtc) {
+ XRRCrtcInfo * crtc_info = XRRGetCrtcInfo (display, screen, info->crtc);
+ *screenOffsetX = crtc_info->x;
+ *screenOffsetY = crtc_info->y;
+ XRRFreeCrtcInfo(crtc_info);
+ result = true;
}
-
- XFree(screens);
+ XRRFreeOutputInfo (info);
+ XRRFreeScreenResources(screen);
}
- return foundScreen;
+ return result;
}
void PlatformCore::showWindowDecorations(bool show)
@@ -476,11 +471,11 @@ RenderDevice* PlatformCore::SetupGraphics(const SetupGraphicsDeviceSet& setupGra
{
const SetupGraphicsDeviceSet* setupDesc = setupGraphicsDesc.PickSetupDevice(type);
OVR_ASSERT(setupDesc);
-
+
pRender = *setupDesc->pCreateDevice(rp, this);
if (pRender)
pRender->SetWindowSize(Width, Height);
-
+
return pRender.GetPtr();
}
@@ -540,7 +535,7 @@ void RenderDevice::Shutdown()
}}}}
-int main(int argc, const char* argv[])
+int main(int argc, char** argv)
{
using namespace OVR;
using namespace OVR::Platform;
diff --git a/Samples/CommonSrc/Platform/OSX_Platform.mm b/Samples/CommonSrc/Platform/OSX_Platform.mm
index 491ff6c..9926cca 100644
--- a/Samples/CommonSrc/Platform/OSX_Platform.mm
+++ b/Samples/CommonSrc/Platform/OSX_Platform.mm
@@ -29,7 +29,7 @@ using namespace OVR::Platform;
[self setApp:app];
[self setPlatform:platform];
- const char* argv[] = {"OVRApp"};
+ char* argv[] = {"OVRApp"};
int exitCode = app->OnStartup(1, argv);
if (exitCode)
{
diff --git a/Samples/CommonSrc/Platform/Platform.h b/Samples/CommonSrc/Platform/Platform.h
index 201aad6..992a3fa 100644
--- a/Samples/CommonSrc/Platform/Platform.h
+++ b/Samples/CommonSrc/Platform/Platform.h
@@ -79,7 +79,7 @@ typedef RenderDevice* (*RenderDeviceCreateFunc)(const Render::RendererParams&, v
// used to build up a list of RenderDevices that can be used for rendering.
// Specifying a smaller set allows application to avoid linking unused graphics devices.
struct SetupGraphicsDeviceSet
-{
+{
SetupGraphicsDeviceSet(const char* typeArg, RenderDeviceCreateFunc createFunc)
: pTypeArg(typeArg), pCreateDevice(createFunc), pNext(0) { }
SetupGraphicsDeviceSet(const char* typeArg, RenderDeviceCreateFunc createFunc,
@@ -90,7 +90,7 @@ struct SetupGraphicsDeviceSet
const SetupGraphicsDeviceSet* PickSetupDevice(const char* typeArg) const;
const char* pTypeArg;
- RenderDeviceCreateFunc pCreateDevice;
+ RenderDeviceCreateFunc pCreateDevice;
private:
const SetupGraphicsDeviceSet* pNext;
@@ -111,7 +111,7 @@ protected:
Application* pApp;
Ptr<RenderDevice> pRender;
Ptr<GamepadManager> pGamepadManager;
- UInt64 StartupTicks;
+ UInt64 StartupTicks;
public:
PlatformCore(Application *app);
@@ -126,10 +126,10 @@ public:
virtual void Exit(int exitcode) = 0;
virtual void ShowWindow(bool visible) = 0;
-
+
virtual bool SetFullscreen(const Render::RendererParams& rp, int fullscreen);
-
- // Search for a matching graphics renderer based on type argument and initializes it.
+
+ // Search for a matching graphics renderer based on type argument and initializes it.
virtual RenderDevice* SetupGraphics(const SetupGraphicsDeviceSet& setupGraphicsDesc,
const char* gtype,
const Render::RendererParams& rp) = 0;
@@ -142,10 +142,10 @@ public:
virtual void PlayMusicFile(const char *fileName) { OVR_UNUSED(fileName); }
virtual int GetDisplayCount() { return 0; }
virtual Render::DisplayId GetDisplay(int screen);
-
+
// Get time since start of application in seconds.
- double GetAppTime() const;
-
+ double GetAppTime() const;
+
virtual String GetContentDirectory() const { return "."; }
};
@@ -161,7 +161,7 @@ protected:
public:
virtual ~Application() { }
- virtual int OnStartup(int argc, const char** argv) = 0;
+ virtual int OnStartup(int argc, char** argv) = 0;
virtual void OnQuitRequest() { pPlatform->Exit(0); }
virtual void OnIdle() {}
diff --git a/Samples/CommonSrc/Platform/Platform_Default.h b/Samples/CommonSrc/Platform/Platform_Default.h
index e4fecf2..75bd1d8 100644
--- a/Samples/CommonSrc/Platform/Platform_Default.h
+++ b/Samples/CommonSrc/Platform/Platform_Default.h
@@ -3,7 +3,7 @@
Filename : Platform_Default.h
Content : Default Platform class and RenderDevice selection file
Created : October 4, 2012
-Authors :
+Authors :
Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved.
@@ -31,7 +31,7 @@ limitations under the License.
#include "Win32_Platform.h"
#include "../Render/Render_D3D11_Device.h"
- #undef OVR_D3D_VERSION
+ #undef OVR_D3D_VERSION
#include "../Render/Render_D3D10_Device.h"
// #include "../Render/Render_GL_Win32_Device.h"
@@ -46,14 +46,17 @@ limitations under the License.
#define OVR_DEFAULT_RENDER_DEVICE_SET \
SetupGraphicsDeviceSet("GL", &OVR::Render::GL::OSX::RenderDevice::CreateDevice)
-
-#else
+#elif defined(OVR_OS_LINUX)
#include "Linux_Platform.h"
#define OVR_DEFAULT_RENDER_DEVICE_SET \
SetupGraphicsDeviceSet("GL", &OVR::Render::GL::Linux::RenderDevice::CreateDevice)
+#else
+
+ #error "Not implemented yet"
+
#endif
#endif // OVR_Platform_Default_h
diff --git a/Samples/CommonSrc/Platform/Win32_Platform.cpp b/Samples/CommonSrc/Platform/Win32_Platform.cpp
index eeab429..09830d2 100644
--- a/Samples/CommonSrc/Platform/Win32_Platform.cpp
+++ b/Samples/CommonSrc/Platform/Win32_Platform.cpp
@@ -563,7 +563,7 @@ int WINAPI WinMain(HINSTANCE hinst, HINSTANCE prevInst, LPSTR inArgs, int show)
// Nested scope for container destructors to shutdown before DestroyApplication.
{
Array<String> args;
- Array<const char*> argv;
+ Array<char*> argv;
argv.PushBack("app");
const char* p = inArgs;
@@ -584,8 +584,9 @@ int WINAPI WinMain(HINSTANCE hinst, HINSTANCE prevInst, LPSTR inArgs, int show)
}
if (p != pstart)
args.PushBack(String(pstart, p - pstart));
+ // FIXME memory leak of the command line arguments here
for (UPInt i = 0; i < args.GetSize(); i++)
- argv.PushBack(args[i].ToCStr());
+ argv.PushBack(strdup(args[i].ToCStr()));
exitCode = g_app->OnStartup((int)argv.GetSize(), &argv[0]);
if (!exitCode)