private void MakeVAO() { vbo_xy = new BufferObject <float>(quad_xy, BufferTarget.ArrayBuffer); ebo_ix = new BufferObject <byte>(quad_el, BufferTarget.ElementArrayBuffer); vao = new VertexArrayObject(); vao.Bind(); vbo_xy.Bind(); vao.SetAttrib(0, 2, VertexAttribPointerType.Float); int stride = this.InstanceStride; var vbo = this.VBO; vbo.Bind(); vao.SetAttrib(1, 4, VertexAttribPointerType.Float, false, stride, 0, 1); vao.SetAttrib(2, 4, VertexAttribPointerType.Float, false, stride, 16, 1); vao.SetAttrib(3, 4, VertexAttribPointerType.Float, false, stride, 32, 1); vao.SetAttrib(4, 4, VertexAttribPointerType.Float, false, stride, 48, 1); vao.SetAttrib(5, 4, VertexAttribPointerType.UnsignedByte, true, stride, 64, 1); vbo.Unbind(); vao.Enable(0); vao.Enable(1); vao.Enable(2); vao.Enable(3); vao.Enable(4); vao.Enable(5); vao.Unbind(); }
/// Constructor. public Renderer(Display display) { this.display = display; this.spriteBatch = new SpriteBatch( LoadShaderProgram("vert.glsl", "frag.glsl"), 2048 ); this.rectangleBatch = new RectangleBatch( LoadShaderProgram("rect.v.glsl", "rect.f.glsl"), 256 ); vboQuadPosition = new BufferObject <float>(quad_xy, BufferTarget.ArrayBuffer); vboQuadTexcoord = new BufferObject <float>(quad_uv, BufferTarget.ArrayBuffer); ppVao = new VertexArrayObject(); ppVao.Bind(); vboQuadPosition.Bind(); ppVao.SetAttrib(0, 2, VertexAttribPointerType.Float); vboQuadTexcoord.Bind(); ppVao.SetAttrib(1, 2, VertexAttribPointerType.Float); ppVao.Enable(0); ppVao.Enable(1); ppVao.Unbind(); ppEbo = new BufferObject <byte>(quad_ix, BufferTarget.ElementArrayBuffer); frameBuffers = new FrameBuffer[2]; frameBuffers[0] = new FrameBuffer(display.Resolution, PixelFormat.Rgba); frameBuffers[1] = new FrameBuffer(display.Resolution, PixelFormat.Rgba); activeFramebuffer = 0; this.screenBuffer = new FrameBuffer(display.Viewport); this.blit = LoadShaderProgram("blit.v.glsl", "blit.f.glsl"); this.gray = LoadShaderProgram("blit.v.glsl", "gray.f.glsl"); screenBuffer.SetViewport(); }