Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10034 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Dec 7, 2006, 7:02:27 PM (18 years ago)
Author:
rennerc
Message:

fix for segfault with ati r300 driver

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/shader.cc

    r9942 r10034  
    7575
    7676Shader::Shader()
    77   : data(new ShaderData)
     77  : data(NULL)
    7878{
    7979
  • trunk/src/world_entities/environments/mapped_water.cc

    r9882 r10034  
    5252  this->registerObject(this, MappedWater::_objectList);
    5353  this->toList(OM_ENVIRON);
     54 
     55  cam_uni = NULL;
     56  light_uni = NULL;
     57  color_uni = NULL;
     58  shineSize_uni = NULL;
     59  shineStrength_uni = NULL;
     60  reflStrength_uni = NULL;
     61  refr_uni = NULL;
    5462
    5563  /// sets start values and parameters
     
    7886MappedWater::~MappedWater()
    7987{
    80   delete cam_uni;
    81   delete color_uni;
    82   delete light_uni;
    83   delete shineSize_uni;
    84   delete shineStrength_uni;
    85   delete reflStrength_uni;
    86   delete refr_uni;
     88  if ( cam_uni )
     89    delete cam_uni;
     90 
     91  if ( color_uni )
     92    delete color_uni;
     93 
     94  if ( light_uni )
     95    delete light_uni;
     96 
     97  if ( shineSize_uni )
     98    delete shineSize_uni;
     99 
     100  if ( shineStrength_uni )
     101    delete shineStrength_uni;
     102 
     103  if ( reflStrength_uni )
     104    delete reflStrength_uni;
     105 
     106  if ( refr_uni )
     107    delete refr_uni;
    87108}
    88109
     
    164185void MappedWater::initShaders()
    165186{
     187  if ( !Shader::isSupported() )
     188  {
     189        return;
     190  }
     191       
    166192  // load shader files
    167193  shader = ResourceShader( "shaders/mapped_water.vert", "shaders/mapped_water.frag");
     
    225251void MappedWater::resetWaterColor(float r, float g, float b)
    226252{
     253  if ( !Shader::isSupported() )
     254  {
     255        return;
     256  }
     257 
    227258  this->shader.activateShader();
    228259  this->waterColor = Vector(r, g, b);
     
    240271void MappedWater::resetShineSize(float shine)
    241272{
     273  if ( !Shader::isSupported() )
     274  {
     275        return;
     276  }
     277 
    242278  this->shader.activateShader();
    243279  this->shineSize = shine;
     
    255291void MappedWater::resetShineStrength(float strength)
    256292{
     293  if ( !Shader::isSupported() )
     294  {
     295        return;
     296  }
     297 
    257298  this->shader.activateShader();
    258299  this->shineStrength = strength;
     
    270311void MappedWater::resetReflStrength(float strength)
    271312{
     313  if ( !Shader::isSupported() )
     314  {
     315        return;
     316  }
     317 
    272318  this->shader.activateShader();
    273319  this->reflStrength = strength;
     
    285331void MappedWater::resetRefraction(float refraction)
    286332{
     333  if ( !Shader::isSupported() )
     334  {
     335        return;
     336  }
     337 
    287338  this->shader.activateShader();
    288339  this->refraction = refraction;
     
    302353void MappedWater::resetLightPos(float x, float y, float z)
    303354{
     355  if ( !Shader::isSupported() )
     356  {
     357        return;
     358  }
     359 
    304360  this->shader.activateShader();
    305361  this->lightPos = Vector(x, y, z);
     
    555611
    556612  mat.select();
    557 
    558   this->shader.activateShader();
    559 
    560   // reset the camera uniform to the current cam position
    561   Vector pos = State::getCameraNode()->getAbsCoor();
    562   cam_uni->set(pos.x, pos.y, pos.z, 1.0f);
    563 
    564   glDisable(GL_BLEND);
    565 
    566   // TODO change texture coords, so water doesnt look distorted when xWidth != zWidth
    567   glBegin(GL_QUADS);
    568   // The back left vertice for the water
    569   glMultiTexCoord2f(GL_TEXTURE0, 0, waterUV);                   // Reflection texture
    570   glMultiTexCoord2f(GL_TEXTURE1, 0, waterUV - move);            // Refraction texture
    571   glMultiTexCoord2f(GL_TEXTURE2, 0, normalUV + move2);          // Normal map texture
    572   glMultiTexCoord2f(GL_TEXTURE3, 0, 0);                         // DUDV map texture
    573   glVertex3f(this->waterVerts[0], this->waterHeight, this->waterVerts[1]);
    574 
    575   // The front left vertice for the water
    576   glMultiTexCoord2f(GL_TEXTURE0, 0, 0);                         // Reflection texture
    577   glMultiTexCoord2f(GL_TEXTURE1, 0, -move);                     // Refraction texture
    578   glMultiTexCoord2f(GL_TEXTURE2, 0, move2);                     // Normal map texture
    579   glMultiTexCoord2f(GL_TEXTURE3, 0, 0);                         // DUDV map texture
    580   glVertex3f(this->waterVerts[2], this->waterHeight, this->waterVerts[3]);
    581 
    582   // The front right vertice for the water
    583   glMultiTexCoord2f(GL_TEXTURE0, waterUV, 0);                   // Reflection texture
    584   glMultiTexCoord2f(GL_TEXTURE1, waterUV, -move);               // Refraction texture
    585   glMultiTexCoord2f(GL_TEXTURE2, normalUV, move2);              // Normal map texture
    586   glMultiTexCoord2f(GL_TEXTURE3, 0, 0);                         // DUDV map texture
    587   glVertex3f(this->waterVerts[4], this->waterHeight, this->waterVerts[5]);
    588 
    589   // The back right vertice for the water
    590   glMultiTexCoord2f(GL_TEXTURE0, waterUV, waterUV);             // Reflection texture
    591   glMultiTexCoord2f(GL_TEXTURE1, waterUV, waterUV - move);      // Refraction texture
    592   glMultiTexCoord2f(GL_TEXTURE2, normalUV, normalUV + move2);   // Normal map texture
    593   glMultiTexCoord2f(GL_TEXTURE3, 0, 0);                         // DUDV map texture
    594   glVertex3f(this->waterVerts[6], this->waterHeight, this->waterVerts[7]);
    595   glEnd();
    596 
    597   this->shader.deactivateShader();
    598 
     613  if ( Shader::isSupported() )
     614  {
     615    this->shader.activateShader();
     616 
     617    // reset the camera uniform to the current cam position
     618    Vector pos = State::getCameraNode()->getAbsCoor();
     619    cam_uni->set(pos.x, pos.y, pos.z, 1.0f);
     620 
     621    glDisable(GL_BLEND);
     622 
     623    // TODO change texture coords, so water doesnt look distorted when xWidth != zWidth
     624    glBegin(GL_QUADS);
     625    // The back left vertice for the water
     626    glMultiTexCoord2f(GL_TEXTURE0, 0, waterUV);                   // Reflection texture
     627    glMultiTexCoord2f(GL_TEXTURE1, 0, waterUV - move);            // Refraction texture
     628    glMultiTexCoord2f(GL_TEXTURE2, 0, normalUV + move2);          // Normal map texture
     629    glMultiTexCoord2f(GL_TEXTURE3, 0, 0);                         // DUDV map texture
     630    glVertex3f(this->waterVerts[0], this->waterHeight, this->waterVerts[1]);
     631 
     632    // The front left vertice for the water
     633    glMultiTexCoord2f(GL_TEXTURE0, 0, 0);                         // Reflection texture
     634    glMultiTexCoord2f(GL_TEXTURE1, 0, -move);                     // Refraction texture
     635    glMultiTexCoord2f(GL_TEXTURE2, 0, move2);                     // Normal map texture
     636    glMultiTexCoord2f(GL_TEXTURE3, 0, 0);                         // DUDV map texture
     637    glVertex3f(this->waterVerts[2], this->waterHeight, this->waterVerts[3]);
     638 
     639    // The front right vertice for the water
     640    glMultiTexCoord2f(GL_TEXTURE0, waterUV, 0);                   // Reflection texture
     641    glMultiTexCoord2f(GL_TEXTURE1, waterUV, -move);               // Refraction texture
     642    glMultiTexCoord2f(GL_TEXTURE2, normalUV, move2);              // Normal map texture
     643    glMultiTexCoord2f(GL_TEXTURE3, 0, 0);                         // DUDV map texture
     644    glVertex3f(this->waterVerts[4], this->waterHeight, this->waterVerts[5]);
     645 
     646    // The back right vertice for the water
     647    glMultiTexCoord2f(GL_TEXTURE0, waterUV, waterUV);             // Reflection texture
     648    glMultiTexCoord2f(GL_TEXTURE1, waterUV, waterUV - move);      // Refraction texture
     649    glMultiTexCoord2f(GL_TEXTURE2, normalUV, normalUV + move2);   // Normal map texture
     650    glMultiTexCoord2f(GL_TEXTURE3, 0, 0);                         // DUDV map texture
     651    glVertex3f(this->waterVerts[6], this->waterHeight, this->waterVerts[7]);
     652    glEnd();
     653 
     654    this->shader.deactivateShader();
     655  }
    599656  mat.unselect();
    600657
  • trunk/src/world_entities/environments/mapped_water.h

    r9869 r10034  
    3333template <class T> class tAnimation;
    3434
     35//TODO show some wather for people without shader support
    3536class MappedWater : public WorldEntity
    3637{
  • trunk/src/world_entities/skydome.cc

    r9869 r10034  
    106106  glBindTexture(GL_TEXTURE_3D, texture);
    107107
    108   this->shader->activateShader();
    109 
    110   glPushMatrix();
    111   glTranslatef(0.0f,pRadius,0.0f);
    112 
    113   glBegin(GL_TRIANGLES);
    114   for (int i=0; i < numIndices; i++)
    115   {
    116     glColor3f(1.0f, 1.0f, 1.0f);
    117 
    118     glTexCoord2f(planeVertices[indices[i]].u, planeVertices[indices[i]].v);
    119     glVertex3f(planeVertices[indices[i]].x, planeVertices[indices[i]].y, planeVertices[indices[i]].z);
    120   }
    121   glEnd();
    122 
    123   WorldEntity::draw();
    124 
    125   glPopMatrix();
    126 
    127   this->shader->deactivateShader();
    128 
     108  if ( this->shader && Shader::isSupported() )
     109  {
     110    this->shader->activateShader();
     111 
     112    glPushMatrix();
     113    glTranslatef(0.0f,pRadius,0.0f);
     114 
     115    glBegin(GL_TRIANGLES);
     116    for (int i=0; i < numIndices; i++)
     117    {
     118      glColor3f(1.0f, 1.0f, 1.0f);
     119 
     120      glTexCoord2f(planeVertices[indices[i]].u, planeVertices[indices[i]].v);
     121      glVertex3f(planeVertices[indices[i]].x, planeVertices[indices[i]].y, planeVertices[indices[i]].z);
     122    }
     123    glEnd();
     124 
     125    WorldEntity::draw();
     126 
     127    glPopMatrix();
     128 
     129    this->shader->deactivateShader();
     130  }
    129131  glPopAttrib();
    130132}
  • trunk/src/world_entities/weather_effects/cloud_effect.cc

    r9869 r10034  
    121121    this->skydome->setTexture(noise3DTexName);
    122122
    123     this->shader = ResourceShader("/shaders/cloud.vert", "/shaders/cloud.frag");
    124 
    125     this->shader.activateShader();
    126 
    127     Shader::Uniform(shader, "Noise").set(0);
    128 
    129     this->offset = new Shader::Uniform(shader, "Offset");
    130     this->skycolor = new Shader::Uniform(shader, "SkyColor");
    131     this->cloudcolor = new Shader::Uniform(shader, "CloudColor");
    132 
    133     this->shader.deactivateShader();
    134 
    135     this->skydome->setShader(&shader);
     123    if ( Shader::isSupported() )
     124    {
     125      this->shader = ResourceShader("/shaders/cloud.vert", "/shaders/cloud.frag");
     126     
     127      this->shader.activateShader();
     128     
     129      Shader::Uniform(shader, "Noise").set(0);
     130     
     131      this->offset = new Shader::Uniform(shader, "Offset");
     132      this->skycolor = new Shader::Uniform(shader, "SkyColor");
     133      this->cloudcolor = new Shader::Uniform(shader, "CloudColor");
     134     
     135      this->shader.deactivateShader();
     136     
     137      this->skydome->setShader(&shader);
     138    }
    136139}
    137140
     
    186189void CloudEffect::tick (float dt) {
    187190
    188     if (this->cloudActivate) {
     191    if ( this->cloudActivate && Shader::isSupported() ) {
    189192
    190193        this->offsetZ += 0.05 * dt * this->animationSpeed;
Note: See TracChangeset for help on using the changeset viewer.