0

I know that we can specify attributes for a WebGL context when we create the context:

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

Is there a method that we can call to set the attributes of ctx after ctx has been created? For instance, can we do something akin to

var ctx = myCanvas.getContext(‘webgl’);
ctx.setAttributes(attributes);
John Hoffman
  • 17,857
  • 20
  • 58
  • 81

2 Answers2

2

That would require being able to change the attributes of a context. Which you're not allowed to do. They're fixed at context creation time.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
  • Why fixed upon creation? D: – John Hoffman Jun 17 '13 at 18:05
  • 2
    Thanks, that's fine then. Is there at least a way for me to obtain the existing WebGLContextAttributes of a context? For instance, can I tell if an existing context has set `preserveDrawingBuffer` to true? – John Hoffman Jun 17 '13 at 18:10
  • 1
    @JohnHoffman: That's a completely different question with a completely different answer. But don't ask it as a new question, since [it's right there in the spec](http://www.khronos.org/registry/webgl/specs/latest/#5.14.2). – Nicol Bolas Jun 17 '13 at 18:34
0

here it is:context.getContextAttributes()