Recovered from microbel
This commit is contained in:
153
common/lib/texture/texture.C
Normal file
153
common/lib/texture/texture.C
Normal file
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* PVVMUD a 3D MUD
|
||||
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "pvvmud.H"
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "texture.H"
|
||||
#include "exception.H"
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Create texture
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
CTexture::CTexture(){
|
||||
|
||||
m_id = -1;
|
||||
m_state = 0;
|
||||
m_textureMap = NULL;
|
||||
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Create texture with given id
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
CTexture::CTexture(int id){
|
||||
|
||||
m_id = id;
|
||||
m_state = 0;
|
||||
m_textureMap = NULL;
|
||||
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Create texture with given id
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
CTexture::~CTexture(){
|
||||
|
||||
if (m_textureMap != NULL) delete m_textureMap;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Test if texturemap is loaded
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
int CTexture::loaded(){
|
||||
return ((m_state & TEX_STATE_LOADED)==TEX_STATE_LOADED);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Set texturemap to use with texture
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
void CTexture::setTextureMap(CTextureMap * textureMap){
|
||||
|
||||
if (m_textureMap != NULL) delete m_textureMap;
|
||||
|
||||
m_textureMap = textureMap;
|
||||
|
||||
m_state = m_state | TEX_STATE_LOADED;
|
||||
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Get texturemap from texture.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
CTextureMap * CTexture::getTextureMap(){
|
||||
return m_textureMap;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Exec texture
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
int CTexture::exec(){
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Load texture
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
void CTexture::load(char * fileName){
|
||||
CTextureMap * map = new CTextureMap();
|
||||
map->load(fileName);
|
||||
setTextureMap(map);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Save texture
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
void CTexture::save(char * fileName){
|
||||
m_textureMap->save(fileName);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Add texture to TextureCache
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
CTextureCache::CTextureCache():CCache(){
|
||||
}
|
||||
|
||||
CTexture * CTextureCache::add(CTexture * texture){
|
||||
return (CTexture*)CCache::add(texture->getId(), (CObject*)texture );
|
||||
}
|
||||
|
||||
CTexture * CTextureCache::get(int id){
|
||||
return (CTexture*)CCache::get(id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user