Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "Render_GL_Win32_Device.h"
00025
00026 namespace OVR { namespace Render { namespace GL { namespace Win32 {
00027
00028
00029
00030
00031
00032 Render::RenderDevice* RenderDevice::CreateDevice(const RendererParams&, void* oswnd)
00033 {
00034 HWND hwnd = (HWND)oswnd;
00035
00036 PIXELFORMATDESCRIPTOR pfd;
00037 memset(&pfd, 0, sizeof(pfd));
00038
00039 pfd.nSize = sizeof(pfd);
00040 pfd.nVersion = 1;
00041 pfd.iPixelType = PFD_TYPE_RGBA;
00042 pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW | PFD_DOUBLEBUFFER;
00043 pfd.cColorBits = 32;
00044 pfd.cDepthBits = 16;
00045
00046 HDC dc = GetDC(hwnd);
00047 int pf = ChoosePixelFormat(dc, &pfd);
00048 if (!pf)
00049 {
00050 ReleaseDC(hwnd, dc);
00051 return NULL;
00052 }
00053 if (!SetPixelFormat(dc, pf, &pfd))
00054 {
00055 ReleaseDC(hwnd, dc);
00056 return NULL;
00057 }
00058 HGLRC context = wglCreateContext(dc);
00059 if (!wglMakeCurrent(dc, context))
00060 {
00061 wglDeleteContext(context);
00062 ReleaseDC(hwnd, dc);
00063 return NULL;
00064 }
00065
00066
00067 return 0;
00068 }
00069
00070
00071 void RenderDevice::Present()
00072 {
00073 SwapBuffers(GdiDc);
00074 }
00075
00076 void RenderDevice::Shutdown()
00077 {
00078 if (WglContext)
00079 {
00080 wglMakeCurrent(NULL,NULL);
00081 wglDeleteContext(WglContext);
00082 ReleaseDC(Window, GdiDc);
00083 WglContext = NULL;
00084 GdiDc = NULL;
00085 Window = NULL;
00086 }
00087 }
00088
00089 }}}}
00090