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 102 103 104 105 106 107
| #include <SDL2/SDL.h>
#include <stdlib.h>
#include <stdio.h>
#include <OpenGL/gl3.h>
#include <SDL2_image.framework/Headers/SDL_image.h>
#include <SDL2_ttf.framework/Headers/SDL_ttf.h>
int main(int argc, char** argv)
{
/*SDL_Surface * ws = NULL;*/
TTF_Font *fonts;
SDL_Surface * is = NULL,*texte = NULL;
SDL_DisplayMode dpm;
SDL_GetDesktopDisplayMode(0, &dpm);
SDL_Renderer *renderer = NULL;
SDL_Color ct ={ 255, 255, 255, 255 };
SDL_Rect pt;
int quit = 0;
TTF_Init();
if (TTF_Init() != 0){
SDL_Quit();
return 1;
}
fonts = TTF_OpenFont("Arial.ttf",15);
SDL_Event event;IMG_Init(IMG_INIT_PNG);
/* Initialisation simple */
if (SDL_Init(SDL_INIT_VIDEO) != 0 )
{
fprintf(stdout,"Échec de l'initialisation de la SDL (%s)\n",SDL_GetError());
return -1;
}
/* Création de la fenêtre */
SDL_Window* pWindow = NULL;
pWindow = SDL_CreateWindow("Ma première application SDL2",SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
800,
600,
SDL_WINDOW_RESIZABLE);
// SDL_ShowWindow(pWindow);
// SDL_GLContext glcontext = SDL_GL_CreateContext(pWindow);
renderer = SDL_CreateRenderer(pWindow, -1, SDL_RENDERER_ACCELERATED|SDL_RENDERER_PRESENTVSYNC);
SDL_Surface * image = IMG_Load("image.png");
SDL_Texture * texture = SDL_CreateTextureFromSurface(renderer, image);
SDL_RenderCopy(renderer, texture, NULL, NULL);
SDL_RenderPresent(renderer);
pt.x = 180;pt.y = 210;
texte=TTF_RenderText_Blended(fonts, "Avé frater", ct);
// is = SDL_LoadBMP("image.bmp");
// ws = SDL_GetWindowSurface(pWindow);
//SDL_BlitSurface(is, NULL, ws, NULL);
SDL_UpdateWindowSurface(pWindow);
while (!quit)
{
SDL_WaitEvent(&event);
switch (event.type)
{
case SDL_QUIT:
quit = 1;
break;
}
}
IMG_Quit();SDL_DestroyWindow(pWindow);SDL_DestroyRenderer(renderer);SDL_FreeSurface(image);
SDL_FreeSurface(is);
//SDL_GL_DeleteContext(glcontext);
SDL_Quit();
TTF_CloseFont(fonts);
TTF_Quit();
return 0;
}
void Chargement_fichier(void)
{
int i,v,p;
double tab[10];
FILE *fichier;
fichier = fopen("fap","r");
fscanf(fichier,"%i \n ",&v); // version
fscanf(fichier,"%i \n ",&p); // paquet
if (fichier != NULL)
{
for(i=0;i<2;i++)
{
fscanf(fichier,"%lf \n ",tab+i);
}
fclose(fichier);
for(i=0;i<2;i++) printf("%lf\n",tab[i]);
}
} |