d07c171f |
1 | /* |
2 | Copyright (C) 2003 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 GFXCONTEXT_H |
21 | #define GFXCONTEXT_H |
22 | |
23 | #include "typedefs.h" |
24 | #include "CritSect.h" |
25 | |
26 | enum ClearFlag |
27 | { |
28 | CLEAR_COLOR_BUFFER=0x01, |
29 | CLEAR_DEPTH_BUFFER=0x02, |
30 | CLEAR_COLOR_AND_DEPTH_BUFFER=0x03, |
31 | }; |
32 | |
33 | |
34 | typedef struct |
35 | { |
36 | uint32 addr; //N64 RDRAM address |
37 | uint32 size; //N64 buffer size |
38 | uint32 format; //N64 format |
39 | uint32 width; |
40 | uint32 height; |
41 | } TextureBufferShortInfo; |
42 | |
43 | |
44 | // This class basically provides an extra level of security for our |
45 | // multithreaded code. Threads can Grab the CGraphicsContext to prevent |
46 | // other threads from changing/releasing any of the pointers while it is |
47 | // running. |
48 | |
49 | // It is based on CCritSect for Lock() and Unlock() |
50 | |
51 | class CGraphicsContext : public CCritSect |
52 | { |
53 | friend class CDeviceBuilder; |
54 | |
55 | public: |
56 | bool Ready() { return m_bReady; } |
57 | bool IsWindowed() {return m_bWindowed;} |
58 | |
59 | virtual bool Initialize(uint32 dwWidth, uint32 dwHeight, BOOL bWindowed ); |
60 | virtual bool ResizeInitialize(uint32 dwWidth, uint32 dwHeight, BOOL bWindowed ); |
61 | virtual void CleanUp(); |
62 | |
63 | virtual void Clear(ClearFlag flags, uint32 color=0xFF000000, float depth=1.0f) = 0; |
64 | virtual void UpdateFrame(bool swaponly=false) = 0; |
65 | virtual int ToggleFullscreen()=0; // return 0 as the result is windowed |
66 | |
67 | static void InitWindowInfo(); |
68 | static void InitDeviceParameters(); |
69 | |
70 | bool m_supportTextureMirror; |
71 | |
72 | public: |
73 | static int m_maxFSAA; |
74 | static int m_maxAnisotropy; |
75 | |
76 | protected: |
77 | static uint32 m_dwWindowStyle; // Saved window style for mode switches |
78 | static uint32 m_dwWindowExStyle; // Saved window style for mode switches |
79 | static uint32 m_dwStatusWindowStyle; // Saved window style for mode switches |
80 | |
81 | static bool m_deviceCapsIsInitialized; |
82 | |
83 | bool m_bReady; |
84 | bool m_bActive; |
85 | |
86 | bool m_bWindowed; |
87 | RECT m_rcWindowBounds; |
88 | |
89 | char m_strDeviceStats[256]; |
90 | |
91 | virtual ~CGraphicsContext(); |
92 | CGraphicsContext(); |
93 | |
94 | public: |
95 | static CGraphicsContext *g_pGraphicsContext; |
96 | static CGraphicsContext * Get(void); |
97 | inline const char* GetDeviceStr() {return m_strDeviceStats;} |
98 | static bool needCleanScene; |
99 | }; |
100 | |
101 | #endif |
102 | |