swrast.h revision ba41b8afb1b40b967cf5c0e604bbf09793eb8fee
1/* 2 * Mesa 3-D graphics library 3 * Version: 3.5 4 * 5 * Copyright (C) 1999 Brian Paul All Rights Reserved. 6 * 7 * Permission is hereby granted, free of charge, to any person obtaining a 8 * copy of this software and associated documentation files (the "Software"), 9 * to deal in the Software without restriction, including without limitation 10 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 * and/or sell copies of the Software, and to permit persons to whom the 12 * Software is furnished to do so, subject to the following conditions: 13 * 14 * The above copyright notice and this permission notice shall be included 15 * in all copies or substantial portions of the Software. 16 * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 * 24 * Authors: 25 * Keith Whitwell <keithw@valinux.com> 26 */ 27 28#ifndef SWRAST_H 29#define SWRAST_H 30 31#include "types.h" 32 33 34 35/* The software rasterizer now uses this format for vertices. Thus a 36 * 'RasterSetup' stage or other translation is required between the 37 * tnl module and the swrast rasterization functions. This serves to 38 * isolate the swrast module from the internals of the tnl module, and 39 * improve its usefulness as a fallback mechanism for hardware 40 * drivers. 41 * 42 * Full software drivers: 43 * - Register the rastersetup and triangle functions from 44 * utils/software_helper. 45 * - On statechange, update the rasterization pointers in that module. 46 * 47 * Rasterization hardware drivers: 48 * - Keep native rastersetup. 49 * - Implement native twoside,offset and unfilled triangle setup. 50 * - Implement a translator from native vertices to swrast vertices. 51 * - On partial fallback (mix of accelerated and unaccelerated 52 * prims), call a pass-through function which translates native 53 * vertices to SWvertices and calls the appropriate swrast function. 54 * - On total fallback (vertex format insufficient for state or all 55 * primitives unaccelerated), hook in swrast_setup instead. 56 */ 57typedef struct { 58 GLfloat win[4]; 59 GLfloat eye[4]; /* for GL_EXT_point_param only */ 60 GLfloat texcoord[MAX_TEXTURE_UNITS][4]; 61 GLchan color[4]; 62 GLchan specular[4]; 63 GLfloat fog; 64 GLuint index; 65} SWvertex; 66 67 68 69 70/* These are the public-access functions exported from swrast. 71 */ 72extern void 73_swrast_alloc_buffers( GLcontext *ctx ); 74 75extern GLboolean 76_swrast_CreateContext( GLcontext *ctx ); 77 78extern void 79_swrast_DestroyContext( GLcontext *ctx ); 80 81 82 83extern void 84_swrast_Bitmap( GLcontext *ctx, 85 GLint px, GLint py, 86 GLsizei width, GLsizei height, 87 const struct gl_pixelstore_attrib *unpack, 88 const GLubyte *bitmap ); 89 90extern void 91_swrast_CopyPixels( GLcontext *ctx, 92 GLint srcx, GLint srcy, 93 GLint destx, GLint desty, 94 GLsizei width, GLsizei height, 95 GLenum type ); 96 97extern void 98_swrast_DrawPixels( GLcontext *ctx, 99 GLint x, GLint y, 100 GLsizei width, GLsizei height, 101 GLenum format, GLenum type, 102 const struct gl_pixelstore_attrib *unpack, 103 const GLvoid *pixels ); 104 105extern void 106_swrast_ReadPixels( GLcontext *ctx, 107 GLint x, GLint y, GLsizei width, GLsizei height, 108 GLenum format, GLenum type, 109 const struct gl_pixelstore_attrib *unpack, 110 GLvoid *pixels ); 111 112extern void 113_swrast_Clear( GLcontext *ctx, GLbitfield mask, GLboolean all, 114 GLint x, GLint y, GLint width, GLint height ); 115 116extern void 117_swrast_Accum( GLcontext *ctx, GLenum op, 118 GLfloat value, GLint xpos, GLint ypos, 119 GLint width, GLint height ); 120 121 122/* Get a pointer to the stipple counter. 123 */ 124extern GLuint * 125_swrast_get_stipple_counter_ref( GLcontext *ctx ); 126 127 128/* These will always render the correct point/line/triangle for the 129 * current state. 130 */ 131extern void 132_swrast_Point( GLcontext *ctx, SWvertex *v ); 133 134extern void 135_swrast_Line( GLcontext *ctx, SWvertex *v0, SWvertex *v1 ); 136 137extern void 138_swrast_Triangle( GLcontext *ctx, SWvertex *v0, SWvertex *v1, SWvertex *v2 ); 139 140extern void 141_swrast_Quad( GLcontext *ctx, SWvertex *v0, SWvertex *v1, SWvertex *v2, 142 SWvertex *v3); 143 144extern void 145_swrast_flush( GLcontext *ctx ); 146 147 148/* Tell the software rasterizer about core state changes. 149 */ 150extern void 151_swrast_InvalidateState( GLcontext *ctx, GLuint new_state ); 152 153 154#endif 155