multisample.c revision c1f859d4
1c1f859d4Smrg/*
2c1f859d4Smrg * Mesa 3-D graphics library
3c1f859d4Smrg * Version:  7.1
4c1f859d4Smrg *
5c1f859d4Smrg * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
6c1f859d4Smrg *
7c1f859d4Smrg * Permission is hereby granted, free of charge, to any person obtaining a
8c1f859d4Smrg * copy of this software and associated documentation files (the "Software"),
9c1f859d4Smrg * to deal in the Software without restriction, including without limitation
10c1f859d4Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11c1f859d4Smrg * and/or sell copies of the Software, and to permit persons to whom the
12c1f859d4Smrg * Software is furnished to do so, subject to the following conditions:
13c1f859d4Smrg *
14c1f859d4Smrg * The above copyright notice and this permission notice shall be included
15c1f859d4Smrg * in all copies or substantial portions of the Software.
16c1f859d4Smrg *
17c1f859d4Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18c1f859d4Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19c1f859d4Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20c1f859d4Smrg * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21c1f859d4Smrg * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22c1f859d4Smrg * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23c1f859d4Smrg */
24c1f859d4Smrg
25c1f859d4Smrg
26c1f859d4Smrg#include "main/glheader.h"
27c1f859d4Smrg#include "main/context.h"
28c1f859d4Smrg#include "main/macros.h"
29c1f859d4Smrg#include "main/multisample.h"
30c1f859d4Smrg
31c1f859d4Smrg
32c1f859d4Smrg/**
33c1f859d4Smrg * Called via glSampleCoverageARB
34c1f859d4Smrg */
35c1f859d4Smrgvoid GLAPIENTRY
36c1f859d4Smrg_mesa_SampleCoverageARB(GLclampf value, GLboolean invert)
37c1f859d4Smrg{
38c1f859d4Smrg   GET_CURRENT_CONTEXT(ctx);
39c1f859d4Smrg
40c1f859d4Smrg   if (!ctx->Extensions.ARB_multisample) {
41c1f859d4Smrg      _mesa_error(ctx, GL_INVALID_OPERATION, "glSampleCoverageARB");
42c1f859d4Smrg      return;
43c1f859d4Smrg   }
44c1f859d4Smrg
45c1f859d4Smrg   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx );
46c1f859d4Smrg
47c1f859d4Smrg   ctx->Multisample.SampleCoverageValue = (GLfloat) CLAMP(value, 0.0, 1.0);
48c1f859d4Smrg   ctx->Multisample.SampleCoverageInvert = invert;
49c1f859d4Smrg   ctx->NewState |= _NEW_MULTISAMPLE;
50c1f859d4Smrg}
51c1f859d4Smrg
52c1f859d4Smrg
53c1f859d4Smrg/**
54c1f859d4Smrg * Initialize the context's multisample state.
55c1f859d4Smrg * \param ctx  the GL context.
56c1f859d4Smrg */
57c1f859d4Smrgvoid
58c1f859d4Smrg_mesa_init_multisample(GLcontext *ctx)
59c1f859d4Smrg{
60c1f859d4Smrg   ctx->Multisample.Enabled = GL_TRUE;
61c1f859d4Smrg   ctx->Multisample.SampleAlphaToCoverage = GL_FALSE;
62c1f859d4Smrg   ctx->Multisample.SampleAlphaToOne = GL_FALSE;
63c1f859d4Smrg   ctx->Multisample.SampleCoverage = GL_FALSE;
64c1f859d4Smrg   ctx->Multisample.SampleCoverageValue = 1.0;
65c1f859d4Smrg   ctx->Multisample.SampleCoverageInvert = GL_FALSE;
66c1f859d4Smrg}
67