本文整理汇总了C#中WebGLRenderingContext.disableVertexAttribArray方法的典型用法代码示例。如果您正苦于以下问题:C# WebGLRenderingContext.disableVertexAttribArray方法的具体用法?C# WebGLRenderingContext.disableVertexAttribArray怎么用?C# WebGLRenderingContext.disableVertexAttribArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebGLRenderingContext
的用法示例。
在下文中一共展示了WebGLRenderingContext.disableVertexAttribArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Application
//.........这里部分代码省略.........
left, bottom,
// right top
//right, -1.0f,
right, bottom,
// left bottom
left, top,
// right top
//right, -1.0f,
right, bottom,
// right bottom
//right, 1.0f,
right, top,
// left bottom
left,top
};
var vertices = new Float32Array(fvertices);
#endregion
gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW);
gl.vertexAttribPointer(vec2pos, 2, gl.FLOAT, false, 0, 0);
gl.enableVertexAttribArray(vec2pos);
// GL ERROR :GL_INVALID_OPERATION : glDrawArrays: attempt to render with no buffer attached to enabled attribute 1
gl.drawArrays(gl.TRIANGLES, 0, 6);
// first frame is now visible
gl.disableVertexAttribArray(vec2pos);
gl.bindBuffer(gl.ARRAY_BUFFER, null);
#endregion
//mFrame++;
};
#endregion
Paint_Image(
sw.ElapsedMilliseconds / 1000.0f,
0,
0,
0,
0
);
gl.flush();
//// INVALID_OPERATION: generateMipmap: level 0 not power of 2 or not all the same size
gl.bindTexture(gl.TEXTURE_2D, xWebGLTexture);
gl.generateMipmap(gl.TEXTURE_2D);
gl.bindTexture(gl.TEXTURE_2D, null);
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
#endregion
gl.clearColor(0, 0, 1, 1.0f);
gl.viewport(0, 0, gl.canvas.width, gl.canvas.height);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
示例2: Application
//.........这里部分代码省略.........
// http://www.html5rocks.com/en/tutorials/webgl/webgl_fundamentals/
//gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
gl.viewport(0, 0, viewportxres, viewportyres);
// alpha to zero will only hide the pixel if blending is enabled.
gl.useProgram(mProgram);
// uniform4fv
var mouse = new[] { mousePosX, mousePosY, mouseOriX, mouseOriY };
var l2 = gl.getUniformLocation(mProgram, "iGlobalTime"); if (l2 != null) gl.uniform1f(l2, time);
var l3 = gl.getUniformLocation(mProgram, "iResolution"); if (l3 != null) gl.uniform3f(l3, viewportxres, viewportyres, 1.0f);
var l4 = gl.getUniformLocation(mProgram, "iMouse"); if (l4 != null) gl.uniform4fv(l4, mouse);
//var l7 = gl.getUniformLocation(this.mProgram, "iDate"); if (l7 != null) gl.uniform4fv(l7, dates);
//var l9 = gl.getUniformLocation(this.mProgram, "iSampleRate"); if (l9 != null) gl.uniform1f(l9, this.mSampleRate);
var ich0 = gl.getUniformLocation(mProgram, "iChannel0"); if (ich0 != null) gl.uniform1i(ich0, 0);
var ich1 = gl.getUniformLocation(mProgram, "iChannel1"); if (ich1 != null) gl.uniform1i(ich1, 1);
var ich2 = gl.getUniformLocation(mProgram, "iChannel2"); if (ich2 != null) gl.uniform1i(ich2, 2);
var ich3 = gl.getUniformLocation(mProgram, "iChannel3"); if (ich3 != null) gl.uniform1i(ich3, 3);
//for (var i = 0; i < mInputs.Length; i++)
//{
// var inp = mInputs[i];
// gl.activeTexture((uint)(gl.TEXTURE0 + i));
// if (inp == null)
// {
// gl.bindTexture(gl.TEXTURE_2D, null);
// }
//}
var times = new[] { 0.0f, 0.0f, 0.0f, 0.0f };
var l5 = gl.getUniformLocation(mProgram, "iChannelTime");
if (l5 != null) gl.uniform1fv(l5, times);
var resos = new float[12] { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f };
var l8 = gl.getUniformLocation(mProgram, "iChannelResolution");
if (l8 != null) gl.uniform3fv(l8, resos);
// using ?
var l1 = (uint)gl.getAttribLocation(mProgram, "pos");
gl.bindBuffer(gl.ARRAY_BUFFER, quadVBO);
gl.vertexAttribPointer(l1, 2, gl.FLOAT, false, 0, 0);
gl.enableVertexAttribArray(l1);
gl.drawArrays(gl.TRIANGLES, 0, 6);
// first frame is now visible
gl.disableVertexAttribArray(l1);
#endregion
//mFrame++;
};
#endregion
var sw = Stopwatch.StartNew();
do
{
pass1.Paint_Image(
sw.ElapsedMilliseconds / 1000.0f,
mMouseOriX,
mMouseOriY,
mMousePosX,
mMousePosY,
zoom: 1.0f
);
pass0.Paint_Image(
sw.ElapsedMilliseconds / 1000.0f,
mMouseOriX,
mMouseOriY,
mMousePosX,
mMousePosY,
//zoom: 0.5f
zoom: mMousePosX / (float)c.width
);
// what does it do?
gl.flush();
}
while (await Native.window.async.onframe);
}
);
}
示例3: Application
//.........这里部分代码省略.........
var textureLocation = default(WebGLUniformLocation);
#region resize
Action resize = delegate
{
canvas.style.SetLocation(0, 0);
canvas.width = Native.window.Width;
canvas.height = Native.window.Height;
parameters_screenWidth = canvas.width;
parameters_screenHeight = canvas.height;
gl.viewport(0, 0, canvas.width, canvas.height);
};
Native.window.onresize +=
delegate
{
if (IsDisposed)
return;
resize();
};
resize();
#endregion
Native.window.onframe +=
delegate
{
if (IsDisposed)
return;
if (program == null) return;
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
// Load program into GPU
// Get var locations
vertexPositionLocation = gl.getAttribLocation(program, "position");
textureLocation = gl.getUniformLocation(program, "texture");
// Set values to program variables
var program_uniforms = program.Uniforms(gl);
var resolution = new __vec2 { x = parameters_screenWidth, y = parameters_screenHeight };
program_uniforms.time = time.ElapsedMilliseconds / 1000f;
// could the uniform accept anonymous type and infer vec2 based on x and y?
program_uniforms.resolution = resolution;
//gl.uniform1f(gl.getUniformLocation(program, "time"), parameters_time / 1000);
//gl.uniform2f(gl.getUniformLocation(program, "resolution"), parameters_screenWidth, parameters_screenHeight);
gl.uniform1i(textureLocation, 0);
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(gl.TEXTURE_2D, texture);
// Render geometry
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
gl.vertexAttribPointer((uint)vertexPositionLocation, 2, gl.FLOAT, false, 0, 0);
gl.enableVertexAttribArray((uint)vertexPositionLocation);
gl.drawArrays(gl.TRIANGLES, 0, 6);
gl.disableVertexAttribArray((uint)vertexPositionLocation);
};
#region requestFullscreen
Native.document.body.ondblclick +=
delegate
{
if (IsDisposed)
return;
// http://tutorialzine.com/2012/02/enhance-your-website-fullscreen-api/
Native.document.body.requestFullscreen();
};
#endregion
}