1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "WebGL2Context.h"
10 #include "WebGLBuffer.h"
11 #include "WebGLContextUtils.h"
12 #include "WebGLFramebuffer.h"
13 #include "WebGLSampler.h"
14 #include "WebGLTransformFeedback.h"
15 #include "WebGLVertexArray.h"
19 Maybe
<double> WebGL2Context::GetParameter(GLenum pname
) {
20 const FuncScope
funcScope(*this, "getParameter");
21 // The following cases are handled in WebGLContext::GetParameter():
22 // case LOCAL_GL_MAX_COLOR_ATTACHMENTS:
23 // case LOCAL_GL_MAX_DRAW_BUFFERS:
24 // case LOCAL_GL_DRAW_BUFFERi:
26 if (IsContextLost()) return Nothing();
30 case LOCAL_GL_RASTERIZER_DISCARD
:
31 case LOCAL_GL_SAMPLE_ALPHA_TO_COVERAGE
:
32 case LOCAL_GL_SAMPLE_COVERAGE
: {
34 gl
->fGetBooleanv(pname
, &b
);
38 case LOCAL_GL_TRANSFORM_FEEDBACK_ACTIVE
:
39 return Some(mBoundTransformFeedback
->mIsActive
);
40 case LOCAL_GL_TRANSFORM_FEEDBACK_PAUSED
:
41 return Some(mBoundTransformFeedback
->mIsPaused
);
44 case LOCAL_GL_READ_BUFFER
: {
45 if (!mBoundReadFramebuffer
) return Some(mDefaultFB_ReadBuffer
);
47 if (!mBoundReadFramebuffer
->ColorReadBuffer()) return Some(LOCAL_GL_NONE
);
49 return Some(mBoundReadFramebuffer
->ColorReadBuffer()->mAttachmentPoint
);
52 case LOCAL_GL_FRAGMENT_SHADER_DERIVATIVE_HINT
:
56 case LOCAL_GL_MAX_COMBINED_UNIFORM_BLOCKS
:
57 case LOCAL_GL_MAX_ELEMENTS_INDICES
:
58 case LOCAL_GL_MAX_ELEMENTS_VERTICES
:
59 case LOCAL_GL_MAX_FRAGMENT_INPUT_COMPONENTS
:
60 case LOCAL_GL_MAX_FRAGMENT_UNIFORM_BLOCKS
:
61 case LOCAL_GL_MAX_FRAGMENT_UNIFORM_COMPONENTS
:
62 case LOCAL_GL_MAX_PROGRAM_TEXEL_OFFSET
:
63 case LOCAL_GL_MAX_SAMPLES
:
64 case LOCAL_GL_MAX_TEXTURE_LOD_BIAS
:
65 case LOCAL_GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS
:
66 case LOCAL_GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS
:
67 case LOCAL_GL_MAX_VERTEX_OUTPUT_COMPONENTS
:
68 case LOCAL_GL_MAX_VERTEX_UNIFORM_BLOCKS
:
69 case LOCAL_GL_MAX_VERTEX_UNIFORM_COMPONENTS
:
70 case LOCAL_GL_MIN_PROGRAM_TEXEL_OFFSET
: {
72 gl
->fGetIntegerv(pname
, &val
);
76 case LOCAL_GL_MAX_VARYING_COMPONENTS
: {
77 // On OS X Core Profile this is buggy. The spec says that the
78 // value is 4 * GL_MAX_VARYING_VECTORS
80 gl
->fGetIntegerv(LOCAL_GL_MAX_VARYING_VECTORS
, &val
);
84 case LOCAL_GL_MAX_ELEMENT_INDEX
:
85 // GL_MAX_ELEMENT_INDEX becomes available in GL 4.3 or via ES3
87 if (!gl
->IsSupported(gl::GLFeature::ES3_compatibility
))
88 return Some(UINT32_MAX
);
90 /*** fall through to fGetInteger64v ***/
93 case LOCAL_GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS
:
94 case LOCAL_GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS
:
95 case LOCAL_GL_MAX_UNIFORM_BLOCK_SIZE
: {
97 gl
->fGetInteger64v(pname
, &val
);
98 return Some(static_cast<double>(val
));
102 case LOCAL_GL_MAX_SERVER_WAIT_TIMEOUT
: {
104 gl
->fGetInteger64v(pname
, (GLint64
*)&val
);
105 return Some(static_cast<double>(val
));
109 return WebGLContext::GetParameter(pname
);
113 } // namespace mozilla