public void TestDrawQuad() { var pixel = new Pixel(); _window = new GameWindow { Width = 200, Height = 200 }; _window.RenderFrame += (caller, args) => { IGL gl = new GLWrapper(); gl.ReadBuffer(ReadBufferMode.Front); gl.Clear(ClearBufferMask.ColorBufferBit); gl.Begin(PrimitiveType.Quads); { gl.Color3(1.0f, 1.0f, 1.0f); gl.Vertex2(0.0f, 0.0f); gl.Vertex2(-1.0f, 0.0f); gl.Vertex2(-1.0f, -1.0f); gl.Vertex2(0.0f, -1.0f); } gl.End(); _window.SwapBuffers(); pixel.ReadBuffer(0, 0); _window.Close(); }; _window.Run(); Assert.AreEqual(new Pixel(1.0f, 1.0f, 1.0f), pixel); }
public void TestSetModelViewMatrix() { var pixels = new[] { new Pixel(), new Pixel(), new Pixel(), new Pixel() }; _window = new GameWindow { Width = 200, Height = 200 }; _window.RenderFrame += (caller, args) => { IGL gl = new GLWrapper(); gl.MatrixMode(MatrixMode.Projection); gl.LoadIdentity(); gl.Ortho(0.0, 2.0, 0.0, 2.0, 0.0, 4.0); gl.Viewport(0, 0, 200, 200); gl.MatrixMode(MatrixMode.Modelview); gl.ReadBuffer(ReadBufferMode.Front); gl.Clear(ClearBufferMask.ColorBufferBit); gl.Color3(1.0f, 1.0f, 1.0f); DrawQuad(); gl.PushMatrix(); gl.Translate(0.0f, 1.0f, 0.0f); gl.Color3(1.0f, 0.0f, 0.0f); DrawQuad(); gl.PopMatrix(); gl.PushMatrix(); gl.Translate(1.0f, 1.0f, 0.0f); gl.Color3(0.0f, 1.0f, 0.0f); DrawQuad(); gl.PopMatrix(); gl.PushMatrix(); gl.Translate(1.0f, 0.0f, 0.0f); gl.Color3(0.0f, 0.0f, 1.0f); DrawQuad(); gl.PopMatrix(); _window.SwapBuffers(); pixels[0].ReadBuffer(99, 99); pixels[1].ReadBuffer(99, 100); pixels[2].ReadBuffer(100, 100); pixels[3].ReadBuffer(100, 99); _window.Close(); }; _window.Run(); Assert.AreEqual(new Pixel(1.0f, 1.0f, 1.0f), pixels[0]); Assert.AreEqual(new Pixel(1.0f, 0.0f, 0.0f), pixels[1]); Assert.AreEqual(new Pixel(0.0f, 1.0f, 0.0f), pixels[2]); Assert.AreEqual(new Pixel(0.0f, 0.0f, 1.0f), pixels[3]); }