163 |
183 |
164 status=SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value); |
184 status=SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value); |
165 if (!status) { |
185 if (!status) { |
166 printf("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value); |
186 printf("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value); |
167 } else { |
187 } else { |
168 printf("Failed to get SDL_GL_RED_SIZE: %s\n", SDL_GetError()); |
188 fprintf(stderr, "Failed to get SDL_GL_RED_SIZE: %s\n", SDL_GetError()); |
169 } |
189 } |
170 status=SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value); |
190 status=SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value); |
171 if (!status) { |
191 if (!status) { |
172 printf("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value); |
192 printf("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value); |
173 } else { |
193 } else { |
174 printf("Failed to get SDL_GL_GREEN_SIZE: %s\n", SDL_GetError()); |
194 fprintf(stderr, "Failed to get SDL_GL_GREEN_SIZE: %s\n", SDL_GetError()); |
175 } |
195 } |
176 status=SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value); |
196 status=SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value); |
177 if (!status) { |
197 if (!status) { |
178 printf("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value); |
198 printf("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value); |
179 } else { |
199 } else { |
180 printf("Failed to get SDL_GL_BLUE_SIZE: %s\n", SDL_GetError()); |
200 fprintf(stderr, "Failed to get SDL_GL_BLUE_SIZE: %s\n", SDL_GetError()); |
181 } |
201 } |
182 status=SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value); |
202 status=SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value); |
183 if (!status) { |
203 if (!status) { |
184 printf("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", 16, value); |
204 printf("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", 16, value); |
185 } else { |
205 } else { |
186 printf("Failed to get SDL_GL_DEPTH_SIZE: %s\n", SDL_GetError()); |
206 fprintf(stderr, "Failed to get SDL_GL_DEPTH_SIZE: %s\n", SDL_GetError()); |
187 } |
207 } |
188 if (fsaa) { |
208 if (fsaa) { |
189 status=SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value); |
209 status=SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value); |
190 if (!status) { |
210 if (!status) { |
191 printf("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value); |
211 printf("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value); |
192 } else { |
212 } else { |
193 printf("Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n", SDL_GetError()); |
213 fprintf(stderr, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n", SDL_GetError()); |
194 } |
214 } |
195 status=SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value); |
215 status=SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value); |
196 if (!status) { |
216 if (!status) { |
197 printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, value); |
217 printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, value); |
198 } else { |
218 } else { |
199 printf("Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n", SDL_GetError()); |
219 fprintf(stderr, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n", SDL_GetError()); |
200 } |
220 } |
201 } |
221 } |
202 if (accel) { |
222 if (accel) { |
203 status=SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value); |
223 status=SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value); |
204 if (!status) |
224 if (!status) |
205 { |
225 { |
206 printf("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value); |
226 printf("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value); |
207 } else { |
227 } else { |
208 printf("Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n", SDL_GetError()); |
228 fprintf(stderr, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n", SDL_GetError()); |
209 } |
229 } |
210 } |
230 } |
211 |
231 |
212 /* Set rendering settings */ |
232 /* Set rendering settings for each context */ |
213 glMatrixMode(GL_PROJECTION); |
233 for (i = 0; i < state->num_windows; ++i) { |
214 glLoadIdentity(); |
234 status=SDL_GL_MakeCurrent(state->windows[i], context[i]); |
215 glOrthof(-2.0, 2.0, -2.0, 2.0, -20.0, 20.0); |
235 if (status) |
216 glMatrixMode(GL_MODELVIEW); |
236 { |
217 glLoadIdentity(); |
237 printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); |
218 glEnable(GL_DEPTH_TEST); |
238 |
219 glDepthFunc(GL_LESS); |
239 /* Continue for next window */ |
220 glShadeModel(GL_SMOOTH); |
240 continue; |
|
241 } |
|
242 |
|
243 glMatrixMode(GL_PROJECTION); |
|
244 glLoadIdentity(); |
|
245 glOrthof(-2.0, 2.0, -2.0, 2.0, -20.0, 20.0); |
|
246 glMatrixMode(GL_MODELVIEW); |
|
247 glLoadIdentity(); |
|
248 glEnable(GL_DEPTH_TEST); |
|
249 glDepthFunc(GL_LESS); |
|
250 glShadeModel(GL_SMOOTH); |
|
251 } |
221 |
252 |
222 /* Main render loop */ |
253 /* Main render loop */ |
223 frames = 0; |
254 frames = 0; |
224 then = SDL_GetTicks(); |
255 then = SDL_GetTicks(); |
225 done = 0; |
256 done = 0; |
229 while (SDL_PollEvent(&event)) { |
260 while (SDL_PollEvent(&event)) { |
230 CommonEvent(state, &event, &done); |
261 CommonEvent(state, &event, &done); |
231 } |
262 } |
232 for (i = 0; i < state->num_windows; ++i) { |
263 for (i = 0; i < state->num_windows; ++i) { |
233 int w, h; |
264 int w, h; |
234 SDL_GL_MakeCurrent(state->windows[i], context); |
265 status=SDL_GL_MakeCurrent(state->windows[i], context[i]); |
|
266 if (status) |
|
267 { |
|
268 printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); |
|
269 |
|
270 /* Continue for next window */ |
|
271 continue; |
|
272 } |
235 SDL_GetWindowSize(state->windows[i], &w, &h); |
273 SDL_GetWindowSize(state->windows[i], &w, &h); |
236 glViewport(0, 0, w, h); |
274 glViewport(0, 0, w, h); |
237 Render(); |
275 Render(); |
238 SDL_GL_SwapWindow(state->windows[i]); |
276 SDL_GL_SwapWindow(state->windows[i]); |
239 } |
277 } |