source: GTP/trunk/App/Demos/Illum/Standalone/Hierarchical Systems Demo [OpenGL]/RESOURCES/include/Cg/cgD3D.h @ 852

Revision 852, 4.4 KB checked in by szirmay, 19 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
52#ifndef _cgD3D_h
53#define _cgD3D_h
54
55#if WIN32
56
57#include <Cg/cg.h>
58#include <assert.h>
59
60
61#ifndef STRICT
62#define STRICT
63#endif
64
65#include <windows.h>
66#include <commdlg.h>
67#include <tchar.h>
68#include <stdio.h>
69#include <d3d8.h>
70#include <d3dx8.h>
71
72
73#define MAX_STREAMS 16
74
75#include <Cg/cgProgramManager.h>
76#include <Cg/cgContextManager.h>
77           
78
79
80
81////////////////////////////////////////////////
82//
83//      cgDX8Vertex  and cgDX8Pixel are defined with
84//  macros:
85//
86//      CG_PROFILE_MACRO(DX8Vertex,dx8vs,"dx8vs")
87//      CG_PROFILE_MACRO(DX8Pixel,dx8ps,"dx8ps")
88//
89//      cgDX8VertexProfile
90
91
92
93
94class cgDirect3D
95{
96public:
97
98    cgDirect3D();
99    ~cgDirect3D();
100
101    // add a path to locate the cg programs
102    // do not add the trailing '\\'
103    void AddFilePath(const char * dirpath);
104    void AddFilePath(cg_string & path);
105     
106   
107    void NotePad(const char * title, const char * listing )
108    {
109       
110        cg_string text;
111        text = title;
112
113        if(listing != NULL)
114          text += listing;
115         else
116          text += "*** NO LISTING ***\n";
117       
118        char * TmpLstFile = tmpnam(0);
119       
120        FILE * fpLst = fopen(TmpLstFile, "w");
121        fputs(text.c_str(), fpLst);
122        fclose(fpLst);
123       
124        char Cmd[1000];
125        sprintf(Cmd, "notepad %s", TmpLstFile);
126        int Ret =  system(Cmd);
127       
128        unlink(TmpLstFile);
129       
130    }
131
132    cgContextContainer * CreateContextContainer(LPDIRECT3DDEVICE8 pd3dDevice, DWORD * outIndex = 0)
133    {
134        return cm.CreateContextContainer(pd3dDevice,  outIndex);
135    }
136   
137
138private:
139    cgContextManager cm;
140    LPDIRECT3DDEVICE8 m_pd3dDevice;
141   
142};
143                           
144
145
146
147
148
149
150
151
152#define CGRTERR_ILLEGAL_PROFILE -1
153#define CGRTERR_VERTEX_ATTRIBUTES_NOT_SET -2
154
155#endif // WIN32
156
157#endif
158
Note: See TracBrowser for help on using the repository browser.