+/* Resizeable window. c89
+ * Very heavily based off of the "letterbox" example */
+#include "game.h"
+
+int setupWindow(RenderTexture2D *tar)
+{
+ SetConfigFlags(FLAG_WINDOW_RESIZABLE | FLAG_VSYNC_HINT);
+ InitWindow(RENDERWIDTH, RENDERHEIGHT, WINDOWTITLE);
+ SetTargetFPS(FPS);
+
+ *tar = LoadRenderTexture(RENDERWIDTH, RENDERHEIGHT);
+
+ return 0;
+}
+
+const Vector2 origin = {0, 0};
+
+int drawTexture(RenderTexture2D *tar)
+{
+ Rectangle srcrec, dstrec;
+ float scale;
+
+ ClearBackground(BLACK);
+
+ scale = MIN((float)GetScreenWidth()/RENDERWIDTH,
+ (float)GetScreenHeight()/RENDERHEIGHT);
+ printf("%f\n", scale);
+
+ srcrec.x = 0.0f;
+ srcrec.y = 0.0f;
+ srcrec.width = tar->texture.width;
+ srcrec.height = -tar->texture.height;
+
+ dstrec.x = (GetScreenWidth() - RENDERWIDTH*scale)*0.5f;
+ dstrec.y = (GetScreenHeight() - RENDERHEIGHT*scale)*0.5f;
+ dstrec.width = RENDERWIDTH*scale;
+ dstrec.height = RENDERHEIGHT*scale;
+
+ DrawTexturePro(
+ tar->texture,
+ srcrec,
+ dstrec,
+ origin,
+ 0.0f,
+ WHITE
+ );
+
+ return 0;
+}
+
+int closeWindow(RenderTexture2D *tar)
+{
+ UnloadRenderTexture(*tar);
+ return 0;
+}