2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
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:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
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.
28 * General framebuffer-related functions, like glClear, glScissor, etc.
47 _mesa_ClearIndex( GLfloat c
)
49 GET_CURRENT_CONTEXT(ctx
);
50 ASSERT_OUTSIDE_BEGIN_END(ctx
);
52 if (ctx
->Color
.ClearIndex
== (GLuint
) c
)
55 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
56 ctx
->Color
.ClearIndex
= (GLuint
) c
;
58 if (!ctx
->Visual
.rgbMode
&& ctx
->Driver
.ClearIndex
) {
59 /* it's OK to call glClearIndex in RGBA mode but it should be a NOP */
60 (*ctx
->Driver
.ClearIndex
)( ctx
, ctx
->Color
.ClearIndex
);
67 * Specify the clear values for the color buffers.
69 * \param red red color component.
70 * \param green green color component.
71 * \param blue blue color component.
72 * \param alpha alpha component.
76 * Clamps the parameters and updates gl_colorbuffer_attrib::ClearColor. On a
77 * change, flushes the vertices and notifies the driver via the
78 * dd_function_table::ClearColor callback.
81 _mesa_ClearColor( GLclampf red
, GLclampf green
, GLclampf blue
, GLclampf alpha
)
84 GET_CURRENT_CONTEXT(ctx
);
85 ASSERT_OUTSIDE_BEGIN_END(ctx
);
87 tmp
[0] = CLAMP(red
, 0.0F
, 1.0F
);
88 tmp
[1] = CLAMP(green
, 0.0F
, 1.0F
);
89 tmp
[2] = CLAMP(blue
, 0.0F
, 1.0F
);
90 tmp
[3] = CLAMP(alpha
, 0.0F
, 1.0F
);
92 if (TEST_EQ_4V(tmp
, ctx
->Color
.ClearColor
))
93 return; /* no change */
95 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
96 COPY_4V(ctx
->Color
.ClearColor
, tmp
);
98 if (ctx
->Visual
.rgbMode
&& ctx
->Driver
.ClearColor
) {
99 /* it's OK to call glClearColor in CI mode but it should be a NOP */
100 (*ctx
->Driver
.ClearColor
)(ctx
, ctx
->Color
.ClearColor
);
108 * \param mask bit-mask indicating the buffers to be cleared.
110 * Flushes the vertices and verifies the parameter. If __GLcontextRec::NewState
111 * is set then calls _mesa_update_state() to update gl_frame_buffer::_Xmin,
112 * etc. If the rasterization mode is set to GL_RENDER then requests the driver
113 * to clear the buffers, via the dd_function_table::Clear callback.
116 _mesa_Clear( GLbitfield mask
)
118 GET_CURRENT_CONTEXT(ctx
);
119 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
121 if (MESA_VERBOSE
& VERBOSE_API
)
122 _mesa_debug(ctx
, "glClear 0x%x\n", mask
);
124 if (mask
& ~(GL_COLOR_BUFFER_BIT
|
125 GL_DEPTH_BUFFER_BIT
|
126 GL_STENCIL_BUFFER_BIT
|
127 GL_ACCUM_BUFFER_BIT
)) {
128 /* invalid bit set */
129 _mesa_error( ctx
, GL_INVALID_VALUE
, "glClear(0x%x)", mask
);
134 _mesa_update_state( ctx
); /* update _Xmin, etc */
137 if (ctx
->DrawBuffer
->_Status
!= GL_FRAMEBUFFER_COMPLETE_EXT
) {
138 _mesa_error(ctx
, GL_INVALID_FRAMEBUFFER_OPERATION_EXT
,
139 "glClear(incomplete framebuffer)");
143 if (ctx
->RenderMode
== GL_RENDER
) {
144 const GLint x
= ctx
->DrawBuffer
->_Xmin
;
145 const GLint y
= ctx
->DrawBuffer
->_Ymin
;
146 const GLint height
= ctx
->DrawBuffer
->_Ymax
- ctx
->DrawBuffer
->_Ymin
;
147 const GLint width
= ctx
->DrawBuffer
->_Xmax
- ctx
->DrawBuffer
->_Xmin
;
148 GLbitfield bufferMask
;
150 /* don't clear depth buffer if depth writing disabled */
151 if (!ctx
->Depth
.Mask
)
152 mask
&= ~GL_DEPTH_BUFFER_BIT
;
154 /* Build the bitmask to send to device driver's Clear function.
155 * Note that the GL_COLOR_BUFFER_BIT flag will expand to 0, 1, 2 or 4
156 * of the BUFFER_BIT_FRONT/BACK_LEFT/RIGHT flags, or one of the
157 * BUFFER_BIT_COLORn flags.
160 if (mask
& GL_COLOR_BUFFER_BIT
) {
161 bufferMask
|= ctx
->DrawBuffer
->_ColorDrawBufferMask
[0];
164 if ((mask
& GL_DEPTH_BUFFER_BIT
)
165 && ctx
->DrawBuffer
->Visual
.haveDepthBuffer
) {
166 bufferMask
|= BUFFER_BIT_DEPTH
;
169 if ((mask
& GL_STENCIL_BUFFER_BIT
)
170 && ctx
->DrawBuffer
->Visual
.haveStencilBuffer
) {
171 bufferMask
|= BUFFER_BIT_STENCIL
;
174 if ((mask
& GL_ACCUM_BUFFER_BIT
)
175 && ctx
->DrawBuffer
->Visual
.haveAccumBuffer
) {
176 bufferMask
|= BUFFER_BIT_ACCUM
;
179 ASSERT(ctx
->Driver
.Clear
);
180 ctx
->Driver
.Clear( ctx
, bufferMask
, (GLboolean
) !ctx
->Scissor
.Enabled
,
181 x
, y
, width
, height
);
188 * Return bitmask of BUFFER_BIT_* flags indicating which color buffers are
189 * available to the rendering context.
190 * This depends on the framebuffer we're writing to. For window system
191 * framebuffers we look at the framebuffer's visual. But for user-
192 * create framebuffers we look at the number of supported color attachments.
195 supported_buffer_bitmask(const GLcontext
*ctx
, GLuint framebufferID
)
197 GLbitfield mask
= 0x0;
199 if (framebufferID
> 0) {
200 /* A user-created renderbuffer */
202 ASSERT(ctx
->Extensions
.EXT_framebuffer_object
);
203 for (i
= 0; i
< ctx
->Const
.MaxColorAttachments
; i
++) {
204 mask
|= (BUFFER_BIT_COLOR0
<< i
);
208 /* A window system renderbuffer */
210 mask
= BUFFER_BIT_FRONT_LEFT
; /* always have this */
211 if (ctx
->Visual
.stereoMode
) {
212 mask
|= BUFFER_BIT_FRONT_RIGHT
;
213 if (ctx
->Visual
.doubleBufferMode
) {
214 mask
|= BUFFER_BIT_BACK_LEFT
| BUFFER_BIT_BACK_RIGHT
;
217 else if (ctx
->Visual
.doubleBufferMode
) {
218 mask
|= BUFFER_BIT_BACK_LEFT
;
221 for (i
= 0; i
< ctx
->Visual
.numAuxBuffers
; i
++) {
222 mask
|= (BUFFER_BIT_AUX0
<< i
);
231 * Helper routine used by glDrawBuffer and glDrawBuffersARB.
232 * Given a GLenum naming one or more color buffers (such as
233 * GL_FRONT_AND_BACK), return the corresponding bitmask of BUFFER_BIT_* flags.
236 draw_buffer_enum_to_bitmask(GLenum buffer
)
242 return BUFFER_BIT_FRONT_LEFT
| BUFFER_BIT_FRONT_RIGHT
;
244 return BUFFER_BIT_BACK_LEFT
| BUFFER_BIT_BACK_RIGHT
;
246 return BUFFER_BIT_FRONT_RIGHT
| BUFFER_BIT_BACK_RIGHT
;
248 return BUFFER_BIT_FRONT_RIGHT
;
250 return BUFFER_BIT_BACK_RIGHT
;
252 return BUFFER_BIT_BACK_LEFT
;
253 case GL_FRONT_AND_BACK
:
254 return BUFFER_BIT_FRONT_LEFT
| BUFFER_BIT_BACK_LEFT
255 | BUFFER_BIT_FRONT_RIGHT
| BUFFER_BIT_BACK_RIGHT
;
257 return BUFFER_BIT_FRONT_LEFT
| BUFFER_BIT_BACK_LEFT
;
259 return BUFFER_BIT_FRONT_LEFT
;
261 return BUFFER_BIT_AUX0
;
263 return BUFFER_BIT_AUX1
;
265 return BUFFER_BIT_AUX2
;
267 return BUFFER_BIT_AUX3
;
268 case GL_COLOR_ATTACHMENT0_EXT
:
269 return BUFFER_BIT_COLOR0
;
270 case GL_COLOR_ATTACHMENT1_EXT
:
271 return BUFFER_BIT_COLOR1
;
272 case GL_COLOR_ATTACHMENT2_EXT
:
273 return BUFFER_BIT_COLOR2
;
274 case GL_COLOR_ATTACHMENT3_EXT
:
275 return BUFFER_BIT_COLOR3
;
284 * Helper routine used by glReadBuffer.
285 * Given a GLenum naming a color buffer, return the index of the corresponding
286 * renderbuffer (a BUFFER_* value).
287 * return -1 for an invalid buffer.
290 read_buffer_enum_to_index(GLenum buffer
)
294 return BUFFER_FRONT_LEFT
;
296 return BUFFER_BACK_LEFT
;
298 return BUFFER_FRONT_RIGHT
;
300 return BUFFER_FRONT_RIGHT
;
302 return BUFFER_BACK_RIGHT
;
304 return BUFFER_BACK_LEFT
;
306 return BUFFER_FRONT_LEFT
;
308 return BUFFER_FRONT_LEFT
;
317 case GL_COLOR_ATTACHMENT0_EXT
:
318 return BUFFER_COLOR0
;
319 case GL_COLOR_ATTACHMENT1_EXT
:
320 return BUFFER_COLOR1
;
321 case GL_COLOR_ATTACHMENT2_EXT
:
322 return BUFFER_COLOR2
;
323 case GL_COLOR_ATTACHMENT3_EXT
:
324 return BUFFER_COLOR3
;
333 * Called by glDrawBuffer().
334 * Specify which renderbuffer(s) to draw into for the first color output.
335 * <buffer> can name zero, one, two or four renderbuffers!
336 * \sa _mesa_DrawBuffersARB
338 * \param buffer buffer token such as GL_LEFT or GL_FRONT_AND_BACK, etc.
341 _mesa_DrawBuffer(GLenum buffer
)
345 GET_CURRENT_CONTEXT(ctx
);
346 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
); /* too complex... */
348 if (MESA_VERBOSE
& VERBOSE_API
) {
349 _mesa_debug(ctx
, "glDrawBuffer %s\n", _mesa_lookup_enum_by_nr(buffer
));
352 bufferID
= ctx
->DrawBuffer
->Name
;
354 if (buffer
== GL_NONE
) {
358 const GLbitfield supportedMask
= supported_buffer_bitmask(ctx
, bufferID
);
359 destMask
= draw_buffer_enum_to_bitmask(buffer
);
360 if (destMask
== BAD_MASK
) {
361 /* totally bogus buffer */
362 _mesa_error(ctx
, GL_INVALID_ENUM
, "glDrawBuffer(buffer)");
365 destMask
&= supportedMask
;
366 if (destMask
== 0x0) {
367 /* none of the named color buffers exist! */
368 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glDrawBuffer(buffer)");
373 /* if we get here, there's no error so set new state */
374 _mesa_drawbuffers(ctx
, 1, &buffer
, &destMask
);
379 * Called by glDrawBuffersARB; specifies the destination color renderbuffers
380 * for N fragment program color outputs.
381 * \sa _mesa_DrawBuffer
382 * \param n number of outputs
383 * \param buffers array [n] of renderbuffer names. Unlike glDrawBuffer, the
384 * names cannot specify more than one buffer. For example,
385 * GL_FRONT_AND_BACK is illegal.
388 _mesa_DrawBuffersARB(GLsizei n
, const GLenum
*buffers
)
392 GLbitfield usedBufferMask
, supportedMask
;
393 GLbitfield destMask
[MAX_DRAW_BUFFERS
];
394 GET_CURRENT_CONTEXT(ctx
);
395 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
397 if (!ctx
->Extensions
.ARB_draw_buffers
) {
398 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glDrawBuffersARB");
401 if (n
< 1 || n
> (GLsizei
) ctx
->Const
.MaxDrawBuffers
) {
402 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDrawBuffersARB(n)");
406 bufferID
= ctx
->DrawBuffer
->Name
;
408 supportedMask
= supported_buffer_bitmask(ctx
, bufferID
);
409 usedBufferMask
= 0x0;
411 /* complicated error checking... */
412 for (output
= 0; output
< n
; output
++) {
413 if (buffers
[output
] == GL_NONE
) {
414 destMask
[output
] = 0x0;
417 destMask
[output
] = draw_buffer_enum_to_bitmask(buffers
[output
]);
418 if (destMask
[output
] == BAD_MASK
419 || _mesa_bitcount(destMask
[output
]) > 1) {
420 _mesa_error(ctx
, GL_INVALID_ENUM
, "glDrawBuffersARB(buffer)");
423 destMask
[output
] &= supportedMask
;
424 if (destMask
[output
] == 0) {
425 _mesa_error(ctx
, GL_INVALID_OPERATION
,
426 "glDrawBuffersARB(unsupported buffer)");
429 if (destMask
[output
] & usedBufferMask
) {
430 /* can't specify a dest buffer more than once! */
431 _mesa_error(ctx
, GL_INVALID_OPERATION
,
432 "glDrawBuffersARB(duplicated buffer)");
437 usedBufferMask
|= destMask
[output
];
441 /* OK, if we get here, there were no errors so set the new state */
442 _mesa_drawbuffers(ctx
, n
, buffers
, destMask
);
447 * Set color output state. Traditionally, there was only one color
448 * output, but fragment programs can now have several distinct color
449 * outputs (see GL_ARB_draw_buffers). This function sets the state
450 * for one such color output.
451 * \param ctx current context
452 * \param output which fragment program output
453 * \param buffer buffer to write to (like GL_LEFT)
454 * \param destMask BUFFER_* bitmask
455 * (like BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT).
458 set_color_output(GLcontext
*ctx
, GLuint output
, GLenum buffer
,
461 struct gl_framebuffer
*fb
= ctx
->DrawBuffer
;
463 ASSERT(output
< ctx
->Const
.MaxDrawBuffers
);
465 /* Set per-FBO state */
466 fb
->ColorDrawBuffer
[output
] = buffer
;
467 fb
->_ColorDrawBufferMask
[output
] = destMask
;
468 /* not really needed, will be set later */
469 fb
->_NumColorDrawBuffers
[output
] = 0;
471 /* Set traditional state var */
472 ctx
->Color
.DrawBuffer
[output
] = buffer
;
477 * Helper routine used by _mesa_DrawBuffer, _mesa_DrawBuffersARB and
478 * _mesa_PopAttrib to set drawbuffer state.
479 * All error checking will have been done prior to calling this function
480 * so nothing should go wrong at this point.
481 * \param ctx current context
482 * \param n number of color outputs to set
483 * \param buffers array[n] of colorbuffer names, like GL_LEFT.
484 * \param destMask array[n] of BUFFER_* bitmasks which correspond to the
485 * colorbuffer names. (i.e. GL_FRONT_AND_BACK =>
486 * BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT).
489 _mesa_drawbuffers(GLcontext
*ctx
, GLuint n
, const GLenum
*buffers
,
490 const GLbitfield
*destMask
)
492 GLbitfield mask
[MAX_DRAW_BUFFERS
];
496 /* compute destMask values now */
497 const GLuint bufferID
= ctx
->DrawBuffer
->Name
;
498 const GLbitfield supportedMask
= supported_buffer_bitmask(ctx
, bufferID
);
499 for (output
= 0; output
< n
; output
++) {
500 mask
[output
] = draw_buffer_enum_to_bitmask(buffers
[output
]);
501 ASSERT(mask
[output
] != BAD_MASK
);
502 mask
[output
] &= supportedMask
;
507 for (output
= 0; output
< n
; output
++) {
508 set_color_output(ctx
, output
, buffers
[output
], destMask
[output
]);
511 /* set remaining color outputs to NONE */
512 for (output
= n
; output
< ctx
->Const
.MaxDrawBuffers
; output
++) {
513 set_color_output(ctx
, output
, GL_NONE
, 0x0);
516 ctx
->NewState
|= _NEW_COLOR
;
519 * Call device driver function.
521 if (ctx
->Driver
.DrawBuffers
)
522 ctx
->Driver
.DrawBuffers(ctx
, n
, buffers
);
523 else if (ctx
->Driver
.DrawBuffer
)
524 ctx
->Driver
.DrawBuffer(ctx
, buffers
[0]);
530 * Called by glReadBuffer to set the source renderbuffer for reading pixels.
531 * \param mode color buffer such as GL_FRONT, GL_BACK, etc.
534 _mesa_ReadBuffer(GLenum buffer
)
536 struct gl_framebuffer
*fb
;
537 GLbitfield supportedMask
;
540 GET_CURRENT_CONTEXT(ctx
);
541 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
543 fb
= ctx
->ReadBuffer
;
546 if (MESA_VERBOSE
& VERBOSE_API
)
547 _mesa_debug(ctx
, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(buffer
));
549 if (bufferID
> 0 && buffer
== GL_NONE
) {
550 /* This is legal for user-created framebuffer objects */
554 /* general case / window-system framebuffer */
555 srcBuffer
= read_buffer_enum_to_index(buffer
);
556 if (srcBuffer
== -1) {
557 _mesa_error(ctx
, GL_INVALID_ENUM
, "glReadBuffer(buffer=0x%x)", buffer
);
560 supportedMask
= supported_buffer_bitmask(ctx
, bufferID
);
561 if (((1 << srcBuffer
) & supportedMask
) == 0) {
562 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glReadBuffer(buffer=0x%x)", buffer
);
568 ctx
->Pixel
.ReadBuffer
= buffer
;
570 fb
->ColorReadBuffer
= buffer
;
571 fb
->_ColorReadBufferIndex
= srcBuffer
;
573 ctx
->NewState
|= _NEW_PIXEL
;
576 * Call device driver function.
578 if (ctx
->Driver
.ReadBuffer
)
579 (*ctx
->Driver
.ReadBuffer
)(ctx
, buffer
);
586 * XXX THIS IS OBSOLETE - drivers should take care of detecting window
587 * size changes and act accordingly, likely calling _mesa_resize_framebuffer().
589 * GL_MESA_resize_buffers extension.
591 * When this function is called, we'll ask the window system how large
592 * the current window is. If it's a new size, we'll call the driver's
593 * ResizeBuffers function. The driver will then resize its color buffers
594 * as needed, and maybe call the swrast's routine for reallocating
595 * swrast-managed depth/stencil/accum/etc buffers.
596 * \note This function should only be called through the GL API, not
597 * from device drivers (as was done in the past).
600 void _mesa_resizebuffers( GLcontext
*ctx
)
602 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx
);
604 if (MESA_VERBOSE
& VERBOSE_API
)
605 _mesa_debug(ctx
, "glResizeBuffersMESA\n");
607 if (!ctx
->Driver
.GetBufferSize
) {
611 if (ctx
->WinSysDrawBuffer
) {
612 GLuint newWidth
, newHeight
;
613 GLframebuffer
*buffer
= ctx
->WinSysDrawBuffer
;
615 assert(buffer
->Name
== 0);
617 /* ask device driver for size of output buffer */
618 ctx
->Driver
.GetBufferSize( buffer
, &newWidth
, &newHeight
);
620 /* see if size of device driver's color buffer (window) has changed */
621 if (buffer
->Width
!= newWidth
|| buffer
->Height
!= newHeight
) {
622 if (ctx
->Driver
.ResizeBuffers
)
623 ctx
->Driver
.ResizeBuffers(ctx
, buffer
, newWidth
, newHeight
);
627 if (ctx
->WinSysReadBuffer
628 && ctx
->WinSysReadBuffer
!= ctx
->WinSysDrawBuffer
) {
629 GLuint newWidth
, newHeight
;
630 GLframebuffer
*buffer
= ctx
->WinSysReadBuffer
;
632 assert(buffer
->Name
== 0);
634 /* ask device driver for size of read buffer */
635 ctx
->Driver
.GetBufferSize( buffer
, &newWidth
, &newHeight
);
637 /* see if size of device driver's color buffer (window) has changed */
638 if (buffer
->Width
!= newWidth
|| buffer
->Height
!= newHeight
) {
639 if (ctx
->Driver
.ResizeBuffers
)
640 ctx
->Driver
.ResizeBuffers(ctx
, buffer
, newWidth
, newHeight
);
644 ctx
->NewState
|= _NEW_BUFFERS
; /* to update scissor / window bounds */
649 * XXX THIS IS OBSOLETE
652 _mesa_ResizeBuffersMESA( void )
654 GET_CURRENT_CONTEXT(ctx
);
656 _mesa_resizebuffers( ctx
);
661 * XXX move somewhere else someday?
664 _mesa_SampleCoverageARB(GLclampf value
, GLboolean invert
)
666 GET_CURRENT_CONTEXT(ctx
);
668 if (!ctx
->Extensions
.ARB_multisample
) {
669 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glSampleCoverageARB");
673 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx
);
674 ctx
->Multisample
.SampleCoverageValue
= (GLfloat
) CLAMP(value
, 0.0, 1.0);
675 ctx
->Multisample
.SampleCoverageInvert
= invert
;
676 ctx
->NewState
|= _NEW_MULTISAMPLE
;
679 #endif /* _HAVE_FULL_GL */
684 * Define the scissor box.
686 * \param x, y coordinates of the scissor box lower-left corner.
687 * \param width width of the scissor box.
688 * \param height height of the scissor box.
692 * Verifies the parameters and updates __GLcontextRec::Scissor. On a
693 * change flushes the vertices and notifies the driver via
694 * the dd_function_table::Scissor callback.
697 _mesa_set_scissor(GLcontext
*ctx
,
698 GLint x
, GLint y
, GLsizei width
, GLsizei height
)
700 if (x
== ctx
->Scissor
.X
&&
701 y
== ctx
->Scissor
.Y
&&
702 width
== ctx
->Scissor
.Width
&&
703 height
== ctx
->Scissor
.Height
)
706 FLUSH_VERTICES(ctx
, _NEW_SCISSOR
);
709 ctx
->Scissor
.Width
= width
;
710 ctx
->Scissor
.Height
= height
;
712 if (ctx
->Driver
.Scissor
)
713 ctx
->Driver
.Scissor( ctx
, x
, y
, width
, height
);
718 _mesa_Scissor( GLint x
, GLint y
, GLsizei width
, GLsizei height
)
720 GET_CURRENT_CONTEXT(ctx
);
721 ASSERT_OUTSIDE_BEGIN_END(ctx
);
723 if (width
< 0 || height
< 0) {
724 _mesa_error( ctx
, GL_INVALID_VALUE
, "glScissor" );
728 if (MESA_VERBOSE
& VERBOSE_API
)
729 _mesa_debug(ctx
, "glScissor %d %d %d %d\n", x
, y
, width
, height
);
731 _mesa_set_scissor(ctx
, x
, y
, width
, height
);
736 /**********************************************************************/
737 /** \name Initialization */
741 * Initialize the context's scissor state.
742 * \param ctx the GL context.
745 _mesa_init_scissor(GLcontext
*ctx
)
748 ctx
->Scissor
.Enabled
= GL_FALSE
;
751 ctx
->Scissor
.Width
= 0;
752 ctx
->Scissor
.Height
= 0;
757 * Initialize the context's multisample state.
758 * \param ctx the GL context.
761 _mesa_init_multisample(GLcontext
*ctx
)
763 ctx
->Multisample
.Enabled
= GL_FALSE
;
764 ctx
->Multisample
.SampleAlphaToCoverage
= GL_FALSE
;
765 ctx
->Multisample
.SampleAlphaToOne
= GL_FALSE
;
766 ctx
->Multisample
.SampleCoverage
= GL_FALSE
;
767 ctx
->Multisample
.SampleCoverageValue
= 1.0;
768 ctx
->Multisample
.SampleCoverageInvert
= GL_FALSE
;