#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#include "glut.h"
#include "gl.h"


typedef struct {
  float x;
  float y;
  float z;
} TOCKA;


TOCKA     t[4]= { {-0.5,-0.5, 0.0},
                  { 0.5,-0.5, 0.0},
                  { 0.5, 0.5, 0.0},
                  {-0.5, 0.5, 0.0} };

TOCKA n = { 0.0, 0.0, 1.0};

/* ===================================== */
void pretvori_geom_model_v_GL_gradnike()
{
  glColor3f(1.0, 0.5, 1.0);

  glBegin(GL_QUADS);
    glNormal3f(n.x, n.y, n.z);
    glVertex3f(t[0].x, t[0].y, t[0].z);
    glVertex3f(t[1].x, t[1].y, t[1].z);
    glVertex3f(t[2].x, t[2].y, t[2].z);
    glVertex3f(t[3].x, t[3].y, t[3].z);
  glEnd();
}
/* ===================================== */
void risi()
{
  glClear(GL_COLOR_BUFFER_BIT);

  glLoadIdentity();
  glScalef(0.9, 0.9, 0.9);
  glRotatef(-30.0, 1.0, 0.0, 0.0);
  glRotatef( 30.0, 0.0, 1.0, 0.0);

  pretvori_geom_model_v_GL_gradnike();

  glFlush();
}
/* ===================================== */
void inicializiraj_gl()
{
  glEnable(GL_LIGHTING);
  glEnable(GL_LIGHT0);
  glEnable(GL_COLOR_MATERIAL);
}
/* ===================================== */
int main(int argn, char **argc)
{
  glutInit(&argn, argc);
  glutInitWindowSize(500, 500);
  glutInitDisplayMode(GLUT_SINGLE);
  glutCreateWindow("risi_kvadrat_rotiran");

  inicializiraj_gl();

  glutDisplayFunc (risi);

  glutMainLoop();

  return 0;
}
