keksson_1 done
This commit is contained in:
parent
636409281a
commit
3ac8a6653f
BIN
testSDL/Lesson1/Hello
Executable file
BIN
testSDL/Lesson1/Hello
Executable file
Binary file not shown.
@ -2,24 +2,46 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
if (SDL_Init(SDL_INIT_EVERYTHING) != 0 )
|
||||
{
|
||||
cout << "SDL_Init error\n";
|
||||
return 1;
|
||||
}
|
||||
{
|
||||
cout << "SDL_Init error\n";
|
||||
return 1;
|
||||
}
|
||||
SDL_Window* window = SDL_CreateWindow("Hello World!", 100, 100, 640, 480, SDL_WINDOW_SHOWN);
|
||||
if (window == nullptr)
|
||||
{
|
||||
cout << "Window create error\n";
|
||||
return 1;
|
||||
}
|
||||
if (window == nullptr)
|
||||
{
|
||||
cout << "Window create error\n";
|
||||
return 1;
|
||||
}
|
||||
SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED || SDL_RENDERER_PRESENTVSYNC);
|
||||
if (renderer == nullptr)
|
||||
{
|
||||
cout << "Renderer error\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (renderer == nullptr)
|
||||
{
|
||||
cout << "Renderer error\n";
|
||||
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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user