home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga 5 / MA_Cover_5.iso / ppc / mesa / include / gl / xmesa.h < prev   
Encoding:
C/C++ Source or Header  |  1998-01-31  |  8.2 KB  |  314 lines

  1. /* $Id: xmesa.h,v 1.8 1997/09/29 23:22:16 brianp Exp $ */
  2.  
  3. /*
  4.  * Mesa 3-D graphics library
  5.  * Version:  2.5
  6.  * Copyright (C) 1995-1997  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. /*
  25.  * $Log: xmesa.h,v $
  26.  * Revision 1.8  1997/09/29 23:22:16  brianp
  27.  * updated version to 2.5
  28.  *
  29.  * Revision 1.7  1997/07/11 23:06:55  brianp
  30.  * added XMesaGetDepthBuffer function (Randy Frank)
  31.  *
  32.  * Revision 1.6  1997/05/16 01:54:28  brianp
  33.  * edited a comment
  34.  *
  35.  * Revision 1.5  1997/05/14 03:28:37  brianp
  36.  * added XMesaDitherColor()
  37.  *
  38.  * Revision 1.4  1997/04/27 03:21:34  brianp
  39.  * added XMesaFindBuffer() and XMesaGarbageCollect
  40.  *
  41.  * Revision 1.3  1996/10/30 03:13:01  brianp
  42.  * incremented version to 2.1
  43.  *
  44.  * Revision 1.2  1996/09/20 02:56:45  brianp
  45.  * updated for new XMesaContext, XMesaVisual and XMesaBuffer datatypes
  46.  *
  47.  * Revision 1.1  1996/09/13 01:26:41  brianp
  48.  * Initial revision
  49.  *
  50.  */
  51.  
  52.  
  53. /*
  54.  * Mesa/X11 interface.  This header file serves as the documentation for
  55.  * the Mesa/X11 interface functions.
  56.  *
  57.  * Note: this interface isn't intended for user programs.  It's primarily
  58.  * just for implementing the pseudo-GLX interface.
  59.  */
  60.  
  61.  
  62. /* Sample Usage:
  63.  
  64. In addition to the usual X calls to select a visual, create a colormap
  65. and create a window, you must do the following to use the X/Mesa interface:
  66.  
  67. 1. Call XMesaCreateVisual() to make an XMesaVisual from an XVisualInfo.
  68.  
  69. 2. Call XMesaCreateContext() to create an X/Mesa rendering context, given
  70.    the XMesaVisual.
  71.  
  72. 3. Call XMesaCreateWindowBuffer() to create an XMesaBuffer from an X window
  73.    and XMesaVisual.
  74.  
  75. 4. Call XMesaMakeCurrent() to bind the XMesaBuffer to an XMesaContext and
  76.    to make the context the current one.
  77.  
  78. 5. Make gl* calls to render your graphics.
  79.  
  80. 6. Use XMesaSwapBuffers() when double buffering to swap front/back buffers.
  81.  
  82. 7. Before the X window is destroyed, call XMesaDestroyBuffer().
  83.  
  84. 8. Before exiting, call XMesaDestroyVisual and XMesaDestroyContext.
  85.  
  86. See the demos/xdemo.c and xmesa1.c files for examples.
  87. */
  88.  
  89.  
  90.  
  91.  
  92. #ifndef XMESA_H
  93. #define XMESA_H
  94.  
  95.  
  96. #ifdef __cplusplus
  97. extern "C" {
  98. #endif
  99.  
  100.  
  101. #include <X11/Xlib.h>
  102. #include <X11/Xutil.h>
  103. #include "GL/gl.h"
  104.  
  105. #ifdef AMIWIN
  106. #include <pragmas/xlib_pragmas.h>
  107. extern struct Library *XLibBase;
  108. #endif
  109.  
  110.  
  111. #define XMESA_MAJOR_VERSION 2
  112. #define XMESA_MINOR_VERSION 5
  113.  
  114.  
  115.  
  116. /*
  117.  * Values passed to XMesaGetString:
  118.  */
  119. #define XMESA_VERSION 1
  120. #define XMESA_EXTENSIONS 2
  121.  
  122.  
  123.  
  124. typedef struct xmesa_context *XMesaContext;
  125.  
  126. typedef struct xmesa_visual *XMesaVisual;
  127.  
  128. typedef struct xmesa_buffer *XMesaBuffer;
  129.  
  130.  
  131.  
  132.  
  133. /*
  134.  * Create a new X/Mesa visual.
  135.  * Input:  display - X11 display
  136.  *         visinfo - an XVisualInfo pointer
  137.  *         rgb_flag - GL_TRUE = RGB mode,
  138.  *                    GL_FALSE = color index mode
  139.  *         alpha_flag - alpha buffer requested?
  140.  *         db_flag - GL_TRUE = double-buffered,
  141.  *                   GL_FALSE = single buffered
  142.  *         depth_size - requested bits/depth values, or zero
  143.  *         stencil_size - requested bits/stencil values, or zero
  144.  *         accum_size - requested bits/component values, or zero
  145.  *         ximage_flag - GL_TRUE = use an XImage for back buffer,
  146.  *                       GL_FALSE = use an off-screen pixmap for back buffer
  147.  * Return;  a new XMesaVisual or 0 if error.
  148.  */
  149. extern XMesaVisual XMesaCreateVisual( Display *display,
  150.                                       XVisualInfo *visinfo,
  151.                                       GLboolean rgb_flag,
  152.                                       GLboolean alpha_flag,
  153.                                       GLboolean db_flag,
  154.                                       GLboolean ximage_flag,
  155.                                       GLint depth_size,
  156.                                       GLint stencil_size,
  157.                                       GLint accum_size,
  158.                                       GLint level );
  159.  
  160. /*
  161.  * Destroy an XMesaVisual, but not the associated XVisualInfo.
  162.  */
  163. extern void XMesaDestroyVisual( XMesaVisual v );
  164.  
  165.  
  166.  
  167. /*
  168.  * Create a new XMesaContext for rendering into an X11 window.
  169.  *
  170.  * Input:  visual - an XMesaVisual
  171.  *         share_list - another XMesaContext with which to share display
  172.  *                      lists or NULL if no sharing is wanted.
  173.  * Return:  an XMesaContext or NULL if error.
  174.  */
  175. extern XMesaContext XMesaCreateContext( XMesaVisual visual,
  176.                                         XMesaContext share_list );
  177.  
  178.  
  179. /*
  180.  * Destroy a rendering context as returned by XMesaCreateContext()
  181.  */
  182. extern void XMesaDestroyContext( XMesaContext c );
  183.  
  184.  
  185. /*
  186.  * Create an XMesaBuffer from an X window.
  187.  */
  188. extern XMesaBuffer XMesaCreateWindowBuffer( XMesaVisual v, Window w );
  189.  
  190.  
  191. /*
  192.  * Create an XMesaBuffer from an X pixmap.
  193.  */
  194. extern XMesaBuffer XMesaCreatePixmapBuffer( XMesaVisual v, Pixmap p,
  195.                                             Colormap c );
  196.  
  197.  
  198. /*
  199.  * Destroy an XMesaBuffer, but not the corresponding window or pixmap.
  200.  */
  201. extern void XMesaDestroyBuffer( XMesaBuffer b );
  202.  
  203.  
  204. /*
  205.  * Return the XMesaBuffer handle which corresponds to an X drawable, if any.
  206.  * New in Mesa 2.3.
  207.  */
  208. extern XMesaBuffer XMesaFindBuffer( Display *dpy, Drawable d );
  209.  
  210.  
  211.  
  212. /*
  213.  * Bind a buffer to a context and make the context the current one.
  214.  */
  215. extern GLboolean XMesaMakeCurrent( XMesaContext c, XMesaBuffer b );
  216.  
  217.  
  218. /*
  219.  * Return a handle to the current context.
  220.  */
  221. extern XMesaContext XMesaGetCurrentContext( void );
  222.  
  223.  
  224. /*
  225.  * Return handle to the current buffer.
  226.  */
  227. extern XMesaBuffer XMesaGetCurrentBuffer( void );
  228.  
  229.  
  230. /*
  231.  * Swap the front and back buffers for the given buffer.  No action is
  232.  * taken if the buffer is not double buffered.
  233.  */
  234. extern void XMesaSwapBuffers( XMesaBuffer b );
  235.  
  236.  
  237. /*
  238.  * Return a pointer to the the Pixmap or XImage being used as the back
  239.  * color buffer of an XMesaBuffer.  This function is a way to get "under
  240.  * the hood" of X/Mesa so one can manipulate the back buffer directly.
  241.  * Input:  b - the XMesaBuffer
  242.  * Output:  pixmap - pointer to back buffer's Pixmap, or 0
  243.  *          ximage - pointer to back buffer's XImage, or NULL
  244.  * Return:  GL_TRUE = context is double buffered
  245.  *          GL_FALSE = context is single buffered
  246.  */
  247. extern GLboolean XMesaGetBackBuffer( XMesaBuffer b,
  248.                                      Pixmap *pixmap, XImage **ximage );
  249.  
  250.  
  251.  
  252. /*
  253.  * Return the depth buffer associated with an XMesaBuffer.
  254.  * Input:  b - the XMesa buffer handle
  255.  * Output:  width, height - size of buffer in pixels
  256.  *          bytesPerValue - bytes per depth value (2 or 4)
  257.  *          buffer - pointer to depth buffer values
  258.  * Return:  GL_TRUE or GL_FALSE to indicate success or failure.
  259.  *
  260.  * New in Mesa 2.4.
  261.  */
  262. extern GLboolean XMesaGetDepthBuffer( XMesaBuffer b,
  263.                                       GLint *width, GLint *height,
  264.                                       GLint *bytesPerValue, void **buffer );
  265.  
  266.  
  267.  
  268. /*
  269.  * Flush/sync a context
  270.  */
  271. extern void XMesaFlush( XMesaContext c );
  272.  
  273.  
  274.  
  275. /*
  276.  * Get an X/Mesa-specific string.
  277.  * Input:  name - either XMESA_VERSION or XMESA_EXTENSIONS
  278.  */
  279. extern const char *XMesaGetString( XMesaContext c, int name );
  280.  
  281.  
  282.  
  283. /*
  284.  * Scan for XMesaBuffers whose window/pixmap has been destroyed, then free
  285.  * any memory used by that buffer.
  286.  *
  287.  * New in Mesa 2.3.
  288.  */
  289. extern void XMesaGarbageCollect( void );
  290.  
  291.  
  292.  
  293. /*
  294.  * Return a dithered pixel value.
  295.  * Input:  c - XMesaContext
  296.  *         x, y - window coordinate
  297.  *         red, green, blue, alpha - color components in [0,1]
  298.  * Return:  pixel value
  299.  *
  300.  * New in Mesa 2.3.
  301.  */
  302. extern unsigned long XMesaDitherColor( XMesaContext c, GLint x, GLint y,
  303.                                        GLfloat red, GLfloat green,
  304.                                        GLfloat blue, GLfloat alpha );
  305.  
  306.  
  307.  
  308. #ifdef __cplusplus
  309. }
  310. #endif
  311.  
  312.  
  313. #endif
  314.