本文整理汇总了C#中SharpGL.OpenGL.UniformMatrix4方法的典型用法代码示例。如果您正苦于以下问题:C# OpenGL.UniformMatrix4方法的具体用法?C# OpenGL.UniformMatrix4怎么用?C# OpenGL.UniformMatrix4使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SharpGL.OpenGL
的用法示例。
在下文中一共展示了OpenGL.UniformMatrix4方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyModelViewProjection
private void ApplyModelViewProjection(OpenGL gl)
{
gl.UniformMatrix4(Uniforms["ModelviewProjection"], 1, false, (Modelview.Transpose() * Projection.Transpose()).to_array());
}
示例2: OnUpdate
public override void OnUpdate(OpenGL gl)
{
_camera.View *= Mat4.RotateX(Angle.FromDegrees(0.6));
using (new Bind(_shader))
{
_camera.Resize((int)ActualWidth, (int)ActualHeight);
gl.UniformMatrix4(_modelUniform, 1, false, Mat4.Identity.ToColumnMajorArray());
gl.UniformMatrix4(_viewUniform, 1, false, _camera.View.ToColumnMajorArray());
gl.UniformMatrix4(_projectionUniform, 1, false, _camera.Projection.ToColumnMajorArray());
}
}
示例3: DrawTrefoilCelShaded
private void DrawTrefoilCelShaded(OpenGL gl)
{
// Use the shader program.
gl.UseProgram(shaderProgram.ProgramObject);
// Set the variables for the shader program.
gl.Uniform3(toonUniforms.DiffuseMaterial, 0f, 0.75f, 0.75f);
gl.Uniform3(toonUniforms.AmbientMaterial, 0.04f, 0.04f, 0.04f);
gl.Uniform3(toonUniforms.SpecularMaterial, 0.5f, 0.5f, 0.5f);
gl.Uniform1(toonUniforms.Shininess, 50f);
// Set the light position.
gl.Uniform3(toonUniforms.LightPosition, 1, new float[4] { 0.25f, 0.25f, 1f, 0f });
// Set the matrices.
gl.UniformMatrix4(toonUniforms.Projection, 1, false, projection.AsColumnMajorArrayFloat);
gl.UniformMatrix4(toonUniforms.Modelview, 1, false, modelView.AsColumnMajorArrayFloat);
gl.UniformMatrix3(toonUniforms.NormalMatrix, 1, false, normalMatrix.AsColumnMajorArrayFloat);
// Bind the vertex and index buffer.
gl.BindBuffer(OpenGL.GL_ARRAY_BUFFER, vertexBuffer);
gl.BindBuffer(OpenGL.GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
gl.EnableVertexAttribArray(attrPosition);
gl.EnableVertexAttribArray(attrNormal);
// Draw the geometry, straight from the vertex buffer.
gl.VertexAttribPointer(attrPosition, 3, OpenGL.GL_FLOAT, false, Marshal.SizeOf(typeof(Vertex)), IntPtr.Zero);
int normalOffset = Marshal.SizeOf(typeof(Vertex));
gl.VertexAttribPointer(attrNormal, 3, OpenGL.GL_FLOAT, false, Marshal.SizeOf(typeof(Vertex)), IntPtr.Add(new IntPtr(0), normalOffset));
gl.DrawElements(OpenGL.GL_TRIANGLES, (int)trefoilKnot.IndexCount, OpenGL.GL_UNSIGNED_SHORT, IntPtr.Zero);
}
示例4: OnResize
public override void OnResize(OpenGL gl, int width, int height)
{
if (width == -1 || height == -1) return;
using (new Bind(_shader))
{
_camera.Resize(width, height);
gl.UniformMatrix4(_projectionUniform, 1, false, _camera.Projection.ToColumnMajorArray());
}
}
示例5: OnRender
public override void OnRender(OpenGL gl)
{
gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);
gl.ClearColor(0.137f, 0.121f, 0.125f, 0f);
_graph.Render();
gl.Disable(OpenGL.GL_DEPTH_TEST);
using (new Bind(_shader))
{
gl.UniformMatrix4(_modelUniform, 1, false, Mat4.Identity.ToColumnMajorArray());
gl.PointSize(10f);
gl.Begin(BeginMode.Points);
gl.Vertex(6, 0);
gl.End();
}
gl.PointSize(5f);
_points.Render();
gl.Enable(OpenGL.GL_DEPTH_TEST);
}