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