hey,
Ik ben dus nog C++ aan het leren, en nou moest ik deze code gebruiken. Hij werkt alleen niet
De fout zit op regel 120
Ik ben dus nog C++ aan het leren, en nou moest ik deze code gebruiken. Hij werkt alleen niet
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
| #include <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>
HDC g_HDC; //globale device context
///////////////////////////////////////////////////////////////////////////
//Pixelformatdescriptor
///////////////////////////////////////////////////////////////////////////
void setuppfd(HDC hDC)
{
int nPixelFormat;
static PIXELFORMATDESCRIPTOR pfd={
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW|
PFD_SUPPORT_OPENGL|
PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA,
32,
0,0,0,0,0,0,
0,
0,
0,
0,0,0,0,
16,
0,
0,
PFD_MAIN_PLANE,
0,
0,0,0};
nPixelFormat = ChoosePixelFormat(hDC, &pfd);
SetPixelFormat(hDC,nPixelFormat, &pfd);
}
/////////////////////////////////////////////////////////////////////////////
//Windows Procedure
/////////////////////////////////////////////////////////////////////////////
LRESULT CALLBACK WndProc(HWND hwnd,
UINT message,
WPARAM wParam,
LPARAM lParam)
{
static HGLRC hRC;
static HDC hDC;
switch (message)
{
case WM_CREATE:
hDC = GetDC(hwnd);
g_HDC = hDC;
setuppfd(hDC);
hRC = wglCreateContext(hDC);
wglMakeCurrent(hDC,hRC);
break;
case WM_CLOSE:
wglMakeCurrent(hDC,NULL);
wglDeleteContext(hRC);
PostQuitMessage(0);
break;
case WM_KEYDOWN:
switch (wParam)
{
case VK_ESCAPE:
wglMakeCurrent(hDC,NULL);
wglDeleteContext(hRC);
PostQuitMessage(0);
break;
}
}
return DefWindowProc(hwnd,message,wParam,lParam);
}
////////////////////////////////////////////////////////////////////////////
//Main Functie
////////////////////////////////////////////////////////////////////////////
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nShowCmd)
{
WNDCLASSEX wc;
HWND hwnd;
MSG msg;
bool done=FALSE;
wc.cbSize =sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = NULL;
wc.lpszMenuName = NULL;
wc.lpszClassName = "OpenGL";
wc.hIconSm = LoadIcon(NULL,IDI_WINLOGO);
RegisterClassEx(&wc);
hwnd=CreateWindowEx(NULL,
"OpenGL",
"glwindow",
WS_OVERLAPPEDWINDOW |WS_VISIBLE |
WS_SYSMENU | WS_CLIPCHILDREN |
WS_CLIPSIBLINGS,
100,100,
400,400,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hwnd, SW_SHOW);
UpdateWindow(hwnd);
while(!done)
{
PeekMessage(&msg,NULL,0,0,PM_REMOVE);
if (msg.message==WM_QUIT)
{
done=TRUE;
}
else
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f,0.0f,0.0f);
glColor3f(1.0f,0.0f,0.0f);
glBegin(GL_TRIANGLES);
glVertex3f(0.0f,0.5f,0.0f);
glVertex3f(-0.5f,-0.5f,0.0f);
glVertex3f(0.5f,-0.5f,0.0f);
glEnd();
SwapBuffers(g_HDC);
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (msg.wParam);
} |
De fout zit op regel 120
[ Voor 4% gewijzigd door Verwijderd op 06-11-2004 14:49 ]