Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5263 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Sep 27, 2005, 12:33:05 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: using glew, and Shaders are now read

Location:
trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/Makefile.am

    r5261 r5263  
    3131                lib/tinyxml/libtinyxml.a \
    3232                lib/shell/libORXshell.a \
    33                 $(GTK2_LIBS) $(GTHREAD_LIBS) $(CURL_LIBS)
    34 
     33                $(GTK2_LIBS) $(GTHREAD_LIBS) $(CURL_LIBS) \
     34                -lGLEW
    3535
    3636orxonox_SOURCES = orxonox.cc \
  • trunk/src/Makefile.in

    r5261 r5263  
    292292                lib/tinyxml/libtinyxml.a \
    293293                lib/shell/libORXshell.a \
    294                 $(GTK2_LIBS) $(GTHREAD_LIBS) $(CURL_LIBS)
     294                $(GTK2_LIBS) $(GTHREAD_LIBS) $(CURL_LIBS) \
     295                -lGLEW
    295296
    296297orxonox_SOURCES = orxonox.cc \
  • trunk/src/defs/glincl.h

    r4381 r5263  
    22  \file glincl.h
    33  \brief This file includes gl Headers.
    4  
     4
    55  no Class is defined here, but the opengl Headers
    66*/
     
    1010
    1111#ifndef __APPLE__
     12#include <GL/glew.h>
    1213#include <GL/gl.h>
    1314#include <GL/glu.h>
    1415#else
     16#include <OpenGL/glew.h>
    1517#include <OpenGL/gl.h>
    1618#include <OpenGL/glu.h>
  • trunk/src/lib/graphics/graphics_engine.cc

    r5262 r5263  
    6161  this->hwVersion = NULL;
    6262  this->hwExtensions = NULL;
    63 
    64   Shader shader("test.txt");
    65   shader.debug();
    66   exit(-1);
    6763}
    6864
     
    267263    for (unsigned int i = 0; i < this->hwExtensions->getCount(); i++)
    268264      PRINT(4)("%d: %s\n", i, this->hwExtensions->getString(i));
     265
     266
     267  // inizializing GLEW
     268  GLenum err = glewInit();
     269  if (GLEW_OK != err)
     270  {
     271    /* Problem: glewInit failed, something is seriously wrong. */
     272    PRINTF(1)("%s\n", glewGetErrorString(err));
     273  }
     274  PRINTF(4)("Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
     275
     276  Shader* shader = new Shader("test.txt");
     277  shader->debug();
     278  delete shader;
     279//  exit(-1);
     280
    269281}
    270282
  • trunk/src/lib/graphics/shader.cc

    r5262 r5263  
    1818#include "shader.h"
    1919
     20
    2021#include "array.h"
    2122#include "stdlibincl.h"
     
    4243   this->fragmentShaderSource = NULL;
    4344   this->vertexShaderSource = NULL;
     45   this->fragmentShaderLengths = NULL;
     46   this->vertexShaderLenghts = NULL;
    4447   this->shaderProgram = 0;
    4548   this->vertexShader = 0;
    4649   this->fragmentShader = 0;
     50
     51   if (GLEW_ARB_shader_objects && GLEW_ARB_shading_language_100)
     52     this->shaderProgram = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
    4753
    4854   if (vertexShaderFile != NULL)
     
    6167  this->deleteProgram(SHADER_VERTEX);
    6268  this->deleteProgram(SHADER_FRAGMENT);
    63   // DELETE THE PROGRAMS
    64 /*  this->shaderProgram = 0;
    65   this->vertexShader = 0;
    66   this->fragmentShader = 0;*/
     69
     70  glDeleteObjectARB(this->shaderProgram);
    6771}
    6872
     
    8286  }
    8387  Array<char*>* program = new Array<char*>;
     88  Array<int>* lengths = new Array<int>;
    8489  if (type == SHADER_VERTEX)
    8590  {
     
    8792    strcpy(this->vertexShaderFile, fileName);
    8893    this->vertexShaderSource = program;
     94    this->vertexShaderLenghts = lengths;
    8995  }
    9096  else
     
    9399    strcpy(this->fragmentShaderFile, fileName);
    94100    this->fragmentShaderSource = program;
     101    this->fragmentShaderLengths = lengths;
    95102  }
    96103
     
    113120    }
    114121    program->addEntry(addString);
    115 
    116     printf(lineBuffer);
     122    lengths->addEntry(strlen(addString));
    117123  }
    118124  fclose(stream);
    119125
    120126  program->finalizeArray();
    121 
    122 
    123 //  this->shaderProgram = glCreateProgramObjectARB();
    124   this->vertexShader =1;
     127  lengths->finalizeArray();
     128
     129  if (type == SHADER_VERTEX && GLEW_ARB_vertex_shader)
     130  {
     131    this->vertexShader = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
     132    glShaderSourceARB(this->vertexShader, program->getCount(), (const GLcharARB**)program->getArray(), lengths->getArray());
     133    glCompileShaderARB(this->vertexShader);
     134    glAttachObjectARB(this->shaderProgram, this->vertexShader);
     135  }
     136
     137  if (type == SHADER_FRAGMENT && GLEW_ARB_fragment_shader)
     138  {
     139    this->fragmentShader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
     140    glShaderSourceARB(this->fragmentShader, program->getCount(), (const GLcharARB**)program->getArray(), lengths->getArray());
     141    glCompileShaderARB(this->fragmentShader);
     142    glAttachObjectARB(this->shaderProgram, this->fragmentShader);
     143  }
     144  glLinkProgramARB(this->shaderProgram);
    125145}
    126146
    127147bool Shader::activateShader()
    128148{
    129 
     149  glUseProgramObjectARB(this->shaderProgram);
    130150}
    131151
     
    138158    deleteArray = this->vertexShaderSource;
    139159    this->vertexShaderSource = NULL;
     160    delete this->vertexShaderLenghts;
     161    this->vertexShaderLenghts = NULL;
    140162    delete[] this->vertexShaderFile;
    141163    this->vertexShaderFile = NULL;
     164    glDeleteObjectARB(this->vertexShader);
     165    this->vertexShader = 0;
    142166  }
    143167  else if (type == SHADER_FRAGMENT)
    144168  {
    145169    deleteArray = this->fragmentShaderSource;
     170    delete this->fragmentShaderLengths;
     171    this->fragmentShaderLengths = NULL;
    146172    this->fragmentShaderSource = NULL;
    147173    delete[] this->fragmentShaderFile;
    148174    this->fragmentShaderFile = NULL;
     175    glDeleteObjectARB(this->fragmentShader);
     176    this->fragmentShader = 0;
    149177  }
    150178  else
  • trunk/src/lib/graphics/shader.h

    r5262 r5263  
    4343   Array<char*>*          fragmentShaderSource;
    4444   Array<char*>*          vertexShaderSource;
     45   Array<int>*            fragmentShaderLengths;
     46   Array<int>*            vertexShaderLenghts;
    4547   GLenum                 shaderProgram;
    4648   GLenum                 vertexShader;
Note: See TracChangeset for help on using the changeset viewer.