Java-Gaming.org 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 (575)
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  
  DevIL texture loader  (Read 3306 times)
0 Members and 1 Guest are viewing this topic.
Offline weston

Junior Duke





« Posted 2005-03-14 17:28:50 »

I had been using Kevglass' texture loader (thanks for that Grin )  for a long time, but after deciding to use DevIL and needing multithreaded texture loading, I found myself wanting to write a new one from scratch. So this loader is still fairly simple, and mostly just for 2D games (doesn't generate mipmaps or anything), but it does flip your textures, convert to power of two dimensions, use DevIL, and supports loading on one thread and creating the texture on another. Here are the classes:

http://www.cyntaks.com/projects/source/TextureLoader.java
http://www.cyntaks.com/projects/source/Texture.java

I'll write some example code using the TextureLoader on two threads if anyone is interested. Although I do try to explain it with comments in the code, it may be a bit non-intuitive for some people to use.

For anyone who doesn't know, the reason you want to load and create the texture on multiple threads is this: loading your textures can take a while and chances are you want to show a progress bar or something while this takes places. The obvious way to do this is to just load the texture on another thread, problem is that textures must be created on the same thread that they will be used on. This code splits the process into two parts so that you can load on the new thread and create on your rendering thread.

Enjoy!

for(int i = 1; i > 0; i++)
{
System.out.println(i+" cups of java downed");
}
Offline weston

Junior Duke





« Reply #1 - Posted 2005-03-16 04:15:26 »

Oh yeah, and if anyone looks through the code and finds that I'm doing something that could potentially blow up someone's computer, let me know Grin

for(int i = 1; i > 0; i++)
{
System.out.println(i+" cups of java downed");
}
Offline wiesi

Senior Newbie




Java rulez!


« Reply #2 - Posted 2005-06-05 06:26:53 »

Why don't you use "static" instead of your private constructor and declare all the methods in the TextureLoader static; would be easier to handle and faster to use...

WiESi
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Online kevglass

JGO Kernel


Medals: 186
Projects: 24
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #3 - Posted 2005-06-05 10:53:08 »

I suspect it was an attempt to make the thing more future proof, you might want multiple TextureLoader instances (maybe for texture context) at some point one day.

Kev

Offline weston

Junior Duke





« Reply #4 - Posted 2005-06-06 08:40:12 »

yeah what kev said Smiley

Actually my reasons weren't quite as good, I don't remember why I chose to do it that way but I probably figured usage would be pretty much the same either way. I probably just did it because I think I should be creating objects instead of using classes with static methods for some reason.

for(int i = 1; i > 0; i++)
{
System.out.println(i+" cups of java downed");
}
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 78
Projects: 15


★★★★★


« Reply #5 - Posted 2005-08-08 14:21:19 »

is this compatible with the space invaders demo? (ie if i switch the files it won't know the difference) ?

if so this would be great and should replace it in the lwjgl library, most newbies (including me) use textureLoader and texture for there games so this would be a welcome addition!
Offline weston

Junior Duke





« Reply #6 - Posted 2005-08-08 18:26:48 »

It actually can't be swapped with the space invaders texture loader. There is more you have to do if you want to use multi-threaded loading and I'm not sure if my methods for single-threaded loading are the same as the invaders loader or not (they will certainly be similar though). I don't know if its a good replacement because it probably hasn't been tested much, all I can say is that I've been using it and havn't had any problems Smiley

for(int i = 1; i > 0; i++)
{
System.out.println(i+" cups of java downed");
}
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 (35 views)
2014-10-17 03:59:02

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

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

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

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

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

TehJavaDev (40 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 (75 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
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!