1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program Tester Core
3 * ----------------------------------------
4 *
5 * Copyright 2014 The Android Open Source Project
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 *//*!
20 * \file
21 * \brief Win32 platform port.
22 *//*--------------------------------------------------------------------*/
23
24 #include "tcuWin32Platform.hpp"
25 #include "tcuWGLContextFactory.hpp"
26
27 #if defined(DEQP_SUPPORT_EGL)
28 # include "tcuWin32EGLNativeDisplayFactory.hpp"
29 # include "egluGLContextFactory.hpp"
30 #endif
31
32 namespace tcu
33 {
34
Win32Platform(void)35 Win32Platform::Win32Platform (void)
36 : m_instance(GetModuleHandle(NULL))
37 {
38 // Set process priority to lower.
39 SetPriorityClass(GetCurrentProcess(), BELOW_NORMAL_PRIORITY_CLASS);
40
41 {
42 WGLContextFactory* factory = DE_NULL;
43
44 try
45 {
46 factory = new WGLContextFactory(m_instance);
47 }
48 catch (const std::exception& e)
49 {
50 print("Warning: WGL not supported: %s\n", e.what());
51 }
52
53 if (factory)
54 {
55 try
56 {
57 m_contextFactoryRegistry.registerFactory(factory);
58 }
59 catch (...)
60 {
61 delete factory;
62 throw;
63 }
64 }
65 }
66
67 #if defined(DEQP_SUPPORT_EGL)
68 m_nativeDisplayFactoryRegistry.registerFactory(new Win32EGLNativeDisplayFactory(m_instance));
69 m_contextFactoryRegistry.registerFactory(new eglu::GLContextFactory(m_nativeDisplayFactoryRegistry));
70 #endif
71 }
72
~Win32Platform(void)73 Win32Platform::~Win32Platform (void)
74 {
75 }
76
processEvents(void)77 bool Win32Platform::processEvents (void)
78 {
79 MSG msg;
80 while (PeekMessage(&msg, (HWND)-1, 0, 0, PM_REMOVE))
81 {
82 DispatchMessage(&msg);
83 if (msg.message == WM_QUIT)
84 return false;
85 }
86 return true;
87 }
88
89 } // tcu
90
91 // Create platform
createPlatform(void)92 tcu::Platform* createPlatform (void)
93 {
94 return new tcu::Win32Platform();
95 }
96