質問編集履歴
2
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
c言語の勉強法を知りたいです。
|
test
CHANGED
@@ -1,477 +1 @@
|
|
1
|
-
### 前提・実現したいこと
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
ここに質問の内容を詳しく書いてください。
|
6
|
-
|
7
|
-
(例)PHP(CakePHP)で●●なシステムを作っています。
|
8
|
-
|
9
|
-
■■な機能を実装中に以下のエラーメッセージが発生しました。
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
### 発生している問題・エラーメッセージ
|
14
|
-
|
15
|
-
|
1
|
+
初学からc言語を勉強し、基本情報技術者の試験で(c言語の部分だけ)9割安定するくらいの能力、それから実践でも簡単なアプリを作れる、、というようなレベルまで高めるにはどのような勉強法で学習していけばよいですか?
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
エラー 2 error LNK2019: 未解決の外部シンボル __imp____glutCreateWindowWithExit@8 が関数 _glutCreateWindow_ATEXIT_HACK@4 で参照されました。 Z:\mywork\mywork.obj mywork
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
```
|
26
|
-
|
27
|
-
エラーメッセージ
|
28
|
-
|
29
|
-
```
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
### 該当のソースコード
|
34
|
-
|
35
|
-
c++
|
36
|
-
|
37
|
-
```ここに言語名を入力
|
38
|
-
|
39
|
-
ソースコード
|
40
|
-
|
41
|
-
#include <stdlib.h>
|
42
|
-
|
43
|
-
#include <math.h>
|
44
|
-
|
45
|
-
#include <GL/glut.h>
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
#define W 6 /* 台の幅の2分の1 */
|
50
|
-
|
51
|
-
#define D 6 /* 台の長さの2分の1 */
|
52
|
-
|
53
|
-
#define CYCLE 600 /* 一周分のフレーム数 */
|
54
|
-
|
55
|
-
#define GR (D * 0.1) /* ゴンドラの半径 */
|
56
|
-
|
57
|
-
#define GD (D * 0.05) /* ゴンドラの幅 */
|
58
|
-
|
59
|
-
#define WR (W * 0.6) /* 観覧車の半径 */
|
60
|
-
|
61
|
-
#define SR (W * 0.01) /* 支柱の半径 */
|
62
|
-
|
63
|
-
#define NG 8 /* ゴンドラの数 */
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
#define PI 3.1415926535897932 /* 円周率 */
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
/*
|
72
|
-
|
73
|
-
* 床を描く
|
74
|
-
|
75
|
-
*/
|
76
|
-
|
77
|
-
static void myGround(double height)
|
78
|
-
|
79
|
-
{
|
80
|
-
|
81
|
-
const static GLfloat ground[][4] = { /* 台の色 */
|
82
|
-
|
83
|
-
{ 0.6, 0.6, 0.6, 1.0 },
|
84
|
-
|
85
|
-
{ 0.3, 0.3, 0.3, 1.0 }
|
86
|
-
|
87
|
-
};
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
glBegin(GL_QUADS);
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
glNormal3d(0.0, 1.0, 0.0);
|
96
|
-
|
97
|
-
int i=0,j=0;
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
for (j = -D; j < D; ++j) {
|
102
|
-
|
103
|
-
for (i = -W; i < W; ++i) {
|
104
|
-
|
105
|
-
glMaterialfv(GL_FRONT, GL_DIFFUSE, ground[(i + j) & 1]);
|
106
|
-
|
107
|
-
glVertex3d((GLdouble)i, height, (GLdouble)j);
|
108
|
-
|
109
|
-
glVertex3d((GLdouble)i, height, (GLdouble)(j + 1));
|
110
|
-
|
111
|
-
glVertex3d((GLdouble)(i + 1), height, (GLdouble)(j + 1));
|
112
|
-
|
113
|
-
glVertex3d((GLdouble)(i + 1), height, (GLdouble)j);
|
114
|
-
|
115
|
-
}
|
116
|
-
|
117
|
-
}
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
glEnd();
|
122
|
-
|
123
|
-
}
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
/*
|
128
|
-
|
129
|
-
* 円柱を描く
|
130
|
-
|
131
|
-
*/
|
132
|
-
|
133
|
-
static void myCylinder(double radius, double height, int sides)
|
134
|
-
|
135
|
-
{
|
136
|
-
|
137
|
-
double step = 6.2831853072 / (double)sides;
|
138
|
-
|
139
|
-
int i = 0;
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
/* 後面 */
|
144
|
-
|
145
|
-
glNormal3d(0.0, 0.0, -1.0);
|
146
|
-
|
147
|
-
glBegin(GL_TRIANGLE_FAN);
|
148
|
-
|
149
|
-
while (i < sides) {
|
150
|
-
|
151
|
-
double t = step * (double)i++;
|
152
|
-
|
153
|
-
glVertex3d(radius * sin(t), radius * cos(t), 0.0);
|
154
|
-
|
155
|
-
}
|
156
|
-
|
157
|
-
glEnd();
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
/* 前面 */
|
162
|
-
|
163
|
-
glNormal3d(0.0, 0.0, 1.0);
|
164
|
-
|
165
|
-
glBegin(GL_TRIANGLE_FAN);
|
166
|
-
|
167
|
-
while (--i >= 0) {
|
168
|
-
|
169
|
-
double t = step * (double)i;
|
170
|
-
|
171
|
-
glVertex3d(radius * sin(t), radius * cos(t), height);
|
172
|
-
|
173
|
-
}
|
174
|
-
|
175
|
-
glEnd();
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
/* 側面 */
|
180
|
-
|
181
|
-
glBegin(GL_QUAD_STRIP);
|
182
|
-
|
183
|
-
while (i <= sides) {
|
184
|
-
|
185
|
-
double t = step * (double)i++;
|
186
|
-
|
187
|
-
double x = sin(t);
|
188
|
-
|
189
|
-
double y = cos(t);
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
glNormal3d(x, y, 0.0);
|
194
|
-
|
195
|
-
glVertex3f(radius * x, radius * y, 0.0);
|
196
|
-
|
197
|
-
glVertex3f(radius * x, radius * y, height);
|
198
|
-
|
199
|
-
}
|
200
|
-
|
201
|
-
glEnd();
|
202
|
-
|
203
|
-
}
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
/*
|
208
|
-
|
209
|
-
* 画面表示
|
210
|
-
|
211
|
-
*/
|
212
|
-
|
213
|
-
static void display(void)
|
214
|
-
|
215
|
-
{
|
216
|
-
|
217
|
-
const static GLfloat lightpos[] = { -3.0, 4.0, 5.0, 1.0 }; /* 光源の位置 */
|
218
|
-
|
219
|
-
const static GLfloat orange[] = { 0.9, 0.4, 0.1, 1.0 }; /* ゴンドラの色 */
|
220
|
-
|
221
|
-
const static GLfloat white[] = { 0.9, 0.9, 0.9, 1.0 }; /* 支柱の色 */
|
222
|
-
|
223
|
-
static int frame = 0; /* 現在のフレーム数 */
|
224
|
-
|
225
|
-
int i;
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
/* CYCLE フレームごとに 0 -> 1 に変化 */
|
230
|
-
|
231
|
-
double t = (double)frame / (double)CYCLE;
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
/* フレーム数(画面表示を行った回数)をカウントする */
|
236
|
-
|
237
|
-
if (++frame >= CYCLE) frame = 0;
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
/* 画面クリア */
|
242
|
-
|
243
|
-
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
/* モデルビュー変換行列の初期化 */
|
248
|
-
|
249
|
-
glLoadIdentity();
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
/* 光源の位置を設定 */
|
254
|
-
|
255
|
-
glLightfv(GL_LIGHT0, GL_POSITION, lightpos);
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
/* 視点の移動(物体の方を奥に移す)*/
|
260
|
-
|
261
|
-
glTranslated(0.0, 0.0, -10.0);
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
/* 地面の描画 */
|
266
|
-
|
267
|
-
myGround(-(WR + GR + GR));
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
for (i = 0; i < NG; ++i) {
|
272
|
-
|
273
|
-
glRotated(360.0 / (double)NG, 0.0, 0.0, 1.0);
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
/* ゴンドラの描画 */
|
278
|
-
|
279
|
-
glPushMatrix();
|
280
|
-
|
281
|
-
{
|
282
|
-
|
283
|
-
glTranslated(WR, 0.0, 0.0);
|
284
|
-
|
285
|
-
glTranslated(0.0, GR * (-0.8), -GD); /* ゴンドラの支点 */
|
286
|
-
|
287
|
-
glMaterialfv(GL_FRONT, GL_DIFFUSE, orange);
|
288
|
-
|
289
|
-
myCylinder(GR, GD * 2.0, 32);
|
290
|
-
|
291
|
-
}
|
292
|
-
|
293
|
-
glPopMatrix();
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
/* 支柱の描画 */
|
298
|
-
|
299
|
-
glMaterialfv(GL_FRONT, GL_DIFFUSE, white);
|
300
|
-
|
301
|
-
glPushMatrix();
|
302
|
-
|
303
|
-
{
|
304
|
-
|
305
|
-
glRotated(90.0, 0.0, 1.0, 0.0);
|
306
|
-
|
307
|
-
glPushMatrix();
|
308
|
-
|
309
|
-
{
|
310
|
-
|
311
|
-
glTranslated(GD + SR, 0.0, 0.0);
|
312
|
-
|
313
|
-
myCylinder(SR, WR, 8);
|
314
|
-
|
315
|
-
glTranslated(0.0, 0.0, WR);
|
316
|
-
|
317
|
-
glRotated(90.0 + 180.0 / NG, -1.0, 0.0, 0.0);
|
318
|
-
|
319
|
-
myCylinder(SR, WR * 2.0 * PI / NG, 8);
|
320
|
-
|
321
|
-
}
|
322
|
-
|
323
|
-
glPopMatrix();
|
324
|
-
|
325
|
-
glPushMatrix();
|
326
|
-
|
327
|
-
{
|
328
|
-
|
329
|
-
glTranslated(-(GD + SR), 0.0, 0.0);
|
330
|
-
|
331
|
-
myCylinder(SR, WR, 8);
|
332
|
-
|
333
|
-
glTranslated(0.0, 0.0, WR);
|
334
|
-
|
335
|
-
glRotated(90.0 + 180.0 / NG, -1.0, 0.0, 0.0);
|
336
|
-
|
337
|
-
myCylinder(SR, WR * 2.0 * sin(PI / NG), 8);
|
338
|
-
|
339
|
-
}
|
340
|
-
|
341
|
-
glPopMatrix();
|
342
|
-
|
343
|
-
}
|
344
|
-
|
345
|
-
glPopMatrix();
|
346
|
-
|
347
|
-
}
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
glFlush();
|
352
|
-
|
353
|
-
}
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
static void resize(int w, int h)
|
358
|
-
|
359
|
-
{
|
360
|
-
|
361
|
-
/* ウィンドウ全体をビューポートにする */
|
362
|
-
|
363
|
-
glViewport(0, 0, w, h);
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
/* 透視変換行列の指定 */
|
368
|
-
|
369
|
-
glMatrixMode(GL_PROJECTION);
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
/* 透視変換行列の初期化 */
|
374
|
-
|
375
|
-
glLoadIdentity();
|
376
|
-
|
377
|
-
gluPerspective(60.0, (double)w / (double)h, 1.0, 100.0);
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
/* モデルビュー変換行列の指定 */
|
382
|
-
|
383
|
-
glMatrixMode(GL_MODELVIEW);
|
384
|
-
|
385
|
-
}
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
static void keyboard(unsigned char key, int x, int y)
|
390
|
-
|
391
|
-
{
|
392
|
-
|
393
|
-
/* ESC か q をタイプしたら終了 */
|
394
|
-
|
395
|
-
if (key == '\033' || key == 'q') {
|
396
|
-
|
397
|
-
exit(0);
|
398
|
-
|
399
|
-
}
|
400
|
-
|
401
|
-
}
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
static void init(void)
|
406
|
-
|
407
|
-
{
|
408
|
-
|
409
|
-
/* 初期設定 */
|
410
|
-
|
411
|
-
glClearColor(1.0, 1.0, 1.0, 1.0);
|
412
|
-
|
413
|
-
glEnable(GL_DEPTH_TEST);
|
414
|
-
|
415
|
-
glEnable(GL_CULL_FACE);
|
416
|
-
|
417
|
-
glEnable(GL_LIGHTING);
|
418
|
-
|
419
|
-
glEnable(GL_LIGHT0);
|
420
|
-
|
421
|
-
}
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
int main(int argc, char *argv[])
|
426
|
-
|
427
|
-
{
|
428
|
-
|
429
|
-
glutInit(&argc, argv);
|
430
|
-
|
431
|
-
glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH);
|
432
|
-
|
433
|
-
glutCreateWindow(argv[0]);
|
434
|
-
|
435
|
-
glutDisplayFunc(display);
|
436
|
-
|
437
|
-
glutReshapeFunc(resize);
|
438
|
-
|
439
|
-
glutKeyboardFunc(keyboard);
|
440
|
-
|
441
|
-
init();
|
442
|
-
|
443
|
-
glutMainLoop();
|
444
|
-
|
445
|
-
return 0;
|
446
|
-
|
447
|
-
}
|
448
|
-
|
449
|
-
```
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
### 試したこと
|
454
|
-
|
455
|
-
vs2012から新規->visualc++->Win32->Win32 コンソールアプリケーション
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
~.cppにglut,h、GLUTをコピー
|
460
|
-
|
461
|
-
構成プロパティ プリコンパイル済み
|
462
|
-
|
463
|
-
ヘッダーを使用しない
|
464
|
-
|
465
|
-
追加の依存ファイルに
|
466
|
-
|
467
|
-
glut32.libを追加
|
468
|
-
|
469
|
-
ここに問題に対して試したことを記載してください。
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
### 補足情報(FW/ツールのバージョンなど)
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
ここにより詳細な情報を記載してください。
|
1
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|