public Texture2d Get(BitmapBuffer bb) { //get the current entry Texture2d currentTexture = _currentTextures[0]; // TODO - its a bit cruddy here that we dont respect the current texture HasAlpha condition (in fact, there's no such concept) // we might need to deal with that in the future to fix some bugs. //check if its rotten and needs recreating if (currentTexture == null || currentTexture.IntWidth != bb.Width || currentTexture.IntHeight != bb.Height) { //needs recreating. be sure to kill the old one... currentTexture?.Dispose(); //and make a new one currentTexture = _gl.LoadTexture(bb); } else { //its good! just load in the data _gl.LoadTextureData(currentTexture, bb); } //now shuffle the buffers _currentTextures[0] = _currentTextures[1]; _currentTextures[1] = currentTexture; //deterministic state, i guess currentTexture.SetFilterNearest(); return(currentTexture); }
public Texture2d Get(BitmapBuffer bb) { //get the current entry Texture2d CurrentTexture = CurrentTextures[0]; //check if its rotten and needs recreating if (CurrentTexture == null || CurrentTexture.IntWidth != bb.Width || CurrentTexture.IntHeight != bb.Height) { //needs recreating. be sure to kill the old one... if (CurrentTexture != null) { CurrentTexture.Dispose(); } //and make a new one CurrentTexture = GL.LoadTexture(bb); } else { //its good! just load in the data GL.LoadTextureData(CurrentTexture, bb); } //now shuffle the buffers CurrentTextures[0] = CurrentTextures[1]; CurrentTextures[1] = CurrentTexture; //deterministic state, i guess CurrentTexture.SetFilterNearest(); return(CurrentTexture); }
private void clear() { if (frameBufferId != -1) { GL.DeleteFramebuffer(frameBufferId); frameBufferId = -1; } if (renderBufferId != -1) { GL.DeleteRenderbuffer(renderBufferId); renderBufferId = -1; } texture?.Dispose(); texture = null; }
public void TestCreate() { Texture2d texture = null; // Create(uint, uint, PixelLayout) try { texture = new Texture2d(); Assert.IsFalse(texture.Exists(_Context)); texture.Create(16, 16, PixelLayout.RGB24); Assert.IsFalse(texture.Exists(_Context)); texture.Create(_Context); Assert.IsTrue(texture.Exists(_Context)); } finally { if (texture != null) { texture.Dispose(_Context); } texture = null; } // Create(GraphicsContext, uint, uint, PixelLayout) try { texture = new Texture2d(); Assert.IsFalse(texture.Exists(_Context)); texture.Create(_Context, 16, 32, PixelLayout.RGB24); Assert.IsTrue(texture.Exists(_Context)); Assert.AreEqual(16, texture.Width); Assert.AreEqual(32, texture.Height); Assert.AreEqual(PixelLayout.RGB24, texture.PixelLayout); } finally { if (texture != null) { texture.Dispose(_Context); } texture = null; } }
public void TestCreate() { Texture2d texture = null; // Create(uint, uint, PixelLayout) try { texture = new Texture2d(); Assert.IsFalse(texture.Exists(_Context)); texture.Create(16, 16, PixelLayout.RGB24); Assert.IsFalse(texture.Exists(_Context)); texture.Create(_Context); Assert.IsTrue(texture.Exists(_Context)); } finally { if (texture != null) texture.Dispose(_Context); texture = null; } // Create(GraphicsContext, uint, uint, PixelLayout) try { texture = new Texture2d(); Assert.IsFalse(texture.Exists(_Context)); texture.Create(_Context, 16, 32, PixelLayout.RGB24); Assert.IsTrue(texture.Exists(_Context)); Assert.AreEqual(16, texture.Width); Assert.AreEqual(32, texture.Height); Assert.AreEqual(PixelLayout.RGB24, texture.PixelLayout); } finally { if (texture != null) texture.Dispose(_Context); texture = null; } }