public VertexArrayObject(BufferObject <TVerexType> vbo, BufferObject <TIndexType> ibo) { _id = GL.GenVertexArray(); Bind(); vbo.Bind(); ibo.Bind(); }
public SpriteBatch(JackApp jack, int batchSize = 1000) { _batchSize = batchSize; _quadShader = Shader.FromStrings(_quadVertShaderSource, _quadFragmentShaderSource); // the amount of quads times the size of a vertex times 4 vertices per quad _indices = GenerateIndices(batchSize); // make a dynamic vbo and set it's data to null _quadVbo = new BufferObject <float>(_vertices, BufferTarget.ArrayBuffer, BufferUsageHint.DynamicDraw); GL.BufferData(BufferTarget.ArrayBuffer, VerticesAmount * sizeof(float), IntPtr.Zero, BufferUsageHint.DynamicDraw); _quadIbo = new BufferObject <int>(_indices, BufferTarget.ElementArrayBuffer); // add descriptions for the vertices inside the vao _quadVao = new VertexArrayObject <float, int>(_quadVbo, _quadIbo); _quadVao.VertexAttribPointer(0, POSITION_SIZE, VertexAttribPointerType.Float, VertexSize, 0); _quadVao.VertexAttribPointer(1, COLOR_SIZE, VertexAttribPointerType.Float, VertexSize, POSITION_SIZE); _quadVao.VertexAttribPointer(2, TEX_COORDS_SIZE, VertexAttribPointerType.Float, VertexSize, POSITION_SIZE + COLOR_SIZE); _quadVao.VertexAttribPointer(3, TEX_INDEX_SIZE, VertexAttribPointerType.Float, VertexSize, POSITION_SIZE + COLOR_SIZE + TEX_COORDS_SIZE); JackApp.OnExit += Dispose; }