public override void Draw() { view.Bind(); var modelview = Matrix4.LookAt(Vector3.Zero, Vector3.UnitZ, Vector3.UnitY); GL.MatrixMode(MatrixMode.Modelview); GL.LoadMatrix(ref modelview); GL.Disable(EnableCap.Texture2D); { var screenSize = Window.Instance.GameScreenSize; var x = screenSize.X / 2 - Rect.Position.X - Rect.Size.X / 2; var y = screenSize.Y / 2 - Rect.Position.Y - Rect.Size.Y / 2; GL.Translate(x, y, 0); } var w = Rect.Size.X / 2; var h = Rect.Size.Y / 2; var z = 1; Color.SetGLColor(); GL.Begin(BeginMode.Quads); //GL.Begin(BeginMode.Lines); GL.Vertex3(-w, h, z); GL.Vertex3(-w, -h, z); GL.Vertex3(w, -h, z); GL.Vertex3(w, h, z); GL.End(); }
public override void Draw() { view.Bind(); var modelview = Matrix4.LookAt(Vector3.Zero, Vector3.UnitZ, Vector3.UnitY); GL.MatrixMode(MatrixMode.Modelview); GL.LoadMatrix(ref modelview); GL.Enable(EnableCap.Texture2D); GL.Enable(EnableCap.Blend); //GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); //GL.BlendFunc(BlendingFactor.Src1Alpha, BlendingFactor.OneMinusSrcAlpha); GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha); { var screenSize = Window.Instance.GameScreenSize; var x = screenSize.X / 2 - Rect.Position.X - Rect.Size.X / 2; var y = screenSize.Y / 2 - Rect.Position.Y - Rect.Size.Y / 2; GL.Translate(x, y, 0); } var w = Rect.Size.X / 2; var h = Rect.Size.Y / 2; var z = 1; Color.SetGLColor(); texture.Bind(); //GL.Begin(BeginMode.Quads); // TriangleStrip GL.Begin(BeginMode.TriangleStrip); // //GL.Begin(BeginMode.Lines); //GL.Vertex3(-w, h, z); //GL.Vertex3(-w, -h, z); //GL.Vertex3(w, -h, z); //GL.Vertex3(w, h, z); var u1 = 0.0f; var v1 = 0.0f; var u2 = 1.0f; var v2 = 1.0f; GL.TexCoord2(u1, v1); GL.Vertex3(+w, +h, z); GL.TexCoord2(u1, v2); GL.Vertex3(+w, -h, z); GL.TexCoord2(u2, v1); GL.Vertex3(-w, +h, z); GL.TexCoord2(u2, v2); GL.Vertex3(-w, -h, z); GL.End(); }