3
// Copyright (C) 2002 Deon Ramsey <dramsey@sourceforge.net>
5
// This program is free software; you can redistribute it and/or
6
// modify it under the terms of the GNU General Public License
7
// as published by the Free Software Foundation; either version 2
8
// of the License, or (at your option) any later version.
10
#include "multitexture.h"
11
#include "texmanager.h"
16
MultiResTexture::MultiResTexture()
18
tex[lores] = InvalidResource;
19
tex[medres] = InvalidResource;
20
tex[hires] = InvalidResource;
24
MultiResTexture::MultiResTexture(ResourceHandle loTex,
25
ResourceHandle medTex,
34
MultiResTexture::MultiResTexture(const fs::path& source,
37
setTexture(source, path);
41
void MultiResTexture::setTexture(const fs::path& source,
45
TextureManager* texMan = GetTextureManager();
46
tex[lores] = texMan->getHandle(TextureInfo(source, path, flags, lores));
47
tex[medres] = texMan->getHandle(TextureInfo(source, path, flags, medres));
48
tex[hires] = texMan->getHandle(TextureInfo(source, path, flags, hires));
52
void MultiResTexture::setTexture(const fs::path& source,
57
TextureManager* texMan = GetTextureManager();
58
tex[lores] = texMan->getHandle(TextureInfo(source, path, bumpHeight, flags, lores));
59
tex[medres] = texMan->getHandle(TextureInfo(source, path, bumpHeight, flags, medres));
60
tex[hires] = texMan->getHandle(TextureInfo(source, path, bumpHeight, flags, hires));
64
Texture* MultiResTexture::find(unsigned int resolution)
66
TextureManager* texMan = GetTextureManager();
68
Texture* res = texMan->find(tex[resolution]);
72
// Preferred resolution isn't available; try the second choice
73
// Set these to some defaults to avoid GCC complaints
74
// about possible uninitialized variable usage:
75
unsigned int secondChoice = medres;
76
unsigned int lastResort = hires;
80
secondChoice = medres;
88
secondChoice = medres;
93
tex[resolution] = tex[secondChoice];
94
res = texMan->find(tex[resolution]);
98
tex[resolution] = tex[lastResort];
100
return texMan->find(tex[resolution]);
104
bool MultiResTexture::isValid() const
106
return (tex[lores] != InvalidResource ||
107
tex[medres] != InvalidResource ||
108
tex[hires] != InvalidResource);