/// <summary> /// Loads contents /// </summary> public override void LoadContent() { Display.RenderState.ClearColor = Color.CornflowerBlue; // Shader Shader = Shader.CreateTextureShader(); Display.Shader = Shader; #region Texture // Loads a texture and binds it to TUI 2 Texture = new Texture2D("data/texture.png"); Texture.HorizontalWrap = TextureWrapFilter.Repeat; Texture.VerticalWrap = TextureWrapFilter.Repeat; Display.TextureUnit = 2; Display.Texture = Texture; #endregion // Matrices ModelViewMatrix = Matrix4.LookAt(new Vector3(0, 0, 1), new Vector3(0, 0, 0), new Vector3(0, 1, 0));; ProjectionMatrix = Matrix4.CreateOrthographicOffCenter(0, Display.ViewPort.Width, Display.ViewPort.Height, 0, -1.0f, 1.0f); TextureMatrix = Matrix4.Scale(1.0f / Texture.Size.Width, 1.0f / Texture.Size.Height, 1.0f); #region Buffer // Indices uint[] indices = new uint[] { 0, 1, 2, 1, 2, 3 }; Index = new IndexBuffer(); Index.Update(indices); // Creates a position, color, texture buffer Buffer = BatchBuffer.CreatePositionColorTextureBuffer(); // Vertex elements float[] vertices = new float[] { // Coord Color Texture 100.0f, 100.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 500.0f, 100.0f, 0.0f, 1.0f, 0.0f, 1.0f, 256.0f, 0.0f, 100.0f, 500.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 256.0f, 500.0f, 500.0f, 1.0f, 1.0f, 1.0f, 1.0f, 256.0f, 256.0f }; Buffer.SetVertices(vertices); // Or set data one by one Buffer.AddPoint(new Point(100, 100), Color.FromArgb(255, 0, 0), new Point(0, 0)); Buffer.AddPoint(new Point(500, 100), Color.FromArgb(0, 255, 0), new Point(256, 0)); Buffer.AddPoint(new Point(100, 500), Color.FromArgb(0, 0, 255), new Point(0, 256)); Buffer.AddPoint(new Point(500, 500), Color.FromArgb(255, 255, 255), new Point(256, 256)); Buffer.Update(); #region VAO //Batch = new BatchBuffer(); //VertexBuffer.Bind(0, 2); //Shader.BindAttrib(0, "in_position"); //ColorBuffer.Bind(1, 4); //Shader.BindAttrib(1, "in_color"); //GL.BindVertexArray(0); #endregion #endregion #region Font SpriteBatch = new Graphic.SpriteBatch(); Font = BitmapFont.CreateFromTTF("c:\\windows\\fonts\\verdana.ttf", 16, FontStyle.Regular); #endregion }