Win32_Platform.h
Go to the documentation of this file.
00001 /************************************************************************************
00002 
00003 Filename    :   Win32_Platform.h
00004 Content     :   Win32 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 Licensed under the Apache License, Version 2.0 (the "License");
00011 you may not use this file except in compliance with the License.
00012 You may obtain a copy of the License at
00013 
00014 http://www.apache.org/licenses/LICENSE-2.0
00015 
00016 Unless required by applicable law or agreed to in writing, software
00017 distributed under the License is distributed on an "AS IS" BASIS,
00018 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00019 See the License for the specific language governing permissions and
00020 limitations under the License.
00021 
00022 ************************************************************************************/
00023 
00024 #ifndef OVR_Win32_Platform_h
00025 #define OVR_Win32_Platform_h
00026 
00027 #include "Platform.h"
00028 #include <windows.h>
00029 
00030 
00031 namespace OVR { namespace Render {
00032     class RenderDevice;
00033     struct DisplayId;
00034 }}
00035 
00036 namespace OVR { namespace Platform { namespace Win32 {
00037 
00038 class PlatformCore : public Platform::PlatformCore
00039 {
00040     HWND        hWnd;
00041     HINSTANCE   hInstance;
00042     bool        Quit;
00043     int         ExitCode;
00044     int         Width, Height;
00045 
00046     MouseMode   MMode;    
00047     POINT       WindowCenter; // In desktop coordinates
00048     HCURSOR     Cursor;
00049     int         Modifiers;
00050     String      WindowTitle;
00051 
00052     // Win32 static function that delegates to WindowProc member function.
00053     static LRESULT CALLBACK systemWindowProc(HWND window, UINT msg, WPARAM wp, LPARAM lp);
00054 
00055     LRESULT     WindowProc(UINT msg, WPARAM wp, LPARAM lp);
00056 
00057 public:
00058     PlatformCore(Application* app, HINSTANCE hinst);
00059     ~PlatformCore();
00060 
00061     bool      SetupWindow(int w, int h);
00062     void      DestroyWindow();
00063     void      ShowWindow(bool visible);
00064     void      Exit(int exitcode) { Quit = 1; ExitCode = exitcode; }
00065 
00066     RenderDevice* SetupGraphics(const SetupGraphicsDeviceSet& setupGraphicsDesc,
00067                                 const char* type,
00068                                 const Render::RendererParams& rp);
00069 
00070     void      SetMouseMode(MouseMode mm);
00071     void      GetWindowSize(int* w, int* h) const;
00072 
00073     void      SetWindowTitle(const char*title);
00074         void      PlayMusicFile(const char *fileName);
00075     int       GetDisplayCount();
00076     Render::DisplayId    GetDisplay(int screen);
00077 
00078     int       Run();
00079 };
00080 
00081 
00082 // Win32 key conversion helper.
00083 KeyCode MapVKToKeyCode(unsigned vk);
00084 
00085 }}}
00086 
00087 
00088 // OVR_PLATFORM_APP_ARGS specifies the Application class to use for startup,
00089 // providing it with startup arguments.
00090 #define OVR_PLATFORM_APP_ARGS(AppClass, args)                                            \
00091     OVR::Platform::Application* OVR::Platform::Application::CreateApplication()          \
00092     { OVR::System::Init(OVR::Log::ConfigureDefaultLog(OVR::LogMask_All));                \
00093       return new AppClass args; }                                                        \
00094     void OVR::Platform::Application::DestroyApplication(OVR::Platform::Application* app) \
00095     { OVR::Platform::PlatformCore* platform = app->pPlatform;                            \
00096       delete app; delete platform; OVR::System::Destroy(); };
00097 
00098 // OVR_PLATFORM_APP_ARGS specifies the Application startup class with no args.
00099 #define OVR_PLATFORM_APP(AppClass) OVR_PLATFORM_APP_ARGS(AppClass, ())
00100 
00101 #endif // OVR_Win32_Platform_h


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