本文整理汇总了C#中SharpGL.OpenGL.GenBuffers方法的典型用法代码示例。如果您正苦于以下问题:C# OpenGL.GenBuffers方法的具体用法?C# OpenGL.GenBuffers怎么用?C# OpenGL.GenBuffers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SharpGL.OpenGL
的用法示例。
在下文中一共展示了OpenGL.GenBuffers方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VBO
public VBO(OpenGL gl, BeginMode beginMode)
{
Mode = beginMode;
_gl = gl;
var buffers = new uint[1];
gl.GenBuffers(1, buffers);
Handle = buffers[0];
Count = 0;
}
示例2: CreateBufferIds
public static OGLBufferId[] CreateBufferIds(OpenGL gl, int amount)
{
uint[] ids = new uint[amount];
OGLBufferId[] bIds = new OGLBufferId[amount];
gl.GenBuffers(amount, ids);
for (int i = 0; i < amount; i++)
{
bIds[i] = new OGLBufferId(ids[i]);
}
return bIds;
}
示例3: CreateVertexNormalBuffer
public uint CreateVertexNormalBuffer(OpenGL gl)
{
Vertex[] verts = new Vertex[VertexCount * 2];
int count = 0;
float ds = 1.0f / Slices;
float dt = 1.0f / Stacks;
// The upper bounds in these loops are tweaked to reduce the
// chance of precision error causing an incorrect # of iterations.
for (float s = 0; s < 1 - ds / 2; s += ds)
{
for (float t = 0; t < 1 - dt / 2; t += dt)
{
const float E = 0.01f;
Vertex p = EvaluateTrefoil(s, t);
Vertex u = EvaluateTrefoil(s + E, t) - p;
Vertex v = EvaluateTrefoil(s, t + E) - p;
Vertex n = u.VectorProduct(v);
n.Normalize();
verts[count++] = p;
verts[count++] = n;
}
}
// Pin the data.
GCHandle vertsHandle = GCHandle.Alloc(verts, GCHandleType.Pinned);
IntPtr vertsPtr = vertsHandle.AddrOfPinnedObject();
var size = Marshal.SizeOf(typeof(Vertex)) * VertexCount;
uint[] buffers = new uint[1];
gl.GenBuffers(1, buffers);
uint handle = buffers[0];
gl.BindBuffer(OpenGL.GL_ARRAY_BUFFER, handle);
gl.BufferData(OpenGL.GL_ARRAY_BUFFER, size, vertsPtr, OpenGL.GL_STATIC_DRAW);
// Free the data.
vertsHandle.Free();
return handle;
}
示例4: CreateBufferIds
private void CreateBufferIds(OpenGL gl)
{
var amount = 8;
uint[] ids = new uint[amount];
gl.GenBuffers(amount, ids);
Position = ids[0];
Normal = ids[1];
AmbientMaterial = ids[2];
DiffuseMaterial = ids[3];
SpecularMaterial = ids[4];
ShininessValue = ids[5];
HTColorId = ids[6];
Ibo = ids[7];
}
示例5: CreateIndexBuffer
private uint CreateIndexBuffer(OpenGL gl)
{
ushort[] inds = new ushort[IndexCount];
int count = 0;
ushort n = 0;
for (ushort i = 0; i < Slices; i++)
{
for (ushort j = 0; j < Stacks; j++)
{
inds[count++] = (ushort)(n + j);
inds[count++] = (ushort)(n + (j + 1) % Stacks);
inds[count++] = (ushort)((n + j + Stacks) % VertexCount);
inds[count++] = (ushort)((n + j + Stacks) % VertexCount);
inds[count++] = (ushort)((n + (j + 1) % Stacks) % VertexCount);
inds[count++] = (ushort)((n + (j + 1) % Stacks + Stacks) % VertexCount);
}
n += (ushort)Stacks;
}
// Pin the data.
GCHandle indsHandle = GCHandle.Alloc(inds, GCHandleType.Pinned);
IntPtr indsPtr = indsHandle.AddrOfPinnedObject();
var size = Marshal.SizeOf(typeof(ushort)) * VertexCount;
uint[] buffers = new uint[1];
gl.GenBuffers(1, buffers);
uint handle = buffers[0];
gl.BindBuffer(OpenGL.GL_ELEMENT_ARRAY_BUFFER, handle);
gl.BufferData(OpenGL.GL_ELEMENT_ARRAY_BUFFER, (int)size, indsPtr, OpenGL.GL_STATIC_DRAW);
// Free the data.
indsHandle.Free();
return handle;
}
示例6: CreateBufferIds
private void CreateBufferIds(OpenGL gl)
{
var amount = 3;
uint[] ids = new uint[amount];
gl.GenBuffers(amount, ids);
Position = ids[0];
ColorValue = ids[1];
Ibo = ids[2];
}
示例7: VBO
public VBO(OpenGL gl)
{
_gl = gl;
_gl.GenBuffers(1, _handle);
}