- Timestamp:
- Dec 7, 2006, 7:02:27 PM (18 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/shader.cc
r9942 r10034 75 75 76 76 Shader::Shader() 77 : data( new ShaderData)77 : data(NULL) 78 78 { 79 79 -
trunk/src/world_entities/environments/mapped_water.cc
r9882 r10034 52 52 this->registerObject(this, MappedWater::_objectList); 53 53 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; 54 62 55 63 /// sets start values and parameters … … 78 86 MappedWater::~MappedWater() 79 87 { 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; 87 108 } 88 109 … … 164 185 void MappedWater::initShaders() 165 186 { 187 if ( !Shader::isSupported() ) 188 { 189 return; 190 } 191 166 192 // load shader files 167 193 shader = ResourceShader( "shaders/mapped_water.vert", "shaders/mapped_water.frag"); … … 225 251 void MappedWater::resetWaterColor(float r, float g, float b) 226 252 { 253 if ( !Shader::isSupported() ) 254 { 255 return; 256 } 257 227 258 this->shader.activateShader(); 228 259 this->waterColor = Vector(r, g, b); … … 240 271 void MappedWater::resetShineSize(float shine) 241 272 { 273 if ( !Shader::isSupported() ) 274 { 275 return; 276 } 277 242 278 this->shader.activateShader(); 243 279 this->shineSize = shine; … … 255 291 void MappedWater::resetShineStrength(float strength) 256 292 { 293 if ( !Shader::isSupported() ) 294 { 295 return; 296 } 297 257 298 this->shader.activateShader(); 258 299 this->shineStrength = strength; … … 270 311 void MappedWater::resetReflStrength(float strength) 271 312 { 313 if ( !Shader::isSupported() ) 314 { 315 return; 316 } 317 272 318 this->shader.activateShader(); 273 319 this->reflStrength = strength; … … 285 331 void MappedWater::resetRefraction(float refraction) 286 332 { 333 if ( !Shader::isSupported() ) 334 { 335 return; 336 } 337 287 338 this->shader.activateShader(); 288 339 this->refraction = refraction; … … 302 353 void MappedWater::resetLightPos(float x, float y, float z) 303 354 { 355 if ( !Shader::isSupported() ) 356 { 357 return; 358 } 359 304 360 this->shader.activateShader(); 305 361 this->lightPos = Vector(x, y, z); … … 555 611 556 612 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 } 599 656 mat.unselect(); 600 657 -
trunk/src/world_entities/environments/mapped_water.h
r9869 r10034 33 33 template <class T> class tAnimation; 34 34 35 //TODO show some wather for people without shader support 35 36 class MappedWater : public WorldEntity 36 37 { -
trunk/src/world_entities/skydome.cc
r9869 r10034 106 106 glBindTexture(GL_TEXTURE_3D, texture); 107 107 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 } 129 131 glPopAttrib(); 130 132 } -
trunk/src/world_entities/weather_effects/cloud_effect.cc
r9869 r10034 121 121 this->skydome->setTexture(noise3DTexName); 122 122 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 } 136 139 } 137 140 … … 186 189 void CloudEffect::tick (float dt) { 187 190 188 if ( this->cloudActivate) {191 if ( this->cloudActivate && Shader::isSupported() ) { 189 192 190 193 this->offsetZ += 0.05 * dt * this->animationSpeed;
Note: See TracChangeset
for help on using the changeset viewer.