How to use WebGLContext method in wpt

Best JavaScript code snippet using wpt

laya.webgl.js

Source:laya.webgl.js Github

copy

Full Screen

...3923 return gl;3924 }3925 return null;3926 }3927 WebGL.mainContext=RunDriver.getWebGLContext(Render._mainCanvas);3928 if (WebGL.mainContext==null)3929 return false;3930 if (Render.isWebGL)return true;3931 HTMLImage.create=function (src,def){3932 return new WebGLImage(src,def);3933 }3934 HTMLSubImage.create=function (canvas,offsetX,offsetY,width,height,atlasImage,src){3935 return new WebGLSubImage(canvas,offsetX,offsetY,width,height,atlasImage,src);3936 }3937 Render.WebGL=WebGL;3938 Render.isWebGL=true;3939 DrawText.__init__();3940 RunDriver.createRenderSprite=function (type,next){3941 return new RenderSprite3D(type,next);3942 }3943 RunDriver.createWebGLContext2D=function (c){3944 return new WebGLContext2D(c);3945 }3946 RunDriver.changeWebGLSize=function (width,height){3947 laya.webgl.WebGL.onStageResize(width,height);3948 }3949 RunDriver.createGraphics=function (){3950 return new GraphicsGL();3951 };3952 var action=RunDriver.createFilterAction;3953 RunDriver.createFilterAction=action ? action :function (type){3954 return new ColorFilterActionGL()3955 }3956 RunDriver.clear=function (color){3957 RenderState2D.worldScissorTest && laya.webgl.WebGL.mainContext.disable(/*laya.webgl.WebGLContext.SCISSOR_TEST*/0x0C11);3958 var ctx=Render.context.ctx;3959 var c=(ctx._submits._length==0 || Config.preserveDrawingBuffer)? Color.create(color)._color :Stage._wgColor;3960 if (c)ctx.clearBG(c[0],c[1],c[2],c[3]);3961 RenderState2D.clear();3962 }3963 RunDriver.addToAtlas=function (texture,force){3964 (force===void 0)&& (force=false);3965 var bitmap=texture.bitmap;3966 if (!Render.optimizeTextureMemory(texture.url,texture)){3967 (bitmap).enableMerageInAtlas=false;3968 return;3969 }3970 if ((Laya.__typeof(bitmap,'laya.webgl.resource.IMergeAtlasBitmap'))&& ((bitmap).allowMerageInAtlas)){3971 bitmap.on(/*laya.events.Event.RECOVERED*/"recovered",texture,texture.addTextureToAtlas);3972 }3973 }3974 RunDriver.isAtlas=function (bitmap){3975 return (bitmap instanceof laya.webgl.atlas.AtlasWebGLCanvas );3976 }3977 AtlasResourceManager._enable();3978 RunDriver.beginFlush=function (){3979 var atlasResourceManager=AtlasResourceManager.instance;3980 var count=atlasResourceManager.getAtlaserCount();3981 for (var i=0;i < count;i++){3982 var atlerCanvas=atlasResourceManager.getAtlaserByIndex(i).texture;3983 (atlerCanvas._flashCacheImageNeedFlush)&& (RunDriver.flashFlushImage(atlerCanvas));3984 }3985 }3986 RunDriver.drawToCanvas=function (sprite,_renderType,canvasWidth,canvasHeight,offsetX,offsetY){3987 if (canvasWidth <=0 || canvasHeight <=0){3988 console.log("[error] canvasWidth and canvasHeight should greater than zero");3989 }3990 offsetX-=sprite.x;3991 offsetY-=sprite.y;3992 var renderTarget=RenderTarget2D.create(canvasWidth,canvasHeight,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,0,false);3993 renderTarget.start();3994 renderTarget.clear(0,0,0,0);3995 Render.context.clear();3996 RenderSprite.renders[_renderType]._fun(sprite,Render.context,offsetX,RenderState2D.height-canvasHeight+offsetY);3997 Render.context.flush();3998 renderTarget.end();3999 var pixels=renderTarget.getData(0,0,renderTarget.width,renderTarget.height);4000 renderTarget.recycle();4001 var htmlCanvas=new WebGLCanvas();4002 htmlCanvas._canvas=Browser.createElement("canvas");4003 htmlCanvas.size(canvasWidth,canvasHeight);4004 var context=htmlCanvas._canvas.getContext('2d');4005 Browser.canvas.size(canvasWidth,canvasHeight);4006 var tempContext=Browser.context;4007 var imgData=tempContext.createImageData(canvasWidth,canvasHeight);4008 imgData.data.set(/*__JS__ */new Uint8ClampedArray(pixels.buffer));4009 htmlCanvas._imgData=imgData;4010 tempContext.putImageData(imgData,0,0);4011 context.save();4012 context.translate(0,canvasHeight);4013 context.scale(1,-1);4014 context.drawImage(Browser.canvas.source,0,0);4015 context.restore();4016 return htmlCanvas;4017 }4018 RunDriver.createFilterAction=function (type){4019 var action;4020 switch (type){4021 case /*laya.filters.Filter.COLOR*/0x20:4022 action=new ColorFilterActionGL();4023 break ;4024 }4025 return action;4026 }4027 RunDriver.addTextureToAtlas=function (texture){4028 texture._uvID++;4029 AtlasResourceManager._atlasRestore++;4030 ((texture.bitmap).enableMerageInAtlas)&& (AtlasResourceManager.instance.addToAtlas(texture));4031 }4032 RunDriver.getTexturePixels=function (value,x,y,width,height){4033 (Render.context.ctx).clear();4034 var tSprite=new Sprite();4035 tSprite.graphics.drawTexture(value,-x,-y);4036 var tRenderTarget=RenderTarget2D.create(width,height);4037 tRenderTarget.start();4038 tRenderTarget.clear(0,0,0,0);4039 tSprite.render(Render.context,0,0);4040 (Render.context.ctx).flush();4041 tRenderTarget.end();4042 var tUint8Array=tRenderTarget.getData(0,0,width,height);4043 var tArray=[];4044 var tIndex=0;4045 for (var i=height-1;i >=0;i--){4046 for (var j=0;j < width;j++){4047 tIndex=(i *width+j)*4;4048 tArray.push(tUint8Array[tIndex]);4049 tArray.push(tUint8Array[tIndex+1]);4050 tArray.push(tUint8Array[tIndex+2]);4051 tArray.push(tUint8Array[tIndex+3]);4052 }4053 }4054 return tArray;4055 }4056 RunDriver.skinAniSprite=function (){4057 var tSkinSprite=new SkinMesh()4058 return tSkinSprite;4059 }4060 HTMLCanvas.create=function (type,canvas){4061 var ret=new WebGLCanvas();4062 ret._imgData=canvas;4063 ret.flipY=false;4064 return ret;4065 }4066 Filter._filterStart=function (scope,sprite,context,x,y){4067 var b=scope.getValue("bounds");4068 var source=RenderTarget2D.create(b.width,b.height);4069 source.start();4070 source.clear(0,0,0,0);4071 scope.addValue("src",source);4072 scope.addValue("ScissorTest",RenderState2D.worldScissorTest);4073 if (RenderState2D.worldScissorTest){4074 var tClilpRect=new Rectangle();4075 tClilpRect.copyFrom((context.ctx)._clipRect)4076 scope.addValue("clipRect",tClilpRect);4077 RenderState2D.worldScissorTest=false;4078 laya.webgl.WebGL.mainContext.disable(/*laya.webgl.WebGLContext.SCISSOR_TEST*/0x0C11);4079 }4080 }4081 Filter._filterEnd=function (scope,sprite,context,x,y){4082 var b=scope.getValue("bounds");4083 var source=scope.getValue("src");4084 source.end();4085 var out=RenderTarget2D.create(b.width,b.height);4086 out.start();4087 out.clear(0,0,0,0);4088 scope.addValue("out",out);4089 sprite._set$P('_filterCache',out);4090 sprite._set$P('_isHaveGlowFilter',scope.getValue("_isHaveGlowFilter"));4091 }4092 Filter._EndTarget=function (scope,context){4093 var source=scope.getValue("src");4094 source.recycle();4095 var out=scope.getValue("out");4096 out.end();4097 var b=scope.getValue("ScissorTest");4098 if (b){4099 RenderState2D.worldScissorTest=true;4100 laya.webgl.WebGL.mainContext.enable(/*laya.webgl.WebGLContext.SCISSOR_TEST*/0x0C11);4101 context.ctx.save();4102 var tClipRect=scope.getValue("clipRect");4103 (context.ctx).clipRect(tClipRect.x,tClipRect.y,tClipRect.width,tClipRect.height);4104 }4105 }4106 Filter._useSrc=function (scope){4107 var source=scope.getValue("out");4108 source.end();4109 source=scope.getValue("src");4110 source.start();4111 source.clear(0,0,0,0);4112 }4113 Filter._endSrc=function (scope){4114 var source=scope.getValue("src");4115 source.end();4116 }4117 Filter._useOut=function (scope){4118 var source=scope.getValue("src");4119 source.end();4120 source=scope.getValue("out");4121 source.start();4122 source.clear(0,0,0,0);4123 }4124 Filter._endOut=function (scope){4125 var source=scope.getValue("out");4126 source.end();4127 }4128 Filter._recycleScope=function (scope){4129 scope.recycle();4130 }4131 Filter._filter=function (sprite,context,x,y){4132 var next=this._next;4133 if (next){4134 var filters=sprite.filters,len=filters.length;4135 if (len==1 && (filters[0].type==/*laya.filters.Filter.COLOR*/0x20)){4136 context.ctx.save();4137 context.ctx.setFilters([filters[0]]);4138 next._fun.call(next,sprite,context,x,y);4139 context.ctx.restore();4140 return;4141 };4142 var shaderValue;4143 var b;4144 var scope=SubmitCMDScope.create();4145 var p=Point.TEMP;4146 var tMatrix=context.ctx._getTransformMatrix();4147 var mat=Matrix.create();4148 tMatrix.copyTo(mat);4149 var tPadding=0;4150 var tHalfPadding=0;4151 var tIsHaveGlowFilter=false;4152 var out=sprite._$P._filterCache ? sprite._$P._filterCache :null;4153 if (!out || sprite._repaint){4154 tIsHaveGlowFilter=sprite._isHaveGlowFilter();4155 scope.addValue("_isHaveGlowFilter",tIsHaveGlowFilter);4156 if (tIsHaveGlowFilter){4157 tPadding=50;4158 tHalfPadding=25;4159 }4160 b=new Rectangle();4161 b.copyFrom((sprite).getSelfBounds());4162 b.x+=(sprite).x;4163 b.y+=(sprite).y;4164 b.x-=(sprite).pivotX+4;4165 b.y-=(sprite).pivotY+4;4166 var tSX=b.x;4167 var tSY=b.y;4168 b.width+=(tPadding+8);4169 b.height+=(tPadding+8);4170 p.x=b.x *mat.a+b.y *mat.c;4171 p.y=b.y *mat.d+b.x *mat.b;4172 b.x=p.x;4173 b.y=p.y;4174 p.x=b.width *mat.a+b.height *mat.c;4175 p.y=b.height *mat.d+b.width *mat.b;4176 b.width=p.x;4177 b.height=p.y;4178 if (b.width <=0 || b.height <=0){4179 return;4180 }4181 out && out.recycle();4182 scope.addValue("bounds",b);4183 var submit=SubmitCMD.create([scope,sprite,context,0,0],Filter._filterStart);4184 context.addRenderObject(submit);4185 (context.ctx)._renderKey=0;4186 (context.ctx)._shader2D.glTexture=null;4187 var tX=sprite.x-tSX+tHalfPadding;4188 var tY=sprite.y-tSY+tHalfPadding;4189 next._fun.call(next,sprite,context,tX,tY);4190 submit=SubmitCMD.create([scope,sprite,context,0,0],Filter._filterEnd);4191 context.addRenderObject(submit);4192 for (var i=0;i < len;i++){4193 if (i !=0){4194 submit=SubmitCMD.create([scope],Filter._useSrc);4195 context.addRenderObject(submit);4196 shaderValue=Value2D.create(/*laya.webgl.shader.d2.ShaderDefines2D.TEXTURE2D*/0x01,0);4197 Matrix.TEMP.identity();4198 context.ctx.drawTarget(scope,0,0,b.width,b.height,Matrix.TEMP,"out",shaderValue,null,BlendMode.TOINT.overlay);4199 submit=SubmitCMD.create([scope],Filter._useOut);4200 context.addRenderObject(submit);4201 };4202 var fil=filters[i];4203 fil.action.apply3d(scope,sprite,context,0,0);4204 }4205 submit=SubmitCMD.create([scope,context],Filter._EndTarget);4206 context.addRenderObject(submit);4207 }else {4208 tIsHaveGlowFilter=sprite._$P._isHaveGlowFilter ? sprite._$P._isHaveGlowFilter :false;4209 if (tIsHaveGlowFilter){4210 tPadding=50;4211 tHalfPadding=25;4212 }4213 b=sprite.getBounds();4214 if (b.width <=0 || b.height <=0){4215 return;4216 }4217 b.width+=tPadding;4218 b.height+=tPadding;4219 p.x=b.x *mat.a+b.y *mat.c;4220 p.y=b.y *mat.d+b.x *mat.b;4221 b.x=p.x;4222 b.y=p.y;4223 p.x=b.width *mat.a+b.height *mat.c;4224 p.y=b.height *mat.d+b.width *mat.b;4225 b.width=p.x;4226 b.height=p.y;4227 scope.addValue("out",out);4228 }4229 x=x-tHalfPadding-sprite.x;4230 y=y-tHalfPadding-sprite.y;4231 p.setTo(x,y);4232 mat.transformPoint(p);4233 x=p.x+b.x;4234 y=p.y+b.y;4235 shaderValue=Value2D.create(/*laya.webgl.shader.d2.ShaderDefines2D.TEXTURE2D*/0x01,0);4236 Matrix.TEMP.identity();4237 (context.ctx).drawTarget(scope,x,y,b.width,b.height,Matrix.TEMP,"out",shaderValue,null,BlendMode.TOINT.overlay);4238 submit=SubmitCMD.create([scope],Filter._recycleScope);4239 context.addRenderObject(submit);4240 mat.destroy();4241 }4242 }4243 Float32Array.prototype.slice || (Float32Array.prototype.slice=WebGL._float32ArraySlice);4244 Uint16Array.prototype.slice || (Uint16Array.prototype.slice=WebGL._uint16ArraySlice);4245 Uint8Array.prototype.slice || (Uint8Array.prototype.slice=WebGL._uint8ArraySlice);4246 return true;4247 }4248 WebGL.onStageResize=function(width,height){4249 if (WebGL.mainContext==null)return;4250 WebGL.mainContext.viewport(0,0,width,height);4251 RenderState2D.width=width;4252 RenderState2D.height=height;4253 }4254 WebGL.onInvalidGLRes=function(){4255 AtlasResourceManager.instance.freeAll();4256 ResourceManager.releaseContentManagers(true);4257 WebGL.doNodeRepaint(Laya.stage);4258 WebGL.mainContext.viewport(0,0,RenderState2D.width,RenderState2D.height);4259 Laya.stage.event(/*laya.events.Event.DEVICE_LOST*/"devicelost");4260 }4261 WebGL.doNodeRepaint=function(sprite){4262 (sprite.numChildren==0)&& (sprite.repaint());4263 for (var i=0;i < sprite.numChildren;i++)4264 WebGL.doNodeRepaint(sprite.getChildAt(i));4265 }4266 WebGL.init=function(canvas,width,height){4267 WebGL.mainCanvas=canvas;4268 HTMLCanvas._createContext=function (canvas){4269 return new WebGLContext2D(canvas);4270 }4271 WebGLCanvas._createContext=function (canvas){4272 return new WebGLContext2D(canvas);4273 };4274 var gl=laya.webgl.WebGL.mainContext;4275 if (gl.getShaderPrecisionFormat !=null){4276 var vertexPrecisionFormat=gl.getShaderPrecisionFormat(/*laya.webgl.WebGLContext.VERTEX_SHADER*/0x8B31,/*laya.webgl.WebGLContext.HIGH_FLOAT*/0x8DF2);4277 var framePrecisionFormat=gl.getShaderPrecisionFormat(/*laya.webgl.WebGLContext.FRAGMENT_SHADER*/0x8B30,/*laya.webgl.WebGLContext.HIGH_FLOAT*/0x8DF2);4278 WebGL.shaderHighPrecision=(vertexPrecisionFormat.precision&&framePrecisionFormat.precision)? true :false;4279 }else {4280 WebGL.shaderHighPrecision=false;4281 }4282 WebGL.compressAstc=gl.getExtension("WEBGL_compressed_texture_astc");4283 WebGL.compressAtc=gl.getExtension("WEBGL_compressed_texture_atc");4284 WebGL.compressEtc=gl.getExtension("WEBGL_compressed_texture_etc");4285 WebGL.compressEtc1=gl.getExtension("WEBGL_compressed_texture_etc1");4286 WebGL.compressPvrtc=gl.getExtension("WEBGL_compressed_texture_pvrtc");4287 WebGL.compressS3tc=gl.getExtension("WEBGL_compressed_texture_s3tc");4288 WebGL.compressS3tc_srgb=gl.getExtension("WEBGL_compressed_texture_s3tc_srgb");4289 gl.deleteTexture1=gl.deleteTexture;4290 gl.deleteTexture=function (t){4291 if (t==WebGLContext.curBindTexValue){4292 WebGLContext.curBindTexValue=null;4293 }4294 gl.deleteTexture1(t);4295 }4296 WebGL.onStageResize(width,height);4297 if (WebGL.mainContext==null)4298 throw new Error("webGL getContext err!");4299 System.__init__();4300 AtlasResourceManager.__init__();4301 ShaderDefines2D.__init__();4302 Submit.__init__();4303 WebGLContext2D.__init__();4304 Value2D.__init__();4305 Shader2D.__init__();4306 Buffer2D.__int__(gl);4307 BlendMode._init_(gl);4308 if (Render.isConchApp){4309 /*__JS__ */conch.setOnInvalidGLRes(WebGL.onInvalidGLRes);4310 }4311 }4312 WebGL.compressAstc=null;4313 WebGL.compressAtc=null;4314 WebGL.compressEtc=null;4315 WebGL.compressEtc1=null;4316 WebGL.compressPvrtc=null;4317 WebGL.compressS3tc=null;4318 WebGL.compressS3tc_srgb=null;4319 WebGL.mainCanvas=null;4320 WebGL.mainContext=null;4321 WebGL.antialias=true;4322 WebGL.shaderHighPrecision=false;4323 WebGL._bg_null=[0,0,0,0];4324 return WebGL;4325})()4326//class laya.webgl.WebGLContext4327var WebGLContext=(function(){4328 function WebGLContext(){}4329 __class(WebGLContext,'laya.webgl.WebGLContext');4330 WebGLContext.UseProgram=function(program){4331 if (WebGLContext._useProgram===program)return false;4332 WebGL.mainContext.useProgram(program);4333 WebGLContext._useProgram=program;4334 return true;4335 }4336 WebGLContext.setDepthTest=function(gl,value){4337 value!==WebGLContext._depthTest && (WebGLContext._depthTest=value,value?gl.enable(/*CLASS CONST:laya.webgl.WebGLContext.DEPTH_TEST*/0x0B71):gl.disable(/*CLASS CONST:laya.webgl.WebGLContext.DEPTH_TEST*/0x0B71));4338 }4339 WebGLContext.setDepthMask=function(gl,value){4340 value!==WebGLContext._depthMask && (WebGLContext._depthMask=value,gl.depthMask(value));4341 }4342 WebGLContext.setDepthFunc=function(gl,value){...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1function test() {2 var canvas = document.getElementById("canvas");3 var gl = canvas.getContext("webgl");4 gl.clearColor(0.0, 0.0, 0.0, 1.0);5 gl.clear(gl.COLOR_BUFFER_BIT);6}7function test() {8 var canvas = document.getElementById("canvas");9 var gl = canvas.getContext("webgl");10 gl.clearColor(0.0, 0.0, 0.0, 1.0);11 gl.clear(gl.COLOR_BUFFER_BIT);12}13var canvas = document.getElementById("canvas");14var gl = canvas.getContext("webgl");15var canvas = document.getElementById("canvas");16var gl = canvas.getContext("webgl");17var canvas = document.getElementById("canvas");18var gl = canvas.getContext("webgl");

Full Screen

Using AI Code Generation

copy

Full Screen

1var context = WebGLTestUtils.create3DContext(canvas);2var context = WebGLTestUtils.create3DContext(canvas, undefined, 2);3var context = WebGLTestUtils.create3DContext(canvas, undefined, 2, {antialias: false});4var context = WebGLTestUtils.create3DContext(canvas);5var context = WebGLTestUtils.create3DContext(canvas, undefined, 2);6var context = WebGLTestUtils.create3DContext(canvas, undefined, 2, {antialias: false});7var context = WebGLTestUtils.create3DContext(canvas);8var context = WebGLTestUtils.create3DContext(canvas, undefined, 2);9var context = WebGLTestUtils.create3DContext(canvas, undefined, 2, {antialias: false});10var context = WebGLTestUtils.create3DContext(canvas);11var context = WebGLTestUtils.create3DContext(canvas, undefined, 2);12var context = WebGLTestUtils.create3DContext(canvas, undefined, 2, {antialias: false});13var context = WebGLTestUtils.create3DContext(canvas);14var context = WebGLTestUtils.create3DContext(canvas, undefined, 2);15var context = WebGLTestUtils.create3DContext(canvas, undefined, 2, {antialias: false});16var context = WebGLTestUtils.create3DContext(canvas);17var context = WebGLTestUtils.create3DContext(canvas, undefined, 2);

Full Screen

Using AI Code Generation

copy

Full Screen

1var canvas = document.createElement("canvas");2var context = canvas.getContext("webgl");3var webglContext = context.getExtension("WEBGL_debug_renderer_info");4var vendor = context.getParameter(webglContext.UNMASKED_VENDOR_WEBGL);5var renderer = context.getParameter(webglContext.UNMASKED_RENDERER_WEBGL);6console.log("WebGL Vendor: " + vendor);7console.log("WebGL Renderer: " + renderer);8var resultsDiv = document.getElementById("results");9resultsDiv.innerHTML = "WebGL Vendor: " + vendor + "<br>WebGL Renderer: " + renderer;10var resultsDiv = document.getElementById("results");11resultsDiv.innerHTML = "WebGL Vendor: " + vendor + "<br>WebGL Renderer: " + renderer;12var resultsDiv = document.getElementById("results");13resultsDiv.innerHTML = "WebGL Vendor: " + vendor + "<br>WebGL Renderer: " + renderer;14var resultsDiv = document.getElementById("results");15resultsDiv.innerHTML = "WebGL Vendor: " + vendor + "<br>WebGL Renderer: " + renderer;16var resultsDiv = document.getElementById("results");17resultsDiv.innerHTML = "WebGL Vendor: " + vendor + "<br>WebGL Renderer: " + renderer;18var resultsDiv = document.getElementById("results");19resultsDiv.innerHTML = "WebGL Vendor: " + vendor + "<br>WebGL Renderer: " + renderer;20var resultsDiv = document.getElementById("results");21resultsDiv.innerHTML = "WebGL Vendor: " + vendor + "<br>WebGL Renderer: " + renderer;22var resultsDiv = document.getElementById("results");23resultsDiv.innerHTML = "WebGL Vendor: " + vendor + "<br>WebGL Renderer: " + renderer;24var resultsDiv = document.getElementById("results");25resultsDiv.innerHTML = "WebGL Vendor: " + vendor + "<br>WebGL Renderer: " + renderer;26var resultsDiv = document.getElementById("results");

Full Screen

Using AI Code Generation

copy

Full Screen

1var WebGLContext = require('webgl-context');2var gl = WebGLContext.create3D({width: 100, height: 100});3var canvas = document.createElement('canvas');4var gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');5var canvas = document.createElement('canvas');6var gl = canvas.getContext('webgl');7var canvas = document.createElement('canvas');8var gl = canvas.getContext('webgl', {alpha: false});9var canvas = document.createElement('canvas');10var gl = canvas.getContext('webgl', {alpha: true});11var canvas = document.createElement('canvas');12var gl = canvas.getContext('webgl', {depth: false});13var canvas = document.createElement('canvas');14var gl = canvas.getContext('webgl', {depth: true});15var canvas = document.createElement('canvas');16var gl = canvas.getContext('webgl', {stencil: false});17var canvas = document.createElement('canvas');18var gl = canvas.getContext('webgl', {stencil: true});19var canvas = document.createElement('canvas');20var gl = canvas.getContext('webgl', {antialias: false});21var canvas = document.createElement('canvas');22var gl = canvas.getContext('webgl', {antialias: true});23var canvas = document.createElement('canvas');24var gl = canvas.getContext('webgl', {premultipliedAlpha: false});25var canvas = document.createElement('canvas');26var gl = canvas.getContext('webgl', {premultipliedAlpha: true});27var canvas = document.createElement('canvas');28var gl = canvas.getContext('webgl', {preserveDrawingBuffer: false});

Full Screen

Using AI Code Generation

copy

Full Screen

1function testWebGLContext() {2 var canvas = document.getElementById("canvas");3 var gl = canvas.getContext("webgl");4 var context = new WebGLContext(gl);5 context.enable(gl.BLEND);6 context.disable(gl.BLEND);7 context.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);8 context.blendColor(0.5, 0.5, 0.5, 0.5);9 context.blendEquation(gl.FUNC_ADD);10 context.blendEquationSeparate(gl.FUNC_ADD, gl.FUNC_ADD);11 context.viewport(0, 0, 10, 10);12 context.scissor(0, 0, 10, 10);13 context.lineWidth(1.0);14 context.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 1);15 context.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1);16 context.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, gl.NONE);17 context.cullFace(gl.FRONT);18 context.frontFace(gl.CCW);19 context.enable(gl.CULL_FACE);20 context.disable(gl.CULL_FACE);21 context.enable(gl.POLYGON_OFFSET_FILL);22 context.disable(gl.POLYGON_OFFSET_FILL);23 context.polygonOffset(0.0, 0.0);24 context.activeTexture(gl.TEXTURE0);25 context.bindTexture(gl.TEXTURE_2D, gl.createTexture());26 context.bindTexture(gl.TEXTURE_CUBE_MAP, gl.createTexture());27 context.useProgram(gl.createProgram());28 context.uniform1f(gl.getUniformLocation(gl.createProgram(), "test"), 1.0);29 context.uniform1fv(gl.getUniformLocation(gl.createProgram(), "test"), new Float32Array(1));30 context.uniform1i(gl.getUniformLocation(gl.createProgram(), "test"), 1);31 context.uniform1iv(gl.getUniformLocation(gl.createProgram(), "test"), new Int32Array(1));32 context.uniform2f(gl.getUniformLocation(gl.createProgram(), "test"), 1.0, 1.0);33 context.uniform2fv(gl.getUniformLocation(gl.createProgram(), "test"), new Float32Array(2));34 context.uniform2i(gl.getUniformLocation(gl.createProgram(), "test"), 1, 1);35 context.uniform2iv(gl.getUniformLocation(gl.createProgram(), "test"), new Int32Array(2));

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = new WebGLContext();2var canvas = document.getElementById("canvas");3var gl = canvas.getContext("webgl");4var program = wpt.createProgramFromScriptTags(gl, "vertex-shader", "fragment-shader");5gl.useProgram(program);6var positionLocation = gl.getAttribLocation(program, "a_position");7var positionBuffer = gl.createBuffer();8gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);9];10gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(positions), gl.STATIC_DRAW);11gl.enableVertexAttribArray(positionLocation);12gl.vertexAttribPointer(positionLocation, 2, gl.FLOAT, false, 0, 0);13var colorLocation = gl.getAttribLocation(program, "a_color");14var colorBuffer = gl.createBuffer();15gl.bindBuffer(gl.ARRAY_BUFFER, colorBuffer);16];17gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(colors), gl.STATIC_DRAW);18gl.enableVertexAttribArray(colorLocation);19gl.vertexAttribPointer(colorLocation, 3, gl.FLOAT, false, 0, 0);20var matrixLocation = gl.getUniformLocation(program, "u_matrix");21var translation = [200, 150];22var angleInRadians = 0;23var scale = [1, 1];24drawScene();25webglLessonsUI.setupSlider("#x", {value: translation[0], slide: updatePosition(0), max: gl.canvas.width});26webglLessonsUI.setupSlider("#y", {value: translation[1], slide: updatePosition(1), max: gl.canvas.height});27webglLessonsUI.setupSlider("#angle", {slide: updateAngle, max: 360});28webglLessonsUI.setupSlider("#scaleX", {value: scale[0], slide: updateScale(0), max: 2, min: -2, step: .01, precision: 2});29webglLessonsUI.setupSlider("#scaleY", {value: scale[1], slide: updateScale(1), max: 2, min

Full Screen

Using AI Code Generation

copy

Full Screen

1var canvas = document.createElement('canvas');2var gl = canvas.getContext('webgl');3var context = gl.getContextAttributes();4if (context.alpha == false) {5 testPassed('getContextAttributes() returns false for alpha');6} else {7 testFailed('getContextAttributes() returns true for alpha');8}9finishJSTest();

Full Screen

Using AI Code Generation

copy

Full Screen

1var wtu = WebGLTestUtils;2var gl = null;3var successfullyParsed = false;4var canvas = null;5function runTest()6{7 debug("");8 debug("This test verifies that WebGL compiles shaders with array of structs.");9 debug("");10 canvas = document.createElement("canvas");11 canvas.width = 1;12 canvas.height = 1;13 document.body.appendChild(canvas);14 gl = wtu.create3DContext(canvas);15 if (!gl) {16 testFailed("WebGL context does not exist");17 return;18 }19 var program = gl.createProgram();20 var vshader = gl.createShader(gl.VERTEX_SHADER);21 var fshader = gl.createShader(gl.FRAGMENT_SHADER);22 var vshaderSource = "attribute vec4 a_position;23void main(void) {24 gl_Position = a_position;25}26";27 var fshaderSource = "precision mediump float;28void main(void) {29 gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);30}31";32 gl.shaderSource(vshader, vshaderSource);33 gl.compileShader(vshader);34 if (!gl.getShaderParameter(vshader, gl.COMPILE_STATUS)) {35 testFailed("Vertex shader failed to compile");36 return;37 }38 gl.shaderSource(fshader, fshaderSource);39 gl.compileShader(fshader);40 if (!gl.getShaderParameter(fshader, gl.COMPILE_STATUS)) {41 testFailed("Fragment shader failed to compile");42 return;43 }44 gl.attachShader(program, vshader);45 gl.attachShader(program, fshader);46 gl.linkProgram(program);47 if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {48 testFailed("Program failed to link");

Full Screen

Using AI Code Generation

copy

Full Screen

1function testWebGL() {2 if (wpt.webglEnabled()) {3 var canvas = document.createElement("canvas");4 var gl = canvas.getContext("webgl");5 if (gl) {6 return true;7 }8 }9 return false;10}11function testWebGL() {12 if (wpt.webglEnabled()) {13 var canvas = document.createElement("canvas");14 var gl = canvas.getContext("webgl");15 if (gl) {16 return true;17 }18 }19 return false;20}21function testWebGL() {22 if (wpt.webglEnabled()) {23 var canvas = document.createElement("canvas");24 var gl = canvas.getContext("webgl");25 if (gl) {26 return true;27 }28 }29 return false;30}31function testWebGL() {32 if (wpt.webglEnabled()) {33 var canvas = document.createElement("canvas");34 var gl = canvas.getContext("webgl");35 if (gl) {36 return true;37 }38 }39 return false;40}41function testWebGL() {42 if (wpt.webglEnabled()) {

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful