Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#include <iostream>
#include <SDL_image.h>
#include <SDL.h>
int main(int argc, char *argv[])
{
SDL_Surface* myImage = NULL;
SDL_Surface* imageWindow = NULL;
// Test if make sure SDL is initialised
if (SDL_Init(SDL_INIT_EVERYTHING) < 0)
{
std::cout << "SDL could not initialise: " << SDL_GetError() << std::endl;
}
SDL_Window *window = SDL_CreateWindow( "Title Screen", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 600, 400, SDL_WINDOW_SHOWN);
if(window == NULL)
{
std::cout << "Window failed to be created: " << SDL_GetError( ) << std::endl;
return 1;
}
if( !(IMG_Init(IMG_INIT_PNG) & IMG_INIT_PNG) )
{
std::cout << "Could not Initialise IMG: " << IMG_GetError( ) << std::endl;
return 1;
}
SDL_Event loadIMG;
myImage = IMG_Load(CaveArt.png);
while(1)
{
// While the window event is happening, it is checking to see if the user quits.
if(SDL_PollEvent(&loadIMG))
{
if(loadIMG.type == SDL_QUIT)
break;
}
//This is a drawing method
SDL_BlitSurface(myImage , NULL, imageWindow , NULL);
SDL_updateWindowSurface (window);
}
SDL_FreeSurface(myImage);
SDL_FreeSurface(imageWindow);
myImage = NULL;
imageWindow = NULL;
SDL_DestroyWindow(window);
return EXIT_SUCCESS;
}