1 // 2 // Copyright 2018 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 // WGLWindow: 7 // Implements initializing a WGL rendering context. 8 // 9 10 #ifndef UTIL_WINDOWS_WGLWINDOW_H_ 11 #define UTIL_WINDOWS_WGLWINDOW_H_ 12 13 #include "common/angleutils.h" 14 #include "export.h" 15 #include "util/EGLWindow.h" 16 17 class OSWindow; 18 19 namespace angle 20 { 21 class Library; 22 } // namespace angle 23 24 class ANGLE_UTIL_EXPORT WGLWindow : public GLWindowBase 25 { 26 public: 27 static WGLWindow *New(EGLenum clientType, int majorVersion, int minorVersion, int profileMask); 28 static void Delete(WGLWindow **window); 29 30 // Internally initializes GL resources. 31 bool initializeGL(OSWindow *osWindow, 32 angle::Library *glWindowingLibrary, 33 angle::GLESDriverType driverType, 34 const EGLPlatformParameters &platformParams, 35 const ConfigParameters &configParams) override; 36 37 GLWindowResult initializeGLWithResult(OSWindow *osWindow, 38 angle::Library *glWindowingLibrary, 39 angle::GLESDriverType driverType, 40 const EGLPlatformParameters &platformParams, 41 const ConfigParameters &configParams) override; 42 43 void destroyGL() override; 44 bool isGLInitialized() const override; 45 bool makeCurrent() override; 46 void swap() override; 47 bool hasError() const override; 48 bool setSwapInterval(EGLint swapInterval) override; 49 angle::GenericProc getProcAddress(const char *name) override; 50 // Initializes WGL resources. 51 GLWindowContext getCurrentContextGeneric() override; 52 GLWindowContext createContextGeneric(GLWindowContext share) override; 53 bool makeCurrentGeneric(GLWindowContext context) override; 54 Image createImage(GLWindowContext context, 55 Enum target, 56 ClientBuffer buffer, 57 const Attrib *attrib_list) override; 58 Image createImageKHR(GLWindowContext context, 59 Enum target, 60 ClientBuffer buffer, 61 const AttribKHR *attrib_list) override; 62 EGLBoolean destroyImage(Image image) override; 63 EGLBoolean destroyImageKHR(Image image) override; 64 Sync createSync(EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list) override; 65 Sync createSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list) override; 66 EGLBoolean destroySync(EGLDisplay dpy, Sync sync) override; 67 EGLBoolean destroySyncKHR(EGLDisplay dpy, Sync sync) override; 68 EGLint clientWaitSync(EGLDisplay dpy, Sync sync, EGLint flags, EGLTimeKHR timeout) override; 69 EGLint clientWaitSyncKHR(EGLDisplay dpy, Sync sync, EGLint flags, EGLTimeKHR timeout) override; 70 EGLint getEGLError() override; 71 Display getCurrentDisplay() override; 72 Surface createPbufferSurface(const EGLint *attrib_list) override; 73 EGLBoolean destroySurface(Surface surface) override; 74 75 EGLBoolean bindTexImage(EGLSurface surface, EGLint buffer) override; 76 EGLBoolean releaseTexImage(EGLSurface surface, EGLint buffer) override; 77 bool makeCurrent(EGLSurface draw, EGLSurface read, EGLContext context) override; 78 79 // Create a WGL context with this window's configuration 80 HGLRC createContext(const ConfigParameters &configParams, HGLRC shareContext); 81 // Make the WGL context current 82 bool makeCurrent(HGLRC context); 83 84 private: 85 WGLWindow(EGLenum clientType, int majorVersion, int minorVersion, int profileMask); 86 ~WGLWindow() override; 87 88 // OS resources. 89 HDC mDeviceContext; 90 HGLRC mWGLContext; 91 HWND mWindow; 92 }; 93 94 #endif // UTIL_WINDOWS_WGLWINDOW_H_ 95