#include <SDL3/SDL.h>
#if _WIN32 // PLATFORM_WINDOWS
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow) {
if (!SDL_Init(SDL_INIT_VIDEO)) {
//SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s", SDL_GetError());
MessageBoxA(0, SDL_GetError(), "Couldn't initialize SDL", MB_OK);
return 3;
}
SDL_Window* window;
SDL_Renderer* renderer;
if (!SDL_CreateWindowAndRenderer("SDL3 Draw a box with 4 lines", 640, 480, SDL_WINDOW_RESIZABLE, &window, &renderer)) {
//SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window and renderer: %s", SDL_GetError());
MessageBoxA(0, SDL_GetError(), "Couldn't create window and renderer", MB_OK);
return 3;
}
SDL_Event event;
while (1) {
SDL_PollEvent(&event);
if (event.type == SDL_EVENT_QUIT) {
break;
}
// set backround color
SDL_SetRenderDrawColor(renderer, 33, 33, 33, SDL_ALPHA_OPAQUE); // dark gray
SDL_RenderClear(renderer); // start with a blank dark gray canvas
// set lines colors
SDL_SetRenderDrawColor(renderer, 38, 203, 55, SDL_ALPHA_OPAQUE);
// bool SDLCALL SDL_RenderLine(SDL_Renderer *renderer, float x1, float y1, float x2, float y2);
// draw the box with lines, one at a time
SDL_RenderLine(renderer, 240, 156, 400, 156); // top line -
SDL_RenderLine(renderer, 240, 350, 400, 350); // bottom line -
SDL_RenderLine(renderer, 400, 156, 400, 350); // right line |
SDL_RenderLine(renderer, 240, 156, 240, 350); // left line |
SDL_RenderPresent(renderer); // put all on the screen
}
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}
#endif