Dosenbier
Senior Newbie 
They EXIST !!!
|
 |
«
Posted
2005-01-10 20:11:52 » |
|
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.
|
Nonsense makes the world go round.
|
|
|
Middy
Junior Member  
Java games rock!
|
 |
«
Reply #1 - Posted
2005-01-11 07:41:18 » |
|
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
|
When do I get my makeMyGameAsILike() extension?
|
|
|
Dosenbier
Senior Newbie 
They EXIST !!!
|
 |
«
Reply #2 - Posted
2005-01-11 11:45:50 » |
|
Im using 0.94-2alpha ,and the code i use is basically: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| Display.setFullscreen(false); Display.setDisplayMode(MY_DISPLAYMODE) Display.create();
GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_DEPTH_TEST);
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);
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(); } |
|
Nonsense makes the world go round.
|
|
|
Games published by our own members! Check 'em out!
|
|
tom
|
 |
«
Reply #3 - Posted
2005-01-11 12:44:52 » |
|
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.
|
|
|
|
Dosenbier
Senior Newbie 
They EXIST !!!
|
 |
«
Reply #4 - Posted
2005-01-11 13:06:58 » |
|
1) Ok done !  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 
|
Nonsense makes the world go round.
|
|
|
javazoid
Junior Member  
Where's Flender?
|
 |
«
Reply #5 - Posted
2005-01-11 13:13:40 » |
|
Did you do
GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_REPLACE);
?
|
|
|
|
Dosenbier
Senior Newbie 
They EXIST !!!
|
 |
«
Reply #6 - Posted
2005-01-11 13:43:17 » |
|
Yes, i tried it before i loaded the image,.. made no difference.... here is the picture thats used
|
Nonsense makes the world go round.
|
|
|
kevglass
|
 |
«
Reply #7 - Posted
2005-01-11 13:49:32 » |
|
Try creating the texture loader at the bottom of the GL init stuff (after you've set everything up)
Kev
|
|
|
|
Dosenbier
Senior Newbie 
They EXIST !!!
|
 |
«
Reply #8 - Posted
2005-01-11 14:03:27 » |
|
Hmm... tried...and didn't change anything  (
|
Nonsense makes the world go round.
|
|
|
Orangy Tang
|
 |
«
Reply #9 - Posted
2005-01-11 14:24:01 » |
|
Er, I don't see you calling glBegin/glEnd anywhere?
I assume you've ommited them, otherwise you wouldn't see anything...?
|
|
|
|
Games published by our own members! Check 'em out!
|
|
Dosenbier
Senior Newbie 
They EXIST !!!
|
 |
«
Reply #10 - Posted
2005-01-11 15:00:09 » |
|
glBegin and glEnd are called in the rendering method.
|
Nonsense makes the world go round.
|
|
|
Orangy Tang
|
 |
«
Reply #11 - Posted
2005-01-11 15:03:57 » |
|
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.
|
|
|
|
Dosenbier
Senior Newbie 
They EXIST !!!
|
 |
«
Reply #12 - Posted
2005-01-11 19:29:24 » |
|
DOH !!!! Ok,....  Thanks all for the answers ! *sneaking out of this topic....*
|
Nonsense makes the world go round.
|
|
|
|