public static void LoadRenderer() { CompileShaders(); CreateProjectionMatrix(width, height); //VertexShader VertexBufferObject = GL.GenBuffer(); GL.BindBuffer(BufferTarget.ArrayBuffer, VertexBufferObject); GL.BufferData(BufferTarget.ArrayBuffer, Geometry.vertices.Length * sizeof(float), Geometry.vertices, BufferUsageHint.StaticDraw); VertexArrayObject = GL.GenVertexArray(); GL.BindVertexArray(VertexArrayObject); // 2. copy our vertices array in a buffer for OpenGL to use GL.BindBuffer(BufferTarget.ArrayBuffer, VertexBufferObject); GL.BufferData(BufferTarget.ArrayBuffer, Geometry.vertices.Length * sizeof(float), Geometry.vertices, BufferUsageHint.StaticDraw); // 3. then set our vertex attributes pointers GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 5 * sizeof(float), 0); GL.EnableVertexAttribArray(0); GL.VertexAttribPointer(1, 2, VertexAttribPointerType.Float, false, 5 * sizeof(float), 3 * sizeof(float)); GL.EnableVertexAttribArray(1); ElementBufferObject = GL.GenBuffer(); GL.BindBuffer(BufferTarget.ElementArrayBuffer, ElementBufferObject); GL.BufferData(BufferTarget.ElementArrayBuffer, Geometry.indices.Length * sizeof(uint), Geometry.indices, BufferUsageHint.StaticDraw); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.Repeat); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.Repeat); system.Use(Shader); YeenBoxTiles.initializeObjects(); }
//The draw frame loop, rendering functions go here public static void DrawFrame() { system.Use(Shader); GL.Clear(ClearBufferMask.ColorBufferBit); GL.ClearColor(0.2f, 0.3f, 0.3f, 1.0f); YeenBoxTiles.renderWorld(); /*GL.UniformMatrix4(5, false, ref position); * GL.BindTexture(TextureTarget.Texture2D, textureBind); * GL.DrawElements(PrimitiveType.Triangles, Geometry.indices.Length, DrawElementsType.UnsignedInt, 0);*/ }