| 1 | /* |
| 2 | Copyright (C) 2002 Rice1964 |
| 3 | |
| 4 | This program is free software; you can redistribute it and/or |
| 5 | modify it under the terms of the GNU General Public License |
| 6 | as published by the Free Software Foundation; either version 2 |
| 7 | of the License, or (at your option) any later version. |
| 8 | |
| 9 | This program is distributed in the hope that it will be useful, |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | GNU General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU General Public License |
| 15 | along with this program; if not, write to the Free Software |
| 16 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 17 | |
| 18 | */ |
| 19 | |
| 20 | #ifndef _TEXTURE_BUFFER_H_ |
| 21 | #define _TEXTURE_BUFFER_H_ |
| 22 | |
| 23 | #include "typedefs.h" |
| 24 | #include "TextureManager.h" |
| 25 | |
| 26 | class CRenderTexture; |
| 27 | typedef struct { |
| 28 | CRenderTexture *pRenderTexture; |
| 29 | SetImgInfo CI_Info; |
| 30 | |
| 31 | uint32 bufferWidth; |
| 32 | uint32 bufferHeight; |
| 33 | uint32 N64Width; |
| 34 | uint32 N64Height; |
| 35 | float scaleX; |
| 36 | float scaleY; |
| 37 | |
| 38 | int maxUsedHeight; |
| 39 | uint32 updateAtFrame; |
| 40 | uint32 updateAtUcodeCount; |
| 41 | |
| 42 | bool isUsed; |
| 43 | uint32 knownHeight; |
| 44 | |
| 45 | uint32 crcInRDRAM; |
| 46 | uint32 crcCheckedAtFrame; |
| 47 | |
| 48 | TxtrCacheEntry txtEntry; |
| 49 | } RenderTextureInfo; |
| 50 | |
| 51 | |
| 52 | class CRenderTexture |
| 53 | { |
| 54 | public: |
| 55 | friend class CGraphicsContext; |
| 56 | friend class CDXGraphicsContext; |
| 57 | friend class FrameBufferManager; |
| 58 | friend class DXFrameBufferManager; |
| 59 | friend class OGLFrameBufferManager; |
| 60 | CRenderTexture(int width, int height, RenderTextureInfo* pInfo, TextureUsage usage) |
| 61 | { |
| 62 | m_beingRendered = false; |
| 63 | m_width = m_height = 0; |
| 64 | m_pTexture = NULL; |
| 65 | m_pInfo = pInfo; |
| 66 | m_usage = usage; |
| 67 | } |
| 68 | virtual ~CRenderTexture() {} |
| 69 | |
| 70 | virtual bool SetAsRenderTarget(bool enable)=0; |
| 71 | virtual void LoadTexture(TxtrCacheEntry* pEntry)=0; |
| 72 | |
| 73 | virtual void StoreToRDRAM(int infoIdx) {}; |
| 74 | |
| 75 | void GetDimension(int &width, int &height) |
| 76 | { |
| 77 | width = m_width; |
| 78 | height = m_height; |
| 79 | } |
| 80 | |
| 81 | bool IsBeingRendered() |
| 82 | { |
| 83 | return m_beingRendered; |
| 84 | } |
| 85 | |
| 86 | TextureUsage GetUsage() {return m_usage;} |
| 87 | |
| 88 | |
| 89 | protected: |
| 90 | int m_width; |
| 91 | int m_height; |
| 92 | bool m_beingRendered; |
| 93 | TextureUsage m_usage; |
| 94 | |
| 95 | CTexture* m_pTexture; |
| 96 | RenderTextureInfo* m_pInfo; |
| 97 | }; |
| 98 | |
| 99 | |
| 100 | class COGLRenderTexture : public CRenderTexture |
| 101 | { |
| 102 | // Haven't implemented yet |
| 103 | public: |
| 104 | COGLRenderTexture(int width, int height, RenderTextureInfo* pInfo, TextureUsage usage); |
| 105 | ~COGLRenderTexture(); |
| 106 | |
| 107 | bool SetAsRenderTarget(bool enable); |
| 108 | void LoadTexture(TxtrCacheEntry* pEntry); |
| 109 | void StoreToRDRAM(int infoIdx); |
| 110 | |
| 111 | protected: |
| 112 | bool InitPBuffer(void); |
| 113 | void ShutdownPBuffer(void); |
| 114 | |
| 115 | int m_widthCreated; |
| 116 | int m_heightCreated; |
| 117 | |
| 118 | |
| 119 | COGLTexture *m_pOGLTexture; |
| 120 | }; |
| 121 | |
| 122 | #endif |
| 123 | |
| 124 | |
| 125 | |