int SDL_RenderDrawLines(SDL_Renderer* renderer, const SDL_Point* points, int count)
renderer | レンダリングコンテキスト |
points | 直線の端点のSDL_Pointの配列 |
count | pointsの数. count-1本の直線が描かれる |
#include "SDL.h"
#define POINTS_COUNT 4
static SDL_Point points[POINTS_COUNT] = {
{320, 200},
{300, 240},
{340, 240},
{320, 200}
};
int main(int argc, char* argv[])
{
if (SDL_Init(SDL_INIT_VIDEO) == 0) {
SDL_Window* window = NULL;
SDL_Renderer* renderer = NULL;
if (SDL_CreateWindowAndRenderer(640, 480, 0, &window, &renderer) == 0) {
SDL_bool done = SDL_FALSE;
while (!done) {
SDL_Event event;
SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE);
SDL_RenderClear(renderer);
SDL_SetRenderDrawColor(renderer, 255, 255, 255, SDL_ALPHA_OPAQUE);
SDL_RenderDrawLines(renderer, points, POINTS_COUNT);
SDL_RenderPresent(renderer);
while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) {
done = SDL_TRUE;
}
}
}
}
if (renderer) {
SDL_DestroyRenderer(renderer);
}
if (window) {
SDL_DestroyWindow(window);
}
}
SDL_Quit();
return 0;
}
SDL 2.0.0以降