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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
// *********************************************
#include <string.h>
#include "SDL.h"
#include "glut.h"
#include "GL\gl.h"
#include "GL\glext.h"
// fonctions
void Init(){
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
}
void Evenements(){
SDL_Event event;
while ( SDL_PollEvent(&event) ){
switch ( event.type ){
// fins
case SDL_QUIT: { SDL_Quit(); } break;
case SDL_KEYDOWN:{ SDL_Quit(); } break;
}
}
}
void Texte( int x, int y, char* txt ){
glDisable( GL_DEPTH_TEST );
glMatrixMode( GL_PROJECTION );
glPushMatrix();
glLoadIdentity();
glOrtho( -400.0, 400.0, -300.0, 300.0, 1.0, 100.0 );
glRasterPos2f( x,y );
int len = (int) strlen(txt);
for (int i = 0; i < len; i++){ glutBitmapCharacter( GLUT_BITMAP_HELVETICA_18, txt[i] ); }
glPopMatrix();
glMatrixMode( GL_MODELVIEW );
glEnable( GL_DEPTH_TEST );
}
// Entry point
int main( int argc, char *argv[] )
{
SDL_Init( SDL_INIT_VIDEO );
SDL_SetVideoMode( 800, 600, 32, SDL_OPENGL );
glViewport ( 0,0, 800,600 );
glClearColor ( 0.2f, 0.0f, 0.4f, 0.6f );
glClearDepth ( 1.0 );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
gluPerspective ( 45.0f, ((GLfloat) 800 / (GLfloat) 600), 0.1f, 100.0f );
glMatrixMode( GL_MODELVIEW );
glDepthFunc( GL_LESS );
glEnable( GL_DEPTH_TEST );
glShadeModel( GL_SMOOTH );
// ****************************************
while ( 1 ){
Evenements();
Init();
glTranslatef( 0.0f, 0.0f, -15.0f );
Texte( 400,300, "BONJOUR_A_TOUS !" );
// redessiner
SDL_GL_SwapBuffers();
}
// fin de programme
return 0;
} |
Partager