VR-Vantage 3.0.3 API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
cgD3D9.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2002-2010, NVIDIA Corporation.
4  *
5  *
6  *
7  * NVIDIA Corporation("NVIDIA") supplies this software to you in consideration
8  * of your agreement to the following terms, and your use, installation,
9  * modification or redistribution of this NVIDIA software constitutes
10  * acceptance of these terms. If you do not agree with these terms, please do
11  * not use, install, modify or redistribute this NVIDIA software.
12  *
13  *
14  *
15  * In consideration of your agreement to abide by the following terms, and
16  * subject to these terms, NVIDIA grants you a personal, non-exclusive license,
17  * under NVIDIA's copyrights in this original NVIDIA software (the "NVIDIA
18  * Software"), to use, reproduce, modify and redistribute the NVIDIA
19  * Software, with or without modifications, in source and/or binary forms;
20  * provided that if you redistribute the NVIDIA Software, you must retain the
21  * copyright notice of NVIDIA, this notice and the following text and
22  * disclaimers in all such redistributions of the NVIDIA Software. Neither the
23  * name, trademarks, service marks nor logos of NVIDIA Corporation may be used
24  * to endorse or promote products derived from the NVIDIA Software without
25  * specific prior written permission from NVIDIA. Except as expressly stated
26  * in this notice, no other rights or licenses express or implied, are granted
27  * by NVIDIA herein, including but not limited to any patent rights that may be
28  * infringed by your derivative works or by other works in which the NVIDIA
29  * Software may be incorporated. No hardware is licensed hereunder.
30  *
31  *
32  *
33  * THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
34  * WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
35  * WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
36  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR ITS USE AND OPERATION
37  * EITHER ALONE OR IN COMBINATION WITH OTHER PRODUCTS.
38  *
39  *
40  *
41  * IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
42  * EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOST
43  * PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
44  * PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY OUT OF THE USE,
45  * REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE NVIDIA SOFTWARE,
46  * HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING
47  * NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF NVIDIA HAS BEEN ADVISED
48  * OF THE POSSIBILITY OF SUCH DAMAGE.
49  *
50  */
51 #ifndef CGD3D9_INCLUDED
52 #define CGD3D9_INCLUDED
53 
54 #ifdef _WIN32
55 
56 #pragma once
57 
58 #include "cg.h"
59 #include <d3d9.h>
60 #include <d3dx9.h>
61 
62 // Set up for either Win32 import/export/lib.
63 #include <windows.h>
64 #ifdef CGD3D9DLL_EXPORTS
65 #define CGD3D9DLL_API __declspec(dllexport)
66 #elif defined (CG_LIB)
67 #define CGD3D9DLL_API
68 #else
69 #define CGD3D9DLL_API __declspec(dllimport)
70 #endif
71 
72 #ifndef CGD3D9ENTRY
73 # ifdef _WIN32
74 # define CGD3D9ENTRY __cdecl
75 # else
76 # define CGD3D9ENTRY
77 # endif
78 #endif
79 
80 /*---------------------------------------------------------------------------
81 // CGerrors that will be fed to cgSetError
82 // Use cgD3D9TranslateCGerror() to translate these errors into strings.
83 ---------------------------------------------------------------------------*/
84 enum cgD3D9Errors
85 {
86  cgD3D9Failed = 1000,
87  cgD3D9DebugTrace = 1001,
88 };
89 
90 /*---------------------------------------------------------------------------
91 // HRESULTs specific to cgD3D9. When the CGerror is set to cgD3D9Failed
92 // cgD3D9GetLastError will return an HRESULT that could be one these.
93 // Use cgD3D9TranslateHRESULT() to translate these errors into strings.
94 ---------------------------------------------------------------------------*/
95 static const HRESULT CGD3D9ERR_NOTLOADED = MAKE_HRESULT(1, 0x877, 1);
96 static const HRESULT CGD3D9ERR_NODEVICE = MAKE_HRESULT(1, 0x877, 2);
97 static const HRESULT CGD3D9ERR_NOTSAMPLER = MAKE_HRESULT(1, 0x877, 3);
98 static const HRESULT CGD3D9ERR_INVALIDPROFILE = MAKE_HRESULT(1, 0x877, 4);
99 static const HRESULT CGD3D9ERR_NULLVALUE = MAKE_HRESULT(1, 0x877, 5);
100 static const HRESULT CGD3D9ERR_OUTOFRANGE = MAKE_HRESULT(1, 0x877, 6);
101 static const HRESULT CGD3D9ERR_NOTUNIFORM = MAKE_HRESULT(1, 0x877, 7);
102 static const HRESULT CGD3D9ERR_NOTMATRIX = MAKE_HRESULT(1, 0x877, 8);
103 static const HRESULT CGD3D9ERR_INVALIDPARAM = MAKE_HRESULT(1, 0x877, 9);
104 
105 /*---------------------------------------------------------------------------
106 // Other error return values
107 ---------------------------------------------------------------------------*/
108 static const DWORD CGD3D9_INVALID_USAGE = 0xFF;
109 
110 #ifdef __cplusplus
111 extern "C"
112 {
113 #endif
114 
115 #ifndef CGD3D9_EXPLICIT
116 
117 /*---------------------------------------------------------------------------
118 // Minimal Interface
119 ---------------------------------------------------------------------------*/
120 
121 CGD3D9DLL_API DWORD CGD3D9ENTRY
122 cgD3D9TypeToSize(
123  CGtype type
124 );
125 
126 CGD3D9DLL_API BYTE CGD3D9ENTRY
127 cgD3D9ResourceToDeclUsage(
128  CGresource resource
129 );
130 
131 CGD3D9DLL_API CGbool CGD3D9ENTRY
132 cgD3D9GetVertexDeclaration(
133  CGprogram prog,
134  D3DVERTEXELEMENT9 decl[MAXD3DDECLLENGTH]
135 );
136 
137 CGD3D9DLL_API CGbool CGD3D9ENTRY
138 cgD3D9ValidateVertexDeclaration(
139  CGprogram prog,
140  const D3DVERTEXELEMENT9* decl
141 );
142 
143 /*---------------------------------------------------------------------------
144 // Expanded Interface
145 ---------------------------------------------------------------------------*/
146 
147 /* ----- D3D Device Control ----------- */
148 CGD3D9DLL_API IDirect3DDevice9 * CGD3D9ENTRY
149 cgD3D9GetDevice();
150 
151 CGD3D9DLL_API HRESULT CGD3D9ENTRY
152 cgD3D9SetDevice(
153  IDirect3DDevice9* pDevice
154 );
155 
156 /* ----- Shader Management ----------- */
157 
158 CGD3D9DLL_API HRESULT CGD3D9ENTRY
159 cgD3D9LoadProgram(
160  CGprogram prog,
161  CGbool paramShadowing,
162  DWORD assemFlags
163 );
164 
165 CGD3D9DLL_API HRESULT CGD3D9ENTRY
166 cgD3D9UnloadProgram(
167  CGprogram prog
168 );
169 
170 CGD3D9DLL_API CGbool CGD3D9ENTRY
171 cgD3D9IsProgramLoaded(
172  CGprogram prog
173 );
174 
175 CGD3D9DLL_API HRESULT CGD3D9ENTRY
176 cgD3D9BindProgram(
177  CGprogram prog
178 );
179 
180 /* ----- Parameter Management ----------- */
181 CGD3D9DLL_API HRESULT CGD3D9ENTRY
182 cgD3D9SetUniform(
184  const void* floats
185 );
186 
187 CGD3D9DLL_API HRESULT CGD3D9ENTRY
188 cgD3D9SetUniformArray(
190  DWORD offset,
191  DWORD numItems,
192  const void* values
193 );
194 
195 CGD3D9DLL_API HRESULT CGD3D9ENTRY
196 cgD3D9SetUniformMatrix(
198  const D3DMATRIX* matrix
199 );
200 
201 CGD3D9DLL_API HRESULT CGD3D9ENTRY
202 cgD3D9SetUniformMatrixArray(
204  DWORD offset,
205  DWORD numItems,
206  const D3DMATRIX* matrices
207 );
208 
209 CGD3D9DLL_API HRESULT CGD3D9ENTRY
210 cgD3D9SetTexture(
212  IDirect3DBaseTexture9* tex
213 );
214 
215 CGD3D9DLL_API HRESULT CGD3D9ENTRY
216 cgD3D9SetSamplerState(
218  D3DSAMPLERSTATETYPE type,
219  DWORD value
220 );
221 
222 CGD3D9DLL_API HRESULT CGD3D9ENTRY
223 cgD3D9SetTextureWrapMode(
225  DWORD value
226 );
227 
228 /* ----- Parameter Management (Shadowing) ----------- */
229 CGD3D9DLL_API HRESULT CGD3D9ENTRY
230 cgD3D9EnableParameterShadowing(
231  CGprogram prog,
232  CGbool enable
233 );
234 
235 CGD3D9DLL_API CGbool CGD3D9ENTRY
236 cgD3D9IsParameterShadowingEnabled(
237  CGprogram prog
238 );
239 
240 /* --------- Profile Options ----------------- */
241 CGD3D9DLL_API CGprofile CGD3D9ENTRY
242 cgD3D9GetLatestVertexProfile();
243 
244 CGD3D9DLL_API CGprofile CGD3D9ENTRY
245 cgD3D9GetLatestPixelProfile();
246 
247 CGD3D9DLL_API const char * * CGD3D9ENTRY
248 cgD3D9GetOptimalOptions(
249  CGprofile profile
250 );
251 
252 CGD3D9DLL_API CGbool CGD3D9ENTRY
253 cgD3D9IsProfileSupported(
254  CGprofile profile
255 );
256 
257 /* --------- Error reporting ----------------- */
258 CGD3D9DLL_API HRESULT CGD3D9ENTRY
259 cgD3D9GetLastError();
260 
261 CGD3D9DLL_API const char * CGD3D9ENTRY
262 cgD3D9TranslateCGerror(
263  CGerror error
264 );
265 
266 CGD3D9DLL_API const char * CGD3D9ENTRY
267 cgD3D9TranslateHRESULT(
268  HRESULT hr
269 );
270 
271 CGD3D9DLL_API void CGD3D9ENTRY
272 cgD3D9EnableDebugTracing(
273  CGbool enable
274 );
275 
276 /* --------- CgFX support -------------------- */
277 
278 CGD3D9DLL_API void CGD3D9ENTRY
279 cgD3D9RegisterStates(
280  CGcontext ctx
281 );
282 
283 CGD3D9DLL_API void CGD3D9ENTRY
284 cgD3D9SetManageTextureParameters(
285  CGcontext ctx,
286  CGbool flag
287 );
288 
289 CGD3D9DLL_API CGbool CGD3D9ENTRY
290 cgD3D9GetManageTextureParameters(
291  CGcontext ctx
292 );
293 
294 CGD3D9DLL_API IDirect3DBaseTexture9 * CGD3D9ENTRY
295 cgD3D9GetTextureParameter(
297 );
298 
299 CGD3D9DLL_API void CGD3D9ENTRY
300 cgD3D9SetTextureParameter(
302  IDirect3DBaseTexture9 *tex
303 );
304 
305 CGD3D9DLL_API void CGD3D9ENTRY
306 cgD3D9UnloadAllPrograms( void );
307 
308 
309 #endif
310 
311 #ifdef __cplusplus
312 };
313 #endif
314 
315 #endif // _WIN32
316 
317 #endif


Copyright © 2005-2023 MAK Technologies. All Rights Reserved (www.mak.com)