Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8034 in orxonox.OLD


Ignore:
Timestamp:
May 31, 2006, 4:19:33 PM (18 years ago)
Author:
stefalie
Message:

water: refraction doesnt work with reflection

Location:
branches/water/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/water/src/lib/graphics/importer/material.cc

    r8027 r8034  
    390390 * @param textureNumber select the texture unit that will be overwritten
    391391*/
    392 void Material::renderToTexture(unsigned int textureNumber, GLenum target, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height)
     392void Material::renderToTexture(unsigned int textureNumber, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
    393393{
    394394  glActiveTexture(Material::glTextureArbs[textureNumber]);
    395395  glEnable(GL_TEXTURE_2D);
    396396  glBindTexture(GL_TEXTURE_2D, this->textures[textureNumber].getTexture());
    397   glCopyTexSubImage2D(target, 0, xoffset, yoffset, 0, 0, width, height);
     397  glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
    398398}
    399399
  • branches/water/src/lib/graphics/importer/material.h

    r8027 r8034  
    5858    void setDiffuseMap(const std::string& dMap, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
    5959    void setSDLDiffuseMap(SDL_Surface *surface, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
    60     void renderToTexture(unsigned int textureNumber, GLenum target, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
     60    void renderToTexture(unsigned int textureNumber, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
    6161
    6262    void setAmbientMap(const std::string& aMap, GLenum target = GL_TEXTURE_2D);
  • branches/water/src/world_entities/environments/mapped_water.cc

    r8031 r8034  
    3939  /// loads the textures
    4040  // set up refleciton texture
    41   // FIXME mat.setDiffuseMap(this->texture, 0); doesnt work,
     41  //mat.setDiffuseMap(this->texture, 0);
    4242  mat.setDiffuseMap("pictures/dudvmap.bmp", GL_TEXTURE_2D, 0);
    4343  // load refraction texture
    44   //mat.setDiffuseMap("pictures/error_texture.png", GL_TEXTURE_2D, 1);
     44  mat.setDiffuseMap("pictures/error_texture.png", GL_TEXTURE_2D, 1);
    4545  // load normal map
    4646  //mat.setDiffuseMap("pictures/normalmap.bmp", GL_TEXTURE_2D, 2);
     
    6060  unsigned int* pTextureReflection = new unsigned int [this->textureSize * this->textureSize * channels];
    6161  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));
     62  unsigned int* pTextureRefraction = new unsigned int [this->textureSize * this->textureSize * channels];
     63  memset(pTextureRefraction, 0, this->textureSize * this->textureSize * channels * sizeof(unsigned int));
    6464  // Register the texture with OpenGL and bind it to the texture ID
    6565  mat.select();
     
    7272
    7373  //the same for the refraction
    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);
     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);
    7676
    7777  // Set the texture quality
     
    8383  // Since we stored the texture space with OpenGL, we can delete the image data
    8484  delete [] pTextureReflection;
    85   //delete [] pTextureRefraction;
     85  delete [] pTextureRefraction;
    8686
    8787
     
    149149  // The back left vertice for the water
    150150  glMultiTexCoord2f(GL_TEXTURE0, 0.0f, 0);//g_WaterUV);            // Reflection texture
    151   glMultiTexCoord2f(GL_TEXTURE1, 0.0f, refrUV - move);        // Refraction texture
     151  glMultiTexCoord2f(GL_TEXTURE1, 0.0f, 0);//refrUV - move);        // Refraction texture
    152152  glMultiTexCoord2f(GL_TEXTURE2, 0.0f, normalUV + move2);     // Normal map texture
    153153  glMultiTexCoord2f(GL_TEXTURE3, 0, 0);                       // DUDV map texture
     
    157157  // The front left vertice for the water
    158158  glMultiTexCoord2f(GL_TEXTURE0, 0.0f, 1);//0.0f);                  // Reflection texture
    159   glMultiTexCoord2f(GL_TEXTURE1, 0.0f, 0.0f - move);           // Refraction texture
     159  glMultiTexCoord2f(GL_TEXTURE1, 0.0f, 1);//0.0f - move);           // Refraction texture
    160160  glMultiTexCoord2f(GL_TEXTURE2, 0.0f, 0.0f + move2);          // Normal map texture
    161161  glMultiTexCoord2f(GL_TEXTURE3, 0, 0);                        // DUDV map texture
     
    165165  // The front right vertice for the water
    166166  glMultiTexCoord2f(GL_TEXTURE0, 1,1); //g_WaterUV, 0.0f);             // Reflection texture
    167   glMultiTexCoord2f(GL_TEXTURE1, refrUV, 0.0f - move);         // Refraction texture
     167  glMultiTexCoord2f(GL_TEXTURE1, 1,1);//refrUV, 0.0f - move);         // Refraction texture
    168168  glMultiTexCoord2f(GL_TEXTURE2, normalUV, 0.0f + move2);      // Normal map texture
    169169  glMultiTexCoord2f(GL_TEXTURE3, 0, 0);                        // DUDV map texture
     
    173173  // The back right vertice for the water
    174174  glMultiTexCoord2f(GL_TEXTURE0, 1,0);//g_WaterUV, g_WaterUV);        // Reflection texture
    175   glMultiTexCoord2f(GL_TEXTURE1, refrUV, refrUV - move);       // Refraction texture
     175  glMultiTexCoord2f(GL_TEXTURE1, 1,0);//refrUV, refrUV - move);       // Refraction texture
    176176  glMultiTexCoord2f(GL_TEXTURE2, normalUV, normalUV + move2);  // Normal map texture
    177177  glMultiTexCoord2f(GL_TEXTURE3, 0, 0);                        // DUDV map texture
     
    244244  mat.select();
    245245  //glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, textureSize, textureSize);
    246   //mat.renderToTexture(0, GL_TEXTURE_2D, 0, 0, textureSize, textureSize);
     246  mat.renderToTexture(0, GL_TEXTURE_2D, 0, 0, 0, 0, 0, textureSize, textureSize);
    247247
    248248  glPopMatrix();
     
    291291
    292292  mat.select();
    293   mat.renderToTexture(0, GL_TEXTURE_2D, 0, 0, textureSize, textureSize);
     293  mat.renderToTexture(1, GL_TEXTURE_2D, 0, 0, 0, 0, 0, textureSize, textureSize);
     294  //glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 0, 0, textureSize, textureSize, 0);
     295  //mat.renderToTexture(0, GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 0, textureSize, textureSize, 0);
    294296
    295297  // Bind the current scene to our refraction texture
Note: See TracChangeset for help on using the changeset viewer.