Bonsoir,
J'ai un probleme, voila je n'arrive pas a afficher une image dans ma fenetre, j'ai cree deux fonctions SDL dans mon fichier Game1.c,
Game1.c :
J'appelle ces fonctions qui sont sensees me simplifier la vie dans la fonction main.c
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 #include <stdio.h> #include <stdlib.h> #include <SDL/SDL.h> #include <SDL/SDL_image.h> int LoadContent (SDL_Surface* sf, char* str, SDL_Rect* pos, int x, int y) { (*pos).x = x; (*pos).y = y; sf = IMG_Load (str); return (0); } int Draw (SDL_Surface* sf1, SDL_Surface* sf2, SDL_Rect* pos) { SDL_BlitSurface (sf1, NULL, sf2, pos); SDL_Flip (sf2); SDL_FreeSurface (sf1); return (0); }
main.c :
Le probleme est que rien ne s'affiche, pourtant lorsque j'appelle les fonctions de bases SDL (cf. FONCTION EN COMMENTAIRE) sans passer par mes fonctions a moi, a savoir, LoadContent et Draw alors la tout fonctionne. Pourquoi ? Je n'en ai aucune idee.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 #include <stdio.h> #include <stdlib.h> #include <SDL/SDL.h> #include <SDL/SDL_image.h> #include "Game1.h" int main (int argc, char* argv[]) { // Textures // surfaces de base (0) SDL_Surface *ecran; int continuer; // surfaces (1) \ SDL_Surface* mario; // position (2) SDL_Rect* pos; SDL_Rect pos_mario; // evenement (3) SDL_Event event; // init ecran = NULL; mario = NULL; continuer = 1; pos = &pos_mario; SDL_Init (SDL_INIT_VIDEO); ecran = SDL_SetVideoMode (640, 480, 32, SDL_HWSURFACE); // boucle infini while (continuer) { SDL_WaitEvent (&event); switch (event.type) { case SDL_QUIT: continuer = 0; default:; break; } SDL_FillRect (ecran, NULL, SDL_MapRGB (ecran -> format, 255, 255, 255)); LoadContent (mario, "mario_bas.gif", pos, 0, 0); Draw (mario, ecran, pos); // FONCTION SDL EN COMMENTAIRE // mario = IMG_Load ("mario_bas.gif"); // SDL_BlitSurface (mario, NULL, ecran, &pos_mario); // SDL_Flip (ecran); } SDL_Quit (); return (EXIT_SUCCESS); }
Pourriez vous m'aider s'il vous plait.
Merci beaucoup.
Cordialement,
helpmeplzzz
Partager