ReactOS 0.4.15-dev-7788-g1ad9096
scissor.c
Go to the documentation of this file.
1/* $Id: scissor.c,v 1.6 1997/11/25 03:38:58 brianp Exp $ */
2
3/*
4 * Mesa 3-D graphics library
5 * Version: 2.5
6 * Copyright (C) 1995-1997 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
24/*
25 * $Log: scissor.c,v $
26 * Revision 1.6 1997/11/25 03:38:58 brianp
27 * small optimization to gl_Scissor() (Daryll Strauss)
28 *
29 * Revision 1.5 1997/07/24 01:21:56 brianp
30 * changed precompiled header symbol from PCH to PC_HEADER
31 *
32 * Revision 1.4 1997/05/28 03:26:29 brianp
33 * added precompiled header (PCH) support
34 *
35 * Revision 1.3 1997/05/17 03:17:50 brianp
36 * faster gl_scissor_span() from Mats Lofkvist
37 *
38 * Revision 1.2 1996/09/15 14:18:37 brianp
39 * now use GLframebuffer and GLvisual
40 *
41 * Revision 1.1 1996/09/13 01:38:16 brianp
42 * Initial revision
43 *
44 */
45
46
47#ifdef PC_HEADER
48#include "all.h"
49#else
50#include "context.h"
51#include "macros.h"
52#include "dlist.h"
53#include "scissor.h"
54#include "types.h"
55#endif
56
57
60{
61 if (width<0 || height<0) {
62 gl_error( ctx, GL_INVALID_VALUE, "glScissor" );
63 return;
64 }
65 if (INSIDE_BEGIN_END(ctx)) {
66 gl_error( ctx, GL_INVALID_OPERATION, "glBegin" );
67 return;
68 }
69
70 if (x!=ctx->Scissor.X || y!=ctx->Scissor.Y ||
71 width!=ctx->Scissor.Width || height!=ctx->Scissor.Height) {
72 ctx->Scissor.X = x;
73 ctx->Scissor.Y = y;
74 ctx->Scissor.Width = width;
75 ctx->Scissor.Height = height;
76 ctx->NewState |= NEW_ALL; /* TODO: this is overkill */
77 }
78}
79
80
81
82/*
83 * Apply the scissor test to a span of pixels.
84 * Return: 0 = all pixels in the span are outside the scissor box.
85 * 1 = one or more pixels passed the scissor test.
86 */
89{
90 /* first check if whole span is outside the scissor box */
91 if (y<ctx->Buffer->Ymin || y>ctx->Buffer->Ymax
92 || x>ctx->Buffer->Xmax || x+(GLint)n-1<ctx->Buffer->Xmin) {
93 return 0;
94 }
95 else {
96 GLint i;
97 GLint xMin = ctx->Buffer->Xmin;
98 GLint xMax = ctx->Buffer->Xmax;
99 for (i=0; x+i < xMin; i++) {
100 mask[i] = 0;
101 }
102 for (i=(GLint)n-1; x+i > xMax; i--) {
103 mask[i] = 0;
104 }
105
106 return 1;
107 }
108}
109
110
111
112
113/*
114 * Apply the scissor test to an array of pixels.
115 */
117 GLuint n, const GLint x[], const GLint y[],
118 GLubyte mask[] )
119{
120 GLint xmin = ctx->Buffer->Xmin;
121 GLint xmax = ctx->Buffer->Xmax;
122 GLint ymin = ctx->Buffer->Ymin;
123 GLint ymax = ctx->Buffer->Ymax;
124 GLuint i;
125
126 for (i=0;i<n;i++) {
127 mask[i] &= (x[i]>=xmin) & (x[i]<=xmax) & (y[i]>=ymin) & (y[i]<=ymax);
128 }
129
130 return 1;
131}
132
Definition: bufpool.h:45
void gl_error(GLcontext *ctx, GLenum error, const char *s)
Definition: context.c:1421
#define NEW_ALL
Definition: types.h:1236
unsigned char GLubyte
Definition: gl.h:157
#define GL_INVALID_VALUE
Definition: gl.h:695
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define GL_INVALID_OPERATION
Definition: gl.h:696
unsigned int GLuint
Definition: gl.h:159
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
int GLsizei
Definition: gl.h:160
int GLint
Definition: gl.h:156
GLint GLint GLsizei width
Definition: gl.h:1546
GLdouble n
Definition: glext.h:7729
GLenum GLint GLuint mask
Definition: glext.h:6028
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define INSIDE_BEGIN_END(CTX)
Definition: macros.h:135
GLuint gl_scissor_pixels(GLcontext *ctx, GLuint n, const GLint x[], const GLint y[], GLubyte mask[])
Definition: scissor.c:116
GLint gl_scissor_span(GLcontext *ctx, GLuint n, GLint x, GLint y, GLubyte mask[])
Definition: scissor.c:87
void gl_Scissor(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height)
Definition: scissor.c:58