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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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.
34 #ifndef CAIRO_GPU_GL_H
35 #define CAIRO_GPU_GL_H
39 #if CAIRO_HAS_GPU_GL_SURFACE
45 CAIRO_GL_API_NONE
= 0,
46 CAIRO_GL_API_OSMESA
= 1,
53 struct __GLXcontextRec
;
54 typedef struct __GLXcontextRec
*GLXContext
;
55 typedef XID GLXDrawable
;
57 struct osmesa_context
;
58 typedef struct osmesa_context
*OSMesaContext
;
60 #define CAIRO_GPU_GL_DISABLE_FRAMEBUFFER_OBJECT 1
61 #define CAIRO_GPU_GL_DISABLE_FRAMEBUFFER_BLIT 2
62 #define CAIRO_GPU_GL_DISABLE_TEXTURE_NON_POWER_OF_TWO 4
63 #define CAIRO_GPU_GL_DISABLE_TEXTURE_RECTANGLE 8
64 #define CAIRO_GPU_GL_DISABLE_FRAGMENT_PROGRAM 0x10
65 #define CAIRO_GPU_GL_DISABLE_VERTEX_PROGRAM 0x20
66 #define CAIRO_GPU_GL_DISABLE_BLEND_FUNC_SEPARATE 0x40
67 #define CAIRO_GPU_GL_DISABLE_TEX_ENV_COMBINE 0x80
68 #define CAIRO_GPU_GL_FORCE_TEX_UNITS_SHIFT 8
69 #define CAIRO_GPU_GL_FORCE_TEX_UNITS_MASK 0x300
71 #define CAIRO_GPU_GL_DISABLE_EVERYTHING 0x1ff
74 cairo_public cairo_space_t
*
75 cairo_glx_space_create (void* libgl
, const char* name
, int direct
, GLXContext share_context
, unsigned flags
);
77 cairo_public cairo_space_t
*
78 cairo_glx_space_wrap (void* libgl
, Display
* dpy
, int owns_dpy
, int direct
, GLXContext share_context
, unsigned flags
);
81 cairo_glx_space_use_waitgl(cairo_space_t
* space
, int value
);
84 cairo_glx_space_use_waitx(cairo_space_t
* space
, int value
);
86 cairo_public cairo_space_t
*
87 cairo_osmesa_space_create (void* libgl
, OSMesaContext share_context
, unsigned flags
);
89 cairo_public cairo_space_t
*
90 cairo_gl_hardware_space_create(void* libgl
, unsigned flags
);
92 cairo_public cairo_space_t
*
93 cairo_gl_space_create (void* libgl
, unsigned flags
);
95 cairo_public cairo_space_t
*
96 cairo_gl_space_create_from_current_context (void* libgl
, unsigned flags
);
98 cairo_public cairo_space_t
*
99 cairo_glx_space_create_from_current_context(void* libgl
, unsigned flags
);
101 cairo_public cairo_space_t
*
102 cairo_osmesa_space_create_from_current_context(void* libgl
, unsigned flags
);
104 /* These functions will return multisampled or non-multisampled objects depending on whether multisampling is enabled.
105 If you enable/disable multisampling (except only at the beginning), you MUST use cairo_surface_flush and cairo_surface_mark_dirty around GL drawing.
106 You must call flush and surface_mark_dirty using the multisample enable mode that you will use for OpenGL drawing.
107 The reason of this is that the backend internally copies data lazily between multisampled and non-multisampled objects.
108 flush and surface_mark_dirty are very cheap if there is no work to do.
120 write with OpenGL, no multisampling
124 flush // even if you haven't drawn anything!
126 write with OpenGL, with multisampling
130 cairo_public cairo_gl_api_t
131 cairo_gl_space_get_api(cairo_space_t
* space
);
134 cairo_gl_space_get_libgl(cairo_space_t
* space
);
136 /* void* is GLXContext, OSMesaContext, EGLContext, ... */
138 cairo_gl_space_create_context(cairo_space_t
* space
, cairo_surface_t
* surface
);
140 cairo_public cairo_bool_t
141 cairo_gl_space_make_current(cairo_space_t
* space
, void* context
, cairo_surface_t
* draw_surface
, cairo_surface_t
* read_surface
);
143 /* you must bind a created context before calling this! */
145 cairo_gl_space_get_proc_address(cairo_space_t
* space
, const char* name
);
148 cairo_gl_space_destroy_context(cairo_space_t
* space
, void* context
);
150 cairo_public
unsigned
151 cairo_gl_surface_get_texture(cairo_surface_t
* surface
);
153 cairo_public
unsigned
154 cairo_gl_surface_get_framebuffer(cairo_surface_t
* surface
);
156 cairo_public
unsigned
157 cairo_gl_surface_get_renderbuffer(cairo_surface_t
* surface
);
159 cairo_public
unsigned long
160 cairo_gl_surface_get_drawable(cairo_surface_t
* surface
);
162 cairo_public
unsigned long
163 cairo_gl_surface_get_gl_drawable(cairo_surface_t
* surface
);
167 #else /* CAIRO_HAS_GL_SURFACE */
168 # error Cairo was not compiled with support for the GPU OpenGL backend
169 #endif /* CAIRO_HAS_GL_SURFACE */
171 #endif /* CAIRO_GPU_H */