Salut
je suis en train de m'amuser à créer des fenetres avec des rectangles sans l'aide de tuto, mais la je seche voila ce que j'ai fait:
#include <stdlib.h>
#include <stdio.h>
#include <SDL/SDL.h>
int main(int argc, char *argv[])
{
SDL_Surface *ecran = NULL, *rectangle[3] = {NULL};
SDL_Rect positionRectangle[3];
SDL_Event event;
int continuer = 1, i = 0;
positionRectangle[0].x = (600/2) - (220/2);
positionRectangle[0].y = (300/2) - (100/2);
positionRectangle[1].x = (600/2) - (110/2);
positionRectangle[1].y = (300/2) - (100/2);
positionRectangle[2].x = (600/2) - (110/2);
positionRectangle[2].y = (300/2) - (100/2);
positionRectangle[3].x = (600/2) - (110/2);
positionRectangle[3].y = (300/2) - (50/2);
SDL_Init(SDL_INIT_VIDEO);
SDL_WM_SetCaption("titre fenetre", NULL);
ecran = SDL_SetVideoMode(600, 300, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
rectangle[0] = SDL_CreateRGBSurface(SDL_HWSURFACE, 220, 100, 32, 0, 0, 0, 0);
rectangle[1] = SDL_CreateRGBSurface(SDL_HWSURFACE, 110, 100, 32, 0, 0, 0, 0);
rectangle[2] = SDL_CreateRGBSurface(SDL_HWSURFACE, 110, 100, 32, 0, 0, 0, 0);
rectangle[3] = SDL_CreateRGBSurface(SDL_HWSURFACE, 110, 50, 32, 0, 0, 0, 0);
for ( i = 0; i <= 3; i++)
{
SDL_FillRect(rectangle[i], NULL,SDL_MapRGB(ecran->format, 255, 200, 255));
SDL_BlitSurface(rectangle[i], NULL, ecran, &positionRectangle[i]);
}
SDL_Flip(ecran);
while (continuer)
{
SDL_WaitEvent(&event);
switch(event.type)
{
case SDL_QUIT:
continuer = 0;
break;
}
}
SDL_FreeSurface(ecran);
for (i = 0; i <= 3; i++)
{
SDL_FreeSurface(rectangle[i]);
}
SDL_Quit();
return EXIT_SUCCESS;
}
les 2 problèmes sont:
- Ca affiche seulement un rectangle
-Quand je quitte le programme avec la croix rouge j'ai cette erreur:
Run-Time Check Failure #2 - Stack arround the variable 'rectangle' was corrupted.
Est-ce que quelqu'un pourrait me dire ou est l'erreur dans mon code
Mici