1 /*------------------------------------------------------------------------- 2 * drawElements Quality Program Tester Core 3 * ---------------------------------------- 4 * 5 * Copyright 2016 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 #include "tcuWin32EGLNativeDisplayFactory.hpp" 27 #include "egluGLContextFactory.hpp" 28 29 namespace tcu 30 { 31 namespace win32 32 { 33 34 Platform::Platform (void) 35 : m_instance (GetModuleHandle(NULL)) 36 , m_vulkanPlatform (m_instance) 37 { 38 // Set process priority to lower. 39 SetPriorityClass(GetCurrentProcess(), BELOW_NORMAL_PRIORITY_CLASS); 40 41 { 42 wgl::ContextFactory* factory = DE_NULL; 43 44 try 45 { 46 factory = new wgl::ContextFactory(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 m_nativeDisplayFactoryRegistry.registerFactory(new win32::EGLNativeDisplayFactory(m_instance)); 68 m_contextFactoryRegistry.registerFactory(new eglu::GLContextFactory(m_nativeDisplayFactoryRegistry)); 69 } 70 71 Platform::~Platform (void) 72 { 73 } 74 75 bool Platform::processEvents (void) 76 { 77 MSG msg; 78 while (PeekMessage(&msg, (HWND)-1, 0, 0, PM_REMOVE)) 79 { 80 DispatchMessage(&msg); 81 if (msg.message == WM_QUIT) 82 return false; 83 } 84 return true; 85 } 86 87 } // win32 88 } // tcu 89 90 // Create platform 91 tcu::Platform* createPlatform (void) 92 { 93 return new tcu::win32::Platform(); 94 } 95