• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #pragma once
2 
3 #include <X11/Xlib.h>
4 #include <GL/glx.h>
5 
6 #include "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 
48 #define LIST_XLIB_FUNCTYPES(f) \
49 f( Display*, XOpenDisplay, (_Xconst char*)) \
50 f( Window, XCreateWindow, ( \
51     Display*		/* display */, \
52     Window		/* parent */, \
53     int			/* x */, \
54     int			/* y */, \
55     unsigned int	/* width */, \
56     unsigned int	/* height */, \
57     unsigned int	/* border_width */, \
58     int			/* depth */, \
59     unsigned int	/* class */, \
60     Visual*		/* visual */, \
61     unsigned long	/* valuemask */, \
62     XSetWindowAttributes*	/* attributes */)) \
63 f( int, XMapWindow, ( \
64     Display*		/* display */, \
65     Window		/* w */ \
66     )) \
67 f( int, XSetWindowBackground, ( \
68     Display*		/* display */, \
69     Window		/* w */, \
70     unsigned long	/* background_pixel */ \
71     )) \
72 f( int, XIfEvent, ( \
73     Display*		/* display */, \
74     XEvent*		/* event_return */, \
75     Bool (*) ( \
76 	       Display*			/* display */, \
77                XEvent*			/* event */, \
78                XPointer			/* arg */ \
79              )		/* predicate */, \
80     XPointer		/* arg */ \
81  )) \
82 f( int, XDestroyWindow, ( \
83     Display*		/* display */, \
84     Window		/* w */ \
85     )) \
86 f( Status, XGetWindowAttributes, ( \
87     Display*		/* display */, \
88     Window		/* w */, \
89     XWindowAttributes*	/* window_attributes_return */ \
90     )) \
91 f( int, XSetWindowBackgroundPixmap, ( \
92     Display*		/* display */, \
93     Window		/* w */, \
94     Pixmap		/* background_pixmap */ \
95     )) \
96 f( int, XMoveResizeWindow, ( \
97     Display*		/* display */, \
98     Window		/* w */, \
99     int			/* x */, \
100     int			/* y */, \
101     unsigned int	/* width */, \
102     unsigned int	/* height */ \
103     )) \
104 f( int, XCloseDisplay, ( \
105     Display*		/* display */ \
106     )) \
107 f( Status, XGetGeometry, ( \
108     Display*		/* display */, \
109     Drawable		/* d */, \
110     Window*		/* root_return */, \
111     int*		/* x_return */, \
112     int*		/* y_return */, \
113     unsigned int*	/* width_return */, \
114     unsigned int*	/* height_return */, \
115     unsigned int*	/* border_width_return */, \
116     unsigned int*	/* depth_return */ \
117     )) \
118 f( int, XFree, (void*)) \
119 f( int, XSync, (Display*, Bool)) \
120 f( XErrorHandler, XSetErrorHandler, (XErrorHandler)) \
121 
122 #define DECLARE_FUNCTION_TYPEDEF(rettype, name, args) \
123     typedef rettype (*name##_t)args;
124 
125 #define DECLARE_API_STRUCT_MEMBER(funcname) \
126     funcname##_t funcname;
127 
128 LIST_XLIB_FUNCTYPES(DECLARE_FUNCTION_TYPEDEF)
129 
130 LIST_GLX_FUNCTYPES(DECLARE_FUNCTION_TYPEDEF)
131 
132 struct X11Api {
133 LIST_XLIB_FUNCS(DECLARE_API_STRUCT_MEMBER)
134 };
135 
136 struct GlxApi {
137 LIST_GLX_FUNCS(DECLARE_API_STRUCT_MEMBER)
138 };
139 
140 AEMU_EXPORT struct X11Api* getX11Api();
141 AEMU_EXPORT struct GlxApi* getGlxApi();
142