internal void RenderFrame(TerminalSpaceWindow window, Dictionary <uint, RenderObject> renderList) { //============================================================================= //Setup before drawing //Clear the screen GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); //Set the ShaderProgram GL.UseProgram(programList["default"]); //TODO: Abstract away Shader Program selection //Should only really need to be called when a new shader program is set //Get the IDs for the shader uniforms modelMatrixUni = GL.GetUniformLocation(programList["default"], "modelMatrix"); viewMatrixUni = GL.GetUniformLocation(programList["default"], "viewMatrix"); projectionMatrixUni = GL.GetUniformLocation(programList["default"], "projectionMatrix"); //texUni = GL.GetUniformLocation(programList["default"], "tex"); //Update matricies in the shader program Matrix4 viewMatrix = camera.GetViewMatrix(); Matrix4 projectionMatrix = camera.GetProjectionMatrix(); GL.UniformMatrix4(viewMatrixUni, false, ref viewMatrix); GL.UniformMatrix4(projectionMatrixUni, false, ref projectionMatrix); foreach (RenderObject renderObject in renderList.Values) { //Grab object information from arrays Matrix4 modelMatrix = renderObject.Transform.GetModelMatrix(); int texture = renderObject.TextureInfo.TextureID; //Update Matrix (Specific to the object) GL.UniformMatrix4(modelMatrixUni, false, ref modelMatrix); //Set Texture GL.ActiveTexture(TextureUnit.Texture0 + 0); GL.BindTexture(TextureTarget.Texture2D, texture); //Draw Mesh GL.BindVertexArray(renderObject.MeshInfo.VertexArrayID); GL.DrawElements( (BeginMode)PrimitiveType.Triangles, renderObject.MeshInfo.AmountOfIndices, DrawElementsType.UnsignedShort, renderObject.MeshInfo.BufferOffset); } //Display the drawn image window.SwapBuffers(); }
static void Main(string[] args) { double updateSec = 30; double frameSec = 60; int winHeight = 600; int winWidth = 800; //Disposible TerminalSpaceWindow window = new TerminalSpaceWindow(winWidth, winHeight); window.Run(updateSec, frameSec); window.Dispose(); }