Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
multitexture.cpp
Package: celestia-1.6.0.tar.gz [view]
Upload User: center1979
Upload Date: 2022-07-26
Package Size: 50633k
Code Size: 3k
Category:
OpenGL program
Development Platform:
Visual C++
- // multirestexture.cpp
- //
- // Copyright (C) 2002 Deon Ramsey <dramsey@sourceforge.net>
- //
- // 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.
- #include "multitexture.h"
- #include "texmanager.h"
- #include <celutil/debug.h>
- using namespace std;
- MultiResTexture::MultiResTexture()
- {
- tex[lores] = InvalidResource;
- tex[medres] = InvalidResource;
- tex[hires] = InvalidResource;
- }
- MultiResTexture::MultiResTexture(ResourceHandle loTex,
- ResourceHandle medTex,
- ResourceHandle hiTex)
- {
- tex[lores] = loTex;
- tex[medres] = medTex;
- tex[hires] = hiTex;
- }
- MultiResTexture::MultiResTexture(const string& source,
- const string& path)
- {
- setTexture(source, path);
- }
- void MultiResTexture::setTexture(const string& source, const string& path,
- unsigned int flags)
- {
- TextureManager* texMan = GetTextureManager();
- tex[lores] = texMan->getHandle(TextureInfo(source, path, flags, lores));
- tex[medres] = texMan->getHandle(TextureInfo(source, path, flags, medres));
- tex[hires] = texMan->getHandle(TextureInfo(source, path, flags, hires));
- }
- void MultiResTexture::setTexture(const string& source, const string& path,
- float bumpHeight, unsigned int flags)
- {
- TextureManager* texMan = GetTextureManager();
- tex[lores] = texMan->getHandle(TextureInfo(source, path, bumpHeight, flags, lores));
- tex[medres] = texMan->getHandle(TextureInfo(source, path, bumpHeight, flags, medres));
- tex[hires] = texMan->getHandle(TextureInfo(source, path, bumpHeight, flags, hires));
- }
- Texture* MultiResTexture::find(unsigned int resolution)
- {
- TextureManager* texMan = GetTextureManager();
- Texture* res = texMan->find(tex[resolution]);
- if (res != NULL)
- return res;
- // Preferred resolution isn't available; try the second choice
- // Set these to some defaults to avoid GCC complaints
- // about possible uninitialized variable usage:
- unsigned int secondChoice = medres;
- unsigned int lastResort = hires;
- switch (resolution)
- {
- case lores:
- secondChoice = medres;
- lastResort = hires;
- break;
- case medres:
- secondChoice = lores;
- lastResort = hires;
- break;
- case hires:
- secondChoice = medres;
- lastResort = lores;
- break;
- }
- tex[resolution] = tex[secondChoice];
- res = texMan->find(tex[resolution]);
- if (res != NULL)
- return res;
- tex[resolution] = tex[lastResort];
- return texMan->find(tex[resolution]);
- }
- bool MultiResTexture::isValid() const
- {
- return (tex[lores] != InvalidResource ||
- tex[medres] != InvalidResource ||
- tex[hires] != InvalidResource);
- }