1 /* 2 * Copyright 2010 Google Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 * use this file except in compliance with the License. You may obtain a copy of 6 * the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 * License for the specific language governing permissions and limitations under 14 * the License. 15 */ 16 17 package com.google.gwt.webgl.client; 18 19 import com.google.gwt.canvas.dom.client.ImageData; 20 import com.google.gwt.core.client.JavaScriptObject; 21 import com.google.gwt.core.client.JsArray; 22 import com.google.gwt.core.client.JsArrayString; 23 import com.google.gwt.dom.client.CanvasElement; 24 import com.google.gwt.dom.client.ImageElement; 25 import com.google.gwt.dom.client.VideoElement; 26 import com.google.gwt.typedarrays.shared.ArrayBuffer; 27 import com.google.gwt.typedarrays.shared.ArrayBufferView; 28 import com.google.gwt.typedarrays.shared.Float32Array; 29 import com.google.gwt.typedarrays.shared.Int32Array; 30 import com.google.gwt.typedarrays.shared.TypedArrays; 31 32 /** TODO: Lots more documentation needed here. 33 * 34 * Taken from the WebGL Draft Spec as of Aug 30, 2010: 35 * https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/doc/spec/WebGL-spec.html TODO: Update this to the Feb 11 version. */ 36 public class WebGLRenderingContext extends JavaScriptObject { 37 38 /* ClearBufferMask */ 39 public static final int DEPTH_BUFFER_BIT = 0x00000100; 40 public static final int STENCIL_BUFFER_BIT = 0x00000400; 41 public static final int COLOR_BUFFER_BIT = 0x00004000; 42 43 /* BeginMode */ 44 public static final int POINTS = 0x0000; 45 public static final int LINES = 0x0001; 46 public static final int LINE_LOOP = 0x0002; 47 public static final int LINE_STRIP = 0x0003; 48 public static final int TRIANGLES = 0x0004; 49 public static final int TRIANGLE_STRIP = 0x0005; 50 public static final int TRIANGLE_FAN = 0x0006; 51 52 /* AlphaFunction (not supported in ES20) */ 53 /* NEVER */ 54 /* LESS */ 55 /* EQUAL */ 56 /* LEQUAL */ 57 /* GREATER */ 58 /* NOTEQUAL */ 59 /* GEQUAL */ 60 /* ALWAYS */ 61 62 /* BlendingFactorDest */ 63 public static final int ZERO = 0; 64 public static final int ONE = 1; 65 public static final int SRC_COLOR = 0x0300; 66 public static final int ONE_MINUS_SRC_COLOR = 0x0301; 67 public static final int SRC_ALPHA = 0x0302; 68 public static final int ONE_MINUS_SRC_ALPHA = 0x0303; 69 public static final int DST_ALPHA = 0x0304; 70 public static final int ONE_MINUS_DST_ALPHA = 0x0305; 71 72 /* BlendingFactorSrc */ 73 /* ZERO */ 74 /* ONE */ 75 public static final int DST_COLOR = 0x0306; 76 public static final int ONE_MINUS_DST_COLOR = 0x0307; 77 public static final int SRC_ALPHA_SATURATE = 0x0308; 78 /* SRC_ALPHA */ 79 /* ONE_MINUS_SRC_ALPHA */ 80 /* DST_ALPHA */ 81 /* ONE_MINUS_DST_ALPHA */ 82 83 /* BlendEquationSeparate */ 84 public static final int FUNC_ADD = 0x8006; 85 public static final int BLEND_EQUATION = 0x8009; 86 public static final int BLEND_EQUATION_RGB = 0x8009; /* same as BLEND_EQUATION */ 87 public static final int BLEND_EQUATION_ALPHA = 0x883D; 88 89 /* BlendSubtract */ 90 public static final int FUNC_SUBTRACT = 0x800A; 91 public static final int FUNC_REVERSE_SUBTRACT = 0x800B; 92 93 /* Separate Blend Functions */ 94 public static final int BLEND_DST_RGB = 0x80C8; 95 public static final int BLEND_SRC_RGB = 0x80C9; 96 public static final int BLEND_DST_ALPHA = 0x80CA; 97 public static final int BLEND_SRC_ALPHA = 0x80CB; 98 public static final int CONSTANT_COLOR = 0x8001; 99 public static final int ONE_MINUS_CONSTANT_COLOR = 0x8002; 100 public static final int CONSTANT_ALPHA = 0x8003; 101 public static final int ONE_MINUS_CONSTANT_ALPHA = 0x8004; 102 public static final int BLEND_COLOR = 0x8005; 103 104 /* Buffer Objects */ 105 public static final int ARRAY_BUFFER = 0x8892; 106 public static final int ELEMENT_ARRAY_BUFFER = 0x8893; 107 public static final int ARRAY_BUFFER_BINDING = 0x8894; 108 public static final int ELEMENT_ARRAY_BUFFER_BINDING = 0x8895; 109 110 public static final int STREAM_DRAW = 0x88E0; 111 public static final int STATIC_DRAW = 0x88E4; 112 public static final int DYNAMIC_DRAW = 0x88E8; 113 114 public static final int BUFFER_SIZE = 0x8764; 115 public static final int BUFFER_USAGE = 0x8765; 116 117 public static final int CURRENT_VERTEX_ATTRIB = 0x8626; 118 119 /* CullFaceMode */ 120 public static final int FRONT = 0x0404; 121 public static final int BACK = 0x0405; 122 public static final int FRONT_AND_BACK = 0x0408; 123 124 /* DepthFunction */ 125 /* NEVER */ 126 /* LESS */ 127 /* EQUAL */ 128 /* LEQUAL */ 129 /* GREATER */ 130 /* NOTEQUAL */ 131 /* GEQUAL */ 132 /* ALWAYS */ 133 134 /* EnableCap */ 135 public static final int TEXTURE_2D = 0x0DE1; 136 public static final int CULL_FACE = 0x0B44; 137 public static final int BLEND = 0x0BE2; 138 public static final int DITHER = 0x0BD0; 139 public static final int STENCIL_TEST = 0x0B90; 140 public static final int DEPTH_TEST = 0x0B71; 141 public static final int SCISSOR_TEST = 0x0C11; 142 public static final int POLYGON_OFFSET_FILL = 0x8037; 143 public static final int SAMPLE_ALPHA_TO_COVERAGE = 0x809E; 144 public static final int SAMPLE_COVERAGE = 0x80A0; 145 146 /* ErrorCode */ 147 public static final int NO_ERROR = 0; 148 public static final int INVALID_ENUM = 0x0500; 149 public static final int INVALID_VALUE = 0x0501; 150 public static final int INVALID_OPERATION = 0x0502; 151 public static final int OUT_OF_MEMORY = 0x0505; 152 153 /* FrontFaceDirection */ 154 public static final int CW = 0x0900; 155 public static final int CCW = 0x0901; 156 157 /* GetPName */ 158 public static final int LINE_WIDTH = 0x0B21; 159 public static final int ALIASED_POINT_SIZE_RANGE = 0x846D; 160 public static final int ALIASED_LINE_WIDTH_RANGE = 0x846E; 161 public static final int CULL_FACE_MODE = 0x0B45; 162 public static final int FRONT_FACE = 0x0B46; 163 public static final int DEPTH_RANGE = 0x0B70; 164 public static final int DEPTH_WRITEMASK = 0x0B72; 165 public static final int DEPTH_CLEAR_VALUE = 0x0B73; 166 public static final int DEPTH_FUNC = 0x0B74; 167 public static final int STENCIL_CLEAR_VALUE = 0x0B91; 168 public static final int STENCIL_FUNC = 0x0B92; 169 public static final int STENCIL_FAIL = 0x0B94; 170 public static final int STENCIL_PASS_DEPTH_FAIL = 0x0B95; 171 public static final int STENCIL_PASS_DEPTH_PASS = 0x0B96; 172 public static final int STENCIL_REF = 0x0B97; 173 public static final int STENCIL_VALUE_MASK = 0x0B93; 174 public static final int STENCIL_WRITEMASK = 0x0B98; 175 public static final int STENCIL_BACK_FUNC = 0x8800; 176 public static final int STENCIL_BACK_FAIL = 0x8801; 177 public static final int STENCIL_BACK_PASS_DEPTH_FAIL = 0x8802; 178 public static final int STENCIL_BACK_PASS_DEPTH_PASS = 0x8803; 179 public static final int STENCIL_BACK_REF = 0x8CA3; 180 public static final int STENCIL_BACK_VALUE_MASK = 0x8CA4; 181 public static final int STENCIL_BACK_WRITEMASK = 0x8CA5; 182 public static final int VIEWPORT = 0x0BA2; 183 public static final int SCISSOR_BOX = 0x0C10; 184 /* SCISSOR_TEST */ 185 public static final int COLOR_CLEAR_VALUE = 0x0C22; 186 public static final int COLOR_WRITEMASK = 0x0C23; 187 public static final int UNPACK_ALIGNMENT = 0x0CF5; 188 public static final int PACK_ALIGNMENT = 0x0D05; 189 public static final int MAX_TEXTURE_SIZE = 0x0D33; 190 public static final int MAX_VIEWPORT_DIMS = 0x0D3A; 191 public static final int SUBPIXEL_BITS = 0x0D50; 192 public static final int RED_BITS = 0x0D52; 193 public static final int GREEN_BITS = 0x0D53; 194 public static final int BLUE_BITS = 0x0D54; 195 public static final int ALPHA_BITS = 0x0D55; 196 public static final int DEPTH_BITS = 0x0D56; 197 public static final int STENCIL_BITS = 0x0D57; 198 public static final int POLYGON_OFFSET_UNITS = 0x2A00; 199 /* POLYGON_OFFSET_FILL */ 200 public static final int POLYGON_OFFSET_FACTOR = 0x8038; 201 public static final int TEXTURE_BINDING_2D = 0x8069; 202 public static final int SAMPLE_BUFFERS = 0x80A8; 203 public static final int SAMPLES = 0x80A9; 204 public static final int SAMPLE_COVERAGE_VALUE = 0x80AA; 205 public static final int SAMPLE_COVERAGE_INVERT = 0x80AB; 206 207 /* GetTextureParameter */ 208 /* TEXTURE_MAG_FILTER */ 209 /* TEXTURE_MIN_FILTER */ 210 /* TEXTURE_WRAP_S */ 211 /* TEXTURE_WRAP_T */ 212 213 public static final int NUM_COMPRESSED_TEXTURE_FORMATS = 0x86A2; 214 public static final int COMPRESSED_TEXTURE_FORMATS = 0x86A3; 215 216 /* HintMode */ 217 public static final int DONT_CARE = 0x1100; 218 public static final int FASTEST = 0x1101; 219 public static final int NICEST = 0x1102; 220 221 /* HintTarget */ 222 public static final int GENERATE_MIPMAP_HINT = 0x8192; 223 224 /* DataType */ 225 public static final int BYTE = 0x1400; 226 public static final int UNSIGNED_BYTE = 0x1401; 227 public static final int SHORT = 0x1402; 228 public static final int UNSIGNED_SHORT = 0x1403; 229 public static final int INT = 0x1404; 230 public static final int UNSIGNED_INT = 0x1405; 231 public static final int FLOAT = 0x1406; 232 233 /* PixelFormat */ 234 public static final int DEPTH_COMPONENT = 0x1902; 235 public static final int ALPHA = 0x1906; 236 public static final int RGB = 0x1907; 237 public static final int RGBA = 0x1908; 238 public static final int LUMINANCE = 0x1909; 239 public static final int LUMINANCE_ALPHA = 0x190A; 240 241 /* PixelType */ 242 /* UNSIGNED_BYTE */ 243 public static final int UNSIGNED_SHORT_4_4_4_4 = 0x8033; 244 public static final int UNSIGNED_SHORT_5_5_5_1 = 0x8034; 245 public static final int UNSIGNED_SHORT_5_6_5 = 0x8363; 246 247 /* Shaders */ 248 public static final int FRAGMENT_SHADER = 0x8B30; 249 public static final int VERTEX_SHADER = 0x8B31; 250 public static final int MAX_VERTEX_ATTRIBS = 0x8869; 251 public static final int MAX_VERTEX_UNIFORM_VECTORS = 0x8DFB; 252 public static final int MAX_VARYING_VECTORS = 0x8DFC; 253 public static final int MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8B4D; 254 public static final int MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8B4C; 255 public static final int MAX_TEXTURE_IMAGE_UNITS = 0x8872; 256 public static final int MAX_FRAGMENT_UNIFORM_VECTORS = 0x8DFD; 257 public static final int SHADER_TYPE = 0x8B4F; 258 public static final int DELETE_STATUS = 0x8B80; 259 public static final int LINK_STATUS = 0x8B82; 260 public static final int VALIDATE_STATUS = 0x8B83; 261 public static final int ATTACHED_SHADERS = 0x8B85; 262 public static final int ACTIVE_UNIFORMS = 0x8B86; 263 public static final int ACTIVE_UNIFORM_MAX_LENGTH = 0x8B87; 264 public static final int ACTIVE_ATTRIBUTES = 0x8B89; 265 public static final int ACTIVE_ATTRIBUTE_MAX_LENGTH = 0x8B8A; 266 public static final int SHADING_LANGUAGE_VERSION = 0x8B8C; 267 public static final int CURRENT_PROGRAM = 0x8B8D; 268 269 /* StencilFunction */ 270 public static final int NEVER = 0x0200; 271 public static final int LESS = 0x0201; 272 public static final int EQUAL = 0x0202; 273 public static final int LEQUAL = 0x0203; 274 public static final int GREATER = 0x0204; 275 public static final int NOTEQUAL = 0x0205; 276 public static final int GEQUAL = 0x0206; 277 public static final int ALWAYS = 0x0207; 278 279 /* StencilOp */ 280 /* ZERO */ 281 public static final int KEEP = 0x1E00; 282 public static final int REPLACE = 0x1E01; 283 public static final int INCR = 0x1E02; 284 public static final int DECR = 0x1E03; 285 public static final int INVERT = 0x150A; 286 public static final int INCR_WRAP = 0x8507; 287 public static final int DECR_WRAP = 0x8508; 288 289 /* StringName */ 290 public static final int VENDOR = 0x1F00; 291 public static final int RENDERER = 0x1F01; 292 public static final int VERSION = 0x1F02; 293 294 /* TextureMagFilter */ 295 public static final int NEAREST = 0x2600; 296 public static final int LINEAR = 0x2601; 297 298 /* TextureMinFilter */ 299 /* NEAREST */ 300 /* LINEAR */ 301 public static final int NEAREST_MIPMAP_NEAREST = 0x2700; 302 public static final int LINEAR_MIPMAP_NEAREST = 0x2701; 303 public static final int NEAREST_MIPMAP_LINEAR = 0x2702; 304 public static final int LINEAR_MIPMAP_LINEAR = 0x2703; 305 306 /* TextureParameterName */ 307 public static final int TEXTURE_MAG_FILTER = 0x2800; 308 public static final int TEXTURE_MIN_FILTER = 0x2801; 309 public static final int TEXTURE_WRAP_S = 0x2802; 310 public static final int TEXTURE_WRAP_T = 0x2803; 311 312 /* TextureTarget */ 313 /* TEXTURE_2D */ 314 public static final int TEXTURE = 0x1702; 315 316 public static final int TEXTURE_CUBE_MAP = 0x8513; 317 public static final int TEXTURE_BINDING_CUBE_MAP = 0x8514; 318 public static final int TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515; 319 public static final int TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516; 320 public static final int TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517; 321 public static final int TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518; 322 public static final int TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519; 323 public static final int TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851A; 324 public static final int MAX_CUBE_MAP_TEXTURE_SIZE = 0x851C; 325 326 /* TextureUnit */ 327 public static final int TEXTURE0 = 0x84C0; 328 public static final int TEXTURE1 = 0x84C1; 329 public static final int TEXTURE2 = 0x84C2; 330 public static final int TEXTURE3 = 0x84C3; 331 public static final int TEXTURE4 = 0x84C4; 332 public static final int TEXTURE5 = 0x84C5; 333 public static final int TEXTURE6 = 0x84C6; 334 public static final int TEXTURE7 = 0x84C7; 335 public static final int TEXTURE8 = 0x84C8; 336 public static final int TEXTURE9 = 0x84C9; 337 public static final int TEXTURE10 = 0x84CA; 338 public static final int TEXTURE11 = 0x84CB; 339 public static final int TEXTURE12 = 0x84CC; 340 public static final int TEXTURE13 = 0x84CD; 341 public static final int TEXTURE14 = 0x84CE; 342 public static final int TEXTURE15 = 0x84CF; 343 public static final int TEXTURE16 = 0x84D0; 344 public static final int TEXTURE17 = 0x84D1; 345 public static final int TEXTURE18 = 0x84D2; 346 public static final int TEXTURE19 = 0x84D3; 347 public static final int TEXTURE20 = 0x84D4; 348 public static final int TEXTURE21 = 0x84D5; 349 public static final int TEXTURE22 = 0x84D6; 350 public static final int TEXTURE23 = 0x84D7; 351 public static final int TEXTURE24 = 0x84D8; 352 public static final int TEXTURE25 = 0x84D9; 353 public static final int TEXTURE26 = 0x84DA; 354 public static final int TEXTURE27 = 0x84DB; 355 public static final int TEXTURE28 = 0x84DC; 356 public static final int TEXTURE29 = 0x84DD; 357 public static final int TEXTURE30 = 0x84DE; 358 public static final int TEXTURE31 = 0x84DF; 359 public static final int ACTIVE_TEXTURE = 0x84E0; 360 361 /* TextureWrapMode */ 362 public static final int REPEAT = 0x2901; 363 public static final int CLAMP_TO_EDGE = 0x812F; 364 public static final int MIRRORED_REPEAT = 0x8370; 365 366 /* Uniform Types */ 367 public static final int FLOAT_VEC2 = 0x8B50; 368 public static final int FLOAT_VEC3 = 0x8B51; 369 public static final int FLOAT_VEC4 = 0x8B52; 370 public static final int INT_VEC2 = 0x8B53; 371 public static final int INT_VEC3 = 0x8B54; 372 public static final int INT_VEC4 = 0x8B55; 373 public static final int BOOL = 0x8B56; 374 public static final int BOOL_VEC2 = 0x8B57; 375 public static final int BOOL_VEC3 = 0x8B58; 376 public static final int BOOL_VEC4 = 0x8B59; 377 public static final int FLOAT_MAT2 = 0x8B5A; 378 public static final int FLOAT_MAT3 = 0x8B5B; 379 public static final int FLOAT_MAT4 = 0x8B5C; 380 public static final int SAMPLER_2D = 0x8B5E; 381 public static final int SAMPLER_CUBE = 0x8B60; 382 383 /* Vertex Arrays */ 384 public static final int VERTEX_ATTRIB_ARRAY_ENABLED = 0x8622; 385 public static final int VERTEX_ATTRIB_ARRAY_SIZE = 0x8623; 386 public static final int VERTEX_ATTRIB_ARRAY_STRIDE = 0x8624; 387 public static final int VERTEX_ATTRIB_ARRAY_TYPE = 0x8625; 388 public static final int VERTEX_ATTRIB_ARRAY_NORMALIZED = 0x886A; 389 public static final int VERTEX_ATTRIB_ARRAY_POINTER = 0x8645; 390 public static final int VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 0x889F; 391 392 /* Read Format */ 393 public static final int IMPLEMENTATION_COLOR_READ_TYPE = 0x8B9A; 394 public static final int IMPLEMENTATION_COLOR_READ_FORMAT = 0x8B9B; 395 396 /* Shader Source */ 397 public static final int COMPILE_STATUS = 0x8B81; 398 public static final int INFO_LOG_LENGTH = 0x8B84; 399 public static final int SHADER_SOURCE_LENGTH = 0x8B88; 400 401 /* Shader Precision-Specified Types */ 402 public static final int LOW_FLOAT = 0x8DF0; 403 public static final int MEDIUM_FLOAT = 0x8DF1; 404 public static final int HIGH_FLOAT = 0x8DF2; 405 public static final int LOW_INT = 0x8DF3; 406 public static final int MEDIUM_INT = 0x8DF4; 407 public static final int HIGH_INT = 0x8DF5; 408 409 /* Framebuffer Object. */ 410 public static final int FRAMEBUFFER = 0x8D40; 411 public static final int RENDERBUFFER = 0x8D41; 412 413 public static final int RGBA4 = 0x8056; 414 public static final int RGB5_A1 = 0x8057; 415 public static final int RGB565 = 0x8D62; 416 public static final int DEPTH_COMPONENT16 = 0x81A5; 417 public static final int STENCIL_INDEX = 0x1901; 418 public static final int STENCIL_INDEX8 = 0x8D48; 419 public static final int DEPTH_STENCIL = 0x84F9; 420 421 public static final int RENDERBUFFER_WIDTH = 0x8D42; 422 public static final int RENDERBUFFER_HEIGHT = 0x8D43; 423 public static final int RENDERBUFFER_INTERNAL_FORMAT = 0x8D44; 424 public static final int RENDERBUFFER_RED_SIZE = 0x8D50; 425 public static final int RENDERBUFFER_GREEN_SIZE = 0x8D51; 426 public static final int RENDERBUFFER_BLUE_SIZE = 0x8D52; 427 public static final int RENDERBUFFER_ALPHA_SIZE = 0x8D53; 428 public static final int RENDERBUFFER_DEPTH_SIZE = 0x8D54; 429 public static final int RENDERBUFFER_STENCIL_SIZE = 0x8D55; 430 431 public static final int FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = 0x8CD0; 432 public static final int FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = 0x8CD1; 433 public static final int FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = 0x8CD2; 434 public static final int FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8CD3; 435 436 public static final int COLOR_ATTACHMENT0 = 0x8CE0; 437 public static final int DEPTH_ATTACHMENT = 0x8D00; 438 public static final int STENCIL_ATTACHMENT = 0x8D20; 439 public static final int DEPTH_STENCIL_ATTACHMENT = 0x821A; 440 441 public static final int NONE = 0; 442 443 public static final int FRAMEBUFFER_COMPLETE = 0x8CD5; 444 public static final int FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8CD6; 445 public static final int FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7; 446 public static final int FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8CD9; 447 public static final int FRAMEBUFFER_UNSUPPORTED = 0x8CDD; 448 449 public static final int FRAMEBUFFER_BINDING = 0x8CA6; 450 public static final int RENDERBUFFER_BINDING = 0x8CA7; 451 public static final int MAX_RENDERBUFFER_SIZE = 0x84E8; 452 453 public static final int INVALID_FRAMEBUFFER_OPERATION = 0x0506; 454 455 /* WebGL-specific enums */ 456 public static final int UNPACK_FLIP_Y_WEBGL = 0x9240; 457 public static final int UNPACK_PREMULTIPLY_ALPHA_WEBGL = 0x9241; 458 public static final int CONTEXT_LOST_WEBGL = 0x9242; 459 460 /** Returns a WebGL context for the given canvas element. Returns null if no 3d context is available. */ getContext(CanvasElement canvas)461 public static WebGLRenderingContext getContext (CanvasElement canvas) { 462 return getContext(canvas, WebGLContextAttributes.create()); 463 } 464 465 /** Returns a WebGL context for the given canvas element. Returns null if no 3d context is available. */ getContext(CanvasElement canvas, WebGLContextAttributes attributes)466 public static native WebGLRenderingContext getContext (CanvasElement canvas, WebGLContextAttributes attributes) /*-{ 467 var names = [ "experimental-webgl", "webgl", "moz-webgl", 468 "webkit-webgl", "webkit-3d" ]; 469 470 for ( var i = 0; i < names.length; i++) { 471 try { 472 var ctx = canvas.getContext(names[i], attributes); 473 474 if (ctx != null) { 475 // Hook for the semi-standard WebGLDebugUtils script. 476 if ($wnd.WebGLDebugUtils) { 477 if ($wnd.console && $wnd.console.log) 478 console.log('WebGL debugging enabled'); 479 return $wnd.WebGLDebugUtils.makeDebugContext(ctx); 480 } 481 return ctx; 482 } 483 } catch (e) { 484 } 485 } 486 487 return null; 488 }-*/; 489 WebGLRenderingContext()490 protected WebGLRenderingContext () { 491 } 492 getCanvas()493 public final native CanvasElement getCanvas () /*-{ 494 return this.canvas; 495 }-*/; 496 getContextAttributes()497 public final native WebGLContextAttributes getContextAttributes () /*-{ 498 return this.getContextAttributes(); 499 }-*/; 500 isContextLost()501 public final native boolean isContextLost () /*-{ 502 return this.isContextLost(); 503 }-*/; 504 getSupportedExtensions()505 public final native JsArrayString getSupportedExtensions () /*-{ 506 return this.getSupportedExtensions(); 507 }-*/; 508 getExtension(String name)509 public final native JavaScriptObject getExtension (String name) /*-{ 510 return this.getExtension(name); 511 }-*/; 512 activeTexture(int texture)513 public final native void activeTexture (int texture) /*-{ 514 this.activeTexture(texture); 515 }-*/; 516 attachShader(WebGLProgram program, WebGLShader shader)517 public final native void attachShader (WebGLProgram program, WebGLShader shader) /*-{ 518 this.attachShader(program, shader); 519 }-*/; 520 bindAttribLocation(WebGLProgram program, int index, String name)521 public final native void bindAttribLocation (WebGLProgram program, int index, String name) /*-{ 522 this.bindAttribLocation(program, index, name); 523 }-*/; 524 bindBuffer(int target, WebGLBuffer buffer)525 public final native void bindBuffer (int target, WebGLBuffer buffer) /*-{ 526 this.bindBuffer(target, buffer); 527 }-*/; 528 bindFramebuffer(int target, WebGLFramebuffer framebuffer)529 public final native void bindFramebuffer (int target, WebGLFramebuffer framebuffer) /*-{ 530 this.bindFramebuffer(target, framebuffer); 531 }-*/; 532 bindRenderbuffer(int target, WebGLRenderbuffer renderbuffer)533 public final native void bindRenderbuffer (int target, WebGLRenderbuffer renderbuffer) /*-{ 534 this.bindRenderbuffer(target, renderbuffer); 535 }-*/; 536 bindTexture(int target, WebGLTexture texture)537 public final native void bindTexture (int target, WebGLTexture texture) /*-{ 538 this.bindTexture(target, texture); 539 }-*/; 540 blendColor(float red, float green, float blue, float alpha)541 public final native void blendColor (float red, float green, float blue, float alpha) /*-{ 542 this.blendColor(red, green, blue, alpha); 543 }-*/; 544 blendEquation(int mode)545 public final native void blendEquation (int mode) /*-{ 546 this.blendEquation(mode); 547 }-*/; 548 blendEquationSeparate(int modeRGB, int modeAlpha)549 public final native void blendEquationSeparate (int modeRGB, int modeAlpha) /*-{ 550 this.blendEquationSeparate(modeRGB, modeAlpha); 551 }-*/; 552 blendFunc(int sfactor, int dfactor)553 public final native void blendFunc (int sfactor, int dfactor) /*-{ 554 this.blendFunc(sfactor, dfactor); 555 }-*/; 556 blendFuncSeparate(int srcRGB, int dstRGB, int srcAlpha, int dstAlpha)557 public final native void blendFuncSeparate (int srcRGB, int dstRGB, int srcAlpha, int dstAlpha) /*-{ 558 this.blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); 559 }-*/; 560 bufferData(int target, int size, int usage)561 public final native void bufferData (int target, int size, int usage) /*-{ 562 this.bufferData(target, size, usage); 563 }-*/; 564 bufferData(int target, ArrayBufferView data, int usage)565 public final native void bufferData (int target, ArrayBufferView data, int usage) /*-{ 566 this.bufferData(target, data, usage); 567 }-*/; 568 bufferData(int target, ArrayBuffer data, int usage)569 public final native void bufferData (int target, ArrayBuffer data, int usage) /*-{ 570 this.bufferData(target, data, usage); 571 }-*/; 572 bufferSubData(int target, int offset, ArrayBufferView data)573 public final native void bufferSubData (int target, int offset, ArrayBufferView data) /*-{ 574 this.bufferSubData(target, offset, data); 575 }-*/; 576 bufferSubData(int target, int offset, ArrayBuffer data)577 public final native void bufferSubData (int target, int offset, ArrayBuffer data) /*-{ 578 this.bufferSubData(target, offset, data); 579 }-*/; 580 checkFramebufferStatus(int target)581 public final native int checkFramebufferStatus (int target) /*-{ 582 return this.checkFramebufferStatus(target); 583 }-*/; 584 clear(int mask)585 public final native void clear (int mask) /*-{ 586 this.clear(mask); 587 }-*/; 588 clearColor(float red, float green, float blue, float alpha)589 public final native void clearColor (float red, float green, float blue, float alpha) /*-{ 590 this.clearColor(red, green, blue, alpha); 591 }-*/; 592 clearDepth(float depth)593 public final native void clearDepth (float depth) /*-{ 594 this.clearDepth(depth); 595 }-*/; 596 clearStencil(int s)597 public final native void clearStencil (int s) /*-{ 598 this.clearStencil(s); 599 }-*/; 600 colorMask(boolean red, boolean green, boolean blue, boolean alpha)601 public final native void colorMask (boolean red, boolean green, boolean blue, boolean alpha) /*-{ 602 this.colorMask(red, green, blue, alpha); 603 }-*/; 604 compileShader(WebGLShader shader)605 public final native void compileShader (WebGLShader shader) /*-{ 606 this.compileShader(shader); 607 }-*/; 608 copyTexImage2D(int target, int level, int internalformat, int x, int y, int width, int height, int border)609 public final native void copyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, 610 int border) /*-{ 611 this.copyTexImage2D(target, level, internalformat, x, y, width, height, 612 border); 613 }-*/; 614 copyTexSubImage2D(int target, int level, int xoffset, int yoffset, int x, int y, int width, int height)615 public final native void copyTexSubImage2D (int target, int level, int xoffset, int yoffset, int x, int y, int width, 616 int height) /*-{ 617 this.copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, 618 height); 619 }-*/; 620 createBuffer()621 public final native WebGLBuffer createBuffer () /*-{ 622 return this.createBuffer(); 623 }-*/; 624 createFramebuffer()625 public final native WebGLFramebuffer createFramebuffer () /*-{ 626 return this.createFramebuffer(); 627 }-*/; 628 createProgram()629 public final native WebGLProgram createProgram () /*-{ 630 return this.createProgram(); 631 }-*/; 632 createRenderbuffer()633 public final native WebGLRenderbuffer createRenderbuffer () /*-{ 634 return this.createRenderbuffer(); 635 }-*/; 636 createShader(int type)637 public final native WebGLShader createShader (int type) /*-{ 638 return this.createShader(type); 639 }-*/; 640 createTexture()641 public final native WebGLTexture createTexture () /*-{ 642 return this.createTexture(); 643 }-*/; 644 cullFace(int mode)645 public final native void cullFace (int mode) /*-{ 646 this.cullFace(mode); 647 }-*/; 648 deleteBuffer(WebGLBuffer buffer)649 public final native void deleteBuffer (WebGLBuffer buffer) /*-{ 650 this.deleteBuffer(buffer); 651 }-*/; 652 deleteFramebuffer(WebGLFramebuffer framebuffer)653 public final native void deleteFramebuffer (WebGLFramebuffer framebuffer) /*-{ 654 this.deleteFramebuffer(framebuffer); 655 }-*/; 656 deleteProgram(WebGLProgram program)657 public final native void deleteProgram (WebGLProgram program) /*-{ 658 this.deleteProgram(program); 659 }-*/; 660 deleteRenderbuffer(WebGLRenderbuffer renderbuffer)661 public final native void deleteRenderbuffer (WebGLRenderbuffer renderbuffer) /*-{ 662 this.deleteRenderbuffer(renderbuffer); 663 }-*/; 664 deleteShader(WebGLShader shader)665 public final native void deleteShader (WebGLShader shader) /*-{ 666 this.deleteShader(shader); 667 }-*/; 668 deleteTexture(WebGLTexture texture)669 public final native void deleteTexture (WebGLTexture texture) /*-{ 670 this.deleteTexture(texture); 671 }-*/; 672 depthFunc(int func)673 public final native void depthFunc (int func) /*-{ 674 this.depthFunc(func); 675 }-*/; 676 depthMask(boolean flag)677 public final native void depthMask (boolean flag) /*-{ 678 this.depthMask(flag); 679 }-*/; 680 depthRange(float zNear, float zFar)681 public final native void depthRange (float zNear, float zFar) /*-{ 682 this.depthRange(zNear, zFar); 683 }-*/; 684 detachShader(WebGLProgram program, WebGLShader shader)685 public final native void detachShader (WebGLProgram program, WebGLShader shader) /*-{ 686 this.detachShader(program, shader); 687 }-*/; 688 disable(int cap)689 public final native void disable (int cap) /*-{ 690 this.disable(cap); 691 }-*/; 692 disableVertexAttribArray(int index)693 public final native void disableVertexAttribArray (int index) /*-{ 694 this.disableVertexAttribArray(index); 695 }-*/; 696 drawArrays(int mode, int first, int count)697 public final native void drawArrays (int mode, int first, int count) /*-{ 698 this.drawArrays(mode, first, count); 699 }-*/; 700 drawElements(int mode, int count, int type, int offset)701 public final native void drawElements (int mode, int count, int type, int offset) /*-{ 702 this.drawElements(mode, count, type, offset); 703 }-*/; 704 enable(int cap)705 public final native void enable (int cap) /*-{ 706 this.enable(cap); 707 }-*/; 708 enableVertexAttribArray(int index)709 public final native void enableVertexAttribArray (int index) /*-{ 710 this.enableVertexAttribArray(index); 711 }-*/; 712 finish()713 public final native void finish () /*-{ 714 this.finish(); 715 }-*/; 716 flush()717 public final native void flush () /*-{ 718 this.flush(); 719 }-*/; 720 framebufferRenderbuffer(int target, int attachment, int renderbuffertarget, WebGLRenderbuffer renderbuffer)721 public final native void framebufferRenderbuffer (int target, int attachment, int renderbuffertarget, 722 WebGLRenderbuffer renderbuffer) /*-{ 723 this.framebufferRenderbuffer(target, attachment, renderbuffertarget, 724 renderbuffer); 725 }-*/; 726 framebufferTexture2D(int target, int attachment, int textarget, WebGLTexture texture, int level)727 public final native void framebufferTexture2D (int target, int attachment, int textarget, WebGLTexture texture, int level) /*-{ 728 this 729 .framebufferTexture2D(target, attachment, textarget, texture, 730 level); 731 }-*/; 732 frontFace(int mode)733 public final native void frontFace (int mode) /*-{ 734 this.frontFace(mode); 735 }-*/; 736 generateMipmap(int target)737 public final native void generateMipmap (int target) /*-{ 738 this.generateMipmap(target); 739 }-*/; 740 getActiveAttrib(WebGLProgram program, int index)741 public final native WebGLActiveInfo getActiveAttrib (WebGLProgram program, int index) /*-{ 742 return this.getActiveAttrib(program, index); 743 }-*/; 744 getActiveUniform(WebGLProgram program, int index)745 public final native WebGLActiveInfo getActiveUniform (WebGLProgram program, int index) /*-{ 746 return this.getActiveUniform(program, index); 747 }-*/; 748 getAttachedShaders(WebGLProgram program)749 public final native JsArray<WebGLShader> getAttachedShaders (WebGLProgram program) /*-{ 750 return this.getAttachedShaders(program); 751 }-*/; 752 getAttribLocation(WebGLProgram program, String name)753 public final native int getAttribLocation (WebGLProgram program, String name) /*-{ 754 return this.getAttribLocation(program, name); 755 }-*/; 756 getError()757 public final native int getError () /*-{ 758 return this.getError(); 759 }-*/; 760 getProgramInfoLog(WebGLProgram program)761 public final native String getProgramInfoLog (WebGLProgram program) /*-{ 762 return this.getProgramInfoLog(program); 763 }-*/; 764 getShaderInfoLog(WebGLShader shader)765 public final native String getShaderInfoLog (WebGLShader shader) /*-{ 766 return this.getShaderInfoLog(shader); 767 }-*/; 768 getShaderSource(WebGLShader shader)769 public final native String getShaderSource (WebGLShader shader) /*-{ 770 return this.getShaderSource(shader); 771 }-*/; 772 getUniformLocation(WebGLProgram program, String name)773 public final native WebGLUniformLocation getUniformLocation (WebGLProgram program, String name) /*-{ 774 return this.getUniformLocation(program, name); 775 }-*/; 776 getVertexAttribOffset(int index, int pname)777 public final native int getVertexAttribOffset (int index, int pname) /*-{ 778 return this.getVertexAttribOffset(index, pname); 779 }-*/; 780 hint(int target, int mode)781 public final native void hint (int target, int mode) /*-{ 782 this.hint(target, mode); 783 }-*/; 784 isBuffer(WebGLBuffer buffer)785 public final native boolean isBuffer (WebGLBuffer buffer) /*-{ 786 return this.isBuffer(buffer); 787 }-*/; 788 isEnabled(int cap)789 public final native boolean isEnabled (int cap) /*-{ 790 return this.isEnabled(cap); 791 }-*/; 792 isFramebuffer(WebGLFramebuffer framebuffer)793 public final native boolean isFramebuffer (WebGLFramebuffer framebuffer) /*-{ 794 return this.isFramebuffer(framebuffer); 795 }-*/; 796 isProgram(WebGLProgram program)797 public final native boolean isProgram (WebGLProgram program) /*-{ 798 return this.isProgram(program); 799 }-*/; 800 isRenderbuffer(WebGLRenderbuffer renderbuffer)801 public final native boolean isRenderbuffer (WebGLRenderbuffer renderbuffer) /*-{ 802 return this.isRenderbuffer(renderbuffer); 803 }-*/; 804 isShader(WebGLShader shader)805 public final native boolean isShader (WebGLShader shader) /*-{ 806 return this.isShader(shader); 807 }-*/; 808 isTexture(WebGLTexture texture)809 public final native boolean isTexture (WebGLTexture texture) /*-{ 810 return this.isTexture(texture); 811 }-*/; 812 lineWidth(float width)813 public final native void lineWidth (float width) /*-{ 814 this.lineWidth(width); 815 }-*/; 816 linkProgram(WebGLProgram program)817 public final native void linkProgram (WebGLProgram program) /*-{ 818 this.linkProgram(program); 819 }-*/; 820 pixelStorei(int pname, int param)821 public final native void pixelStorei (int pname, int param) /*-{ 822 this.pixelStorei(pname, param); 823 }-*/; 824 polygonOffset(float factor, float units)825 public final native void polygonOffset (float factor, float units) /*-{ 826 this.polygonOffset(factor, units); 827 }-*/; 828 readPixels(int x, int y, int width, int height, int format, int type, ArrayBufferView pixels)829 public final native void readPixels (int x, int y, int width, int height, int format, int type, ArrayBufferView pixels) /*-{ 830 this.readPixels(x, y, width, height, format, type, pixels); 831 }-*/; 832 renderbufferStorage(int target, int internalformat, int width, int height)833 public final native void renderbufferStorage (int target, int internalformat, int width, int height) /*-{ 834 this.renderbufferStorage(target, internalformat, width, height); 835 }-*/; 836 sampleCoverage(float value, boolean invert)837 public final native void sampleCoverage (float value, boolean invert) /*-{ 838 this.sampleCoverage(value, invert); 839 }-*/; 840 scissor(int x, int y, int width, int height)841 public final native void scissor (int x, int y, int width, int height) /*-{ 842 this.scissor(x, y, width, height); 843 }-*/; 844 shaderSource(WebGLShader shader, String source)845 public final native void shaderSource (WebGLShader shader, String source) /*-{ 846 this.shaderSource(shader, source); 847 }-*/; 848 stencilFunc(int func, int ref, int mask)849 public final native void stencilFunc (int func, int ref, int mask) /*-{ 850 this.stencilFunc(func, ref, mask); 851 }-*/; 852 stencilFuncSeparate(int face, int func, int ref, int mask)853 public final native void stencilFuncSeparate (int face, int func, int ref, int mask) /*-{ 854 this.stencilFuncSeparate(face, func, ref, mask); 855 }-*/; 856 stencilMask(int mask)857 public final native void stencilMask (int mask) /*-{ 858 this.stencilMask(mask); 859 }-*/; 860 stencilMaskSeparate(int face, int mask)861 public final native void stencilMaskSeparate (int face, int mask) /*-{ 862 this.stencilMaskSeparate(face, mask); 863 }-*/; 864 stencilOp(int fail, int zfail, int zpass)865 public final native void stencilOp (int fail, int zfail, int zpass) /*-{ 866 this.stencilOp(fail, zfail, zpass); 867 }-*/; 868 stencilOpSeparate(int face, int fail, int zfail, int zpass)869 public final native void stencilOpSeparate (int face, int fail, int zfail, int zpass) /*-{ 870 this.stencilOpSeparate(face, fail, zfail, zpass); 871 }-*/; 872 texImage2D(int target, int level, int internalformat, int width, int height, int border, int format, int type, ArrayBufferView pixels)873 public final native void texImage2D (int target, int level, int internalformat, int width, int height, int border, int format, 874 int type, ArrayBufferView pixels) /*-{ 875 this.texImage2D(target, level, internalformat, width, height, border, 876 format, type, pixels); 877 }-*/; 878 texImage2D(int target, int level, int internalformat, int format, int type, ImageData pixels)879 public final native void texImage2D (int target, int level, int internalformat, int format, int type, ImageData pixels) /*-{ 880 this.texImage2D(target, level, internalformat, format, type, pixels); 881 }-*/; 882 texImage2D(int target, int level, int internalformat, int format, int type, ImageElement image)883 public final native void texImage2D (int target, int level, int internalformat, int format, int type, ImageElement image) /*-{ 884 this.texImage2D(target, level, internalformat, format, type, image); 885 }-*/; 886 texImage2D(int target, int level, int internalformat, int format, int type, CanvasElement canvas)887 public final native void texImage2D (int target, int level, int internalformat, int format, int type, CanvasElement canvas) /*-{ 888 this.texImage2D(target, level, internalformat, format, type, canvas); 889 }-*/; 890 texImage2D(int target, int level, int internalformat, int format, int type, VideoElement video)891 public final native void texImage2D (int target, int level, int internalformat, int format, int type, VideoElement video) /*-{ 892 this.texImage2D(target, level, internalformat, format, type, video); 893 }-*/; 894 texParameterf(int target, int pname, float param)895 public final native void texParameterf (int target, int pname, float param) /*-{ 896 this.texParameterf(target, pname, param); 897 }-*/; 898 texParameteri(int target, int pname, int param)899 public final native void texParameteri (int target, int pname, int param) /*-{ 900 this.texParameteri(target, pname, param); 901 }-*/; 902 texSubImage2D(int target, int level, int xoffset, int yoffset, int width, int height, int format, int type, ArrayBufferView pixels)903 public final native void texSubImage2D (int target, int level, int xoffset, int yoffset, int width, int height, int format, 904 int type, ArrayBufferView pixels) /*-{ 905 this.texSubImage2D(target, level, xoffset, yoffset, width, height, 906 format, type, pixels); 907 }-*/; 908 texSubImage2D(int target, int level, int xoffset, int yoffset, int format, int type, ImageData pixels)909 public final native void texSubImage2D (int target, int level, int xoffset, int yoffset, int format, int type, ImageData pixels) /*-{ 910 this.texSubImage2D(target, level, xoffset, yoffset, format, type, 911 pixels); 912 }-*/; 913 texSubImage2D(int target, int level, int xoffset, int yoffset, int format, int type, ImageElement image)914 public final native void texSubImage2D (int target, int level, int xoffset, int yoffset, int format, int type, 915 ImageElement image) /*-{ 916 this 917 .texSubImage2D(target, level, xoffset, yoffset, format, type, 918 image); 919 }-*/; 920 texSubImage2D(int target, int level, int xoffset, int yoffset, int format, int type, CanvasElement canvas)921 public final native void texSubImage2D (int target, int level, int xoffset, int yoffset, int format, int type, 922 CanvasElement canvas) /*-{ 923 this.texSubImage2D(target, level, xoffset, yoffset, format, type, 924 canvas); 925 }-*/; 926 texSubImage2D(int target, int level, int xoffset, int yoffset, int format, int type, VideoElement video)927 public final native void texSubImage2D (int target, int level, int xoffset, int yoffset, int format, int type, 928 VideoElement video) /*-{ 929 this 930 .texSubImage2D(target, level, xoffset, yoffset, format, type, 931 video); 932 }-*/; 933 uniform1f(WebGLUniformLocation location, float x)934 public final native void uniform1f (WebGLUniformLocation location, float x) /*-{ 935 this.uniform1f(location, x); 936 }-*/; 937 uniform1fv(WebGLUniformLocation location, Float32Array v)938 public final void uniform1fv (WebGLUniformLocation location, Float32Array v) { 939 this.uniform1fv(location, (JavaScriptObject)v); 940 } 941 uniform1fv(WebGLUniformLocation location, float[] v)942 public final void uniform1fv (WebGLUniformLocation location, float[] v) { 943 this.uniform1fv(location, toJsArray(v)); 944 } 945 uniform1fv(WebGLUniformLocation location, JavaScriptObject v)946 private final native void uniform1fv (WebGLUniformLocation location, JavaScriptObject v) /*-{ 947 this.uniform1fv(location, v); 948 }-*/; 949 uniform1i(WebGLUniformLocation location, int x)950 public final native void uniform1i (WebGLUniformLocation location, int x) /*-{ 951 this.uniform1i(location, x); 952 }-*/; 953 uniform1iv(WebGLUniformLocation location, Int32Array v)954 public final void uniform1iv (WebGLUniformLocation location, Int32Array v) { 955 this.uniform1iv(location, (JavaScriptObject)v); 956 } 957 uniform1iv(WebGLUniformLocation location, int[] v)958 public final void uniform1iv (WebGLUniformLocation location, int[] v) { 959 this.uniform1iv(location, toJsArray(v)); 960 } 961 uniform1iv(WebGLUniformLocation location, JavaScriptObject v)962 private final native void uniform1iv (WebGLUniformLocation location, JavaScriptObject v) /*-{ 963 this.uniform1iv(location, v); 964 }-*/; 965 uniform2f(WebGLUniformLocation location, float x, float y)966 public final native void uniform2f (WebGLUniformLocation location, float x, float y) /*-{ 967 this.uniform2f(location, x, y); 968 }-*/; 969 uniform2fv(WebGLUniformLocation location, Float32Array v)970 public final void uniform2fv (WebGLUniformLocation location, Float32Array v) { 971 this.uniform2fv(location, (JavaScriptObject)v); 972 } 973 uniform2fv(WebGLUniformLocation location, float[] v)974 public final void uniform2fv (WebGLUniformLocation location, float[] v) { 975 this.uniform2fv(location, toJsArray(v)); 976 } 977 uniform2fv(WebGLUniformLocation location, JavaScriptObject v)978 private final native void uniform2fv (WebGLUniformLocation location, JavaScriptObject v) /*-{ 979 this.uniform2fv(location, v); 980 }-*/; 981 uniform2i(WebGLUniformLocation location, int x, int y)982 public final native void uniform2i (WebGLUniformLocation location, int x, int y) /*-{ 983 this.uniform2i(location, x, y); 984 }-*/; 985 uniform2iv(WebGLUniformLocation location, Int32Array v)986 public final void uniform2iv (WebGLUniformLocation location, Int32Array v) { 987 this.uniform2iv(location, (JavaScriptObject)v); 988 } 989 uniform2iv(WebGLUniformLocation location, int[] v)990 public final void uniform2iv (WebGLUniformLocation location, int[] v) { 991 this.uniform2iv(location, toJsArray(v)); 992 } 993 uniform2iv(WebGLUniformLocation location, JavaScriptObject v)994 private final native void uniform2iv (WebGLUniformLocation location, JavaScriptObject v) /*-{ 995 this.uniform2iv(location, v); 996 }-*/; 997 uniform3f(WebGLUniformLocation location, float x, float y, float z)998 public final native void uniform3f (WebGLUniformLocation location, float x, float y, float z) /*-{ 999 this.uniform3f(location, x, y, z); 1000 }-*/; 1001 uniform3fv(WebGLUniformLocation location, Float32Array v)1002 public final void uniform3fv (WebGLUniformLocation location, Float32Array v) { 1003 this.uniform3fv(location, (JavaScriptObject)v); 1004 } 1005 uniform3fv(WebGLUniformLocation location, float[] v)1006 public final void uniform3fv (WebGLUniformLocation location, float[] v) { 1007 this.uniform3fv(location, toJsArray(v)); 1008 } 1009 uniform3fv(WebGLUniformLocation location, JavaScriptObject v)1010 private final native void uniform3fv (WebGLUniformLocation location, JavaScriptObject v) /*-{ 1011 this.uniform3fv(location, v); 1012 }-*/; 1013 uniform3i(WebGLUniformLocation location, int x, int y, int z)1014 public final native void uniform3i (WebGLUniformLocation location, int x, int y, int z) /*-{ 1015 this.uniform3i(location, x, y, z); 1016 }-*/; 1017 uniform3iv(WebGLUniformLocation location, Int32Array v)1018 public final void uniform3iv (WebGLUniformLocation location, Int32Array v) { 1019 this.uniform3iv(location, (JavaScriptObject)v); 1020 } 1021 uniform3iv(WebGLUniformLocation location, int[] v)1022 public final void uniform3iv (WebGLUniformLocation location, int[] v) { 1023 1024 this.uniform3iv(location, toJsArray(v)); 1025 } 1026 uniform3iv(WebGLUniformLocation location, JavaScriptObject v)1027 private final native void uniform3iv (WebGLUniformLocation location, JavaScriptObject v) /*-{ 1028 this.uniform3iv(location, v); 1029 }-*/; 1030 uniform4f(WebGLUniformLocation location, float x, float y, float z, float w)1031 public final native void uniform4f (WebGLUniformLocation location, float x, float y, float z, float w) /*-{ 1032 this.uniform4f(location, x, y, z, w); 1033 }-*/; 1034 uniform4fv(WebGLUniformLocation location, Float32Array v)1035 public final void uniform4fv (WebGLUniformLocation location, Float32Array v) { 1036 this.uniform4fv(location, (JavaScriptObject)v); 1037 } 1038 uniform4fv(WebGLUniformLocation location, float[] v)1039 public final void uniform4fv (WebGLUniformLocation location, float[] v) { 1040 this.uniform4fv(location, toJsArray(v)); 1041 } 1042 uniform4fv(WebGLUniformLocation location, JavaScriptObject v)1043 private final native void uniform4fv (WebGLUniformLocation location, JavaScriptObject v) /*-{ 1044 this.uniform4fv(location, v); 1045 }-*/; 1046 uniform4i(WebGLUniformLocation location, int x, int y, int z, int w)1047 public final native void uniform4i (WebGLUniformLocation location, int x, int y, int z, int w) /*-{ 1048 this.uniform4i(location, x, y, z, w); 1049 }-*/; 1050 uniform4iv(WebGLUniformLocation location, Int32Array v)1051 public final void uniform4iv (WebGLUniformLocation location, Int32Array v) { 1052 this.uniform4iv(location, (JavaScriptObject)v); 1053 } 1054 uniform4iv(WebGLUniformLocation location, int[] v)1055 public final void uniform4iv (WebGLUniformLocation location, int[] v) { 1056 this.uniform4iv(location, toJsArray(v)); 1057 } 1058 uniform4iv(WebGLUniformLocation location, JavaScriptObject v)1059 private final native void uniform4iv (WebGLUniformLocation location, JavaScriptObject v) /*-{ 1060 this.uniform4iv(location, v); 1061 }-*/; 1062 uniformMatrix2fv(WebGLUniformLocation location, boolean transpose, Float32Array value)1063 public final void uniformMatrix2fv (WebGLUniformLocation location, boolean transpose, Float32Array value) { 1064 this.uniformMatrix2fv(location, transpose, (JavaScriptObject)value); 1065 } 1066 uniformMatrix2fv(WebGLUniformLocation location, boolean transpose, float[] value)1067 public final void uniformMatrix2fv (WebGLUniformLocation location, boolean transpose, float[] value) { 1068 this.uniformMatrix2fv(location, transpose, toJsArray(value)); 1069 } 1070 uniformMatrix2fv(WebGLUniformLocation location, boolean transpose, JavaScriptObject value)1071 private final native void uniformMatrix2fv (WebGLUniformLocation location, boolean transpose, JavaScriptObject value) /*-{ 1072 this.uniformMatrix2fv(location, transpose, value); 1073 }-*/; 1074 uniformMatrix3fv(WebGLUniformLocation location, boolean transpose, Float32Array value)1075 public final void uniformMatrix3fv (WebGLUniformLocation location, boolean transpose, Float32Array value) { 1076 this.uniformMatrix3fv(location, transpose, (JavaScriptObject)value); 1077 } 1078 uniformMatrix3fv(WebGLUniformLocation location, boolean transpose, float[] value)1079 public final void uniformMatrix3fv (WebGLUniformLocation location, boolean transpose, float[] value) { 1080 this.uniformMatrix3fv(location, transpose, toJsArray(value)); 1081 } 1082 uniformMatrix3fv(WebGLUniformLocation location, boolean transpose, JavaScriptObject value)1083 private final native void uniformMatrix3fv (WebGLUniformLocation location, boolean transpose, JavaScriptObject value) /*-{ 1084 this.uniformMatrix3fv(location, transpose, value); 1085 }-*/; 1086 uniformMatrix4fv(WebGLUniformLocation location, boolean transpose, Float32Array value)1087 public final void uniformMatrix4fv (WebGLUniformLocation location, boolean transpose, Float32Array value) { 1088 this.uniformMatrix4fv(location, transpose, (JavaScriptObject)value); 1089 } 1090 uniformMatrix4fv(WebGLUniformLocation location, boolean transpose, float[] value)1091 public final void uniformMatrix4fv (WebGLUniformLocation location, boolean transpose, float[] value) { 1092 uniformMatrix4fv(location, transpose, toJsArray(value)); 1093 } 1094 uniformMatrix4fv(WebGLUniformLocation location, boolean transpose, JavaScriptObject value)1095 private final native void uniformMatrix4fv (WebGLUniformLocation location, boolean transpose, JavaScriptObject value) /*-{ 1096 this.uniformMatrix4fv(location, transpose, value); 1097 }-*/; 1098 useProgram(WebGLProgram program)1099 public final native void useProgram (WebGLProgram program) /*-{ 1100 this.useProgram(program); 1101 }-*/; 1102 validateProgram(WebGLProgram program)1103 public final native void validateProgram (WebGLProgram program) /*-{ 1104 this.validateProgram(program); 1105 }-*/; 1106 vertexAttrib1f(int indx, float x)1107 public final native void vertexAttrib1f (int indx, float x) /*-{ 1108 this.vertexAttrib1f(indx, x); 1109 }-*/; 1110 vertexAttrib1fv(int indx, Float32Array values)1111 public final void vertexAttrib1fv (int indx, Float32Array values) { 1112 this.vertexAttrib1fv(indx, (JavaScriptObject)values); 1113 } 1114 vertexAttrib1fv(int indx, float[] values)1115 public final void vertexAttrib1fv (int indx, float[] values) { 1116 this.vertexAttrib1fv(indx, toJsArray(values)); 1117 } 1118 vertexAttrib1fv(int indx, JavaScriptObject values)1119 private final native void vertexAttrib1fv (int indx, JavaScriptObject values) /*-{ 1120 this.vertexAttrib1fv(indx, values); 1121 }-*/; 1122 vertexAttrib2f(int indx, float x, float y)1123 public final native void vertexAttrib2f (int indx, float x, float y) /*-{ 1124 this.vertexAttrib2f(indx, x, y); 1125 }-*/; 1126 vertexAttrib2fv(int indx, Float32Array values)1127 public final void vertexAttrib2fv (int indx, Float32Array values) { 1128 this.vertexAttrib2fv(indx, (JavaScriptObject)values); 1129 } 1130 vertexAttrib2fv(int indx, float[] values)1131 public final void vertexAttrib2fv (int indx, float[] values) { 1132 this.vertexAttrib2fv(indx, toJsArray(values)); 1133 } 1134 vertexAttrib2fv(int indx, JavaScriptObject values)1135 private final native void vertexAttrib2fv (int indx, JavaScriptObject values) /*-{ 1136 this.vertexAttrib2fv(indx, values); 1137 }-*/; 1138 vertexAttrib3f(int indx, float x, float y, float z)1139 public final native void vertexAttrib3f (int indx, float x, float y, float z) /*-{ 1140 this.vertexAttrib3f(indx, x, y, z); 1141 }-*/; 1142 vertexAttrib3fv(int indx, Float32Array values)1143 public final void vertexAttrib3fv (int indx, Float32Array values) { 1144 this.vertexAttrib3fv(indx, (JavaScriptObject)values); 1145 } 1146 vertexAttrib3fv(int indx, float[] values)1147 public final void vertexAttrib3fv (int indx, float[] values) { 1148 this.vertexAttrib3fv(indx, toJsArray(values)); 1149 } 1150 vertexAttrib3fv(int indx, JavaScriptObject values)1151 private final native void vertexAttrib3fv (int indx, JavaScriptObject values) /*-{ 1152 this.vertexAttrib3fv(indx, values); 1153 }-*/; 1154 vertexAttrib4f(int indx, float x, float y, float z, float w)1155 public final native void vertexAttrib4f (int indx, float x, float y, float z, float w) /*-{ 1156 this.vertexAttrib4f(indx, x, y, z, w); 1157 }-*/; 1158 vertexAttrib4fv(int indx, Float32Array values)1159 public final void vertexAttrib4fv (int indx, Float32Array values) { 1160 this.vertexAttrib4fv(indx, (JavaScriptObject)values); 1161 } 1162 vertexAttrib4fv(int indx, float[] values)1163 public final void vertexAttrib4fv (int indx, float[] values) { 1164 this.vertexAttrib4fv(indx, toJsArray(values)); 1165 } 1166 toJsArray(float[] values)1167 public final Float32Array toJsArray (float[] values) { 1168 Float32Array array = TypedArrays.createFloat32Array(values.length); 1169 array.set(values); 1170 return array; 1171 } 1172 toJsArray(int[] values)1173 public final Int32Array toJsArray (int[] values) { 1174 Int32Array array = TypedArrays.createInt32Array(values.length); 1175 array.set(values); 1176 return array; 1177 } 1178 vertexAttrib4fv(int indx, JavaScriptObject values)1179 private final native void vertexAttrib4fv (int indx, JavaScriptObject values) /*-{ 1180 this.vertexAttrib4fv(indx, values); 1181 }-*/; 1182 vertexAttribPointer(int indx, int size, int type, boolean normalized, int stride, int offset)1183 public final native void vertexAttribPointer (int indx, int size, int type, boolean normalized, int stride, int offset) /*-{ 1184 this.vertexAttribPointer(indx, size, type, normalized, stride, offset); 1185 }-*/; 1186 viewport(int x, int y, int width, int height)1187 public final native void viewport (int x, int y, int width, int height) /*-{ 1188 this.viewport(x, y, width, height); 1189 }-*/; 1190 1191 /** Return the value for the passed pname. 1192 * 1193 * @param pname one of RENDERER, SHADING_LANGUAGE_VERSION, VENDOR, VERSION */ getParameterString(int pname)1194 public final native String getParameterString (int pname) /*-{ 1195 return this.getParameter(pname); 1196 }-*/; 1197 1198 /** Return the value for the passed pname. 1199 * 1200 * @param pname one of ACTIVE_TEXTURE, ALPHA_BITS, BLEND_DST_ALPHA, BLEND_DST_RGB, BLEND_EQUATION_ALPHA, BLEND_EQUATION_RGB, 1201 * BLEND_SRC_ALPHA, BLEND_SRC_RGB, BLUE_BITS, CULL_FACE_MODE, DEPTH_BITS, DEPTH_FUNC, FRONT_FACE, 1202 * GENERATE_MIPMAP_HINT, GREEN_BITS, IMPLEMENTATION_COLOR_READ_FORMAT, IMPLEMENTATION_COLOR_READ_TYPE, 1203 * MAX_COMBINED_TEXTURE_IMAGE_UNITS, MAX_CUBE_MAP_TEXTURE_SIZE, MAX_FRAGMENT_UNIFORM_VECTORS, MAX_RENDERBUFFER_SIZE, 1204 * MAX_TEXTURE_IMAGE_UNITS, MAX_TEXTURE_SIZE, MAX_VARYING_VECTORS, MAX_VERTEX_ATTRIBS, 1205 * MAX_VERTEX_TEXTURE_IMAGE_UNITS, MAX_VERTEX_UNIFORM_VECTORS, NUM_COMPRESSED_TEXTURE_FORMATS, PACK_ALIGNMENT, 1206 * RED_BITS, SAMPLE_BUFFERS, SAMPLES, STENCIL_BACK_FAIL, STENCIL_BACK_FUNC, STENCIL_BACK_PASS_DEPTH_FAIL, 1207 * STENCIL_BACK_PASS_DEPTH_PASS, STENCIL_BACK_REF, STENCIL_BACK_VALUE_MASK, STENCIL_BACK_WRITEMASK, STENCIL_BITS, 1208 * STENCIL_CLEAR_VALUE, STENCIL_FAIL, STENCIL_FUNC, STENCIL_PASS_DEPTH_FAIL, STENCIL_PASS_DEPTH_PASS, STENCIL_REF, 1209 * STENCIL_VALUE_MASK, STENCIL_WRITEMASK, SUBPIXEL_BITS, UNPACK_ALIGNMENT */ getParameteri(int pname)1210 public final native int getParameteri (int pname) /*-{ 1211 return this.getParameter(pname); 1212 }-*/; 1213 1214 /** Return the value for the passed pname. 1215 * 1216 * @param pname one of BLEND, CULL_FACE, DEPTH_TEST, DEPTH_WRITEMASK, DITHER, POLYGON_OFFSET_FILL, SAMPLE_COVERAGE_INVERT, 1217 * SCISSOR_TEST, STENCIL_TEST, UNPACK_FLIP_Y_WEBGL, UNPACK_PREMULTIPLY_ALPHA_WEBGL */ getParameterb(int pname)1218 public final native boolean getParameterb (int pname) /*-{ 1219 return this.getParameter(pname); 1220 }-*/; 1221 1222 /** Return the value for the passed pname. 1223 * 1224 * @param pname one of DEPTH_CLEAR_VALUE, LINE_WIDTH, POLYGON_OFFSET_FACTOR, POLYGON_OFFSET_UNITS, SAMPLE_COVERAGE_VALUE */ getParameterf(int pname)1225 public final native float getParameterf (int pname) /*-{ 1226 return this.getParameter(pname); 1227 }-*/; 1228 1229 /** Return the value for the passed pname. 1230 * 1231 * @param pname one of ARRAY_BUFFER_BINDING, COMPRESSED_TEXTURE_FORMATS, CURRENT_PROGRAM, ELEMENT_ARRAY_BUFFER_BINDING, 1232 * FRAMEBUFFER_BINDING, RENDERBUFFER_BINDING, TEXTURE_BINDING_2D, TEXTURE_BINDING_CUBE_MAP */ getParametero(int pname)1233 public final native <T extends WebGLObject> T getParametero (int pname) /*-{ 1234 return this.getParameter(pname); 1235 }-*/; 1236 1237 /** Return the value for the passed pname. 1238 * 1239 * @param pname one of ALIASED_LINE_WIDTH_RANGE, ALIASED_POINT_SIZE_RANGE, BLEND_COLOR, COLOR_CLEAR_VALUE, COLOR_WRITEMASK, 1240 * DEPTH_RANGE, MAX_VIEWPORT_DIMS, SCISSOR_BOX, VIEWPORT */ getParameterv(int pname)1241 public final native <T extends ArrayBufferView> T getParameterv (int pname) /*-{ 1242 return this.getParameter(pname); 1243 }-*/; 1244 1245 /** Return the uniform value at the passed location in the passed program. */ getUniformb(WebGLProgram program, WebGLUniformLocation location)1246 public final native boolean getUniformb (WebGLProgram program, WebGLUniformLocation location) /*-{ 1247 return this.getUniform(program, location); 1248 }-*/; 1249 1250 /** Return the uniform value at the passed location in the passed program. */ getUniformi(WebGLProgram program, WebGLUniformLocation location)1251 public final native int getUniformi (WebGLProgram program, WebGLUniformLocation location) /*-{ 1252 return this.getUniform(program, location); 1253 }-*/; 1254 1255 /** Return the uniform value at the passed location in the passed program. */ getUniformf(WebGLProgram program, WebGLUniformLocation location)1256 public final native float getUniformf (WebGLProgram program, WebGLUniformLocation location) /*-{ 1257 return this.getUniform(program, location); 1258 }-*/; 1259 1260 /** Return the uniform value at the passed location in the passed program. */ getUniformv(WebGLProgram program, WebGLUniformLocation location)1261 public final native <T extends ArrayBufferView> T getUniformv (WebGLProgram program, WebGLUniformLocation location) /*-{ 1262 return this.getUniform(program, location); 1263 }-*/; 1264 1265 /** Return the information requested in pname about the vertex attribute at the passed index. 1266 * 1267 * @param pname one of VERTEX_ATTRIB_ARRAY_SIZE, VERTEX_ATTRIB_ARRAY_STRIDE, VERTEX_ATTRIB_ARRAY_TYPE */ getVertexAttribi(int index, int pname)1268 public final native int getVertexAttribi (int index, int pname) /*-{ 1269 return this.getVertexAttrib(index, pname); 1270 }-*/; 1271 1272 /** Return the information requested in pname about the vertex attribute at the passed index. 1273 * 1274 * @param pname one of VERTEX_ATTRIB_ARRAY_ENABLED, VERTEX_ATTRIB_ARRAY_NORMALIZED */ getVertexAttribb(int index, int pname)1275 public final native boolean getVertexAttribb (int index, int pname) /*-{ 1276 return this.getVertexAttrib(index, pname); 1277 }-*/; 1278 1279 /** Return the information requested in pname about the vertex attribute at the passed index. 1280 * 1281 * @param pname VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 1282 * @return {@link WebGLBuffer} */ getVertexAttribo(int index, int pname)1283 public final native <T extends WebGLObject> T getVertexAttribo (int index, int pname) /*-{ 1284 return this.getVertexAttrib(index, pname); 1285 }-*/; 1286 1287 /** Return the information requested in pname about the vertex attribute at the passed index. 1288 * 1289 * @param pname CURRENT_VERTEX_ATTRIB 1290 * @return a {@link Float32Array} with 4 elements */ getVertexAttribv(int index, int pname)1291 public final native Float32Array getVertexAttribv (int index, int pname) /*-{ 1292 return this.getVertexAttrib(index, pname); 1293 }-*/; 1294 1295 /** Return the value for the passed pname given the passed target. The type returned is the natural type for the requested 1296 * pname, as given in the following table: If an attempt is made to call this function with no WebGLTexture bound (see above), 1297 * an INVALID_OPERATION error is generated. 1298 * 1299 * @param pname one of TEXTURE_MAG_FILTER, TEXTURE_MIN_FILTER, TEXTURE_WRAP_S, TEXTURE_WRAP_T */ getTexParameter(int target, int pname)1300 public final native int getTexParameter (int target, int pname) /*-{ 1301 return this.getTexParameter(target, pname); 1302 }-*/; 1303 1304 /** Return the value for the passed pname given the passed shader. 1305 * 1306 * @param pname one of DELETE_STATUS, COMPILE_STATUS */ getShaderParameterb(WebGLShader shader, int pname)1307 public final native boolean getShaderParameterb (WebGLShader shader, int pname) /*-{ 1308 return this.getShaderParameter(shader, pname); 1309 }-*/; 1310 1311 /** Return the value for the passed pname given the passed shader. 1312 * 1313 * @param pname one of SHADER_TYPE, INFO_LOG_LENGTH, SHADER_SOURCE_LENGTH */ getShaderParameteri(WebGLShader shader, int pname)1314 public final native int getShaderParameteri (WebGLShader shader, int pname) /*-{ 1315 return this.getShaderParameter(shader, pname); 1316 }-*/; 1317 1318 /** Return the value for the passed pname given the passed target. 1319 * 1320 * @param pname one of RENDERBUFFER_WIDTH, RENDERBUFFER_HEIGHT, RENDERBUFFER_INTERNAL_FORMAT, RENDERBUFFER_RED_SIZE, 1321 * RENDERBUFFER_GREEN_SIZE, RENDERBUFFER_BLUE_SIZE, RENDERBUFFER_ALPHA_SIZE, RENDERBUFFER_DEPTH_SIZE, 1322 * RENDERBUFFER_STENCIL_SIZE */ getRenderbufferParameter(int target, int pname)1323 public final native int getRenderbufferParameter (int target, int pname) /*-{ 1324 return this.getRenderbufferParameter(target, pname); 1325 }-*/; 1326 1327 /** Return the value for the passed pname given the passed program. 1328 * 1329 * @param pname one of DELETE_STATUS, LINK_STATUS, VALIDATE_STATUS */ getProgramParameterb(WebGLProgram program, int pname)1330 public final native boolean getProgramParameterb (WebGLProgram program, int pname) /*-{ 1331 return this.getProgramParameter(program, pname); 1332 }-*/; 1333 1334 /** Return the value for the passed pname given the passed program. 1335 * 1336 * @param pname one of INFO_LOG_LENGTH, ATTACHED_SHADERS, ACTIVE_ATTRIBUTES, ACTIVE_ATTRIBUTE_MAX_LENGTH, ACTIVE_UNIFORMS, 1337 * ACTIVE_UNIFORM_MAX_LENGTH */ getProgramParameteri(WebGLProgram program, int pname)1338 public final native int getProgramParameteri (WebGLProgram program, int pname) /*-{ 1339 return this.getProgramParameter(program, pname); 1340 }-*/; 1341 1342 /** Return the value for the passed pname. 1343 * 1344 * @param pname one of BUFFER_SIZE, BUFFER_USAGE */ getBufferParameter(int target, int pname)1345 public final native int getBufferParameter (int target, int pname) /*-{ 1346 return this.getBufferParameter(target, pname); 1347 }-*/; 1348 1349 /** Return the value for the passed pname given the passed target and attachment. 1350 * 1351 * @param pname one of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL, 1352 * FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */ getFramebufferAttachmentParameteri(int target, int attachment, int pname)1353 public final native int getFramebufferAttachmentParameteri (int target, int attachment, int pname) /*-{ 1354 return this 1355 .getFramebufferAttachmentParameter(target, attachment, pname); 1356 }-*/; 1357 1358 /** Return the value for the passed pname given the passed target and attachment. 1359 * 1360 * @param pname FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 1361 * @return {@link WebGLRenderbuffer} or {@link WebGLTexture} */ getFramebufferAttachmentParametero(int target, int attachment, int pname)1362 public final native <T extends WebGLObject> T getFramebufferAttachmentParametero (int target, int attachment, int pname) /*-{ 1363 return this 1364 .getFramebufferAttachmentParameter(target, attachment, pname); 1365 }-*/; 1366 } 1367