00001 /*********************************************************************** 00002 filename: texture.h 00003 created: 10/4/2004 00004 author: Paul D Turner 00005 00006 purpose: Defines concrete texture class 00007 *************************************************************************/ 00008 /*************************************************************************** 00009 * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team 00010 * 00011 * Permission is hereby granted, free of charge, to any person obtaining 00012 * a copy of this software and associated documentation files (the 00013 * "Software"), to deal in the Software without restriction, including 00014 * without limitation the rights to use, copy, modify, merge, publish, 00015 * distribute, sublicense, and/or sell copies of the Software, and to 00016 * permit persons to whom the Software is furnished to do so, subject to 00017 * the following conditions: 00018 * 00019 * The above copyright notice and this permission notice shall be 00020 * included in all copies or substantial portions of the Software. 00021 * 00022 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00023 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00024 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00025 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 00026 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00027 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00028 * OTHER DEALINGS IN THE SOFTWARE. 00029 ***************************************************************************/ 00030 #ifndef _texture_h_ 00031 #define _texture_h_ 00032 00033 #include "CEGUIBase.h" 00034 #include "CEGUIRenderer.h" 00035 #include "CEGUITexture.h" 00036 #include "renderer.h" 00037 #include <d3d8.h> 00038 #include <list> 00039 00040 // Start of CEGUI namespace section 00041 namespace CEGUI 00042 { 00043 00048 class DIRECTX81_GUIRENDERER_API DirectX81Texture : public Texture 00049 { 00050 private: 00051 /************************************************************************* 00052 Friends (to allow construction and destruction) 00053 *************************************************************************/ 00054 friend Texture* DirectX81Renderer::createTexture(void); 00055 friend Texture* DirectX81Renderer::createTexture(const String& filename, const String& resourceGroup); 00056 friend Texture* DirectX81Renderer::createTexture(float size); 00057 friend void DirectX81Renderer::destroyTexture(Texture* texture); 00058 00059 00060 /************************************************************************* 00061 Construction & Destruction (by Renderer object only) 00062 *************************************************************************/ 00063 DirectX81Texture(Renderer* owner); 00064 virtual ~DirectX81Texture(void); 00065 00066 public: 00074 virtual ushort getWidth(void) const {return d_width;} 00075 00076 00084 virtual ushort getHeight(void) const {return d_height;} 00085 00086 virtual ushort getOriginalWidth(void) const { return d_orgWidth; } 00087 virtual ushort getOriginalHeight(void) const { return d_orgHeight; } 00088 00102 virtual void loadFromFile(const String& filename, const String& resourceGroup); 00103 00104 00124 virtual void loadFromMemory(const void* buffPtr, uint buffWidth, uint buffHeight, PixelFormat pixelFormat); 00125 00126 00134 LPDIRECT3DTEXTURE8 getD3DTexture(void) const {return d_d3dtexture;} 00135 00136 00137 // 00148 void setD3DTextureSize(uint size); 00149 00150 00162 virtual void preD3DReset(void); 00163 00164 00176 virtual void postD3DReset(void); 00177 00178 00179 private: 00180 /************************************************************************* 00181 Implementation Functions 00182 *************************************************************************/ 00183 // safely free direc3d texture (can be called multiple times with no ill effect) 00184 void freeD3DTexture(void); 00185 // obtain and fill-in the real texture dimensions. 00186 // d_orgWidth and d_orgHeight should be set before calling this, since 00187 // they are used as fall-back values if the query fails. 00188 void obtainActualTextureSize(void); 00189 00190 /************************************************************************* 00191 Implementation Data 00192 *************************************************************************/ 00193 LPDIRECT3DTEXTURE8 d_d3dtexture; 00194 String d_filename; 00195 String d_resourceGroup; 00196 bool d_isMemoryTexture; 00197 00198 ushort d_width; 00199 ushort d_height; 00200 ushort d_orgWidth; 00201 ushort d_orgHeight; 00202 }; 00203 00204 } // End of CEGUI namespace section 00205 00206 00207 #endif // end of guard _texture_h_