title: Right way to display an image using C++ with OpenGL
body: <p>(i've updated the code the new better one)</p>
  
  <p><a href="http://www.flickr.com/photos/pkerkm/8251188947/in/photostream" rel="nofollow">http://www.flickr.com/photos/pkerkm/8251188947/in/photostream</a>
  good directions</p>
  
  <p><a href="http://www.flickr.com/photos/pkerkm/8252258464/in/photostream" rel="nofollow">http://www.flickr.com/photos/pkerkm/8252258464/in/photostream</a>
  bad directions</p>
  
  <p>We are using SOIL library
  C++
  openGL</p>
  
  <p>We drew the symbols of N, S, W, E on one of the images we are displaying, because     we thought that the images are being flipped or displayed incorrectly. We were right, but not sure why and how to fix it. Our W is up, E is down, S is right and N is left. This means, that the symbol N is on the left side, as to where it should be on the up part.</p>
  
  <p>Here is the code where we generate the 3-dimmentional array and our pictures.</p>
  
  <pre><code>void genTex(){
  texture[0]=SOIL_load_OGL_texture // load an image file directly as a new OpenGL      texture 
      (
          "C:\\Users\\Pkerkm\\Documents\\Visual Studio 2010\\Projects\\files\\gameprojecgraphics\\bloodwall2.png",
          SOIL_LOAD_AUTO,
          SOIL_CREATE_NEW_ID,
          SOIL_FLAG_MIPMAPS | SOIL_FLAG_INVERT_Y | SOIL_FLAG_NTSC_SAFE_RGB | SOIL_FLAG_COMPRESS_TO_DXT
      );
  glBindTexture(GL_TEXTURE_2D, texture[0]);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
  //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 
  }
  
  void /*GraphicsEngine::*/generateMap(){
    int i, k, j;
    double coordinates[8][3];
    for(i=0; i&lt;MAPWIDTH; i++){
      for(j=0; j&lt;MAPHEIGHT; j++){
        for(k=0; k&lt;MAPDEPTH; k++){
      if(stage[i][j][k]==0){
        //do nothing
      }
      else if (stage[i][j][k]==1){
        getWallCoordinates(coordinates, i, j, k);
    if(j==0 || stage[i][j-1][k]==0){
          drawWall(coordinates[0],coordinates[1],coordinates[2],coordinates[3],true);
    }
        if(j&lt;MAPHEIGHT-1 &amp;&amp; stage[i][j+1][k]==0){drawWall(coordinates[7],coordinates[6],coordinates[5],coordinates[4],false);
    }
    if(i==0 || stage[i-1][j][k]==0){drawWall(coordinates[7],coordinates[4],coordinates[0],coordinates[3],false);
    }
    if(k==MAPDEPTH-1 || stage[i][j][k+1]==0){drawWall(coordinates[7],coordinates[3],coordinates[2],coordinates[6],false);
    }
    if(i==MAPWIDTH-1 || stage[i+1][j][k]==0){drawWall(coordinates[6],coordinates[2],coordinates[1],coordinates[5],false);
    }
    if(k==0 || stage[i][j][k-1]==0){drawWall(coordinates[5],coordinates[1],coordinates[0],coordinates[4],false);
   }
      }
     }
    }
   }
  } 
  void /*GraphicsEngine::*/drawWall(double a[3],double b[3], double c[3], double d[3], bool floor){
  //glColor3f(1.0,0.0,1.0);
  
  
  if(floor){
      glBindTexture(GL_TEXTURE_2D, texture[1]);
  }else{
      glBindTexture(GL_TEXTURE_2D, texture[0]);
  }
  //GLuint tex;
  //glGenTextures(1, &amp;tex);
  glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE,GL_MODULATE );
  glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
  //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
  
  //glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
  
  //glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
  
  //tex = LoadTexture("wallsprite.png");
  //glBindTexture(GL_TEXTURE_2D, tex);
  glEnable(GL_TEXTURE_2D);
  glBegin(GL_QUADS);
      //glNormal3f(0, 1, 0);
      glTexCoord2d(0.0,0.0);
      glVertex3dv(a);
      glTexCoord2d(-1.0,0.0);
      //glVertex3dv(b);
      glVertex3dv(d);
      glTexCoord2d(-1.0,-1.0);
      glVertex3dv(c);
      glTexCoord2d(0.0,-1.0);
      //glVertex3iv(d);
      glVertex3dv(b);
  glEnd();
  /*glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, -1.0, 0.0);
      glTexCoord2f(0.0, 1.0); glVertex3f(-2.0, 1.0, 0.0);
      glTexCoord2f(1.0, 1.0); glVertex3f(0.0, 1.0, 0.0);
      glTexCoord2f(1.0, 0.0); glVertex3f(0.0, -1.0, 0.0);*/
  glDisable( GL_TEXTURE_2D );
   }
  </code></pre>
  
  <p>}</p>
  
  <p>I am thinking the problem is in here, but not sure how to fix it</p>
  
  <pre><code>void /*GraphicsEngine::*/getWallCoordinates(double coordinates[8][3], double x, double y, double z){
  int i;
  for(i=0;i&lt;8; i++){
      if((i/4)&gt;=1){
          coordinates[i][1]=BLOCKHEIGHT*(y+1);
      }else{
          coordinates[i][1]=BLOCKHEIGHT*y;
      }
      if((i/2)%2==0){
          coordinates[i][2]=BLOCKDEPTH*z;
      }else{
          coordinates[i][2]=BLOCKDEPTH*(z+1);
      }
      if((i%4)%3==0){
          coordinates[i][0]=BLOCKWIDTH*x;
      }else{
          coordinates[i][0]=BLOCKWIDTH*(x+1);
      }
  }
  </code></pre>
  
  <p>}</p>