| 1 |
/* $Id: polygon.c,v 1.2 2000/10/27 15:21:40 mholst Exp $ */ |
| 2 |
|
| 3 |
/* |
| 4 |
* Mesa 3-D graphics library |
| 5 |
* Version: 2.0 |
| 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 |
#include <assert.h> |
| 24 |
#include <stdlib.h> |
| 25 |
#include <string.h> |
| 26 |
#include "context.h" |
| 27 |
#include "macros.h" |
| 28 |
#include "polygon.h" |
| 29 |
#include "types.h" |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
void gl_CullFace( GLcontext *ctx, GLenum mode ) |
| 34 |
{ |
| 35 |
if (mode!=GL_FRONT && mode!=GL_BACK && mode!=GL_FRONT_AND_BACK) { |
| 36 |
gl_error( ctx, GL_INVALID_ENUM, "glCullFace" ); |
| 37 |
return; |
| 38 |
} |
| 39 |
if (INSIDE_BEGIN_END(ctx)) { |
| 40 |
gl_error( ctx, GL_INVALID_OPERATION, "glCullFace" ); |
| 41 |
return; |
| 42 |
} |
| 43 |
ctx->Polygon.CullFaceMode = mode; |
| 44 |
ctx->NewState |= NEW_RASTER_OPS; |
| 45 |
} |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
void gl_FrontFace( GLcontext *ctx, GLenum mode ) |
| 50 |
{ |
| 51 |
if (INSIDE_BEGIN_END(ctx)) { |
| 52 |
gl_error( ctx, GL_INVALID_OPERATION, "glFrontFace" ); |
| 53 |
return; |
| 54 |
} |
| 55 |
if (mode!=GL_CW && mode!=GL_CCW) { |
| 56 |
gl_error( ctx, GL_INVALID_ENUM, "glFrontFace" ); |
| 57 |
return; |
| 58 |
} |
| 59 |
ctx->Polygon.FrontFace = mode; |
| 60 |
} |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
void gl_PolygonMode( GLcontext *ctx, GLenum face, GLenum mode ) |
| 65 |
{ |
| 66 |
if (INSIDE_BEGIN_END(ctx)) { |
| 67 |
gl_error( ctx, GL_INVALID_OPERATION, "glPolygonMode" ); |
| 68 |
return; |
| 69 |
} |
| 70 |
if (face!=GL_FRONT && face!=GL_BACK && face!=GL_FRONT_AND_BACK) { |
| 71 |
gl_error( ctx, GL_INVALID_ENUM, "glPolygonMode(face)" ); |
| 72 |
return; |
| 73 |
} |
| 74 |
else if (mode!=GL_POINT && mode!=GL_LINE && mode!=GL_FILL) { |
| 75 |
gl_error( ctx, GL_INVALID_ENUM, "glPolygonMode(mode)" ); |
| 76 |
return; |
| 77 |
} |
| 78 |
|
| 79 |
if (face==GL_FRONT || face==GL_FRONT_AND_BACK) { |
| 80 |
ctx->Polygon.FrontMode = mode; |
| 81 |
} |
| 82 |
if (face==GL_BACK || face==GL_FRONT_AND_BACK) { |
| 83 |
ctx->Polygon.BackMode = mode; |
| 84 |
} |
| 85 |
|
| 86 |
/* Compute a handy "shortcut" value: */ |
| 87 |
if (ctx->Polygon.FrontMode!=GL_FILL || ctx->Polygon.BackMode!=GL_FILL) { |
| 88 |
ctx->Polygon.Unfilled = GL_TRUE; |
| 89 |
} |
| 90 |
else { |
| 91 |
ctx->Polygon.Unfilled = GL_FALSE; |
| 92 |
} |
| 93 |
|
| 94 |
ctx->NewState |= NEW_RASTER_OPS; |
| 95 |
} |
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
void gl_PolygonStipple( GLcontext *ctx, const GLubyte *mask ) |
| 100 |
{ |
| 101 |
/* TODO: bit twiddling, unpacking */ |
| 102 |
if (INSIDE_BEGIN_END(ctx)) { |
| 103 |
gl_error( ctx, GL_INVALID_OPERATION, "glPolygonStipple" ); |
| 104 |
return; |
| 105 |
} |
| 106 |
MEMCPY( ctx->PolygonStipple, mask, 32*4 ); |
| 107 |
if (ctx->Polygon.StippleFlag) { |
| 108 |
ctx->NewState |= NEW_RASTER_OPS; |
| 109 |
} |
| 110 |
} |
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
void gl_GetPolygonStipple( GLcontext *ctx, GLubyte *mask ) |
| 115 |
{ |
| 116 |
/* TODO */ |
| 117 |
} |
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
void gl_PolygonOffset( GLcontext *ctx, |
| 122 |
GLfloat factor, GLfloat units ) |
| 123 |
{ |
| 124 |
if (INSIDE_BEGIN_END(ctx)) { |
| 125 |
gl_error( ctx, GL_INVALID_OPERATION, "glPolygonOffset" ); |
| 126 |
return; |
| 127 |
} |
| 128 |
ctx->Polygon.OffsetFactor = factor; |
| 129 |
ctx->Polygon.OffsetUnits = units; |
| 130 |
} |
| 131 |
|