NullPointerException after calling to GL11.glGenTextures

I have the following code:


        IntBuffer textureId = BufferUtil.newIntBuffer(1);	
        GL11.glGenTextures(textureId);							// 

and i get a NullPointerException …

why is that?

A proper stack trace would help, but I’d guess maybe you havn’t created a display yet? Or maybe you’re calling this in a thread where the gl context isn’t current? (ie. the thread you created your display in).

Hi… ok, i did what u suggested, and it worked, but now i have a serious runtime crash -

An unexpected error has been detected by HotSpot Virtual Machine:

EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x69557dda, pid=3168, tid=3156

Java VM: Java HotSpot™ Client VM (1.5.0_09-b03 mixed mode, sharing)

Problematic frame:

C [nvoglnt.dll+0x57dda]

An error report file with more information is saved as hs_err_pid3168.log

If you would like to submit a bug report, please visit:

http://java.sun.com/webapps/bugreport/crash.jsp

what can it be?

again, post the full log - there is no info in that one, except your nvidia drivers are crashing.

It shouldn’t crash, since the Nehe tutorial (45) worked with JoGL library.

I just tried to port it to LWJGL, and it crashed when calling to GL11.glGenTextures(m_textureId).

m_textureId is defined as:
private IntBuffer m_textureId = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer();

I just copy pasted all that memory stuff from other Nehe - LWJGL lesson, since it worked there (a textured spinning cube).

its impossible to guess whats wrong without the full log, for all we know, you could be calling OpenGL methods without even having created a display - or you could passing illegal buffers to the drivers - it’s pure guesswork.

Saying that stuff work in jogl doesn’t actually mean anything. Since jogl and lwjgl are two completely different codebases you can’t compare them in that regard.

hi

the display was created.
I copy pasted a legitimate code from texture-loading in LWJGL based NeHe lesson 7…

http://www.catb.org/~esr/faqs/smart-questions.html

Here is the full log:


#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x69557dda, pid=3544, tid=2472
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_09-b03 mixed mode, sharing)
# Problematic frame:
# C  [nvoglnt.dll+0x57dda]
#

---------------  T H R E A D  ---------------

Current thread (0x000368b8):  JavaThread "main" [_thread_in_native, id=2472]

siginfo: ExceptionCode=0xc0000005, reading address 0x0c0c2fa2

Registers:
EAX=0x00000031, EBX=0x0bf92fa2, ECX=0x0bbc5474, EDX=0x42a00000
ESP=0x0007f964, EBP=0x00000030, ESI=0x07485298, EDI=0x0c0c2fa2
EIP=0x69557dda, EFLAGS=0x00010202

Top of Stack: (sp=0x0007f964)
0x0007f964:   00018000 00000004 0747c2c0 00000000
0x0007f974:   0747c2c0 69558d12 00000000 00017f34
0x0007f984:   0007f9f8 000368b8 0747c2c0 26b066e8
0x0007f994:   6960deff 0747c2c0 00000004 00000000
0x0007f9a4:   00018000 26b066e8 10006f53 00000004
0x0007f9b4:   00000000 00018000 00ad832f 00036978
0x0007f9c4:   0007fa00 00000004 00000000 00018000
0x0007f9d4:   69607730 00000000 0007f9dc 26b066e8 

Instructions: (pc=0x69557dda)
0x69557dca:   12 8b d5 0d 00 38 00 40 4d 89 41 fc 85 d2 7e 2b
0x69557dda:   8b 07 89 01 83 c1 14 8b 57 04 89 51 f0 03 7e 7c 


Stack: [0x00040000,0x00080000),  sp=0x0007f964,  free space=254k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [nvoglnt.dll+0x57dda]

[error occurred during error reporting, step 120, id 0xc0000005]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  org.lwjgl.opengl.GL11.nglDrawArrays(IIIJ)V+0
j  org.lwjgl.opengl.GL11.glDrawArrays(III)V+20
j  myUtilities.myHeightMap.render()V+92
j  Main.render()V+36
j  Main.run()V+31
j  Main.main([Ljava/lang/String;)V+3
v  ~StubRoutines::call_stub

---------------  P R O C E S S  ---------------

Java Threads: ( => current thread )
  0x00a72038 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=1120]
  0x00a70c20 JavaThread "CompilerThread0" daemon [_thread_blocked, id=2744]
  0x00a6ffd0 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=1608]
  0x00a48c60 JavaThread "Finalizer" daemon [_thread_blocked, id=3756]
  0x00a6ab30 JavaThread "Reference Handler" daemon [_thread_blocked, id=3108]
=>0x000368b8 JavaThread "main" [_thread_in_native, id=2472]

Other Threads:
  0x00a68df0 VMThread [id=2940]
  0x00a8cb88 WatcherThread [id=1812]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
 def new generation   total 576K, used 208K [0x22a70000, 0x22b10000, 0x22f50000)
  eden space 512K,  40% used [0x22a70000, 0x22aa41b8, 0x22af0000)
  from space 64K,   0% used [0x22af0000, 0x22af0000, 0x22b00000)
  to   space 64K,   0% used [0x22b00000, 0x22b00000, 0x22b10000)
 tenured generation   total 3232K, used 2345K [0x22f50000, 0x23278000, 0x26a70000)
   the space 3232K,  72% used [0x22f50000, 0x2319a7a0, 0x2319a800, 0x23278000)
 compacting perm gen  total 8192K, used 873K [0x26a70000, 0x27270000, 0x2aa70000)
   the space 8192K,  10% used [0x26a70000, 0x26b4a728, 0x26b4a800, 0x27270000)
    ro space 8192K,  67% used [0x2aa70000, 0x2afce5d8, 0x2afce600, 0x2b270000)
    rw space 12288K,  47% used [0x2b270000, 0x2b8187f0, 0x2b818800, 0x2be70000)

Dynamic libraries:
0x00400000 - 0x0040d000 	C:\Program Files\Java\jdk1.5.0_09\bin\java.exe
0x77f50000 - 0x77ff7000 	C:\WINDOWS\System32\ntdll.dll
0x77e60000 - 0x77f46000 	C:\WINDOWS\system32\kernel32.dll
0x77dd0000 - 0x77e5d000 	C:\WINDOWS\system32\ADVAPI32.dll
0x78000000 - 0x78087000 	C:\WINDOWS\system32\RPCRT4.dll
0x77c10000 - 0x77c63000 	C:\WINDOWS\system32\MSVCRT.dll
0x6d730000 - 0x6d8cb000 	C:\Program Files\Java\jdk1.5.0_09\jre\bin\client\jvm.dll
0x77d40000 - 0x77dcd000 	C:\WINDOWS\system32\USER32.dll
0x7f000000 - 0x7f042000 	C:\WINDOWS\system32\GDI32.dll
0x76b40000 - 0x76b6c000 	C:\WINDOWS\System32\WINMM.dll
0x76390000 - 0x763ac000 	C:\WINDOWS\System32\IMM32.DLL
0x629c0000 - 0x629c8000 	C:\WINDOWS\System32\LPK.DLL
0x72fa0000 - 0x72ffa000 	C:\WINDOWS\System32\USP10.dll
0x6d2f0000 - 0x6d2f8000 	C:\Program Files\Java\jdk1.5.0_09\jre\bin\hpi.dll
0x76bf0000 - 0x76bfb000 	C:\WINDOWS\System32\PSAPI.DLL
0x6d700000 - 0x6d70c000 	C:\Program Files\Java\jdk1.5.0_09\jre\bin\verify.dll
0x6d370000 - 0x6d38d000 	C:\Program Files\Java\jdk1.5.0_09\jre\bin\java.dll
0x6d720000 - 0x6d72f000 	C:\Program Files\Java\jdk1.5.0_09\jre\bin\zip.dll
0x10000000 - 0x1004b000 	C:\WINDOWS\system32\lwjgl.dll
0x72280000 - 0x722a8000 	C:\WINDOWS\System32\DINPUT.dll
0x4fec0000 - 0x4ffe6000 	C:\WINDOWS\system32\ole32.dll
0x5ed00000 - 0x5edc6000 	C:\WINDOWS\System32\OPENGL32.dll
0x68b20000 - 0x68b3e000 	C:\WINDOWS\System32\GLU32.dll
0x51000000 - 0x51050000 	C:\WINDOWS\System32\DDRAW.dll
0x73bc0000 - 0x73bc6000 	C:\WINDOWS\System32\DCIMAN32.dll
0x77c00000 - 0x77c07000 	C:\WINDOWS\system32\VERSION.dll
0x5ad70000 - 0x5ada4000 	C:\WINDOWS\System32\uxtheme.dll
0x06ea0000 - 0x06ecb000 	C:\WINDOWS\System32\msctfime.ime
0x69500000 - 0x6981e000 	C:\WINDOWS\System32\nvoglnt.dll
0x746f0000 - 0x74716000 	C:\WINDOWS\System32\Msimtf.dll
0x74720000 - 0x74764000 	C:\WINDOWS\System32\MSCTF.dll
0x7c890000 - 0x7c910000 	C:\WINDOWS\System32\CLBCATQ.DLL
0x77120000 - 0x771ab000 	C:\WINDOWS\system32\OLEAUT32.dll
0x77050000 - 0x77115000 	C:\WINDOWS\System32\COMRes.dll
0x6ce10000 - 0x6ce45000 	C:\WINDOWS\System32\dinput8.dll
0x688f0000 - 0x688f9000 	C:\WINDOWS\System32\HID.DLL
0x76670000 - 0x76757000 	C:\WINDOWS\System32\SETUPAPI.DLL
0x6d070000 - 0x6d1d9000 	C:\Program Files\Java\jdk1.5.0_09\jre\bin\awt.dll
0x73000000 - 0x73023000 	C:\WINDOWS\System32\WINSPOOL.DRV
0x0c1e0000 - 0x0c2d6000 	C:\WINDOWS\System32\OpenAL32.dll
0x51080000 - 0x510e1000 	C:\WINDOWS\System32\dsound.dll
0x72d20000 - 0x72d29000 	C:\WINDOWS\System32\wdmaud.drv
0x72d10000 - 0x72d18000 	C:\WINDOWS\System32\msacm32.drv
0x77be0000 - 0x77bf4000 	C:\WINDOWS\System32\MSACM32.dll
0x77bd0000 - 0x77bd7000 	C:\WINDOWS\System32\midimap.dll
0x5ef80000 - 0x5ef84000 	C:\WINDOWS\System32\KsUser.dll

VM Arguments:
java_command: Main
Launcher Type: SUN_STANDARD

Environment Variables:
PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\flexlm\bin;C:\Ptc\promechWildfire\bin;C:\Program Files\Common Files\Autodesk Shared\
USERNAME=asi preshel
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 6 Model 9 Stepping 5, GenuineIntel



---------------  S Y S T E M  ---------------

OS: Windows XP Build 2600 Service Pack 1

CPU:total 1 (cores per cpu 1, threads per core 1) family 6 model 9 stepping 5, cmov, cx8, fxsr, mmx, sse, sse2

Memory: 4k page, physical 261104k(97844k free), swap 639152k(289400k free)

vm_info: Java HotSpot(TM) Client VM (1.5.0_09-b03) for windows-x86, built on Oct 12 2006 01:20:10 by "java_re" with MS VC++ 6.0


first of all, its a bad idea to place natives in: C:\WINDOWS\system32
secondly, assuming you create a display before calling ANY OpenGL commands, then it would appear that you’re passing some invalid data to GL11.glDrawArrays
Check your parameters