My Project
TextureEntityOpenGL.h
1 #pragma once
2 #include "TextureEntity.h"
3 
4 namespace ParaEngine
5 {
6  class CRenderTarget;
7 
11  {
12  public:
13  virtual AssetEntity::AssetType GetType(){ return TextureEntity::texture; };
14 
15  public:
16  TextureEntityOpenGL(const AssetKey& key);
17  TextureEntityOpenGL(GLWrapper::Texture2D* texture);
19  virtual ~TextureEntityOpenGL();
20 
21  virtual HRESULT InitDeviceObjects();
22  virtual HRESULT RestoreDeviceObjects();
23  virtual HRESULT InvalidateDeviceObjects();
24  virtual HRESULT DeleteDeviceObjects();
25  virtual HRESULT RendererRecreated();
26 
31  virtual bool LoadFromImage(ImageEntity * image, D3DFORMAT dwTextureFormat = D3DFMT_UNKNOWN, UINT nMipLevels = 0, void** ppTexture = NULL);
32 
36  virtual HRESULT LoadFromMemory(const char* buffer, DWORD nFileSize, UINT nMipLevels, D3DFORMAT dwTextureFormat = D3DFMT_UNKNOWN, void** ppTexture = NULL);
37 
39  virtual void SetSamplerStateBlocky(bool bIsBlocky);
40  virtual bool IsSamplerStateBlocky();
41 
42  virtual int32 GetWidth();
43  virtual int32 GetHeight();
44 
48  virtual bool SaveToFile(const char* filename, D3DFORMAT dwFormat, int width, int height, UINT MipLevels = 1, DWORD Filter = D3DX_DEFAULT, Color ColorKey = 0);
49 
50  void SetAliasTexParameters();
51  public:
52  void SetInnerTexture(GLWrapper::Texture2D* texture);
53  virtual DeviceTexturePtr_type GetTexture();
54  virtual const TextureInfo* GetTextureInfo();
55 
56  GLWrapper::Texture2D* CreateTextureFromFile_Serial(const std::string& sFileName);
57 
61  virtual bool IsFlipY();
62 
71  static void LoadImage(char *sBufMemFile, int sizeBuf, int &width, int &height, byte ** ppBuffer, bool bAlpha);
76  static bool LoadImageOfFormat(const std::string& sTextureFileName, char *sBufMemFile, int sizeBuf, int &width, int &height, byte ** ppBuffer, int* pBytesPerPixel = NULL, int nFormat = -1);
77 
79  static TextureEntity* CreateTexture(const uint8 * pTexels, int width, int height, int rowLength, int bytesPerPixel, uint32 nMipLevels = 0, D3DPOOL dwCreatePool = D3DPOOL_MANAGED, DWORD nFormat = 0);
81  static TextureEntity* CreateTexture(const char* pFileName, uint32 nMipLevels = 0, D3DPOOL dwCreatePool = D3DPOOL_MANAGED);
82  protected:
83  friend class CRenderTarget;
84  union{
85  GLWrapper::Texture2D* m_texture;
86  GLWrapper::Texture2D** m_pTextureSequence;
87  };
90  };
91 
92  // the manager class
94 
95 }
Which DXT Compression to Use? Obviously, there are some trade-offs between the different formats whic...
Definition: TextureEntity.h:29
virtual DeviceTexturePtr_type GetTexture()
Get the texture for rendering.
virtual bool IsFlipY()
in most cases this is false, where the image origin is at left, top.
static bool LoadImageOfFormat(const std::string &sTextureFileName, char *sBufMemFile, int sizeBuf, int &width, int &height, byte **ppBuffer, int *pBytesPerPixel=NULL, int nFormat=-1)
this function uses FreeImage lib and support more formats.
virtual HRESULT RendererRecreated()
callback of listening the event that renderer was recreated on Android/WP8 all opengl related id has ...
virtual void SetSamplerStateBlocky(bool bIsBlocky)
whether we will use blocky or non-blocky (anti-aliased) texture
AssetType
each asset type has a unique asset type number
Definition: AssetEntity.h:82
a render target scene object.
Definition: RenderTarget.h:16
basic texture information
Definition: TextureEntity.h:83
different physics engine has different winding order.
Definition: EventBinding.h:32
uint32 m_nSamplerState
0 for anti-aliased, 1 for blocky texture.
Definition: TextureEntityOpenGL.h:89
virtual const TextureInfo * GetTextureInfo()
get texture info.
virtual bool LoadFromImage(ImageEntity *image, D3DFORMAT dwTextureFormat=D3DFMT_UNKNOWN, UINT nMipLevels=0, void **ppTexture=NULL)
Initializes a texture from an ImageEntity object.
AssetManager manages a set of asset entities of a certain type.
Definition: AssetManager.h:13
static void LoadImage(char *sBufMemFile, int sizeBuf, int &width, int &height, byte **ppBuffer, bool bAlpha)
load image of any format to buffer.
virtual bool SaveToFile(const char *filename, D3DFORMAT dwFormat, int width, int height, UINT MipLevels=1, DWORD Filter=D3DX_DEFAULT, Color ColorKey=0)
save any texture to a different texture file format and save with full mipmapping to disk...
static TextureEntity * CreateTexture(const uint8 *pTexels, int width, int height, int rowLength, int bytesPerPixel, uint32 nMipLevels=0, D3DPOOL dwCreatePool=D3DPOOL_MANAGED, DWORD nFormat=0)
create a texture entity from memory buffer.
texture entity.
Definition: TextureEntityOpenGL.h:10
std::string AssetKey
the unique key object for asset entity.
Definition: AssetEntity.h:13
Definition: ParaColor.h:275
Unlike TextureEntity, ImageEntity is a device independent entity in memory.
Definition: ImageEntity.h:9
virtual HRESULT LoadFromMemory(const char *buffer, DWORD nFileSize, UINT nMipLevels, D3DFORMAT dwTextureFormat=D3DFMT_UNKNOWN, void **ppTexture=NULL)
load from memory buffer.