Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (582)
games submitted by our members
Games in WIP (503)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Weird color problem after enabling Texture_2D  (Read 1568 times)
0 Members and 1 Guest are viewing this topic.
Offline 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.

Offline 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?
Offline 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)
// 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();
}

Nonsense makes the world go round.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline 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.

Offline Dosenbier

Senior Newbie




They EXIST !!!


« Reply #4 - Posted 2005-01-11 13:06:58 »

1) Ok done ! Smiley

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 Sad

Nonsense makes the world go round.

Offline 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);

?

Offline 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.

Offline kevglass

JGO Kernel


Medals: 85
Projects: 25


Coder, Trainee Pixel Artist, Game Reviewer


« 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

Offline Dosenbier

Senior Newbie




They EXIST !!!


« Reply #8 - Posted 2005-01-11 14:03:27 »

Hmm... tried...and didn't change anything Sad(

Nonsense makes the world go round.

Offline Orangy Tang

JGO Kernel


Medals: 51
Projects: 11


Monkey for a head


« 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...?

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline 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.

Offline Orangy Tang

JGO Kernel


Medals: 51
Projects: 11


Monkey for a head


« 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.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Dosenbier

Senior Newbie




They EXIST !!!


« Reply #12 - Posted 2005-01-11 19:29:24 »

DOH !!!!

Ok,....   Embarrassed

Thanks all for the answers !


*sneaking out of this topic....*

Nonsense makes the world go round.

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (72 views)
2014-04-15 18:08:23

BurntPizza (68 views)
2014-04-15 03:46:01

UprightPath (79 views)
2014-04-14 17:39:50

UprightPath (65 views)
2014-04-14 17:35:47

Porlus (80 views)
2014-04-14 15:48:38

tom_mai78101 (104 views)
2014-04-10 04:04:31

BurntPizza (164 views)
2014-04-08 23:06:04

tom_mai78101 (260 views)
2014-04-05 13:34:39

trollwarrior1 (210 views)
2014-04-04 12:06:45

CJLetsGame (220 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!