- Timestamp:
- May 24, 2006, 12:03:01 AM (19 years ago)
- Location:
- branches/water/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/water/src/lib/graphics/shader.h
r7221 r7780 47 47 inline static void restoreShader() { if (storedShader != NULL) storedShader->activateShader(); storedShader = NULL; }; 48 48 49 GLhandleARB getProgram() { return this->shaderProgram; } 50 GLhandleARB getVertexS() { return this->vertexShader; } 51 GLhandleARB getFragmentS() { return this->fragmentShader; } 49 52 50 53 void printError(GLhandleARB program); -
branches/water/src/story_entities/game_world.cc
r7741 r7780 476 476 // clear buffer 477 477 glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); 478 glLoadIdentity(); 478 479 479 480 const std::list<BaseObject*>* reflectedWaters; -
branches/water/src/world_entities/environments/mapped_water.cc
r7741 r7780 17 17 #include "util/loading/load_param.h" 18 18 #include "util/loading/factory.h" 19 #include "material.h" 19 20 20 21 21 22 … … 32 33 this->loadParams(root); 33 34 34 35 mat.setDiffuseMap(&this->texture, 0); 36 // Change the view port to be the size of the texture we will render to 37 // HACK 38 this->textureSize = 512; 35 //! HACK FIXME HACK FIXME HACK FIXME HACK FIXME 36 //! todo: rename texture to reflection texture 37 // set up refleciton texture 38 //mat.setDiffuseMap(&this->texture, 0); 39 mat.setDiffuseMap("pictures/dudvmap.bmp", GL_TEXTURE_2D, 0); 40 mat.setDiffuseMap("pictures/sky-replace.jpg", GL_TEXTURE_2D, 1); 41 mat.setDiffuseMap("pictures/sky-replace.jpg", GL_TEXTURE_2D, 2); 42 mat.setDiffuseMap("pictures/sky-replace.jpg", GL_TEXTURE_2D, 3); 43 mat.setDiffuseMap("pictures/sky-replace.jpg", GL_TEXTURE_2D, 4); 44 // load refraction texture 45 //mat.setDiffuseMap(&this->refractionTexture, 1); 46 // load normal map 47 //mat.setDiffuseMap("pictures/normalmap.bmp", GL_TEXTURE_2D, 2); 48 // load dudv map 49 //mat.setDiffuseMap("pictures/dudvmap.bmp", GL_TEXTURE_2D, 3); 50 // set up depth texture 51 //mat.setDiffuseMap(&this->depthTexture, 4); 52 53 // set the size of the refraction and reflection textures 54 this->textureSize = 512; 55 56 shader = new Shader("/home/lieni/orxonox/data/trunk/shaders/water.vert", "/home/lieni/orxonox/data/trunk/shaders/mapped_water.frag"); 39 57 } 40 58 41 59 MappedWater::~MappedWater() 42 60 { 43 61 delete shader; 44 62 } 45 63 … … 55 73 { 56 74 glPushMatrix(); 57 58 /*59 glTranslatef (this->getAbsCoor ().x,60 this->getAbsCoor ().y,61 this->getAbsCoor ().z);62 */63 75 glTranslatef(0,this->waterHeight,0); 64 76 … … 78 90 79 91 mat.select(); 92 // Shader init 93 this->shader->activateShader(); 94 GLint uniform; 95 96 // Set the variable "reflection" to correspond to the first texture unit 97 uniform = glGetUniformLocationARB(shader->getProgram(), "reflection"); 98 glUniform1iARB(uniform, 0); //second paramter is the texture unit 99 100 // Set the variable "refraction" to correspond to the second texture unit 101 //uniform = glGetUniformLocationARB(shader->getProgram(), "refraction"); 102 //glUniform1iARB(uniform, 0); 103 // FIXME glUniform1iARB(uniform, 1); 104 105 // Set the variable "normalMap" to correspond to the third texture unit 106 //uniform = glGetUniformLocationARB(shader->getProgram(), "normalMap"); 107 //glUniform1iARB(uniform, 2); 108 109 // Set the variable "dudvMap" to correspond to the fourth texture unit 110 uniform = glGetUniformLocationARB(shader->getProgram(), "dudvMap"); 111 glUniform1iARB(uniform, 3); 112 113 // Set the variable "depthMap" to correspond to the fifth texture unit 114 //uniform = glGetUniformLocationARB(shader->getProgram(), "depthMap"); 115 //glUniform1iARB(uniform, 4); 116 // FIXME we dont have a depthMap yet :-( 117 118 // Give the variable "waterColor" a blue color 119 uniform = glGetUniformLocationARB(shader->getProgram(), "waterColor"); 120 glUniform4fARB(uniform, 0.1f, 0.2f, 0.4f, 1.0f); 121 122 // FIXME set camera and light information 123 Vector lightPos(100.0f, 150.0f, 100.0f); 124 125 // Store the camera position in a variable 126 //CVector3 vPosition = g_Camera.Position(); 127 Vector vPosition(50.0f, 50.0f, 50.0f); 128 129 // Give the variable "lightPos" our hard coded light position 130 uniform = glGetUniformLocationARB(shader->getProgram(), "lightPos"); 131 glUniform4fARB(uniform, lightPos.x, lightPos.y, lightPos.z, 1.0f); 132 133 // Give the variable "cameraPos" our camera position 134 uniform = glGetUniformLocationARB(shader->getProgram(), "cameraPos"); 135 glUniform4fARB(uniform, vPosition.x, vPosition.y, vPosition.z, 1.0f); 80 136 81 137 glBegin(GL_QUADS); 82 138 glNormal3f(0,1,0); 83 glTexCoord2f(0,0); 84 //glMultiTexCoord2f(GL_TEXTURE1, 0,0); 139 glMultiTexCoord2f(GL_TEXTURE0, 0,0); 140 glMultiTexCoord2f(GL_TEXTURE1, 0,0); 141 glMultiTexCoord2f(GL_TEXTURE2, 0,0); 142 glMultiTexCoord2f(GL_TEXTURE3, 0,0); 143 glMultiTexCoord2f(GL_TEXTURE4, 0,0); 85 144 glVertex3f(0,0,0); 86 glTexCoord2f(1,0); 87 //glMultiTexCoord2f(GL_TEXTURE1, 1,0); 145 146 glMultiTexCoord2f(GL_TEXTURE0, 1,0); 147 glMultiTexCoord2f(GL_TEXTURE1, 1,0); 148 glMultiTexCoord2f(GL_TEXTURE2, 1,0); 149 glMultiTexCoord2f(GL_TEXTURE3, 1,0); 150 glMultiTexCoord2f(GL_TEXTURE4, 1,0); 88 151 glVertex3f(100,0,0); 89 glTexCoord2f(1,1); 90 //glMultiTexCoord2f(GL_TEXTURE1, 1,1); 152 153 glMultiTexCoord2f(GL_TEXTURE0, 1,1); 154 glMultiTexCoord2f(GL_TEXTURE1, 1,1); 155 glMultiTexCoord2f(GL_TEXTURE2, 1,1); 156 glMultiTexCoord2f(GL_TEXTURE3, 1,1); 157 glMultiTexCoord2f(GL_TEXTURE4, 1,1); 91 158 glVertex3f(100,0,-100); 92 glTexCoord2f(0,1); 93 //glMultiTexCoord2f(GL_TEXTURE1, 0,1); 159 160 glMultiTexCoord2f(GL_TEXTURE0, 0,1); 161 glMultiTexCoord2f(GL_TEXTURE1, 0,1); 162 glMultiTexCoord2f(GL_TEXTURE2, 0,1); 163 glMultiTexCoord2f(GL_TEXTURE3, 0,1); 164 glMultiTexCoord2f(GL_TEXTURE4, 0,1); 94 165 glVertex3f(0,0,-100); 95 166 glEnd(); 167 this->shader->deactivateShader(); 96 168 97 169 glPopMatrix(); … … 165 237 void MappedWater::deactivateReflection() 166 238 { 167 //glBindTexture(GL_TEXTURE_2D, texture.getTexture()); 239 //glBindTexture(GL_TEXTURE_2D, texture.getTexture()); is done by mat.select(); 168 240 169 241 //mat.setDiffuseMap(&texture, 0); 170 mat.select(); 171 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, textureSize, textureSize); 242 243 //mat.select(); 244 //glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, textureSize, textureSize); 172 245 173 246 -
branches/water/src/world_entities/environments/mapped_water.h
r7740 r7780 11 11 #include "material.h" 12 12 #include "texture.h" 13 13 #include "shader.h" 14 14 15 15 class MappedWater : public WorldEntity … … 39 39 Texture texture; 40 40 int textureSize; //!< size of the texture 41 Shader* shader; 41 42 42 43 };
Note: See TracChangeset
for help on using the changeset viewer.