Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
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  
  Easy way to load a texture in LWJGL?  (Read 8751 times)
0 Members and 1 Guest are viewing this topic.
Offline CyanPrime
« Posted 2009-12-24 17:55:23 »

Okay, so now that devIL isn't supported anymore it seems I'm expected create my own texture loader (I didn't have to do this in JOGL!), so I was wondering if there was a easier way to load a texture (.png). Thanks in advance.
Offline kappa
« League of Dukes »

JGO Kernel

Medals: 78
Projects: 15


« Reply #1 - Posted 2009-12-24 18:06:26 »

Fmod and Devil were both removed for LWJGL2+, the recommended replacement is a library called slick-util (note different from slick2d). You should be able to load various texture and sound formats with it.

you can get it from and the javadoc is located at

Its pretty easy to use, just download the package and have a look at the examples included in the source code on how to use it.
Offline indexunknown

Junior Duke

« Reply #2 - Posted 2009-12-24 18:14:13 »

int textureID = TextureLoader.getTexture(".PNG",this.getClass().getClassLoader().getResourceAsStream("image.png"),true).getTextureID();
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline CyanPrime
« Reply #3 - Posted 2009-12-24 18:35:35 »

Thank you very much. I'm now using Slick ^_^
Problem when I use textures though Sad

        // Front Face
           GL11.glTexCoord2f(0.0f, 0.0f);
           GL11.glVertex3f(-1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and Quad
           GL11.glTexCoord2f(1.0f, 0.0f);
           GL11.glVertex3f(1.0f, -1.0f, 1.0f); // Bottom Right Of The Texture and Quad
           GL11.glTexCoord2f(1.0f, 1.0f);
           GL11.glVertex3f(1.0f, 1.0f, 1.0f); // Top Right Of The Texture and Quad
           GL11.glTexCoord2f(0.0f, 1.0f);
           GL11.glVertex3f(-1.0f, 1.0f, 1.0f); // Top Left Of The Texture and Quad
Offline indexunknown

Junior Duke

« Reply #4 - Posted 2009-12-24 18:39:41 »

that's a non power of two texture i think.
Offline CyanPrime
« Reply #5 - Posted 2009-12-27 22:35:43 »

So I'm trying to get a tech demo out of Ultra GL as a JWS App, and for some reason the TextureLoader from Slick-Util doesn't want to see my .png from inside the  jar file. Here's the code.

try {
         texture = TextureLoader.getTexture("PNG", new FileInputStream("data/wall.png"));
      } catch (IOException e) {
Offline lhkbob

JGO Knight

Medals: 32

« Reply #6 - Posted 2009-12-27 22:52:07 »

You need to do:
texture = TextureLoader.getTexture("PNG", this.getClass().getClassLoader().getResource("data/wall.png").openStream());

This should work, or be very close to something that works.  You need to use getResource() to easily fetch resources that are inside jars.

Offline Riven
« League of Dukes »

JGO Overlord

Medals: 816
Projects: 4
Exp: 16 years

Hand over your head.

« Reply #7 - Posted 2009-12-29 12:48:32 »

Actually, for (old, bugged versions of?) Java WebStart you need to do:


This works everywhere.

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

JGO Kernel

Medals: 149
Projects: 4
Exp: 14 years

Esoteric Software

« Reply #8 - Posted 2009-12-29 15:58:27 »

If you are using Slick, you can use:
texture = TextureLoader.getTexture("PNG", ResourceLoader.getResource("data/wall.png"));

This will find it both in the classpath and on the filesystem.

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.

Longarmx (36 views)
2014-10-17 03:59:02

Norakomi (28 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (27 views)
2014-10-15 16:18:58

TehJavaDev (52 views)
2014-10-14 00:39:48

TehJavaDev (54 views)
2014-10-14 00:35:47

TehJavaDev (42 views)
2014-10-14 00:32:37

BurntPizza (63 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (77 views)
2014-10-11 22:30:10
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

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