source: GTP/branches/IllumWPdeliver2008dec/IlluminationWP/demos/Standalone/Hierarchical Systems Demo [OpenGL]/RESOURCES/include/Cg/cgD3D9.h @ 3255

Revision 3255, 7.7 KB checked in by szirmay, 15 years ago (diff)
Line 
1/*
2 *
3 * Copyright (c) 2002, 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#if 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#if WIN32
64    # include <windows.h>
65    #ifdef CGD3D9DLL_EXPORTS
66    #define CGD3D9DLL_API __declspec(dllexport)
67    #elif defined (CG_LIB)
68    #define CGD3D9DLL_API
69    #else
70    #define CGD3D9DLL_API __declspec(dllimport)
71    #endif
72#else
73    #define CGD3D9DLL_API
74#endif
75
76/*---------------------------------------------------------------------------
77// CGerrors that will be fed to cgSetError
78// Use cgD3D9TranslateCGerror() to translate these errors into strings.
79---------------------------------------------------------------------------*/
80enum cgD3D9Errors
81{
82    cgD3D9Failed = 1000,
83    cgD3D9DebugTrace = 1001,
84};
85
86/*---------------------------------------------------------------------------
87// HRESULTs specific to cgD3D9. When the CGerror is set to cgD3D9Failed
88// cgD3D9GetLastError will return an HRESULT that could be one these.
89// Use cgD3D9TranslateHRESULT() to translate these errors into strings.
90---------------------------------------------------------------------------*/
91static const HRESULT CGD3D9ERR_NOTLOADED       = MAKE_HRESULT(1, 0x877,  1);
92static const HRESULT CGD3D9ERR_NODEVICE        = MAKE_HRESULT(1, 0x877,  2);
93static const HRESULT CGD3D9ERR_NOTSAMPLER      = MAKE_HRESULT(1, 0x877,  3);
94static const HRESULT CGD3D9ERR_INVALIDPROFILE  = MAKE_HRESULT(1, 0x877,  4);
95static const HRESULT CGD3D9ERR_NULLVALUE       = MAKE_HRESULT(1, 0x877,  5);
96static const HRESULT CGD3D9ERR_OUTOFRANGE      = MAKE_HRESULT(1, 0x877,  6);
97static const HRESULT CGD3D9ERR_NOTUNIFORM      = MAKE_HRESULT(1, 0x877,  7);
98static const HRESULT CGD3D9ERR_NOTMATRIX       = MAKE_HRESULT(1, 0x877,  8);
99static const HRESULT CGD3D9ERR_INVALIDPARAM    = MAKE_HRESULT(1, 0x877,  9);
100
101/*---------------------------------------------------------------------------
102// Other error return values
103---------------------------------------------------------------------------*/
104static const DWORD CGD3D9_INVALID_USAGE = 0xFF;
105
106#ifdef __cplusplus
107extern "C"
108{
109#endif
110
111/*---------------------------------------------------------------------------
112// Minimal Interface
113---------------------------------------------------------------------------*/
114
115CGD3D9DLL_API
116DWORD cgD3D9TypeToSize(
117  CGtype type
118);
119
120CGD3D9DLL_API
121BYTE cgD3D9ResourceToDeclUsage(
122  CGresource resource
123);
124
125CGD3D9DLL_API
126CGbool cgD3D9GetVertexDeclaration(
127  CGprogram prog,
128  D3DVERTEXELEMENT9 decl[MAXD3DDECLLENGTH]
129);
130
131CGD3D9DLL_API
132CGbool cgD3D9ValidateVertexDeclaration(
133  CGprogram    prog,
134  const D3DVERTEXELEMENT9* decl
135);
136
137/*---------------------------------------------------------------------------
138// Expanded Interface
139---------------------------------------------------------------------------*/
140
141/* ----- D3D Device Control ----------- */
142CGD3D9DLL_API
143IDirect3DDevice9* cgD3D9GetDevice();
144
145CGD3D9DLL_API
146HRESULT cgD3D9SetDevice(
147  IDirect3DDevice9* pDevice
148);
149
150/* ----- Shader Management ----------- */
151
152CGD3D9DLL_API
153HRESULT cgD3D9LoadProgram(
154  CGprogram    prog,
155  CGbool       paramShadowing,
156  DWORD        assemFlags
157);
158
159CGD3D9DLL_API
160HRESULT cgD3D9UnloadProgram(
161  CGprogram prog
162);
163
164CGD3D9DLL_API
165CGbool cgD3D9IsProgramLoaded(
166  CGprogram prog
167);
168
169CGD3D9DLL_API
170HRESULT cgD3D9BindProgram(
171  CGprogram prog
172);
173
174/* ----- Parameter Management ----------- */
175CGD3D9DLL_API
176HRESULT cgD3D9SetUniform(
177  CGparameter param,
178  const void* floats
179);
180
181CGD3D9DLL_API
182HRESULT cgD3D9SetUniformArray(
183  CGparameter param,
184  DWORD       offset,
185  DWORD       numItems,
186  const void* values
187);
188
189CGD3D9DLL_API
190HRESULT cgD3D9SetUniformMatrix(
191  CGparameter      param,
192  const D3DMATRIX* matrix
193);
194
195CGD3D9DLL_API
196HRESULT cgD3D9SetUniformMatrixArray(
197  CGparameter      param,
198  DWORD            offset,
199  DWORD            numItems,
200  const D3DMATRIX* matrices
201);
202
203CGD3D9DLL_API
204HRESULT cgD3D9SetTexture(
205  CGparameter            param,
206  IDirect3DBaseTexture9* tex
207);
208
209CGD3D9DLL_API
210HRESULT cgD3D9SetSamplerState(
211  CGparameter         param,
212  D3DSAMPLERSTATETYPE type,
213  DWORD               value
214);
215
216CGD3D9DLL_API
217HRESULT cgD3D9SetTextureWrapMode(
218  CGparameter param,
219  DWORD       value
220);
221
222/* ----- Parameter Management (Shadowing) ----------- */
223CGD3D9DLL_API
224HRESULT cgD3D9EnableParameterShadowing(
225  CGprogram prog,
226  CGbool enable
227);
228
229CGD3D9DLL_API
230CGbool cgD3D9IsParameterShadowingEnabled(
231  CGprogram prog
232);
233
234/* --------- Profile Options ----------------- */
235CGD3D9DLL_API
236CGprofile cgD3D9GetLatestVertexProfile();
237
238CGD3D9DLL_API
239CGprofile cgD3D9GetLatestPixelProfile();
240
241CGD3D9DLL_API
242char const* cgD3D9GetOptimalOptions(
243  CGprofile profile
244);
245
246/* --------- Error reporting ----------------- */
247CGD3D9DLL_API
248HRESULT cgD3D9GetLastError();
249
250CGD3D9DLL_API
251const char* cgD3D9TranslateCGerror(
252  CGerror error
253);
254
255CGD3D9DLL_API
256const char* cgD3D9TranslateHRESULT(
257  HRESULT hr
258);
259
260CGD3D9DLL_API
261void cgD3D9EnableDebugTracing(
262  CGbool enable
263);
264
265#ifdef __cplusplus
266};
267#endif
268
269#endif // WIN32
270
271#endif
Note: See TracBrowser for help on using the repository browser.