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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
| // instruction préprocesseur: recopier le code qui se trouve dans le ficher
//========================================================================
#include <SDL.h>
#include <SDL_image.h> // import image de format different de bmp
#include <SDL_ttf.h>
#include <stdio.h>
#include <iostream>
// declaration, initialisation de variables
//=========================================
// dimension ecran
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 440;
// The window we'll be rendering to
SDL_Window* gWindow = NULL;
// The window renderer
SDL_Renderer* gRenderer = NULL;
// Globally used font
TTF_Font *font = NULL;
// couleur
SDL_Color couleur_vert = {130, 250, 0, 1};
SDL_Color couleur_texte = {5, 50, 200};
// fonction principale
//====================
int main( int argc, char* args[] )
{
//Initialize SDL
SDL_Init( SDL_INIT_VIDEO );
//Set texture filtering to linear
SDL_SetHint( SDL_HINT_RENDER_SCALE_QUALITY, "1" );
//Create window
gWindow = SDL_CreateWindow( "Table de multiplication", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
// icone de la fenetre
SDL_Surface* var_icon = IMG_Load("logo.png");
if( var_icon != NULL )
{
std::cout << "image importeee" << std::endl;
}
SDL_SetWindowIcon(gWindow, var_icon);
//Create vsynced renderer for window
gRenderer = SDL_CreateRenderer( gWindow, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC );
//Initialize renderer color
//SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF );
SDL_SetRenderDrawColor( gRenderer, couleur_vert.r, couleur_vert.g, couleur_vert.b, couleur_vert.a);
//Initialize PNG loading
int imgFlags = IMG_INIT_PNG;
IMG_Init( imgFlags );
//Initialize SDL_ttf
TTF_Init();
//Load media
//Open the font
font = TTF_OpenFont( "arial.ttf", 25 );
//Main loop flag
bool quit = false;
//Event handler
SDL_Event e;
//While application is running
while( !quit )
{
//The rerender text flag
bool renderText = false;
bool bouton_egal_clique = false;
//Handle events on queue
while( SDL_PollEvent( &e ) != 0 )
{
//User requests quit
if( e.type == SDL_QUIT )
{
quit = true;
}
}
}
//Free global font
TTF_CloseFont( font );
font = NULL;
//Destroy window
SDL_DestroyRenderer( gRenderer );
SDL_DestroyWindow( gWindow );
gWindow = NULL;
gRenderer = NULL;
//Quit SDL subsystems
TTF_Quit();
IMG_Quit();
SDL_Quit();
return 0;
} |
Partager