Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 24, 2006, 4:39:32 PM (19 years ago)
Author:
stefalie
Message:

branches/water: textures works now, but its at the wrong place

File:
1 edited

Legend:

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

    r7796 r7814  
    3434    this->loadParams(root);
    3535
    36   //! HACK FIXME HACK FIXME HACK FIXME HACK FIXME
    3736  //! todo: rename texture to reflection texture
    3837  // set up refleciton texture
    39   //mat.setDiffuseMap(&this->texture, 0);
     38  // FIXME mat.setDiffuseMap(this->texture, 0); doesnt work,
    4039  mat.setDiffuseMap("pictures/dudvmap.bmp", GL_TEXTURE_2D, 0);
    41 /*  mat.setDiffuseMap("pictures/sky-replace.jpg", GL_TEXTURE_2D, 1);
    42   mat.setDiffuseMap("pictures/sky-replace.jpg", GL_TEXTURE_2D, 2);
    43   mat.setDiffuseMap("pictures/sky-replace.jpg", GL_TEXTURE_2D, 3);
    44   mat.setDiffuseMap("pictures/sky-replace.jpg", GL_TEXTURE_2D, 4);*/
    4540  // load refraction texture
    4641  //mat.setDiffuseMap(&this->refractionTexture, 1);
     
    7166  glTexImage2D(GL_TEXTURE_2D, 0, channels, this->textureSize, this->textureSize, 0, type, GL_UNSIGNED_INT, pTexture);
    7267
     68  //gluBuild2DMipmaps(GL_TEXTURE_2D, channels, this->textureSize, this->textureSize, type,  GL_UNSIGNED_INT, pTexture);
     69
    7370  // Set the texture quality
    7471  glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
     
    8077  delete [] pTexture;
    8178
    82   //  shader = new Shader( ResourceManager::getInstance()->getDataDir() + "/shaders/water.vert", ResourceManager::getInstance()->getDataDir() +"/shaders/mapped_water.frag");
     79
     80  //shader = new Shader( "/home/stefalie/svn/orxonox/data/trunk/shaders/water.vert", "/home/stefalie/svn/orxonox/data/trunk/shaders/mapped_water.frag");
     81  shader = new Shader( ResourceManager::getInstance()->getDataDir() + "/shaders/mapped_water.vert", ResourceManager::getInstance()->getDataDir() +"/shaders/mapped_water.frag");
    8382}
    8483
     
    101100  glTranslatef(0,this->waterHeight,0);
    102101
     102  //HACK
     103  glTranslatef(550,0,100);
    103104  //glEnable(GL_LIGHTING);
    104105
     
    111112  // HACK
    112113
    113   //glDisable(GL_BLEND);
     114  glDisable(GL_BLEND);
    114115  //glActiveTexture(GL_TEXTURE0);
    115116  //glBindTexture(GL_TEXTURE_2D, this->texture);
     
    118119  glBindTexture(GL_TEXTURE_2D, this->mat.getDiffuseTexture(0));
    119120
    120   // Shader init
     121
     122/*  // Shader init
    121123  //this->shader->activateShader();
    122124  GLint uniform;
     
    162164  uniform = glGetUniformLocationARB(shader->getProgram(), "cameraPos");
    163165  glUniform4fARB(uniform, vPosition.x, vPosition.y, vPosition.z, 1.0f);
    164 
     166*/
    165167  glBegin(GL_QUADS);
    166   glNormal3f(0,1,0);
    167   glMultiTexCoord2f(GL_TEXTURE0, 0,0);
    168   glMultiTexCoord2f(GL_TEXTURE1, 0,0);
    169   glMultiTexCoord2f(GL_TEXTURE2, 0,0);
    170   glMultiTexCoord2f(GL_TEXTURE3, 0,0);
    171   glMultiTexCoord2f(GL_TEXTURE4, 0,0);
    172   glVertex3f(0,0,0);
    173 
    174   glMultiTexCoord2f(GL_TEXTURE0, 1,0);
    175   glMultiTexCoord2f(GL_TEXTURE1, 1,0);
    176   glMultiTexCoord2f(GL_TEXTURE2, 1,0);
    177   glMultiTexCoord2f(GL_TEXTURE3, 1,0);
    178   glMultiTexCoord2f(GL_TEXTURE4, 1,0);
    179   glVertex3f(100,0,0);
    180 
    181   glMultiTexCoord2f(GL_TEXTURE0, 1,1);
    182   glMultiTexCoord2f(GL_TEXTURE1, 1,1);
    183   glMultiTexCoord2f(GL_TEXTURE2, 1,1);
    184   glMultiTexCoord2f(GL_TEXTURE3, 1,1);
    185   glMultiTexCoord2f(GL_TEXTURE4, 1,1);
    186   glVertex3f(100,0,-100);
    187 
    188   glMultiTexCoord2f(GL_TEXTURE0, 0,1);
    189   glMultiTexCoord2f(GL_TEXTURE1, 0,1);
    190   glMultiTexCoord2f(GL_TEXTURE2, 0,1);
    191   glMultiTexCoord2f(GL_TEXTURE3, 0,1);
    192   glMultiTexCoord2f(GL_TEXTURE4, 0,1);
    193   glVertex3f(0,0,-100);
     168  glNormal3f(0, 1, 0);
     169  glMultiTexCoord2f(GL_TEXTURE0, 0, 0);
     170  glMultiTexCoord2f(GL_TEXTURE1, 0, 0);
     171  glMultiTexCoord2f(GL_TEXTURE2, 0, 0);
     172  glMultiTexCoord2f(GL_TEXTURE3, 0, 0);
     173  glMultiTexCoord2f(GL_TEXTURE4, 0, 0);
     174  glVertex3f(-500, 0, 500);
     175
     176  glMultiTexCoord2f(GL_TEXTURE0, 1, 0);
     177  glMultiTexCoord2f(GL_TEXTURE1, 1, 0);
     178  glMultiTexCoord2f(GL_TEXTURE2, 1, 0);
     179  glMultiTexCoord2f(GL_TEXTURE3, 1, 0);
     180  glMultiTexCoord2f(GL_TEXTURE4, 1, 0);
     181  glVertex3f(500, 0, 500);
     182
     183  glMultiTexCoord2f(GL_TEXTURE0, 1, 1);
     184  glMultiTexCoord2f(GL_TEXTURE1, 1, 1);
     185  glMultiTexCoord2f(GL_TEXTURE2, 1, 1);
     186  glMultiTexCoord2f(GL_TEXTURE3, 1, 1);
     187  glMultiTexCoord2f(GL_TEXTURE4, 1, 1);
     188  glVertex3f(500, 0, -500);
     189
     190  glMultiTexCoord2f(GL_TEXTURE0, 0, 1);
     191  glMultiTexCoord2f(GL_TEXTURE1, 0, 1);
     192  glMultiTexCoord2f(GL_TEXTURE2, 0, 1);
     193  glMultiTexCoord2f(GL_TEXTURE3, 0, 1);
     194  glMultiTexCoord2f(GL_TEXTURE4, 0, 1);
     195  glVertex3f(-500, 0, -500);
    194196  glEnd();
    195197  //this->shader->deactivateShader();
     
    210212{
    211213  glPushAttrib(GL_VIEWPORT_BIT);
    212   //   glPushMatrix();
     214 
    213215
    214216  //glLoadIdentity();
    215217  glViewport(0,0, textureSize, textureSize);
    216218
    217 
     219  glPushMatrix();
    218220  // Clear the color and depth bits, reset the matrix and position our camera.
    219221
     
    227229  //{
    228230  // Translate the world, then flip it upside down
    229   //   glTranslatef(0.0f, waterHeight*2.0f, 0.0f);
    230   //  glScalef(1.0, -1.0, 1.0);
     231  glTranslatef(0.0f, this->waterHeight*2.0f, 0.0f);
     232  glScalef(1.0, -1.0, 1.0);
    231233
    232234  // Since the world is updside down we need to change the culling to FRONT
    233   //glCullFace(GL_FRONT);
     235  glCullFace(GL_FRONT);
    234236
    235237  // Set our plane equation and turn clipping on
    236   // double plane[4] = {0.0, 1.0, 0.0, -waterHeight};
    237   //   glEnable(GL_CLIP_PLANE0);
    238   // glClipPlane(GL_CLIP_PLANE0, plane);
     238  double plane[4] = {0.0, 1.0, 0.0, -waterHeight};
     239  //glEnable(GL_CLIP_PLANE0);
     240  //glClipPlane(GL_CLIP_PLANE0, plane);
    239241
    240242  // Render the world upside down and clipped (only render the top flipped).
     
    265267{
    266268//  glBindTexture(GL_TEXTURE_2D, texture.getTexture()); //is done by mat.select();
    267   glBindTexture(GL_TEXTURE_2D, this->mat.getDiffuseTexture(0));
     269  //glBindTexture(GL_TEXTURE_2D, this->mat.getDiffuseTexture(0));
    268270
    269271  //mat.setDiffuseMap(&texture, 0);
    270   // mat.select();
     272  mat.select();
    271273  glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, textureSize, textureSize);
    272 
     274  //glDisable(GL_CLIP_PLANE0);
     275
     276  glPopMatrix();
    273277
    274278  glPopAttrib();
    275   //   glPopMatrix();
     279 
    276280}
    277281
Note: See TracChangeset for help on using the changeset viewer.