public virtual void Load(int width, int height) { Width = width; Height = height; _page = new Texture(); GUIShader = Assets.Fetch<ShaderProgram>("GUI"); GUIShader.AddUniform("scale"); VBO = new VBO<VertexPositionNormalTexture>(); VAO = new VAO<VertexPositionNormalTexture>(); VBO.Buffer(new[]{ new VertexPositionNormalTexture{Position = new Vector3(0, Height, 0f),Normal = Vector3.UnitZ,TexCoord = new Vector2(0, Height)}, new VertexPositionNormalTexture{Position = new Vector3(Width, Height, 0f),Normal = Vector3.UnitZ,TexCoord = new Vector2(Width, Height)}, new VertexPositionNormalTexture{Position = new Vector3(Width, 0, 0f),Normal = Vector3.UnitZ,TexCoord = new Vector2(Width, 0)}, new VertexPositionNormalTexture{Position = new Vector3(0, 0, 0),Normal = Vector3.UnitZ,TexCoord = new Vector2(0,0)} }); VAO.Setup(GUIShader, VBO); _webView = WebCore.CreateWebView(Width, Height); WebCore.BaseDirectory = Path.Combine(Directory.GetCurrentDirectory(), "GUI"); _webView.FlushAlpha = false; _webView.IsTransparent = true; _webView.CreateObject("console"); _webView.SetObjectCallback("console", "log", (sender, e) => Bus.Add(new DebugMessage(Timer.LastTickTime, e.Arguments[0].ToString()))); _webView.CreateObject("GUI"); _webView.CreateObject("Bus"); _webView.LoadFile("index.htm"); }
public void Load() { _program = _assets.Fetch<ShaderProgram>("Main"); _vbo = new VBO(); data = new List<Vertex>(); _tex = _assets.Fetch<Texture>("blank.png"); const float size = 1f; data.Add(new Vertex { Position = new Vector3(0, 0, 0), Colour = Color.Blue.ToVector4() }); data.Add(new Vertex { Position = new Vector3(size, 0, 0), Colour = Color.Blue.ToVector4() }); data.Add(new Vertex { Position = new Vector3(0, 0, 0), Colour = Color.Red.ToVector4() }); data.Add(new Vertex { Position = new Vector3(0, size, 0), Colour = Color.Red.ToVector4() }); data.Add(new Vertex { Position = new Vector3(0, 0, 0), Colour = Color.Green.ToVector4() }); data.Add(new Vertex { Position = new Vector3(0, 0, size), Colour = Color.Green.ToVector4() }); _vbo.Buffer(data.ToArray()); _vao = new VAO(_program, _vbo); Loaded = true; }
public void Load() { _program = _assets.Fetch<ShaderProgram>("Main"); _vbo = new VBO(); _tex = _assets.Fetch<Texture>("star.png"); data = new List<Vertex>(); var rnd = new Random(); for (var i = 0; i < 150; i++) { //rnd.NextDouble() var x = rnd.NextFloat(-80f, 80f); var y = rnd.NextFloat(-80f, 80f); var z = rnd.NextFloat(0f, 10f) - 60.0f; AddStar((float)rnd.NextDouble() + 0.1f, new Vector3(x, y,z)); } _vbo.Buffer(data.ToArray()); _vao = new VAO(_program, _vbo); Loaded = true; }
public void Load() { _program = _assets.Fetch<ShaderProgram>("Main"); _vbo = new VBO(); _data = new List<Vertex>(); _tex = _assets.Fetch<Texture>("blank.png"); stl = new STLLoader("Media/Models/testship.stl"); var col = Color.FromArgb(255, 94, 169, 198); foreach (var element in stl.Elements) { _data.Add(new Vertex { Position = element.P1.ToVector3(), Normal = element.Normal.ToVector3(), Colour = new Vector4(col.R / 255f, col.G / 255f, col.B / 255f, col.A / 255f) }); _data.Add(new Vertex { Position = element.P2.ToVector3(), Normal = element.Normal.ToVector3(), Colour = new Vector4(col.R / 255f, col.G / 255f, col.B / 255f, col.A / 255f) }); _data.Add(new Vertex { Position = element.P3.ToVector3(), Normal = element.Normal.ToVector3(), Colour = new Vector4(col.R / 255f, col.G / 255f, col.B / 255f, col.A / 255f) }); } _vbo.Buffer(_data.ToArray()); _vao = new VAO(_program, _vbo); Loaded = true; }