blob: 2c59bb3208d3fb18bb16f2fd8ec9f8895ce6430f [file] [log] [blame]
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001//
2// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
3// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6
7// Display.cpp: Implements the egl::Display class, representing the abstract
8// display on which graphics are drawn. Implements EGLDisplay.
9// [EGL 1.4] section 2.1.2 page 3.
10
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000011#include "libEGL/Display.h"
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000012
daniel@transgaming.com16973022010-03-11 19:22:19 +000013#include <algorithm>
14#include <vector>
15
alokp@chromium.orgea0e1af2010-03-22 19:33:14 +000016#include "common/debug.h"
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000017
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000018#include "libEGL/main.h"
19
daniel@transgaming.com741a5882010-05-20 19:17:29 +000020#define REF_RAST 0 // Can also be enabled by defining FORCE_REF_RAST in the project's predefined macros
21
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000022namespace egl
23{
24Display::Display(HDC deviceContext) : mDc(deviceContext)
25{
26 mD3d9 = NULL;
27 mDevice = NULL;
28
29 mAdapter = D3DADAPTER_DEFAULT;
daniel@transgaming.com741a5882010-05-20 19:17:29 +000030
daniel@transgaming.com8b9f4cc2010-05-20 19:17:35 +000031 #if REF_RAST == 1 || defined(FORCE_REF_RAST)
daniel@transgaming.com741a5882010-05-20 19:17:29 +000032 mDeviceType = D3DDEVTYPE_REF;
33 #else
34 mDeviceType = D3DDEVTYPE_HAL;
35 #endif
daniel@transgaming.com616ffcf2010-05-07 19:01:49 +000036
37 mMinSwapInterval = 1;
38 mMaxSwapInterval = 1;
39 setSwapInterval(1);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000040}
41
42Display::~Display()
43{
44 terminate();
45}
46
47bool Display::initialize()
48{
49 if (isInitialized())
50 {
51 return true;
52 }
53
54 mD3d9 = Direct3DCreate9(D3D_SDK_VERSION);
55
56 if (mD3d9)
57 {
58 if (mDc != NULL)
59 {
daniel@transgaming.com02bc1592010-03-30 03:36:13 +000060 // UNIMPLEMENTED(); // FIXME: Determine which adapter index the device context corresponds to
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000061 }
62
daniel@transgaming.com353569a2010-06-24 13:02:12 +000063 HRESULT result = mD3d9->GetDeviceCaps(mAdapter, mDeviceType, &mDeviceCaps);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000064
65 if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY)
66 {
67 return error(EGL_BAD_ALLOC, false);
68 }
69
daniel@transgaming.com353569a2010-06-24 13:02:12 +000070 if (mDeviceCaps.PixelShaderVersion < D3DPS_VERSION(2, 0))
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000071 {
72 mD3d9->Release();
73 mD3d9 = NULL;
74 }
75 else
76 {
daniel@transgaming.com616ffcf2010-05-07 19:01:49 +000077 mMinSwapInterval = 4;
78 mMaxSwapInterval = 0;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000079
daniel@transgaming.com353569a2010-06-24 13:02:12 +000080 if (mDeviceCaps.PresentationIntervals & D3DPRESENT_INTERVAL_IMMEDIATE) {mMinSwapInterval = std::min(mMinSwapInterval, 0); mMaxSwapInterval = std::max(mMaxSwapInterval, 0);}
81 if (mDeviceCaps.PresentationIntervals & D3DPRESENT_INTERVAL_ONE) {mMinSwapInterval = std::min(mMinSwapInterval, 1); mMaxSwapInterval = std::max(mMaxSwapInterval, 1);}
82 if (mDeviceCaps.PresentationIntervals & D3DPRESENT_INTERVAL_TWO) {mMinSwapInterval = std::min(mMinSwapInterval, 2); mMaxSwapInterval = std::max(mMaxSwapInterval, 2);}
83 if (mDeviceCaps.PresentationIntervals & D3DPRESENT_INTERVAL_THREE) {mMinSwapInterval = std::min(mMinSwapInterval, 3); mMaxSwapInterval = std::max(mMaxSwapInterval, 3);}
84 if (mDeviceCaps.PresentationIntervals & D3DPRESENT_INTERVAL_FOUR) {mMinSwapInterval = std::min(mMinSwapInterval, 4); mMaxSwapInterval = std::max(mMaxSwapInterval, 4);}
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000085
daniel@transgaming.comadf02842010-05-07 13:03:33 +000086 const D3DFORMAT renderTargetFormats[] =
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000087 {
88 D3DFMT_A1R5G5B5,
daniel@transgaming.comadf02842010-05-07 13:03:33 +000089 // D3DFMT_A2R10G10B10, // The color_ramp conformance test uses ReadPixels with UNSIGNED_BYTE causing it to think that rendering skipped a colour value.
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000090 D3DFMT_A8R8G8B8,
91 D3DFMT_R5G6B5,
92 D3DFMT_X1R5G5B5,
93 D3DFMT_X8R8G8B8
94 };
95
96 const D3DFORMAT depthStencilFormats[] =
97 {
daniel@transgaming.com02bc1592010-03-30 03:36:13 +000098 // D3DFMT_D16_LOCKABLE,
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000099 D3DFMT_D32,
daniel@transgaming.comd1f6fde2010-05-07 19:01:43 +0000100 // D3DFMT_D15S1,
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000101 D3DFMT_D24S8,
102 D3DFMT_D24X8,
daniel@transgaming.comd1f6fde2010-05-07 19:01:43 +0000103 // D3DFMT_D24X4S4,
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000104 D3DFMT_D16,
daniel@transgaming.com02bc1592010-03-30 03:36:13 +0000105 // D3DFMT_D32F_LOCKABLE,
106 // D3DFMT_D24FS8
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000107 };
108
109 D3DDISPLAYMODE currentDisplayMode;
110 mD3d9->GetAdapterDisplayMode(mAdapter, &currentDisplayMode);
111
daniel@transgaming.com178adff2010-05-18 18:52:04 +0000112 ConfigSet configSet;
113
daniel@transgaming.comadf02842010-05-07 13:03:33 +0000114 for (int formatIndex = 0; formatIndex < sizeof(renderTargetFormats) / sizeof(D3DFORMAT); formatIndex++)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000115 {
daniel@transgaming.comadf02842010-05-07 13:03:33 +0000116 D3DFORMAT renderTargetFormat = renderTargetFormats[formatIndex];
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000117
118 HRESULT result = mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_RENDERTARGET, D3DRTYPE_SURFACE, renderTargetFormat);
119
120 if (SUCCEEDED(result))
121 {
122 for (int depthStencilIndex = 0; depthStencilIndex < sizeof(depthStencilFormats) / sizeof(D3DFORMAT); depthStencilIndex++)
123 {
124 D3DFORMAT depthStencilFormat = depthStencilFormats[depthStencilIndex];
125 HRESULT result = mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, depthStencilFormat);
126
127 if (SUCCEEDED(result))
128 {
daniel@transgaming.comadf02842010-05-07 13:03:33 +0000129 HRESULT result = mD3d9->CheckDepthStencilMatch(mAdapter, mDeviceType, currentDisplayMode.Format, renderTargetFormat, depthStencilFormat);
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +0000130
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000131 if (SUCCEEDED(result))
132 {
133 // FIXME: Enumerate multi-sampling
134
daniel@transgaming.com178adff2010-05-18 18:52:04 +0000135 configSet.add(currentDisplayMode, mMinSwapInterval, mMaxSwapInterval, renderTargetFormat, depthStencilFormat, 0);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000136 }
137 }
138 }
139 }
140 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000141
daniel@transgaming.com178adff2010-05-18 18:52:04 +0000142 // Give the sorted configs a unique ID and store them internally
143 EGLint index = 1;
144 for (ConfigSet::Iterator config = configSet.mSet.begin(); config != configSet.mSet.end(); config++)
145 {
146 Config configuration = *config;
147 configuration.mConfigID = index;
148 index++;
149
150 mConfigSet.mSet.insert(configuration);
151 }
152 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000153 }
154
155 if (!isInitialized())
156 {
157 terminate();
158
159 return false;
160 }
161
162 return true;
163}
164
165void Display::terminate()
166{
167 for (SurfaceSet::iterator surface = mSurfaceSet.begin(); surface != mSurfaceSet.end(); surface++)
168 {
169 delete *surface;
170 }
171
172 for (ContextSet::iterator context = mContextSet.begin(); context != mContextSet.end(); context++)
173 {
174 glDestroyContext(*context);
175 }
176
177 if (mDevice)
178 {
179 mDevice->Release();
180 mDevice = NULL;
181 }
182
183 if (mD3d9)
184 {
185 mD3d9->Release();
186 mD3d9 = NULL;
187 }
188}
189
daniel@transgaming.comae072af2010-05-05 18:47:28 +0000190void Display::startScene()
191{
192 if (!mSceneStarted)
193 {
194 long result = mDevice->BeginScene();
195 ASSERT(SUCCEEDED(result));
196 mSceneStarted = true;
197 }
198}
199
200void Display::endScene()
201{
202 if (mSceneStarted)
203 {
204 long result = mDevice->EndScene();
205 ASSERT(SUCCEEDED(result));
206 mSceneStarted = false;
207 }
208}
209
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000210bool Display::getConfigs(EGLConfig *configs, const EGLint *attribList, EGLint configSize, EGLint *numConfig)
211{
212 return mConfigSet.getConfigs(configs, attribList, configSize, numConfig);
213}
214
215bool Display::getConfigAttrib(EGLConfig config, EGLint attribute, EGLint *value)
216{
217 const egl::Config *configuration = mConfigSet.get(config);
218
219 switch (attribute)
220 {
221 case EGL_BUFFER_SIZE: *value = configuration->mBufferSize; break;
222 case EGL_ALPHA_SIZE: *value = configuration->mAlphaSize; break;
223 case EGL_BLUE_SIZE: *value = configuration->mBlueSize; break;
224 case EGL_GREEN_SIZE: *value = configuration->mGreenSize; break;
225 case EGL_RED_SIZE: *value = configuration->mRedSize; break;
226 case EGL_DEPTH_SIZE: *value = configuration->mDepthSize; break;
227 case EGL_STENCIL_SIZE: *value = configuration->mStencilSize; break;
228 case EGL_CONFIG_CAVEAT: *value = configuration->mConfigCaveat; break;
229 case EGL_CONFIG_ID: *value = configuration->mConfigID; break;
230 case EGL_LEVEL: *value = configuration->mLevel; break;
231 case EGL_NATIVE_RENDERABLE: *value = configuration->mNativeRenderable; break;
232 case EGL_NATIVE_VISUAL_TYPE: *value = configuration->mNativeVisualType; break;
233 case EGL_SAMPLES: *value = configuration->mSamples; break;
234 case EGL_SAMPLE_BUFFERS: *value = configuration->mSampleBuffers; break;
235 case EGL_SURFACE_TYPE: *value = configuration->mSurfaceType; break;
236 case EGL_TRANSPARENT_TYPE: *value = configuration->mTransparentType; break;
237 case EGL_TRANSPARENT_BLUE_VALUE: *value = configuration->mTransparentBlueValue; break;
238 case EGL_TRANSPARENT_GREEN_VALUE: *value = configuration->mTransparentGreenValue; break;
239 case EGL_TRANSPARENT_RED_VALUE: *value = configuration->mTransparentRedValue; break;
240 case EGL_BIND_TO_TEXTURE_RGB: *value = configuration->mBindToTextureRGB; break;
241 case EGL_BIND_TO_TEXTURE_RGBA: *value = configuration->mBindToTextureRGBA; break;
242 case EGL_MIN_SWAP_INTERVAL: *value = configuration->mMinSwapInterval; break;
243 case EGL_MAX_SWAP_INTERVAL: *value = configuration->mMaxSwapInterval; break;
244 case EGL_LUMINANCE_SIZE: *value = configuration->mLuminanceSize; break;
245 case EGL_ALPHA_MASK_SIZE: *value = configuration->mAlphaMaskSize; break;
246 case EGL_COLOR_BUFFER_TYPE: *value = configuration->mColorBufferType; break;
247 case EGL_RENDERABLE_TYPE: *value = configuration->mRenderableType; break;
daniel@transgaming.comb6bd7272010-05-05 18:48:22 +0000248 case EGL_MATCH_NATIVE_PIXMAP: *value = false; UNIMPLEMENTED(); break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000249 case EGL_CONFORMANT: *value = configuration->mConformant; break;
250 default:
251 return false;
252 }
253
254 return true;
255}
256
daniel@transgaming.comb6bd7272010-05-05 18:48:22 +0000257Surface *Display::createWindowSurface(HWND window, EGLConfig config)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000258{
daniel@transgaming.comb6bd7272010-05-05 18:48:22 +0000259 const Config *configuration = mConfigSet.get(config);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000260
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000261 D3DPRESENT_PARAMETERS presentParameters = {0};
262
263 presentParameters.AutoDepthStencilFormat = configuration->mDepthStencilFormat;
264 presentParameters.BackBufferCount = 1;
265 presentParameters.BackBufferFormat = configuration->mRenderTargetFormat;
266 presentParameters.BackBufferWidth = 0;
267 presentParameters.BackBufferHeight = 0;
268 presentParameters.EnableAutoDepthStencil = configuration->mDepthSize ? TRUE : FALSE;
269 presentParameters.Flags = 0;
270 presentParameters.hDeviceWindow = window;
271 presentParameters.MultiSampleQuality = 0; // FIXME: Unimplemented
272 presentParameters.MultiSampleType = D3DMULTISAMPLE_NONE; // FIXME: Unimplemented
daniel@transgaming.com616ffcf2010-05-07 19:01:49 +0000273 presentParameters.PresentationInterval = convertInterval(mMinSwapInterval);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000274 presentParameters.SwapEffect = D3DSWAPEFFECT_COPY;
275 presentParameters.Windowed = TRUE; // FIXME
276
277 IDirect3DSwapChain9 *swapChain = NULL;
daniel@transgaming.com0009d622010-03-16 06:23:31 +0000278 IDirect3DSurface9 *depthStencilSurface = NULL;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000279
280 if (!mDevice)
281 {
daniel@transgaming.com02bc1592010-03-30 03:36:13 +0000282 DWORD behaviorFlags = D3DCREATE_FPU_PRESERVE | D3DCREATE_NOWINDOWCHANGES;
283
daniel@transgaming.comc28e76b2010-05-05 18:47:16 +0000284 HRESULT result = mD3d9->CreateDevice(mAdapter, mDeviceType, window, behaviorFlags | D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_PUREDEVICE, &presentParameters, &mDevice);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000285
286 if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY)
287 {
288 return error(EGL_BAD_ALLOC, (egl::Surface*)NULL);
289 }
290
daniel@transgaming.com02bc1592010-03-30 03:36:13 +0000291 if (FAILED(result))
292 {
daniel@transgaming.comc28e76b2010-05-05 18:47:16 +0000293 result = mD3d9->CreateDevice(mAdapter, mDeviceType, window, behaviorFlags | D3DCREATE_SOFTWARE_VERTEXPROCESSING, &presentParameters, &mDevice);
daniel@transgaming.com02bc1592010-03-30 03:36:13 +0000294
295 if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY)
296 {
297 return error(EGL_BAD_ALLOC, (egl::Surface*)NULL);
298 }
299 }
300
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000301 ASSERT(SUCCEEDED(result));
302
303 if (mDevice)
304 {
daniel@transgaming.comc9def0b2010-05-05 18:48:06 +0000305 mSceneStarted = false;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000306 mDevice->GetSwapChain(0, &swapChain);
daniel@transgaming.com0009d622010-03-16 06:23:31 +0000307 mDevice->GetDepthStencilSurface(&depthStencilSurface);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000308 }
309 }
310 else
311 {
daniel@transgaming.com0009d622010-03-16 06:23:31 +0000312 if (!mSurfaceSet.empty())
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000313 {
daniel@transgaming.com0009d622010-03-16 06:23:31 +0000314 // if the device already exists, and there are other surfaces/windows currently in use, we need to create
315 // a separate swap chain for the new draw surface.
316 HRESULT result = mDevice->CreateAdditionalSwapChain(&presentParameters, &swapChain);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000317
daniel@transgaming.com0009d622010-03-16 06:23:31 +0000318 if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY)
319 {
320 ERR("Could not create additional swap chains. Out of memory.");
321 return error(EGL_BAD_ALLOC, (egl::Surface*)NULL);
322 }
323
324 ASSERT(SUCCEEDED(result));
325
326 // CreateAdditionalSwapChain does not automatically generate a depthstencil surface, unlike
327 // CreateDevice, so we must do so explicitly.
328 result = mDevice->CreateDepthStencilSurface(presentParameters.BackBufferWidth, presentParameters.BackBufferHeight,
329 presentParameters.AutoDepthStencilFormat, presentParameters.MultiSampleType,
330 presentParameters.MultiSampleQuality, FALSE, &depthStencilSurface, NULL);
331
332 if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY)
333 {
334 swapChain->Release();
335 ERR("Could not create depthstencil surface for new swap chain. Out of memory.");
336 return error(EGL_BAD_ALLOC, (egl::Surface*)NULL);
337 }
338
339 ASSERT(SUCCEEDED(result));
340 }
341 else
342 {
343 // if the device already exists, but there are no surfaces in use, then all the surfaces/windows
344 // have been destroyed, and we should repurpose the originally created depthstencil surface for
345 // use with the new surface we are creating.
346 HRESULT result = mDevice->Reset(&presentParameters);
347
348 if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY)
349 {
daniel@transgaming.comc9def0b2010-05-05 18:48:06 +0000350 ERR("Could not reset presentation parameters for device. Out of memory.");
daniel@transgaming.com0009d622010-03-16 06:23:31 +0000351 return error(EGL_BAD_ALLOC, (egl::Surface*)NULL);
352 }
353
354 ASSERT(SUCCEEDED(result));
355
356 if (mDevice)
357 {
daniel@transgaming.comc9def0b2010-05-05 18:48:06 +0000358 mSceneStarted = false;
daniel@transgaming.com0009d622010-03-16 06:23:31 +0000359 mDevice->GetSwapChain(0, &swapChain);
360 mDevice->GetDepthStencilSurface(&depthStencilSurface);
361 }
362 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000363 }
364
daniel@transgaming.combe5a0862010-07-28 19:20:37 +0000365 // Permanent non-default states
366 mDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, TRUE);
367
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000368 Surface *surface = NULL;
369
370 if (swapChain)
371 {
daniel@transgaming.comb6bd7272010-05-05 18:48:22 +0000372 surface = new Surface(this, swapChain, depthStencilSurface, configuration);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000373 mSurfaceSet.insert(surface);
374
375 swapChain->Release();
376 }
daniel@transgaming.comfab5a1a2010-03-11 19:22:30 +0000377
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000378 return surface;
379}
380
381EGLContext Display::createContext(EGLConfig configHandle)
382{
383 const egl::Config *config = mConfigSet.get(configHandle);
384
385 gl::Context *context = glCreateContext(config);
386 mContextSet.insert(context);
387
388 return context;
389}
390
391void Display::destroySurface(egl::Surface *surface)
392{
393 delete surface;
394 mSurfaceSet.erase(surface);
395}
396
397void Display::destroyContext(gl::Context *context)
398{
399 glDestroyContext(context);
400 mContextSet.erase(context);
401}
402
403bool Display::isInitialized()
404{
405 return mD3d9 != NULL && mConfigSet.size() > 0;
406}
407
408bool Display::isValidConfig(EGLConfig config)
409{
410 return mConfigSet.get(config) != NULL;
411}
412
413bool Display::isValidContext(gl::Context *context)
414{
415 return mContextSet.find(context) != mContextSet.end();
416}
417
418bool Display::isValidSurface(egl::Surface *surface)
419{
420 return mSurfaceSet.find(surface) != mSurfaceSet.end();
421}
422
423bool Display::hasExistingWindowSurface(HWND window)
424{
425 for (SurfaceSet::iterator surface = mSurfaceSet.begin(); surface != mSurfaceSet.end(); surface++)
426 {
427 if ((*surface)->getWindowHandle() == window)
428 {
429 return true;
430 }
431 }
432
433 return false;
434}
435
daniel@transgaming.comb6bd7272010-05-05 18:48:22 +0000436void Display::setSwapInterval(GLint interval)
437{
438 mSwapInterval = interval;
daniel@transgaming.com616ffcf2010-05-07 19:01:49 +0000439 mSwapInterval = std::max(mSwapInterval, mMinSwapInterval);
440 mSwapInterval = std::min(mSwapInterval, mMaxSwapInterval);
441
442 mPresentInterval = convertInterval(mSwapInterval);
daniel@transgaming.comb6bd7272010-05-05 18:48:22 +0000443}
444
daniel@transgaming.com616ffcf2010-05-07 19:01:49 +0000445DWORD Display::getPresentInterval()
daniel@transgaming.comb6bd7272010-05-05 18:48:22 +0000446{
daniel@transgaming.com616ffcf2010-05-07 19:01:49 +0000447 return mPresentInterval;
448}
daniel@transgaming.comb6bd7272010-05-05 18:48:22 +0000449
daniel@transgaming.com616ffcf2010-05-07 19:01:49 +0000450DWORD Display::convertInterval(GLint interval)
451{
daniel@transgaming.comb6bd7272010-05-05 18:48:22 +0000452 switch(interval)
453 {
454 case 0: return D3DPRESENT_INTERVAL_IMMEDIATE;
455 case 1: return D3DPRESENT_INTERVAL_ONE;
456 case 2: return D3DPRESENT_INTERVAL_TWO;
457 case 3: return D3DPRESENT_INTERVAL_THREE;
458 case 4: return D3DPRESENT_INTERVAL_FOUR;
459 default: UNREACHABLE();
460 }
461
462 return D3DPRESENT_INTERVAL_DEFAULT;
463}
464
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000465IDirect3DDevice9 *Display::getDevice()
466{
467 return mDevice;
468}
daniel@transgaming.com353569a2010-06-24 13:02:12 +0000469
470D3DCAPS9 Display::getDeviceCaps()
471{
472 return mDeviceCaps;
473}
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000474}