SHOW:
|
|
- or go back to the newest paste.
| 1 | int sgeSetRenderMode(sgeEventMode mode) | |
| 2 | {
| |
| 3 | if (!(sgeDefaultContext)) {
| |
| 4 | fprintf(stderr, "%s: SGE must be initialised first.\n", __func__); | |
| 5 | return -1; | |
| 6 | } | |
| 7 | sgeDefaultContext->RenderMode = mode; | |
| 8 | /* Set up OpenGL for 2D rendering if necessary. | |
| 9 | */ | |
| 10 | if (mode == SGE_OPENGL2D) {
| |
| 11 | if (!(sgeDefaultContext->Screen)) {
| |
| 12 | sgeSetError("%s: Video mode must be set first.\n",
| |
| 13 | __func__); | |
| 14 | return -1; | |
| 15 | } | |
| 16 | SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); | |
| 17 | glEnable(GL_TEXTURE_2D); | |
| 18 | glClearColor(0.f, 0.f, 0.f, 0.f); | |
| 19 | glViewport(0, 0, sgeDefaultContext->Screen->w, sgeDefaultContext->Screen->h); | |
| 20 | glClear(GL_COLOR_BUFFER_BIT); | |
| 21 | glMatrixMode(GL_PROJECTION); | |
| 22 | glLoadIdentity(); | |
| 23 | glOrtho(0.f, sgeDefaultContext->Screen->w, sgeDefaultContext->Screen->h, 0.f, -1.f, 1.f); | |
| 24 | glMatrixMode(GL_MODELVIEW); | |
| 25 | glLoadIdentity(); | |
| 26 | } | |
| 27 | return 0; | |
| 28 | } |