1 #pragma once 2 3 #include <X11/Xlib.h> 4 #include <GL/glx.h> 5 6 #include "aemu/base/export.h" 7 8 // GLX 9 #define LIST_GLX_FUNCS(f) \ 10 f(glXQueryVersion) \ 11 f(glXGetFBConfigs) \ 12 f(glXGetFBConfigAttrib) \ 13 f(glXCreatePbuffer) \ 14 f(glXDestroyPbuffer) \ 15 f(glXCreateNewContext) \ 16 f(glXDestroyContext) \ 17 f(glXMakeContextCurrent) \ 18 f(glXSwapBuffers) \ 19 20 #define LIST_GLX_FUNCTYPES(f) \ 21 f( Bool, glXQueryVersion, ( Display *dpy, int *maj, int *min )) \ 22 f( GLXFBConfig*, glXGetFBConfigs, ( Display *dpy, int screen, int *nelements )) \ 23 f( int, glXGetFBConfigAttrib, ( Display *dpy, GLXFBConfig config, int attribute, int *value )) \ 24 f( GLXPbuffer, glXCreatePbuffer, ( Display *dpy, GLXFBConfig config, const int *attribList )) \ 25 f( void, glXDestroyPbuffer, ( Display *dpy, GLXPbuffer pbuf )) \ 26 f( GLXContext, glXCreateNewContext, ( Display *dpy, GLXFBConfig config, int renderType, GLXContext shareList, Bool direct )) \ 27 f( void, glXDestroyContext, ( Display *dpy, GLXContext ctx )) \ 28 f( Bool, glXMakeContextCurrent, ( Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx )) \ 29 f( void, glXSwapBuffers, (Display *dpy, GLXDrawable drawable )) \ 30 31 // X11 32 #define LIST_XLIB_FUNCS(f) \ 33 f(XOpenDisplay) \ 34 f(XCreateWindow) \ 35 f(XMapWindow) \ 36 f(XSetWindowBackground) \ 37 f(XIfEvent) \ 38 f(XDestroyWindow) \ 39 f(XGetWindowAttributes) \ 40 f(XSetWindowBackgroundPixmap) \ 41 f(XMoveResizeWindow) \ 42 f(XCloseDisplay) \ 43 f(XGetGeometry) \ 44 f(XFree) \ 45 f(XSync) \ 46 f(XSetErrorHandler) \ 47 f(XCreatePixmap) \ 48 f(XFreePixmap) \ 49 50 #define LIST_XLIB_FUNCTYPES(f) \ 51 f( Display*, XOpenDisplay, (_Xconst char*)) \ 52 f( Window, XCreateWindow, ( \ 53 Display* /* display */, \ 54 Window /* parent */, \ 55 int /* x */, \ 56 int /* y */, \ 57 unsigned int /* width */, \ 58 unsigned int /* height */, \ 59 unsigned int /* border_width */, \ 60 int /* depth */, \ 61 unsigned int /* class */, \ 62 Visual* /* visual */, \ 63 unsigned long /* valuemask */, \ 64 XSetWindowAttributes* /* attributes */)) \ 65 f( int, XMapWindow, ( \ 66 Display* /* display */, \ 67 Window /* w */ \ 68 )) \ 69 f( int, XSetWindowBackground, ( \ 70 Display* /* display */, \ 71 Window /* w */, \ 72 unsigned long /* background_pixel */ \ 73 )) \ 74 f( int, XIfEvent, ( \ 75 Display* /* display */, \ 76 XEvent* /* event_return */, \ 77 Bool (*) ( \ 78 Display* /* display */, \ 79 XEvent* /* event */, \ 80 XPointer /* arg */ \ 81 ) /* predicate */, \ 82 XPointer /* arg */ \ 83 )) \ 84 f( int, XDestroyWindow, ( \ 85 Display* /* display */, \ 86 Window /* w */ \ 87 )) \ 88 f( Status, XGetWindowAttributes, ( \ 89 Display* /* display */, \ 90 Window /* w */, \ 91 XWindowAttributes* /* window_attributes_return */ \ 92 )) \ 93 f( int, XSetWindowBackgroundPixmap, ( \ 94 Display* /* display */, \ 95 Window /* w */, \ 96 Pixmap /* background_pixmap */ \ 97 )) \ 98 f( int, XMoveResizeWindow, ( \ 99 Display* /* display */, \ 100 Window /* w */, \ 101 int /* x */, \ 102 int /* y */, \ 103 unsigned int /* width */, \ 104 unsigned int /* height */ \ 105 )) \ 106 f( int, XCloseDisplay, ( \ 107 Display* /* display */ \ 108 )) \ 109 f( Status, XGetGeometry, ( \ 110 Display* /* display */, \ 111 Drawable /* d */, \ 112 Window* /* root_return */, \ 113 int* /* x_return */, \ 114 int* /* y_return */, \ 115 unsigned int* /* width_return */, \ 116 unsigned int* /* height_return */, \ 117 unsigned int* /* border_width_return */, \ 118 unsigned int* /* depth_return */ \ 119 )) \ 120 f( int, XFree, (void*)) \ 121 f( int, XSync, (Display*, Bool)) \ 122 f( XErrorHandler, XSetErrorHandler, (XErrorHandler)) \ 123 f( Pixmap, XCreatePixmap, (Display*, Drawable, unsigned int, unsigned int, unsigned int)) \ 124 f( void, XFreePixmap, (Display*, Pixmap)) \ 125 126 #define DECLARE_FUNCTION_TYPEDEF(rettype, name, args) \ 127 typedef rettype (*name##_t)args; 128 129 #define DECLARE_API_STRUCT_MEMBER(funcname) \ 130 funcname##_t funcname; 131 132 LIST_XLIB_FUNCTYPES(DECLARE_FUNCTION_TYPEDEF) 133 134 LIST_GLX_FUNCTYPES(DECLARE_FUNCTION_TYPEDEF) 135 136 struct X11Api { 137 LIST_XLIB_FUNCS(DECLARE_API_STRUCT_MEMBER) 138 }; 139 140 struct GlxApi { 141 LIST_GLX_FUNCS(DECLARE_API_STRUCT_MEMBER) 142 }; 143 144 AEMU_EXPORT struct X11Api* getX11Api(); 145 AEMU_EXPORT struct GlxApi* getGlxApi(); 146