protected DrawObject2D CreateDrawObject2D() { DrawObject2D polygonCoordinates = DrawObject2D.CreateTriangleTopologyMeshWithPolygonCoordinates(new List <Vector2>() { new Vector2(0.0f, 0.0f), new Vector2(0.0f, Size.Y), new Vector2(Size.X, Size.Y), new Vector2(Size.X, 0.0f) }); polygonCoordinates.DrawObjectType = DrawObjectType.Quad; polygonCoordinates.TextureCoordinates[0] = 0.0f; polygonCoordinates.TextureCoordinates[1] = 0.0f; polygonCoordinates.TextureCoordinates[2] = 0.0f; polygonCoordinates.TextureCoordinates[3] = 1f; polygonCoordinates.TextureCoordinates[4] = 1f; polygonCoordinates.TextureCoordinates[5] = 1f; polygonCoordinates.TextureCoordinates[6] = 0.0f; polygonCoordinates.TextureCoordinates[7] = 0.0f; polygonCoordinates.TextureCoordinates[8] = 1f; polygonCoordinates.TextureCoordinates[9] = 1f; polygonCoordinates.TextureCoordinates[10] = 1f; polygonCoordinates.TextureCoordinates[11] = 0.0f; polygonCoordinates.Width = Size.X; polygonCoordinates.Height = Size.Y; polygonCoordinates.MinU = 0.0f; polygonCoordinates.MaxU = 1f; polygonCoordinates.MinV = 0.0f; polygonCoordinates.MaxV = 1f; return(polygonCoordinates); }
private void UpdateDrawObject2D(float width, float height) { if (_cachedMesh == null || Math.Abs(_cachedMesh.Width - width) > 0.01f && Math.Abs(_cachedMesh.Height - height) > 0.01f) { _cachedMesh = Widgets.Utility.CreateDrawObject2D(width, height); } }
public static DrawObject2D CreateDrawObject2D(float width, float height) { DrawObject2D polygonCoordinates = DrawObject2D.CreateTriangleTopologyMeshWithPolygonCoordinates(new List <Vector2>() { new Vector2(0.0f, 0.0f), new Vector2(0.0f, height), new Vector2(width, height), new Vector2(width, 0.0f) }); polygonCoordinates.DrawObjectType = DrawObjectType.Quad; polygonCoordinates.TextureCoordinates[0] = 0.0f; polygonCoordinates.TextureCoordinates[1] = 0.0f; polygonCoordinates.TextureCoordinates[2] = 0.0f; polygonCoordinates.TextureCoordinates[3] = 1f; polygonCoordinates.TextureCoordinates[4] = 1f; polygonCoordinates.TextureCoordinates[5] = 1f; polygonCoordinates.TextureCoordinates[6] = 0.0f; polygonCoordinates.TextureCoordinates[7] = 0.0f; polygonCoordinates.TextureCoordinates[8] = 1f; polygonCoordinates.TextureCoordinates[9] = 1f; polygonCoordinates.TextureCoordinates[10] = 1f; polygonCoordinates.TextureCoordinates[11] = 0.0f; polygonCoordinates.Width = width; polygonCoordinates.Height = height; polygonCoordinates.MinU = 0.0f; polygonCoordinates.MaxU = 1f; polygonCoordinates.MinV = 0.0f; polygonCoordinates.MaxV = 1f; return(polygonCoordinates); }
static Scene() { _axisHelper = new DrawObject2D { Mesh = AxisHelper.Object }; }
protected virtual void UpdateDrawObject2D() { CachedMesh = CreateDrawObject2D(); }
static void Main(string[] args) { Font font = new Font(@".\GapSansBold.ttf") { FontSize = 51, }; controller = new GameController(0); GameKeybindHost host = new GameKeybindHost(new GameKeybindList() { { "g_test", context => Keyboard.IsAnyKeyPressed, context => context.ControllerState.Buttons[GamepadButtonFlags.A, true] } }); actor = GameKeybindActor.CreateControllerActor(controller); actor.ConnectHost(host); portal = STPProject.CreateFromZIP("portal.zip"); window = new GLWindow(1280, 720, "0ms", WindowFlags.Window, VSyncMode.Off); window.ApplySetup(new Window2DSetup()); window.SetRenderPipeline(new TestRenderPipeline()); window.SetScene(scene = new Scene() { ShowAxisHelper = true }); scene.Background.Color = Color4.DarkGray; scene.Camera = new Camera() { }; SimpleShader shader = new SimpleShader("basic", AssemblyUtility.ReadAssemblyFile("SM_TEST.Default Fragment Shader1.frag"), (a, b) => { a["Color"].SetColor(b.Material.Tint); a["Scale"].SetFloat(b.Material.ShaderArguments.Get("Scale", 1f)); }); DrawObject2D obj = new DrawObject2D() { Material = { CustomShader = shader, Tint = new Color4(1f, 0.151217f, 0.050313f, 1), ShaderArguments = { ["Scale"] = 50f } } };/* * DrawObject2D obj2 = new DrawObject2D() * { * Material = * { * Tint = Color4.Aqua, * CustomShader = shader, * ShaderArguments = * { * ["Scale"] = 1000f * } * } * }; * obj2.Transform.Position.Set(300);*/ scene.Objects.Add(obj); window.RenderFrame += Window_RenderFrame; window.Run(); Debug.WriteLine("Window Closed"); }