Index: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am	(revision 5262)
+++ trunk/src/Makefile.am	(revision 5263)
@@ -31,6 +31,6 @@
                 lib/tinyxml/libtinyxml.a \
 		lib/shell/libORXshell.a \
-                $(GTK2_LIBS) $(GTHREAD_LIBS) $(CURL_LIBS)
-
+                $(GTK2_LIBS) $(GTHREAD_LIBS) $(CURL_LIBS) \
+                -lGLEW
 
 orxonox_SOURCES = orxonox.cc \
Index: trunk/src/Makefile.in
===================================================================
--- trunk/src/Makefile.in	(revision 5262)
+++ trunk/src/Makefile.in	(revision 5263)
@@ -292,5 +292,6 @@
                 lib/tinyxml/libtinyxml.a \
 		lib/shell/libORXshell.a \
-                $(GTK2_LIBS) $(GTHREAD_LIBS) $(CURL_LIBS)
+                $(GTK2_LIBS) $(GTHREAD_LIBS) $(CURL_LIBS) \
+                -lGLEW
 
 orxonox_SOURCES = orxonox.cc \
Index: trunk/src/defs/glincl.h
===================================================================
--- trunk/src/defs/glincl.h	(revision 5262)
+++ trunk/src/defs/glincl.h	(revision 5263)
@@ -2,5 +2,5 @@
   \file glincl.h
   \brief This file includes gl Headers.
-  
+
   no Class is defined here, but the opengl Headers
 */
@@ -10,7 +10,9 @@
 
 #ifndef __APPLE__
+#include <GL/glew.h>
 #include <GL/gl.h>
 #include <GL/glu.h>
 #else
+#include <OpenGL/glew.h>
 #include <OpenGL/gl.h>
 #include <OpenGL/glu.h>
Index: trunk/src/lib/graphics/graphics_engine.cc
===================================================================
--- trunk/src/lib/graphics/graphics_engine.cc	(revision 5262)
+++ trunk/src/lib/graphics/graphics_engine.cc	(revision 5263)
@@ -61,8 +61,4 @@
   this->hwVersion = NULL;
   this->hwExtensions = NULL;
-
-  Shader shader("test.txt");
-  shader.debug();
-  exit(-1);
 }
 
@@ -267,4 +263,20 @@
     for (unsigned int i = 0; i < this->hwExtensions->getCount(); i++)
       PRINT(4)("%d: %s\n", i, this->hwExtensions->getString(i));
+
+
+  // inizializing GLEW
+  GLenum err = glewInit();
+  if (GLEW_OK != err)
+  {
+    /* Problem: glewInit failed, something is seriously wrong. */
+    PRINTF(1)("%s\n", glewGetErrorString(err));
+  }
+  PRINTF(4)("Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
+
+  Shader* shader = new Shader("test.txt");
+  shader->debug();
+  delete shader;
+//  exit(-1);
+
 }
 
Index: trunk/src/lib/graphics/shader.cc
===================================================================
--- trunk/src/lib/graphics/shader.cc	(revision 5262)
+++ trunk/src/lib/graphics/shader.cc	(revision 5263)
@@ -18,4 +18,5 @@
 #include "shader.h"
 
+
 #include "array.h"
 #include "stdlibincl.h"
@@ -42,7 +43,12 @@
    this->fragmentShaderSource = NULL;
    this->vertexShaderSource = NULL;
+   this->fragmentShaderLengths = NULL;
+   this->vertexShaderLenghts = NULL;
    this->shaderProgram = 0;
    this->vertexShader = 0;
    this->fragmentShader = 0;
+
+   if (GLEW_ARB_shader_objects && GLEW_ARB_shading_language_100)
+     this->shaderProgram = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
 
    if (vertexShaderFile != NULL)
@@ -61,8 +67,6 @@
   this->deleteProgram(SHADER_VERTEX);
   this->deleteProgram(SHADER_FRAGMENT);
-  // DELETE THE PROGRAMS
-/*  this->shaderProgram = 0;
-  this->vertexShader = 0;
-  this->fragmentShader = 0;*/
+
+  glDeleteObjectARB(this->shaderProgram);
 }
 
@@ -82,4 +86,5 @@
   }
   Array<char*>* program = new Array<char*>;
+  Array<int>* lengths = new Array<int>;
   if (type == SHADER_VERTEX)
   {
@@ -87,4 +92,5 @@
     strcpy(this->vertexShaderFile, fileName);
     this->vertexShaderSource = program;
+    this->vertexShaderLenghts = lengths;
   }
   else
@@ -93,4 +99,5 @@
     strcpy(this->fragmentShaderFile, fileName);
     this->fragmentShaderSource = program;
+    this->fragmentShaderLengths = lengths;
   }
 
@@ -113,19 +120,32 @@
     }
     program->addEntry(addString);
-
-    printf(lineBuffer);
+    lengths->addEntry(strlen(addString));
   }
   fclose(stream);
 
   program->finalizeArray();
-
-
-//  this->shaderProgram = glCreateProgramObjectARB();
-  this->vertexShader =1;
+  lengths->finalizeArray();
+
+  if (type == SHADER_VERTEX && GLEW_ARB_vertex_shader)
+  {
+    this->vertexShader = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
+    glShaderSourceARB(this->vertexShader, program->getCount(), (const GLcharARB**)program->getArray(), lengths->getArray());
+    glCompileShaderARB(this->vertexShader);
+    glAttachObjectARB(this->shaderProgram, this->vertexShader);
+  }
+
+  if (type == SHADER_FRAGMENT && GLEW_ARB_fragment_shader)
+  {
+    this->fragmentShader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
+    glShaderSourceARB(this->fragmentShader, program->getCount(), (const GLcharARB**)program->getArray(), lengths->getArray());
+    glCompileShaderARB(this->fragmentShader);
+    glAttachObjectARB(this->shaderProgram, this->fragmentShader);
+  }
+  glLinkProgramARB(this->shaderProgram);
 }
 
 bool Shader::activateShader()
 {
-
+  glUseProgramObjectARB(this->shaderProgram);
 }
 
@@ -138,13 +158,21 @@
     deleteArray = this->vertexShaderSource;
     this->vertexShaderSource = NULL;
+    delete this->vertexShaderLenghts;
+    this->vertexShaderLenghts = NULL;
     delete[] this->vertexShaderFile;
     this->vertexShaderFile = NULL;
+    glDeleteObjectARB(this->vertexShader);
+    this->vertexShader = 0;
   }
   else if (type == SHADER_FRAGMENT)
   {
     deleteArray = this->fragmentShaderSource;
+    delete this->fragmentShaderLengths;
+    this->fragmentShaderLengths = NULL;
     this->fragmentShaderSource = NULL;
     delete[] this->fragmentShaderFile;
     this->fragmentShaderFile = NULL;
+    glDeleteObjectARB(this->fragmentShader);
+    this->fragmentShader = 0;
   }
   else
Index: trunk/src/lib/graphics/shader.h
===================================================================
--- trunk/src/lib/graphics/shader.h	(revision 5262)
+++ trunk/src/lib/graphics/shader.h	(revision 5263)
@@ -43,4 +43,6 @@
    Array<char*>*          fragmentShaderSource;
    Array<char*>*          vertexShaderSource;
+   Array<int>*            fragmentShaderLengths;
+   Array<int>*            vertexShaderLenghts;
    GLenum                 shaderProgram;
    GLenum                 vertexShader;
