1 // 2 // Copyright 2015 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 // FunctionsGLX.h: Defines the FunctionsGLX class to load functions and data from GLX 8 9 #ifndef LIBANGLE_RENDERER_GL_GLX_FUNCTIONSGLX_H_ 10 #define LIBANGLE_RENDERER_GL_GLX_FUNCTIONSGLX_H_ 11 12 #include <string> 13 #include <vector> 14 15 #include "libANGLE/renderer/gl/glx/platform_glx.h" 16 17 namespace rx 18 { 19 20 class FunctionsGLX 21 { 22 public: 23 FunctionsGLX(); 24 ~FunctionsGLX(); 25 26 // Load data from GLX, can be called multiple times 27 bool initialize(Display *xDisplay, int screen, std::string *errorString); 28 void terminate(); 29 30 bool hasExtension(const char *extension) const; 31 int majorVersion; 32 int minorVersion; 33 34 Display *getDisplay() const; 35 int getScreen() const; 36 37 PFNGETPROCPROC getProc; 38 39 // GLX 1.0 40 glx::Context createContext(XVisualInfo *visual, glx::Context share, bool direct) const; 41 void destroyContext(glx::Context context) const; 42 Bool makeCurrent(glx::Drawable drawable, glx::Context context) const; 43 void swapBuffers(glx::Drawable drawable) const; 44 Bool queryExtension(int *errorBase, int *event) const; 45 Bool queryVersion(int *major, int *minor) const; 46 glx::Context getCurrentContext() const; 47 glx::Drawable getCurrentDrawable() const; 48 void waitX() const; 49 void waitGL() const; 50 51 // GLX 1.1 52 const char *getClientString(int name) const; 53 const char *queryExtensionsString() const; 54 55 // GLX 1.3 56 glx::FBConfig *getFBConfigs(int *nElements) const; 57 glx::FBConfig *chooseFBConfig(const int *attribList, int *nElements) const; 58 int getFBConfigAttrib(glx::FBConfig config, int attribute, int *value) const; 59 XVisualInfo *getVisualFromFBConfig(glx::FBConfig config) const; 60 glx::Window createWindow(glx::FBConfig config, Window window, const int *attribList) const; 61 void destroyWindow(glx::Window window) const; 62 glx::Pbuffer createPbuffer(glx::FBConfig config, const int *attribList) const; 63 void destroyPbuffer(glx::Pbuffer pbuffer) const; 64 void queryDrawable(glx::Drawable drawable, int attribute, unsigned int *value) const; 65 glx::Pixmap createPixmap(glx::FBConfig config, Pixmap pixmap, const int *attribList) const; 66 void destroyPixmap(Pixmap pixmap) const; 67 68 // GLX_ARB_create_context 69 glx::Context createContextAttribsARB(glx::FBConfig config, 70 glx::Context shareContext, 71 Bool direct, 72 const int *attribList) const; 73 74 // GLX_EXT_swap_control 75 void swapIntervalEXT(glx::Drawable drawable, int interval) const; 76 77 // GLX_MESA_swap_control 78 int swapIntervalMESA(int interval) const; 79 80 // GLX_SGI_swap_control 81 int swapIntervalSGI(int interval) const; 82 83 // GLX_OML_sync_control 84 bool getSyncValuesOML(glx::Drawable drawable, int64_t *ust, int64_t *msc, int64_t *sbc) const; 85 bool getMscRateOML(glx::Drawable drawable, int32_t *numerator, int32_t *denominator) const; 86 87 // GLX_EXT_texture_from_pixmap 88 void bindTexImageEXT(glx::Drawable drawable, int buffer, const int *attribList) const; 89 void releaseTexImageEXT(glx::Drawable drawable, int buffer) const; 90 91 private: 92 // So as to isolate GLX from angle we do not include angleutils.h and cannot 93 // use angle::NonCopyable so we replicated it here instead. 94 FunctionsGLX(const FunctionsGLX &) = delete; 95 void operator=(const FunctionsGLX &) = delete; 96 97 struct GLXFunctionTable; 98 99 static void *sLibHandle; 100 Display *mXDisplay; 101 int mXScreen; 102 103 GLXFunctionTable *mFnPtrs; 104 std::vector<std::string> mExtensions; 105 }; 106 107 } // namespace rx 108 109 #endif // LIBANGLE_RENDERER_GL_GLX_FUNCTIONSGLX_H_ 110