2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2007 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
->DrawBuffer
->Width
== 0 || ctx
->DrawBuffer
->Height
== 0 ||
144 ctx
->DrawBuffer
->_Xmin
>= ctx
->DrawBuffer
->_Xmax
||
145 ctx
->DrawBuffer
->_Ymin
>= ctx
->DrawBuffer
->_Ymax
)
148 if (ctx
->RenderMode
== GL_RENDER
) {
149 GLbitfield bufferMask
;
151 /* don't clear depth buffer if depth writing disabled */
152 if (!ctx
->Depth
.Mask
)
153 mask
&= ~GL_DEPTH_BUFFER_BIT
;
155 /* Build the bitmask to send to device driver's Clear function.
156 * Note that the GL_COLOR_BUFFER_BIT flag will expand to 0, 1, 2 or 4
157 * of the BUFFER_BIT_FRONT/BACK_LEFT/RIGHT flags, or one of the
158 * BUFFER_BIT_COLORn flags.
161 if (mask
& GL_COLOR_BUFFER_BIT
) {
162 bufferMask
|= ctx
->DrawBuffer
->_ColorDrawBufferMask
[0];
165 if ((mask
& GL_DEPTH_BUFFER_BIT
)
166 && ctx
->DrawBuffer
->Visual
.haveDepthBuffer
) {
167 bufferMask
|= BUFFER_BIT_DEPTH
;
170 if ((mask
& GL_STENCIL_BUFFER_BIT
)
171 && ctx
->DrawBuffer
->Visual
.haveStencilBuffer
) {
172 bufferMask
|= BUFFER_BIT_STENCIL
;
175 if ((mask
& GL_ACCUM_BUFFER_BIT
)
176 && ctx
->DrawBuffer
->Visual
.haveAccumBuffer
) {
177 bufferMask
|= BUFFER_BIT_ACCUM
;
180 ASSERT(ctx
->Driver
.Clear
);
181 ctx
->Driver
.Clear(ctx
, bufferMask
);
188 * Return bitmask of BUFFER_BIT_* flags indicating which color buffers are
189 * available to the rendering context (for drawing or reading).
190 * This depends on the type of framebuffer. For window system framebuffers
191 * we look at the framebuffer's visual. But for user-create framebuffers we
192 * look at the number of supported color attachments.
193 * \param fb the framebuffer to draw to, or read from
194 * \return bitmask of BUFFER_BIT_* flags
197 supported_buffer_bitmask(const GLcontext
*ctx
, const struct gl_framebuffer
*fb
)
199 GLbitfield mask
= 0x0;
202 /* A user-created renderbuffer */
204 ASSERT(ctx
->Extensions
.EXT_framebuffer_object
);
205 for (i
= 0; i
< ctx
->Const
.MaxColorAttachments
; i
++) {
206 mask
|= (BUFFER_BIT_COLOR0
<< i
);
210 /* A window system framebuffer */
212 mask
= BUFFER_BIT_FRONT_LEFT
; /* always have this */
213 if (fb
->Visual
.stereoMode
) {
214 mask
|= BUFFER_BIT_FRONT_RIGHT
;
215 if (fb
->Visual
.doubleBufferMode
) {
216 mask
|= BUFFER_BIT_BACK_LEFT
| BUFFER_BIT_BACK_RIGHT
;
219 else if (fb
->Visual
.doubleBufferMode
) {
220 mask
|= BUFFER_BIT_BACK_LEFT
;
223 for (i
= 0; i
< fb
->Visual
.numAuxBuffers
; i
++) {
224 mask
|= (BUFFER_BIT_AUX0
<< i
);
233 * Helper routine used by glDrawBuffer and glDrawBuffersARB.
234 * Given a GLenum naming one or more color buffers (such as
235 * GL_FRONT_AND_BACK), return the corresponding bitmask of BUFFER_BIT_* flags.
238 draw_buffer_enum_to_bitmask(GLenum buffer
)
244 return BUFFER_BIT_FRONT_LEFT
| BUFFER_BIT_FRONT_RIGHT
;
246 return BUFFER_BIT_BACK_LEFT
| BUFFER_BIT_BACK_RIGHT
;
248 return BUFFER_BIT_FRONT_RIGHT
| BUFFER_BIT_BACK_RIGHT
;
250 return BUFFER_BIT_FRONT_RIGHT
;
252 return BUFFER_BIT_BACK_RIGHT
;
254 return BUFFER_BIT_BACK_LEFT
;
255 case GL_FRONT_AND_BACK
:
256 return BUFFER_BIT_FRONT_LEFT
| BUFFER_BIT_BACK_LEFT
257 | BUFFER_BIT_FRONT_RIGHT
| BUFFER_BIT_BACK_RIGHT
;
259 return BUFFER_BIT_FRONT_LEFT
| BUFFER_BIT_BACK_LEFT
;
261 return BUFFER_BIT_FRONT_LEFT
;
263 return BUFFER_BIT_AUX0
;
265 return BUFFER_BIT_AUX1
;
267 return BUFFER_BIT_AUX2
;
269 return BUFFER_BIT_AUX3
;
270 case GL_COLOR_ATTACHMENT0_EXT
:
271 return BUFFER_BIT_COLOR0
;
272 case GL_COLOR_ATTACHMENT1_EXT
:
273 return BUFFER_BIT_COLOR1
;
274 case GL_COLOR_ATTACHMENT2_EXT
:
275 return BUFFER_BIT_COLOR2
;
276 case GL_COLOR_ATTACHMENT3_EXT
:
277 return BUFFER_BIT_COLOR3
;
286 * Helper routine used by glReadBuffer.
287 * Given a GLenum naming a color buffer, return the index of the corresponding
288 * renderbuffer (a BUFFER_* value).
289 * return -1 for an invalid buffer.
292 read_buffer_enum_to_index(GLenum buffer
)
296 return BUFFER_FRONT_LEFT
;
298 return BUFFER_BACK_LEFT
;
300 return BUFFER_FRONT_RIGHT
;
302 return BUFFER_FRONT_RIGHT
;
304 return BUFFER_BACK_RIGHT
;
306 return BUFFER_BACK_LEFT
;
308 return BUFFER_FRONT_LEFT
;
310 return BUFFER_FRONT_LEFT
;
319 case GL_COLOR_ATTACHMENT0_EXT
:
320 return BUFFER_COLOR0
;
321 case GL_COLOR_ATTACHMENT1_EXT
:
322 return BUFFER_COLOR1
;
323 case GL_COLOR_ATTACHMENT2_EXT
:
324 return BUFFER_COLOR2
;
325 case GL_COLOR_ATTACHMENT3_EXT
:
326 return BUFFER_COLOR3
;
327 case GL_COLOR_ATTACHMENT4_EXT
:
328 return BUFFER_COLOR4
;
329 case GL_COLOR_ATTACHMENT5_EXT
:
330 return BUFFER_COLOR5
;
331 case GL_COLOR_ATTACHMENT6_EXT
:
332 return BUFFER_COLOR6
;
333 case GL_COLOR_ATTACHMENT7_EXT
:
334 return BUFFER_COLOR7
;
343 * Called by glDrawBuffer().
344 * Specify which renderbuffer(s) to draw into for the first color output.
345 * <buffer> can name zero, one, two or four renderbuffers!
346 * \sa _mesa_DrawBuffersARB
348 * \param buffer buffer token such as GL_LEFT or GL_FRONT_AND_BACK, etc.
350 * Note that the behaviour of this function depends on whether the
351 * current ctx->DrawBuffer is a window-system framebuffer (Name=0) or
352 * a user-created framebuffer object (Name!=0).
353 * In the former case, we update the per-context ctx->Color.DrawBuffer
354 * state var _and_ the FB's ColorDrawBuffer state.
355 * In the later case, we update the FB's ColorDrawBuffer state only.
357 * Furthermore, upon a MakeCurrent() or BindFramebuffer() call, if the
358 * new FB is a window system FB, we need to re-update the FB's
359 * ColorDrawBuffer state to match the context. This is handled in
360 * _mesa_update_framebuffer().
362 * See the GL_EXT_framebuffer_object spec for more info.
365 _mesa_DrawBuffer(GLenum buffer
)
368 GET_CURRENT_CONTEXT(ctx
);
369 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
); /* too complex... */
371 if (MESA_VERBOSE
& VERBOSE_API
) {
372 _mesa_debug(ctx
, "glDrawBuffer %s\n", _mesa_lookup_enum_by_nr(buffer
));
375 if (buffer
== GL_NONE
) {
379 const GLbitfield supportedMask
380 = supported_buffer_bitmask(ctx
, ctx
->DrawBuffer
);
381 destMask
= draw_buffer_enum_to_bitmask(buffer
);
382 if (destMask
== BAD_MASK
) {
383 /* totally bogus buffer */
384 _mesa_error(ctx
, GL_INVALID_ENUM
, "glDrawBuffer(buffer)");
387 destMask
&= supportedMask
;
388 if (destMask
== 0x0) {
389 /* none of the named color buffers exist! */
390 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glDrawBuffer(buffer)");
395 /* if we get here, there's no error so set new state */
396 _mesa_drawbuffers(ctx
, 1, &buffer
, &destMask
);
399 * Call device driver function.
401 if (ctx
->Driver
.DrawBuffers
)
402 ctx
->Driver
.DrawBuffers(ctx
, 1, &buffer
);
403 else if (ctx
->Driver
.DrawBuffer
)
404 ctx
->Driver
.DrawBuffer(ctx
, buffer
);
409 * Called by glDrawBuffersARB; specifies the destination color renderbuffers
410 * for N fragment program color outputs.
411 * \sa _mesa_DrawBuffer
412 * \param n number of outputs
413 * \param buffers array [n] of renderbuffer names. Unlike glDrawBuffer, the
414 * names cannot specify more than one buffer. For example,
415 * GL_FRONT_AND_BACK is illegal.
418 _mesa_DrawBuffersARB(GLsizei n
, const GLenum
*buffers
)
421 GLbitfield usedBufferMask
, supportedMask
;
422 GLbitfield destMask
[MAX_DRAW_BUFFERS
];
423 GET_CURRENT_CONTEXT(ctx
);
424 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
426 if (!ctx
->Extensions
.ARB_draw_buffers
) {
427 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glDrawBuffersARB");
430 if (n
< 1 || n
> (GLsizei
) ctx
->Const
.MaxDrawBuffers
) {
431 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDrawBuffersARB(n)");
435 supportedMask
= supported_buffer_bitmask(ctx
, ctx
->DrawBuffer
);
436 usedBufferMask
= 0x0;
438 /* complicated error checking... */
439 for (output
= 0; output
< n
; output
++) {
440 if (buffers
[output
] == GL_NONE
) {
441 destMask
[output
] = 0x0;
444 destMask
[output
] = draw_buffer_enum_to_bitmask(buffers
[output
]);
445 if (destMask
[output
] == BAD_MASK
446 || _mesa_bitcount(destMask
[output
]) > 1) {
447 _mesa_error(ctx
, GL_INVALID_ENUM
, "glDrawBuffersARB(buffer)");
450 destMask
[output
] &= supportedMask
;
451 if (destMask
[output
] == 0) {
452 _mesa_error(ctx
, GL_INVALID_OPERATION
,
453 "glDrawBuffersARB(unsupported buffer)");
456 if (destMask
[output
] & usedBufferMask
) {
457 /* can't specify a dest buffer more than once! */
458 _mesa_error(ctx
, GL_INVALID_OPERATION
,
459 "glDrawBuffersARB(duplicated buffer)");
464 usedBufferMask
|= destMask
[output
];
468 /* OK, if we get here, there were no errors so set the new state */
469 _mesa_drawbuffers(ctx
, n
, buffers
, destMask
);
472 * Call device driver function.
474 if (ctx
->Driver
.DrawBuffers
)
475 ctx
->Driver
.DrawBuffers(ctx
, n
, buffers
);
476 else if (ctx
->Driver
.DrawBuffer
)
477 ctx
->Driver
.DrawBuffer(ctx
, buffers
[0]);
482 * Set color output state. Traditionally, there was only one color
483 * output, but fragment programs can now have several distinct color
484 * outputs (see GL_ARB_draw_buffers). This function sets the state
485 * for one such color output.
486 * \param ctx current context
487 * \param output which fragment program output
488 * \param buffer buffer to write to (like GL_LEFT)
489 * \param destMask BUFFER_* bitmask
490 * (like BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT).
493 set_color_output(GLcontext
*ctx
, GLuint output
, GLenum buffer
,
496 struct gl_framebuffer
*fb
= ctx
->DrawBuffer
;
498 ASSERT(output
< ctx
->Const
.MaxDrawBuffers
);
500 /* Set per-FBO state */
501 fb
->ColorDrawBuffer
[output
] = buffer
;
502 fb
->_ColorDrawBufferMask
[output
] = destMask
;
503 /* not really needed, will be set later */
504 fb
->_NumColorDrawBuffers
[output
] = 0;
507 /* Only set the per-context DrawBuffer state if we're currently
508 * drawing to a window system framebuffer.
510 ctx
->Color
.DrawBuffer
[output
] = buffer
;
516 * Helper function to set the GL_DRAW_BUFFER state in the context and
519 * All error checking will have been done prior to calling this function
520 * so nothing should go wrong at this point.
522 * \param ctx current context
523 * \param n number of color outputs to set
524 * \param buffers array[n] of colorbuffer names, like GL_LEFT.
525 * \param destMask array[n] of BUFFER_* bitmasks which correspond to the
526 * colorbuffer names. (i.e. GL_FRONT_AND_BACK =>
527 * BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT).
530 _mesa_drawbuffers(GLcontext
*ctx
, GLuint n
, const GLenum
*buffers
,
531 const GLbitfield
*destMask
)
533 GLbitfield mask
[MAX_DRAW_BUFFERS
];
537 /* compute destMask values now */
538 const GLbitfield supportedMask
539 = supported_buffer_bitmask(ctx
, ctx
->DrawBuffer
);
540 for (output
= 0; output
< n
; output
++) {
541 mask
[output
] = draw_buffer_enum_to_bitmask(buffers
[output
]);
542 ASSERT(mask
[output
] != BAD_MASK
);
543 mask
[output
] &= supportedMask
;
548 for (output
= 0; output
< n
; output
++) {
549 set_color_output(ctx
, output
, buffers
[output
], destMask
[output
]);
552 /* set remaining color outputs to NONE */
553 for (output
= n
; output
< ctx
->Const
.MaxDrawBuffers
; output
++) {
554 set_color_output(ctx
, output
, GL_NONE
, 0x0);
557 ctx
->NewState
|= _NEW_COLOR
;
562 * Like \sa _mesa_drawbuffers(), this is a helper function for setting
563 * GL_READ_BUFFER state in the context and current FBO.
564 * \param ctx the rendering context
565 * \param buffer GL_FRONT, GL_BACK, GL_COLOR_ATTACHMENT0, etc.
566 * \param bufferIndex the numerical index corresponding to 'buffer'
569 _mesa_readbuffer(GLcontext
*ctx
, GLenum buffer
, GLint bufferIndex
)
571 struct gl_framebuffer
*fb
= ctx
->ReadBuffer
;
574 /* Only update the per-context READ_BUFFER state if we're bound to
575 * a window-system framebuffer.
577 ctx
->Pixel
.ReadBuffer
= buffer
;
580 fb
->ColorReadBuffer
= buffer
;
581 fb
->_ColorReadBufferIndex
= bufferIndex
;
583 ctx
->NewState
|= _NEW_PIXEL
;
589 * Called by glReadBuffer to set the source renderbuffer for reading pixels.
590 * \param mode color buffer such as GL_FRONT, GL_BACK, etc.
593 _mesa_ReadBuffer(GLenum buffer
)
595 struct gl_framebuffer
*fb
;
596 GLbitfield supportedMask
;
598 GET_CURRENT_CONTEXT(ctx
);
599 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
601 if (MESA_VERBOSE
& VERBOSE_API
)
602 _mesa_debug(ctx
, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(buffer
));
604 fb
= ctx
->ReadBuffer
;
606 if (MESA_VERBOSE
& VERBOSE_API
)
607 _mesa_debug(ctx
, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(buffer
));
609 if (fb
->Name
> 0 && buffer
== GL_NONE
) {
610 /* This is legal for user-created framebuffer objects */
614 /* general case / window-system framebuffer */
615 srcBuffer
= read_buffer_enum_to_index(buffer
);
616 if (srcBuffer
== -1) {
617 _mesa_error(ctx
, GL_INVALID_ENUM
,
618 "glReadBuffer(buffer=0x%x)", buffer
);
621 supportedMask
= supported_buffer_bitmask(ctx
, fb
);
622 if (((1 << srcBuffer
) & supportedMask
) == 0) {
623 _mesa_error(ctx
, GL_INVALID_OPERATION
,
624 "glReadBuffer(buffer=0x%x)", buffer
);
629 /* OK, all error checking has been completed now */
631 _mesa_readbuffer(ctx
, buffer
, srcBuffer
);
634 * Call device driver function.
636 if (ctx
->Driver
.ReadBuffer
)
637 (*ctx
->Driver
.ReadBuffer
)(ctx
, buffer
);
644 * XXX THIS IS OBSOLETE - drivers should take care of detecting window
645 * size changes and act accordingly, likely calling _mesa_resize_framebuffer().
647 * GL_MESA_resize_buffers extension.
649 * When this function is called, we'll ask the window system how large
650 * the current window is. If it's a new size, we'll call the driver's
651 * ResizeBuffers function. The driver will then resize its color buffers
652 * as needed, and maybe call the swrast's routine for reallocating
653 * swrast-managed depth/stencil/accum/etc buffers.
654 * \note This function should only be called through the GL API, not
655 * from device drivers (as was done in the past).
658 void _mesa_resizebuffers( GLcontext
*ctx
)
660 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx
);
662 if (MESA_VERBOSE
& VERBOSE_API
)
663 _mesa_debug(ctx
, "glResizeBuffersMESA\n");
665 if (!ctx
->Driver
.GetBufferSize
) {
669 if (ctx
->WinSysDrawBuffer
) {
670 GLuint newWidth
, newHeight
;
671 GLframebuffer
*buffer
= ctx
->WinSysDrawBuffer
;
673 assert(buffer
->Name
== 0);
675 /* ask device driver for size of output buffer */
676 ctx
->Driver
.GetBufferSize( buffer
, &newWidth
, &newHeight
);
678 /* see if size of device driver's color buffer (window) has changed */
679 if (buffer
->Width
!= newWidth
|| buffer
->Height
!= newHeight
) {
680 if (ctx
->Driver
.ResizeBuffers
)
681 ctx
->Driver
.ResizeBuffers(ctx
, buffer
, newWidth
, newHeight
);
685 if (ctx
->WinSysReadBuffer
686 && ctx
->WinSysReadBuffer
!= ctx
->WinSysDrawBuffer
) {
687 GLuint newWidth
, newHeight
;
688 GLframebuffer
*buffer
= ctx
->WinSysReadBuffer
;
690 assert(buffer
->Name
== 0);
692 /* ask device driver for size of read buffer */
693 ctx
->Driver
.GetBufferSize( buffer
, &newWidth
, &newHeight
);
695 /* see if size of device driver's color buffer (window) has changed */
696 if (buffer
->Width
!= newWidth
|| buffer
->Height
!= newHeight
) {
697 if (ctx
->Driver
.ResizeBuffers
)
698 ctx
->Driver
.ResizeBuffers(ctx
, buffer
, newWidth
, newHeight
);
702 ctx
->NewState
|= _NEW_BUFFERS
; /* to update scissor / window bounds */
707 * XXX THIS IS OBSOLETE
710 _mesa_ResizeBuffersMESA( void )
712 GET_CURRENT_CONTEXT(ctx
);
714 if (ctx
->Extensions
.MESA_resize_buffers
)
715 _mesa_resizebuffers( ctx
);
720 * XXX move somewhere else someday?
723 _mesa_SampleCoverageARB(GLclampf value
, GLboolean invert
)
725 GET_CURRENT_CONTEXT(ctx
);
727 if (!ctx
->Extensions
.ARB_multisample
) {
728 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glSampleCoverageARB");
732 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx
);
733 ctx
->Multisample
.SampleCoverageValue
= (GLfloat
) CLAMP(value
, 0.0, 1.0);
734 ctx
->Multisample
.SampleCoverageInvert
= invert
;
735 ctx
->NewState
|= _NEW_MULTISAMPLE
;
738 #endif /* _HAVE_FULL_GL */
743 * Define the scissor box.
745 * \param x, y coordinates of the scissor box lower-left corner.
746 * \param width width of the scissor box.
747 * \param height height of the scissor box.
751 * Verifies the parameters and updates __GLcontextRec::Scissor. On a
752 * change flushes the vertices and notifies the driver via
753 * the dd_function_table::Scissor callback.
756 _mesa_set_scissor(GLcontext
*ctx
,
757 GLint x
, GLint y
, GLsizei width
, GLsizei height
)
759 if (x
== ctx
->Scissor
.X
&&
760 y
== ctx
->Scissor
.Y
&&
761 width
== ctx
->Scissor
.Width
&&
762 height
== ctx
->Scissor
.Height
)
765 FLUSH_VERTICES(ctx
, _NEW_SCISSOR
);
768 ctx
->Scissor
.Width
= width
;
769 ctx
->Scissor
.Height
= height
;
771 if (ctx
->Driver
.Scissor
)
772 ctx
->Driver
.Scissor( ctx
, x
, y
, width
, height
);
777 _mesa_Scissor( GLint x
, GLint y
, GLsizei width
, GLsizei height
)
779 GET_CURRENT_CONTEXT(ctx
);
780 ASSERT_OUTSIDE_BEGIN_END(ctx
);
782 if (width
< 0 || height
< 0) {
783 _mesa_error( ctx
, GL_INVALID_VALUE
, "glScissor" );
787 if (MESA_VERBOSE
& VERBOSE_API
)
788 _mesa_debug(ctx
, "glScissor %d %d %d %d\n", x
, y
, width
, height
);
790 _mesa_set_scissor(ctx
, x
, y
, width
, height
);
795 /**********************************************************************/
796 /** \name Initialization */
800 * Initialize the context's scissor state.
801 * \param ctx the GL context.
804 _mesa_init_scissor(GLcontext
*ctx
)
807 ctx
->Scissor
.Enabled
= GL_FALSE
;
810 ctx
->Scissor
.Width
= 0;
811 ctx
->Scissor
.Height
= 0;
816 * Initialize the context's multisample state.
817 * \param ctx the GL context.
820 _mesa_init_multisample(GLcontext
*ctx
)
822 ctx
->Multisample
.Enabled
= GL_FALSE
;
823 ctx
->Multisample
.SampleAlphaToCoverage
= GL_FALSE
;
824 ctx
->Multisample
.SampleAlphaToOne
= GL_FALSE
;
825 ctx
->Multisample
.SampleCoverage
= GL_FALSE
;
826 ctx
->Multisample
.SampleCoverageValue
= 1.0;
827 ctx
->Multisample
.SampleCoverageInvert
= GL_FALSE
;