Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (780)
Games in Android Showcase (233)
games submitted by our members
Games in WIP (856)
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 4962 times)
0 Members and 1 Guest are viewing this topic.
Offline weston
« 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:

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.


for(int i = 1; i > 0; i++)
     System.out.println(i+" cups of java downed");
Offline weston
« 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...

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

« JGO Spiffy Duke »

Medals: 319
Projects: 25
Exp: 22 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.


Offline weston
« 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: 123
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
« 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  

hadezbladez (712 views)
2018-11-16 13:46:03

hadezbladez (355 views)
2018-11-16 13:41:33

hadezbladez (699 views)
2018-11-16 13:35:35

hadezbladez (175 views)
2018-11-16 13:32:03

EgonOlsen (2368 views)
2018-06-10 19:43:48

EgonOlsen (2502 views)
2018-06-10 19:43:44

EgonOlsen (1465 views)
2018-06-10 19:43:20

DesertCoockie (2131 views)
2018-05-13 18:23:11

nelsongames (1927 views)
2018-04-24 18:15:36

nelsongames (2600 views)
2018-04-24 18:14:32
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46 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!