Fixed typo
[reactos.git] / dll / opengl / mesa / swrast / s_feedback.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 7.0
4 *
5 * Copyright (C) 1999-2007 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
25 #include <precomp.h>
26
27 #include <main/feedback.h>
28
29 static void
30 feedback_vertex(struct gl_context * ctx, const SWvertex * v, const SWvertex * pv)
31 {
32 GLfloat win[4];
33 const GLfloat *vtc = v->attrib[FRAG_ATTRIB_TEX];
34 const GLfloat *color = v->attrib[FRAG_ATTRIB_COL];
35
36 win[0] = v->attrib[FRAG_ATTRIB_WPOS][0];
37 win[1] = v->attrib[FRAG_ATTRIB_WPOS][1];
38 win[2] = v->attrib[FRAG_ATTRIB_WPOS][2] / ctx->DrawBuffer->_DepthMaxF;
39 win[3] = 1.0F / v->attrib[FRAG_ATTRIB_WPOS][3];
40
41 _mesa_feedback_vertex(ctx, win, color, vtc);
42 }
43
44
45 /*
46 * Put triangle in feedback buffer.
47 */
48 void
49 _swrast_feedback_triangle(struct gl_context *ctx, const SWvertex *v0,
50 const SWvertex *v1, const SWvertex *v2)
51 {
52 if (!_swrast_culltriangle(ctx, v0, v1, v2)) {
53 _mesa_feedback_token(ctx, (GLfloat) (GLint) GL_POLYGON_TOKEN);
54 _mesa_feedback_token(ctx, (GLfloat) 3); /* three vertices */
55
56 if (ctx->Light.ShadeModel == GL_SMOOTH) {
57 feedback_vertex(ctx, v0, v0);
58 feedback_vertex(ctx, v1, v1);
59 feedback_vertex(ctx, v2, v2);
60 }
61 else {
62 feedback_vertex(ctx, v0, v2);
63 feedback_vertex(ctx, v1, v2);
64 feedback_vertex(ctx, v2, v2);
65 }
66 }
67 }
68
69
70 void
71 _swrast_feedback_line(struct gl_context *ctx, const SWvertex *v0,
72 const SWvertex *v1)
73 {
74 GLenum token = GL_LINE_TOKEN;
75 SWcontext *swrast = SWRAST_CONTEXT(ctx);
76
77 if (swrast->StippleCounter == 0)
78 token = GL_LINE_RESET_TOKEN;
79
80 _mesa_feedback_token(ctx, (GLfloat) (GLint) token);
81
82 if (ctx->Light.ShadeModel == GL_SMOOTH) {
83 feedback_vertex(ctx, v0, v0);
84 feedback_vertex(ctx, v1, v1);
85 }
86 else {
87 feedback_vertex(ctx, v0, v1);
88 feedback_vertex(ctx, v1, v1);
89 }
90
91 swrast->StippleCounter++;
92 }
93
94
95 void
96 _swrast_feedback_point(struct gl_context *ctx, const SWvertex *v)
97 {
98 _mesa_feedback_token(ctx, (GLfloat) (GLint) GL_POINT_TOKEN);
99 feedback_vertex(ctx, v, v);
100 }
101
102
103 void
104 _swrast_select_triangle(struct gl_context *ctx, const SWvertex *v0,
105 const SWvertex *v1, const SWvertex *v2)
106 {
107 if (!_swrast_culltriangle(ctx, v0, v1, v2)) {
108 const GLfloat zs = 1.0F / ctx->DrawBuffer->_DepthMaxF;
109
110 _mesa_update_hitflag( ctx, v0->attrib[FRAG_ATTRIB_WPOS][2] * zs );
111 _mesa_update_hitflag( ctx, v1->attrib[FRAG_ATTRIB_WPOS][2] * zs );
112 _mesa_update_hitflag( ctx, v2->attrib[FRAG_ATTRIB_WPOS][2] * zs );
113 }
114 }
115
116
117 void
118 _swrast_select_line(struct gl_context *ctx, const SWvertex *v0, const SWvertex *v1)
119 {
120 const GLfloat zs = 1.0F / ctx->DrawBuffer->_DepthMaxF;
121 _mesa_update_hitflag( ctx, v0->attrib[FRAG_ATTRIB_WPOS][2] * zs );
122 _mesa_update_hitflag( ctx, v1->attrib[FRAG_ATTRIB_WPOS][2] * zs );
123 }
124
125
126 void
127 _swrast_select_point(struct gl_context *ctx, const SWvertex *v)
128 {
129 const GLfloat zs = 1.0F / ctx->DrawBuffer->_DepthMaxF;
130 _mesa_update_hitflag( ctx, v->attrib[FRAG_ATTRIB_WPOS][2] * zs );
131 }