本文整理汇总了C#中WebGLRenderingContext.getProgramParameter方法的典型用法代码示例。如果您正苦于以下问题:C# WebGLRenderingContext.getProgramParameter方法的具体用法?C# WebGLRenderingContext.getProgramParameter怎么用?C# WebGLRenderingContext.getProgramParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebGLRenderingContext
的用法示例。
在下文中一共展示了WebGLRenderingContext.getProgramParameter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateShader
static CreateShaderResult CreateShader(
WebGLRenderingContext gl,
string tvs,
string tfs,
bool nativeDebug
)
{
//new IHTMLPre { "enter CreateShader" }.AttachToDocument();
//var p = gl.createProgram();
var vs = new WebGLShader(gl, gl.VERTEX_SHADER);
var fs = new WebGLShader(gl, gl.FRAGMENT_SHADER);
gl.shaderSource(vs, tvs);
gl.shaderSource(fs, tfs);
gl.compileShader(vs);
var ok = new CreateShaderResult { mSuccess = true };
// https://www.khronos.org/registry/webgl/extensions/WEBGL_debug_shaders/
new WebGLDebugShaders(gl).With(x => ok.vsTranslatedShaderSource = x.getTranslatedShaderSource(vs));
//gl.getExtension("WEBGL_debug_shaders").With(
//(dynamic WEBGL_debug_shaders) =>
// {
// ok.vsTranslatedShaderSource = WEBGL_debug_shaders.getTranslatedShaderSource((WebGLShader)vs);
// }
//);
gl.compileShader(fs);
// ipad wont have it available
new WebGLDebugShaders(gl).With(x => ok.fsTranslatedShaderSource = x.getTranslatedShaderSource(fs));
//gl.getExtension("WEBGL_debug_shaders").With(
// (dynamic WEBGL_debug_shaders) =>
// {
// ok.fsTranslatedShaderSource = WEBGL_debug_shaders.getTranslatedShaderSource((WebGLShader)fs);
// }
//);
if (gl.getShaderParameter(vs, gl.COMPILE_STATUS) == null)
{
var infoLog = gl.getShaderInfoLog(vs);
// does our async rewriter throw async exceptions yet?
throw new Exception(message: new { infoLog }.ToString());
//new IHTMLPre { "error CreateShader " + new { infoLog } }.AttachToDocument();
//return new CreateShaderResult { mSuccess = false, mInfo = infoLog };
}
var fsCOMPILE_STATUS = (bool)gl.getShaderParameter(fs, gl.COMPILE_STATUS);
//new IHTMLPre { "CreateShader " + new { fsCOMPILE_STATUS } }.AttachToDocument();
if (!fsCOMPILE_STATUS)
{
var infoLog = gl.getShaderInfoLog(fs);
throw new Exception(message: new { infoLog }.ToString());
//new IHTMLPre { "error CreateShader " + new { infoLog } }.AttachToDocument();
//return new CreateShaderResult { mSuccess = false, mInfo = infoLog };
}
var p = new WebGLProgram(gl);
gl.attachShader(p, vs);
gl.attachShader(p, fs);
// using dispose?
gl.deleteShader(vs);
gl.deleteShader(fs);
gl.linkProgram(p);
var linkResult = (bool)gl.getProgramParameter(p, gl.LINK_STATUS);
//new IHTMLPre { "CreateShader " + new { linkResult } }.AttachToDocument();
if (!linkResult)
{
var infoLog = gl.getProgramInfoLog(p);
gl.deleteProgram(p);
throw new Exception(message: new { infoLog }.ToString());
//new IHTMLPre { "error CreateShader " + new { infoLog } }.AttachToDocument();
//return new CreateShaderResult { mSuccess = false, mInfo = infoLog };
}
// https://msdn.microsoft.com/en-us/library/ie/dn302415(v=vs.85).aspx
//new IHTMLPre { "exit CreateShader" }.AttachToDocument();
ok.mProgram = p;
return ok;
}
示例2: Initialize
private void Initialize(IHTMLCanvas c, WebGLRenderingContext gl, IDefault page)
{
// http://cs.helsinki.fi/u/ilmarihe/metatunnel.html
// http://wakaba.c3.cx/w/puls.html
Action<string> alert = Native.window.alert;
c.style.border = "1px solid yellow";
page.MaxTextures.innerText = "" + gl.getParameter(gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
// https://www.khronos.org/webgl/public-mailing-list/archives/1007/msg00034.html
var vs = "";
vs += "precision highp float; \n";
vs += "attribute vec3 aVertexPosition;";
vs += "attribute vec2 aTextureCoord;";
vs += "uniform mat4 uModelViewMatrix;";
vs += "uniform mat4 uProjectionMatrix;";
vs += "varying vec2 vTextureCoord;";
vs += "void main(void) {";
vs += "gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(aVertexPosition, 1.0);";
vs += "vTextureCoord = vec2(aTextureCoord.x, 1.0 - aTextureCoord.y);";
vs += "}";
var fs = "";
fs += "precision highp float; \n";
fs += "varying vec2 vTextureCoord;";
fs += "uniform sampler2D uSamplerDiffuse1;";
fs += "uniform sampler2D uSamplerDiffuse2;";
fs += "uniform sampler2D uSamplerDiffuse3;";
fs += "uniform sampler2D uSamplerDiffuse4;";
fs += "uniform sampler2D uSamplerDiffuse5;";
fs += "uniform sampler2D uSamplerDiffuse6;";
fs += "void main(void) {";
fs += "gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0) * texture2D(uSamplerDiffuse1, vTextureCoord)";
fs += "+ vec4(0.0, 1.0, 0.0, 1.0) * texture2D(uSamplerDiffuse2, vTextureCoord)";
fs += "+ vec4(0.0, 0.0, 1.0, 1.0) * texture2D(uSamplerDiffuse3, vTextureCoord)";
fs += "+ vec4(0.0, 1.0, 1.0, 1.0) * texture2D(uSamplerDiffuse4, vTextureCoord)";
fs += "+ vec4(1.0, 0.0, 1.0, 1.0) * texture2D(uSamplerDiffuse5, vTextureCoord)";
fs += "+ vec4(1.0, 1.0, 0.0, 1.0) * texture2D(uSamplerDiffuse6, vTextureCoord);";
fs += "}";
var xfs = gl.createShader(gl.FRAGMENT_SHADER);
gl.shaderSource(xfs, fs);
gl.compileShader(xfs);
if ((int)gl.getShaderParameter(xfs, gl.COMPILE_STATUS) != 1)
{
// vs: ERROR: 0:2: '' : Version number not supported by ESSL
// fs: ERROR: 0:1: '' : No precision specified for (float)
var error = gl.getShaderInfoLog(xfs);
Native.window.alert("fs: " + error);
return;
}
var xvs = gl.createShader(gl.VERTEX_SHADER);
gl.shaderSource(xvs, vs);
gl.compileShader(xvs);
if ((int)gl.getShaderParameter(xvs, gl.COMPILE_STATUS) != 1)
{
// vs: ERROR: 0:2: '' : Version number not supported by ESSL
// vs: ERROR: 0:10: '-' : wrong operand types no operation '-' exists that takes a left-hand operand of type 'const mediump int' and a right operand of type 'float' (or there is no acceptable conversion)
var error = gl.getShaderInfoLog(xvs);
Native.window.alert("vs: " + error);
return;
}
var shader = new foo();
shader.program = gl.createProgram();
gl.attachShader(shader.program, xvs);
gl.attachShader(shader.program, xfs);
gl.linkProgram(shader.program);
var linked = gl.getProgramParameter(shader.program, gl.LINK_STATUS);
if (linked == null)
{
var error = gl.getProgramInfoLog(shader.program);
Native.window.alert("Error while linking: " + error);
return;
}
gl.useProgram(shader.program);
shader.aVertexPosition = gl.getAttribLocation(shader.program, "aVertexPosition");
shader.aTextureCoord = gl.getAttribLocation(shader.program, "aTextureCoord");
gl.enableVertexAttribArray((uint)shader.aVertexPosition);
gl.enableVertexAttribArray((uint)shader.aTextureCoord);
shader.u["uModelViewMatrix"] = gl.getUniformLocation(shader.program, "uModelViewMatrix");
shader.u["uProjectionMatrix"] = gl.getUniformLocation(shader.program, "uProjectionMatrix");
shader.u["uSamplerDiffuse1"] = gl.getUniformLocation(shader.program, "uSamplerDiffuse1");
shader.u["uSamplerDiffuse2"] = gl.getUniformLocation(shader.program, "uSamplerDiffuse2");
shader.u["uSamplerDiffuse3"] = gl.getUniformLocation(shader.program, "uSamplerDiffuse3");
//.........这里部分代码省略.........