Učim se podle zdejších tutoriálů dělat s SDL, ale mam problém, nespouští se mi callback funkce Timer1(), ta má vykreslit vždycky posunutej obrázek (v tom problém neni). Nemoch by mi někdo pls poradit co s tim může bejt?
#include <SDL/SDL.h>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
SDL_Surface *screen;
SDL_Surface *image;
Uint32 left = 0;
Uint32 top = 0;
void LoadImages()
{
image = SDL_LoadBMP("image.bmp");
}
void DrawIMG(SDL_Surface *img, int x, int y)
{
SDL_Rect rect;
rect.x = x;
rect.y = y;
SDL_BlitSurface(img, NULL, screen, &rect);
}
//callback
Uint32 Timer1(Uint32 interval, void* param)
{
//MessageBox(NULL, NULL, NULL, NULL);
left += 100;
top += 100;
DrawIMG(image, left, top);
return interval;
}
SDL_TimerID timer1 = SDL_AddTimer(1000, Timer1, NULL); //časovač
int main(int argc, char *argv[])
{
if(SDL_Init(SDL_INIT_VIDEO) < 0){
printf("Inicializace SDL se nezdařila: %s", SDL_GetError());
exit(1);
}
atexit(SDL_Quit);
screen = SDL_SetVideoMode(800, 600, 32, SDL_HWSURFACE|SDL_DOUBLEBUF);
if (screen == NULL){
printf("Vytvoření okna se nezdařilo: %s", SDL_GetError());
exit(1);
}
LoadImages();
Uint32 flags = SDL_SWSURFACE;
SDL_Event event;
bool quit = false;
SDL_Surface * screen = NULL;
SDL_Init(SDL_INIT_VIDEO);
screen = SDL_SetVideoMode(700, 500, 32, flags);
SDL_Flip(screen);
while (quit == false)
{
SDL_WaitEvent(&event);
switch(event.type) {
case SDL_QUIT:
quit = true;
}
}
SDL_FreeSurface(screen);
SDL_Quit();
}