1 minute ago, Green_Baron said:
Thank you I'll keep practicing ! I'm really motivated so I'll definitely keep going ?
Hey I have a "Invalid renderer" error whenever I try to run my program, I tried modifying several things but I can't make it work. It's different from the guide since I didn't learn the "std::string" thing so I tried to do it another way but I don't even know if this is because of that Can I have a little hint about what's wrong because I can't figure it out ? It's supposed to load my .bmp but there's just no way :
#include <stdio.h>
#include <stdlib.h>
#include <SDL2/SDL.h>
void pause();
int main(int arc, char **arv)
{
SDL_Window *win;
SDL_Renderer *rend;
SDL_Surface *bmp;
SDL_Texture *tex;
int i;
if(SDL_Init(SDL_INIT_VIDEO) == -1)
{
printf("Error during SDL initialization : %s\n", SDL_GetError());
exit(EXIT_FAILURE);
}
win = SDL_CreateWindow("Hello world!", 100, 100, 640, 480, SDL_WINDOW_SHOWN);
bmp = SDL_LoadBMP("lac_en_montagne.bmp");
if(bmp == NULL)
{
SDL_DestroyRenderer(rend);
SDL_DestroyWindow(win);
printf("Error during BMP : %s\n", SDL_GetError());
}
tex = SDL_CreateTextureFromSurface(rend, bmp);
SDL_FreeSurface(bmp);
if(tex == NULL)
{
SDL_DestroyRenderer(rend);
SDL_DestroyWindow(win);
printf("Error durin Tex to surf : %s\n", SDL_GetError());
}
while(i < 3)
{
SDL_RenderClear(rend);
SDL_RenderCopy(rend, tex, NULL, NULL);
SDL_RenderPresent(rend);
SDL_Delay(1000);
i++;
}
pause();
SDL_Quit();
}
void pause()
{
int continuer = 1;
SDL_Event event;
while(continuer)
{
SDL_WaitEvent(&event);
switch(event.type)
{
case SDL_QUIT:
continuer = 0;
}
}
}
Thank you again for everything guys you're the best !