Skip to content

Commit ed41a54

Browse files
committed
refactor(WebGL): remove support for WebGL1
1 parent 3aff1e3 commit ed41a54

27 files changed

Lines changed: 813 additions & 1378 deletions

File tree

Sources/Rendering/OpenGL/CellArrayBufferObject/index.js

Lines changed: 287 additions & 109 deletions
Large diffs are not rendered by default.

Sources/Rendering/OpenGL/Convolution2DPass/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,9 @@ function vtkConvolution2DPass(publicAPI, model) {
253253
points,
254254
tcoords,
255255
cellOffset: 0,
256+
// This pass draws with gl.drawArrays, so it needs the flattened
257+
// (non indexed) vertex layout where elementCount matches the vertices.
258+
forceFlatten: true,
256259
});
257260

258261
model.VBOBuildTime.modified();

Sources/Rendering/OpenGL/Framebuffer/index.js

Lines changed: 20 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function vtkFramebuffer(publicAPI, model) {
3838
};
3939

4040
publicAPI.saveCurrentBuffers = (modeIn) => {
41-
// noop on webgl 1
41+
// noop on webgl
4242
};
4343

4444
publicAPI.restorePreviousBindingsAndBuffers = (modeIn) => {
@@ -64,7 +64,7 @@ function vtkFramebuffer(publicAPI, model) {
6464
};
6565

6666
publicAPI.restorePreviousBuffers = (modeIn) => {
67-
// currently a noop on webgl1
67+
// currently a noop
6868
};
6969

7070
publicAPI.bind = (modeArg = null) => {
@@ -104,14 +104,7 @@ function vtkFramebuffer(publicAPI, model) {
104104

105105
let glAttachment = gl.COLOR_ATTACHMENT0;
106106
if (attachment > 0) {
107-
if (model._openGLRenderWindow.getWebgl2()) {
108-
glAttachment += attachment;
109-
} else {
110-
macro.vtkErrorMacro(
111-
'Using multiple framebuffer attachments requires WebGL 2'
112-
);
113-
return;
114-
}
107+
glAttachment += attachment;
115108
}
116109
model.colorBuffers[attachment] = texture;
117110
gl.framebufferTexture2D(
@@ -135,14 +128,7 @@ function vtkFramebuffer(publicAPI, model) {
135128

136129
let glAttachment = gl.COLOR_ATTACHMENT0;
137130
if (attachment > 0) {
138-
if (model._openGLRenderWindow.getWebgl2()) {
139-
glAttachment += attachment;
140-
} else {
141-
macro.vtkErrorMacro(
142-
'Using multiple framebuffer attachments requires WebGL 2'
143-
);
144-
return;
145-
}
131+
glAttachment += attachment;
146132
}
147133

148134
gl.framebufferTexture2D(
@@ -164,20 +150,14 @@ function vtkFramebuffer(publicAPI, model) {
164150
return;
165151
}
166152

167-
if (model._openGLRenderWindow.getWebgl2()) {
168-
const gl = model.context;
169-
gl.framebufferTexture2D(
170-
gl.FRAMEBUFFER,
171-
gl.DEPTH_ATTACHMENT,
172-
gl.TEXTURE_2D,
173-
texture.getHandle(),
174-
0
175-
);
176-
} else {
177-
macro.vtkErrorMacro(
178-
'Attaching depth buffer textures to fbo requires WebGL 2'
179-
);
180-
}
153+
const gl = model.context;
154+
gl.framebufferTexture2D(
155+
gl.FRAMEBUFFER,
156+
gl.DEPTH_ATTACHMENT,
157+
gl.TEXTURE_2D,
158+
texture.getHandle(),
159+
0
160+
);
181161
};
182162

183163
publicAPI.removeDepthBuffer = () => {
@@ -188,20 +168,14 @@ function vtkFramebuffer(publicAPI, model) {
188168
return;
189169
}
190170

191-
if (model._openGLRenderWindow.getWebgl2()) {
192-
const gl = model.context;
193-
gl.framebufferTexture2D(
194-
gl.FRAMEBUFFER,
195-
gl.DEPTH_ATTACHMENT,
196-
gl.TEXTURE_2D,
197-
null,
198-
0
199-
);
200-
} else {
201-
macro.vtkErrorMacro(
202-
'Attaching depth buffer textures to framebuffers requires WebGL 2'
203-
);
204-
}
171+
const gl = model.context;
172+
gl.framebufferTexture2D(
173+
gl.FRAMEBUFFER,
174+
gl.DEPTH_ATTACHMENT,
175+
gl.TEXTURE_2D,
176+
null,
177+
0
178+
);
205179
};
206180

207181
publicAPI.getGLFramebuffer = () => model.glFramebuffer;

0 commit comments

Comments
 (0)