keksson_1 done

This commit is contained in:
vedevdem 2018-12-03 21:41:31 +03:00
parent 636409281a
commit 3ac8a6653f
2 changed files with 37 additions and 15 deletions

BIN
testSDL/Lesson1/Hello Executable file

Binary file not shown.

View File

@ -2,6 +2,7 @@
#include <iostream> #include <iostream>
using namespace std; using namespace std;
int main() int main()
{ {
if (SDL_Init(SDL_INIT_EVERYTHING) != 0 ) if (SDL_Init(SDL_INIT_EVERYTHING) != 0 )
@ -21,5 +22,26 @@ int main()
cout << "Renderer error\n"; cout << "Renderer error\n";
return 1; return 1;
} }
SDL_Surface* pic = SDL_LoadBMP("./hello.bmp");
if (pic == nullptr)
{
cout << "pic load error\n";
return 1;
}
SDL_Texture* texture = SDL_CreateTextureFromSurface(renderer, pic);
SDL_FreeSurface(pic);
if (texture == nullptr)
{
cout << "texture create error\n";
return 1;
}
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, texture, NULL, NULL);
SDL_RenderPresent(renderer);
SDL_Delay(3000);
SDL_DestroyRenderer(renderer);
SDL_DestroyTexture(texture);
SDL_DestroyWindow(window);
SDL_Quit;
return 0;
} }