mirror of
https://github.com/gwdevhub/gMod.git
synced 2026-07-26 00:45:31 +00:00
Improvements:
- Support for Volume and Cube textures.
This commit is contained in:
@@ -104,114 +104,3 @@ int OTM_FileHandler::Remove(TextureFileStruct* file)
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
OTM_TextureHandler::OTM_TextureHandler(void)
|
||||
{
|
||||
Message("OTM_TextureHandler(void): %lu\n", this);
|
||||
Number = 0;
|
||||
FieldCounter = 0;
|
||||
|
||||
Textures = NULL;
|
||||
}
|
||||
|
||||
OTM_TextureHandler::~OTM_TextureHandler(void)
|
||||
{
|
||||
Message("~OTM_TextureHandler(void): %lu\n", this);
|
||||
if (Textures!=NULL)
|
||||
{
|
||||
for (int i=0; i<FieldCounter; i++) if (Textures[i] != NULL) delete [] Textures[i];
|
||||
delete [] Textures;
|
||||
}
|
||||
}
|
||||
|
||||
int OTM_TextureHandler::Add(OTM_IDirect3DTexture9* pTexture)
|
||||
{
|
||||
Message("OTM_TextureHandler::Add( %lu): %lu\n", pTexture, this);
|
||||
if (gl_ErrorState & OTM_ERROR_FATAL) return (RETURN_FATAL_ERROR);
|
||||
|
||||
if (pTexture->Reference>=0) return (RETURN_TEXTURE_ALLREADY_ADDED);
|
||||
|
||||
if (Number/FieldLength==FieldCounter)
|
||||
{
|
||||
OTM_IDirect3DTexture9*** temp = NULL;
|
||||
try {temp = new OTM_IDirect3DTexture9**[FieldCounter+10];}
|
||||
catch (...)
|
||||
{
|
||||
gl_ErrorState |= OTM_ERROR_MEMORY | OTM_ERROR_TEXTURE;
|
||||
return (RETURN_NO_MEMORY);
|
||||
}
|
||||
|
||||
for (int i=0; i<FieldCounter; i++) temp[i] = Textures[i];
|
||||
|
||||
for (int i=FieldCounter; i<FieldCounter+10; i++) temp[i] = NULL;
|
||||
|
||||
FieldCounter += 10;
|
||||
|
||||
if (Textures!=NULL) delete [] Textures;
|
||||
|
||||
Textures = temp;
|
||||
}
|
||||
if (Number%FieldLength==0)
|
||||
{
|
||||
try {if (Textures[Number/FieldLength]==NULL) Textures[Number/FieldLength] = new OTM_IDirect3DTexture9*[FieldLength];}
|
||||
catch (...)
|
||||
{
|
||||
Textures[Number/FieldLength]=NULL;
|
||||
gl_ErrorState |= OTM_ERROR_MEMORY | OTM_ERROR_TEXTURE;
|
||||
return (RETURN_NO_MEMORY);
|
||||
}
|
||||
}
|
||||
|
||||
Textures[Number/FieldLength][Number%FieldLength] = pTexture;
|
||||
pTexture->Reference = Number++;
|
||||
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
|
||||
int OTM_TextureHandler::Remove(OTM_IDirect3DTexture9* pTexture) //will be called, if a texture is completely released
|
||||
{
|
||||
Message("OTM_TextureHandler::Remove( %lu): %lu\n", pTexture, this);
|
||||
if (gl_ErrorState & OTM_ERROR_FATAL) return (RETURN_FATAL_ERROR);
|
||||
|
||||
int ref = pTexture->Reference;
|
||||
if (ref<0) return (RETURN_OK); // returning if no TextureHandlerRef is set
|
||||
|
||||
if (ref<(--Number))
|
||||
{
|
||||
Textures[ref/FieldLength][ref%FieldLength] = Textures[Number/FieldLength][Number%FieldLength];
|
||||
Textures[ref/FieldLength][ref%FieldLength]->Reference = ref;
|
||||
}
|
||||
return (RETURN_OK);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user