title: LWJGL Colors messed up when using textures + lower FPS when disabling texturing often
body: <p>I initially had a problem of messed up colors when using texturing but I managed to fix it (the problem was I wasn't disabling texturing when needed). After doing that, the colors changed but are still not the ones I'd wish to - white instead of pure blue (0,0,255) RGB.
  Here is the complete rendering method:</p>
  
  <pre><code>private void render() {
  
      GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer
      GL11.glLoadIdentity(); // Reset The View
  
      GL11.glRotatef(lookupdown, 1.0f, 0, 0);
      GL11.glRotatef(360.0f - yrot, 0, 1.0f, 0);
  
      GL11.glTranslatef(-xpos, 0, -zpos);
  
  
  
      /*                   RENDERING BLOCKS                      */
      for (Block block : lvLoader.currentLevel.blocks)
      {
          if (block.created)
          {
              if (block.texturePos != null)
              {
                  if (block.texturePos.pos != -1)
                  {
                      Texture txt = TextureManager.getInstance().blocks[block.texturePos.pos];
                      if (txt != null)
                      {
                          GL11.glEnable(GL11.GL_TEXTURE_2D);
                          GL11.glBindTexture(GL11.GL_TEXTURE_2D, txt.getTextureID());
                      }
                  }
              }
  
              GL11.glColor3ub(block.color.getRedByte(), block.color.getGreenByte(), block.color.getBlueByte());
              GL11.glBegin(GL11.GL_QUADS);
  
              for (int i = 0; i &lt; 6; i++)
              {
                  for (int j = 0; j &lt; 4; j++)
                  {
                      if (block.texturePos != null)
                      {
                          switch (j)
                          {
                              case 0:
                                  GL11.glTexCoord2f(1.0f, 1.0f);
                                  break;
                              case 1:
                                  GL11.glTexCoord2f(0.0f, 1.0f);
                                  break;
                              case 2:
                                  GL11.glTexCoord2f(0.0f, 0.0f);
                                  break;
                              case 3:
                                  GL11.glTexCoord2f(1.0f, 0.0f);
                                  break;
                              default:
                                  break;
                          }
                      }
  
                      GL11.glVertex3f(block.walls[i].vertices[j].x, block.walls[i].vertices[j].y, block.walls[i].vertices[j].z);
                  }
              }
  
  
  
              GL11.glEnd();
  
              //if (block.texturePos != null)
                  //if (block.texturePos.pos != -1)
                      GL11.glDisable(GL11.GL_TEXTURE_2D);
          }
      }
  
  
      /*                   RENDERING TILES                      */
      for (Tile tile : lvLoader.currentLevel.tiles)
      {
          if (tile.created)
          {
              if (tile.texturePos != null)
              {
                  GL11.glEnable(GL11.GL_TEXTURE_2D);
                  if (tile.texturePos.pos != -1)
                  {
                      Texture txt = TextureManager.getInstance().tiles[tile.texturePos.pos];
                      if (txt != null)
                      {
  
                          GL11.glBindTexture(GL11.GL_TEXTURE_2D, txt.getTextureID());
                      }
                  }
              }
  
              GL11.glBegin(GL11.GL_QUADS);
              GL11.glColor3ub(tile.color.getRedByte(), tile.color.getGreenByte(), tile.color.getBlueByte());
  
  
              for (int jj = 0; jj &lt; 4; jj++)
              {
                  if (tile.texturePos != null)
                  {
                      switch (jj)
                      {
                          case 0:
                              GL11.glTexCoord2f(1.0f, 1.0f);
                              break;
                          case 1:
                              GL11.glTexCoord2f(0.0f, 1.0f);
                              break;
                          case 2:
                              GL11.glTexCoord2f(0.0f, 0.0f);
                              break;
                          case 3:
                              GL11.glTexCoord2f(1.0f, 0.0f);
                              break;
                          default:
                              break;
                      }
                  } 
  
                  GL11.glVertex3f(tile.surface.vertices[jj].x, tile.surface.vertices[jj].y, tile.surface.vertices[jj].z);
              }
  
  
  
              GL11.glEnd();
  
              //if (tile.texturePos != null)
                  //if (tile.texturePos.pos != -1)
                      GL11.glDisable(GL11.GL_TEXTURE_2D);
          }
      }
  
  
      /*                   RENDERING ROOF                      */ 
      for (Tile rTile : lvLoader.currentLevel.roof)
      {
          if (rTile != null)
          {
              if (rTile.created)
              {
                  if (rTile.texturePos != null)
                  {
                      if (rTile.texturePos.pos != -1)
                      {
                          Texture txt = TextureManager.getInstance().tiles[rTile.texturePos.pos];
                          if (txt != null)
                          {
                              GL11.glEnable(GL11.GL_TEXTURE_2D);
                              GL11.glBindTexture(GL11.GL_TEXTURE_2D, txt.getTextureID());
                          }
                      }
                  }
  
                  GL11.glColor3ub(rTile.color.getRedByte(), rTile.color.getGreenByte(), rTile.color.getBlueByte());
                  GL11.glBegin(GL11.GL_QUADS);
  
                  for (int k = 0; k &lt; 4; k++)
                  {
                      if (rTile.texturePos != null)
                      {
                          switch (k)
                          {
                              case 0:
                                  GL11.glTexCoord2f(1.0f, 1.0f);
                                  break;
                              case 1:
                                  GL11.glTexCoord2f(0.0f, 1.0f);
                                  break;
                              case 2:
                                  GL11.glTexCoord2f(0.0f, 0.0f);
                                  break;
                              case 3:
                                  GL11.glTexCoord2f(1.0f, 0.0f);
                                  break;
                              default:
                                  break;
                          }
                      }
  
                      GL11.glVertex3f(rTile.surface.vertices[k].x, rTile.surface.vertices[k].y, rTile.surface.vertices[k].z);
                  }
  
                  GL11.glEnd();
  
                  //if (rTile.texturePos != null)
                      //if (rTile.texturePos.pos != -1)
                          GL11.glDisable(GL11.GL_TEXTURE_2D);
              }
          }
      }
  }
  </code></pre>
  
  <p>Problem occurs in the RENDERING TILES part. Those are without a texture (for now) and I want them to be just colored squares - red (for lava) and blue (for water). Colors are taken from a static var and are proper (I checked that by System.out.ln(tile.color.getRed()......  -  the output was 0,0,255). Here is the static var:</p>
  
  <pre><code>/* TILES */
  //ShallowWater
  public static ColorStruct V00255 = new ColorStruct(new Color(0, 0, 255), "Tile", "ShallowWater"); //Pure blue
  </code></pre>
  
  <p>The output looks like this: <a href="http://imageshack.us/photo/my-images/225/probvx.jpg/" rel="nofollow">Rendered scene</a></p>
  
  <p>The white fields are water - they're supposed to be blue!</p>
  
  <p>An additional problem is the FPS - as you can see on the screen, it's 41. Before adding the multiple glEnable and glDisables of textures in the rendering section, FPS were 60. Are those multiple enables and disables causing this and can it be avoided?</p>
  
  <p>I'm a complete newbie at openGL and this is also my first question here so please forgive me if I did something wrong.</p>