Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (603)
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  
  Trouble with Textures  (Read 2080 times)
0 Members and 1 Guest are viewing this topic.
Offline cborders

Junior Devvie





« Posted 2005-10-07 05:09:33 »

I am trying to do a skyBox, but as soon as I put a texture on it the thing goes wonky!  It looks like the base color of the texture is bleeding into the rest of the scene.  Here are some pictures of what I mean:

Before Textures (I made the SkyBox gray so the spheres would show up!)


First texture I tried broke in a couple different ways!
Here is the Texture:

Here is the result:


Texture 2:

Result: (The spheres are there I promise!)


Texture 3:

Result:


Here's the code I use for loading images:
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  
private void loadTextures()
{
    rust = loadTexture("Box.jpg");
    night = loadTexture("cloud-02.jpg");
}

private int loadTexture(String path)
{
    IntBuffer image = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer();
    IL.ilGenImages(image);
    IL.ilBindImage(image.get(0));
    IL.ilLoadImage(path);
    IL.ilConvertImage(IL.IL_RGB, IL.IL_BYTE);
    ByteBuffer scratch = ByteBuffer.allocateDirect(IL.ilGetInteger(IL.IL_IMAGE_WIDTH) * IL.ilGetInteger(IL.IL_IMAGE_HEIGHT) * 3);
    IL.ilCopyPixels(0, 0, 0, IL.ilGetInteger(IL.IL_IMAGE_WIDTH), IL.ilGetInteger(IL.IL_IMAGE_HEIGHT), 1, IL.IL_RGB, IL.IL_BYTE, scratch);
   
    // Create A IntBuffer For Image Address In Memory
    IntBuffer buf = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer();
    GL11.glGenTextures(buf); // Create Texture In OpenGL
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, buf.get(0));
    // Typical Texture Generation Using Data From The Image
     // Linear Filtering
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
    // Linear Filtering
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
    // Generate The Texture
    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, IL.ilGetInteger(IL.IL_IMAGE_WIDTH),
    IL.ilGetInteger(IL.IL_IMAGE_HEIGHT), 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, scratch);
    return buf.get(0); // Return Image Address In Memory
}


Any idea what I'm doing wrong? Huh
Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #1 - Posted 2005-10-07 06:38:41 »

Try drawing those eggs with texturing disabled.

弾幕 ☆ @mahonnaiseblog
Offline hvor2

Junior Devvie




Beyond mind, there is an awareness...


« Reply #2 - Posted 2005-10-07 07:27:28 »

Yes, openGL is state machine. It will remember latest texture used and it will be your current texture until you either disable it  or enable another texture (for egg).

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline cborders

Junior Devvie





« Reply #3 - Posted 2005-10-07 13:27:31 »

HAHA Beautiful!!!  Thank you!!!  Grin

-=EDIT=-
So even though I was not setting and Texture Coords it still effected the scene?!  Weird!, BUt disabling textrures worked perfectly!!  Thanks again!
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 841
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #4 - Posted 2005-10-07 18:24:23 »

Yes, you set the TexCoord, when you were rendering the skybox. As OpenGL is a state-machine is still has the last texcoord in it's memory and will use it.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social
Offline cborders

Junior Devvie





« Reply #5 - Posted 2005-10-07 19:18:20 »

Good to know!  Grin  That's why I love this place! Everyone is so helpful!!  Now I just need to get my posterier in gear and come up with something good to give back!!!  Tongue
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 841
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #6 - Posted 2005-10-07 19:28:13 »

The scewed rusty texture output looks like you loaded RGB pixels (the image) into RGBA pixels (the texture).

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social
Offline cborders

Junior Devvie





« Reply #7 - Posted 2005-10-07 19:40:53 »

That's very possible!  I just started playing with GIMP so I am not sure what what's going on with that yet!  I'll pull it into Photoshop and look at it!  Thanks!!
Offline cborders

Junior Devvie





« Reply #8 - Posted 2005-10-08 04:40:34 »

 Embarrassed The trouble was that it was not a power of 2 and mu graphics card didn't like it!  I meant it to be 512x512, but somehow it came out to be 410x410!  It was late...Yeah, that's the ticket!!  Wink

Noe I am having another Texture issue.  There is blurring of the texture, I know it has to have something to do with the kind of filtering I am enabling, or not, but I am not sure which one it is.  Here is a pic of the problem!



It only happens when viewed from an extreme angle.
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 841
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #9 - Posted 2005-10-08 10:14:10 »

You definitly need to mipmap your textures, then apply the correct MIN/MAG filters

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
boolean useMipmaps = true;

      if(useMipmaps)
      {
         MipMap.gluBuild2DMipmaps(GL_TEXTURE_2D, bpp, dim, dim, format, GL_UNSIGNED_BYTE, bb);
      }
      else
      {
         glTexImage2D(GL_TEXTURE_2D, 0, format, dim, dim, 0, format, GL_UNSIGNED_BYTE, bb);
      }

      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, useMipmaps ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline cborders

Junior Devvie





« Reply #10 - Posted 2005-10-08 15:46:16 »

Very cool!  I will look into that!!  Thank you!  Grin
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.

rwatson462 (36 views)
2014-12-15 09:26:44

Mr.CodeIt (29 views)
2014-12-14 19:50:38

BurntPizza (61 views)
2014-12-09 22:41:13

BurntPizza (98 views)
2014-12-08 04:46:31

JscottyBieshaar (58 views)
2014-12-05 12:39:02

SHC (74 views)
2014-12-03 16:27:13

CopyableCougar4 (76 views)
2014-11-29 21:32:03

toopeicgaming1999 (137 views)
2014-11-26 15:22:04

toopeicgaming1999 (127 views)
2014-11-26 15:20:36

toopeicgaming1999 (37 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
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!