1 /* $Id: xmesa.h,v 1.2 2000/11/01 22:18:00 mholst Exp $ */ 2 3 /* 4 * Mesa 3-D graphics library 5 * Version: 2.1 6 * Copyright (C) 1995-1996 Brian Paul 7 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Library General Public 10 * License as published by the Free Software Foundation; either 11 * version 2 of the License, or (at your option) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Library General Public License for more details. 17 * 18 * You should have received a copy of the GNU Library General Public 19 * License along with this library; if not, write to the Free 20 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 */ 22 23 /* 24 * Mesa/X11 interface. This header file serves as the documentation for 25 * the Mesa/X11 interface functions. 26 */ 27 28 29 /* Sample Usage: 30 31 In addition to the usual X calls to select a visual, create a colormap 32 and create a window, you must do the following to use the X/Mesa interface: 33 34 1. Call XMesaCreateVisual() to make an XMesaVisual from an XVisualInfo. 35 36 2. Call XMesaCreateContext() to create an X/Mesa rendering context, given 37 the XMesaVisual. 38 39 3. Call XMesaCreateWindowBuffer() to create an XMesaBuffer from an X window 40 and XMesaVisual. 41 42 4. Call XMesaMakeCurrent() to bind the XMesaBuffer to an XMesaContext and 43 to make the context the current one. 44 45 5. Make gl* calls to render your graphics. 46 47 6. Use XMesaSwapBuffers() when double buffering to update the buffer. 48 49 7. Before the X window is destroyed, call XMesaDestroyBuffer(). 50 51 8. Before exiting, call XMesaDestroyVisual and XMesaDestroyContext. 52 53 See the demos/xdemo.c and xmesa1.c files for examples. 54 */ 55 56 57 58 59 #ifndef XMESA_H 60 #define XMESA_H 61 62 63 #ifdef __cplusplus 64 extern "C" { 65 #endif 66 67 68 #include <X11/Xlib.h> 69 #include <X11/Xutil.h> 70 #include "GL/gl.h" 71 72 #ifdef AMIWIN 73 #include <pragmas/xlib_pragmas.h> 74 extern struct Library *XLibBase; 75 #endif 76 77 78 #define XMESA_MAJOR_VERSION 2 79 #define XMESA_MINOR_VERSION 1 80 81 82 83 /* 84 * Values passed to XMesaGetString: 85 */ 86 #define XMESA_VERSION 1 87 #define XMESA_EXTENSIONS 2 88 89 90 91 typedef struct xmesa_context *XMesaContext; 92 93 typedef struct xmesa_visual *XMesaVisual; 94 95 typedef struct xmesa_buffer *XMesaBuffer; 96 97 98 99 100 /* 101 * Create a new X/Mesa visual. 102 * Input: display - X11 display 103 * visinfo - an XVisualInfo pointer 104 * rgb_flag - GL_TRUE = RGB mode, 105 * GL_FALSE = color index mode 106 * alpha_flag - alpha buffer requested? 107 * db_flag - GL_TRUE = double-buffered, 108 * GL_FALSE = single buffered 109 * depth_size - requested bits/depth values, or zero 110 * stencil_size - requested bits/stencil values, or zero 111 * accum_size - requested bits/component values, or zero 112 * ximage_flag - GL_TRUE = use an XImage for back buffer, 113 * GL_FALSE = use an off-screen pixmap for back buffer 114 * Return; a new XMesaVisual or 0 if error. 115 */ 116 extern XMesaVisual XMesaCreateVisual( Display *display, 117 XVisualInfo *visinfo, 118 GLboolean rgb_flag, 119 GLboolean alpha_flag, 120 GLboolean db_flag, 121 GLboolean ximage_flag, 122 GLint depth_size, 123 GLint stencil_size, 124 GLint accum_size, 125 GLint level ); 126 127 /* 128 * Destroy an XMesaVisual, but not the associated XVisualInfo. 129 */ 130 extern void XMesaDestroyVisual( XMesaVisual v ); 131 132 133 134 /* 135 * Create a new XMesaContext for rendering into an X11 window. 136 * 137 * Input: visual - an XMesaVisual 138 * share_list - another XMesaContext with which to share display 139 * lists or NULL if no sharing is wanted. 140 * Return: an XMesaContext or NULL if error. 141 */ 142 extern XMesaContext XMesaCreateContext( XMesaVisual visual, 143 XMesaContext share_list ); 144 145 146 /* 147 * Destroy a rendering context as returned by XMesaCreateContext() 148 */ 149 extern void XMesaDestroyContext( XMesaContext c ); 150 151 152 /* 153 * Create an XMesaBuffer from an X window. 154 */ 155 extern XMesaBuffer XMesaCreateWindowBuffer( XMesaVisual v, Window w ); 156 157 158 /* 159 * Create an XMesaBuffer from an X pixmap. 160 */ 161 extern XMesaBuffer XMesaCreatePixmapBuffer( XMesaVisual v, Pixmap p, 162 Colormap c ); 163 164 165 /* 166 * Destroy an XMesaBuffer, but not the corresponding window or pixmap. 167 */ 168 extern void XMesaDestroyBuffer( XMesaBuffer b ); 169 170 171 /* 172 * Bind a buffer to a context and make the context the current one. 173 */ 174 extern GLboolean XMesaMakeCurrent( XMesaContext c, XMesaBuffer b ); 175 176 177 /* 178 * Return a handle to the current context. 179 */ 180 extern XMesaContext XMesaGetCurrentContext( void ); 181 182 183 /* 184 * Return handle to the current buffer. 185 */ 186 extern XMesaBuffer XMesaGetCurrentBuffer( void ); 187 188 189 /* 190 * Swap the front and back buffers for the given buffer. No action is 191 * taken if the buffer is not double buffered. 192 */ 193 extern void XMesaSwapBuffers( XMesaBuffer b ); 194 195 196 /* 197 * Return a pointer to the the Pixmap or XImage being used as the back 198 * color buffer of an XMesaBuffer. This function is a way to get "under 199 * the hood" of X/Mesa so one can manipulate the back buffer directly. 200 * Input: b - the XMesaBuffer 201 * Output: pixmap - pointer to back buffer's Pixmap, or 0 202 * ximage - pointer to back buffer's XImage, or NULL 203 * Return: GL_TRUE = context is double buffered 204 * GL_FALSE = context is single buffered 205 */ 206 extern GLboolean XMesaGetBackBuffer( XMesaBuffer b, 207 Pixmap *pixmap, XImage **ximage ); 208 209 210 211 /* 212 * Flush/sync a context 213 */ 214 extern void XMesaFlush( XMesaContext c ); 215 216 217 218 /* 219 * Get an X/Mesa-specific string. 220 * Input: name - either XMESA_VERSION or XMESA_EXTENSIONS 221 */ 222 extern const char *XMesaGetString( XMesaContext c, int name ); 223 224 225 226 #ifdef __cplusplus 227 } 228 #endif 229 230 231 #endif 232