Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GLX and improved CGL support #57

Merged
merged 1 commit into from Oct 24, 2013
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Add GLX and improved CGL support

  • Loading branch information
pcwalton committed Oct 23, 2013
commit 8ee0302f97682a5b73667a596ae019ebfc571121
3 cgl.rs
@@ -42,6 +42,7 @@ extern {
// Context functions
pub fn CGLCreateContext(pix: CGLPixelFormatObj, share: CGLContextObj, ctx: *CGLContextObj) ->
CGLError;
pub fn CGLGetPixelFormat(ctx: CGLContextObj) -> CGLPixelFormatObj;

// Locking functions
pub fn CGLLockContext(ctx: CGLContextObj) -> CGLError;
@@ -52,4 +53,4 @@ extern {
pub fn CGLTexImageIOSurface2D(ctx: CGLContextObj, target: GLenum, internal_format: GLenum,
width: GLsizei, height: GLsizei, format: GLenum, ty: GLenum,
ioSurface: IOSurfaceRef, plane: GLuint) -> CGLError;
}
}
123 glx.rs
@@ -0,0 +1,123 @@
// Copyright 2013 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! Functions for X11 support.

use std::libc::{c_char, c_int, c_ulong};

// Types

pub struct Display {
priv opaque: (),
}

pub type GLXDrawable = c_ulong;

pub struct __GLXFBConfig {
priv opaque: (),
}

pub type GLXFBConfig = *__GLXFBConfig;

pub type GLXPixmap = c_ulong;

pub type Pixmap = c_ulong;

pub struct __XVisualInfo {
priv opaque: (),
}

pub type XVisualInfo = *__XVisualInfo;

// Constants

pub static GLX_BIND_TO_TEXTURE_RGB_EXT: c_int = 0x20d0;
pub static GLX_BIND_TO_TEXTURE_RGBA_EXT: c_int = 0x20d1;
pub static GLX_BIND_TO_MIPMAP_TEXTURE_EXT: c_int = 0x20d2;
pub static GLX_BIND_TO_TEXTURE_TARGETS_EXT: c_int = 0x20d3;
pub static GLX_Y_INVERTED_EXT: c_int = 0x20d4;

pub static GLX_TEXTURE_FORMAT_EXT: c_int = 0x20d5;
pub static GLX_TEXTURE_TARGET_EXT: c_int = 0x20d6;
pub static GLX_MIPMAP_TEXTURE_EXT: c_int = 0x20d7;

pub static GLX_TEXTURE_FORMAT_NONE_EXT: c_int = 0x20d8;
pub static GLX_TEXTURE_FORMAT_RGB_EXT: c_int = 0x20d9;
pub static GLX_TEXTURE_FORMAT_RGBA_EXT: c_int = 0x20da;

pub static GLX_TEXTURE_1D_BIT_EXT: c_int = 0x1;
pub static GLX_TEXTURE_2D_BIT_EXT: c_int = 0x2;
pub static GLX_TEXTURE_RECTANGLE_BIT_EXT: c_int = 0x4;

pub static GLX_TEXTURE_1D_EXT: c_int = 0x20db;
pub static GLX_TEXTURE_2D_EXT: c_int = 0x20dc;
pub static GLX_TEXTURE_RECTANGLE_EXT: c_int = 0x20dd;

pub static GLX_FRONT_LEFT_EXT: c_int = 0x20de;
pub static GLX_FRONT_RIGHT_EXT: c_int = 0x20df;
pub static GLX_BACK_LEFT_EXT: c_int = 0x20e0;
pub static GLX_BACK_RIGHT_EXT: c_int = 0x20e1;
pub static GLX_FRONT_EXT: c_int = GLX_FRONT_LEFT_EXT;
pub static GLX_BACK_EXT: c_int = GLX_BACK_LEFT_EXT;
pub static GLX_AUX0_EXT: c_int = 0x20e2;
pub static GLX_AUX1_EXT: c_int = 0x20e3;
pub static GLX_AUX2_EXT: c_int = 0x20e4;
pub static GLX_AUX3_EXT: c_int = 0x20e5;
pub static GLX_AUX4_EXT: c_int = 0x20e6;
pub static GLX_AUX5_EXT: c_int = 0x20e7;
pub static GLX_AUX6_EXT: c_int = 0x20e8;
pub static GLX_AUX7_EXT: c_int = 0x20e9;
pub static GLX_AUX8_EXT: c_int = 0x20ea;
pub static GLX_AUX9_EXT: c_int = 0x20eb;

pub static GLX_DRAWABLE_TYPE: c_int = 0x8010;

pub static GLX_RGBA: c_int = 4;
pub static GLX_DEPTH_SIZE: c_int = 12;

pub static GLX_WINDOW_BIT: c_int = 0x01;
pub static GLX_PIXMAP_BIT: c_int = 0x02;
pub static GLX_PBUFFER_BIT: c_int = 0x04;
pub static GLX_AUX_BUFFERS_BIT: c_int = 0x10;

// Functions

extern {
pub fn glXGetProcAddress(procName: *c_char) -> extern "C" fn();

pub fn glXReleaseTexImageEXT(dpy: *Display, drawable: GLXDrawable, buffer: c_int);

pub fn glXChooseFBConfig(dpy: *Display,
screen: c_int,
attrib_list: *c_int,
n_elements: *mut c_int)
-> *GLXFBConfig;

pub fn glXChooseVisual(dpy: *Display, screen: c_int, attribList: *c_int) -> *XVisualInfo;

pub fn glXCreatePixmap(dpy: *Display, config: GLXFBConfig, pixmap: Pixmap, attribList: *c_int)
-> GLXPixmap;

pub fn glXDestroyPixmap(dpy: *Display, pixmap: GLXPixmap);

pub fn glXCreateGLXPixmap(dpy: *Display, visual: *XVisualInfo, pixmap: Pixmap) -> GLXPixmap;

pub fn glXDestroyGLXPixmap(dpy: *Display, pix: GLXPixmap);

pub fn glXGetFBConfigAttrib(dpy: *Display,
config: GLXFBConfig,
attribute: c_int,
value: *mut c_int)
-> c_int;

pub fn glXGetFBConfigs(dpy: *Display, screen: c_int, nelements: *mut c_int) -> *GLXFBConfig;

pub fn glXGetVisualFromFBConfig(dpy: *Display, config: GLXFBConfig) -> *XVisualInfo;
}

3 lib.rs
@@ -15,6 +15,9 @@ extern mod std;

pub mod gl2;

#[cfg(target_os="linux")]
pub mod glx;

#[cfg(target_os="macos")]
pub mod cgl;

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.