Dynamic texture update crashes

Started by Burhan1976, October 18, 2006, 21:48:05

Previous topic - Next topic

Burhan1976

Hello,
When I load the scene, everyrhing goes fine, and textures load correctly, but when I need to change the texture, to make a different scene, (and this is done by opening a file, read the textures pixels into buffers) this is fine too, but when I want to create buffers indecies where I use the same texture generator function, every thing crashes, with a long long message saying that there's an error happened outside the VM in the native code.

How is the same function fails if used in the real time updating?
I thought the textures aren't loaded correctly from the file, but I check for that, and it isn't the problem.
I think the problem is in these lines:

GL11.glGenTextures(struct.tob[num].AddressBuf);

   GL11.glBindTexture(GL11.GL_TEXTURE_2D, struct.tob[num].AddressBuf.get(0));

Thanx in Advance

Fool Running

Can you post the real long VM message? (maybe only the stack trace :D )

My best guess is that you need to put a struct.tob[num].AddressBuf.clear() before you call GL11.glGenTextures(struct.tob[num].AddressBuf);
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

Burhan1976

Ok, I do the clear() whenever I use the buffer, so it's not the problem,
I'll post the texture loader function, and the real long message

-------------------------------------------------------------------------
THE CODE:
-------------------------------------------------------------------------
//TEXTURE LOADER FUNCTION, pass the:
//as: for(LOOP by i) => texture = loadTextre(i)

private int loadTexture(int num) {
   int type = GL11.GL_RGB;
   
   GL11.glGenTextures(struct.tob[num].AddressBuf); // Create Texture In OpenGL

   GL11.glBindTexture(GL11.GL_TEXTURE_2D, struct.tob[num].AddressBuf.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, type, struct.tob[num].Width, struct.tob[num].Height, 0, type, GL11.GL_UNSIGNED_BYTE,struct.tob[num].PixelBuf);

   return struct.tob[num].AddressBuf.get(0);
 }
--------------------------------------------------------------------------------
This function works ok when used first time, but when I need to change
the textures, it fails, I tried to skip this function by calling glGenTextures..
or glBindTexture.. etc inside the function responsible for the change, same thing happens. So I suspect one of these commands is the problem.

-------------------------------------------------------------------------------
THE POST WHEN CRASH
-------------------------------------------------------------------------------

An unexpected exception has been detected in native code outside the VM.
Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred at PC=0x6961B226
Function=[Unknown.]
Library=C:\WINDOWS\system32\nvoglnt.dll

NOTE: We are unable to locate the function name symbol for the error
     just occurred. Please refer to release documentation for possible
     reason and solutions.


Current Java thread:
   at org.lwjgl.opengl.GL11.glBindTexture(Native Method)
   at avu.AvuMain.nextScene(AvuMain.java:567)
   at toolbox.ToolBox.nextScene(ToolBox.java:184)
   at toolbox.ToolBox$2.actionPerformed(ToolBox.java:150)
   at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)
   at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839)
   at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
   at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
   at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
   at java.awt.Component.processMouseEvent(Component.java:5100)
   at java.awt.Component.processEvent(Component.java:4897)
   at java.awt.Container.processEvent(Container.java:1569)
   at java.awt.Component.dispatchEventImpl(Component.java:3615)
   at java.awt.Container.dispatchEventImpl(Container.java:1627)
   at java.awt.Component.dispatchEvent(Component.java:3477)
   at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
   at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)
   at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
   at java.awt.Container.dispatchEventImpl(Container.java:1613)
   at java.awt.Window.dispatchEventImpl(Window.java:1606)
   at java.awt.Component.dispatchEvent(Component.java:3477)
   at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
   at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
   at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)

Dynamic libraries:
0x00400000 - 0x00407000    C:\JBuilderX\jdk1.4\bin\javaw.exe
0x7C900000 - 0x7C9B0000    C:\WINDOWS\system32\ntdll.dll
0x7C800000 - 0x7C8F4000    C:\WINDOWS\system32\kernel32.dll
0x77DD0000 - 0x77E6B000    C:\WINDOWS\system32\ADVAPI32.dll
0x77E70000 - 0x77F01000    C:\WINDOWS\system32\RPCRT4.dll
0x77D40000 - 0x77DD0000    C:\WINDOWS\system32\USER32.dll
0x77F10000 - 0x77F56000    C:\WINDOWS\system32\GDI32.dll
0x77C10000 - 0x77C68000    C:\WINDOWS\system32\MSVCRT.dll
0x629C0000 - 0x629C9000    C:\WINDOWS\system32\LPK.DLL
0x74D90000 - 0x74DFB000    C:\WINDOWS\system32\USP10.dll
0x08000000 - 0x08136000    C:\JBuilderX\jdk1.4\jre\bin\client\jvm.dll
0x76B40000 - 0x76B6D000    C:\WINDOWS\system32\WINMM.dll
0x5CD70000 - 0x5CD77000    C:\WINDOWS\system32\serwvdrv.dll
0x5B0A0000 - 0x5B0A7000    C:\WINDOWS\system32\umdmxfrm.dll
0x10000000 - 0x10007000    C:\JBuilderX\jdk1.4\jre\bin\hpi.dll
0x00940000 - 0x0094E000    C:\JBuilderX\jdk1.4\jre\bin\verify.dll
0x00950000 - 0x00968000    C:\JBuilderX\jdk1.4\jre\bin\java.dll
0x00970000 - 0x0097D000    C:\JBuilderX\jdk1.4\jre\bin\zip.dll
0x02F60000 - 0x0306F000    C:\JBuilderX\jdk1.4\jre\bin\awt.dll
0x73000000 - 0x73026000    C:\WINDOWS\system32\WINSPOOL.DRV
0x76390000 - 0x763AD000    C:\WINDOWS\system32\IMM32.dll
0x774E0000 - 0x7761C000    C:\WINDOWS\system32\ole32.dll
0x03080000 - 0x030D0000    C:\JBuilderX\jdk1.4\jre\bin\fontmanager.dll
0x73760000 - 0x737A9000    C:\WINDOWS\system32\ddraw.dll
0x73BC0000 - 0x73BC6000    C:\WINDOWS\system32\DCIMAN32.dll
0x73940000 - 0x73A10000    C:\WINDOWS\system32\D3DIM700.DLL
0x07790000 - 0x077CF000    D:\Work\Panorama\Code\lwjgl92\lwjgl.dll
0x72280000 - 0x722AA000    C:\WINDOWS\system32\DINPUT.dll
0x5ED00000 - 0x5EDCC000    C:\WINDOWS\system32\OPENGL32.dll
0x68B20000 - 0x68B40000    C:\WINDOWS\system32\GLU32.dll
0x77C00000 - 0x77C08000    C:\WINDOWS\system32\VERSION.dll
0x69500000 - 0x6986B000    C:\WINDOWS\system32\nvoglnt.dll
0x688F0000 - 0x688F9000    C:\WINDOWS\system32\HID.DLL
0x77920000 - 0x77A13000    C:\WINDOWS\system32\SETUPAPI.DLL
0x76C30000 - 0x76C5E000    C:\WINDOWS\system32\WINTRUST.dll
0x77A80000 - 0x77B14000    C:\WINDOWS\system32\CRYPT32.dll
0x77B20000 - 0x77B32000    C:\WINDOWS\system32\MSASN1.dll
0x76C90000 - 0x76CB8000    C:\WINDOWS\system32\IMAGEHLP.dll
0x59A60000 - 0x59B01000    C:\WINDOWS\system32\DBGHELP.dll
0x76BF0000 - 0x76BFB000    C:\WINDOWS\system32\PSAPI.DLL

Heap at VM Abort:
Heap
def new generation   total 576K, used 395K [0x10010000, 0x100b0000, 0x104f0000)
 eden space 512K,  74% used [0x10010000, 0x1006f9c0, 0x10090000)
 from space 64K,  20% used [0x10090000, 0x10093490, 0x100a0000)
 to   space 64K,   0% used [0x100a0000, 0x100a0000, 0x100b0000)
tenured generation   total 2276K, used 1605K [0x104f0000, 0x10729000, 0x14010000)
  the space 2276K,  70% used [0x104f0000, 0x10681598, 0x10681600, 0x10729000)
compacting perm gen  total 4352K, used 4287K [0x14010000, 0x14450000, 0x18010000)
  the space 4352K,  98% used [0x14010000, 0x1443ffb8, 0x14440000, 0x14450000)

Local Time = Thu Oct 19 01:03:16 2006
Elapsed Time = 2
#
# The exception above was detected in native code outside the VM
#
# Java VM: Java HotSpot(TM) Client VM (1.4.2_01-b06 mixed mode)
#
----------------------------------------------------------------------------------
That's it  :D

I thought that it maybe illegal to change the buffer on realtime (after initialzation took place) and tried to use glTexSubImage maybe but I don't have any resources of how to use this command.

Thanx in advance

darkprophet

Sorry, i dont understand...are you modifying an already created texture using glTexSubImage2D ? Or are you dynamically creating a new one?

If you are creating a new one, then you would need the glGenTextures stuff, after which, you would bind the texture and use glTexImage2D to send the data to the server side of OGL, then set the correct mipmaping functions.

I remember getting a native crash with vertex buffer objects because i didn't fill the VBO with data...this might be similar.

DP

Burhan1976

:D  :D  :D

Guess what, I solved the problem, it has nothing to do with my code.
The only reason it crashes is that I'm calling the load function from a JFrame, that's it!!!

I replaced the calling by a flag, the flag is set by the JFrame, and the loading happens when the loop reads the flag = true;
THAT'S IT.

Thanx in Advance. :D

darkprophet

Thats really strange, in the case of unproper multithreaded usage (like what you were doing), glGenTextures should have thrown an NPE because the context of that thread is NULL...


Ah well, glad that you fixed it :)