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
5use std::os::raw::{c_char, c_int, c_uchar, c_uint, c_ulong};
6
7use super::xlib::{Display, XVisualInfo, XID};
8
9//
10// functions
11//
12
13x11_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 () -> (),
54variadic:
55globals:
56}
57
58//
59// types
60//
61
62// opaque structures
63#[repr(C)]
64pub struct __GLXcontextRec;
65#[repr(C)]
66pub struct __GLXFBConfigRec;
67
68// types
69pub type GLXContext = *mut __GLXcontextRec;
70pub type GLXContextID = XID;
71pub type GLXDrawable = XID;
72pub type GLXFBConfig = *mut __GLXFBConfigRec;
73pub type GLXFBConfigID = XID;
74pub type GLXPbuffer = XID;
75pub type GLXPixmap = XID;
76pub type GLXWindow = XID;
77
78//
79// constants
80//
81
82// config caveats
83pub const GLX_SLOW_CONFIG: c_int = 0x8001;
84pub const GLX_NON_CONFORMANT_CONFIG: c_int = 0x800d;
85
86// drawable type mask
87pub const GLX_WINDOW_BIT: c_int = 0x0001;
88pub const GLX_PIXMAP_BIT: c_int = 0x0002;
89pub const GLX_PBUFFER_BIT: c_int = 0x0004;
90
91// framebuffer attributes
92pub const GLX_USE_GL: c_int = 0x0001;
93pub const GLX_BUFFER_SIZE: c_int = 0x0002;
94pub const GLX_LEVEL: c_int = 0x0003;
95pub const GLX_RGBA: c_int = 0x0004;
96pub const GLX_DOUBLEBUFFER: c_int = 0x0005;
97pub const GLX_STEREO: c_int = 0x0006;
98pub const GLX_AUX_BUFFERS: c_int = 0x0007;
99pub const GLX_RED_SIZE: c_int = 0x0008;
100pub const GLX_GREEN_SIZE: c_int = 0x0009;
101pub const GLX_BLUE_SIZE: c_int = 0x000a;
102pub const GLX_ALPHA_SIZE: c_int = 0x000b;
103pub const GLX_DEPTH_SIZE: c_int = 0x000c;
104pub const GLX_STENCIL_SIZE: c_int = 0x000d;
105pub const GLX_ACCUM_RED_SIZE: c_int = 0x000e;
106pub const GLX_ACCUM_GREEN_SIZE: c_int = 0x000f;
107pub const GLX_ACCUM_BLUE_SIZE: c_int = 0x0010;
108pub const GLX_ACCUM_ALPHA_SIZE: c_int = 0x0011;
109pub const GLX_CONFIG_CAVEAT: c_int = 0x0020;
110pub const GLX_X_VISUAL_TYPE: c_int = 0x0022;
111pub const GLX_TRANSPARENT_TYPE: c_int = 0x0023;
112pub const GLX_TRANSPARENT_INDEX_VALUE: c_int = 0x0024;
113pub const GLX_TRANSPARENT_RED_VALUE: c_int = 0x0025;
114pub const GLX_TRANSPARENT_GREEN_VALUE: c_int = 0x0026;
115pub const GLX_TRANSPARENT_BLUE_VALUE: c_int = 0x0027;
116pub const GLX_TRANSPARENT_ALPHA_VALUE: c_int = 0x0028;
117pub const GLX_VISUAL_ID: c_int = 0x800B;
118pub const GLX_SCREEN: c_int = 0x800C;
119pub const GLX_DRAWABLE_TYPE: c_int = 0x8010;
120pub const GLX_RENDER_TYPE: c_int = 0x8011;
121pub const GLX_X_RENDERABLE: c_int = 0x8012;
122pub const GLX_FBCONFIG_ID: c_int = 0x8013;
123pub const GLX_MAX_PBUFFER_WIDTH: c_int = 0x8016;
124pub const GLX_MAX_PBUFFER_HEIGHT: c_int = 0x8017;
125pub const GLX_MAX_PBUFFER_PIXELS: c_int = 0x8018;
126pub const GLX_SAMPLE_BUFFERS: c_int = 0x1_86a0;
127pub const GLX_SAMPLES: c_int = 0x1_86a1;
128
129// misc
130pub const GLX_DONT_CARE: c_int = -1;
131pub const GLX_NONE: c_int = 0x8000;
132
133// render type mask
134pub const GLX_RGBA_BIT: c_int = 0x0001;
135pub const GLX_COLOR_INDEX_BIT: c_int = 0x0002;
136
137// transparent types
138pub const GLX_TRANSPARENT_RGB: c_int = 0x8008;
139pub const GLX_TRANSPARENT_INDEX: c_int = 0x8009;
140
141// visual types
142pub const GLX_TRUE_COLOR: c_int = 0x8002;
143pub const GLX_DIRECT_COLOR: c_int = 0x8003;
144pub const GLX_PSEUDO_COLOR: c_int = 0x8004;
145pub const GLX_STATIC_COLOR: c_int = 0x8005;
146pub const GLX_GRAY_SCALE: c_int = 0x8006;
147pub const GLX_STATIC_GRAY: c_int = 0x8007;
148
149// glXGetConfig errors
150pub const GLX_BAD_SCREEN: c_int = 1;
151pub const GLX_BAD_ATTRIBUTE: c_int = 2;
152pub const GLX_NO_EXTENSION: c_int = 3;
153pub const GLX_BAD_VISUAL: c_int = 4;
154pub const GLX_BAD_CONTEXT: c_int = 5;
155pub const GLX_BAD_VALUE: c_int = 6;
156pub const GLX_BAD_ENUM: c_int = 7;
157
158// glXGetClientString names
159pub const GLX_VENDOR: c_int = 1;
160pub const GLX_VERSION: c_int = 2;
161pub const GLX_EXTENSIONS: c_int = 3;
162
163// drawable type mask?
164pub const GLX_FRONT_LEFT_BUFFER_BIT: c_uint = 0x0001;
165pub const GLX_FRONT_RIGHT_BUFFER_BIT: c_uint = 0x0002;
166pub const GLX_BACK_LEFT_BUFFER_BIT: c_uint = 0x0004;
167pub const GLX_BACK_RIGHT_BUFFER_BIT: c_uint = 0x0008;
168pub const GLX_AUX_BUFFERS_BIT: c_uint = 0x0010;
169pub const GLX_DEPTH_BUFFER_BIT: c_uint = 0x0020;
170pub const GLX_STENCIL_BUFFER_BIT: c_uint = 0x0040;
171pub const GLX_ACCUM_BUFFER_BIT: c_uint = 0x0080;
172
173// render type for glXCreateNewContext
174pub const GLX_RGBA_TYPE: c_int = 0x8014;
175pub const GLX_COLOR_INDEX_TYPE: c_int = 0x8015;
176
177// drawable attributes
178pub const GLX_PRESERVED_CONTENTS: c_int = 0x801B;
179pub const GLX_LARGEST_PBUFFER: c_int = 0x801C;
180pub const GLX_WIDTH: c_int = 0x801D;
181pub const GLX_HEIGHT: c_int = 0x801E;
182pub const GLX_PBUFFER_HEIGHT: c_int = 0x8040;
183pub const GLX_PBUFFER_WIDTH: c_int = 0x8041;
184
185// other?
186pub const GLX_EVENT_MASK: c_int = 0x801F;
187
188// event mask
189pub const GLX_PBUFFER_CLOBBER_MASK: c_ulong = 0x0800_0000;
190
191// event types
192pub const GLX_DAMAGED: c_int = 0x8020;
193pub const GLX_SAVED: c_int = 0x8021;
194
195// drawable types
196pub const GLX_WINDOW: c_int = 0x8022;
197pub const GLX_PBUFFER: c_int = 0x8023;
198
199//
200// ARB extensions
201//
202
203pub 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
225pub 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