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  
  How to make a textureLoader  (Read 1039 times)
0 Members and 1 Guest are viewing this topic.
Offline Joshua Waring
« Posted 2012-12-15 06:52:22 »

I'm trying to cut my use of slick by making my own TextureLoader, I don't need any fancy tricks.
I was wondering if anyone had a tutorial on loading textures from PNG format

I'm currently looking through the slick source code.

In particular, once reading and decoding the file, how should it be arranged for OpenGL to use it?

The world is big, so learn it in small bytes.
Offline ra4king

JGO Kernel


Medals: 356
Projects: 3
Exp: 5 years


I'm the King!


« Reply #1 - Posted 2012-12-15 07:04:06 »

OpenGL only cares for pure RGB/RGBA data. You have to decode PNG into that pure data. Good luck!

Offline Joshua Waring
« Reply #2 - Posted 2012-12-15 07:15:54 »

So put it all into a ByteBuffer, how does OpenGL read the texture, top left across then down a row?

Sorry for all the questions :3

The world is big, so learn it in small bytes.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline davedes
« Reply #3 - Posted 2012-12-15 07:16:21 »

https://github.com/mattdesl/lwjgl-basics/wiki

In particular the Textures and Buffers page.

Refer to this post which shows how to fix NPOT images when not supported in hardware.

That should be enough for most 2D purposes. You can take a peek at some more advanced texture loading concepts here (compressed textures, different formats, different targets, mipmaps, etc).

Offline HeroesGraveDev

JGO Kernel


Medals: 310
Projects: 11
Exp: 3 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #4 - Posted 2012-12-15 07:25:48 »

http://pastebin.java-gaming.org/3fe088a3a3f
Here's my code for this.
Converts a BufferedImage to a ByteBuffer and back.

Enjoy!

Offline Joshua Waring
« Reply #5 - Posted 2012-12-15 07:40:10 »

Thank you, it's actually a really good idea to let awt handle the decoding :3

The world is big, so learn it in small bytes.
Offline davedes
« Reply #6 - Posted 2012-12-15 12:55:00 »

Thank you, it's actually a really good idea to let awt handle the decoding :3
Not really. It introduces a huge dependency that isn't necessary for something so simple, and ImageIO can be pretty slow sometimes.

If you are going to use AWT, you can use this technique which may lead to better performance.

Smiley

Offline gouessej
« Reply #7 - Posted 2012-12-15 16:13:39 »

I was wondering if anyone had a tutorial on loading textures from PNG format
JOGL 2.0 uses PNGJ for that, it works very well even under Android.

Offline kappa
« League of Dukes »

JGO Kernel


Medals: 81
Projects: 15


★★★★★


« Reply #8 - Posted 2012-12-15 17:26:14 »

@Joshua Waring - Have a look at the PNGDecoder tutorial found on the LWJGL wiki here.

PNGDecoder is one of the most lightweight and fastest Java PNG decoders you'll find (being just one class and no dependency on AWT), the rest is just plugging the raw decoded data into OpenGL.
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 (30 views)
2014-12-15 09:26:44

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

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

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

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

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

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

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

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

toopeicgaming1999 (32 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!