VR-Vantage 2.7 API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cgD3D8.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 CGD3D8_INCLUDED
52 #define CGD3D8_INCLUDED
53 
54 #ifdef _WIN32
55 
56 #pragma once
57 
58 #include "cg.h"
59 #include <d3d8.h>
60 #include <d3dx8.h>
61 
62 // Set up for either Win32 import/export/lib.
63 #include <windows.h>
64 #ifdef CGD3D8DLL_EXPORTS
65 #define CGD3D8DLL_API __declspec(dllexport)
66 #elif defined (CG_LIB)
67 #define CGD3D8DLL_API
68 #else
69 #define CGD3D8DLL_API __declspec(dllimport)
70 #endif
71 
72 #ifndef CGD3D8ENTRY
73 # ifdef _WIN32
74 # define CGD3D8ENTRY __cdecl
75 # else
76 # define CGD3D8ENTRY
77 # endif
78 #endif
79 
80 /*---------------------------------------------------------------------------
81 // CGerrors that will be fed to cgSetError
82 // Use cgD3D8TranslateCGerror() to translate these errors into strings.
83 ---------------------------------------------------------------------------*/
84 enum cgD3D8Errors
85 {
86  cgD3D8Failed = 1000,
87  cgD3D8DebugTrace = 1001,
88 };
89 
90 /*---------------------------------------------------------------------------
91 // HRESULTs specific to cgD3D8. When the CGerror is set to cgD3D8Failed
92 // cgD3D8GetLastError will return an HRESULT that could be one these.
93 // Use cgD3D8TranslateHRESULT() to translate these errors into strings.
94 ---------------------------------------------------------------------------*/
95 static const HRESULT CGD3D8ERR_NOTLOADED = MAKE_HRESULT(1, 0x877, 1);
96 static const HRESULT CGD3D8ERR_NODEVICE = MAKE_HRESULT(1, 0x877, 2);
97 static const HRESULT CGD3D8ERR_NOTSAMPLER = MAKE_HRESULT(1, 0x877, 3);
98 static const HRESULT CGD3D8ERR_INVALIDPROFILE = MAKE_HRESULT(1, 0x877, 4);
99 static const HRESULT CGD3D8ERR_NULLVALUE = MAKE_HRESULT(1, 0x877, 5);
100 static const HRESULT CGD3D8ERR_OUTOFRANGE = MAKE_HRESULT(1, 0x877, 6);
101 static const HRESULT CGD3D8ERR_NOTUNIFORM = MAKE_HRESULT(1, 0x877, 7);
102 static const HRESULT CGD3D8ERR_NOTMATRIX = MAKE_HRESULT(1, 0x877, 8);
103 static const HRESULT CGD3D8ERR_INVALIDPARAM = MAKE_HRESULT(1, 0x877, 9);
104 
105 static const HRESULT CGD3D8ERR_INVALIDSAMPLERSTATE = MAKE_HRESULT(1, 0x877, 100);
106 static const HRESULT CGD3D8ERR_INVALIDVEREXDECL = MAKE_HRESULT(1, 0x877, 101);
107 
108 /*---------------------------------------------------------------------------
109 // Other error return values
110 ---------------------------------------------------------------------------*/
111 static const DWORD CGD3D8_INVALID_REG = 0xFFFFFFFF;
112 
113 #ifdef __cplusplus
114 extern "C"
115 {
116 #endif
117 
118 /*---------------------------------------------------------------------------
119 // Minimal Interface
120 ---------------------------------------------------------------------------*/
121 
122 CGD3D8DLL_API DWORD CGD3D8ENTRY
123 cgD3D8TypeToSize(
124  CGtype type
125 );
126 
127 CGD3D8DLL_API DWORD CGD3D8ENTRY
128 cgD3D8ResourceToInputRegister(
129  CGresource resource
130 );
131 
132 CGD3D8DLL_API CGbool CGD3D8ENTRY
133 cgD3D8GetVertexDeclaration(
134  CGprogram prog,
135  DWORD decl[MAX_FVF_DECL_SIZE]
136 );
137 
138 CGD3D8DLL_API CGbool CGD3D8ENTRY
139 cgD3D8ValidateVertexDeclaration(
140  CGprogram prog,
141  const DWORD* decl
142 );
143 
144 /*---------------------------------------------------------------------------
145 // Expanded Interface
146 ---------------------------------------------------------------------------*/
147 
148 /* ----- D3D Device Control ----------- */
149 CGD3D8DLL_API IDirect3DDevice8 * CGD3D8ENTRY
150 cgD3D8GetDevice();
151 
152 CGD3D8DLL_API HRESULT CGD3D8ENTRY
153 cgD3D8SetDevice(
154  IDirect3DDevice8* pDevice
155 );
156 
157 /* ----- Shader Management ----------- */
158 CGD3D8DLL_API HRESULT CGD3D8ENTRY
159 cgD3D8LoadProgram(
160  CGprogram prog,
161  CGbool paramShadowing,
162  DWORD assemFlags,
163  DWORD vshaderUsage,
164  const DWORD* vertexDecl
165 );
166 
167 CGD3D8DLL_API HRESULT CGD3D8ENTRY
168 cgD3D8UnloadProgram(
169  CGprogram prog
170 );
171 
172 CGD3D8DLL_API CGbool CGD3D8ENTRY
173 cgD3D8IsProgramLoaded(
174  CGprogram prog
175 );
176 
177 CGD3D8DLL_API HRESULT CGD3D8ENTRY
178 cgD3D8BindProgram(
179  CGprogram prog
180 );
181 
182 /* ----- Parameter Management ----------- */
183 CGD3D8DLL_API HRESULT CGD3D8ENTRY
184 cgD3D8SetUniform(
186  const void* floats
187 );
188 
189 CGD3D8DLL_API HRESULT CGD3D8ENTRY
190 cgD3D8SetUniformArray(
192  DWORD offset,
193  DWORD numItems,
194  const void* values
195 );
196 
197 CGD3D8DLL_API HRESULT CGD3D8ENTRY
198 cgD3D8SetUniformMatrix(
200  const D3DMATRIX* matrix
201 );
202 
203 CGD3D8DLL_API HRESULT CGD3D8ENTRY
204 cgD3D8SetUniformMatrixArray(
206  DWORD offset,
207  DWORD numItems,
208  const D3DMATRIX* matrices
209 );
210 
211 CGD3D8DLL_API HRESULT CGD3D8ENTRY
212 cgD3D8SetTexture(
214  IDirect3DBaseTexture8* tex
215 );
216 
217 CGD3D8DLL_API HRESULT CGD3D8ENTRY
218 cgD3D8SetTextureStageState(
220  D3DTEXTURESTAGESTATETYPE type,
221  DWORD value
222 );
223 
224 CGD3D8DLL_API HRESULT CGD3D8ENTRY
225 cgD3D8SetTextureWrapMode(
227  DWORD value
228 );
229 
230 /* ----- Parameter Management (Shadowing) ----------- */
231 CGD3D8DLL_API HRESULT CGD3D8ENTRY
232 cgD3D8EnableParameterShadowing(
233  CGprogram prog,
234  CGbool enable
235 );
236 
237 CGD3D8DLL_API CGbool CGD3D8ENTRY
238 cgD3D8IsParameterShadowingEnabled(
239  CGprogram prog
240 );
241 
242 /* --------- Profile Options ----------------- */
243 CGD3D8DLL_API CGprofile CGD3D8ENTRY
244 cgD3D8GetLatestVertexProfile();
245 
246 CGD3D8DLL_API CGprofile CGD3D8ENTRY
247 cgD3D8GetLatestPixelProfile();
248 
249 CGD3D8DLL_API const char * CGD3D8ENTRY
250 cgD3D8GetOptimalOptions(
251  CGprofile profile
252 );
253 
254 /* --------- Error reporting ----------------- */
255 CGD3D8DLL_API HRESULT CGD3D8ENTRY
256 cgD3D8GetLastError();
257 
258 CGD3D8DLL_API const char * CGD3D8ENTRY
259 cgD3D8TranslateCGerror(
260  CGerror error
261 );
262 
263 CGD3D8DLL_API const char * CGD3D8ENTRY
264 cgD3D8TranslateHRESULT(
265  HRESULT hr
266 );
267 
268 CGD3D8DLL_API void CGD3D8ENTRY
269 cgD3D8EnableDebugTracing(
270  CGbool enable
271 );
272 
273 #ifdef __cplusplus
274 };
275 #endif
276 
277 #endif // _WIN32
278 
279 #endif


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