' 
' 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 GFXType texture, background_texture

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

glEnable GL_TEXTURE_2D						' Texturen erlauben.
load_texture ("resources/examples/horse.tga", texture)		' Pferd
load_texture ("resources/examples/grass.tga", background_texture)' Hintergrund
glEnable GL_BLEND						' Blending erlauben

WindowTitle "[ Shadow ]"

DIM AS INTEGER x, y, bx, by
x = 150
y = 0

do
  glCls  
  
  ' Zeichne Untergrund
  
  FOR bx = 0 TO fix(scrnX / background_texture.width)
   FOR by = 0 TO fix(scrnY / background_texture.height)   
    PutTexture (background_texture,_
    bx * background_texture.width,_
    by * background_texture.height, 0)
   NEXT by 
  NEXT bx
  
  ' Schatten
  glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
  glColor4ub 0,0,0,128
  glBindTexture GL_TEXTURE_2D, texture.handle  
  DrawTexQuad (x+5, y+5, 2, texture.width, texture.height)
    
  glColor3ub 255,255,255  
  glBindTexture GL_TEXTURE_2D, texture.handle  
  DrawTexQuad (x, y, 3, texture.width, texture.height)
    
  'PutTexture (texture, x, y, 10) ' Figur
  
  IF MULTIKEY(SC_LEFT) THEN x-=1  
  IF MULTIKEY(SC_RIGHT) THEN x+=1
  IF MULTIKEY(SC_UP) THEN y-=1
  IF MULTIKEY(SC_DOWN) THEN y+=1
    
  glFlush 
  flip 
  screensync
loop until multikey(SC_ESCAPE) ' Verlasse die Schleife sobald Escape gedrückt wird
