#include "raylib.h"
#include "image_loading.h"
#include "main.h"

float screen_width = 1280;
float screen_height = 720;
float aspect_multiplier = 1.7777777777777777;

void render_to_screen(void)
{

	if (IsWindowResized())
	{
		screen_width = GetScreenWidth();
		screen_height = GetScreenHeight();
	}
	BeginDrawing();
	    ClearBackground(BLACK);

		if (screen_width > screen_height * aspect_multiplier)
		{
			DrawTexturePro(
			    renderTexture.texture,
			    (Rectangle){ 0,  0, 1280,-720},
			    (Rectangle){ (screen_width - (screen_height) * aspect_multiplier) / 2, 0, screen_height * aspect_multiplier, screen_height},
			    (Vector2){ 0, 0 },
			    0,
			    WHITE);		
		}
		else
		{
			DrawTexturePro(
				renderTexture.texture,
				(Rectangle){ 0, 0, 1280,-720},
				(Rectangle){ 0, ( screen_height - ( screen_width / aspect_multiplier )) / 2, screen_width, screen_width / aspect_multiplier},
				(Vector2){ 0, 0 },
				0,
				WHITE);
		}
	EndDrawing();	
}
