LWJGL
May 17, 2012, 03:06:16 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: LWJGL 2.8.3 released!
 
   Home   Help Search Login Register  



Pages: [1]
  Print  
Author Topic: DevIL problem  (Read 7505 times)
sir_wojciech
Newbie
*
Posts: 38


« on: November 29, 2005, 09:18:49 »

I've got a problem with DevIL and I've some posts with the same problem but couldn't find the solution. The problem is that when I compile my code I get with IL.create() in the code:

Exception in thread "main" java.lang.NullPointerException
        at org.lwjgl.opengl.GL11.glGenTextures(GL11.java:1169)
        at game.TextureLoader.load(TextureLoader.java:28)
        at game.Scene.<init>(Scene.java:7)
        at game.Main.<init>(Main.java:15)
        at game.Main.main(Main.java:81)
Java Result: 1

and without it in the code:

#
# An unexpected error has been detected by Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00000000, pid=2812, tid=1108
#
# Java VM: Java HotSpot(TM) Client VM (1.6.0-rc-b61 mixed mode, sharing)
# Problematic frame:
# C  0x00000000
#
# An error report file with more information is saved as hs_err_pid2812.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#
Java Result: 1

It's the same when using jse 5.0 and jse 6.0
Any solution to this?

Thanks in advance!
Logged
darkprophet
Talks Too Much
***
Posts: 179


« Reply #1 on: November 29, 2005, 17:15:24 »

The crash is a known problem as dynamic stub loading isn't supported on the DevIL side of things yet, and if I remember correctly, FMOD does the same too... But Mazon is on it, so it should be fixed soon  Smiley

As for the stack trace, would you mind posting some code? That would help alot..

DP
Logged
sir_wojciech
Newbie
*
Posts: 38


« Reply #2 on: November 30, 2005, 06:30:58 »

Strange cause it worked earlier...
For the code this is supposed to load the texture in to the memory and return the handle (I took it from NeHe's tutorial - still learning to use LWJGL  Smiley )
Code:

    public static int load(String path)
    {
        IntBuffer image = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer();
        IL.ilGenImages(image);
        IL.ilBindImage(image.get(0));
        IL.ilLoadImage(path);
        IL.ilConvertImage(IL.IL_RGBA, IL.IL_BYTE);
        ByteBuffer scratch = ByteBuffer.allocateDirect(IL.ilGetInteger(IL.IL_IMAGE_WIDTH) * IL.ilGetInteger(IL.IL_IMAGE_HEIGHT) * 3);
        IL.ilCopyPixels(0, 0, 0, IL.ilGetInteger(IL.IL_IMAGE_WIDTH), IL.ilGetInteger(IL.IL_IMAGE_HEIGHT), 1, IL.IL_RGB, IL.IL_BYTE, scratch);
        IntBuffer buf = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer();
        GL11.glGenTextures(buf);
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, buf.get(0));
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
        GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, IL.ilGetInteger(IL.IL_IMAGE_WIDTH),
                IL.ilGetInteger(IL.IL_IMAGE_HEIGHT), 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, scratch);
        return buf.get(0);
    }
Logged
sir_wojciech
Newbie
*
Posts: 38


« Reply #3 on: November 30, 2005, 06:38:21 »

Forgot to add this before at the beginning:
Code:

        try
        {
            IL.create();
        }catch(LWJGLException e){}
Logged
darkprophet
Talks Too Much
***
Posts: 179


« Reply #4 on: December 01, 2005, 08:47:34 »

Code:

static {
try {
IL.create();
ILU.create();
ILUT.create();
ILUT.ilutRenderer( ILUT.ILUT_OPENGL );

checkAnisotropicFilter();
} catch ( LWJGLException e ) {
System.err.println( "Failed to load OpenIL" );
System.exit( 1 );
}
}

private static Texture loadTextureBase( URL url, boolean mipmap, boolean flip )
throws IOException {
IntBuffer ib = BufferUtils.createIntBuffer( 1 );
IL.ilGenImages( ib );
int image = ib.get( 0 );
IL.ilBindImage( image );
if ( !IL.ilLoadFromURL( url ) )
throw new IOException( "IL error " + IL.ilGetError() + " loading texture" );

if ( flip )
ILU.iluFlipImage();

int glImage = 0;
if ( mipmap )  
glImage = ILUT.ilutGLBindMipmaps();
else
glImage = ILUT.ilutGLBindTexImage();

if ( anisotropicFilter > 0 )
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropicFilter);

if ( glImage == 0 )
Util.checkGLError();

IL.ilDeleteImages( ib );

// reset texture, got me in a proper headache earlier
GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);

return new Texture( glImage );
}


That works...try that...

DP
Logged
sir_wojciech
Newbie
*
Posts: 38


« Reply #5 on: December 01, 2005, 09:27:38 »

Not working. Still the same NullPointerException.
Logged
Matzon
Administrator
Demigod
*****
Posts: 2177



« Reply #6 on: December 01, 2005, 09:55:13 »

have you created an display beforehand ?
Logged

http://certusgames.com (Free Online Multiplayer Java Games)
http://lwjgl.org (OpenGL/OpenAL for Java)
sir_wojciech
Newbie
*
Posts: 38


« Reply #7 on: December 01, 2005, 11:28:08 »

yes
Logged
Matzon
Administrator
Demigod
*****
Posts: 2177



« Reply #8 on: December 01, 2005, 13:04:41 »

well, the only way you can get a NPE in that piece of code:
long function_pointer = GLContext.getCapabilities().GL11_glGenTextures_pointer;
is by not having a valid context, which I am unsure about how you can possibly have.
Do you have some multithreaded code ?
Does LWJGL demos work fine for you ?
Logged

http://certusgames.com (Free Online Multiplayer Java Games)
http://lwjgl.org (OpenGL/OpenAL for Java)
sir_wojciech
Newbie
*
Posts: 38


« Reply #9 on: December 01, 2005, 13:21:23 »

The demos work fine and well my application is not multithreaded.
Logged
sir_wojciech
Newbie
*
Posts: 38


« Reply #10 on: December 01, 2005, 13:33:16 »

I checked the devil's BasicTest and I get:
init:
deps-jar:
Compiling 1 source file to F:\java app\Game\build\classes
compile:
run:
error = no error
ilGenImages
ilBindImage
error = no error
error = no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L.ilGetInteger(IL.IL_ACTIVE_IMAGE) = 0
Version: 167
error = no error
info.id         = 3
info.width      = 15
info.height     = 15
info.depth      = 1
info.bpp        = 4
info.sizeOfData = 900
info.format     = 6408
info.type       = 5121
info.origin     = 1537
info.palType    = 1024
info.palSize    = 0
info.numNext    = 0
info.numMips    = 0
info.numLayers  = 0
error = no error
ILUT Vendor: Abysmal Software
BUILD SUCCESSFUL (total time: 1 second)

so it's working
Logged
sir_wojciech
Newbie
*
Posts: 38


« Reply #11 on: December 01, 2005, 13:44:17 »

Here's my code for loading the texture:
Code:

    public static int load(String path)
    {
        try
        {
            IL.create();
            ILU.create();
            ILUT.create();
            ILUT.ilutRenderer( ILUT.ILUT_OPENGL );
        }
        catch(LWJGLException e)
        {}
        IntBuffer ib = BufferUtils.createIntBuffer( 1 );
        IL.ilGenImages( ib );
        int image = ib.get( 0 );
        IL.ilBindImage( image );
        IL.ilLoadImage(path);
        int glImage = 0;
        glImage = ILUT.ilutGLBindTexImage();
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT, 16);
        if ( glImage == 0 )
            Util.checkGLError();
        IL.ilDeleteImages( ib );
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
        return glImage;
    }

And I get:
Code:

Exception in thread "main" java.lang.NullPointerException
        at org.lwjgl.opengl.GL11.glTexParameterf(GL11.java:2264)
        at game.TextureLoader.load(TextureLoader.java:34)
        at game.Scene.<init>(Scene.java:7)
        at game.Main.<init>(Main.java:15)
        at game.Main.main(Main.java:81)
Java Result: 1

Strange cause the BasicTest works..
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines
SMFAds for Free Forums
Valid XHTML 1.0! Valid CSS!