OSDN Git Service

Implement a Radiance prototype.
[android-x86/external-swiftshader.git] / src / Main / FrameBufferWin.cpp
1 // SwiftShader Software Renderer\r
2 //\r
3 // Copyright(c) 2005-2012 TransGaming Inc.\r
4 //\r
5 // All rights reserved. No part of this software may be copied, distributed, transmitted,\r
6 // transcribed, stored in a retrieval system, translated into any human or computer\r
7 // language by any means, or disclosed to third parties without the explicit written\r
8 // agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express\r
9 // or implied, including but not limited to any patent rights, are granted to you.\r
10 //\r
11 \r
12 #include "FrameBufferWin.hpp"\r
13 \r
14 namespace sw\r
15 {\r
16         FrameBufferWin::FrameBufferWin(HWND windowHandle, int width, int height, bool fullscreen, bool topLeftOrigin) : FrameBuffer(width, height, fullscreen, topLeftOrigin), windowHandle(windowHandle)\r
17         {\r
18                 if(!windowed)\r
19                 {\r
20                         // Force fullscreen window style (no borders)\r
21                         originalWindowStyle = GetWindowLong(windowHandle, GWL_STYLE);\r
22                         SetWindowLong(windowHandle, GWL_STYLE, WS_POPUP);\r
23                 }\r
24         }\r
25 \r
26         FrameBufferWin::~FrameBufferWin()\r
27         {\r
28                 if(!windowed && GetWindowLong(windowHandle, GWL_STYLE) == WS_POPUP)\r
29                 {\r
30                         SetWindowLong(windowHandle, GWL_STYLE, originalWindowStyle);\r
31                 }\r
32         }\r
33 \r
34         void FrameBufferWin::updateBounds(HWND windowOverride)\r
35         {\r
36                 HWND window = windowOverride ? windowOverride : windowHandle;\r
37 \r
38                 if(windowed)\r
39                 {\r
40                         GetClientRect(window, &bounds);\r
41                         ClientToScreen(window, (POINT*)&bounds);\r
42                         ClientToScreen(window, (POINT*)&bounds + 1);\r
43                 }\r
44                 else\r
45                 {\r
46                         SetRect(&bounds, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));\r
47                 }\r
48         }\r
49 }\r
50 \r
51 #include "FrameBufferDD.hpp"\r
52 #include "FrameBufferGDI.hpp"\r
53 #include "Common/Configurator.hpp"\r
54 \r
55 extern "C"\r
56 {\r
57         sw::FrameBufferWin *createFrameBufferWin(HWND windowHandle, int width, int height, bool fullscreen, bool topLeftOrigin)\r
58         {\r
59                 sw::Configurator ini("SwiftShader.ini");\r
60                 int api = ini.getInteger("Testing", "FrameBufferAPI", 0);\r
61 \r
62                 if(api == 0 && topLeftOrigin)\r
63                 {\r
64                         return new sw::FrameBufferDD(windowHandle, width, height, fullscreen, topLeftOrigin);\r
65                 }\r
66                 else\r
67                 {\r
68                         return new sw::FrameBufferGDI(windowHandle, width, height, fullscreen, topLeftOrigin);\r
69                 }\r
70 \r
71                 return 0;\r
72         }\r
73 \r
74         sw::FrameBuffer *createFrameBuffer(HDC display, HWND window, int width, int height)\r
75         {\r
76                 return createFrameBufferWin(window, width, height, false, false);\r
77         }\r
78 }\r