#define SDL_MAIN_USE_CALLBACKS 1 #include #include #include #include #include "globals.hpp" #include "math.hpp" #include "renderer/camera.hpp" #include "renderer/calls.hpp" static SDL_Window *window = NULL; static SDL_Renderer *renderer = NULL; DeltaVector2 temp1(125, 150), temp2(150, 120), temp3(100, 100); DeltaVector2 topleft, bottomright, p; SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[]) { SDL_SetAppMetadata("delta engine game", "0.0", "com.miletici.game"); if (!SDL_Init(SDL_INIT_VIDEO)) { SDL_Log("Couldn't initialize SDL: %s", SDL_GetError()); return SDL_APP_FAILURE; } if (!SDL_CreateWindowAndRenderer("game", SIMULATED_WIDTH, SIMULATED_HEIGHT, 0, &window, &renderer)) { SDL_Log("Couldn't create window/renderer: %s", SDL_GetError()); return SDL_APP_FAILURE; } SDL_SetRenderLogicalPresentation(renderer, 640, 480, SDL_LOGICAL_PRESENTATION_LETTERBOX); return SDL_APP_CONTINUE; /* carry on with the program! */ } SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event) { if (event->type == SDL_EVENT_QUIT) { return SDL_APP_SUCCESS; } return SDL_APP_CONTINUE; } SDL_AppResult SDL_AppIterate(void *appstate) { const double now = ((double)SDL_GetTicks()) / 1000.0; SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE_FLOAT); SDL_RenderClear(renderer); SDL_SetRenderDrawColor(renderer, 255, 0, 255, SDL_ALPHA_OPAQUE); rasterizeTriangle(renderer, temp1, temp2, temp3); SDL_RenderPresent(renderer); return SDL_APP_CONTINUE; } void SDL_AppQuit(void *appstate, SDL_AppResult result) { }