public void Reset() { subTextureBounds.Clear(); currentY = 0; //may be zero in a headless context. if (atlasWidth == 0 || atlasHeight == 0) { return; } if (atlasTexture == null) { Logger.Log($"New TextureAtlas initialised {atlasWidth}x{atlasHeight}", LoggingTarget.Runtime, LogLevel.Debug); } atlasTexture = new TextureGLAtlas(atlasWidth, atlasHeight, manualMipmaps, filteringMode); using (var whiteTex = Add(3, 3)) { //add an empty white rect to use for solid box drawing (shader optimisation). byte[] white = new byte[whiteTex.Width * whiteTex.Height * 4]; for (int i = 0; i < white.Length; i++) { white[i] = 255; } whiteTex.SetData(new TextureUpload(white)); } }
private Texture loadRaw(TextureUpload upload) { if (upload == null) { return(null); } TextureGL glTexture = null; if (Atlas != null) { if ((glTexture = Atlas.Add(upload.Width, upload.Height)) == null) { Logger.Log($"Texture requested ({upload.Width}x{upload.Height}) which exceeds {nameof(TextureStore)}'s atlas size ({max_atlas_size}x{max_atlas_size}) - bypassing atlasing. Consider using {nameof(LargeTextureStore)}.", LoggingTarget.Performance); } } if (glTexture == null) { glTexture = new TextureGLSingle(upload.Width, upload.Height, manualMipmaps, filteringMode); } Texture tex = new Texture(glTexture) { ScaleAdjust = ScaleAdjust }; tex.SetData(upload); return(tex); }
public void Reset() { subTextureBounds.Clear(); currentY = 0; atlasTexture = new TextureGLSingle(atlasWidth, atlasHeight); }
public void Reset() { subTextureBounds.Clear(); currentY = 0; AtlasTexture = new TextureGLAtlas(atlasWidth, atlasHeight, manualMipmaps, filteringMode); using (var whiteTex = Add(3, 3)) whiteTex.SetData(new TextureUpload(new Image <Rgba32>(SixLabors.ImageSharp.Configuration.Default, whiteTex.Width, whiteTex.Height, Rgba32.White))); }
private void addTexture(TextureGLSingle texture) => Schedule(() => { var target = texture is TextureGLAtlas ? atlasFlow : textureFlow; if (target.Any(p => p.Texture == texture)) { return; } target.Add(new TexturePanel(texture)); });
protected override void PopIn() { base.PopIn(); foreach (var tex in TextureGLSingle.GetAllTextures()) { addTexture(tex); } TextureGLSingle.TextureCreated += addTexture; }
public void Reset() { subTextureBounds.Clear(); currentPosition = Vector2I.Zero; AtlasTexture = new TextureGLAtlas(atlasWidth, atlasHeight, manualMipmaps, filteringMode); using (var whiteTex = Add(WHITE_PIXEL_SIZE, WHITE_PIXEL_SIZE)) whiteTex.SetData(new TextureUpload(new Image <Rgba32>(SixLabors.ImageSharp.Configuration.Default, whiteTex.Width, whiteTex.Height, Rgba32.White))); currentPosition = new Vector2I(Math.Max(currentPosition.X, PADDING), PADDING); }
public void Reset() { subTextureBounds.Clear(); currentPosition = Vector2I.Zero; // We pass PADDING/2 as opposed to PADDING such that the padded region of each individual texture // occupies half of the padded space. AtlasTexture = new TextureGLAtlas(atlasWidth, atlasHeight, manualMipmaps, filteringMode, PADDING / 2); RectangleI bounds = new RectangleI(0, 0, WHITE_PIXEL_SIZE, WHITE_PIXEL_SIZE); subTextureBounds.Add(bounds); using (var whiteTex = new TextureGLSub(bounds, AtlasTexture, WrapMode.Repeat, WrapMode.Repeat)) // Generate white padding as if WhitePixel was wrapped, even though it isn't whiteTex.SetData(new TextureUpload(new Image <Rgba32>(SixLabors.ImageSharp.Configuration.Default, whiteTex.Width, whiteTex.Height, Rgba32.White))); currentPosition = new Vector2I(PADDING + WHITE_PIXEL_SIZE, PADDING); }
public TexturePanel(TextureGLSingle texture) { textureReference = new WeakReference <TextureGLSingle>(texture); Size = new Vector2(100, 132); InternalChild = new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FillDirection.Vertical, Children = new Drawable[] { titleText = new SpriteText { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Font = FrameworkFont.Regular.With(size: 16) }, new Container { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Children = new Drawable[] { usage = new UsageBackground(textureReference) { Size = new Vector2(100) }, }, }, footerText = new SpriteText { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Font = FrameworkFont.Regular.With(size: 16), }, } }; }
public void Initialize(bool withTexture = true, All filteringMode = All.Linear) { frameBuffer = GL.GenFramebuffer(); if (withTexture) { Texture = new TextureGLSingle(1, 1, true, filteringMode); Texture.SetData(new TextureUpload(new byte[0])); Texture.Upload(); Bind(); GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget2d.Texture2D, Texture.TextureId, 0); GLWrapper.BindTexture(null); Unbind(); } IsInitialized = true; }
public void Reset() { subTextureBounds.Clear(); currentY = 0; //may be zero in a headless context. if (atlasWidth == 0 || atlasHeight == 0) { return; } if (AtlasTexture == null) { Logger.Log($"New TextureAtlas initialised {atlasWidth}x{atlasHeight}", LoggingTarget.Runtime, LogLevel.Debug); } AtlasTexture = new TextureGLAtlas(atlasWidth, atlasHeight, manualMipmaps, filteringMode); using (var whiteTex = Add(3, 3)) whiteTex.SetData(new TextureUpload(new Image <Rgba32>(SixLabors.ImageSharp.Configuration.Default, whiteTex.Width, whiteTex.Height, Rgba32.White))); }