Urgent LWJGL Issue! Texture laoding causing darkened quads.

Started by GenomeGame, May 17, 2013, 22:57:39

Previous topic - Next topic

GenomeGame

Hello members of the LWJGL forum,

I am new to workng with LWJGL, and i seem to be having a bit of an issue with lwjgl 2.9.0 and slick-util: I bind a texture with click-util, and draw it on a quad with openGL. However, when i go to draw a quad without entering the texcoord2d functions, which should, to my knowledge, not call upon a texture, by colored quad gets displayed darkened, as if there were a half-opaque black quad on top of it. Here is my code for rendering a simple gui (ignore the wierd setup, just look at the GL11.something code):

NOTE: I think i have to do something to "unbind" the texture, but I don't know if there is a command like that.

package gui;

import org.lwjgl.opengl.*;

import core.Genome;

public class GUIMainMenu extends GUI {
   
   int counter;
   
   public GUIMainMenu(int arg0, int arg1, int arg2, int arg3) {
     
      super(arg0, arg1, arg2, arg3);
     
   }
   
   public void tick() throws Exception {
     
      if (counter < 1000) {
         
         counter ++;
         
      }
     
      GL11.glColor3d(0, 0, 1);
     
      GL11.glBegin(GL11.GL_QUADS);
     
      GL11.glVertex2f(0, 0);
     
      GL11.glVertex2f(w, 0);
     
      GL11.glVertex2f(w, h);
     
      GL11.glVertex2f(0, h);
     
      GL11.glEnd();
     
      if (Genome.instance.tick.ticks % 10 <= 5) {
         
         GL11.glColor3d(1, 1, 1);
         
         GL11.glBegin(GL11.GL_QUADS);
         
         GL11.glVertex2f(0, h * 7 / 8);
         
         GL11.glVertex2f(w / 16, h * 7 / 8);
         
         GL11.glVertex2f(w / 16, h * 29 / 32);
         
         GL11.glVertex2f(0, h * 29 / 32);
         
         GL11.glEnd();
         
      }
     
      if (counter >= 20) {
         
         GL11.glColor3d(1, 1, 1);
         
         Genome.instance.screen.textureMap.loadTexture("initializing.png");
         
         GL11.glBegin(GL11.GL_QUADS);
         
         GL11.glTexCoord2f(0, 1);
         
         GL11.glVertex2f(0, h * 3 / 4);
         
         GL11.glTexCoord2f(1, 1);
         
         GL11.glVertex2f(w * 1 / 2, h * 3 / 4);
         
         GL11.glTexCoord2f(1, 0);
         
         GL11.glVertex2f(w * 1 / 2, h * 7 / 8);
         
         GL11.glTexCoord2f(0, 0);
         
         GL11.glVertex2f(0, h * 7 / 8);
         
         GL11.glEnd();
         
      }
     
   }
   
}

All help is appreciated!

isaacais

This is just my understanding of drawing quads with OpenGL, but I am pretty sure that you are supposed to disable GL_TEXTURE_2D when drawing quads without texture coordinates.  I hope I helped!

GenomeGame

Thank you so much! I never realized that, I'm an idiot.  :o

Thanks for the help,

GenomeGame