Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

OgreD3D7Texture.h

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004     (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://ogre.sourceforge.net/
00006 
00007 Copyright © 2000-2002 The OGRE Team
00008 Also see acknowledgements in Readme.html
00009 
00010 This program is free software; you can redistribute it and/or modify it under
00011 the terms of the GNU Lesser General Public License as published by the Free Software
00012 Foundation; either version 2 of the License, or (at your option) any later
00013 version.
00014 
00015 This program is distributed in the hope that it will be useful, but WITHOUT
00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public License along with
00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00022 http://www.gnu.org/copyleft/lesser.txt.
00023 -----------------------------------------------------------------------------
00024 */
00025 #ifndef _D3DTexture_H__
00026 #define _D3DTexture_H__
00027 
00028 #include "OgreD3D7Prerequisites.h"
00029 #include "OgreTexture.h"
00030 #include "OgreRenderTarget.h"
00031 #include "OgreRenderTexture.h"
00032 #include "OgreRenderTargetListener.h"
00033 #include <ddraw.h>
00034 #include <d3d.h>
00035 
00036 namespace Ogre {
00037 
00040     class D3DTexture : public Texture
00041     {
00042     public:
00043         // Constructor, called from D3DTextureManager
00044         D3DTexture( String name, IDirect3DDevice7 * lpDirect3dDevice, TextureUsage usage );
00046         D3DTexture( 
00047             String name, 
00048             IDirect3DDevice7 * lpDirect3dDevice, 
00049             uint width, 
00050             uint height, 
00051             uint num_mips,
00052             PixelFormat format,
00053             TextureUsage usage );
00054         virtual ~D3DTexture();
00055 
00056         virtual void load(void);
00057         virtual void loadImage( const Image &img );
00058         virtual void blitToTexture( const Image &src, unsigned uStartX, unsigned uStartY );        
00059         virtual void blitImage( const Image& src, 
00060             const Image::Rect imgRect, const Image::Rect texRect );
00061         virtual void unload(void);
00062         virtual void copyToTexture( Texture * target );
00063 
00065         LPDIRECTDRAWSURFACE7 getDDSurface(void);
00066 
00067     protected:
00068         IDirect3DDevice7 * mD3DDevice;       
00069         IDirectDrawSurface7 * mSurface;      
00070 
00071     protected:
00072         void createSurface();
00073     };
00074 
00075     class D3D7RenderTexture : public RenderTexture
00076     {
00077     public:
00078         D3D7RenderTexture( const String & name, uint width, uint height )
00079             : RenderTexture( name, width, height )
00080         {
00081         }
00082 
00083         virtual ~D3D7RenderTexture()
00084         {
00085             mPrivateTex->unload();
00086             delete mPrivateTex;
00087         }
00088 
00089         bool requiresTextureFlipping() const { return true; }
00090 
00091         virtual void getCustomAttribute( String name, void* pData )
00092         {
00093             if( name == "DDBACKBUFFER" )
00094             {
00095                 LPDIRECTDRAWSURFACE7 *pSurf = (LPDIRECTDRAWSURFACE7*)pData;
00096 
00097                 *pSurf = ((D3DTexture*)mPrivateTex)->getDDSurface();
00098                 return;
00099             }
00100             else if( name == "DDFRONTBUFFER" )
00101             {
00102                 LPDIRECTDRAWSURFACE7 *pSurf = (LPDIRECTDRAWSURFACE7*)pData;
00103 
00104                 *pSurf = ((D3DTexture*)mPrivateTex)->getDDSurface();
00105                 return;
00106             }
00107             else if( name == "HWND" )
00108             {
00109                 HWND *pHwnd = (HWND*)pData;
00110 
00111                 *pHwnd = NULL;
00112                 return;
00113             }
00114             else if( name == "isTexture" )
00115             {
00116                 bool *b = reinterpret_cast< bool * >( pData );
00117                 *b = true;
00118 
00119                 return;
00120             }
00121         }
00122         virtual void writeContentsToFile( const String & filename ) {}
00123         virtual void outputText(int x, int y, const String& text) {}
00124     };
00125 }
00126 
00127 #endif

Copyright © 2002 by The OGRE Team