public SpriteComponent(string filename) { if (string.IsNullOrWhiteSpace(filename)) { throw new ArgumentNullException(nameof(filename)); } this.Texture = Texture2DLoader.Load(filename); this.Rectangle = new Rectangle(0, 0, this.Texture.Width, this.Texture.Height); }
public Test(GraphicsDevice gd) { test = new Selection(0, 0, new string[] { "Duck", "Fillet", "I just want to get out of here!", "LALA" }, "Testington"); Texture2DLoader tl = new Texture2DLoader(Main.ContentManager.RootDirectory + "/test.zip", true); tl.Load(); AS = new AnimatedSprite(TemporaryContent.GetTexture("dragon"), 40, 40, 100); AS.Position = new Vector2(300, 300); }
public void LoadJpgTest() { EmbeddedResourceDirectory resourceDirectory = new("Zenseless.OpenTK.Tests.Content"); using var stream = resourceDirectory.Resource("test.jpg").Open(); Helper.ExecuteOnOpenGL(window => { var tex = Texture2DLoader.Load(stream); Assert.AreEqual(335, tex.Width); Assert.AreEqual(1024, tex.Height); GL.GetTextureLevelParameter(tex.Handle, 0, GetTextureParameter.TextureInternalFormat, out int format); Assert.AreEqual((int)All.Rgb8, format); tex.Dispose(); return(0); }); }
/// <summary> /// Initialize the level. /// </summary> public void Initialize() { LoadFunc = () => { if (Texture2DLoader != null) { Texture2DLoader.Load(); } if (SoundEffectLoader != null) { SoundEffectLoader.Load(); } PrepareLevel(); }; LoadThread = new Thread(LoadFunc); LoadThread.Start(); Initialized = true; }
public Title() { this.Texture2DLoader = new Texture2DLoader(Main.ContentManager.RootDirectory + "/Compressed/ShooterTextures.zip", false); this.SoundEffectLoader = new Content.SoundEffectLoader(Main.ContentManager.RootDirectory + "/Compressed/ShooterSoundEffects.zip", false); LoadFunc = () => { TitleScreenTexture = Texture2D.FromStream(Main.GraphicsDevice, File.OpenRead(Main.ContentManager.RootDirectory + "/Textures/TitleScreen.dat")); if (Texture2DLoader != null) { Texture2DLoader.Load(); } if (SoundEffectLoader != null) { SoundEffectLoader.Load(); } }; LoadThread = new Thread(LoadFunc); LoadThread.Start(); }