本文整理匯總了C#中SharpGL.OpenGL.EnableVertexAttribArray方法的典型用法代碼示例。如果您正苦於以下問題:C# OpenGL.EnableVertexAttribArray方法的具體用法?C# OpenGL.EnableVertexAttribArray怎麽用?C# OpenGL.EnableVertexAttribArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SharpGL.OpenGL
的用法示例。
在下文中一共展示了OpenGL.EnableVertexAttribArray方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: VAO
public VAO(OpenGL gl, IShaderProgram program, VBO vbo)
{
_gl = gl;
_program = program;
VBO = vbo;
var buffers = new uint[1];
gl.GenVertexArrays(1, buffers);
Handle = buffers[0];
using (new Bind(program))
using (new Bind(this))
using (new Bind(vbo))
{
var stride = Vect3f.SizeInBytes * 2 + Vect4f.SizeInBytes;
gl.EnableVertexAttribArray(0);
gl.VertexAttribPointer(0, 3, OpenGL.GL_FLOAT, true, stride, IntPtr.Zero);
gl.BindAttribLocation(program.Handle, 0, "vert_position");
gl.EnableVertexAttribArray(1);
gl.VertexAttribPointer(1, 3, OpenGL.GL_FLOAT, true, stride, new IntPtr(Vect3f.SizeInBytes));
gl.BindAttribLocation(program.Handle, 1, "vert_normal");
gl.EnableVertexAttribArray(2);
gl.VertexAttribPointer(2, 4, OpenGL.GL_FLOAT, false, stride, new IntPtr(Vect3f.SizeInBytes * 2));
gl.BindAttribLocation(program.Handle, 2, "vert_colour");
}
}
示例2: BindVBOs
public void BindVBOs(OpenGL gl, LinesProgram program)
{
var attribPos = program.Attribs["Position"];
gl.BindBuffer(_vboTarget, Position);
gl.VertexAttribPointer(attribPos, 3, OpenGL.GL_FLOAT, false, 0, IntPtr.Zero);
gl.EnableVertexAttribArray(attribPos);
attribPos = program.Attribs["ColorValue"];
gl.BindBuffer(_vboTarget, ColorValue);
gl.VertexAttribPointer(attribPos, 3, OpenGL.GL_FLOAT, false, 0, IntPtr.Zero);
gl.VertexAttribDivisor(attribPos, 1);
gl.EnableVertexAttribArray(attribPos);
if (IndicesCount > 0)
gl.BindBuffer(_iboTarget, Ibo);
}
示例3: DrawTrefoilBuffers
private void DrawTrefoilBuffers(OpenGL gl)
{
// 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_LINES, (int)trefoilKnot.IndexCount, OpenGL.GL_UNSIGNED_SHORT, IntPtr.Zero);
}
示例4: BackgroundRenderer
public BackgroundRenderer(OpenGL gl)
{
_gl = gl;
_program = new BackgroundShader(gl);
_flat = new VAO(gl);
_flatBuffer = new VBO(gl);
using (new Bind(_flat))
using (new Bind(_flatBuffer))
{
var flatData = new float[] { -1, -1, 1, -1, -1, 1, 1, 1, };
_flatBuffer.Update(flatData, flatData.Length * sizeof(float));
gl.EnableVertexAttribArray(0);
gl.VertexAttribPointer(0, 2, OpenGL.GL_FLOAT, false, 0, new IntPtr(0));
gl.BindVertexArray(0);
}
}
示例5: PostProcesser
public PostProcesser(OpenGL gl,int width,int height)
{
_gl = gl;
_fbo = new FBO(gl, width, height);
_flatProgram = new FlatShader(gl);
_flat = new VAO(gl);
_flatBuffer = new VBO(gl);
using (new Bind(_flat))
using (new Bind(_flatBuffer))
{
var flatData = new float[] { -1, -1, 1, -1, -1, 1, 1, 1, };
_flatBuffer.Update(flatData, flatData.Length * sizeof(float));
gl.EnableVertexAttribArray(0);
gl.VertexAttribPointer(0, 2, OpenGL.GL_FLOAT, false, 0, new IntPtr(0));
gl.BindVertexArray(0);
}
}
示例6: OctreeRenderer
public OctreeRenderer(OctreeModel model, OpenGL gl)
{
_gl = gl;
_octreeProgram = new OctreeShader(gl);
_cubes = new VAO(gl);
_cubeBuffer = new VBO(gl);
var filled = model.Node.Flatten().Where(o => o.State == NodeState.Filled).ToArray();
_count = filled.Length;
var list = new List<float>();
foreach (var octreeNode in filled)
{
list.AddRange(octreeNode.Center.ToArray().Select(d => (float)d));
list.AddRange(new[]
{
(float)MathsHelper.Map(octreeNode.Color.R, 0, 255, 0, 1),
(float)MathsHelper.Map(octreeNode.Color.G, 0, 255, 0, 1),
(float)MathsHelper.Map(octreeNode.Color.B, 0, 255, 0, 1),
(float)MathsHelper.Map(octreeNode.Color.A, 0, 255, 0, 1),
(float)octreeNode.Size
});
}
var vertices = list.ToArray();
using (new Bind(_cubes))
using (new Bind(_cubeBuffer))
{
_cubeBuffer.Update(vertices, vertices.Length * sizeof(float));
const int stride = sizeof(float) * 8;
gl.EnableVertexAttribArray(0);
gl.VertexAttribPointer(0, 3, OpenGL.GL_FLOAT, false, stride, new IntPtr(0));
gl.EnableVertexAttribArray(1);
gl.VertexAttribPointer(1, 4, OpenGL.GL_FLOAT, false, stride, new IntPtr(sizeof(float) * 3));
gl.EnableVertexAttribArray(2);
gl.VertexAttribPointer(2, 1, OpenGL.GL_FLOAT, false, stride, new IntPtr(sizeof(float) * 7));
gl.BindVertexArray(0);
}
}
示例7: CreateVertexArrayObject
private void CreateVertexArrayObject(OpenGL gl, RenderMode renderMode)
{
if (this.positionBuffer == null || this.colorBuffer == null) { return; }
this.vertexArrayObject = new uint[1];
gl.GenVertexArrays(1, this.vertexArrayObject);
gl.BindVertexArray(this.vertexArrayObject[0]);
// prepare positions
{
int location = shaderProgram.GetAttributeLocation(gl, in_Position);
ATTRIB_INDEX_POSITION = (uint)location;
gl.BindBuffer(OpenGL.GL_ARRAY_BUFFER, positionBuffer[0]);
gl.VertexAttribPointer(ATTRIB_INDEX_POSITION, 3, OpenGL.GL_FLOAT, false, 0, IntPtr.Zero);
gl.EnableVertexAttribArray(ATTRIB_INDEX_POSITION);
}
// prepare colors
{
int location = shaderProgram.GetAttributeLocation(gl, in_uv);
ATTRIB_INDEX_UV = (uint)location;
gl.BindBuffer(OpenGL.GL_ARRAY_BUFFER, colorBuffer[0]);
gl.VertexAttribPointer(ATTRIB_INDEX_UV, 1, OpenGL.GL_FLOAT, false, 0, IntPtr.Zero);
gl.EnableVertexAttribArray(ATTRIB_INDEX_UV);
}
gl.BindVertexArray(0);
}
示例8: PrepareNMVAO
public void PrepareNMVAO(OpenGL gl, NormalMaterialProgram program)
{
var vertArrIds = new uint[1];
gl.GenVertexArrays(1, vertArrIds);
VaoNM = vertArrIds[0];
gl.BindVertexArray(VaoNM);
BindNMVBOs(gl, program);
gl.EnableVertexAttribArray(0);
gl.BindVertexArray(0);
}
示例9: PrepareHTVAO
public void PrepareHTVAO(OpenGL gl, HitTestProgram program)
{
var vertArrIds = new uint[1];
gl.GenVertexArrays(1, vertArrIds);
VaoHT = vertArrIds[0];
gl.BindVertexArray(VaoHT);
BindHTVBOs(gl, program);
gl.EnableVertexAttribArray(0);
gl.BindVertexArray(0);
}
示例10: BindNMVBOs
public void BindNMVBOs(OpenGL gl, NormalMaterialProgram program)
{
var attribPos = program.Attribs["Position"];
gl.BindBuffer(_vboTarget, Position);
gl.VertexAttribPointer(attribPos, 3, OpenGL.GL_FLOAT, false, 0, IntPtr.Zero);
gl.EnableVertexAttribArray(attribPos);
attribPos = program.Attribs["Normal"];
gl.BindBuffer(_vboTarget, Normal);
gl.VertexAttribPointer(attribPos, 3, OpenGL.GL_FLOAT, false, 0, IntPtr.Zero);
gl.EnableVertexAttribArray(attribPos);
attribPos = program.Attribs["AmbientMaterial"];
gl.BindBuffer(_vboTarget, AmbientMaterial);
gl.VertexAttribPointer(attribPos, 3, OpenGL.GL_FLOAT, false, 0, IntPtr.Zero);
gl.VertexAttribDivisor(attribPos, 1);
gl.EnableVertexAttribArray(attribPos);
attribPos = program.Attribs["DiffuseMaterial"];
gl.BindBuffer(_vboTarget, DiffuseMaterial);
gl.VertexAttribPointer(attribPos, 3, OpenGL.GL_FLOAT, false, 0, IntPtr.Zero);
gl.VertexAttribDivisor(attribPos, 1);
gl.EnableVertexAttribArray(attribPos);
attribPos = program.Attribs["SpecularMaterial"];
gl.BindBuffer(_vboTarget, SpecularMaterial);
gl.VertexAttribPointer(attribPos, 3, OpenGL.GL_FLOAT, false, 0, IntPtr.Zero);
gl.VertexAttribDivisor(attribPos, 1);
gl.EnableVertexAttribArray(attribPos);
attribPos = program.Attribs["ShininessValue"];
gl.BindBuffer(_vboTarget, ShininessValue);
gl.VertexAttribPointer(attribPos, 1, OpenGL.GL_FLOAT, false, 0, IntPtr.Zero);
gl.VertexAttribDivisor(attribPos, 1);
gl.EnableVertexAttribArray(attribPos);
gl.BindBuffer(_iboTarget, Ibo);
}
示例11: BindHTVBOs
public void BindHTVBOs(OpenGL gl, HitTestProgram program)
{
var attribPos = program.Attribs["Position"];
gl.BindBuffer(_vboTarget, Position);
gl.VertexAttribPointer(attribPos, 3, OpenGL.GL_FLOAT, false, 0, IntPtr.Zero);
gl.EnableVertexAttribArray(attribPos);
attribPos = program.Attribs["HTColorId"];
gl.BindBuffer(_vboTarget, HTColorId);
gl.VertexAttribPointer(attribPos, 3, OpenGL.GL_FLOAT, false, 0, IntPtr.Zero);
gl.VertexAttribDivisor(attribPos, 1);
gl.EnableVertexAttribArray(attribPos);
gl.BindBuffer(_iboTarget, Ibo);
}
示例12: PrepareVAO
public void PrepareVAO(OpenGL gl, LinesProgram program)
{
var vertArrIds = new uint[1];
gl.GenVertexArrays(1, vertArrIds);
Vao = vertArrIds[0];
gl.BindVertexArray(Vao);
BindVBOs(gl, program);
gl.EnableVertexAttribArray(0);
gl.BindVertexArray(0);
}
示例13: 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);
}
示例14: Bind
public void Bind(OpenGL gl)
{
// Bind the vertex, normal and index buffers.
if (_transformationsBufferId != null)
{
var transStride = 16;
//Bind
gl.BindBuffer(OpenGL.GL_ARRAY_BUFFER, _transformationsBufferId.Value);
gl.VertexAttribPointer(VertexAttributes.Position, transStride, OpenGL.GL_FLOAT, false, 0, IntPtr.Zero);
gl.EnableVertexAttribArray(VertexAttributes.Position);
}
if (_colorsBufferId != null)
{
var colStride = 3;
//Bind
gl.BindBuffer(OpenGL.GL_ARRAY_BUFFER, _colorsBufferId.Value);
gl.VertexAttribPointer(VertexAttributes.Normal, colStride, OpenGL.GL_FLOAT, false, 0, IntPtr.Zero);
gl.EnableVertexAttribArray(VertexAttributes.Normal);
}
if (_indicesBufferId != null)
{
gl.BindBuffer(OpenGL.GL_ELEMENT_ARRAY_BUFFER, _indicesBufferId.Value);
}
}
示例15: Bind
/// <summary>
/// Calls VertexBuffer.Bind(gl), IndexBuffer.Bind(gl) and Material.Bind(gl).
/// </summary>
/// <param name="gl">The OpenGL</param>
public void Bind(OpenGL gl)
{
//if (gl == null)
//{
// throw new ArgumentNullException("OpenGL parameter cannot be null. Call 'GenerateGeometry(...)' before attempting to bind.");
//}
// Bind the vertex, normal and index buffers.
if (VertexBuffer != null)
{
//Bind
//VertexBuffer.BindBuffer(gl); //
gl.BindBuffer(OpenGL.GL_ARRAY_BUFFER, VertexBuffer.BufferId.Value);
gl.VertexAttribPointer(VertexAttributes.Position, BufferStride, OpenGL.GL_FLOAT, false, 0, IntPtr.Zero);
gl.EnableVertexAttribArray(VertexAttributes.Position);
}
if (NormalBuffer != null)
{
//Bind
//NormalBuffer.BindBuffer(gl); //
gl.BindBuffer(OpenGL.GL_ARRAY_BUFFER, NormalBuffer.BufferId.Value);
gl.VertexAttribPointer(VertexAttributes.Normal, BufferStride, OpenGL.GL_FLOAT, false, 0, IntPtr.Zero);
gl.EnableVertexAttribArray(VertexAttributes.Normal);
}
if (IndexBuffer != null)
{
//IndexBuffer.BindBuffer(gl); //
gl.BindBuffer(OpenGL.GL_ELEMENT_ARRAY_BUFFER, IndexBuffer.BufferId.Value);
}
}