Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
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  
  Textures  (Read 1153 times)
0 Members and 1 Guest are viewing this topic.
Offline nickdotjava

Junior Member




I have fallen to the dark side.  I'm using DX9


« Posted 2003-07-03 18:54:50 »

I have this code from the LWJGL examples:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
public Texture loadImage(String filename) throws Exception {
        Texture texture = null;
        BufferedImage tmpImg = null;
        
        /* normally I would use StringUtils.isValid(String) from the
           jakarta commons lib, but thats beyond the scope of this lesson */

        if ((filename != null) && (filename.trim() != "")) {
            try {
                InputStream is = getClass().getResourceAsStream(filename);
                tmpImg = (BufferedImage) ImageIO.read(is);
                if (tmpImg == null) {
                    throw new Exception("Error: Got null from ImageIO.read()");
                }
                texture = new Texture(tmpImg);
            }
            catch ( Exception e ) {
                throw new Exception("Problem loading bitmap", e);
            }
        } else {
            throw new Exception("Error: file name is not valid!");
        }
        return texture;
    }


And it has problems finding bmps, but not pngs.  Is there a reason for this?  And what settings do I need on the png for it to show up?

Thanks.

-Nick

"Oh ya, that's trivial.  I should have it done in an hour."
Offline Backmask

Junior Member




586: The average IQ needed to understand a PC


« Reply #1 - Posted 2003-07-04 07:34:48 »

http://www.puppygames.net/forums/viewtopic.php?t=73&highlight=png+textures

Offline nickdotjava

Junior Member




I have fallen to the dark side.  I'm using DX9


« Reply #2 - Posted 2003-07-08 17:55:28 »

If I use certain textures, any polygon that's not texture mapped disappears.  Anyone know why this happens?

Thanks.

-Nick

"Oh ya, that's trivial.  I should have it done in an hour."
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Andrew

Senior Newbie




Java games rock!


« Reply #3 - Posted 2003-07-08 18:26:06 »

I just had a problem like this.

Are you turning off texture mapping when drawing the other polygons? If not, then all the vertices will inherit the previous texture coord, which could be black - depending on the image - and nothing appears.
Offline nickdotjava

Junior Member




I have fallen to the dark side.  I'm using DX9


« Reply #4 - Posted 2003-07-08 18:35:56 »

What's the line of code to disable texturing?  And where do I put it?  If you can, use the following as an example:

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  
float[][] triangle1={{20.0f, 30.0f, 200.0f},
                                      {20.0f, 40.0f, 0.0f},
                                      {60.0f, 30.0f, -20.0f}};
        crossProduct=GraphicsUtil.unitCrossProduct(triangle1);
        gl.begin(GL.TRIANGLES);
              gl.normal3f(crossProduct[0], crossProduct[1], crossProduct[2]);
              gl.texCoord2f(0.0f, 0.86f);
            gl.vertex3f(20.0f, 30.0f, 200.0f);
            gl.normal3f(crossProduct[0], crossProduct[1], crossProduct[2]);
            gl.texCoord2f(0.77f, 1.0f);
            gl.vertex3f(20.0f, 40.0f, 0.0f);
            gl.normal3f(crossProduct[0], crossProduct[1], crossProduct[2]);
            gl.texCoord2f(0.88f, 0.86f);
            gl.vertex3f(60.0f, 30.0f, -20.0f);
        gl.end();

        float[][] triangle2={{20.0f, 30.0f, 200.0f},
                                      {60.0f, 30.0f, -20.0f},
                                      {40.0f, -20.0f, -10.0f}};
            crossProduct=GraphicsUtil.unitCrossProduct(triangle2);
        gl.begin(GL.TRIANGLES);
              gl.normal3f(crossProduct[0], crossProduct[1], crossProduct[2]);
              gl.vertex3f(20.0f, 30.0f, 200.0f);
              gl.normal3f(crossProduct[0], crossProduct[1], crossProduct[2]);
              gl.vertex3f(60.0f, 30.0f, -20.0f);
              gl.normal3f(crossProduct[0], crossProduct[1], crossProduct[2]);
              gl.vertex3f(40.0f, -20.0f, -10.0f);
        gl.end();


I tried putting the line:         gl.disable(GL.TEXTURE_2D);
right after the first gl.end(), but then no textures show up.

Edit:  If I edit it, and press save, then the tabbing on the code fixes itself.

-Nick

"Oh ya, that's trivial.  I should have it done in an hour."
Offline nickdotjava

Junior Member




I have fallen to the dark side.  I'm using DX9


« Reply #5 - Posted 2003-07-08 18:42:26 »

Now it gets really bizarre.  All I did was add a different filter to it on Photoshop, and now everything appears normally.

-Nick

"Oh ya, that's trivial.  I should have it done in an hour."
Offline Andrew

Senior Newbie




Java games rock!


« Reply #6 - Posted 2003-07-08 19:55:19 »

Quote
I tried putting the line:         gl.disable(GL.TEXTURE_2D);
right after the first gl.end(), but then no textures show up.

It will remember the last state set between frames, so you'll need to enable textures again before drawing any.
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 (53 views)
2014-04-15 18:08:23

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

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

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

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

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

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

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

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

CJLetsGame (210 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!