[7796] | 1 | /* |
---|
| 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
| 10 | |
---|
| 11 | ### File Specific: |
---|
| 12 | main-programmer: Stefan Lienard |
---|
| 13 | co-programmer: ... |
---|
| 14 | */ |
---|
| 15 | |
---|
| 16 | #include "mapped_water.h" |
---|
| 17 | #include "util/loading/load_param.h" |
---|
| 18 | #include "util/loading/factory.h" |
---|
| 19 | #include "util/loading/resource_manager.h" |
---|
[8037] | 20 | #include "state.h" |
---|
[7796] | 21 | |
---|
| 22 | |
---|
| 23 | |
---|
| 24 | |
---|
| 25 | CREATE_FACTORY(MappedWater, CL_MAPPED_WATER); |
---|
| 26 | |
---|
| 27 | |
---|
| 28 | MappedWater::MappedWater(const TiXmlElement* root) |
---|
| 29 | { |
---|
| 30 | this->setClassID(CL_MAPPED_WATER, "MappedWater"); |
---|
| 31 | this->toList(OM_ENVIRON); |
---|
| 32 | |
---|
| 33 | if (root != NULL) |
---|
| 34 | this->loadParams(root); |
---|
| 35 | |
---|
[8037] | 36 | PRINTF(0)("MaxTextureUnits: %i\n", Material::getMaxTextureUnits()); |
---|
| 37 | |
---|
| 38 | // TODO rename texture to reflection texture |
---|
| 39 | /// loads the textures |
---|
[7796] | 40 | // set up refleciton texture |
---|
[8037] | 41 | //mat.setDiffuseMap(this->texture, 0); |
---|
[8235] | 42 | mat.setDiffuseMap("pictures/refl.bmp", GL_TEXTURE_2D, 0); |
---|
[7796] | 43 | // load refraction texture |
---|
[8235] | 44 | mat.setDiffuseMap("pictures/refr.bmp", GL_TEXTURE_2D, 1); |
---|
[7796] | 45 | // load normal map |
---|
[8095] | 46 | mat.setDiffuseMap("pictures/normalmap.bmp", GL_TEXTURE_2D, 2); |
---|
[7796] | 47 | // load dudv map |
---|
[8095] | 48 | mat.setDiffuseMap("pictures/dudvmap.bmp", GL_TEXTURE_2D, 3); |
---|
[7796] | 49 | // set up depth texture |
---|
[8037] | 50 | //mat.setDiffuseMap("pictures/sky-replace.jpg", GL_TEXTURE_2D, 4); |
---|
[7796] | 51 | |
---|
| 52 | |
---|
| 53 | |
---|
| 54 | /// MAKE THE MAPPING TEXTURE. |
---|
[8037] | 55 | // THIS IS A HACK AND SHOULD BE IN TEXTURE SOMEWHERE |
---|
| 56 | // set the size of the refraction and reflection textures |
---|
[7796] | 57 | this->textureSize = 512; |
---|
[8090] | 58 | //unsigned int channels = 32; |
---|
| 59 | //GLenum type = GL_RGBA; |
---|
| 60 | //unsigned int* pTextureReflection = new unsigned int [this->textureSize * this->textureSize * channels]; |
---|
| 61 | //memset(pTextureReflection, 0, this->textureSize * this->textureSize * channels * sizeof(unsigned int)); |
---|
| 62 | //unsigned int* pTextureRefraction = new unsigned int [this->textureSize * this->textureSize * channels]; |
---|
| 63 | //memset(pTextureRefraction, 0, this->textureSize * this->textureSize * channels * sizeof(unsigned int)); |
---|
[7796] | 64 | // Register the texture with OpenGL and bind it to the texture ID |
---|
[8090] | 65 | //mat.select(); |
---|
| 66 | //glBindTexture(GL_TEXTURE_2D, this->mat.getDiffuseTexture(0)); |
---|
[7796] | 67 | |
---|
| 68 | // Create the texture and store it on the video card |
---|
[8090] | 69 | //glTexImage2D(GL_TEXTURE_2D, 0, channels, this->textureSize, this->textureSize, 0, type, GL_UNSIGNED_INT, pTextureReflection); |
---|
[7796] | 70 | |
---|
[8037] | 71 | //gluBuild2DMipmaps(GL_TEXTURE_2D, channels, this->textureSize, this->textureSize, type, GL_UNSIGNED_INT, pTexture); |
---|
| 72 | |
---|
| 73 | //the same for the refraction |
---|
[8090] | 74 | //glBindTexture(GL_TEXTURE_2D, this->mat.getDiffuseTexture(1)); |
---|
| 75 | //glTexImage2D(GL_TEXTURE_2D, 0, channels, this->textureSize, this->textureSize, 0, type, GL_UNSIGNED_INT, pTextureRefraction); |
---|
[8037] | 76 | |
---|
[8235] | 77 | unsigned int channels = 32; |
---|
| 78 | GLenum type = GL_RGBA; |
---|
| 79 | unsigned int* pTextureReflection = new unsigned int [this->textureSize * this->textureSize * channels]; |
---|
| 80 | memset(pTextureReflection, 0, this->textureSize * this->textureSize * channels * sizeof(unsigned int)); |
---|
[8241] | 81 | //mat.select(); |
---|
[8235] | 82 | glBindTexture(GL_TEXTURE_2D, this->mat.getDiffuseTexture(0)); |
---|
[8241] | 83 | glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); |
---|
| 84 | glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); |
---|
| 85 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
---|
| 86 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
---|
[8249] | 87 | glTexImage2D(GL_TEXTURE_2D, 0, channels, this->textureSize, this->textureSize, 0, type, GL_UNSIGNED_INT, pTextureReflection); |
---|
| 88 | |
---|
| 89 | |
---|
[8241] | 90 | unsigned int* pTextureRefraction = new unsigned int [this->textureSize * this->textureSize * channels]; |
---|
| 91 | memset(pTextureRefraction, 0, this->textureSize * this->textureSize * channels * sizeof(unsigned int)); |
---|
| 92 | glBindTexture(GL_TEXTURE_2D, this->mat.getDiffuseTexture(1)); |
---|
[7796] | 93 | glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); |
---|
| 94 | glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); |
---|
| 95 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
---|
| 96 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
---|
[8249] | 97 | glTexImage2D(GL_TEXTURE_2D, 0, channels, this->textureSize, this->textureSize, 0, type, GL_UNSIGNED_INT, pTextureRefraction); |
---|
[7796] | 98 | |
---|
[8249] | 99 | // Set the texture quality |
---|
| 100 | |
---|
| 101 | |
---|
[7796] | 102 | // Since we stored the texture space with OpenGL, we can delete the image data |
---|
[8090] | 103 | //delete [] pTextureReflection; |
---|
| 104 | //delete [] pTextureRefraction; |
---|
[7796] | 105 | |
---|
[8037] | 106 | |
---|
| 107 | /// initialization of the texture coords, speeds etc... |
---|
| 108 | this->move = 0.0f; |
---|
| 109 | this->g_WaterUV = 35.0f; |
---|
| 110 | this->kNormalMapScale = 0.25f; |
---|
| 111 | this->g_WaterFlow = 0.0015f; |
---|
| 112 | |
---|
| 113 | /// initialization of the shaders |
---|
| 114 | // load shader files |
---|
[8095] | 115 | shader = new Shader( ResourceManager::getInstance()->getDataDir() + "/shaders/mapped_water.vert", ResourceManager::getInstance()->getDataDir() +"/shaders/mapped_water.frag"); |
---|
[8037] | 116 | |
---|
| 117 | this->shader->activateShader(); |
---|
| 118 | // Set the variable "reflection" to correspond to the first texture unit |
---|
| 119 | Shader::Uniform(shader, "reflection").set(0); |
---|
| 120 | // Set the variable "refraction" to correspond to the second texture unit |
---|
| 121 | Shader::Uniform(shader, "refraction").set(1); |
---|
| 122 | // Set the variable "normalMap" to correspond to the third texture unit |
---|
| 123 | Shader::Uniform(shader, "normalMap").set(2); |
---|
| 124 | // Set the variable "dudvMap" to correspond to the fourth texture unit |
---|
| 125 | Shader::Uniform(shader, "dudvMap").set(3); |
---|
| 126 | // Set the variable "depthMap" to correspond to the fifth texture unit |
---|
[8095] | 127 | //Shader::Uniform(shader, "depthMap").set(4); |
---|
[8037] | 128 | // Give the variable "waterColor" a blue color |
---|
| 129 | Shader::Uniform(shader, "waterColor").set(0.1f, 0.2f, 0.4f, 1.0f); |
---|
| 130 | // Give the variable "lightPos" our hard coded light position |
---|
| 131 | Shader::Uniform(shader, "lightPos").set(lightPos.x, lightPos.y, lightPos.z, 1.0f); |
---|
| 132 | // uniform for the camera position |
---|
| 133 | cam_uni = new Shader::Uniform(shader, "cameraPos"); |
---|
| 134 | |
---|
[8095] | 135 | this->shader->deactivateShader(); |
---|
[7796] | 136 | } |
---|
| 137 | |
---|
| 138 | MappedWater::~MappedWater() |
---|
| 139 | { |
---|
| 140 | //delete shader; |
---|
[8037] | 141 | //delete cam_uni; |
---|
[7796] | 142 | } |
---|
| 143 | |
---|
| 144 | void MappedWater::loadParams(const TiXmlElement* root) |
---|
| 145 | { |
---|
| 146 | WorldEntity::loadParams(root); |
---|
| 147 | |
---|
| 148 | LoadParam(root, "waterHeight", this, MappedWater, setHeight); |
---|
[8037] | 149 | LoadParam(root, "lightPos", this, MappedWater, setLightPosition); |
---|
[7796] | 150 | } |
---|
| 151 | |
---|
| 152 | |
---|
| 153 | void MappedWater::draw() const |
---|
| 154 | { |
---|
| 155 | glPushMatrix(); |
---|
| 156 | glTranslatef(0,this->waterHeight,0); |
---|
| 157 | |
---|
[8037] | 158 | mat.unselect(); |
---|
[7796] | 159 | mat.select(); |
---|
| 160 | |
---|
[8095] | 161 | this->shader->activateShader(); |
---|
[7796] | 162 | |
---|
[8037] | 163 | // reset the camera uniform to the current cam position |
---|
| 164 | Vector pos = State::getCameraNode()->getAbsCoor(); |
---|
[8095] | 165 | cam_uni->set(pos.x, pos.y, pos.z, 1.0f); |
---|
[7796] | 166 | |
---|
[8037] | 167 | glBegin(GL_QUADS); |
---|
| 168 | // The back left vertice for the water |
---|
[8095] | 169 | // glMultiTexCoord2f(GL_TEXTURE0, 0.0f, 0);//g_WaterUV); // Reflection texture |
---|
| 170 | // glMultiTexCoord2f(GL_TEXTURE1, 0.0f, 0);//refrUV - move); // Refraction texture |
---|
| 171 | glMultiTexCoord2f(GL_TEXTURE0, 0.0f, g_WaterUV); // Reflection texture |
---|
| 172 | glMultiTexCoord2f(GL_TEXTURE1, 0.0f, refrUV - move); // Refraction texture |
---|
[8037] | 173 | glMultiTexCoord2f(GL_TEXTURE2, 0.0f, normalUV + move2); // Normal map texture |
---|
| 174 | glMultiTexCoord2f(GL_TEXTURE3, 0, 0); // DUDV map texture |
---|
| 175 | glMultiTexCoord2f(GL_TEXTURE4, 0, 0); // Depth texture |
---|
| 176 | glVertex3f(0.0f, waterHeight, 0.0f); |
---|
[7796] | 177 | |
---|
[8037] | 178 | // The front left vertice for the water |
---|
[8095] | 179 | // glMultiTexCoord2f(GL_TEXTURE0, 0.0f, 1);//0.0f); // Reflection texture |
---|
| 180 | // glMultiTexCoord2f(GL_TEXTURE1, 0.0f, 1);//0.0f - move); // Refraction texture |
---|
| 181 | glMultiTexCoord2f(GL_TEXTURE0, 0.0f, 0.0f); // Reflection texture |
---|
| 182 | glMultiTexCoord2f(GL_TEXTURE1, 0.0f, 0.0f - move); // Refraction texture |
---|
[8037] | 183 | glMultiTexCoord2f(GL_TEXTURE2, 0.0f, 0.0f + move2); // Normal map texture |
---|
| 184 | glMultiTexCoord2f(GL_TEXTURE3, 0, 0); // DUDV map texture |
---|
| 185 | glMultiTexCoord2f(GL_TEXTURE4, 0, 0); // Depth texture |
---|
| 186 | glVertex3f(0.0f, waterHeight, 1000.0f); |
---|
[7796] | 187 | |
---|
[8037] | 188 | // The front right vertice for the water |
---|
[8095] | 189 | // glMultiTexCoord2f(GL_TEXTURE0, 1,1); //g_WaterUV, 0.0f); // Reflection texture |
---|
| 190 | // glMultiTexCoord2f(GL_TEXTURE1, 1,1);//refrUV, 0.0f - move); // Refraction texture |
---|
| 191 | glMultiTexCoord2f(GL_TEXTURE0, g_WaterUV, 0.0f); // Reflection texture |
---|
| 192 | glMultiTexCoord2f(GL_TEXTURE1, refrUV, 0.0f - move); // Refraction texture |
---|
[8037] | 193 | glMultiTexCoord2f(GL_TEXTURE2, normalUV, 0.0f + move2); // Normal map texture |
---|
| 194 | glMultiTexCoord2f(GL_TEXTURE3, 0, 0); // DUDV map texture |
---|
| 195 | glMultiTexCoord2f(GL_TEXTURE4, 0, 0); // Depth texture |
---|
| 196 | glVertex3f(1000.0f, waterHeight, 1000.0f); |
---|
[7796] | 197 | |
---|
[8037] | 198 | // The back right vertice for the water |
---|
[8095] | 199 | // glMultiTexCoord2f(GL_TEXTURE0, 1,0);//g_WaterUV, g_WaterUV); // Reflection texture |
---|
| 200 | // glMultiTexCoord2f(GL_TEXTURE1, 1,0);//refrUV, refrUV - move); // Refraction texture |
---|
| 201 | glMultiTexCoord2f(GL_TEXTURE0, g_WaterUV, g_WaterUV); // Reflection texture |
---|
| 202 | glMultiTexCoord2f(GL_TEXTURE1, refrUV, refrUV - move); // Refraction texture |
---|
[8037] | 203 | glMultiTexCoord2f(GL_TEXTURE2, normalUV, normalUV + move2); // Normal map texture |
---|
| 204 | glMultiTexCoord2f(GL_TEXTURE3, 0, 0); // DUDV map texture |
---|
| 205 | glMultiTexCoord2f(GL_TEXTURE4, 0, 0); // Depth texture |
---|
| 206 | glVertex3f(1000.0f, waterHeight, 0.0f); |
---|
| 207 | glEnd(); |
---|
[7796] | 208 | |
---|
[8095] | 209 | this->shader->deactivateShader(); |
---|
[7796] | 210 | |
---|
[8037] | 211 | mat.unselect(); |
---|
[7796] | 212 | |
---|
| 213 | glPopMatrix(); |
---|
| 214 | } |
---|
| 215 | |
---|
| 216 | void MappedWater::tick(float dt) |
---|
| 217 | { |
---|
[8037] | 218 | // makes the water flow |
---|
| 219 | this->move += this->g_WaterFlow; |
---|
| 220 | this->move2 = this->move * this->kNormalMapScale; |
---|
| 221 | this->refrUV = this->g_WaterUV; |
---|
| 222 | this->normalUV = this->g_WaterUV * this->kNormalMapScale; |
---|
[7796] | 223 | } |
---|
| 224 | |
---|
| 225 | void MappedWater::setHeight(float height) |
---|
| 226 | { |
---|
| 227 | this->waterHeight = height; |
---|
| 228 | } |
---|
| 229 | |
---|
| 230 | void MappedWater::activateReflection() |
---|
| 231 | { |
---|
[8037] | 232 | // save viewport matrix and change the viewport size |
---|
[7796] | 233 | glPushAttrib(GL_VIEWPORT_BIT); |
---|
| 234 | glViewport(0,0, textureSize, textureSize); |
---|
| 235 | |
---|
[8089] | 236 | glMatrixMode(GL_MODELVIEW); |
---|
[8037] | 237 | glPushMatrix(); |
---|
[7796] | 238 | |
---|
| 239 | // If our camera is above the water we will render the scene flipped upside down. |
---|
| 240 | // In order to line up the reflection nicely with the world we have to translate |
---|
| 241 | // the world to the position of our reflected surface, multiplied by two. |
---|
[8249] | 242 | //glEnable(GL_CLIP_PLANE0); |
---|
[8037] | 243 | Vector pos = State::getCameraNode()->getAbsCoor(); |
---|
| 244 | if(pos.y > waterHeight) |
---|
| 245 | { |
---|
| 246 | // Translate the world, then flip it upside down |
---|
| 247 | glTranslatef(0.0f, waterHeight*2.0f, 0.0f); |
---|
| 248 | glScalef(1.0, -1.0, 1.0); |
---|
[7796] | 249 | |
---|
[8037] | 250 | // Since the world is updside down we need to change the culling to FRONT |
---|
[8249] | 251 | //glCullFace(GL_FRONT); |
---|
[7796] | 252 | |
---|
[8037] | 253 | // Set our plane equation and turn clipping on |
---|
| 254 | double plane[4] = {0.0, 1.0, 0.0, -waterHeight}; |
---|
[8249] | 255 | //glClipPlane(GL_CLIP_PLANE0, plane); |
---|
[8037] | 256 | } |
---|
| 257 | else |
---|
[7796] | 258 | { |
---|
[8037] | 259 | // If the camera is below the water we don't want to flip the world, |
---|
| 260 | // but just render it clipped so only the top is drawn. |
---|
| 261 | double plane[4] = {0.0, 1.0, 0.0, waterHeight}; |
---|
[8249] | 262 | //glClipPlane(GL_CLIP_PLANE0, plane); |
---|
[8037] | 263 | } |
---|
[7796] | 264 | } |
---|
| 265 | |
---|
| 266 | |
---|
| 267 | void MappedWater::deactivateReflection() |
---|
| 268 | { |
---|
[8249] | 269 | //glDisable(GL_CLIP_PLANE0); |
---|
| 270 | //glCullFace(GL_BACK); |
---|
[7796] | 271 | |
---|
[8249] | 272 | //mat.select(); |
---|
[8235] | 273 | /////glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, textureSize, textureSize); |
---|
| 274 | ///mat.renderToTexture(0, GL_TEXTURE_2D, 0, 0, 0, 0, 0, textureSize, textureSize); |
---|
| 275 | /// |
---|
[7796] | 276 | |
---|
[8235] | 277 | glBindTexture(GL_TEXTURE_2D, this->mat.getDiffuseTexture(0)); |
---|
| 278 | |
---|
| 279 | // Create the texture and store it on the video card |
---|
| 280 | glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, textureSize, textureSize); |
---|
[8249] | 281 | |
---|
| 282 | |
---|
[8037] | 283 | glPopMatrix(); |
---|
[7796] | 284 | glPopAttrib(); |
---|
| 285 | } |
---|
| 286 | |
---|
| 287 | void MappedWater::activateRefraction() |
---|
[8249] | 288 | { |
---|
| 289 | // save viewport matrix and change the viewport size |
---|
| 290 | glPushAttrib(GL_VIEWPORT_BIT); |
---|
| 291 | glViewport(0,0, textureSize, textureSize); |
---|
| 292 | |
---|
| 293 | glMatrixMode(GL_MODELVIEW); |
---|
| 294 | glPushMatrix(); |
---|
| 295 | |
---|
| 296 | // If our camera is above the water we will render the scene flipped upside down. |
---|
| 297 | // In order to line up the reflection nicely with the world we have to translate |
---|
| 298 | // the world to the position of our reflected surface, multiplied by two. |
---|
| 299 | //glEnable(GL_CLIP_PLANE0); |
---|
| 300 | Vector pos = State::getCameraNode()->getAbsCoor(); |
---|
| 301 | if(pos.y > waterHeight) |
---|
| 302 | { |
---|
| 303 | // Translate the world, then flip it upside down |
---|
| 304 | glTranslatef(0.0f, waterHeight*2.0f, 0.0f); |
---|
| 305 | glScalef(1.0, -1.0, 1.0); |
---|
| 306 | |
---|
| 307 | // Since the world is updside down we need to change the culling to FRONT |
---|
| 308 | //glCullFace(GL_FRONT); |
---|
| 309 | |
---|
| 310 | // Set our plane equation and turn clipping on |
---|
| 311 | double plane[4] = {0.0, 1.0, 0.0, -waterHeight}; |
---|
| 312 | //glClipPlane(GL_CLIP_PLANE0, plane); |
---|
| 313 | } |
---|
| 314 | else |
---|
| 315 | { |
---|
| 316 | // If the camera is below the water we don't want to flip the world, |
---|
| 317 | // but just render it clipped so only the top is drawn. |
---|
| 318 | double plane[4] = {0.0, 1.0, 0.0, waterHeight}; |
---|
| 319 | //glClipPlane(GL_CLIP_PLANE0, plane); |
---|
| 320 | } |
---|
| 321 | |
---|
| 322 | /* |
---|
[8037] | 323 | // To create the refraction and depth textures we do the same thing |
---|
| 324 | // we did for the reflection texture, except we don't need to turn |
---|
| 325 | // the world upside down. We want to find the depth of the water, |
---|
| 326 | // not the depth of the sky and above water terrain. |
---|
| 327 | |
---|
| 328 | // save viewport matrix and change the viewport size |
---|
| 329 | glPushAttrib(GL_VIEWPORT_BIT); |
---|
| 330 | glViewport(0,0, textureSize, textureSize); |
---|
| 331 | |
---|
[8089] | 332 | glMatrixMode(GL_MODELVIEW); |
---|
[8037] | 333 | glPushMatrix(); |
---|
| 334 | |
---|
| 335 | // If our camera is above the water we will render only the parts that |
---|
| 336 | // are under the water. If the camera is below the water we render |
---|
| 337 | // only the stuff above the water. Like the reflection texture, we |
---|
| 338 | // incorporate clipping planes to only render what we need. |
---|
| 339 | |
---|
| 340 | // If the camera is above water, render the data below the water |
---|
[8249] | 341 | glEnable(GL_CLIP_PLANE1); |
---|
[8037] | 342 | Vector pos = State::getCameraNode()->getAbsCoor(); |
---|
| 343 | if(pos.y > waterHeight) |
---|
| 344 | { |
---|
| 345 | double plane[4] = {0.0, -1.0, 0.0, waterHeight}; |
---|
| 346 | glClipPlane(GL_CLIP_PLANE0, plane); |
---|
[8249] | 347 | |
---|
[8037] | 348 | } |
---|
| 349 | // If the camera is below the water, only render the data above the water |
---|
| 350 | else |
---|
| 351 | { |
---|
| 352 | glCullFace(GL_FRONT); |
---|
| 353 | double plane[4] = {0.0, 1.0, 0.0, -waterHeight}; |
---|
| 354 | glClipPlane(GL_CLIP_PLANE0, plane); |
---|
| 355 | } |
---|
[8249] | 356 | PRINTF(0)("test");*/ |
---|
[7796] | 357 | } |
---|
| 358 | |
---|
| 359 | void MappedWater::deactivateRefraction() |
---|
| 360 | { |
---|
[8249] | 361 | //glDisable(GL_CLIP_PLANE0); |
---|
| 362 | //glCullFace(GL_BACK); |
---|
[8037] | 363 | |
---|
| 364 | |
---|
[8249] | 365 | glBindTexture(GL_TEXTURE_2D, this->mat.getDiffuseTexture(1)); |
---|
| 366 | |
---|
| 367 | // Create the texture and store it on the video card |
---|
| 368 | glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, textureSize, textureSize); |
---|
| 369 | |
---|
| 370 | glPopMatrix(); |
---|
| 371 | glPopAttrib(); |
---|
| 372 | |
---|
[8037] | 373 | // Bind the current scene to our refraction texture |
---|
| 374 | // glBindTexture(GL_TEXTURE_2D, g_Texture[REFRACTION_ID]); |
---|
| 375 | // glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, textureSize, textureSize); |
---|
| 376 | |
---|
| 377 | // Bind the current scene to our depth texture |
---|
| 378 | // glBindTexture(GL_TEXTURE_2D, g_Texture[DEPTH_ID]); |
---|
| 379 | // glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 0, 0, textureSize, textureSize, 0); |
---|
| 380 | |
---|
[7796] | 381 | } |
---|