Hi first sorry for my english im try to speak much better and im new on world of programming. If any person suggest me how to learn spaces with code i would apreciate. Now the problem im learning how to make games with SDL from an tutorial but i have a problem. I try to fail the code with a sdl or window or surface but can not print in screen the errors. instead of failing I can not see the error code with SDL_GetError()
and the window does not close.
Im using code::blocks and learning from here Tutorial Lazyfoo
Here the code can’t upload:
#include <SDL2/SDL.h>
#include <iostream>
using namespace std;
const int width=640,height=480;
int main(){
SDL_Window* window = NULL;
SDL_Surface* surface = NULL;
if(SDL_Init(SDL_INIT_VIDEO)<0){
cout<<"Can't start SDL .\nError: "<<SDL_GetError()<<endl;
}else{
window = SDL_CreateWindow("Game Window",SDL_WINDOWPOS_UNDEFINED,SDL_WINDOWPOS_UNDEFINED,height,width,SDL_WINDOW_SHOWN);
if(window == NULL){
cout<<"Can't start Window.\nError: "<<SDL_GetError()<<endl;
}else{
surface = SDL_GetWindowSurface(surface);
SDL_FillRect(surface,NULL,SDL_MapRGB( surface->format,0xFF,0xFF,0xFF) );
SDL_UpdateWindowSurface(window);
SDL_Delay(2000);
}
SDL_DestroyWindow(window);
SDL_Quit();
}
return 0;
}