public void BasicSpriteTexture() { Assert.True(Engine.Initialize("Altseed2 C# Engine", 800, 600, new Configuration())); var count = 0; var t1 = Texture2D.Load(@"../../Core/TestData/IO/AltseedPink.png"); var t2 = Texture2D.Load(@"../../Core/TestData/IO/AltseedPink.jpg"); Assert.NotNull(t1); Assert.NotNull(t2); var s1 = RenderedSprite.Create(); var s1_2 = RenderedSprite.Create(); var s1_3 = RenderedSprite.Create(); var s2 = RenderedSprite.Create(); s1.Texture = t1; s1.Src = new RectF(0, 0, 128, 128); var trans = new Matrix44F(); trans.SetTranslation(100, 200, 0); s1_2.Texture = t1; s1_2.Transform = trans; s1_2.Src = new RectF(128, 128, 256, 256); trans = new Matrix44F(); trans.SetTranslation(200, 200, 0); s1_3.Texture = t1; s1_3.Transform = trans; s1_3.Src = new RectF(128, 128, 256, 256); trans = new Matrix44F(); trans.SetTranslation(200, 200, 0); s2.Texture = t2; s2.Transform = trans; s2.Src = new RectF(128, 128, 256, 256); while (Engine.DoEvents() && count++ < 300) { Assert.True(Engine.Graphics.BeginFrame()); Engine.Renderer.DrawSprite(s1); Engine.Renderer.DrawSprite(s1_2); Engine.Renderer.DrawSprite(s2); Engine.Update(); var cmdList = Engine.Graphics.CommandList; cmdList.SetRenderTargetWithScreen(); Engine.Renderer.Render(cmdList); Assert.True(Engine.Graphics.EndFrame()); } Engine.Terminate(); }
public void DrawingPriority() { Assert.True(Engine.Initialize("ObjectSystem Test", 800, 600, new Configuration())); var texture = Texture2D.Load(@"../../Core/TestData/IO/AltseedPink.png"); var texture2 = Texture2D.Load(@"../../Core/TestData/IO/AltseedPink.jpg"); Assert.NotNull(texture); var scene = Engine.CurrentScene; var obj1 = new TaggedObject() { DrawingPriority = 1, Tag = "1", }; var tr = new Matrix44F(); tr.SetTranslation(0, 0, 0); var comp1 = new TextureComponent() { Texture = texture, Src = new RectF(200, 0, 200, 200), Transform = tr, }; obj1.AddComponent(comp1); scene.AddObject(obj1); var obj2 = new TaggedObject() { DrawingPriority = 2, Tag = "2", }; tr = new Matrix44F(); tr.SetTranslation(200, 200, 0); var comp2 = new TextureComponent() { Texture = texture2, Src = new RectF(100, 100, 200, 200), Transform = tr, }; obj2.AddComponent(comp2); scene.AddObject(obj2); var obj3 = new TaggedObject() { DrawingPriority = 3, Tag = "3", }; tr = new Matrix44F(); tr.SetTranslation(400, 400, 0); var comp3 = new TextureComponent() { Texture = texture, Src = new RectF(0, 200, 200, 200), Transform = tr, }; obj3.AddComponent(comp3); scene.AddObject(obj3); #if COUNT var count = 0; #endif while (Engine.DoEvents() #if COUNT && count < 300 #endif ) { Assert.True(Engine.Graphics.BeginFrame()); Engine.Update(); var cmdList = Engine.Graphics.CommandList; cmdList.SetRenderTargetWithScreen(); Engine.Renderer.Render(cmdList); Assert.True(Engine.Graphics.EndFrame()); if (Engine.Keyboard.GetKeyState(Keys.Escape) == ButtonState.Push) { break; } #if COUNT count++; #endif } Engine.Terminate(); }