Cleanup of derived state calculation prior to seperating software T&L
[mesa.git] / src / mesa / main / points.c
1 /* $Id: points.c,v 1.21 2000/11/13 20:02:56 keithw Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.4
6 *
7 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 */
26
27
28 #ifdef PC_HEADER
29 #include "all.h"
30 #else
31 #include "glheader.h"
32 #include "context.h"
33 #include "feedback.h"
34 #include "macros.h"
35 #include "mmath.h"
36 #include "points.h"
37 #include "texstate.h"
38 #include "types.h"
39 #include "vb.h"
40 #endif
41
42
43
44 void
45 _mesa_PointSize( GLfloat size )
46 {
47 GET_CURRENT_CONTEXT(ctx);
48 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPointSize");
49
50 if (size <= 0.0) {
51 gl_error( ctx, GL_INVALID_VALUE, "glPointSize" );
52 return;
53 }
54
55 if (ctx->Point.UserSize != size) {
56 ctx->Point.UserSize = size;
57 ctx->Point.Size = CLAMP(size, ctx->Const.MinPointSize, ctx->Const.MaxPointSize);
58 ctx->_TriangleCaps &= ~DD_POINT_SIZE;
59 if (size != 1.0)
60 ctx->_TriangleCaps |= DD_POINT_SIZE;
61 ctx->NewState |= _NEW_POINT;
62 }
63 }
64
65
66
67 void
68 _mesa_PointParameterfEXT( GLenum pname, GLfloat param)
69 {
70 _mesa_PointParameterfvEXT(pname, &param);
71 }
72
73
74 void
75 _mesa_PointParameterfvEXT( GLenum pname, const GLfloat *params)
76 {
77 GET_CURRENT_CONTEXT(ctx);
78 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPointParameterfvEXT");
79
80 switch (pname) {
81 case GL_DISTANCE_ATTENUATION_EXT:
82 {
83 const GLboolean tmp = ctx->Point._Attenuated;
84 COPY_3V(ctx->Point.Params, params);
85 ctx->Point._Attenuated = (params[0] != 1.0 ||
86 params[1] != 0.0 ||
87 params[2] != 0.0);
88
89 if (tmp != ctx->Point._Attenuated) {
90 ctx->_Enabled ^= ENABLE_POINT_ATTEN;
91 ctx->_TriangleCaps ^= DD_POINT_ATTEN;
92 ctx->_NeedEyeCoords ^= NEED_EYE_POINT_ATTEN;
93 }
94 }
95 break;
96 case GL_POINT_SIZE_MIN_EXT:
97 if (*params < 0.0F) {
98 gl_error( ctx, GL_INVALID_VALUE, "glPointParameterfvEXT" );
99 return;
100 }
101 ctx->Point.MinSize = *params;
102 break;
103 case GL_POINT_SIZE_MAX_EXT:
104 if (*params < 0.0F) {
105 gl_error( ctx, GL_INVALID_VALUE, "glPointParameterfvEXT" );
106 return;
107 }
108 ctx->Point.MaxSize = *params;
109 break;
110 case GL_POINT_FADE_THRESHOLD_SIZE_EXT:
111 if (*params < 0.0F) {
112 gl_error( ctx, GL_INVALID_VALUE, "glPointParameterfvEXT" );
113 return;
114 }
115 ctx->Point.Threshold = *params;
116 break;
117 default:
118 gl_error( ctx, GL_INVALID_ENUM, "glPointParameterfvEXT" );
119 return;
120 }
121
122 ctx->NewState |= _NEW_POINT;
123 }
124