SDL_Renderer* SDL_CreateRenderer(SDL_Window* window, int index, Uint32 flags)
window | レンダリングを表示するウィンドウ |
index | 初期化するレンダリングドライバの番号. -1のとき要求のflagsに対応した最初のドライバを初期化する |
flags | 0または1つ以上のSDL_RendererFlagsの倫理和 |
#include "SDL.h"
int main(int argc, char *argv[])
{
SDL_Window *win = NULL;
SDL_Renderer *renderer = NULL;
SDL_Texture *bitmapTex = NULL;
SDL_Surface *bitmapSurface = NULL;
int posX = 100, posY = 100, width = 320, height = 240;
SDL_bool loopShouldStop = SDL_FALSE;
SDL_Init(SDL_INIT_VIDEO);
win = SDL_CreateWindow("Hello World", posX, posY, width, height, 0);
renderer = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED);
bitmapSurface = SDL_LoadBMP("img/hello.bmp");
bitmapTex = SDL_CreateTextureFromSurface(renderer, bitmapSurface);
SDL_FreeSurface(bitmapSurface);
while (!loopShouldStop)
{
SDL_Event event;
while (SDL_PollEvent(&event))
{
switch (event.type)
{
case SDL_QUIT:
loopShouldStop = SDL_TRUE;
break;
}
}
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, bitmapTex, NULL, NULL);
SDL_RenderPresent(renderer);
}
SDL_DestroyTexture(bitmapTex);
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(win);
SDL_Quit();
return 0;
}