【问题标题】:How do I set the attributes of a WebGL context after it has been created?创建 WebGL 上下文后如何设置其属性?
【发布时间】:2019-12-04 18:41:59
【问题描述】:

我知道我们可以在创建上下文时为 WebGL 上下文指定属性:

var ctx = myCanvas.getContext(‘webgl’, attributes);

在创建 ctx 之后,我们可以调用一个方法来设置 ctx 的属性吗?例如,我们可以做一些类似于

var ctx = myCanvas.getContext(‘webgl’);
ctx.setAttributes(attributes);

【问题讨论】:

    标签: webgl


    【解决方案1】:

    这需要能够更改上下文的属性。你不允许这样做。它们在上下文创建时固定。

    【讨论】:

    • 为什么要固定在创作上? D:
    • 谢谢,那很好。我至少有办法获取上下文的现有 WebGLContextAttributes 吗?例如,我能否判断现有上下文是否已将 preserveDrawingBuffer 设置为 true?
    • @JohnHoffman:这是一个完全不同的问题,答案也完全不同。但是不要把它当作一个新问题来问,因为it's right there in the spec
    【解决方案2】:

    这里是:context.getContextAttributes()

    【讨论】:

      猜你喜欢
      • 2013-03-25
      • 2018-05-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-21
      • 2016-02-07
      • 2018-10-16
      • 1970-01-01
      相关资源
      最近更新 更多