ScummVM API documentation
Texture.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22/*
23 * Copyright (C) 2006-2010 - Frictional Games
24 *
25 * This file is part of HPL1 Engine.
26 */
27
28#ifndef HPL_TEXTURE_H
29#define HPL_TEXTURE_H
30
31#include "common/array.h"
32#include "graphics/pixelformat.h"
33#include "hpl1/engine/graphics/GraphicsTypes.h"
34#include "hpl1/engine/graphics/LowLevelPicture.h"
35#include "hpl1/engine/graphics/bitmap2D.h"
36#include "hpl1/engine/resources/ResourceBase.h"
37
38namespace hpl {
39
40enum eTextureType {
41 eTextureType_Normal,
42 eTextureType_RenderTarget,
43 eTextureType_LastEnum
44};
45
46//-----------------------------------------
47
48enum eTextureTarget {
49 eTextureTarget_1D,
50 eTextureTarget_2D,
51 eTextureTarget_Rect,
52 eTextureTarget_CubeMap,
53 eTextureTarget_3D,
54 eTextureTarget_LastEnum
55};
56
57//-----------------------------------------
58
59enum eTextureWrap {
60 eTextureWrap_Repeat,
61 eTextureWrap_Clamp,
62 eTextureWrap_ClampToEdge,
63 eTextureWrap_ClampToBorder,
64 eTextureWrap_LastEnum
65};
66
67//-----------------------------------------
68
69enum eTextureFilter {
70 eTextureFilter_Bilinear,
71 eTextureFilter_Trilinear,
72 eTextureFilter_LastEnum
73};
74
75//-----------------------------------------
76
77enum eTextureAnimMode {
78 eTextureAnimMode_None,
79 eTextureAnimMode_Loop,
80 eTextureAnimMode_Oscillate,
81 eTextureAnimMode_LastEnum
82};
83
84//-----------------------------------------
85
86class iLowLevelGraphics;
87
88class iTexture : public LowLevelPicture, public iResourceBase {
89public:
90 iTexture(tString asName, tString asType, Graphics::PixelFormat *apPxlFmt, iLowLevelGraphics *apLowLevelGraphics,
91 eTextureType aType, bool abUseMipMaps, eTextureTarget aTarget,
92 bool abCompress = false)
93 : LowLevelPicture(asType), iResourceBase(asName, 0),
94 mType(aType), mbUseMipMaps(abUseMipMaps),
95 mpLowLevelGraphics(apLowLevelGraphics), mbCompress(abCompress),
96 mTarget(aTarget),
97 mWrapS(eTextureWrap_Repeat), mWrapT(eTextureWrap_Repeat), mWrapR(eTextureWrap_Repeat),
98 mfFrameTime(1), mAnimMode(eTextureAnimMode_Loop), mlSizeLevel(0), mvMinLevelSize(16, 16),
99 mfAnisotropyDegree(1.0f), mFilter(eTextureFilter_Bilinear), _bpp(apPxlFmt->bpp()) {}
100
101 virtual ~iTexture() {}
102
103 void SetSizeLevel(unsigned int alLevel) { mlSizeLevel = alLevel; }
104 void SetMinLevelSize(const cVector2l &avSize) { mvMinLevelSize = avSize; }
105
106 bool reload() override { return false; }
107 void unload() override {}
108 void destroy() override {}
109
115 virtual bool CreateFromBitmap(Bitmap2D *pBmp) = 0;
122 virtual bool CreateCubeFromBitmapVec(tBitmap2DVec *avBitmaps) = 0;
130 virtual bool Create(unsigned int alWidth, unsigned int alHeight, cColor aCol) = 0;
131
132 virtual bool CreateAnimFromBitmapVec(tBitmap2DVec *avBitmaps) = 0;
133
134 virtual bool CreateFromArray(unsigned char *apPixelData, int alChannels, const cVector3l &avSize) = 0;
135
136 virtual void Update(float afTimeStep) = 0;
137
138 virtual void SetFilter(eTextureFilter aFilter) = 0;
139 virtual void SetAnisotropyDegree(float afX) = 0;
140 eTextureFilter GetFilter() { return mFilter; }
141 float GetAnisotropyDegree(float afX) { return mfAnisotropyDegree; }
142
143 virtual float GetGamma() = 0;
144 virtual void SetGamma(float afGamma) = 0;
145 virtual int GetHandle() = 0;
146
147 virtual bool hasAlpha() override { return false; }
148 uint32 getBpp() const override { return _bpp; }
149
150 virtual void SetWrapS(eTextureWrap aMode) = 0;
151 virtual void SetWrapT(eTextureWrap aMode) = 0;
152 virtual void SetWrapR(eTextureWrap aMode) = 0;
153
154 eTextureWrap GetWrapS() { return mWrapS; }
155 eTextureWrap GetWrapT() { return mWrapT; }
156 eTextureWrap GetWrapR() { return mWrapR; }
157
158 void SetFrameTime(float afX) { mfFrameTime = afX; }
159 float GetFrameTime() { return mfFrameTime; }
160
161 eTextureAnimMode GetAnimMode() { return mAnimMode; }
162 void SetAnimMode(eTextureAnimMode aMode) { mAnimMode = aMode; };
163
164 eTextureType GetTextureType() { return mType; }
165 bool UsesMipMaps() { return mbUseMipMaps; }
166 void SetMipMapUse(bool abX) { mbUseMipMaps = abX; }
167 eTextureTarget GetTarget() { return mTarget; }
168
169 virtual bool HasAnimation() = 0;
170 virtual void NextFrame() = 0;
171 virtual void PrevFrame() = 0;
172 virtual float GetT() = 0;
173 virtual float GetTimeCount() = 0;
174 virtual void SetTimeCount(float afX) = 0;
175 virtual int GetCurrentLowlevelHandle() = 0;
176
177protected:
178 eTextureType mType;
179 eTextureTarget mTarget;
180 eTextureWrap mWrapS;
181 eTextureWrap mWrapT;
182 eTextureWrap mWrapR;
183 eTextureFilter mFilter;
184 float mfAnisotropyDegree;
185
186 bool mbUseMipMaps;
187 bool mbCompress;
188 iLowLevelGraphics *mpLowLevelGraphics;
189 float mfFrameTime;
190 eTextureAnimMode mAnimMode;
191 unsigned int mlSizeLevel;
192 uint32 _bpp;
193 cVector2l mvMinLevelSize;
194};
195
196typedef Common::Array<iTexture *> tTextureVec;
197typedef tTextureVec::iterator tTextureVecIt;
198
199} // namespace hpl
200
201#endif // HPL_TEXTURE_H
Definition: array.h:52
iTexture * * iterator
Definition: array.h:54
Definition: str.h:59
Definition: bitmap2D.h:42
Definition: LowLevelPicture.h:37
Definition: Color.h:37
Definition: Vector3.h:38
Definition: LowLevelGraphics.h:200
Definition: ResourceBase.h:36
Definition: Texture.h:88
void unload() override
Definition: Texture.h:107
virtual bool CreateFromBitmap(Bitmap2D *pBmp)=0
bool reload() override
Definition: Texture.h:106
virtual bool CreateCubeFromBitmapVec(tBitmap2DVec *avBitmaps)=0
virtual bool Create(unsigned int alWidth, unsigned int alHeight, cColor aCol)=0
void destroy() override
Definition: Texture.h:108
Definition: pixelformat.h:138
byte bpp() const
Definition: pixelformat.h:360