本文整理汇总了C#中WebGLRenderingContext.generateMipmap方法的典型用法代码示例。如果您正苦于以下问题:C# WebGLRenderingContext.generateMipmap方法的具体用法?C# WebGLRenderingContext.generateMipmap怎么用?C# WebGLRenderingContext.generateMipmap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebGLRenderingContext
的用法示例。
在下文中一共展示了WebGLRenderingContext.generateMipmap方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Application
//.........这里部分代码省略.........
};
Native.Document.onkeyup +=
e =>
{
currentlyPressedKeys[e.KeyCode] = false;
};
#endregion
new WebGLLesson07.HTML.Images.FromAssets.crate().InvokeOnComplete(
texture_image =>
{
#region handleLoadedTexture
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 1);
gl.bindTexture(gl.TEXTURE_2D, textures[0]);
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.NEAREST);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, (int)gl.NEAREST);
gl.bindTexture(gl.TEXTURE_2D, textures[1]);
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, textures[2]);
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_MIPMAP_NEAREST);
gl.generateMipmap(gl.TEXTURE_2D);
gl.bindTexture(gl.TEXTURE_2D, null);
#endregion
gl.clearColor(0.0f, 0.0f, 0.0f, 1.0f);
gl.enable(gl.DEPTH_TEST);
#region animate
var lastTime = 0L;
Action animate = delegate
{
var timeNow = new IDate().getTime();
if (lastTime != 0)
{
var elapsed = timeNow - lastTime;
xRot += (xSpeed * elapsed) / 1000.0f;
yRot += (ySpeed * elapsed) / 1000.0f;
}
lastTime = timeNow;
};
#endregion
Func<float, float> degToRad = (degrees) =>
{
示例2: InitializeContent
//.........这里部分代码省略.........
#region setMatrixUniforms
Action setMatrixUniforms =
delegate
{
#region [uniform] mat4 uPMatrix <- pMatrix
gl.uniformMatrix4fv(currentProgram.pMatrixUniform, false, pMatrix);
#endregion
#region [uniform] mat4 uMVMatrix <- mvMatrix
gl.uniformMatrix4fv(currentProgram.mvMatrixUniform, false, mvMatrix);
#endregion
var normalMatrix = glMatrix.mat3.create();
glMatrix.mat4.toInverseMat3(mvMatrix, normalMatrix);
glMatrix.mat3.transpose(normalMatrix);
#region [uniform] mat3 uNMatrix <- normalMatrix
gl.uniformMatrix3fv(currentProgram.nMatrixUniform, false, normalMatrix);
#endregion
};
#endregion
#region handleLoadedTexture
Action<WebGLTexture, IHTMLImage> handleLoadedTexture = (texture, texture_image) =>
{
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 1);
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texture_image);
gl.texParameteri((uint)gl.TEXTURE_2D, (uint)gl.TEXTURE_MAG_FILTER, (int)gl.LINEAR);
gl.texParameteri((uint)gl.TEXTURE_2D, (uint)gl.TEXTURE_MIN_FILTER, (int)gl.LINEAR_MIPMAP_NEAREST);
// INVALID_OPERATION: generateMipmap: level 0 not power of 2 or not all the same size
gl.generateMipmap(gl.TEXTURE_2D);
gl.bindTexture(gl.TEXTURE_2D, null);
};
#endregion
var crateTexture = gl.createTexture();
handleLoadedTexture(crateTexture, crate);
var moonTexture = gl.createTexture();
handleLoadedTexture(moonTexture, moon);
#region initTextureFramebuffer
var rttFramebuffer = gl.createFramebuffer();
gl.bindFramebuffer(gl.FRAMEBUFFER, rttFramebuffer);
var rttFramebuffer_width = 512;
var rttFramebuffer_height = 512;
var rttTexture = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, rttTexture);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, (int)gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, (int)gl.LINEAR_MIPMAP_NEAREST);
gl.generateMipmap(gl.TEXTURE_2D);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, rttFramebuffer_width, rttFramebuffer_height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
var renderbuffer = gl.createRenderbuffer();
gl.bindRenderbuffer(gl.RENDERBUFFER, renderbuffer);
gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, rttFramebuffer_width, rttFramebuffer_height);
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, rttTexture, 0);
示例3: Application
//.........这里部分代码省略.........
// initTexture new in lesson 05
var tex0 = gl.createTexture();
var tex0i = new WebGLSVGAnonymous.HTML.Images.FromAssets.Anonymous_LogosSingleWings();
//var tex0i = new WebGLSVGAnonymous.HTML.Images.FromAssets.nehe();
// WebGL: drawElements: texture bound to texture unit 0 is not renderable. It maybe non-power-of-2 and have incompatible texture filtering or is not 'texture complete'. Or the texture is Float or Half Float type with linear filtering while OES_float_linear or OES_half_float_linear extension is not enabled.
tex0i.width = 1024 * 2;
tex0i.height = 1024 * 2;
tex1i.InvokeOnComplete(
delegate
{
tex0i.InvokeOnComplete(
delegate
{
// this is a workaround
// chrome has a bug where svg textures are merged..
var tex1ii = new CanvasRenderingContext2D(1024 * 2, 1024 * 2);
tex1ii.drawImage(
tex1i, 0, 0, 1024 * 2, 1024 * 2);
{
gl.activeTexture(gl.TEXTURE1);
gl.bindTexture(gl.TEXTURE_2D, tex1);
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 1);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, tex1ii.canvas);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, (int)gl.NEAREST);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, (int)gl.NEAREST);
gl.generateMipmap(gl.TEXTURE_2D);
gl.bindTexture(gl.TEXTURE_2D, null);
}
{
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(gl.TEXTURE_2D, tex0);
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 1);
// http://msdn.microsoft.com/en-us/library/ie/dn302435(v=vs.85).aspx
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, tex0i);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, (int)gl.NEAREST);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, (int)gl.NEAREST);
gl.generateMipmap(gl.TEXTURE_2D);
gl.bindTexture(gl.TEXTURE_2D, null);
}
//gl.clearColor(0.0f, 0.0f, 0.0f, 1.0f);
//gl.enable(gl.DEPTH_TEST);
gl.enable(gl.BLEND);
//gl.enable(gl.CULL_FACE);
// http://stackoverflow.com/questions/11521035/blending-with-html-background-in-webgl
gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
var xRot = 0.0f;
示例4: Application
//.........这里部分代码省略.........
var vs = createShader(new GeometryVertexShader());
var fs = createShader(new GeometryFragmentShader());
var shaderProgram = new WebGLProgram(gl);
gl.attachShader(shaderProgram, vs);
gl.attachShader(shaderProgram, fs);
gl.linkProgram(shaderProgram);
var mvMatrix = glMatrix.mat4.create();
var pMatrix = glMatrix.mat4.create();
var vec3aVertexPositionBuffer = new WebGLBuffer(gl);
var vec2aTextureCoordBuffer = new WebGLBuffer(gl);
gl.clearColor(0.0f, 0.0f, 0.0f, 1.0f);
gl.enable(gl.DEPTH_TEST);
#region initTextureFramebuffer
var xWebGLFramebuffer = new WebGLFramebuffer(gl);
gl.bindFramebuffer(gl.FRAMEBUFFER, xWebGLFramebuffer);
// generateMipmap: level 0 not power of 2 or not all the same size
//var rttFramebuffer_width = canvas.width;
// WebGL: INVALID_OPERATION: generateMipmap: level 0 not power of 2 or not all the same size
var xWebGLTexture = new WebGLTexture(gl);
gl.bindTexture(gl.TEXTURE_2D, xWebGLTexture);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, (int)gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, (int)gl.LINEAR_MIPMAP_NEAREST);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, rttFramebuffer_width, rttFramebuffer_height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
gl.generateMipmap(gl.TEXTURE_2D);
var xWebGLRenderbuffer = new WebGLRenderbuffer(gl);
gl.bindRenderbuffer(gl.RENDERBUFFER, xWebGLRenderbuffer);
gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, rttFramebuffer_width, rttFramebuffer_height);
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, xWebGLTexture, 0);
gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, xWebGLRenderbuffer);
gl.bindTexture(gl.TEXTURE_2D, null);
gl.bindRenderbuffer(gl.RENDERBUFFER, null);
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
#endregion
var pass = new ChromeShaderToyColumns.Library.ShaderToy.EffectPass(
gl: gl,
precission: ChromeShaderToyColumns.Library.ShaderToy.DetermineShaderPrecission(gl),
supportDerivatives: gl.getExtension("OES_standard_derivatives") != null
);
pass.MakeHeader_Image();
pass.NewShader_Image(
new ChromeShaderToyColumns.Shaders.ProgramFragmentShader()
);
var sw = Stopwatch.StartNew();
var vbo = new WebGLBuffer(gl);
Native.window.onframe += e =>
{
// can we run it in VR as HUD?
// https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20150706
示例5: Application
//.........这里部分代码省略.........
var moonVertexNormalBuffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, moonVertexNormalBuffer);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(normalData.ToArray()), gl.STATIC_DRAW);
var moonVertexNormalBuffer_itemSize = 3;
var moonVertexNormalBuffer_numItems = normalData.Count / 3;
var moonVertexTextureCoordBuffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, moonVertexTextureCoordBuffer);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(textureCoordData.ToArray()), gl.STATIC_DRAW);
var moonVertexTextureCoordBuffer_itemSize = 2;
var moonVertexTextureCoordBuffer_numItems = textureCoordData.Count / 2;
var moonVertexPositionBuffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, moonVertexPositionBuffer);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertexPositionData.ToArray()), gl.STATIC_DRAW);
var moonVertexPositionBuffer_itemSize = 3;
var moonVertexPositionBuffer_numItems = vertexPositionData.Count / 3;
var moonVertexIndexBuffer = gl.createBuffer();
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, moonVertexIndexBuffer);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(indexData.ToArray()), gl.STREAM_DRAW);
var moonVertexIndexBuffer_itemSize = 1;
var moonVertexIndexBuffer_numItems = indexData.Count;
#endregion
#region handleLoadedTexture
Action<WebGLTexture, IHTMLImage> handleLoadedTexture = (texture, texture_image) =>
{
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 1);
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texture_image);
gl.texParameteri((uint)gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, (int)gl.LINEAR);
gl.texParameteri((uint)gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, (int)gl.LINEAR_MIPMAP_NEAREST);
gl.generateMipmap(gl.TEXTURE_2D);
gl.bindTexture(gl.TEXTURE_2D, null);
};
#endregion
var moonTexture = gl.createTexture();
handleLoadedTexture(moonTexture, moon);
var crateTexture = gl.createTexture();
handleLoadedTexture(crateTexture, crate);
gl.clearColor(0.0f, 0.0f, 0.0f, 1.0f);
gl.enable(gl.DEPTH_TEST);
var moonAngle = 180f;
var cubeAngle = 0f;
var lastTime = 0L;
#region animate
Action animate = () =>
{
var timeNow = new IDate().getTime();
if (lastTime != 0)
{
var elapsed = timeNow - lastTime;
moonAngle += 0.05f * elapsed;
示例6: Application
//.........这里部分代码省略.........
gl.uniformMatrix4fv(currentProgram.mvMatrixUniform, false, mvMatrix);
#endregion
var normalMatrix = glMatrix.mat3.create();
glMatrix.mat4.toInverseMat3(mvMatrix, normalMatrix);
glMatrix.mat3.transpose(normalMatrix);
#region [uniform] mat3 uNMatrix <- normalMatrix
gl.uniformMatrix3fv(currentProgram.nMatrixUniform, false, normalMatrix);
#endregion
};
#endregion
#region handleLoadedTexture
Action<WebGLTexture, IHTMLImage> handleLoadedTexture = (texture, texture_image) =>
{
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 1);
gl.bindTexture(gl.TEXTURE_2D, texture);
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_MIPMAP_NEAREST);
gl.generateMipmap(gl.TEXTURE_2D);
gl.bindTexture(gl.TEXTURE_2D, null);
};
#endregion
var earthTexture = gl.createTexture();
handleLoadedTexture(earthTexture, earth);
var galvanizedTexture = gl.createTexture();
handleLoadedTexture(galvanizedTexture, metal);
new WebGLLesson14.Data.Teapot().Content.AttachToDocument().onload +=
delegate
{
#region loadTeapot
var teapotData = Application.Teapot;
var teapotVertexNormalBuffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, teapotVertexNormalBuffer);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(teapotData.vertexNormals), gl.STATIC_DRAW);
var teapotVertexNormalBuffer_itemSize = 3;
var teapotVertexNormalBuffer_numItems = teapotData.vertexNormals.Length / 3;
var teapotVertexTextureCoordBuffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, teapotVertexTextureCoordBuffer);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(teapotData.vertexTextureCoords), gl.STATIC_DRAW);
示例7: Application
//.........这里部分代码省略.........
{
#region setMatrixUniforms
Action setMatrixUniforms =
delegate
{
#region [uniform] mat4 uPMatrix <- pMatrix
gl.uniformMatrix4fv(currentProgram.pMatrixUniform, false, pMatrix);
#endregion
#region [uniform] mat4 uMVMatrix <- mvMatrix
gl.uniformMatrix4fv(currentProgram.mvMatrixUniform, false, mvMatrix);
#endregion
var normalMatrix = glMatrix.mat3.create();
glMatrix.mat4.toInverseMat3(mvMatrix, normalMatrix);
glMatrix.mat3.transpose(normalMatrix);
#region [uniform] mat3 uNMatrix <- normalMatrix
gl.uniformMatrix3fv(currentProgram.nMatrixUniform, false, normalMatrix);
#endregion
};
#endregion
#region handleLoadedTexture
Action<WebGLTexture, IHTMLImage> handleLoadedTexture = (texture, texture_image) =>
{
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 1);
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texture_image);
gl.texParameteri((uint)gl.TEXTURE_2D, (uint)gl.TEXTURE_MAG_FILTER, (int)gl.LINEAR);
gl.texParameteri((uint)gl.TEXTURE_2D, (uint)gl.TEXTURE_MIN_FILTER, (int)gl.LINEAR_MIPMAP_NEAREST);
gl.generateMipmap(gl.TEXTURE_2D);
gl.bindTexture(gl.TEXTURE_2D, null);
};
#endregion
var earthColorMapTexture = gl.createTexture();
handleLoadedTexture(earthColorMapTexture, earth);
var earthSpecularMapTexture = gl.createTexture();
handleLoadedTexture(earthSpecularMapTexture, earth_specular);
#region initBuffers
var latitudeBands = 30;
var longitudeBands = 30;
var radius = 13;
var vertexPositionData = new List<f>();
var normalData = new List<f>();
var textureCoordData = new List<f>();
for (var latNumber = 0; latNumber <= latitudeBands; latNumber++)
{
var theta = latNumber * Math.PI / latitudeBands;
var sinTheta = (f)Math.Sin(theta);
var cosTheta = (f)Math.Cos(theta);
for (var longNumber = 0; longNumber <= longitudeBands; longNumber++)
{
var phi = longNumber * 2 * Math.PI / longitudeBands;
var sinPhi = (f)Math.Sin(phi);
var cosPhi = (f)Math.Cos(phi);
var x = cosPhi * sinTheta;
示例8: Application
/// <summary>
/// This is a javascript application.
/// </summary>
/// <param name="page">HTML document rendered by the web server which can now be enhanced.</param>
public Application(IDefault page = null)
{
// view-source:http://mrdoob.com/lab/javascript/webgl/glsl/04/
var time = new Stopwatch();
time.Start();
var parameters_screenWidth = 0;
var parameters_screenHeight = 0;
var gl = new WebGLRenderingContext();
var canvas = gl.canvas.AttachToDocument();
#region IsDisposed
var IsDisposed = false;
Dispose = delegate
{
if (IsDisposed)
return;
IsDisposed = true;
canvas.Orphanize();
};
#endregion
// Create Vertex buffer (2 triangles)
var buffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(-1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f), gl.STATIC_DRAW);
// Create Program
var program = gl.createProgram(
new DisturbVertexShader(),
new DisturbFragmentShader()
);
gl.linkProgram(program);
gl.useProgram(program);
#region loadTexture
Action<IHTMLImage, WebGLTexture> loadTexture =
async (image, texture_) =>
{
await image;
gl.enable(gl.TEXTURE_2D);
gl.bindTexture(gl.TEXTURE_2D, texture_);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, 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_MIPMAP_LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, (int)gl.REPEAT);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, (int)gl.REPEAT);
gl.generateMipmap(gl.TEXTURE_2D);
gl.bindTexture(gl.TEXTURE_2D, null);
};
#endregion
var texture = gl.createTexture();
loadTexture(new HTML.Images.FromAssets.disturb(), texture);
var vertexPositionLocation = default(long);
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();
//.........这里部分代码省略.........
示例9: Application
//.........这里部分代码省略.........
var moonVertexNormalBuffer_numItems = normalData.Count / 3;
var moonVertexTextureCoordBuffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, moonVertexTextureCoordBuffer);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(textureCoordData.ToArray()), gl.STATIC_DRAW);
var moonVertexTextureCoordBuffer_itemSize = 2;
var moonVertexTextureCoordBuffer_numItems = textureCoordData.Count / 2;
var moonVertexPositionBuffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, moonVertexPositionBuffer);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertexPositionData.ToArray()), gl.STATIC_DRAW);
var moonVertexPositionBuffer_itemSize = 3;
var moonVertexPositionBuffer_numItems = vertexPositionData.Count / 3;
var moonVertexIndexBuffer = gl.createBuffer();
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, moonVertexIndexBuffer);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(indexData.ToArray()), gl.STATIC_DRAW);
var moonVertexIndexBuffer_itemSize = 1;
var moonVertexIndexBuffer_numItems = indexData.Count;
new HTML.Images.FromAssets.moon().InvokeOnComplete(
mud =>
{
var moonTexture = gl.createTexture();
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 1);
gl.bindTexture(gl.TEXTURE_2D, moonTexture);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, mud);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, (int)gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, (int)gl.LINEAR_MIPMAP_NEAREST);
gl.generateMipmap(gl.TEXTURE_2D);
gl.bindTexture(gl.TEXTURE_2D, null);
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(