質問編集履歴

1

必要なところだけにした。また学校で配っているものなので、そのまま載せると問題かと思い直した

2017/12/14 13:52

投稿

wasabi999
wasabi999

スコア7

test CHANGED
File without changes
test CHANGED
@@ -1,10 +1,8 @@
1
1
  ###前提・実現したいこと
2
2
 
3
- ここに質問したいことを詳細に書いてください
4
3
 
5
- 学校の課題で、Open GLで日本の国旗を書くこと。
6
4
 
7
- 今回は学校が配布したライブラリでエラーが発生しました。(学校ではwindowsで
5
+ 自作のライブラリでエラーが発生しました。(学校ではwindowsで
8
6
 
9
7
  visual studioを使っていますが、家のパソコンではvisual studioを使えないので
10
8
 
@@ -30,255 +28,11 @@
30
28
 
31
29
  ###該当のソースコード
32
30
 
33
- #ifndef __sdglib_h__
34
-
35
- #define __sdglib_h__
36
31
 
37
32
 
38
-
39
- //#include <math.h>
40
-
41
- //#include <iostream>
42
-
43
- //#include <stdexcept>
44
-
45
- #include <string>
46
-
47
- //#include <string.h>
48
-
49
- //#include <GL/glut.h>
33
+ LIB::LIB(int size_x=600,int size_y=600, std::string title="No Title", double small_x=-300.0, double large_x=-300.0, double small_y=-300.0, double large_y=300.0) //ここにエラーが発生する。
50
34
 
51
35
 
52
-
53
- #if defined(WINDOWS) || defined(_WIN32) || defined(_WIN64)
54
-
55
- #include <GL/glut.h>
56
-
57
- #endif
58
-
59
- #if defined(linux) || defined(__linux) || defined(__linux__)
60
-
61
- #include <GL/glut.h>
62
-
63
- #endif
64
-
65
- #if defined(__APPLE__)
66
-
67
- #include <GLUT/glut.h>
68
-
69
- #endif
70
-
71
-
72
-
73
- #ifndef M_PI
74
-
75
- #define M_PI 3.14159265358979323846
76
-
77
- #endif
78
-
79
-
80
-
81
-
82
-
83
- class SDGLib {
84
-
85
- public:
86
-
87
- SDGLib(int, int, std::string, double, double, double, double);
88
-
89
- // ~SDGLib();
90
-
91
- //void Before(void);
92
-
93
- //void After(void);
94
-
95
- //void ReDraw(void);
96
-
97
- void Start(void);
98
-
99
- void SetCursor(int);
100
-
101
- //void SetColor(float, float, float);
102
-
103
- //void DrawPoint(float, double, double);
104
-
105
- //void DrawLine(float, double, double, double, double);
106
-
107
- //void DrawCircle(float, double, double, double);
108
-
109
- //void DrawString(double, double, char *);
110
-
111
- void Display(void (*)(void));
112
-
113
- void Keyboard(void (*)(unsigned char, int, int));
114
-
115
- private:
116
-
117
- int size_x, size_y;
118
-
119
- std::string title;
120
-
121
- double small_x, large_x, small_y, large_y;
122
-
123
- };
124
-
125
-
126
-
127
- void SDGLib::Display(void (*func)(void)) {
128
-
129
- glutDisplayFunc(func);
130
-
131
- };
132
-
133
- void SDGLib::Keyboard(void (*func)(unsigned char a, int b, int c)) {
134
-
135
- glutKeyboardFunc(func);
136
-
137
- };
138
-
139
-
140
-
141
- SDGLib::SDGLib(int size_x=600,int size_y=600, std::string title="No Title", double small_x=-300.0, double large_x=-300.0, double small_y=-300.0, double large_y=300.0) //ここにエラーが発生する。
142
-
143
- {
144
-
145
- int i=1;
146
-
147
- char *cv[1]={"SD"};
148
-
149
- glutInit(&i,cv);
150
-
151
- glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
152
-
153
- glutInitWindowSize(size_x, size_y);
154
-
155
- glutInitWindowPosition(0, 0);
156
-
157
- glutCreateWindow(title.c_str());
158
-
159
- glClearColor(1.0, 1.0, 1.0, 1.0);
160
-
161
- gluOrtho2D(small_x, large_x, small_y, large_y);
162
-
163
- glutSetCursor(GLUT_CURSOR_HELP);
164
-
165
- }
166
-
167
- void SDGLib::SetCursor(int cursor_type){
168
-
169
- glutSetCursor(cursor_type);
170
-
171
- }
172
-
173
- void SDGLib::Start(void){
174
-
175
- glutMainLoop();
176
-
177
- }
178
-
179
-
180
-
181
-
182
-
183
- namespace SDGLibF {
184
-
185
- void Before(void){
186
-
187
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
188
-
189
- }
190
-
191
- void After(void){
192
-
193
- glutSwapBuffers();
194
-
195
- }
196
-
197
- void SetCursor(int cursor_type){
198
-
199
- glutSetCursor(cursor_type);
200
-
201
- }
202
-
203
- void SetColor(float r, float g, float b){
204
-
205
- glColor3f((GLfloat)r, (GLfloat)g, (GLfloat)b);
206
-
207
- }
208
-
209
- void DrawPoint(float size=10, double x=0, double y=0){
210
-
211
- glPointSize((GLfloat)size);
212
-
213
- glBegin(GL_POINTS);
214
-
215
- glVertex2d((GLdouble)x, (GLdouble)y);
216
-
217
- glEnd();
218
-
219
- }
220
-
221
- void DrawLine(float width=2, double x1=100, double y1=100, double x2=-100, double y2=-100){
222
-
223
- glLineWidth((GLfloat)width);
224
-
225
- glBegin(GL_LINES);
226
-
227
- glVertex2d((GLdouble)x1,(GLdouble)y1);
228
-
229
- glVertex2d((GLdouble)x2,(GLdouble)y2);
230
-
231
- glEnd();
232
-
233
- }
234
-
235
- void DrawCircle(float width, double x, double y, double r){
236
-
237
- int i;
238
-
239
- GLdouble x1, x2, y1, y2;
240
-
241
-
242
-
243
- for(i=0; i<360; i++){
244
-
245
- x1=x+r*sin(M_PI*i/180.0); y1=y+r*cos(M_PI*i/180.0);
246
-
247
- x2=x+r*sin(M_PI*(i+1)/180.0); y2=y+r*cos(M_PI*(i+1)/180.0);
248
-
249
- DrawLine((GLfloat)width, x1, y1, x2, y2);
250
-
251
- }
252
-
253
- }
254
-
255
- void DrawString(double x, double y, std::string s){
256
-
257
- glRasterPos2f(x, y);
258
-
259
- for(unsigned int i=0; i<s.length(); i++){
260
-
261
- glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, s.at(i));
262
-
263
- }
264
-
265
- }
266
-
267
- void ReDraw(void){
268
-
269
- glutPostRedisplay();
270
-
271
- }
272
-
273
- void IdleFunc(void (*func)(void)) {
274
-
275
- glutIdleFunc(func);
276
-
277
- }
278
-
279
- }
280
-
281
- # endif
282
36
 
283
37
  ここにご自身が実行したソースコードを書いてください
284
38