mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-13 01:26:50 -04:00
Reset texture ids to -1 in DeleteTexture().
This commit is contained in:
parent
714f03e893
commit
bc77db70e3
@ -110,7 +110,7 @@ namespace ClassicalSharp {
|
|||||||
Window.AsyncDownloader.TryGetItem( "skin_" + SkinName, out item );
|
Window.AsyncDownloader.TryGetItem( "skin_" + SkinName, out item );
|
||||||
if( item != null && item.Bmp != null ) {
|
if( item != null && item.Bmp != null ) {
|
||||||
Bitmap bmp = item.Bmp;
|
Bitmap bmp = item.Bmp;
|
||||||
Window.Graphics.DeleteTexture( renderer.TextureId );
|
Window.Graphics.DeleteTexture( ref renderer.TextureId );
|
||||||
renderer.TextureId = Window.Graphics.LoadTexture( bmp );
|
renderer.TextureId = Window.Graphics.LoadTexture( bmp );
|
||||||
SkinType = Utils.GetSkinType( bmp );
|
SkinType = Utils.GetSkinType( bmp );
|
||||||
bmp.Dispose();
|
bmp.Dispose();
|
||||||
|
10
Game/Game.cs
10
Game/Game.cs
@ -96,12 +96,10 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
void LoadAtlas( Bitmap bmp ) {
|
void LoadAtlas( Bitmap bmp ) {
|
||||||
// Cleanup old atlas if applicable.
|
// Cleanup old atlas if applicable.
|
||||||
if( TerrainAtlasTexId != -1 ) {
|
Graphics.DeleteTexture( ref TerrainAtlasTexId );
|
||||||
Graphics.DeleteTexture( TerrainAtlasTexId );
|
|
||||||
}
|
|
||||||
if( TerrainAtlas1DTexIds != null ) {
|
if( TerrainAtlas1DTexIds != null ) {
|
||||||
for( int i = 0; i < TerrainAtlas1DTexIds.Length; i++ ) {
|
for( int i = 0; i < TerrainAtlas1DTexIds.Length; i++ ) {
|
||||||
Graphics.DeleteTexture( TerrainAtlas1DTexIds[i] );
|
Graphics.DeleteTexture( ref TerrainAtlas1DTexIds[i] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( TerrainAtlas != null ) {
|
if( TerrainAtlas != null ) {
|
||||||
@ -303,9 +301,9 @@ namespace ClassicalSharp {
|
|||||||
SetNewScreen( null );
|
SetNewScreen( null );
|
||||||
fpsScreen.Dispose();
|
fpsScreen.Dispose();
|
||||||
SelectionManager.Dispose();
|
SelectionManager.Dispose();
|
||||||
Graphics.DeleteTexture( TerrainAtlasTexId );
|
Graphics.DeleteTexture( ref TerrainAtlasTexId );
|
||||||
for( int i = 0; i < TerrainAtlas1DTexIds.Length; i++ ) {
|
for( int i = 0; i < TerrainAtlas1DTexIds.Length; i++ ) {
|
||||||
Graphics.DeleteTexture( TerrainAtlas1DTexIds[i] );
|
Graphics.DeleteTexture( ref TerrainAtlas1DTexIds[i] );
|
||||||
}
|
}
|
||||||
ModelCache.Dispose();
|
ModelCache.Dispose();
|
||||||
for( int i = 0; i < NetPlayers.Length; i++ ) {
|
for( int i = 0; i < NetPlayers.Length; i++ ) {
|
||||||
|
@ -34,11 +34,10 @@ namespace ClassicalSharp.GraphicsAPI {
|
|||||||
|
|
||||||
public abstract void Bind2DTexture( int texId );
|
public abstract void Bind2DTexture( int texId );
|
||||||
|
|
||||||
public abstract void DeleteTexture( int texId );
|
public abstract void DeleteTexture( ref int texId );
|
||||||
|
|
||||||
public virtual void DeleteTexture( ref Texture texture ) {
|
public virtual void DeleteTexture( ref Texture texture ) {
|
||||||
DeleteTexture( texture.ID );
|
DeleteTexture( ref texture.ID );
|
||||||
texture.ID = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -156,12 +156,13 @@ namespace ClassicalSharp.GraphicsAPI {
|
|||||||
GL.BindTexture( TextureTarget.Texture2D, texture );
|
GL.BindTexture( TextureTarget.Texture2D, texture );
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeleteTexture( int texId ) {
|
public override void DeleteTexture( ref int texId ) {
|
||||||
if( texId <= 0 ) return;
|
if( texId <= 0 ) return;
|
||||||
#if TRACK_RESOURCES
|
#if TRACK_RESOURCES
|
||||||
textures.Remove( texId );
|
textures.Remove( texId );
|
||||||
#endif
|
#endif
|
||||||
GL.DeleteTexture( texId );
|
GL.DeleteTexture( texId );
|
||||||
|
texId = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Texturing {
|
public override bool Texturing {
|
||||||
|
@ -33,15 +33,9 @@ namespace Launcher {
|
|||||||
form.Text = MainForm.AppName + " - fetching " + output;
|
form.Text = MainForm.AppName + " - fetching " + output;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
byte[] data = client.DownloadData( resUri + uri );
|
client.DownloadFile( resUri + uri, output );
|
||||||
try {
|
|
||||||
File.WriteAllBytes( output, data );
|
|
||||||
} catch( IOException ) {
|
|
||||||
MessageBox.Show( "Unable to save " + output, "Failed to save resource", MessageBoxButtons.OK, MessageBoxIcon.Error );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} catch( WebException ) {
|
} catch( WebException ) {
|
||||||
MessageBox.Show( "Unable to download " + output, "Failed to download resource", MessageBoxButtons.OK, MessageBoxIcon.Error );
|
MessageBox.Show( "Unable to download or save " + output, "Failed to download or save resource", MessageBoxButtons.OK, MessageBoxIcon.Error );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -75,7 +75,7 @@ namespace ClassicalSharp.Model {
|
|||||||
|
|
||||||
public override void Dispose() {
|
public override void Dispose() {
|
||||||
Set.Dispose();
|
Set.Dispose();
|
||||||
graphics.DeleteTexture( DefaultSkinTextureId );
|
graphics.DeleteTexture( ref DefaultSkinTextureId );
|
||||||
}
|
}
|
||||||
|
|
||||||
class ModelSet {
|
class ModelSet {
|
||||||
|
@ -55,7 +55,7 @@ namespace ClassicalSharp.Model {
|
|||||||
|
|
||||||
public override void Dispose() {
|
public override void Dispose() {
|
||||||
Set.Dispose();
|
Set.Dispose();
|
||||||
graphics.DeleteTexture( DefaultSkinTextureId );
|
graphics.DeleteTexture( ref DefaultSkinTextureId );
|
||||||
}
|
}
|
||||||
|
|
||||||
class ModelSet {
|
class ModelSet {
|
||||||
|
@ -55,7 +55,7 @@ namespace ClassicalSharp.Model {
|
|||||||
|
|
||||||
public override void Dispose() {
|
public override void Dispose() {
|
||||||
Set.Dispose();
|
Set.Dispose();
|
||||||
graphics.DeleteTexture( DefaultSkinTextureId );
|
graphics.DeleteTexture( ref DefaultSkinTextureId );
|
||||||
}
|
}
|
||||||
|
|
||||||
class ModelSet {
|
class ModelSet {
|
||||||
|
@ -101,7 +101,7 @@ namespace ClassicalSharp.Model {
|
|||||||
Set64x32.Dispose();
|
Set64x32.Dispose();
|
||||||
Set64x64.Dispose();
|
Set64x64.Dispose();
|
||||||
Set64x64Slim.Dispose();
|
Set64x64Slim.Dispose();
|
||||||
graphics.DeleteTexture( DefaultSkinTextureId );
|
graphics.DeleteTexture( ref DefaultSkinTextureId );
|
||||||
}
|
}
|
||||||
|
|
||||||
class ModelSet {
|
class ModelSet {
|
||||||
|
@ -88,9 +88,9 @@ namespace ClassicalSharp.Model {
|
|||||||
|
|
||||||
public override void Dispose() {
|
public override void Dispose() {
|
||||||
Set.Dispose();
|
Set.Dispose();
|
||||||
graphics.DeleteTexture( DefaultSkinTextureId );
|
graphics.DeleteTexture( ref DefaultSkinTextureId );
|
||||||
if( Fur ) {
|
if( Fur ) {
|
||||||
graphics.DeleteTexture( furTextureId );
|
graphics.DeleteTexture( ref furTextureId );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ namespace ClassicalSharp.Model {
|
|||||||
|
|
||||||
public override void Dispose() {
|
public override void Dispose() {
|
||||||
Set.Dispose();
|
Set.Dispose();
|
||||||
graphics.DeleteTexture( DefaultSkinTextureId );
|
graphics.DeleteTexture( ref DefaultSkinTextureId );
|
||||||
}
|
}
|
||||||
|
|
||||||
class ModelSet {
|
class ModelSet {
|
||||||
|
@ -63,7 +63,7 @@ namespace ClassicalSharp.Model {
|
|||||||
|
|
||||||
public override void Dispose() {
|
public override void Dispose() {
|
||||||
Set.Dispose();
|
Set.Dispose();
|
||||||
graphics.DeleteTexture( DefaultSkinTextureId );
|
graphics.DeleteTexture( ref DefaultSkinTextureId );
|
||||||
}
|
}
|
||||||
|
|
||||||
class ModelSet {
|
class ModelSet {
|
||||||
|
@ -67,7 +67,7 @@ namespace ClassicalSharp.Model {
|
|||||||
|
|
||||||
public override void Dispose() {
|
public override void Dispose() {
|
||||||
Set.Dispose();
|
Set.Dispose();
|
||||||
graphics.DeleteTexture( DefaultSkinTextureId );
|
graphics.DeleteTexture( ref DefaultSkinTextureId );
|
||||||
}
|
}
|
||||||
|
|
||||||
class ModelSet {
|
class ModelSet {
|
||||||
|
@ -80,7 +80,7 @@ namespace ClassicalSharp.Renderers {
|
|||||||
base.Dispose();
|
base.Dispose();
|
||||||
Graphics.DeleteVb( skyVbo );
|
Graphics.DeleteVb( skyVbo );
|
||||||
Graphics.DeleteVb( cloudsVbo );
|
Graphics.DeleteVb( cloudsVbo );
|
||||||
Graphics.DeleteTexture( cloudTexture );
|
Graphics.DeleteTexture( ref cloudTexture );
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderClouds( double delta ) {
|
void RenderClouds( double delta ) {
|
||||||
|
@ -118,8 +118,8 @@ namespace ClassicalSharp {
|
|||||||
public override void Dispose() {
|
public override void Dispose() {
|
||||||
base.Dispose();
|
base.Dispose();
|
||||||
index = 0;
|
index = 0;
|
||||||
Graphics.DeleteTexture( edgeTexId );
|
Graphics.DeleteTexture( ref edgeTexId );
|
||||||
Graphics.DeleteTexture( sideTexId );
|
Graphics.DeleteTexture( ref sideTexId );
|
||||||
Graphics.DeleteVb( sidesVboId );
|
Graphics.DeleteVb( sidesVboId );
|
||||||
Graphics.DeleteVb( edgesVboId );
|
Graphics.DeleteVb( edgesVboId );
|
||||||
sidesVboId = edgesVboId = -1;
|
sidesVboId = edgesVboId = -1;
|
||||||
@ -140,13 +140,13 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
void MakeEdgeTexture() {
|
void MakeEdgeTexture() {
|
||||||
int texLoc = Window.BlockInfo.GetOptimTextureLoc( (byte)Map.EdgeBlock, TileSide.Top );
|
int texLoc = Window.BlockInfo.GetOptimTextureLoc( (byte)Map.EdgeBlock, TileSide.Top );
|
||||||
Window.Graphics.DeleteTexture( edgeTexId );
|
Window.Graphics.DeleteTexture( ref edgeTexId );
|
||||||
edgeTexId = Window.TerrainAtlas.LoadTextureElement( texLoc );
|
edgeTexId = Window.TerrainAtlas.LoadTextureElement( texLoc );
|
||||||
}
|
}
|
||||||
|
|
||||||
void MakeSideTexture() {
|
void MakeSideTexture() {
|
||||||
int texLoc = Window.BlockInfo.GetOptimTextureLoc( (byte)Map.SidesBlock, TileSide.Top );
|
int texLoc = Window.BlockInfo.GetOptimTextureLoc( (byte)Map.SidesBlock, TileSide.Top );
|
||||||
Window.Graphics.DeleteTexture( sideTexId );
|
Window.Graphics.DeleteTexture( ref sideTexId );
|
||||||
sideTexId = Window.TerrainAtlas.LoadTextureElement( texLoc );
|
sideTexId = Window.TerrainAtlas.LoadTextureElement( texLoc );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ namespace ClassicalSharp.Renderers {
|
|||||||
base.Dispose();
|
base.Dispose();
|
||||||
Graphics.DeleteVb( skyVbo );
|
Graphics.DeleteVb( skyVbo );
|
||||||
Graphics.DeleteVb( cloudsVbo );
|
Graphics.DeleteVb( cloudsVbo );
|
||||||
Graphics.DeleteTexture( cloudTexture );
|
Graphics.DeleteTexture( ref cloudTexture );
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderClouds( double delta ) {
|
void RenderClouds( double delta ) {
|
||||||
|
@ -105,8 +105,8 @@ namespace ClassicalSharp {
|
|||||||
public override void Dispose() {
|
public override void Dispose() {
|
||||||
base.Dispose();
|
base.Dispose();
|
||||||
index = 0;
|
index = 0;
|
||||||
Graphics.DeleteTexture( edgeTexId );
|
Graphics.DeleteTexture( ref edgeTexId );
|
||||||
Graphics.DeleteTexture( sideTexId );
|
Graphics.DeleteTexture( ref sideTexId );
|
||||||
Graphics.DeleteVb( sidesVboId );
|
Graphics.DeleteVb( sidesVboId );
|
||||||
Graphics.DeleteVb( edgesVboId );
|
Graphics.DeleteVb( edgesVboId );
|
||||||
sidesVboId = edgesVboId = -1;
|
sidesVboId = edgesVboId = -1;
|
||||||
@ -127,13 +127,13 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
void MakeEdgeTexture() {
|
void MakeEdgeTexture() {
|
||||||
int texLoc = Window.BlockInfo.GetOptimTextureLoc( (byte)Map.EdgeBlock, TileSide.Top );
|
int texLoc = Window.BlockInfo.GetOptimTextureLoc( (byte)Map.EdgeBlock, TileSide.Top );
|
||||||
Window.Graphics.DeleteTexture( edgeTexId );
|
Window.Graphics.DeleteTexture( ref edgeTexId );
|
||||||
edgeTexId = Window.TerrainAtlas.LoadTextureElement( texLoc );
|
edgeTexId = Window.TerrainAtlas.LoadTextureElement( texLoc );
|
||||||
}
|
}
|
||||||
|
|
||||||
void MakeSideTexture() {
|
void MakeSideTexture() {
|
||||||
int texLoc = Window.BlockInfo.GetOptimTextureLoc( (byte)Map.SidesBlock, TileSide.Top );
|
int texLoc = Window.BlockInfo.GetOptimTextureLoc( (byte)Map.SidesBlock, TileSide.Top );
|
||||||
Window.Graphics.DeleteTexture( sideTexId );
|
Window.Graphics.DeleteTexture( ref sideTexId );
|
||||||
sideTexId = Window.TerrainAtlas.LoadTextureElement( texLoc );
|
sideTexId = Window.TerrainAtlas.LoadTextureElement( texLoc );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,8 +33,8 @@ namespace ClassicalSharp.Renderers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose() {
|
public void Dispose() {
|
||||||
Graphics.DeleteTexture( TextureId );
|
Graphics.DeleteTexture( ref TextureId );
|
||||||
Graphics.DeleteTexture( nameTextureId );
|
Graphics.DeleteTexture( ref nameTextureId );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Render( double deltaTime ) {
|
public void Render( double deltaTime ) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user