I was following the lazyfoo tutorial, and when I build the project, I got a black screen instead of white, though in sdl_fillrect we are specifying white color?
#include <SDL.h>
#include <stdio.h>
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;
int main(int argc, char* args[]) {
SDL_Window* window = NULL;
SDL_Surface* screenSurface = NULL;
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
printf("An error occured whilie initializing SDL! Error: %s\n", SDL_GetError());
}
else {
window = SDL_CreateWindow("Mytho's Game", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT,SDL_WINDOW_SHOWN);
if (window == NULL) {
printf("Window could'nt be created! Eroor: %s\n", SDL_GetError());
}
else {
screenSurface = SDL_GetWindowSurface(window);
SDL_FillRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format, 0xFF, 0xFF, 0xFF));
SDL_Event event;
bool quit = false;
while (!quit){
while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) {
quit = true;
}
}
}
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}
}
}