Linux_Platform.h
Go to the documentation of this file.
00001 /************************************************************************************
00002 
00003 Filename    :   Platform_Linux.h
00004 Content     :   Linux (X11) implementation of Platform app infrastructure
00005 Created     :   September 6, 2012
00006 Authors     :   Andrew Reisse
00007 
00008 Copyright   :   Copyright 2012 Oculus VR, Inc. All Rights reserved.
00009 
00010 Use of this software is subject to the terms of the Oculus LLC license
00011 agreement provided at the time of installation or download, or which
00012 otherwise accompanies this software in either electronic or hard copy form.
00013 
00014 ************************************************************************************/
00015 
00016 #ifndef OVR_Platform_Linux_h
00017 #define OVR_Platform_Linux_h
00018 
00019 #include <X11/Xlib.h>
00020 #include <X11/Xutil.h>
00021 #include <GL/glx.h>
00022 
00023 #include "Platform.h"
00024 #include "../Render/Render_GL_Device.h"
00025 
00026 namespace OVR { namespace Render {
00027     class RenderDevice;
00028 }}
00029 
00030 namespace OVR { namespace Platform { namespace Linux {
00031 
00032 class PlatformCore : public Platform::PlatformCore
00033 {
00034 public:
00035     Display*     Disp;
00036     XVisualInfo* Vis;
00037     Window       Win;
00038 
00039     bool         Quit;
00040     int          ExitCode;
00041     int          Width, Height;
00042 
00043     MouseMode    MMode;
00044     Cursor       InvisibleCursor;
00045 
00046     enum
00047     {
00048         WM_PROTOCOLS,
00049         WM_DELETE_WINDOW,
00050         NumAtoms
00051     };
00052     Atom Atoms[NumAtoms];
00053 
00054     void processEvent(XEvent& event);
00055 
00056     Render::RenderDevice* SetupGraphics_GL(const Render::RendererParams& rp);
00057 
00058     void showCursor(bool show);
00059     bool determineScreenOffset(int screenId, int* screenOffsetX, int* screenOffsetY);
00060     void showWindowDecorations(bool show);
00061 
00062 public:
00063     PlatformCore(Application* app);
00064     ~PlatformCore();
00065 
00066     bool      SetupWindow(int w, int h);
00067     void      Exit(int exitcode) { Quit = 1; ExitCode = exitcode; }
00068 
00069     RenderDevice* SetupGraphics(const SetupGraphicsDeviceSet& setupGraphicsDesc,
00070                                 const char* gtype, const Render::RendererParams& rp);
00071 
00072     void      SetMouseMode(MouseMode mm);
00073     void      GetWindowSize(int* w, int* h) const;
00074 
00075     void      SetWindowTitle(const char*title);
00076 
00077     void      ShowWindow(bool show);
00078     void      DestroyWindow();
00079     bool      SetFullscreen(const Render::RendererParams& rp, int fullscreen);
00080     int  Run();
00081 };
00082 
00083 }}
00084 namespace Render { namespace GL { namespace Linux {
00085 
00086 class RenderDevice : public Render::GL::RenderDevice
00087 {
00088     Display*   Disp;
00089     Window     Win;
00090     GLXContext Context;
00091 
00092 public:
00093     RenderDevice(const Render::RendererParams& p, Display* disp, Window w, GLXContext gl)
00094     : GL::RenderDevice(p), Disp(disp), Win(w), Context(gl) {}
00095 
00096     virtual void Shutdown();
00097     virtual void Present();
00098 
00099     // oswnd = Linux::PlatformCore*
00100     static Render::RenderDevice* CreateDevice(const RendererParams& rp, void* oswnd);
00101 };
00102 
00103 }}}}
00104 
00105 
00106 // OVR_PLATFORM_APP_ARGS specifies the Application class to use for startup,
00107 // providing it with startup arguments.
00108 #define OVR_PLATFORM_APP_ARGS(AppClass, args)                                            \
00109     OVR::Platform::Application* OVR::Platform::Application::CreateApplication()          \
00110     { OVR::System::Init(OVR::Log::ConfigureDefaultLog(OVR::LogMask_All));                \
00111       return new AppClass args; }                                                        \
00112     void OVR::Platform::Application::DestroyApplication(OVR::Platform::Application* app) \
00113     { OVR::Platform::PlatformCore* platform = app->pPlatform;                            \
00114       delete app; delete platform; OVR::System::Destroy(); };
00115 
00116 // OVR_PLATFORM_APP_ARGS specifies the Application startup class with no args.
00117 #define OVR_PLATFORM_APP(AppClass) OVR_PLATFORM_APP_ARGS(AppClass, ())
00118 
00119 
00120 #endif


oculus_sdk
Author(s):
autogenerated on Mon Oct 6 2014 03:01:18