Jump to content

LWJGL Loading images WITHOUT Slick2D.

- - - - -

  • Please log in to reply
5 replies to this topic

#1
floorman

floorman

    Newbie

  • Members
  • PipPip
  • 29 posts
Hello,

I want to load images into my Java Game with LWJGL but I don't want to use Slick2D. Is this at all possible?

Thanks.

#2
lethalwire

lethalwire

    while(false){ ... }

  • Members
  • PipPipPipPipPipPipPip
  • 748 posts
  • Programming Language:Java, PHP
  • Learning:Java, PHP
Does the 2nd example from the following website accomplish this?:
embeddednode: Textures in LWJGL 2

Specifically, the "Solution in AWT."


What prevents you from using Slick2D?

#3
floorman

floorman

    Newbie

  • Members
  • PipPip
  • 29 posts
I just don't want to use an entirely library for loading images if I can help it. And I was convinced that LWJGL must have some method or given function for it anyway.

Also, whats with the loops like these?:

for(int i=0x00000000; i<img.data.length; i+=0x00000003) {
temp = src.data[i];
src.data[i] = src.data[i+0x00000002];
src.data[i+0x00000002] = temp;
}

Why all of the 0x00000000 st

Also, I don't know if I should know this by now or something, but why specifically AWT? I apologise if that's a dumb question.

#4
lethalwire

lethalwire

    while(false){ ... }

  • Members
  • PipPipPipPipPipPipPip
  • 748 posts
  • Programming Language:Java, PHP
  • Learning:Java, PHP
I'm not sure why the loops are programmed like this. It looks to be the equivalent of:

for(int i=0; i<img.data.length; i+=3) {

temp = src.data[i];

src.data[i] = src.data[i+2];

src.data[i+2] = temp;

}


The AWT contains 2 classes that are used to store the image data from the disk into the JVM memory, and then transfer the data into a ByteBuffer.

#5
baseball435

baseball435

    Newbie

  • Members
  • PipPip
  • 14 posts
Well you can load an image using the normal Java API by just doing


ImageIcon ic = new ImageIcon(path);

Image i = ic.getImage();


where path = the path to your image...

~baseball435

#6
lethalwire

lethalwire

    while(false){ ... }

  • Members
  • PipPipPipPipPipPipPip
  • 748 posts
  • Programming Language:Java, PHP
  • Learning:Java, PHP

baseball435 said:

Well you can load an image using the normal Java API by just doing


ImageIcon ic = new ImageIcon(path);

Image i = ic.getImage();


where path = the path to your image...

~baseball435

Is the AWT not considered part of the "normal" Java API?
Does ImageIcon provide the necessary information for LWJGL to map textures to polygons?




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users