public Geometry(BeginMode drawMode, VertexBuffer buffer) { this.buffer = buffer; DrawMode = drawMode; Position = new Vector3(); Orientation = Quaternion.Identity; }
public Geometry(Primitive primitiveType, int vertexCountHint = 32, int indexCountHint = 32, bool dynamicHint = false) { m_primitiveType = primitiveType; switch (primitiveType) { case Primitive.Lines: { m_beginMode = BeginMode.Lines; break; } case Primitive.Triangles: default: { m_beginMode = BeginMode.Triangles; break; } } m_bufferUsageHint = dynamicHint ? BufferUsageHint.DynamicDraw : BufferUsageHint.StaticDraw; GL.GenBuffers(1, out m_vertexBuffer); m_vertexData = new float[vertexCountHint * FLOATS_PER_VERTEX]; m_vertexCount = 0; GL.GenBuffers(1, out m_indexBuffer); m_indexData = new short[indexCountHint]; m_indexCount = 0; }
private void Keyboard_KeyUp(object sender, KeyboardKeyEventArgs e) { switch (e.Key) { case Key.Escape: this.Exit(); break; case Key.Number1: this._terrainRenderStyle = BeginMode.Points; break; case Key.Number2: this._terrainRenderStyle = BeginMode.Lines; break; case Key.Number3: this._terrainRenderStyle = BeginMode.Quads; break; case Key.Plus: this.RenderSteps -= 1; break; case Key.Minus: this.RenderSteps += 1; break; } }
public DrawableShape( ) { PrimitiveMode = BeginMode.Triangles; VertexArray = null; IndexArray = null; }
//public Mesh3D(BeginMode mode) // :this(null, mode) //{ //} public Mesh3D(GraphicsInterface gi, BeginMode mode) { GI = gi; fDrawingPrimitive = mode; fUseVertices = true; fUseIndices = true; }
public DrawableShape( bool useDisplayList ) { UseDisplayList = useDisplayList; PrimitiveMode = BeginMode.Triangles; VertexArray = null; IndexArray = null; }
public IBufferRange CreateIndexBufferRange(BeginMode beginMode) { var r = new BufferRangeGL(this, beginMode); Add(r); return(r); }
private void CreateDisplayLists() { int first_list = GL.GenLists(num_lists); for (int i = 0; i < num_lists; i++) { lists[i] = first_list + i; GL.NewList(lists[i], ListMode.Compile); bool AllWhite = false; switch (i) { case 0: terrainRenderStyle = BeginMode.Points; break; case 1: terrainRenderStyle = BeginMode.Lines; break; case 2: terrainRenderStyle = BeginMode.Quads; break; case 3: terrainRenderStyle = BeginMode.Lines; AllWhite = true; break; default: break; } RenderHeightmap(AllWhite); GL.EndList(); } }
public void Render(BeginMode _primitiveType, int instances) { GL.BindVertexArray(vaoHandle); GL.DrawElementsInstanced(_primitiveType, indices.Length, DrawElementsType.UnsignedInt, IntPtr.Zero, instances); GL.BindVertexArray(0); }
public object Select <T>(IVertexRenderable <T> Renderable) where T : struct, IVertex { Type verttype = typeof(T); BeginMode mode = Renderable.Mode; KeyValuePair <Type, BeginMode> key = new KeyValuePair <Type, BeginMode>(verttype, mode); _UntypedVertexList uvl; if (this.VertexStore.TryGetValue(key, out uvl)) { _VertexList <T> vl = (_VertexList <T>)uvl; foreach (T v in Renderable.Vertices) { vl.Iterator.Next(v); } } else { _VertexList <T> vl = new _VertexList <T>() { Mode = mode, Iterator = VBO <T> .Create() }; this.VertexStore[key] = vl; } return(null); }
public void DrawRangeElements(BeginMode mode, int start, int end, int count, DrawElementsType type, IntPtr indices) { unsafe { glDrawRangeElements((int)mode, (uint)start, (uint)end, count, (int)type, indices); } }
public void Render(BeginMode _primitiveType, int[] _customIndices) { GL.BindVertexArray(vaoHandle); GL.DrawElements(_primitiveType, _customIndices.Length, DrawElementsType.UnsignedInt, _customIndices); GL.BindVertexArray(0); }
public Result SetIndices(int materialIndex, int[] indices, BeginMode mode) { if (materialIndex < 0) { return(Result.OutOfIndex); } if (indices == null) { return(Result.ObjectIsNull); } var sub = subMeshes.Find((s) => { return(s.materialIndex == materialIndex); }); if (sub != null) { sub.indices = indices; sub.mode = mode; } else { subMeshes.Add(new SubMesh() { materialIndex = materialIndex, indices = indices, mode = mode }); } return(Result.Success); }
/// <summary> /// Gets a renderable to render the specified subset of vertices in the VBO with the given mode. /// </summary> public IVertexRenderable <V> GetRenderable(BeginMode Mode, int VertexStart, int Amount) { return(new _VertexRenderable() { VBO = this, BeginMode = Mode, Amount = Amount, VertexStart = VertexStart }); }
/// <summary> /// Gets a renderable to render all the vertices in the VBO. /// </summary> public IVertexRenderable <V> GetRenderable(BeginMode Mode) { return(new _VertexRenderable() { VBO = this, BeginMode = Mode, Amount = this._Count, VertexStart = 0 }); }
/// <summary> /// バッファーを作成する /// </summary> /// <param name="viewport">描画対象</param> /// <param name="indicesCount">インデックス数</param> /// <param name="size">データ1つのサイズ</param> /// <param name="type">データの種類</param> Buffer(Viewport viewport, int indicesCount, int size, BeginMode type) { // 描画対象を設定 this.target = viewport.glControl; // 描画対象を有効化 this.target.MakeCurrent(); // VBOを作成 GL.GenBuffers(1, out this.vertexBuffer); // EBOを作成 GL.GenBuffers(1, out this.elementBuffer); // VAOを作成 GL.GenVertexArrays(1, out this.vertexArray); // インデックス数を設定 this.indicesCount = indicesCount; // サイズを設定 this.sizeInByte = size; // 描画モードを設定 this.mode = type; }
public ModelDemo(Vertex minPosition, Vertex maxPosition, int pointCount, BeginMode mode) { this.MinPosition = minPosition; this.MaxPosition = maxPosition; this.Mode = mode; ModelDemoHelper.Build(this, pointCount); }
public GuiModel(GuiVAO vao, Texture texture, BeginMode drawmode, Vector2 size) { this.vao = vao; this.texture = texture; this.drawmode = drawmode; this.size = size; }
public void Begin(bool immediateMode, BeginMode begin, bool depthtesting) { myBeginMode = begin; int floatSize = Marshal.SizeOf(typeof(float)); GL.UseProgram(ProgramID); OnBegin(); CheckErrors(); GL.Enable(EnableCap.DepthTest); if (immediateMode) { GL.Begin(myBeginMode); } else { foreach (Attribute a in myAttributeList) { GL.VertexAttribPointer(myBoundAttributes[myAttributeList.IndexOf(a)], a.mySize, a.myPointerType, a.amINormal, a.myStride, a.myOffset); CheckErrors(); } foreach (int ba in myBoundAttributes) { GL.EnableVertexAttribArray(ba); } } }
public DrawableShape(bool useDisplayList) { UseDisplayList = useDisplayList; PrimitiveMode = BeginMode.Triangles; VertexArray = null; IndexArray = null; }
public ModelMeshPartPrimCall(BeginMode primType, int indexCount, int startIndex) { PrimitiveType = primType; IndexCount = indexCount; StartOffset = IntPtr.Zero; StartIndex = startIndex; }
public void Render(BeginMode mode) { GL.EnableClientState(ArrayCap.VertexArray); GL.BindBuffer(BufferTarget.ArrayBuffer, Handle); GL.VertexPointer(3, VertexPointerType.Float, Marshal.SizeOf(default(T)), new IntPtr(0)); GL.DrawArrays(BeginMode.Quads, 0, _length); }
public Mesh(VertexBuffer vertexBuffer, IndexBuffer indexBuffer, BeginMode mode = BeginMode.Triangles) { _vertexBuffer = vertexBuffer; _indexBuffer = indexBuffer; _renderingMode = mode; }
public void Draw(int lenght, BeginMode mode) { if (true) { GL.EnableClientState(ArrayCap.VertexArray); GL.EnableClientState(ArrayCap.TextureCoordArray); GL.BindBuffer(BufferTarget.ArrayBuffer, vboIds[0]); GL.VertexPointer(2, VertexPointerType.Float, 0, IntPtr.Zero); GL.BindBuffer(BufferTarget.ArrayBuffer, vboIds[1]); GL.TexCoordPointer(2, TexCoordPointerType.Float, 0, IntPtr.Zero); GL.DrawArrays(mode, 0, lenght); GL.DisableClientState(ArrayCap.VertexArray); GL.DisableClientState(ArrayCap.TextureCoordArray); } // Use immediate mode (Check for vbo support ...) else { GL.Begin(mode); for (int i = 0; i < lenght; i++) { GL.TexCoord2(_texCoordArray[i].u, _texCoordArray[i].v); GL.Vertex2(_vertexArray[i].x, _vertexArray[i].y); } GL.End(); } }
void draw3(BeginMode beginMode, double size, float nx, float ny, float nz) { side_size[2] = size; if (verts_side[2] == null || //if the array is not initialized side_size[2] != size) //if the new size is not identical to the old size { //Create a new array of vertices verts_side[2] = new double[] { +size, +size, +size, -size, +size, +size, -size, -size, +size, +size, -size, +size }; } //Flush out the old data GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(verts_side[2].Length * sizeof(double)), IntPtr.Zero, BufferUsageHint.DynamicDraw); //Refilled with the new refreshed data GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(verts_side[2].Length * sizeof(double)), verts_side[2], BufferUsageHint.DynamicDraw); GL.Normal3(nx, ny, nz); //Draw them out GL.DrawArrays(beginMode, 0, 4); }
public void Draw(BeginMode mode, DrawElementsType type) { if (_boolHasBeenUploaded) { GL.BindVertexArray(_vaoId); GL.DrawElements(mode, _indices.Count, type, 0); } }
public static void DrawArrays(BeginMode mode, int first, int count) { #if USE_OPENGL OpenTK.Graphics.OpenGL.GL.DrawArrays((OpenTK.Graphics.OpenGL.BeginMode)mode, first, count); #else OpenTK.Graphics.ES11.GL.DrawArrays((OpenTK.Graphics.ES11.All)mode, first, count); #endif }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); Console.WriteLine(" --- Ajuda / Teclas: "); Console.WriteLine(" [ H ] mostra teclas usadas. "); GL.ClearColor(Color.Gray); this.beginMode = BeginMode.Points; }
public ModelAsset() { Vbo = 0; Vao = 0; DrawType = BeginMode.Triangles; DrawStart = 0; DrawCount = 0; }
public static void SafeBegin(BeginMode mode, Action code) { GL.Begin(mode); code(); GL.End(); }
public IndexBuffer(int length, BeginMode type = BeginMode.Triangles) { _acceptedAsType = type; //_indices.reserve(length); for (int j = 0; j < length; j++) _indices.Add((int)j); }
public VertexArray(float[] Verts, float[] Colors, float[] Texcoords, int Num, BeginMode Mode) { _verts = Verts; _colors = Colors; _texcoords = Texcoords; _num = Num; _mode = Mode; }
/// <summary> /// Draws the arrays. /// </summary> /// <param name="mode">The mode.</param> /// <param name="first">The first.</param> /// <param name="count">The count.</param> protected void DrawArrays(BeginMode mode, int first, int count) { StartUseProgram(); Vao.Bind(); GL.DrawArrays(mode, first, count); Vao.UnBind(); StopUseProgram(); }
public static void DrawRangeElements(BeginMode mode, uint start, uint end, int count, DrawElementsType type, long offset) { if (IntPtr.Size == 4 && ((long)offset >> 32) != 0) { throw new ArgumentOutOfRangeException("offset", PlatformErrorString); } _DrawRangeElements(mode, start, end, count, type, (IntPtr)offset); }
public static void DrawRangeElements(BeginMode mode, int start, int end, int count, DrawElementsType type, IntPtr indices) { #if USE_OPENGL OpenTK.Graphics.OpenGL.GL.DrawRangeElements((OpenTK.Graphics.OpenGL.BeginMode)mode, start, end, count, (OpenTK.Graphics.OpenGL.DrawElementsType)type, indices); #else throw new NotImplementedException(); #endif }
/// <summary> /// Renders multiple instances from array via indices with a per-element offset. /// </summary> /// <param name="mode">A <see cref="BeginMode"/> specifying the type of primitive to be rendered.</param> /// <param name="count">Number of indices.</param> /// <param name="type">A <see cref="DrawElementsType"/> specifying the data type of the indices.</param> /// <param name="offset">The offset into the array bound to <see cref="BufferTarget.ElementArrayBuffer"/>.</param> /// <param name="instancecount">Number of instances to be rendered.</param> /// <param name="basevertex">The per-element offset.</param> public static void DrawElementsInstancedBaseVertex(BeginMode mode, int count, DrawElementsType type, long offset, int instancecount, int basevertex) { if (IntPtr.Size == 4 && ((long)offset >> 32) != 0) { throw new ArgumentOutOfRangeException("offset", PlatformErrorString); } _DrawElementsInstancedBaseVertex(mode, count, type, (IntPtr)offset, instancecount, basevertex); }
public void Draw(BeginMode beginMode) { Activate(); { GL.DrawArrays(beginMode, 0, size); } Deactivate(); }
public ShaderProgram() { BeginMode = BeginMode.Triangles; _attributes = new List<AttributeInfo>(); _textures = new Dictionary<String, TextureInfo>(); _uniforms = new Dictionary<String, int>(); VertexDataStride = 0; VertexDataSize = 0; _started = false; }
public static void addDrawable(Drawable2D drawable, BeginMode begin_mode, ProgramObject program) { DrawingInfo drawing_info = new DrawingInfo(); drawing_info.begin_mode = begin_mode; drawing_info.program = program; GL.GenVertexArrays(1, out drawing_info.VAO_ID); GL.GenBuffers(1, out drawing_info.VBO_ID); objects.Add(drawable, drawing_info); }
public VBO(OpenGL gl, BeginMode beginMode) { Mode = beginMode; _gl = gl; var buffers = new uint[1]; gl.GenBuffers(1, buffers); Handle = buffers[0]; Count = 0; }
public static void Begin(BeginMode mode) { immMode = mode; if(vertices == null)vertices = new List<vector3d>(); if(colors == null)colors = new List<vector4d>(); if(normals == null)normals = new List<vector3d>(); if(texcoords == null)texcoords = new List<vector3d>(); vertices.Clear(); colors.Clear(); normals.Clear(); texcoords.Clear(); }
public Draw(ProgramObject program, BeginMode begin_mode) : base(program, begin_mode) { /*Triangle t = new Triangle(new Vertex[]{ new Vertex(new Vector4(0, 0, 0, 1f)), new Vertex(new Vector4(0.5f, 0.5f, 0, 1f)), new Vertex(new Vector4(0.5f, 0, 0, 1f)), }); triangles.Add(t);*/ //triangles.triangulate(sweep.polynet.faces.ToArray()); }
public static void RenderCube(Vector3 location, Vector3 size, BeginMode mode, Vector3 colorMult) { MatrixHelper.SetViewProjection(ref Forgottenvoxels.lookat, ref Forgottenvoxels.perspective); ShaderController.Cube.UseProgram(); ShaderController.Cube.SetUniform("colorMult", colorMult); GL.Enable(EnableCap.DepthTest); GL.Translate(location); GL.Scale(size * 4); buffer.Render(mode); GL.Scale(-(size * 4)); GL.Translate(-location); GL.Disable(EnableCap.DepthTest); GL.UseProgram(0); }
public void GetArraysforVBO(out BeginMode primitives, out VertexT2fN3fV3f[] vertices, out uint[] indices) { primitives = PrimitiveMode; vertices = new VertexT2fN3fV3f[VertexArray.Length]; for (uint i = 0; i < VertexArray.Length; i++) { vertices[i].TexCoord = (Vector2)VertexArray[i].TexCoord; vertices[i].Normal = (Vector3)VertexArray[i].Normal; vertices[i].Position = (Vector3)VertexArray[i].Position; } indices = IndexArray; }
public static void BeginMode(PrimitiveTopology bTopology, out BeginMode mode, out int patchVertexCount) { switch (bTopology) { case PrimitiveTopology.PointList: mode = OpenTK.Graphics.OpenGL.BeginMode.Points; patchVertexCount = 0; return; case PrimitiveTopology.LineList: mode = OpenTK.Graphics.OpenGL.BeginMode.Lines; patchVertexCount = 0; return; case PrimitiveTopology.LineStrip: mode = OpenTK.Graphics.OpenGL.BeginMode.LineStrip; patchVertexCount = 0; return; case PrimitiveTopology.TriangleList: mode = OpenTK.Graphics.OpenGL.BeginMode.Triangles; patchVertexCount = 0; return; case PrimitiveTopology.TriangleStrip: mode = OpenTK.Graphics.OpenGL.BeginMode.TriangleStrip; patchVertexCount = 0; return; case PrimitiveTopology.LineListWithAdjacency: mode = OpenTK.Graphics.OpenGL.BeginMode.LinesAdjacency; patchVertexCount = 0; return; case PrimitiveTopology.LineStripWithAdjacency: mode = OpenTK.Graphics.OpenGL.BeginMode.LineStripAdjacency; patchVertexCount = 0; return; case PrimitiveTopology.TriangleListWithAdjacency: mode = OpenTK.Graphics.OpenGL.BeginMode.TrianglesAdjacency; patchVertexCount = 0; return; case PrimitiveTopology.TriangleStripWithAdjacency: mode = OpenTK.Graphics.OpenGL.BeginMode.TriangleStripAdjacency; patchVertexCount = 0; return; case PrimitiveTopology.PatchList1: mode = OpenTK.Graphics.OpenGL.BeginMode.Patches; patchVertexCount = 1; return; case PrimitiveTopology.PatchList2: mode = OpenTK.Graphics.OpenGL.BeginMode.Patches; patchVertexCount = 2; return; case PrimitiveTopology.PatchList3: mode = OpenTK.Graphics.OpenGL.BeginMode.Patches; patchVertexCount = 3; return; case PrimitiveTopology.PatchList4: mode = OpenTK.Graphics.OpenGL.BeginMode.Patches; patchVertexCount = 4; return; case PrimitiveTopology.PatchList5: mode = OpenTK.Graphics.OpenGL.BeginMode.Patches; patchVertexCount = 5; return; case PrimitiveTopology.PatchList6: mode = OpenTK.Graphics.OpenGL.BeginMode.Patches; patchVertexCount = 6; return; case PrimitiveTopology.PatchList7: mode = OpenTK.Graphics.OpenGL.BeginMode.Patches; patchVertexCount = 7; return; case PrimitiveTopology.PatchList8: mode = OpenTK.Graphics.OpenGL.BeginMode.Patches; patchVertexCount = 8; return; case PrimitiveTopology.PatchList9: mode = OpenTK.Graphics.OpenGL.BeginMode.Patches; patchVertexCount = 9; return; case PrimitiveTopology.PatchList10: mode = OpenTK.Graphics.OpenGL.BeginMode.Patches; patchVertexCount = 10; return; case PrimitiveTopology.PatchList11: mode = OpenTK.Graphics.OpenGL.BeginMode.Patches; patchVertexCount = 11; return; case PrimitiveTopology.PatchList12: mode = OpenTK.Graphics.OpenGL.BeginMode.Patches; patchVertexCount = 12; return; case PrimitiveTopology.PatchList13: mode = OpenTK.Graphics.OpenGL.BeginMode.Patches; patchVertexCount = 13; return; case PrimitiveTopology.PatchList14: mode = OpenTK.Graphics.OpenGL.BeginMode.Patches; patchVertexCount = 14; return; case PrimitiveTopology.PatchList15: mode = OpenTK.Graphics.OpenGL.BeginMode.Patches; patchVertexCount = 15; return; case PrimitiveTopology.PatchList16: mode = OpenTK.Graphics.OpenGL.BeginMode.Patches; patchVertexCount = 16; return; case PrimitiveTopology.PatchList17: mode = OpenTK.Graphics.OpenGL.BeginMode.Patches; patchVertexCount = 17; return; case PrimitiveTopology.PatchList18: mode = OpenTK.Graphics.OpenGL.BeginMode.Patches; patchVertexCount = 18; return; case PrimitiveTopology.PatchList19: mode = OpenTK.Graphics.OpenGL.BeginMode.Patches; patchVertexCount = 19; return; case PrimitiveTopology.PatchList20: mode = OpenTK.Graphics.OpenGL.BeginMode.Patches; patchVertexCount = 20; return; case PrimitiveTopology.PatchList21: mode = OpenTK.Graphics.OpenGL.BeginMode.Patches; patchVertexCount = 21; return; case PrimitiveTopology.PatchList22: mode = OpenTK.Graphics.OpenGL.BeginMode.Patches; patchVertexCount = 22; return; case PrimitiveTopology.PatchList23: mode = OpenTK.Graphics.OpenGL.BeginMode.Patches; patchVertexCount = 23; return; case PrimitiveTopology.PatchList24: mode = OpenTK.Graphics.OpenGL.BeginMode.Patches; patchVertexCount = 24; return; case PrimitiveTopology.PatchList25: mode = OpenTK.Graphics.OpenGL.BeginMode.Patches; patchVertexCount = 25; return; case PrimitiveTopology.PatchList26: mode = OpenTK.Graphics.OpenGL.BeginMode.Patches; patchVertexCount = 26; return; case PrimitiveTopology.PatchList27: mode = OpenTK.Graphics.OpenGL.BeginMode.Patches; patchVertexCount = 27; return; case PrimitiveTopology.PatchList28: mode = OpenTK.Graphics.OpenGL.BeginMode.Patches; patchVertexCount = 28; return; case PrimitiveTopology.PatchList29: mode = OpenTK.Graphics.OpenGL.BeginMode.Patches; patchVertexCount = 29; return; case PrimitiveTopology.PatchList30: mode = OpenTK.Graphics.OpenGL.BeginMode.Patches; patchVertexCount = 30; return; case PrimitiveTopology.PatchList31: mode = OpenTK.Graphics.OpenGL.BeginMode.Patches; patchVertexCount = 31; return; case PrimitiveTopology.PatchList32: mode = OpenTK.Graphics.OpenGL.BeginMode.Patches; patchVertexCount = 32; return; default: throw new ArgumentOutOfRangeException("bTopology"); } }
public Drawable3D(ProgramObject program, BeginMode begin_mode) { this.begin_mode = begin_mode; this.program = program; projection_location = GL.GetUniformLocation(program.program_handle, "projectionMatrix"); model_view_location = GL.GetUniformLocation(program.program_handle, "modelView"); normal_location = GL.GetUniformLocation(program.program_handle, "normalMatrix"); light_position_location = GL.GetUniformLocation(program.program_handle, "light_position"); light_intensity_location = GL.GetUniformLocation(program.program_handle, "light_intensity"); material_ka_location = GL.GetUniformLocation(program.program_handle, "material_ka"); material_kd_location = GL.GetUniformLocation(program.program_handle, "material_kd"); material_ks_location = GL.GetUniformLocation(program.program_handle, "material_ks"); material_shine_location = GL.GetUniformLocation(program.program_handle, "material_shine"); colored_location = GL.GetUniformLocation(program.program_handle, "colored"); }
/// <summary> /// Initializes a new <see cref="VertexArrayObject"/>. /// </summary> /// <param name="indexBuffer">The <see cref="IBuffer"/> containing the index data.</param> /// <param name="drawMode">The <see cref="BeginMode"/>.</param> /// <param name="indexBufferType">The type of the indices.</param> /// <param name="buffers">The buffers containing the actual vertex data.</param> public VertexArrayObject(IReadOnlyBuffer indexBuffer, BeginMode drawMode, DrawElementsType indexBufferType, params BufferDescription[] buffers) { Contract.Requires<ArgumentNullException>(buffers != null); Contract.Requires<ArgumentNullException>(indexBuffer != null); Contract.Requires<ArgumentException>(indexBuffer.Target == BufferTarget.ElementArrayBuffer); this.VerifyAccess(); this.DrawMode = drawMode; this.IndexBuffer = indexBuffer; this.IndexType = indexBufferType; this.VertexBuffers = buffers.ToImmutableArray(); this.Handle = GL.GenVertexArray(); // Can't use Binding and using clause here because it causes a stack overflow (Bindable.Bind -> Initialize) try { GL.BindVertexArray(this); foreach (BufferDescription desc in this.VertexBuffers) { if (desc.Buffer != null) { using (Binding vboBinding = desc.Buffer.Bind()) { foreach (VertexAttributePointer vertexPointer in desc.VertexAttributePointers.OrderBy(vap => vap.Index)) { vertexPointer.Enable(); vertexPointer.Apply(); } } } } this.IndexBuffer.Bind(); } finally { GL.BindVertexArray(0); } this.IndexBuffer.Unbind(); }
private static void drawRectBase(BeginMode mode, float x, float y, float z, float w, float h, bool allowSmooth) { if (allowSmooth) { GL.Enable(EnableCap.LineSmooth); } else { GL.Disable(EnableCap.LineSmooth); } rectVertices[0, 0] = x; rectVertices[0, 1] = y; rectVertices[0, 2] = z; rectVertices[1, 0] = x + w; rectVertices[1, 1] = y; rectVertices[1, 2] = z; rectVertices[2, 0] = x + w; rectVertices[2, 1] = y + h; rectVertices[2, 2] = z; rectVertices[3, 0] = x; rectVertices[3, 1] = y + h; rectVertices[3, 2] = z; GL.PushMatrix(); //开始绘制 GL.EnableClientState(ArrayCap.VertexArray); GL.VertexPointer(3, VertexPointerType.Float, 0, rectVertices); GL.DrawArrays(mode, 0, 4); GL.DisableClientState(ArrayCap.VertexArray); GL.PopMatrix(); if (!allowSmooth) { GL.Enable(EnableCap.LineSmooth); } else { GL.Disable(EnableCap.LineSmooth); } }
public static void DrawRangeElements(BeginMode mode, int start, int end, int count, DrawElementsType type, IntPtr indices) { #if USE_OPENGL if (openGlHardwareAvailable) { if (glHasBufferObjects) { OpenTK.Graphics.OpenGL.GL.DrawRangeElements((OpenTK.Graphics.OpenGL.BeginMode)mode, start, end, count, (OpenTK.Graphics.OpenGL.DrawElementsType)type, indices); } else { unsafe { fixed (byte* buffer = bufferData[currentElementArrayBufferIndex]) { byte* passedBuffer = &buffer[(int)indices]; OpenTK.Graphics.OpenGL.GL.DrawElements((OpenTK.Graphics.OpenGL.BeginMode)mode, count, (OpenTK.Graphics.OpenGL.DrawElementsType)type, new IntPtr(passedBuffer)); } } } } #else if (glHasBufferObjects) { throw new NotImplementedException(); } else { unsafe { fixed (byte* buffer = bufferData[currentElementArrayBufferIndex]) { byte* passedBuffer = &buffer[(int)indices]; OpenTK.Graphics.ES11.GL.DrawElements((OpenTK.Graphics.ES11.All)mode, count, (OpenTK.Graphics.ES11.All)type, new IntPtr(passedBuffer)); } } } #endif }
public void AddMeshToScene(Vector3[] vertices, Vector3[] normals, uint[] indices, BeginMode mode, Matrix4 world, Instance[] inst, String name = "mesh") { EffectInfo info = new EffectInfo(); info.VertID = Renderer.LoadBuffer(vertices, sceneID, VertexPosition, 0); info.NormID = Renderer.LoadBuffer(normals, sceneID, VertexNormal, 1); info.IndcID = Renderer.LoadBuffer(indices); info.Count = indices.Length; info.Mode = mode; info.World = world; info.Name = GetNewName(name); info.Instances = new List<Instance>(inst); _info.Add(info.Name, info); }
public EffectInfo(int v, int n, int i, int c, BeginMode m, String s) : this(v, n, i, c, m, s, Matrix4.Identity) { }
public EffectInfo(int v, int n, int i, int c, BeginMode m, String s, Matrix4 w) { VertID = v; NormID = n; IndcID = i; Count = c; Mode = m; World = w; Name = s; Instances = new List<Instance>(); }
//public GLBracketDrawing(BeginMode aMode, GraphicsInterface gi) //{ // fGI = gi; // fMode = aMode; //} public GLBracketDrawing(GraphicsInterface gi, BeginMode aMode) { fGI = gi; fMode = aMode; }
public static void Begin(BeginMode mode, Action action) { GL.Begin(mode); action(); GL.End(); }
public static void DrawArrays(BeginMode mode, int first, int count) { #if USE_OPENGL if (openGlHardwareAvailable) { OpenTK.Graphics.OpenGL.GL.DrawArrays((OpenTK.Graphics.OpenGL.BeginMode)mode, first, count); } #else OpenTK.Graphics.ES11.GL.DrawArrays((OpenTK.Graphics.ES11.All)mode, first, count); #endif }
public static void DrawElements(BeginMode mode, int count, DrawElementsType type, int offset) { DrawElements((PrimitiveType)mode, count, type, new IntPtr(offset)); }
public static void Begin(BeginMode mode) { #if USE_OPENGL if (openGlHardwareAvailable) { OpenTK.Graphics.OpenGL.GL.Begin((OpenTK.Graphics.OpenGL.BeginMode)mode); } #else currentImediateData.Mode = mode; #endif }
public static void Draw(BeginMode beginMode, PositionTexture[] vertexData, uint handleTexture) { int primativeCount; switch (beginMode) { case BeginMode.Triangles: primativeCount = vertexData.Length / 3; break; case BeginMode.TriangleStrip: primativeCount = vertexData.Length - 2; break; default: throw new ArgumentException(); } if (primativeCount == 0) return; GL.ActiveTexture(TextureUnit.Texture0); GL.Enable(EnableCap.Texture2D); GL.BindTexture(TextureTarget.Texture2D, handleTexture); GL.EnableClientState(EnableCap.VertexArray); GL.ClientActiveTexture(TextureUnit.Texture0); GL.EnableClientState(EnableCap.TextureCoordArray); shader.Use(); shader.SetSamplerUniform("sampler0", 0); unsafe { fixed (float* pData = &vertexData[0].x) { GL.VertexPointer(3, VertexPointerType.Float, PositionTexture.stride, (IntPtr)pData); GL.TexCoordPointer(2, TexCoordPointerType.Float, PositionTexture.stride, (IntPtr)(pData + 3)); GL.DrawArrays(beginMode, 0, vertexData.Length); } } GL.DisableClientState(EnableCap.VertexArray); GL.DisableClientState(EnableCap.TextureCoordArray); //GL.BindBuffer(BufferTarget.ArrayBuffer, 0); //GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0); GL.Disable(EnableCap.Texture2D); }
public ModelAttribute(BeginMode beginMode, string vertexPropertyName) { BeginMode = beginMode; VertexPropertyName = vertexPropertyName; }
public Mesh3D(BeginMode mode) { fMode = mode; fUseVertices = true; fUseIndices = true; }