1 | // x11-rs: Rust bindings for X11 libraries |
2 | // The X11 libraries are available under the MIT license. |
3 | // These bindings are public domain. |
4 | |
5 | use std::os::raw::{c_char, c_int, c_uchar, c_uint, c_ulong}; |
6 | |
7 | use super::xlib::{Display, XVisualInfo, XID}; |
8 | |
9 | // |
10 | // functions |
11 | // |
12 | |
13 | x11_link! { Glx, gl, ["libGL.so.1" , "libGL.so" ], 40, |
14 | pub fn glXChooseFBConfig (_4: *mut Display, _3: c_int, _2: *const c_int, _1: *mut c_int) -> *mut GLXFBConfig, |
15 | pub fn glXChooseVisual (_3: *mut Display, _2: c_int, _1: *mut c_int) -> *mut XVisualInfo, |
16 | pub fn glXCopyContext (_4: *mut Display, _3: GLXContext, _2: GLXContext, _1: c_ulong) -> (), |
17 | pub fn glXCreateContext (_4: *mut Display, _3: *mut XVisualInfo, _2: GLXContext, _1: c_int) -> GLXContext, |
18 | pub fn glXCreateGLXPixmap (_3: *mut Display, _2: *mut XVisualInfo, _1: c_ulong) -> c_ulong, |
19 | pub fn glXCreateNewContext (_5: *mut Display, _4: GLXFBConfig, _3: c_int, _2: GLXContext, _1: c_int) -> GLXContext, |
20 | pub fn glXCreatePbuffer (_3: *mut Display, _2: GLXFBConfig, _1: *const c_int) -> c_ulong, |
21 | pub fn glXCreatePixmap (_4: *mut Display, _3: GLXFBConfig, _2: c_ulong, _1: *const c_int) -> c_ulong, |
22 | pub fn glXCreateWindow (_4: *mut Display, _3: GLXFBConfig, _2: c_ulong, _1: *const c_int) -> c_ulong, |
23 | pub fn glXDestroyContext (_2: *mut Display, _1: GLXContext) -> (), |
24 | pub fn glXDestroyGLXPixmap (_2: *mut Display, _1: c_ulong) -> (), |
25 | pub fn glXDestroyPbuffer (_2: *mut Display, _1: c_ulong) -> (), |
26 | pub fn glXDestroyPixmap (_2: *mut Display, _1: c_ulong) -> (), |
27 | pub fn glXDestroyWindow (_2: *mut Display, _1: c_ulong) -> (), |
28 | pub fn glXGetClientString (_2: *mut Display, _1: c_int) -> *const c_char, |
29 | pub fn glXGetConfig (_4: *mut Display, _3: *mut XVisualInfo, _2: c_int, _1: *mut c_int) -> c_int, |
30 | pub fn glXGetCurrentContext () -> GLXContext, |
31 | pub fn glXGetCurrentDisplay () -> *mut Display, |
32 | pub fn glXGetCurrentDrawable () -> c_ulong, |
33 | pub fn glXGetCurrentReadDrawable () -> c_ulong, |
34 | pub fn glXGetFBConfigAttrib (_4: *mut Display, _3: GLXFBConfig, _2: c_int, _1: *mut c_int) -> c_int, |
35 | pub fn glXGetFBConfigs (_3: *mut Display, _2: c_int, _1: *mut c_int) -> *mut GLXFBConfig, |
36 | pub fn glXGetProcAddress (_1: *const c_uchar) -> Option<unsafe extern "C" fn ()>, |
37 | pub fn glXGetProcAddressARB (_1: *const c_uchar) -> Option<unsafe extern "C" fn ()>, |
38 | pub fn glXGetSelectedEvent (_3: *mut Display, _2: c_ulong, _1: *mut c_ulong) -> (), |
39 | pub fn glXGetVisualFromFBConfig (_2: *mut Display, _1: GLXFBConfig) -> *mut XVisualInfo, |
40 | pub fn glXIsDirect (_2: *mut Display, _1: GLXContext) -> c_int, |
41 | pub fn glXMakeContextCurrent (_4: *mut Display, _3: c_ulong, _2: c_ulong, _1: GLXContext) -> c_int, |
42 | pub fn glXMakeCurrent (_3: *mut Display, _2: c_ulong, _1: GLXContext) -> c_int, |
43 | pub fn glXQueryContext (_4: *mut Display, _3: GLXContext, _2: c_int, _1: *mut c_int) -> c_int, |
44 | pub fn glXQueryDrawable (_4: *mut Display, _3: c_ulong, _2: c_int, _1: *mut c_uint) -> (), |
45 | pub fn glXQueryExtension (_3: *mut Display, _2: *mut c_int, _1: *mut c_int) -> c_int, |
46 | pub fn glXQueryExtensionsString (_2: *mut Display, _1: c_int) -> *const c_char, |
47 | pub fn glXQueryServerString (_3: *mut Display, _2: c_int, _1: c_int) -> *const c_char, |
48 | pub fn glXQueryVersion (_3: *mut Display, _2: *mut c_int, _1: *mut c_int) -> c_int, |
49 | pub fn glXSelectEvent (_3: *mut Display, _2: c_ulong, _1: c_ulong) -> (), |
50 | pub fn glXSwapBuffers (_2: *mut Display, _1: c_ulong) -> (), |
51 | pub fn glXUseXFont (_4: c_ulong, _3: c_int, _2: c_int, _1: c_int) -> (), |
52 | pub fn glXWaitGL () -> (), |
53 | pub fn glXWaitX () -> (), |
54 | variadic: |
55 | globals: |
56 | } |
57 | |
58 | // |
59 | // types |
60 | // |
61 | |
62 | // opaque structures |
63 | #[repr (C)] |
64 | pub struct __GLXcontextRec; |
65 | #[repr (C)] |
66 | pub struct __GLXFBConfigRec; |
67 | |
68 | // types |
69 | pub type GLXContext = *mut __GLXcontextRec; |
70 | pub type GLXContextID = XID; |
71 | pub type GLXDrawable = XID; |
72 | pub type GLXFBConfig = *mut __GLXFBConfigRec; |
73 | pub type GLXFBConfigID = XID; |
74 | pub type GLXPbuffer = XID; |
75 | pub type GLXPixmap = XID; |
76 | pub type GLXWindow = XID; |
77 | |
78 | // |
79 | // constants |
80 | // |
81 | |
82 | // config caveats |
83 | pub const GLX_SLOW_CONFIG: c_int = 0x8001; |
84 | pub const GLX_NON_CONFORMANT_CONFIG: c_int = 0x800d; |
85 | |
86 | // drawable type mask |
87 | pub const GLX_WINDOW_BIT: c_int = 0x0001; |
88 | pub const GLX_PIXMAP_BIT: c_int = 0x0002; |
89 | pub const GLX_PBUFFER_BIT: c_int = 0x0004; |
90 | |
91 | // framebuffer attributes |
92 | pub const GLX_USE_GL: c_int = 0x0001; |
93 | pub const GLX_BUFFER_SIZE: c_int = 0x0002; |
94 | pub const GLX_LEVEL: c_int = 0x0003; |
95 | pub const GLX_RGBA: c_int = 0x0004; |
96 | pub const GLX_DOUBLEBUFFER: c_int = 0x0005; |
97 | pub const GLX_STEREO: c_int = 0x0006; |
98 | pub const GLX_AUX_BUFFERS: c_int = 0x0007; |
99 | pub const GLX_RED_SIZE: c_int = 0x0008; |
100 | pub const GLX_GREEN_SIZE: c_int = 0x0009; |
101 | pub const GLX_BLUE_SIZE: c_int = 0x000a; |
102 | pub const GLX_ALPHA_SIZE: c_int = 0x000b; |
103 | pub const GLX_DEPTH_SIZE: c_int = 0x000c; |
104 | pub const GLX_STENCIL_SIZE: c_int = 0x000d; |
105 | pub const GLX_ACCUM_RED_SIZE: c_int = 0x000e; |
106 | pub const GLX_ACCUM_GREEN_SIZE: c_int = 0x000f; |
107 | pub const GLX_ACCUM_BLUE_SIZE: c_int = 0x0010; |
108 | pub const GLX_ACCUM_ALPHA_SIZE: c_int = 0x0011; |
109 | pub const GLX_CONFIG_CAVEAT: c_int = 0x0020; |
110 | pub const GLX_X_VISUAL_TYPE: c_int = 0x0022; |
111 | pub const GLX_TRANSPARENT_TYPE: c_int = 0x0023; |
112 | pub const GLX_TRANSPARENT_INDEX_VALUE: c_int = 0x0024; |
113 | pub const GLX_TRANSPARENT_RED_VALUE: c_int = 0x0025; |
114 | pub const GLX_TRANSPARENT_GREEN_VALUE: c_int = 0x0026; |
115 | pub const GLX_TRANSPARENT_BLUE_VALUE: c_int = 0x0027; |
116 | pub const GLX_TRANSPARENT_ALPHA_VALUE: c_int = 0x0028; |
117 | pub const GLX_VISUAL_ID: c_int = 0x800B; |
118 | pub const GLX_SCREEN: c_int = 0x800C; |
119 | pub const GLX_DRAWABLE_TYPE: c_int = 0x8010; |
120 | pub const GLX_RENDER_TYPE: c_int = 0x8011; |
121 | pub const GLX_X_RENDERABLE: c_int = 0x8012; |
122 | pub const GLX_FBCONFIG_ID: c_int = 0x8013; |
123 | pub const GLX_MAX_PBUFFER_WIDTH: c_int = 0x8016; |
124 | pub const GLX_MAX_PBUFFER_HEIGHT: c_int = 0x8017; |
125 | pub const GLX_MAX_PBUFFER_PIXELS: c_int = 0x8018; |
126 | pub const GLX_SAMPLE_BUFFERS: c_int = 0x1_86a0; |
127 | pub const GLX_SAMPLES: c_int = 0x1_86a1; |
128 | |
129 | // misc |
130 | pub const GLX_DONT_CARE: c_int = -1; |
131 | pub const GLX_NONE: c_int = 0x8000; |
132 | |
133 | // render type mask |
134 | pub const GLX_RGBA_BIT: c_int = 0x0001; |
135 | pub const GLX_COLOR_INDEX_BIT: c_int = 0x0002; |
136 | |
137 | // transparent types |
138 | pub const GLX_TRANSPARENT_RGB: c_int = 0x8008; |
139 | pub const GLX_TRANSPARENT_INDEX: c_int = 0x8009; |
140 | |
141 | // visual types |
142 | pub const GLX_TRUE_COLOR: c_int = 0x8002; |
143 | pub const GLX_DIRECT_COLOR: c_int = 0x8003; |
144 | pub const GLX_PSEUDO_COLOR: c_int = 0x8004; |
145 | pub const GLX_STATIC_COLOR: c_int = 0x8005; |
146 | pub const GLX_GRAY_SCALE: c_int = 0x8006; |
147 | pub const GLX_STATIC_GRAY: c_int = 0x8007; |
148 | |
149 | // glXGetConfig errors |
150 | pub const GLX_BAD_SCREEN: c_int = 1; |
151 | pub const GLX_BAD_ATTRIBUTE: c_int = 2; |
152 | pub const GLX_NO_EXTENSION: c_int = 3; |
153 | pub const GLX_BAD_VISUAL: c_int = 4; |
154 | pub const GLX_BAD_CONTEXT: c_int = 5; |
155 | pub const GLX_BAD_VALUE: c_int = 6; |
156 | pub const GLX_BAD_ENUM: c_int = 7; |
157 | |
158 | // glXGetClientString names |
159 | pub const GLX_VENDOR: c_int = 1; |
160 | pub const GLX_VERSION: c_int = 2; |
161 | pub const GLX_EXTENSIONS: c_int = 3; |
162 | |
163 | // drawable type mask? |
164 | pub const GLX_FRONT_LEFT_BUFFER_BIT: c_uint = 0x0001; |
165 | pub const GLX_FRONT_RIGHT_BUFFER_BIT: c_uint = 0x0002; |
166 | pub const GLX_BACK_LEFT_BUFFER_BIT: c_uint = 0x0004; |
167 | pub const GLX_BACK_RIGHT_BUFFER_BIT: c_uint = 0x0008; |
168 | pub const GLX_AUX_BUFFERS_BIT: c_uint = 0x0010; |
169 | pub const GLX_DEPTH_BUFFER_BIT: c_uint = 0x0020; |
170 | pub const GLX_STENCIL_BUFFER_BIT: c_uint = 0x0040; |
171 | pub const GLX_ACCUM_BUFFER_BIT: c_uint = 0x0080; |
172 | |
173 | // render type for glXCreateNewContext |
174 | pub const GLX_RGBA_TYPE: c_int = 0x8014; |
175 | pub const GLX_COLOR_INDEX_TYPE: c_int = 0x8015; |
176 | |
177 | // drawable attributes |
178 | pub const GLX_PRESERVED_CONTENTS: c_int = 0x801B; |
179 | pub const GLX_LARGEST_PBUFFER: c_int = 0x801C; |
180 | pub const GLX_WIDTH: c_int = 0x801D; |
181 | pub const GLX_HEIGHT: c_int = 0x801E; |
182 | pub const GLX_PBUFFER_HEIGHT: c_int = 0x8040; |
183 | pub const GLX_PBUFFER_WIDTH: c_int = 0x8041; |
184 | |
185 | // other? |
186 | pub const GLX_EVENT_MASK: c_int = 0x801F; |
187 | |
188 | // event mask |
189 | pub const GLX_PBUFFER_CLOBBER_MASK: c_ulong = 0x0800_0000; |
190 | |
191 | // event types |
192 | pub const GLX_DAMAGED: c_int = 0x8020; |
193 | pub const GLX_SAVED: c_int = 0x8021; |
194 | |
195 | // drawable types |
196 | pub const GLX_WINDOW: c_int = 0x8022; |
197 | pub const GLX_PBUFFER: c_int = 0x8023; |
198 | |
199 | // |
200 | // ARB extensions |
201 | // |
202 | |
203 | pub mod arb { |
204 | use std::os::raw::c_int; |
205 | |
206 | // context attributes |
207 | pub const GLX_CONTEXT_MAJOR_VERSION_ARB: c_int = 0x2091; |
208 | pub const GLX_CONTEXT_MINOR_VERSION_ARB: c_int = 0x2092; |
209 | pub const GLX_CONTEXT_FLAGS_ARB: c_int = 0x2094; |
210 | pub const GLX_CONTEXT_PROFILE_MASK_ARB: c_int = 0x9126; |
211 | |
212 | // context flags |
213 | pub const GLX_CONTEXT_DEBUG_BIT_ARB: c_int = 0x0001; |
214 | pub const GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB: c_int = 0x0002; |
215 | |
216 | // context profile mask |
217 | pub const GLX_CONTEXT_CORE_PROFILE_BIT_ARB: c_int = 0x0001; |
218 | pub const GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB: c_int = 0x0002; |
219 | } |
220 | |
221 | // |
222 | // EXT extensions |
223 | // |
224 | |
225 | pub mod ext { |
226 | use std::os::raw::c_int; |
227 | |
228 | // drawable attributes |
229 | pub const GLX_SWAP_INTERVAL_EXT: c_int = 0x20f1; |
230 | pub const GLX_MAX_SWAP_INTERVAL_EXT: c_int = 0x20f2; |
231 | } |
232 | |