1 | ///////////////////////////////////////////////////////////////////////////////
|
---|
2 | //
|
---|
3 | // ## ######
|
---|
4 | // ###### ###
|
---|
5 | // ## ############### Shark 3D Engine (www.shark3d.com)
|
---|
6 | // ########## # # #
|
---|
7 | // ######## Copyright (c) 1996-2006 Spinor GmbH.
|
---|
8 | // ######### # # # All rights reserved.
|
---|
9 | // ## ##########
|
---|
10 | // ##
|
---|
11 | //
|
---|
12 | ///////////////////////////////////////////////////////////////////////////////
|
---|
13 |
|
---|
14 | //@cpp
|
---|
15 |
|
---|
16 | #ifndef S3D_DRV_DXBASE_H
|
---|
17 | #define S3D_DRV_DXBASE_H
|
---|
18 |
|
---|
19 | #include "general/general_env.h"
|
---|
20 | #include "drv/interf/drv_gfx.h"
|
---|
21 |
|
---|
22 | ///////////////////////////////////////////////////////////////////////////////
|
---|
23 |
|
---|
24 | #ifndef S3D_GENERAL_PLATFORM_XBOXFAMILY
|
---|
25 | #ifndef S3D_DRV_D3D_DX8
|
---|
26 |
|
---|
27 | #include <d3d9.h>
|
---|
28 | #include <d3dx9.h>
|
---|
29 |
|
---|
30 | // Check DX versions to ensure that an SDK is compiled and linked
|
---|
31 | // against a well-defined DX version:
|
---|
32 |
|
---|
33 | // Important! If you change the version here,
|
---|
34 | // then don't forget to change the verison
|
---|
35 | // also in the documentation about - requirements.
|
---|
36 | // Also important! If you support more than one version,
|
---|
37 | // then you must add the version string to the S3D_GENERAL_AMBIT macro.
|
---|
38 | #if DIRECT3D_VERSION != 0x0900
|
---|
39 | #pragma message( "Found DIRECT3D_VERSION = " \
|
---|
40 | S3D_GENERAL_STR(DIRECT3D_VERSION) )
|
---|
41 | #error Wrong DIRECT3D_VERSION. See the previous output line.
|
---|
42 | #endif
|
---|
43 |
|
---|
44 | // Important! If you change the version here,
|
---|
45 | // then don't forget to change the verison
|
---|
46 | // also in the documentation about - requirements.
|
---|
47 | // Also important! If you support more than one version,
|
---|
48 | // then you must add the version string to the S3D_GENERAL_AMBIT macro.
|
---|
49 | #if (D3D_SDK_VERSION & 0x7fffffff) != 32
|
---|
50 | #pragma message( "Found D3D_SDK_VERSION = " \
|
---|
51 | S3D_GENERAL_STR(D3D_SDK_VERSION) )
|
---|
52 | #error Wrong D3D_SDK_VERSION. See the previous output line.
|
---|
53 | #endif
|
---|
54 |
|
---|
55 | // Important! If you change the version here,
|
---|
56 | // then don't forget to change the verison
|
---|
57 | // also in the documentation about - requirements.
|
---|
58 | // Also important! If you support more than one version,
|
---|
59 | // then you must add the version string to the S3D_GENERAL_AMBIT macro.
|
---|
60 | #if D3DX_VERSION != 0x0902
|
---|
61 | #pragma message( "Found D3DX_VERSION = " \
|
---|
62 | S3D_GENERAL_STR(D3DX_VERSION) )
|
---|
63 | #error Wrong D3DX_VERSION. See the previous output line.
|
---|
64 | #endif
|
---|
65 |
|
---|
66 | // Important! If you change the version here,
|
---|
67 | // then don't forget to change the verison
|
---|
68 | // also in the documentation about - requirements.
|
---|
69 | // Also important! If you support more than one version,
|
---|
70 | // then you must add the version string to the S3D_GENERAL_AMBIT macro.
|
---|
71 | #if D3DX_SDK_VERSION != 31 // HE CAMBIADO ESTO PORQUE AQUÍ USO LA VERSION de Octubre DE D3DX
|
---|
72 | #pragma message( "Found D3DX_SDK_VERSION = " \
|
---|
73 | S3D_GENERAL_STR(D3DX_SDK_VERSION) )
|
---|
74 | #error Wrong D3DX_SDK_VERSION. See the previous output line.
|
---|
75 | #endif
|
---|
76 |
|
---|
77 | #endif
|
---|
78 | #endif
|
---|
79 |
|
---|
80 | ///////////////////////////////////////////////////////////////////////////////
|
---|
81 |
|
---|
82 | //@
|
---|
83 | template<typename T>
|
---|
84 | class s3d_CDrvDxCom
|
---|
85 | {
|
---|
86 | public:
|
---|
87 | //@
|
---|
88 | s3d_CDrvDxCom();
|
---|
89 |
|
---|
90 | //@
|
---|
91 | s3d_CDrvDxCom(const s3d_CDrvDxCom<T> &Com);
|
---|
92 |
|
---|
93 | //@
|
---|
94 | ~s3d_CDrvDxCom();
|
---|
95 |
|
---|
96 | //@
|
---|
97 | void Reset();
|
---|
98 |
|
---|
99 | //@
|
---|
100 | void operator=(T p);
|
---|
101 |
|
---|
102 | //@
|
---|
103 | void operator=(const s3d_CDrvDxCom<T> &Com);
|
---|
104 |
|
---|
105 | //@
|
---|
106 | const T operator->() const;
|
---|
107 |
|
---|
108 | //@
|
---|
109 | operator const T() const;
|
---|
110 |
|
---|
111 | //@
|
---|
112 | T Get() const;
|
---|
113 |
|
---|
114 | //@ To use in QueryInterface functions or other functions
|
---|
115 | // calling implicitely AddRef.
|
---|
116 | T &EmptyRef();
|
---|
117 |
|
---|
118 | private:
|
---|
119 | __declspec(align(16)) T m_p;
|
---|
120 | };
|
---|
121 |
|
---|
122 | ///////////////////////////////////////////////////////////////////////////////
|
---|
123 |
|
---|
124 | //@
|
---|
125 | struct s3d_CDrvDxError: s3d_CDrvGfxError
|
---|
126 | {
|
---|
127 | };
|
---|
128 |
|
---|
129 | ///////////////////////////////////////////////////////////////////////////////
|
---|
130 | // Implementations:
|
---|
131 | ///////////////////////////////////////////////////////////////////////////////
|
---|
132 |
|
---|
133 | template<typename T>
|
---|
134 | S3D_SYS_INLINE s3d_CDrvDxCom<T>::s3d_CDrvDxCom()
|
---|
135 | {
|
---|
136 | m_p = 0;
|
---|
137 | }
|
---|
138 |
|
---|
139 | template<typename T>
|
---|
140 | S3D_SYS_INLINE s3d_CDrvDxCom<T>::s3d_CDrvDxCom(const s3d_CDrvDxCom<T> &Com)
|
---|
141 | {
|
---|
142 | T p = Com.m_p;
|
---|
143 | m_p = p;
|
---|
144 | if(p)
|
---|
145 | p->AddRef();
|
---|
146 | }
|
---|
147 |
|
---|
148 | template<typename T>
|
---|
149 | S3D_SYS_INLINE s3d_CDrvDxCom<T>::~s3d_CDrvDxCom()
|
---|
150 | {
|
---|
151 | T pLast = m_p;
|
---|
152 | if(pLast)
|
---|
153 | pLast->Release();
|
---|
154 | }
|
---|
155 |
|
---|
156 | template<typename T>
|
---|
157 | S3D_SYS_INLINE void s3d_CDrvDxCom<T>::Reset()
|
---|
158 | {
|
---|
159 | T pLast = m_p;
|
---|
160 | if(pLast)
|
---|
161 | {
|
---|
162 | pLast->Release();
|
---|
163 | m_p = 0;
|
---|
164 | }
|
---|
165 | }
|
---|
166 |
|
---|
167 | template<typename T>
|
---|
168 | S3D_SYS_INLINE void s3d_CDrvDxCom<T>::operator=(T p)
|
---|
169 | {
|
---|
170 | if(p)
|
---|
171 | p->AddRef();
|
---|
172 | T pLast = m_p;
|
---|
173 | if(pLast)
|
---|
174 | pLast->Release();
|
---|
175 | m_p = p;
|
---|
176 | }
|
---|
177 |
|
---|
178 | template<typename T>
|
---|
179 | S3D_SYS_INLINE void s3d_CDrvDxCom<T>::operator=(const s3d_CDrvDxCom<T> &Com)
|
---|
180 | {
|
---|
181 | T p = Com.m_p;
|
---|
182 | if(p)
|
---|
183 | p->AddRef();
|
---|
184 | T pLast = m_p;
|
---|
185 | if(pLast)
|
---|
186 | pLast->Release();
|
---|
187 | m_p = p;
|
---|
188 | }
|
---|
189 |
|
---|
190 | template<typename T>
|
---|
191 | S3D_SYS_INLINE const T s3d_CDrvDxCom<T>::operator->() const
|
---|
192 | {
|
---|
193 | return m_p;
|
---|
194 | }
|
---|
195 |
|
---|
196 | template<typename T>
|
---|
197 | S3D_SYS_INLINE s3d_CDrvDxCom<T>::operator const T() const
|
---|
198 | {
|
---|
199 | return m_p;
|
---|
200 | }
|
---|
201 |
|
---|
202 | template<typename T>
|
---|
203 | S3D_SYS_INLINE T s3d_CDrvDxCom<T>::Get() const
|
---|
204 | {
|
---|
205 | return m_p;
|
---|
206 | }
|
---|
207 |
|
---|
208 | template<typename T>
|
---|
209 | S3D_SYS_INLINE T &s3d_CDrvDxCom<T>::EmptyRef()
|
---|
210 | {
|
---|
211 | T pLast = m_p;
|
---|
212 | if(pLast)
|
---|
213 | {
|
---|
214 | pLast->Release();
|
---|
215 | m_p = 0;
|
---|
216 | }
|
---|
217 | return m_p;
|
---|
218 | }
|
---|
219 |
|
---|
220 | ///////////////////////////////////////////////////////////////////////////////
|
---|
221 |
|
---|
222 |
|
---|
223 | #endif
|
---|