Weird color problem after enabling Texture_2D

Hi there !

Im just playing araound with learning Textures in lwjgl, and happened to get some relatively strange effects.
Im drawing two rectangles/quads, where one should have a texture, the other just stay greywith a white border.

Without textures enabled, the rectangle works (wonder, wonder), but the one with the texture (which is also a grey rect) is totally white.

With textures enabled, the rectangle border is somehow about 50% grey, and the textured quad is 50% grey also… but doesn’t show the texture.

Im using the Texture code from the space invaders example, and before drawing the second quad im calling img.bind().

Any ideas whats wrong ?

(image is a gif)

Thanks in advance !

Dose

PS: EVERYTHING is getting darker after enabling.

hard to say without any coce…

  • Are you using texture coords

  • Is Texture2D enabled

  • Try to disable lighting?

  • Some weird blend setting?

The possibilities are endless

Im using 0.94-2alpha ,and the code i use is basically:


Display.setFullscreen(false);
Display.setDisplayMode(MY_DISPLAYMODE)
// this should create a ortographic projection window
Display.create();


// then im calling the initGL method 
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_DEPTH_TEST);

// the rendercode is according to the spaceinvaders example:

img.bind();
GL11.glTexCoord2f(0.0f,0.0f);
GL11.glVertex2i(x, y);
GL11.glTexCoord2f(0.0f,img.getHeight());
GL11.glVertex2i(x, y + img.getImageHeight());
GL11.glTexCoord2f(img.getWidth(),img.getHeight());
GL11.glVertex2i(x + img.getImageWidth(), y + img.getImageHeight());
GL11.glTexCoord2f(img.getWidth(),0.0f);
GL11.glVertex2i(x + img.getImageWidth(), y);

// in the constructor of the Image-class
// calls the constructor of the rectangle class
super(x, y, width, height);
color = new float[] {1.0f, 1.0f, 1.0f, 1.0f };
try
{
      img = Window.TEX_LOADER.getTexture(imgURL);
} catch (IOException e)
{
      e.printStackTrace();
}

  1. If the one of the rectangles should not have a texture, then you need to disable textureing before drawing it.

  2. Is your texture power of two? (Might not matter if texture loader handles it)

  3. Use “1” instead of “img.getWidth()” and “img.getHeight()”. You need to pass a normalized value. Where 1 means the whole width/height of texture.

  1. Ok done ! :slight_smile:

  2. The TextureLoader should take care of it

  3. Tried both. The getHeight and getWidth just return the Height/WidhtRatio so the image is displayed correctly, without the possible 2Fold-borders.

So the Rect displays correctly, the ImageRect is still just dark grey :frowning:

Did you do

        GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_REPLACE);

?

Yes, i tried it before i loaded the image,… made no difference…
here is the picture thats used

Try creating the texture loader at the bottom of the GL init stuff (after you’ve set everything up)

Kev

Hmm… tried…and didn’t change anything :((

Er, I don’t see you calling glBegin/glEnd anywhere?

I assume you’ve ommited them, otherwise you wouldn’t see anything…?

glBegin and glEnd are called in the rendering method.

Whats the code exactly? Or better yet, check you’re not calling .bind on the texture between begin/end.

Although that would give you a glError. You are checking glError every frame aren’t you? I think LWJGL does that automagically if you have asserts enabled.

DOH !!!

Ok,… :-[

Thanks all for the answers !

sneaking out of this topic…