1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
// Copyright (c) 2015, <daggerbot@gmail.com>
// All rights reserved.

use libc::{
  c_char,
  c_int,
};

use ::xlib::{
  Bool,
  Display,
  Drawable,
  XVisualInfo,
};


//
// functions
//


#[link(name="GL")]
extern "C" {
  pub fn glXChooseFBConfig (display: *mut Display, screen: c_int, attr: *const c_int, nitems: *mut c_int)
      -> *mut GLXFBConfig;
  // glXChooseVisual
  // glXCopyContext
  pub fn glXCreateContext (display: *mut Display, visual_info: *const XVisualInfo, share_context: GLXContext,
      direct: Bool) -> GLXContext;
  // glXCreateGLXPixmap
  // glXCreateNewContext
  // glXCreatePbuffer
  // glXCreatePixmap
  // glXCreateWindow
  pub fn glXDestroyContext (display: *mut Display, context: GLXContext);
  // glXDestroyGLXPixmap
  // glXDestroyPbuffer
  // glXDestroyPixmap
  // glXDestroyWindow
  // glXGet
  // glXGetClientString
  // glXGetConfig
  pub fn glXGetCurrentContext () -> GLXContext;
  pub fn glXGetCurrentDisplay () -> *mut Display;
  pub fn glXGetCurrentDrawable () -> GLXDrawable;
  // glXGetCurrentReadDrawable
  // glXGetFBConfigAttrib
  // glXGetFBConfigs
  pub fn glXGetProcAddress (name: *const c_char) -> unsafe extern "C" fn ();
  // glXGetSelectedEvent
  pub fn glXGetVisualFromFBConfig (display: *mut Display, fbconfig: GLXFBConfig) -> *mut XVisualInfo;
  // glXIsDirect
  // glXMakeContextCurrent
  pub fn glXMakeCurrent (display: *mut Display, drawable: GLXDrawable, context: GLXContext) -> Bool;
  // glXNewCommandSGI
  // glXQuery
  // glXQueryContext
  // glXQueryDrawable
  // glXQueryExtension
  // glXQueryExtensionsString
  // glXQueryServerString
  // glXQueryVersion
  // glXSelectEvent
  pub fn glXSwapBuffers (display: *mut Display, drawable: GLXDrawable);
  // glXUseXFont
  // glXWaitGL
  // glXWaitX
}


//
// types
//


// ID types
pub type GLXDrawable = Drawable;

// opaque pointers
#[allow(missing_copy_implementations)]
#[repr(C)]
pub struct GLXContext_Rec;
pub type GLXContext = *mut GLXContext_Rec;

#[allow(missing_copy_implementations)]
#[repr(C)]
pub struct GLXFBConfig_Rec;
pub type GLXFBConfig = *const GLXFBConfig_Rec;


//
// constants
//


// config caveats
pub const GLX_SLOW_CONFIG: c_int = 0x8001;
pub const GLX_NON_CONFORMANT_CONFIG: c_int = 0x800d;

// context attributes
pub const GLX_CONTEXT_MAJOR_VERSION_ARB: c_int = 0x2091;
pub const GLX_CONTEXT_MINOR_VERSION_ARB: c_int = 0x2092;
pub const GLX_CONTEXT_FLAGS_ARB: c_int = 0x2094;
pub const GLX_CONTEXT_PROFILE_MASK_ARB: c_int = 0x9126;

// context flags
pub const GLX_CONTEXT_DEBUG_BIT_ARB: c_int = 0x0001;
pub const GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB: c_int = 0x0002;

// context profile mask
pub const GLX_CONTEXT_CORE_PROFILE_BIT_ARB: c_int = 0x0001;
pub const GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB: c_int = 0x0002;

// drawable type mask
pub const GLX_WINDOW_BIT: c_int = 0x0001;
pub const GLX_PIXMAP_BIT: c_int = 0x0002;
pub const GLX_PBUFFER_BIT: c_int = 0x0004;

// framebuffer attributes
pub const GLX_BUFFER_SIZE: c_int = 0x0002;
pub const GLX_LEVEL: c_int = 0x0003;
pub const GLX_DOUBLEBUFFER: c_int = 0x0005;
pub const GLX_STEREO: c_int = 0x0006;
pub const GLX_AUX_BUFFERS: c_int = 0x0007;
pub const GLX_RED_SIZE: c_int = 0x0008;
pub const GLX_GREEN_SIZE: c_int = 0x0009;
pub const GLX_BLUE_SIZE: c_int = 0x000a;
pub const GLX_ALPHA_SIZE: c_int = 0x000b;
pub const GLX_DEPTH_SIZE: c_int = 0x000c;
pub const GLX_STENCIL_SIZE: c_int = 0x000d;
pub const GLX_ACCUM_RED_SIZE: c_int = 0x000e;
pub const GLX_ACCUM_GREEN_SIZE: c_int = 0x000f;
pub const GLX_ACCUM_BLUE_SIZE: c_int = 0x0010;
pub const GLX_ACCUM_ALPHA_SIZE: c_int = 0x0011;
pub const GLX_CONFIG_CAVEAT: c_int = 0x0020;
pub const GLX_X_VISUAL_TYPE: c_int = 0x0022;
pub const GLX_TRANSPARENT_TYPE: c_int = 0x0023;
pub const GLX_TRANSPARENT_INDEX_VALUE: c_int = 0x0024;
pub const GLX_TRANSPARENT_RED_VALUE: c_int = 0x0025;
pub const GLX_TRANSPARENT_GREEN_VALUE: c_int = 0x0026;
pub const GLX_TRANSPARENT_BLUE_VALUE: c_int = 0x0027;
pub const GLX_TRANSPARENT_ALPHA_VALUE: c_int = 0x0028;
pub const GLX_DRAWABLE_TYPE: c_int = 0x8010;
pub const GLX_RENDER_TYPE: c_int = 0x8011;
pub const GLX_X_RENDERABLE: c_int = 0x8012;
pub const GLX_FBCONFIG_ID: c_int = 0x8013;

// misc
pub const GLX_DONT_CARE: c_int = -1;
pub const GLX_NONE: c_int = 0x8000;

// render type mask
pub const GLX_RGBA_BIT: c_int = 0x0001;
pub const GLX_COLOR_INDEX_BIT: c_int = 0x0002;

// transparent types
pub const GLX_TRANSPARENT_RGB: c_int = 0x8008;
pub const GLX_TRANSPARENT_INDEX: c_int = 0x8009;

// visual types
pub const GLX_TRUE_COLOR: c_int = 0x8002;
pub const GLX_DIRECT_COLOR: c_int = 0x8003;
pub const GLX_PSEUDO_COLOR: c_int = 0x8004;
pub const GLX_STATIC_COLOR: c_int = 0x8005;
pub const GLX_GRAY_SCALE: c_int = 0x8006;
pub const GLX_STATIC_GRAY: c_int = 0x8007;