本文整理汇总了C#中WebGLRenderingContext.uniform3fv方法的典型用法代码示例。如果您正苦于以下问题:C# WebGLRenderingContext.uniform3fv方法的具体用法?C# WebGLRenderingContext.uniform3fv怎么用?C# WebGLRenderingContext.uniform3fv使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebGLRenderingContext
的用法示例。
在下文中一共展示了WebGLRenderingContext.uniform3fv方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
);
}
示例2: Application
//.........这里部分代码省略.........
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, xres, yres, 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);
// what if there are other textures too?
// X:\jsc.svn\examples\javascript\chrome\apps\WebGL\ChromeWebGLFrameBuffer\ChromeWebGLFrameBuffer\Application.cs
//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 vec2pos = (uint)gl.getAttribLocation(mProgram, "pos");
//gl.bindBuffer(gl.ARRAY_BUFFER, quadVBO);
gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
#region vertices
float left = -1.0f;
// y reversed?
float bottom = -1.0f;
float right = 1.0f;
float top = 1.0f;
var fvertices =
new float[]
{
// left top
left, bottom,
// right top
//right, -1.0f,
right, bottom,
// left bottom
left, top,
// right top
//right, -1.0f,
示例3: Application
//.........这里部分代码省略.........
#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 07
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});
gl.uniform3fv(shaderProgram_lightingDirectionUniform, adjustedLD);
gl.uniform3f(
shaderProgram_directionalColorUniform,
toolbar.directionalR,
toolbar.directionalG,
toolbar.directionalB
);
}
#endregion
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, cubeVertexIndexBuffer);
setMatrixUniforms();
gl.drawElements(gl.TRIANGLES, cubeVertexIndexBuffer_numItems, gl.UNSIGNED_SHORT, 0);
};
drawScene();
#endregion
#region handleKeys
Action handleKeys =
delegate
{
if (currentlyPressedKeys[33])
{
// Page Up
z -= 0.05f;
}
示例4: Application
//.........这里部分代码省略.........
gl.clearColor(0.0f, 0.0f, 0.0f, 1.0f);
gl.enable(gl.DEPTH_TEST);
#region drawScene
Action drawScene = () =>
{
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);
var lighting = [email protected];
#region [uniform] bool uUseLighting <- lighting
gl.uniform1i(shaderProgram_useLightingUniform, Convert.ToInt32(lighting));
#endregion
if (lighting)
{
#region [uniform] vec3 uAmbientColor <- (f ambientR, f ambientG, f ambientB)
gl.uniform3f(
shaderProgram_ambientColorUniform,
float.Parse(toolbar.ambientR.value),
float.Parse(toolbar.ambientG.value),
float.Parse(toolbar.ambientB.value)
);
#endregion
var lightingDirection = new[]{
float.Parse(toolbar.lightDirectionX.value),
float.Parse(toolbar.lightDirectionY.value),
float.Parse(toolbar.lightDirectionZ.value)
};
var adjustedLD = glMatrix.vec3.create();
glMatrix.vec3.normalize(lightingDirection, adjustedLD);
glMatrix.vec3.scale(adjustedLD, new f[] { -1 });
#region [uniform] vec3 uLightingDirection <- vec3
gl.uniform3fv(shaderProgram_lightingDirectionUniform, adjustedLD);
#endregion
#region [uniform] vec3 uDirectionalColor <- (f directionalR, f directionalG, f directionalB)
gl.uniform3f(
shaderProgram_directionalColorUniform,
float.Parse(toolbar.directionalR.value),
float.Parse(toolbar.directionalG.value),
float.Parse(toolbar.directionalB.value)
);
#endregion
}
glMatrix.mat4.identity(mvMatrix);
glMatrix.mat4.translate(mvMatrix, new f[] { 0, 0, -6 });
glMatrix.mat4.multiply(mvMatrix, moonRotationMatrix);
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(gl.TEXTURE_2D, moonTexture);
gl.uniform1i(shaderProgram_samplerUniform, 0);
gl.bindBuffer(gl.ARRAY_BUFFER, moonVertexPositionBuffer);
gl.vertexAttribPointer((uint)shaderProgram_vertexPositionAttribute, moonVertexPositionBuffer_itemSize, gl.FLOAT, false, 0, 0);
gl.bindBuffer(gl.ARRAY_BUFFER, moonVertexTextureCoordBuffer);
gl.vertexAttribPointer((uint)shaderProgram_textureCoordAttribute, moonVertexTextureCoordBuffer_itemSize, gl.FLOAT, false, 0, 0);
gl.bindBuffer(gl.ARRAY_BUFFER, moonVertexNormalBuffer);
gl.vertexAttribPointer((uint)shaderProgram_vertexNormalAttribute, moonVertexNormalBuffer_itemSize, gl.FLOAT, false, 0, 0);
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, moonVertexIndexBuffer);
setMatrixUniforms();
gl.drawElements(gl.TRIANGLES, moonVertexIndexBuffer_numItems, gl.UNSIGNED_SHORT, 0);
};
#endregion
Native.window.onframe += delegate
{
if (IsDisposed)
return;
RotateAtDelta(1, 1);
drawScene();
};
}
);
}