public void Render() { DateTime dtStart = DateTime.Now; Console.WriteLine("{0} milliseconds since last render.", (DateTime.Now - lastRender).TotalMilliseconds); lastRender = dtStart; // Console.WriteLine(String.Format("{0:x} {1:x}", Engine.ReadMemory8(0x00), Engine.ReadMemory8(0x44))); // Draw tile table 1 /*int count = 0; * for (int y = 0; y < 16; y++) * for (int x = 0; x < 16; x++) * DrawTile(Engine.Cartridge.CHRBanks[0], count++, x*8, y*8, 0); * //DrawTileFromCache(Engine.PPU.CHRCache, count++, x, y, 0); * * // Draw tile table 2 * for (int y = 0; y < 16; y++) * for (int x = 0; x < 16; x++) * DrawTile(Engine.Cartridge.CHRBanks[0], count++, 128 + (x*8), (y*8), 0); * //DrawTileFromCache(Engine.PPU.CHRCache, count++, x, y, 0); */ // SwapBuffer(); // Gl blah blah lock (RenderLockBlob) { int gerr = Gl.glGetError(); if (gerr != 0) { Log.w("glGetError():: " + Glu.gluErrorString(gerr)); } // How inefficient is this? // (not rhetorical question, seriously -- does it matter?) int WindowWidth, WindowHeight; Glfw.glfwGetWindowSize(out WindowWidth, out WindowHeight); Gl.glViewport(0, 0, WindowWidth, WindowHeight); // clear background (no, really?) Gl.glClearColor(((float)backgroundColor.R) / 255f, ((float)backgroundColor.G / 255f), ((float)backgroundColor.B / 255f), ((float)backgroundColor.A / 255f)); Gl.glClearDepth(double.MinValue); Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); // Set-up the modelview matrix again. Gl.glMatrixMode(Gl.GL_MODELVIEW); Gl.glLoadIdentity(); // Think this does nothing.. used to be camera code Gl.glScalef(1f, 1f, 1f); Gl.glTranslatef(0f, 0f, 0f); Gl.glRotatef(0f, 0f, 0f, 1f); // DO RENDER HERE :) sortTexture(ref SprLowBuffer, ref SprLowPointer); sortTexture(ref BGBuffer, ref BGPointer); sortTexture(ref SprHighBuffer, ref SprHighPointer); renderScreen(SprLowPointer); renderScreen(BGPointer); renderScreen(SprHighPointer); // Finished, swap buffers Glfw.glfwSwapBuffers(); Glfw.glfwPollEvents(); // Debug DateTime dtEnd = DateTime.Now; //Console.WriteLine((dtEnd - dtStart).TotalMilliseconds.ToString() + "ms to render"); } }
/// <summary> /// A warning to all those who cross me! /// </summary> /// <param name="warning">What it is that's got you so worked up</param> /// <param name="format">Formatting shizz.</param> public static void w(string warning, params object[] format) { Log.w(String.Format(warning, format)); }