当前位置: 首页>>代码示例>>C#>>正文


C# WebGLRenderingContext.blendFunc方法代码示例

本文整理汇总了C#中WebGLRenderingContext.blendFunc方法的典型用法代码示例。如果您正苦于以下问题:C# WebGLRenderingContext.blendFunc方法的具体用法?C# WebGLRenderingContext.blendFunc怎么用?C# WebGLRenderingContext.blendFunc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WebGLRenderingContext的用法示例。


在下文中一共展示了WebGLRenderingContext.blendFunc方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Application


//.........这里部分代码省略.........
            #region drawScene
            Action drawScene = delegate
            {


                gl.viewport(0, 0, gl_viewportWidth, gl_viewportWidth);
                gl.useProgram(prog);


                gl.uniformMatrix4fv(gl.getUniformLocation(prog, "prMatrix"),
   false, new Float32Array(prMatrix.getAsArray()));

                rotMat.rotate(xRot / 5, 1, 0, 0);
                rotMat.rotate(yRot / 5, 0, 1, 0);

                yRot = 0;
                xRot = 0;

                gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);

                gl.uniform4f(colorLoc, 1, 1, 0, 1);

                drawBall(1, 1, 1); drawBall(-1, 1, 1); drawBall(1, -1, 1);
                drawBall(1, 1, -1); drawBall(-1, -1, 1); drawBall(-1, 1, -1);
                drawBall(1, -1, -1); drawBall(-1, -1, -1);

                mvMatrix.load(rotMat);
                mvMatrix.translate(0, 0, transl);

                gl.uniformMatrix4fv(mvMatLoc, false,
                  new Float32Array(mvMatrix.getAsArray()));

                gl.enable(gl.BLEND);
                gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
                gl.uniform4f(colorLoc, .0f, .0f, .9f, .7f);
                gl.depthMask(false);
                gl.drawElements(gl.TRIANGLES, 36, gl.UNSIGNED_SHORT, 0);
                gl.depthMask(true);
                gl.disable(gl.BLEND);



                gl.useProgram(line_prog);

                gl.uniformMatrix4fv(gl.getUniformLocation(line_prog, "prMatrix"),
   false, new Float32Array(prMatrix.getAsArray()));

                gl.uniformMatrix4fv(mvMatLineLoc, false,
                  new Float32Array(mvMatrix.getAsArray()));
                gl.drawArrays(gl.LINES, 0, 24);

                gl.flush();
            };
            #endregion


            drawScene();



            #region AtResize
            Action AtResize = delegate
            {
                gl_viewportWidth = Native.window.Width;
                gl_viewportHeight = Native.window.Height;
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:66,代码来源:Application.cs

示例2: Application


//.........这里部分代码省略.........
                    canvas.height = gl_viewportHeight;
                };

            Native.window.onresize +=
                e =>
                {
                    AtResize();
                };
            AtResize();
            #endregion



            new HTML.Images.FromAssets.star().InvokeOnComplete(
               texture_image =>
               {
                   var starTexture = gl.createTexture();

                   #region handleLoadedTexture
                   gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 1);
                   gl.bindTexture(gl.TEXTURE_2D, starTexture);
                   gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texture_image);
                   gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, (int)gl.LINEAR);
                   gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, (int)gl.LINEAR);

                   gl.bindTexture(gl.TEXTURE_2D, null);
                   #endregion

                   #region drawStar
                   Action drawStar = () =>
                   {
                       gl.activeTexture(gl.TEXTURE0);
                       gl.bindTexture(gl.TEXTURE_2D, starTexture);
                       gl.uniform1i(shaderProgram_samplerUniform, 0);

                       gl.bindBuffer(gl.ARRAY_BUFFER, starVertexTextureCoordBuffer);
                       gl.vertexAttribPointer((uint)shaderProgram_textureCoordAttribute, starVertexTextureCoordBuffer_itemSize, gl.FLOAT, false, 0, 0);

                       gl.bindBuffer(gl.ARRAY_BUFFER, starVertexPositionBuffer);
                       gl.vertexAttribPointer((uint)shaderProgram_vertexPositionAttribute, starVertexPositionBuffer_itemSize, gl.FLOAT, false, 0, 0);

                       setMatrixUniforms();
                       gl.drawArrays(gl.TRIANGLE_STRIP, 0, starVertexPositionBuffer_numItems);
                   };
                   #endregion

                   #region drawScene
                   Action drawScene = delegate
                   {
                       gl.viewport(0, 0, gl_viewportWidth, gl_viewportHeight);
                       gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);

                       glMatrix.mat4.perspective(45, gl_viewportWidth / gl_viewportHeight, 0.1f, 100.0f, pMatrix);

                       gl.blendFunc(gl.SRC_ALPHA, gl.ONE);
                       gl.enable(gl.BLEND);

                       glMatrix.mat4.identity(mvMatrix);
                       glMatrix.mat4.translate(mvMatrix, new f[] {0.0f, 0.0f, zoom});
                       glMatrix.mat4.rotate(mvMatrix, degToRad(tilt),new f[] { 1.0f, 0.0f, 0.0f});

                       //var twinkle = document.getElementById("twinkle").checked;
                       var twinkle = false;

                       foreach (var star in stars)
                       {
                           star.draw(
                               tilt,
                               spin,
                               twinkle,
                               mvPushMatrix,
                               mvPopMatrix,
                               mvMatrix,
                               drawStar,
                               shaderProgram_colorUniform,
                               gl


                               );
                           spin += 0.1f;
                       }

                   };
                   #endregion


                   Native.window.onframe += delegate
                   {
                       if (IsDisposed)
                           return;

                       handleKeys();
                       drawScene();
                       animate();

                   };

               }
            );
        }
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:101,代码来源:Application.cs

示例3: Application


//.........这里部分代码省略.........

                        glMatrix.mat4.perspective(45f, (float)gl_viewportWidth / (float)gl_viewportHeight, 0.1f, 100.0f, pMatrix);

                        glMatrix.mat4.identity(mvMatrix);


                        glMatrix.mat4.translate(mvMatrix, new float[] { 0.0f, 0.0f, z });

                        glMatrix.mat4.rotate(mvMatrix, degToRad(xRot), new[] { 1f, 0f, 0f });
                        glMatrix.mat4.rotate(mvMatrix, degToRad(yRot), new[] { 0f, 1f, 0f });


                        gl.bindBuffer(gl.ARRAY_BUFFER, cubeVertexPositionBuffer);
                        gl.vertexAttribPointer((uint)shaderProgram_vertexPositionAttribute, cubeVertexPositionBuffer_itemSize, gl.FLOAT, false, 0, 0);

                        #region new in lesson 07
                        gl.bindBuffer(gl.ARRAY_BUFFER, cubeVertexNormalBuffer);
                        gl.vertexAttribPointer((uint)shaderProgram_vertexNormalAttribute, cubeVertexNormalBuffer_itemSize, gl.FLOAT, false, 0, 0);
                        #endregion

                        gl.bindBuffer(gl.ARRAY_BUFFER, cubeVertexTextureCoordBuffer);
                        gl.vertexAttribPointer((uint)shaderProgram_textureCoordAttribute, cubeVertexTextureCoordBuffer_itemSize, gl.FLOAT, false, 0, 0);


                        gl.activeTexture(gl.TEXTURE0);
                        gl.bindTexture(gl.TEXTURE_2D, textures[filter]);
                        gl.uniform1i(shaderProgram_samplerUniform, 0);

                        #region new in lesson 08

                        var blending = [email protected];
                        if (blending)
                        {
                            gl.blendFunc(gl.SRC_ALPHA, gl.ONE);
                            gl.enable(gl.BLEND);
                            gl.disable(gl.DEPTH_TEST);
                            gl.uniform1f(shaderProgram_alphaUniform, toolbar.alpha);
                        }
                        else
                        {
                            gl.disable(gl.BLEND);
                            gl.enable(gl.DEPTH_TEST);
                        }

                        #endregion


                        var lighting = [email protected];
                        gl.uniform1i(shaderProgram_useLightingUniform, lighting.ToInt32());
                        if (lighting)
                        {
                            gl.uniform3f(
                                shaderProgram_ambientColorUniform,
                                toolbar.ambientR,
                                toolbar.ambientG,
                                toolbar.ambientB
                            );

                            var lightingDirection = new float []{
                                toolbar.lightDirectionX,
                                toolbar.lightDirectionY,
                                toolbar.lightDirectionZ
                            };
                            var adjustedLD = glMatrix.vec3.create();
                            glMatrix.vec3.normalize(lightingDirection, adjustedLD);
                            glMatrix.vec3.scale(adjustedLD, new f[] {-1});
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:67,代码来源:Application.cs


注:本文中的WebGLRenderingContext.blendFunc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。