LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: K.I.L.E.R on April 16, 2004, 15:10:22

Title: Funny thing, I have most LWJGL projects working except this
Post by: K.I.L.E.R on April 16, 2004, 15:10:22
java.lang.UnsatisfiedLinkError: nglGenTextures
      at org.lwjgl.opengl.GL11.nglGenTextures(Native Method)
      at org.lwjgl.opengl.GL11.glGenTextures(Unknown Source)
      at src.main.Video.loadTexture(Video.java:176)
      at src.main.Video.init(Video.java:45)
      at src.main.Main.<init>(Main.java:29)
      at src.main.Main.main(Main.java:35)
Exception in thread "main" Finished executing

:roll:

You see, all my other LWJGL project work fine.
I can knock up a shaded poly in seconds.

Unfortunately this project has a link error. I have followed all the instructions on the LWJGL site and even read the FAQ doing what it asks. In the end, it did nothing.

http://members.optusnet.com.au/ksaho/dlds/src.zip

I've spent hours trying to repair this problem with no luck.
I'm on the brink of insanity, can someone please help me?

Thanks
Title: Funny thing, I have most LWJGL projects working except this
Post by: Optus on April 16, 2004, 15:19:14
Well the UnsatisfiedLinkError is thrown when the JNI Java code cannot find the corresponding method in the native library.  What I would check is that 1) You have the project currently set up with the lwjgl.dll and lwjglaudio.dll from version 0.9. And 2) that there aren't multiple binaries fom different versions of LWJGL also in your path.
Title: Funny thing, I have most LWJGL projects working except this
Post by: elias on April 16, 2004, 15:38:24
Did you succesfully create the WIndow? In 0.9, the GL functions are not bound to the java stubs before a valid context is current.

- elias
Title: Funny thing, I have most LWJGL projects working except this
Post by: K.I.L.E.R on April 17, 2004, 02:51:51
Yes, the Window is successfully created and so is the actual square which I made if you comment out the image loader.

Optus, I have done the things you mentioned.
No luck.
Title: Funny thing, I have most LWJGL projects working except this
Post by: K.I.L.E.R on April 17, 2004, 08:40:53
Here is the problem:

/**buff = IntBuffer.wrap(getIntContents());****/ -works nicely

GL11.glGenTextures(buff); -CHA CHING

Why isn't this working?

*BTW I've done a lot of testing.
Title: Funny thing, I have most LWJGL projects working except this
Post by: cfmdobbie on April 17, 2004, 09:06:15
Hmm, I don't know why it would cause a link error, but there's a problem there that LWJGL methods require direct buffers - I suspect IntBuffer.wrap() will not return a direct buffer.

(Edit: Yep, confirmed.  From Javadoc: "A int buffer created via the wrap methods of this class will be non-direct")

Try swapping that code out for something like:

import org.lwjgl.BufferUtils;
int[] array = getIntContents();
buff = BufferUtils.createIntBuffer(array.length);
buff.put(array).flip();
GL11.glGenTextures(buff);
Title: Funny thing, I have most LWJGL projects working except this
Post by: K.I.L.E.R on April 17, 2004, 14:58:17
Thanks, but it still displays the same error. :(

Here is my new code used as a test bed to repair this error:


public class Main
{
private void programExec()
{
buff = BufferUtils.createIntBuffer(MAX);

buff.put(getIntContents()).flip();

GL11.glGenTextures(buff);
}


private int[] getIntContents()
{
int[] c = new int[MAX];
int i=0;

try
{
   c[i] = fr.read();

   while(c[i] != -1)
{
i++;
c[i] = fr.read();
}
}catch (Exception e)
{
JOptionPane.showMessageDialog(null, e.getMessage());
e.printStackTrace();
}

return c;
}

/**
* MAIN
*/
public Main()
 {
 try
{
  fr = new FileReader("c:\\texture.PNG");
} catch (Exception e)
{
JOptionPane.showMessageDialog(null, e.getMessage());
e.printStackTrace();
}
}

public static void main(String[] args)
 {
Main main = new Main();

main.programExec();
}
/**
* MAIN
*/

BufferedImage bufImg;
Image img;
ImageIcon imgIc;
FileReader fr;
IntBuffer buff;

final static int MAX = 25000;
}
Title: Funny thing, I have most LWJGL projects working except this
Post by: K.I.L.E.R on April 17, 2004, 15:15:49
New update:


//GL11.glGenTextures(buff); -cancelled this line out
GL11.glGetTexImage(GL11.GL_TEXTURE_2D, 0, GL11.GL_ALPHA8, GL11.GL_RGBA8, buff);


The problem seems to be with the buffer itself even though I have already done what it was said, I've also originally used NEHE's code and that displayed the same error.

C:\Program Files\Java\j2sdk1.5.0\bin\java.exe   -classpath "C:\Program Files\Java\j2sdk1.5.0\jre\lib\rt.jar;C:\Program Files\Java\j2sdk1.5.0\lib\tools.jar;C:\Program Files\Java\j2sdk1.5.0\lib\lwjgl.jar;C:\Documents and Settings\Kruno_K.I.L.E.R\My Documents\java\test\classes" Main
java.lang.UnsatisfiedLinkError: nglGetTexImage
      at org.lwjgl.opengl.GL11.nglGetTexImage(Native Method)
      at org.lwjgl.opengl.GL11.glGetTexImage(Unknown Source)
      at Main.programExec(Main.java:22)
      at Main.main(Main.java:68 )
Exception in thread "main" Finished executing

To tell you the truth I have no idea where the error is coming from now that I think about it even harder. :(
Title: Funny thing, I have most LWJGL projects working except this
Post by: elias on April 17, 2004, 15:27:18
So where's your Window.create?

- elias
Title: Funny thing, I have most LWJGL projects working except this
Post by: K.I.L.E.R on April 17, 2004, 15:35:23
Don't need it.

It's only a test class to solve the specific problem.

The problem occurs on NEHE's original code, my code as well as this test code code which leaves me baffled.
Title: Funny thing, I have most LWJGL projects working except this
Post by: elias on April 17, 2004, 15:44:45
But without a valid and current context (the Window) there're will be no GL functions to call... If you just created any window (640*480 with 0 in all caps values, you should be all right)

- elias
Title: Funny thing, I have most LWJGL projects working except this
Post by: K.I.L.E.R on April 17, 2004, 15:55:10
Officially, it's working.

Problem?

DLL in wrong place.

My suggestion:

Update the installation instructions with this information:
Place the DLLs in the JDK's bin directory.

Thanks guys, I can't believe how stupid I am, I should have seen this coming.
Title: Funny thing, I have most LWJGL projects working except this
Post by: elias on April 17, 2004, 16:04:29
No, you should never place the dll anywhere 'system' like, as that will most certainly lead to versioning problems some day (even though I did implement a version check for 0.9... It seems that it didn't kick in in this case though). Always place the dll/so/jnilib in the same directory as the lwjgl.jar file and preferably in the game's local directory, not a system dir like the jdk dir.

- elias
Title: Funny thing, I have most LWJGL projects working except this
Post by: K.I.L.E.R on April 17, 2004, 16:10:00
Since it's working and I know where the DLLs are would it be okay?
Title: Funny thing, I have most LWJGL projects working except this
Post by: elias on April 17, 2004, 16:36:36
Hehe, sure, I didn't mean to lecture you, it was more a statement of intent that the libs never were meant to be installed in a system location because they change so often and are are very tied to the jar

- elias
Title: Funny thing, I have most LWJGL projects working except this
Post by: K.I.L.E.R on April 17, 2004, 16:41:01
Maybe in future you could somehow tightly tie the libs with the jar?

It just so happens it's more convenient doing it my way. ;)
Title: Funny thing, I have most LWJGL projects working except this
Post by: elias on April 17, 2004, 16:56:14
That seems only to be possible under Webstart as far as I know. With Webstart, you can specify a jar that contains native libs, but under a "regular" java run, you need the libs as separate files.

(In fact, webstart also needs the libs as separate files, so it pulls the libs out of the jar before the app runs)

- elias
Title: Funny thing, I have most LWJGL projects working except this
Post by: princec on April 18, 2004, 09:49:03
I thought we had a native lib version check in the latest LWJGL?

Cas :)
Title: Funny thing, I have most LWJGL projects working except this
Post by: K.I.L.E.R on April 18, 2004, 10:34:50
A couple of posts up I was told that it doesn't work.