#include <SDL/SDL.h>
#include <SDL/SDL_OpenGL.h>

#include "project_screen.h"
#include "project_init_gl.h"

SDL_Surface *screen;

int ScreenWidth;
int ScreenHeight;
int ScreenSize;

// ================
// ==== Screen ====
// ================

void InitScreen(bool fs)
{
	ScreenSize = ScreenWidth * ScreenHeight;

    SDL_Init(SDL_INIT_VIDEO);
    screen = SDL_SetVideoMode(ScreenWidth, ScreenHeight, 32, SDL_OPENGL | ((int)fs * SDL_FULLSCREEN));

    SDL_WM_SetCaption ("Test", 0);
    SDL_ShowCursor(SDL_DISABLE);
}

int GetSizeOfSquareWindow()
{
	int min = ScreenHeight;
	if (ScreenWidth < min) min = ScreenWidth;

	if (min<256)
		return 128;
	if (min<512)
		return 256;
	if (min<1024)
		return 512;
	else
		return 1024;
}

void DrawScreenQuad()
{
    glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
		glLoadIdentity();
		glMatrixMode(GL_PROJECTION);
		glPushMatrix();
			glLoadIdentity();
			glBegin(GL_QUADS);
				glTexCoord2f(0.0f, 0.0f); glVertex3f(-1, -1, -1);
				glTexCoord2f(1.0f, 0.0f); glVertex3f(1, -1, -1);
				glTexCoord2f(1.0f, 1.0f); glVertex3f(1, 1, -1);
				glTexCoord2f(0.0f, 1.0f); glVertex3f(-1, 1, -1);
			glEnd();
		glPopMatrix();
		glMatrixMode(GL_MODELVIEW);
	glPopMatrix();
}
