Skip to content

Commit bc47659

Browse files
Refactor WebGL context to provide a read-only accessor for client state
1 parent a0c62e9 commit bc47659

File tree

2 files changed

+9
-25
lines changed

2 files changed

+9
-25
lines changed

fixtures/html/webgl-conformance/getparameter-binding-test.html

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,26 +41,9 @@ <h1>WebGL getParameter Binding Test</h1>
4141
}
4242
}
4343

44-
// Create WebGL1 context
45-
const canvas1 = document.createElement('canvas');
46-
const gl1 = canvas1.getContext('webgl');
47-
48-
if (gl1) {
49-
results.innerHTML += '<h2>WebGL 1.0 Binding Parameters</h2>';
50-
testParameter(gl1, 'ARRAY_BUFFER_BINDING', gl1.ARRAY_BUFFER_BINDING);
51-
testParameter(gl1, 'ELEMENT_ARRAY_BUFFER_BINDING', gl1.ELEMENT_ARRAY_BUFFER_BINDING);
52-
testParameter(gl1, 'FRAMEBUFFER_BINDING', gl1.FRAMEBUFFER_BINDING);
53-
testParameter(gl1, 'RENDERBUFFER_BINDING', gl1.RENDERBUFFER_BINDING);
54-
testParameter(gl1, 'TEXTURE_BINDING_2D', gl1.TEXTURE_BINDING_2D);
55-
testParameter(gl1, 'TEXTURE_BINDING_CUBE_MAP', gl1.TEXTURE_BINDING_CUBE_MAP);
56-
testParameter(gl1, 'CURRENT_PROGRAM', gl1.CURRENT_PROGRAM);
57-
} else {
58-
log('WebGL 1.0 not supported', false);
59-
}
60-
6144
// Create WebGL2 context
6245
const canvas2 = document.createElement('canvas');
63-
const gl2 = canvas2.getContext('webgl2');
46+
const gl2 = navigator.gl || canvas2.getContext('webgl2');
6447

6548
if (gl2) {
6649
results.innerHTML += '<h2>WebGL 2.0 Binding Parameters</h2>';

src/client/graphics/webgl_context.hpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -725,13 +725,6 @@ namespace endor
725725
}
726726

727727
private:
728-
/**
729-
* @returns the client state of the WebGL context.
730-
*/
731-
WebGLState &clientState()
732-
{
733-
return clientState_;
734-
}
735728
/**
736729
* an XR-compatible WebGL context could be configured as an `XRWebGLLayer` object and be connected to a specific WebXR
737730
* session. At the same time, each WebXR session could own 1 base layer, thus the XR-compatible WebGL context to a WebXR
@@ -771,6 +764,14 @@ namespace endor
771764
std::string renderer;
772765
// The default handedness of the coordinate system to use.
773766
commandbuffers::MatrixHandedness defaultCoordHandedness = commandbuffers::MatrixHandedness::MATRIX_RIGHT_HANDED;
767+
/**
768+
* @returns the client state of the WebGL context.
769+
*/
770+
// Read-only accessor
771+
const WebGLState &clientState() const
772+
{
773+
return clientState_;
774+
}
774775

775776
protected:
776777
TrClientContextPerProcess *clientContext_;

0 commit comments

Comments
 (0)