Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

multitexture.cpp

Go to the documentation of this file.
00001 // multirestexture.cpp
00002 //
00003 // Copyright (C) 2002 Deon Ramsey <dramsey@sourceforge.net>
00004 //
00005 // This program is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (at your option) any later version.
00009 
00010 #include "multitexture.h"
00011 #include "texmanager.h"
00012 #include <celutil/debug.h>
00013 
00014 using namespace std;
00015 
00016 
00017 MultiResTexture::MultiResTexture()
00018 {
00019     tex[lores] = InvalidResource;
00020     tex[medres] = InvalidResource;
00021     tex[hires] = InvalidResource;
00022 }
00023 
00024 
00025 MultiResTexture::MultiResTexture(ResourceHandle loTex,
00026                                  ResourceHandle medTex,
00027                                  ResourceHandle hiTex)
00028 {
00029     tex[lores] = loTex;
00030     tex[medres] = medTex;
00031     tex[hires] = hiTex;
00032 }
00033 
00034 
00035 MultiResTexture::MultiResTexture(const string& source,
00036                                  const string& path)
00037 {
00038     setTexture(source, path);
00039 }
00040 
00041 
00042 void MultiResTexture::setTexture(const string& source, const string& path,
00043                                  unsigned int flags)
00044 {
00045     TextureManager* texMan = GetTextureManager();
00046     tex[lores] = texMan->getHandle(TextureInfo(source, path, flags, lores));
00047     tex[medres] = texMan->getHandle(TextureInfo(source, path, flags, medres));
00048     tex[hires] = texMan->getHandle(TextureInfo(source, path, flags, hires));
00049 }
00050 
00051 
00052 void MultiResTexture::setTexture(const string& source, const string& path,
00053                                  float bumpHeight, unsigned int flags)
00054 {
00055     TextureManager* texMan = GetTextureManager();
00056     tex[lores] = texMan->getHandle(TextureInfo(source, path, bumpHeight, flags, lores));
00057     tex[medres] = texMan->getHandle(TextureInfo(source, path, bumpHeight, flags, medres));
00058     tex[hires] = texMan->getHandle(TextureInfo(source, path, bumpHeight, flags, hires));
00059 }
00060 
00061 
00062 Texture* MultiResTexture::find(unsigned int resolution)
00063 {
00064     TextureManager* texMan = GetTextureManager();
00065     Texture* res = texMan->find(tex[resolution]);
00066     if (res != NULL)
00067         return res;
00068     if(resolution == lores)
00069         tex[resolution] = tex[resolution +1];
00070     else
00071         tex[resolution] = tex[resolution -1];
00072     res = texMan->find(tex[resolution]);
00073     if(res != NULL)
00074         return res;
00075     if(resolution == hires)
00076     return texMan->find(tex[lores]);
00077     else
00078         return texMan->find(tex[hires]);
00079 }

Generated on Sat Jan 14 22:30:27 2006 for Celestia by  doxygen 1.4.1