Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 24, 2006, 12:03:01 AM (18 years ago)
Author:
stefalie
Message:

branches/water: compiles, but the reflection texture bug isnt sovled yet; added a few things for the vert and frag shaders but nothing wants works the way its supposed to… and i feel frustrated, grr :-( … gn8

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/water/src/world_entities/environments/mapped_water.cc

    r7741 r7780  
    1717#include "util/loading/load_param.h"
    1818#include "util/loading/factory.h"
    19 #include "material.h"
     19
     20
    2021
    2122
     
    3233    this->loadParams(root);
    3334
    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");
    3957}
    4058
    4159MappedWater::~MappedWater()
    4260{
    43 
     61  delete shader;
    4462}
    4563
     
    5573{
    5674  glPushMatrix();
    57 
    58   /*
    59   glTranslatef (this->getAbsCoor ().x,
    60                 this->getAbsCoor ().y,
    61                 this->getAbsCoor ().z);
    62   */
    6375  glTranslatef(0,this->waterHeight,0);
    6476
     
    7890
    7991  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);
    80136
    81137  glBegin(GL_QUADS);
    82138    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);
    85144    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);
    88151    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);
    91158    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);
    94165    glVertex3f(0,0,-100);
    95166  glEnd();
     167  this->shader->deactivateShader();
    96168
    97169  glPopMatrix();
     
    165237void MappedWater::deactivateReflection()
    166238{
    167   //glBindTexture(GL_TEXTURE_2D, texture.getTexture());
     239  //glBindTexture(GL_TEXTURE_2D, texture.getTexture()); is done by mat.select();
    168240
    169241  //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);
    172245
    173246
Note: See TracChangeset for help on using the changeset viewer.