int SDL_RenderDrawLine(SDL_Renderer* renderer, int x1, int y1, int x2, int y2)
renderer | レンダリングコンテキスト |
x1 | 始点のX座標 |
y1 | 始点のY座標 |
x2 | 終点のX座標 |
y2 | 終点のY座標 |
#include "SDL.h"
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_RenderDrawLine(renderer, 320, 200, 300, 240);
SDL_RenderDrawLine(renderer, 300, 240, 340, 240);
SDL_RenderDrawLine(renderer, 340, 240, 320, 200);
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以降