' 
' Written by Paul Grunewald (aka Stormy)
' Date: 07.28.2006
' Mail: Paul.Grunewald@gmail.com
'
#include "inc/2d_opengl.bi"

' Festlegung der Konstanten, die für den Bildschirm wichtig sind
const scrnX = 640
const scrnY = 480
const depth = 32
const fullscreen = &h0           ' Vollbildmodus ( &h0 = aus, &h1 = an )
DIM AS INTEGER midX, midY
DIM AS INTEGER w = 64, h = 64, change
DIM AS SINGLE rot = 0, scal = 1
DIM AS GFXType texture

' Finde Mittelpunkt
midX = scrnX / 2
midY = scrnY / 2

' Initialisiere den Schirm
Init_ogl2D(scrnX, scrnY, depth, fullscreen)

glEnable GL_TEXTURE_2D					' Texturen erlauben.
load_texture ("resources/examples/eagle.tga", texture)	' Lade eine Textur
glBindTexture GL_TEXTURE_2D, texture.handle		' und aktiviere sie.

WindowTitle "[ Rotation & Scale ] scale factor: "_
             + STR$(scal) + " rotation degree: " + STR$(rot)

do
  glCls  
  glColor3f 1,1,1
       glTranslatef midX,midY,0
       glscalef scal, scal, 1 
       glrotatef rot, 0, 0, 1       
	glBegin GL_QUADS
		glTexCoord2f 0.0, 0.0 ' links unten
		glVertex2i   -w/2, h/2
		glTexCoord2f 1.0, 0.0 ' rechts unten
		glVertex2i   w/2, h/2
		glTexCoord2f 1.0, 1.0 ' rechts oben
		glVertex2i   w/2, -h/2
		glTexCoord2f 0.0, 1.0 ' links oben
		glVertex2i   -w/2, -h/2
	glEnd
     glLoadIdentity
  
  glFlush 
  flip 
  screensync
  change = 0
  IF MULTIKEY(SC_UP) THEN scal+=.05: change = 1
  IF MULTIKEY(SC_DOWN) THEN scal-=.05: change = 1: IF scal <= .1 THEN scal=.05  

  IF MULTIKEY(SC_RIGHT) THEN rot+=5: change = 1
  IF MULTIKEY(SC_LEFT) THEN rot-=5: change = 1
  
  IF change = 1 THEN 
   WindowTitle "[ Rotation & Scale ] scale factor: "_
                + STR$(scal) + " rotation degree: " + STR$(rot)
  END IF		
loop until multikey(SC_ESCAPE) ' Verlasse die Schleife sobald Escape gedrückt wird