beta-0.89.2
[luatex.git] / source / libs / cairo / cairo-src / src / cairo-gl.h
blob9fd7608f5cfec20228696ac46ec82c9e18e3287b
1 /* Cairo - a vector graphics library with display and print output
3 * Copyright © 2009 Eric Anholt
4 * Copyright © 2009 Chris Wilson
6 * This library is free software; you can redistribute it and/or
7 * modify it either under the terms of the GNU Lesser General Public
8 * License version 2.1 as published by the Free Software Foundation
9 * (the "LGPL") or, at your option, under the terms of the Mozilla
10 * Public License Version 1.1 (the "MPL"). If you do not alter this
11 * notice, a recipient may use your version of this file under either
12 * the MPL or the LGPL.
14 * You should have received a copy of the LGPL along with this library
15 * in the file COPYING-LGPL-2.1; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
17 * You should have received a copy of the MPL along with this library
18 * in the file COPYING-MPL-1.1
20 * The contents of this file are subject to the Mozilla Public License
21 * Version 1.1 (the "License"); you may not use this file except in
22 * compliance with the License. You may obtain a copy of the License at
23 * http://www.mozilla.org/MPL/
25 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
26 * OF ANY KIND, either express or implied. See the LGPL or the MPL for
27 * the specific language governing rights and limitations.
29 * The Original Code is the cairo graphics library.
31 * The Initial Developer of the Original Code is Eric Anholt.
35 * cairo-gl.h:
37 * The cairo-gl backend provides an implementation of possibly
38 * hardware-accelerated cairo rendering by targeting the OpenGL API.
39 * The goal of the cairo-gl backend is to provide better performance
40 * with equal functionality to cairo-image where possible. It does
41 * not directly provide for applying additional OpenGL effects to
42 * cairo surfaces.
44 * Cairo-gl allows interoperability with other GL rendering through GL
45 * context sharing. Cairo-gl surfaces are created in reference to a
46 * #cairo_device_t, which represents a GL context created by the user.
47 * When that GL context is created with its sharePtr set to another
48 * context (or vice versa), its objects (textures backing cairo-gl
49 * surfaces) can be accessed in the other OpenGL context. This allows
50 * cairo-gl to maintain its drawing state in one context while the
51 * user's 3D rendering occurs in the user's other context.
53 * However, as only one context can be current to a thread at a time,
54 * cairo-gl may make its context current to the thread on any cairo
55 * call which interacts with a cairo-gl surface or the cairo-gl
56 * device. As a result, the user must make their own context current
57 * between any cairo calls and their own OpenGL rendering.
58 **/
60 #ifndef CAIRO_GL_H
61 #define CAIRO_GL_H
63 #include "cairo.h"
65 #if CAIRO_HAS_GL_SURFACE || CAIRO_HAS_GLESV2_SURFACE
67 CAIRO_BEGIN_DECLS
69 cairo_public cairo_surface_t *
70 cairo_gl_surface_create (cairo_device_t *device,
71 cairo_content_t content,
72 int width, int height);
74 cairo_public cairo_surface_t *
75 cairo_gl_surface_create_for_texture (cairo_device_t *abstract_device,
76 cairo_content_t content,
77 unsigned int tex,
78 int width, int height);
79 cairo_public void
80 cairo_gl_surface_set_size (cairo_surface_t *surface, int width, int height);
82 cairo_public int
83 cairo_gl_surface_get_width (cairo_surface_t *abstract_surface);
85 cairo_public int
86 cairo_gl_surface_get_height (cairo_surface_t *abstract_surface);
88 cairo_public void
89 cairo_gl_surface_swapbuffers (cairo_surface_t *surface);
91 cairo_public void
92 cairo_gl_device_set_thread_aware (cairo_device_t *device,
93 cairo_bool_t thread_aware);
95 #if CAIRO_HAS_GLX_FUNCTIONS
96 #include <GL/glx.h>
98 cairo_public cairo_device_t *
99 cairo_glx_device_create (Display *dpy, GLXContext gl_ctx);
101 cairo_public Display *
102 cairo_glx_device_get_display (cairo_device_t *device);
104 cairo_public GLXContext
105 cairo_glx_device_get_context (cairo_device_t *device);
107 cairo_public cairo_surface_t *
108 cairo_gl_surface_create_for_window (cairo_device_t *device,
109 Window win,
110 int width, int height);
111 #endif
113 #if CAIRO_HAS_WGL_FUNCTIONS
114 #include <windows.h>
116 cairo_public cairo_device_t *
117 cairo_wgl_device_create (HGLRC rc);
119 cairo_public HGLRC
120 cairo_wgl_device_get_context (cairo_device_t *device);
122 cairo_public cairo_surface_t *
123 cairo_gl_surface_create_for_dc (cairo_device_t *device,
124 HDC dc,
125 int width,
126 int height);
127 #endif
129 #if CAIRO_HAS_EGL_FUNCTIONS
130 #include <EGL/egl.h>
132 cairo_public cairo_device_t *
133 cairo_egl_device_create (EGLDisplay dpy, EGLContext egl);
135 cairo_public cairo_surface_t *
136 cairo_gl_surface_create_for_egl (cairo_device_t *device,
137 EGLSurface egl,
138 int width,
139 int height);
141 cairo_public EGLDisplay
142 cairo_egl_device_get_display (cairo_device_t *device);
144 cairo_public EGLSurface
145 cairo_egl_device_get_context (cairo_device_t *device);
147 #endif
149 CAIRO_END_DECLS
151 #else /* CAIRO_HAS_GL_SURFACE */
152 # error Cairo was not compiled with support for the GL backend
153 #endif /* CAIRO_HAS_GL_SURFACE */
155 #endif /* CAIRO_GL_H */