Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (555)
Games in Android Showcase (147)
games submitted by our members
Games in WIP (601)
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 1099 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.
Online ra4king

JGO Kernel

Medals: 363
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 »

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: 350
Projects: 11
Exp: 3 years

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

« Reply #4 - Posted 2012-12-15 07:25:48 »
Here's my code for this.
Converts a BufferedImage to a ByteBuffer and back.


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.


Offline gouessej

« In padded room »

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

Riven (9 views)
2015-02-26 23:38:45

Riven (5 views)
2015-02-26 23:37:24

BurntPizza (18 views)
2015-02-26 21:13:04

Riven (16 views)
2015-02-26 17:13:57

Riven (23 views)
2015-02-26 14:54:51

here2help (36 views)
2015-02-12 00:46:22

here2help (32 views)
2015-02-12 00:27:01

here2help (24 views)
2015-02-12 00:26:53

E.R. Fleming (28 views)
2015-02-11 22:50:38

E.R. Fleming (36 views)
2015-02-11 22:49:12
How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

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 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!