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
   | #include <iostream>
#include <SDL/SDL.h>
#include <GL/gl.h>
#include <GL/glu.h>
 
int main (int argc, char *argv[]) {
 
    SDL_Init(SDL_INIT_VIDEO);
 
    SDL_Surface *ecran = SDL_SetVideoMode(640, 480, 32, SDL_OPENGL);
 
    SDL_Flip(ecran);
 
    bool c = true;
    SDL_Event e;
 
    while(c) {
        SDL_WaitEvent(&e);
        switch(e.type) {
            case SDL_QUIT :
                c = false;
                break;
        }
 
        glClear(GL_COLOR_BUFFER_BIT);
 
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
 
        glBegin(GL_QUADS);
 
            glColor3ub(0, 255, 0);
            glVertex2d(-0.8, -0.8);
            glVertex2d(-0.8, -0.6);
            glVertex2d(-0.4, -0.6);
            glVertex2d(-0.4, -0.8);
 
 
            glPushMatrix();
            glRotated(45, 0, 0, 1);
            glColor3ub(0, 0, 200);
            glVertex2d(-0.6, -0.6);
            glVertex2d(-0.6, -0.5);
            glVertex2d(0.3, -0.5);
            glVertex2d(0.3, -0.6);
            glPopMatrix();
 
        glEnd();
 
 
        glFlush();
        SDL_GL_SwapBuffers();
 
    }
 
    SDL_Quit();
    return 0;
} | 
Partager