private void CreateAndFillBuffers() { Vector3[] aPositions = new Vector3[] { new Vector3(-1, -1, 0), new Vector3(1, -1, 0), new Vector3(-1, 1, 0), new Vector3(1, 1, 0)}; Vector2[] aTexCoords = new Vector2[] { new Vector2(0, 1), new Vector2(1, 1), new Vector2(0, 0), new Vector2(1, 0)}; positions = context.NewVertexBuffer<Vector3>(VertexAttribPointerType.Float, 3); positions.UploadVertices(aPositions); textureCoords = context.NewVertexBuffer<Vector2>(VertexAttribPointerType.Float, 2); textureCoords.UploadVertices(aTexCoords); indices = context.NewIndicesBuffer(); indices.UploadIndices(new uint[] {0, 1, 2, 3}); }
public TextureRenderer(GLGraphicsContext context, GLTexture texture) { this.context = context; texture = context.NewTexture(OpenTK.Graphics.OpenGL.TextureMinFilter.Nearest, OpenTK.Graphics.OpenGL.TextureMagFilter.Nearest, OpenTK.Graphics.OpenGL.TextureWrapMode.Clamp, OpenTK.Graphics.OpenGL.TextureWrapMode.Clamp); vertices = context.NewVertexBuffer<Vector3>(OpenTK.Graphics.OpenGL.VertexAttribPointerType.Float, 3); vertices.UploadVertices(new Vector3[] { new Vector3(-1, -1, 0), new Vector3(1, -1, 0), new Vector3(-1, 1, 0), new Vector3(1, 1, 0)}); texCoords = context.NewVertexBuffer<Vector2>(OpenTK.Graphics.OpenGL.VertexAttribPointerType.Float, 2); texCoords.UploadVertices(new Vector2[] { new Vector2(0, 0), new Vector2(1, 0), new Vector2(0, 1), new Vector2(1, 1)}); prog = context.NewProgram(MVP_VERTEX_SHADER, TEXTURE_SHADER); paramSpec = ImmutableList<Tuple<String, Object>>.List( Tuple.Create<String, Object>("a_position", vertices), Tuple.Create<String, Object>("a_texPos", texCoords), Tuple.Create<String, Object>("u_texture0", texture)); }