Brian Paul | 976c26c | 2001-08-20 16:07:10 +0000 | [diff] [blame] | 1 | /* uglmesa.h - Public header UGL/Mesa */ |
| 2 | |
| 3 | /* Copyright (C) 2001 by Wind River Systems, Inc */ |
| 4 | |
| 5 | /* |
| 6 | * Mesa 3-D graphics library |
| 7 | * Version: 3.5 |
| 8 | * |
| 9 | * The MIT License |
| 10 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 11 | * copy of this software and associated documentation files (the "Software"), |
| 12 | * to deal in the Software without restriction, including without limitation |
| 13 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 14 | * and/or sell copies of the Software, and to permit persons to whom the |
| 15 | * Software is furnished to do so, subject to the following conditions: |
| 16 | * |
| 17 | * The above copyright notice and this permission notice shall be included |
| 18 | * in all copies or substantial portions of the Software. |
| 19 | * |
| 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 21 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 23 | * THE AUTHORS OR COPYRIGHT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 25 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 26 | * DEALINGS IN THE SOFTWARE. |
| 27 | */ |
| 28 | |
| 29 | /* |
| 30 | * Author: |
| 31 | * Stephane Raimbault <stephane.raimbault@windriver.com> |
| 32 | */ |
| 33 | |
| 34 | #ifndef UGLMESA_H |
| 35 | #define UGLMESA_H |
| 36 | |
| 37 | #ifdef __cplusplus |
| 38 | extern "C" { |
| 39 | #endif |
| 40 | |
| 41 | #define UGL_MESA_MAJOR_VERSION 1 |
| 42 | #define UGL_MESA_MINOR_VERSION 0 |
| 43 | |
| 44 | #include <GL/gl.h> |
| 45 | #include <ugl/ugl.h> |
| 46 | |
| 47 | /* |
| 48 | * Values for display mode of uglMesaCreateContext () |
| 49 | */ |
| 50 | |
| 51 | #define UGL_MESA_SINGLE 0x00 |
| 52 | #define UGL_MESA_DOUBLE 0x01 |
| 53 | #define UGL_MESA_DOUBLE_SW 0x02 |
| 54 | #define UGL_MESA_DOUBLE_HW 0x03 |
| 55 | |
| 56 | #define UGL_MESA_FULLSCREEN_WIDTH 0x0 |
| 57 | #define UGL_MESA_FULLSCREEN_HEIGHT 0x0 |
| 58 | |
| 59 | /* |
| 60 | * Pixel format |
| 61 | */ |
| 62 | #define UGL_MESA_ARGB8888 0x01 |
| 63 | #define UGL_MESA_RGB565 0x02 |
| 64 | #define UGL_MESA_RGB888 0x03 |
| 65 | #define UGL_MESA_ARGB4444 0x04 |
| 66 | #define UGL_MESA_CI 0x05 |
| 67 | #define UGL_MESA_DITHER_RGB 0x10 |
| 68 | |
| 69 | /* |
| 70 | * uglMesaPixelStore() parameters: |
| 71 | */ |
| 72 | |
| 73 | #define UGL_MESA_ROW_LENGTH 0x10 |
| 74 | #define UGL_MESA_Y_UP 0x11 |
| 75 | |
| 76 | /* |
| 77 | * Accepted by uglMesaGetIntegerv: |
| 78 | */ |
| 79 | |
| 80 | #define UGL_MESA_LEFT_X 0x18 |
| 81 | #define UGL_MESA_TOP_Y 0x19 |
| 82 | #define UGL_MESA_WIDTH 0x20 |
| 83 | #define UGL_MESA_HEIGHT 0x21 |
| 84 | #define UGL_MESA_DISPLAY_WIDTH 0x22 |
| 85 | #define UGL_MESA_DISPLAY_HEIGHT 0x23 |
| 86 | #define UGL_MESA_COLOR_FORMAT 0x24 |
| 87 | #define UGL_MESA_COLOR_MODEL 0x25 |
| 88 | #define UGL_MESA_PIXEL_FORMAT 0x26 |
| 89 | #define UGL_MESA_TYPE 0x27 |
| 90 | #define UGL_MESA_RGB 0x28 |
| 91 | #define UGL_MESA_COLOR_INDEXED 0x29 |
| 92 | |
| 93 | /* |
| 94 | * typedefs |
| 95 | */ |
| 96 | |
| 97 | typedef struct uglMesaContext * UGL_MESA_CONTEXT; |
| 98 | |
| 99 | /* |
| 100 | * Create an Mesa/UGL rendering context. The attributes needed are |
| 101 | * double buffer flag and a context sharelist. |
| 102 | * |
| 103 | * It's necessary to first call this function before use uglMakeCurrentContext. |
| 104 | * This function provides neither stencil nor accumulation buffer only |
| 105 | * a depth buffer to reduce memory footprint. |
| 106 | * |
| 107 | * Input: db_mode - UGL_MESA_SINGLE = single buffer mode |
| 108 | * UGL_MESA_DOUBLE = double buffer mode (HW fallback -> SW) |
| 109 | * UGL_MESA_DOUBLE_SW = double buffer software |
| 110 | * UGL_MESA_DOUBLE_HW = double buffer hardware |
| 111 | * share_list - specifies another UGL_MESA_CONTEXT with which to share |
| 112 | * display lists. NULL indicates no sharing. |
| 113 | * |
| 114 | * Return: a UGL_MESA_CONTEXT, or zero if error |
| 115 | */ |
| 116 | |
| 117 | UGL_MESA_CONTEXT uglMesaCreateNewContext (GLenum db_mode, |
| 118 | UGL_MESA_CONTEXT share_list); |
| 119 | |
| 120 | /* |
| 121 | * Create an UGL/Mesa rendering context and specify desired |
| 122 | * size of depth buffer, stencil buffer and accumulation buffer. |
| 123 | * If you specify zero for depth_bits, stencil_bits, |
| 124 | * accum_[red|gren|blue]_bits, you can save some memory. |
| 125 | * |
| 126 | * INPUT: db_mode - double buffer mode |
| 127 | * depth_bits - depth buffer size |
| 128 | * stencil_bits - stencil buffer size |
| 129 | * accum_red_bits - accumulation red buffer size |
| 130 | * accum_green_bits - accumulation green buffer size |
| 131 | * accum_blue_bits -accumulation blue buffer size |
| 132 | * accum_alpha_bits -accumulation alpha buffer size |
| 133 | * share_list - specifies another UGL_MESA_CONTEXT with which to share |
| 134 | * display lists. NULL indicates no sharing. |
| 135 | */ |
| 136 | UGL_MESA_CONTEXT uglMesaCreateNewContextExt (GLenum db_flag, |
| 137 | GLint depth_bits, |
| 138 | GLint stencil_bits, |
| 139 | GLint accum_red_bits, |
| 140 | GLint accum_green_bits, |
| 141 | GLint accum_blue_bits, |
| 142 | GLint accum_alpha_bits, |
| 143 | UGL_MESA_CONTEXT share_list); |
| 144 | |
| 145 | /* |
| 146 | * Bind an UGL_MESA_CONTEXT to an image buffer. The image buffer is |
| 147 | * just a block of memory which the client provides. Its size must be |
| 148 | * at least as large as width*height*sizeof(type). Its address should |
| 149 | * be a multiple of 4 if using RGBA mode. |
| 150 | * |
| 151 | * Image data is stored in the order of glDrawPixels: row-major order |
| 152 | * with the lower-left image pixel stored in the first array position |
| 153 | * (ie. bottom-to-top). |
| 154 | * |
| 155 | * Since the only type initially supported is GL_UNSIGNED_BYTE, if the |
| 156 | * context is in RGBA mode, each pixel will be stored as a 4-byte RGBA |
| 157 | * value. If the context is in color indexed mode, each pixel will be |
| 158 | * stored as a 1-byte value. |
| 159 | * |
| 160 | * If the context's viewport hasn't been initialized yet, it will now be |
| 161 | * initialized to (0, 0, width, height). |
| 162 | * |
| 163 | * Input: umc - a rendering context |
| 164 | * left, top - coordinates in pixels of (left,top) pixel |
| 165 | * (0,0) in fullscreen mode. |
| 166 | * width, height - size of image buffer in pixels, at least 1 |
| 167 | * else fullscreen dimensions are used (UGL_MESA_DISPLAY_WIDTH |
| 168 | * and UGL_MESA_DISPLAY_HEIGHT). |
| 169 | * |
| 170 | * Return: GL_TRUE if success, GL_FALSE if error because of invalid umc, |
| 171 | * width<1, height<1, width>internal limit or height>internal limit. |
| 172 | */ |
| 173 | |
| 174 | GLboolean uglMesaMakeCurrentContext (UGL_MESA_CONTEXT umc, |
| 175 | GLsizei left, GLsizei top, |
| 176 | GLsizei width, GLsizei height); |
| 177 | |
| 178 | /* |
| 179 | * Move an OpenGL window by a delta value |
| 180 | * |
| 181 | * Input: dx, dy - delta values in pixels |
| 182 | * |
| 183 | * Return: GL_TRUE if success, GL_FALSE if error because of invalid |
| 184 | * coordinates. |
| 185 | */ |
| 186 | GLboolean uglMesaMoveWindow (GLsizei dx, GLsizei dy); |
| 187 | |
| 188 | /* |
| 189 | * Move an OpenGL window to an absolute position |
| 190 | * |
| 191 | * Input: left, top - new coordinates in pixels |
| 192 | * |
| 193 | * Return: GL_TRUE if success, GL_FALSE if error because of invalid |
| 194 | * coordinates. |
| 195 | */ |
| 196 | GLboolean uglMesaMoveToWindow (GLsizei left, GLsizei top); |
| 197 | |
| 198 | /* |
| 199 | * Resize an OpenGL window by a delta value |
| 200 | * |
| 201 | * Input: dw, dh - delta values in pixels |
| 202 | * |
| 203 | * Return: GL_TRUE if success, GL_FALSE if error because of invalid |
| 204 | * coordinates. |
| 205 | */ |
| 206 | GLboolean uglMesaResizeWindow (GLsizei dw, GLsizei dh); |
| 207 | |
| 208 | /* |
| 209 | * Resize an OpenGL window to an absolute size |
| 210 | * |
| 211 | * Input: width, height - new dimensions in pixels |
| 212 | * |
| 213 | * Return: GL_TRUE if success, GL_FALSE if error because of invalid |
| 214 | * coordinates. |
| 215 | */ |
| 216 | GLboolean uglMesaResizeToWindow (GLsizei width, GLsizei height); |
| 217 | |
| 218 | /* |
| 219 | * Destroy the current UGL/Mesa rendering context |
| 220 | * |
| 221 | */ |
| 222 | void uglMesaDestroyContext (void); |
| 223 | |
| 224 | /* |
| 225 | * Return the current UGL/Mesa context |
| 226 | * |
| 227 | * Return: a UGL/Mesa context, or NULL if error |
| 228 | * |
| 229 | */ |
| 230 | UGL_MESA_CONTEXT uglMesaGetCurrentContext (void); |
| 231 | |
| 232 | /* |
| 233 | * Swap front and back buffers in double buffering mode. This |
| 234 | * function is a no-op if there's no back buffer. In case of software |
| 235 | * double buffering a copy occurs from off-screen buffer to front |
| 236 | * buffer. Works faster with an hardware support. |
| 237 | */ |
| 238 | |
| 239 | void uglMesaSwapBuffers (void); |
| 240 | |
| 241 | /* |
| 242 | * Set pixel store/packing parameters for the current context. This |
| 243 | * is similar to glPixelStore. UGL uses Y coordinates increase |
| 244 | * downward. |
| 245 | * |
| 246 | * Input: pname - UGL_MESA_ROW_LENGTH |
| 247 | * zero, same as image width (default). |
| 248 | * value specify actual pixels per row in image buffer |
| 249 | * UGL_MESA_Y_UP: |
| 250 | * zero = Y coordinates increase downward (default) |
| 251 | * non-zero = Y coordinates increase upward |
| 252 | * value - value for the parameter pname |
| 253 | */ |
| 254 | |
| 255 | void uglMesaPixelStore (GLint pname, GLint value); |
| 256 | |
| 257 | /* |
| 258 | * Return an integer value like glGetIntegerv. |
| 259 | * |
| 260 | * Input: pname - UGL_MESA_LEFT_X return the x axis value |
| 261 | * of the most left pixel |
| 262 | * UGL_MESA_TOP_Y return the y axis value |
| 263 | * of the topper pixel |
| 264 | * UGL_MESA_WIDTH return current image width |
| 265 | * UGL_MESA_HEIGHT return current image height |
| 266 | * UGL_MESA_COLOR_FORMAT return image color format |
| 267 | * UGL_MESA_COLOR_MODEL return image color model |
| 268 | * UGL_MESA_PIXEL_FORMAT return pixel format |
| 269 | * UGL_MESA_ROW_LENGTH return row length in pixels |
| 270 | * UGL_MESA_RGB return true if RGB |
| 271 | * UGL_MESA_COLOR_INDEXED return true if color indexed |
| 272 | * value - pointer to integer in which to return result. |
| 273 | */ |
| 274 | void uglMesaGetIntegerv (GLint pname, GLint *value); |
| 275 | |
| 276 | /* |
| 277 | * Return the depth buffer associated with an UGL/Mesa context. |
| 278 | * |
| 279 | * Output: width, height - size of buffer in pixels |
| 280 | * bytesPerValue - bytes per depth value (2 or 4) |
| 281 | * buffer - pointer to depth buffer values |
| 282 | * Return: GL_TRUE or GL_FALSE to indicate success or failure. |
| 283 | * |
| 284 | */ |
| 285 | GLboolean uglMesaGetDepthBuffer (GLint *width, GLint *height, |
| 286 | GLint *bytesPerValue, void **buffer); |
| 287 | |
| 288 | /* |
| 289 | * Return the color buffer associated with an UGL/Mesa context. |
| 290 | * Input: c - the UGL/Mesa context |
| 291 | * Output: width, height - size of buffer in pixels |
| 292 | * format - buffer format (UGLMESA_FORMAT) |
| 293 | * buffer - pointer to color buffer values |
| 294 | * Return: GL_TRUE or GL_FALSE to indicate success or failure. |
| 295 | * |
| 296 | */ |
| 297 | GLboolean uglMesaGetColorBuffer (GLint *width, GLint *height, |
| 298 | GLint *format, void **buffer); |
| 299 | |
| 300 | /* |
| 301 | * Color allocation in indexed mode. |
| 302 | * This function does nothing in RGB mode. |
| 303 | * |
| 304 | * Input: index - Value for the current color index |
| 305 | * red - Red component (between 0 and 1) |
| 306 | * green - Green component (between 0 and 1) |
| 307 | * blue - Blue component (between 0 and 1) |
| 308 | * |
| 309 | * Return: GL_TRUE if success, or GL_FALSE if index<0 or * clutSize<index, |
| 310 | * red, green and blue are not between 0.0 and 1.0. |
| 311 | * |
| 312 | */ |
| 313 | |
| 314 | GLboolean uglMesaSetColor (GLubyte index, GLfloat red, |
| 315 | GLfloat green, GLfloat blue); |
| 316 | |
| 317 | #ifdef __cplusplus |
| 318 | } |
| 319 | #endif |
| 320 | |
| 321 | |
| 322 | #endif |