1 | import { MSAA_QUALITY } from "@pixi/constants";
|
2 | import { ExtensionType, extensions } from "@pixi/extensions";
|
3 | class MultisampleSystem {
|
4 | constructor(renderer) {
|
5 | this.renderer = renderer;
|
6 | }
|
7 | contextChange(gl) {
|
8 | let samples;
|
9 | if (this.renderer.context.webGLVersion === 1) {
|
10 | const framebuffer = gl.getParameter(gl.FRAMEBUFFER_BINDING);
|
11 | gl.bindFramebuffer(gl.FRAMEBUFFER, null), samples = gl.getParameter(gl.SAMPLES), gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
|
12 | } else {
|
13 | const framebuffer = gl.getParameter(gl.DRAW_FRAMEBUFFER_BINDING);
|
14 | gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, null), samples = gl.getParameter(gl.SAMPLES), gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, framebuffer);
|
15 | }
|
16 | samples >= MSAA_QUALITY.HIGH ? this.multisample = MSAA_QUALITY.HIGH : samples >= MSAA_QUALITY.MEDIUM ? this.multisample = MSAA_QUALITY.MEDIUM : samples >= MSAA_QUALITY.LOW ? this.multisample = MSAA_QUALITY.LOW : this.multisample = MSAA_QUALITY.NONE;
|
17 | }
|
18 | destroy() {
|
19 | }
|
20 | }
|
21 | MultisampleSystem.extension = {
|
22 | type: ExtensionType.RendererSystem,
|
23 | name: "_multisample"
|
24 | };
|
25 | extensions.add(MultisampleSystem);
|
26 | export {
|
27 | MultisampleSystem
|
28 | };
|
29 |
|