Categories
Game Development

libSDL – Drawing a BMP Image

#include <iostream> #include <SDL.h> const int WIDTH = 640, HEIGHT = 360; int main(int argc, char* argv[]) { SDL_Surface* imageSurface = NULL; SDL_Surface* windowSurface = NULL; if (SDL_Init(SDL_INIT_EVERYTHING) < 0) { std::cout << “SDL could not initialize! SDL Error: ” << SDL_GetError() << std::endl; } SDL_Window* window = SDL_CreateWindow(“Hello SDL World”, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WIDTH, HEIGHT, SDL_WINDOW_ALLOW_HIGHDPI); windowSurface = SDL_GetWindowSurface(window); if
Read more…

Categories
Game Development

libSDL – Hello World

#include <iostream> #include <SDL.h> const int WIDTH = 800, HEIGHT = 600; int main(int argc, char* argv[]) { SDL_Init(SDL_INIT_EVERYTHING); SDL_Window* window = SDL_CreateWindow(“Hello SDL World”, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WIDTH, HEIGHT, SDL_WINDOW_ALLOW_HIGHDPI); // Check that the window was successfully created if (NULL == window) { // In the case that the window could not be made… std::cout << “Could not create window:
Read more…

Categories
Game Development

Simplest libSDL example

Simplest libSDL example

#include <iostream> #include <SDL.h> int main(int argc, char* argv[]) { if (SDL_Init(SDL_INIT_EVERYTHING) < 0) { std::cout << “SDL could not initialise! SDL Error: ” << SDL_GetError() << std::endl; } return EXIT_SUCCESS; }

See https://dangeorgiev.com/add-include-directories-and-libraries-to-visual-studio/

Read more…