Hello everyone,
Is there a way not to add my GLCanvas or GLJPanel to a JFrame?
I do not need to see the rendered result of my code.
Cheers
–
amehio
Hello everyone,
Is there a way not to add my GLCanvas or GLJPanel to a JFrame?
I do not need to see the rendered result of my code.
Cheers
–
amehio
What are you doing with your code then ?
I think he might be interested in PBuffers for accelerated offscreen rendering.
Hello,
Riven, I am looking for accelerated offscreen rendering. I need to create a GLContext without the need to append my GLCanvas or GLJPanel to frame.
What I have tried is the following:
Create a GLCanvas and added to it GLEventListener. The application is crashing when calling
GL gl = drawable.getGL();
Debugging shows that “drawable” is returning a “null” reference to the “GLContext”.
Any clue on how to overcome this?
Meanwhile, I will do some search about PBuffers, but I still would appreciate some help from here.
Thanks
–
amehio
As Riven points out the way to do what you are after is by using a pbuffer. If you have a GLEventListener working already then if your card supports pbuffers (and all modern cards do) then you can just plug your GLEventListener into the pbuffer instead of the GLCanvas and call GLPbuffer.display().
I did look at GLPbuffer. Pbuffer does exactly what FBO (Framebuffer Object ) does which I am using in one of the GLEventListener methods.
This brings me to the following two questions:
Thanks
IIRC, FBOs can only be created from a valid GL-context, that is: either a GL-canvas or a PBuffer.
When running the below code, I am getting an ACCESS_EXCEPTION_VIOLATION (which I copied and paster right after the code).
Any clues of what that means? Is that a problem in the implementation of gl.glDeleteFramebuffersEXT (since it says that it is a native code error)?
Any proposed solutions?
Thanks in advance!!
public class Jogl_FBO_Test{
public static void main(String[] args) {
GLCapabilities capabilities = new GLCapabilities();
capabilities.setOffscreenFloatingPointBuffers(true);
capabilities.setOffscreenRenderToTexture(true);
capabilities.setOffscreenRenderToTextureRectangle(true);
GLPbuffer pbuffer = GLDrawableFactory.getFactory().createGLPbuffer(capabilities, null, 2 ,2, null);
JoglEventListener listener = new JoglEventListener( 2, 2, 1);
pbuffer.addGLEventListener(listener);
pbuffer.display();
pbuffer.destroy();
}
}
class JoglEventListener implements GLEventListener {
private GLU glu = new GLU();
private int attachmentpoints[] = { GL.GL_COLOR_ATTACHMENT0_EXT, GL.GL_COLOR_ATTACHMENT1_EXT };
public JoglEventListener() {
}
public void init(GLAutoDrawable drawable) {
// CREATING MY OWN TEXTURES
float[] texture1 = new float[64];
float[] texture2 = new float[64];
int[] texID = new texID[2];
GL gl = drawable.getGL();
gl = drawable.getGL();
gl.glMatrixMode( GL.GL_PROJECTION);
gl.glLoadIdentity();
glu.gluOrtho2D( 0.0, width, 0.0, height);
gl.glMatrixMode( GL.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glViewport( 0, 0, width, height);
// GENERATE AND SET MY TEXTURES
// generateTexture(texture1);
// generateTexture(texture2);
int[] fb = new int[1];
gl.glGenFramebuffersEXT(1, fb, 0);
gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, fb[0]);
// ATTACHING MY TEXTURES TO THE FBO
// gl.glFramebufferTexture2DEXT(GL.GL_FRAMEBUFFER_EXT, attachmentpoints[0], GL.GL_TEXTURE_RECTANGLE_ARB, texID[0], 0);
// gl.glFramebufferTexture2DEXT(GL.GL_FRAMEBUFFER_EXT, attachmentpoints[1], GL.GL_TEXTURE_RECTANGLE_ARB, texID[1], 0);
// RUNNING SOME CODE ..
// and read back
gl.glReadBuffer(attachmentpoints[write]);
gl.glReadPixels(0, 0, width, height, GL.GL_RGBA, GL.GL_FLOAT, FloatBuffer.wrap(texture2));
// destroy texture and framebuffer
gl.glDeleteFramebuffersEXT(GL.GL_FRAMEBUFFER_EXT, fb, 0);
gl.glDeleteTextures(GL.GL_TEXTURE_RECTANGLE_ARB, texID, 0);
}
// IMPLEMENTATION OF OTHER METHOD IN THE GLEVENTLISTENER INTERFACE
}
TEXT OF THE EXCEPTION_ACCESS_VIOLATION
An unexpected exception has been detected in native code outside the VM.
Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred at PC=0x695EDA78
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 com.sun.opengl.impl.GLImpl.dispatch_glDeleteFramebuffersEXT1(Native Method)
at com.sun.opengl.impl.GLImpl.glDeleteFramebuffersEXT(GLImpl.java:2916)
at JoglEventListener.init(JOGL_Test.java:169)
at com.sun.opengl.impl.GLDrawableHelper.init(GLDrawableHelper.java:71)
at com.sun.opengl.impl.GLPbufferImpl$InitAction.run(GLPbufferImpl.java:204)
at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:123)
at com.sun.opengl.impl.GLPbufferImpl$DisplayOnEventDispatchThreadAction.run(GLPbufferImpl.java:229)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:171)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
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:\j2sdk1.4.2_03\jre\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 - 0x77F57000 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 - 0x08138000 C:\j2sdk1.4.2_03\jre\bin\client\jvm.dll
0x76B40000 - 0x76B6D000 C:\WINDOWS\system32\WINMM.dll
0x6BD00000 - 0x6BD0D000 C:\WINDOWS\system32\SYNCOR11.DLL
0x10000000 - 0x10007000 C:\j2sdk1.4.2_03\jre\bin\hpi.dll
0x00940000 - 0x0094E000 C:\j2sdk1.4.2_03\jre\bin\verify.dll
0x00950000 - 0x00969000 C:\j2sdk1.4.2_03\jre\bin\java.dll
0x00970000 - 0x0097D000 C:\j2sdk1.4.2_03\jre\bin\zip.dll
0x02F60000 - 0x02FA7000 C:\j2sdk1.4.2_03\jre\bin\jogl.dll
0x5ED00000 - 0x5EDCC000 C:\WINDOWS\system32\OPENGL32.dll
0x68B20000 - 0x68B40000 C:\WINDOWS\system32\GLU32.dll
0x73760000 - 0x737A9000 C:\WINDOWS\system32\DDRAW.dll
0x73BC0000 - 0x73BC6000 C:\WINDOWS\system32\DCIMAN32.dll
0x034B0000 - 0x035BF000 C:\j2sdk1.4.2_03\jre\bin\awt.dll
0x73000000 - 0x73026000 C:\WINDOWS\system32\WINSPOOL.DRV
0x76390000 - 0x763AD000 C:\WINDOWS\system32\IMM32.dll
0x774E0000 - 0x7761D000 C:\WINDOWS\system32\ole32.dll
0x5AD70000 - 0x5ADA8000 C:\WINDOWS\system32\uxtheme.dll
0x03630000 - 0x03680000 C:\j2sdk1.4.2_03\jre\bin\fontmanager.dll
0x73940000 - 0x73A10000 C:\WINDOWS\system32\D3DIM700.DLL
0x74720000 - 0x7476B000 C:\WINDOWS\system32\MSCTF.dll
0x69500000 - 0x69A37000 C:\WINDOWS\system32\nvoglnt.dll
0x04AB0000 - 0x04C5C000 C:\Program Files\NVIDIA Corporation\Cg\bin\cg.dll
0x04C60000 - 0x04CA1000 C:\Program Files\NVIDIA Corporation\Cg\bin\cgGL.dll
0x04CC0000 - 0x04CDC000 C:\j2sdk1.4.2_03\jre\bin\jogl_cg.dll
0x76C90000 - 0x76CB8000 C:\WINDOWS\system32\imagehlp.dll
0x59A60000 - 0x59B01000 C:\WINDOWS\system32\DBGHELP.dll
0x77C00000 - 0x77C08000 C:\WINDOWS\system32\VERSION.dll
0x76BF0000 - 0x76BFB000 C:\WINDOWS\system32\PSAPI.DLL
Heap at VM Abort:
Heap
def new generation total 576K, used 50K [0x10010000, 0x100b0000, 0x104f0000)
eden space 512K, 5% used [0x10010000, 0x10016940, 0x10090000)
from space 64K, 37% used [0x100a0000, 0x100a5ec0, 0x100b0000)
to space 64K, 0% used [0x10090000, 0x10090000, 0x100a0000)
tenured generation total 1408K, used 876K [0x104f0000, 0x10650000, 0x14010000)
the space 1408K, 62% used [0x104f0000, 0x105cb318, 0x105cb400, 0x10650000)
compacting perm gen total 5120K, used 5016K [0x14010000, 0x14510000, 0x18010000)
the space 5120K, 97% used [0x14010000, 0x144f61f0, 0x144f6200, 0x14510000)
Local Time = Tue Feb 07 16:03:54 2006
Elapsed Time = 1
First, take out all of the settings of the GLCapabilities’ offscreen bits. Those are only for use when rendering to a pbuffer as opposed to an FBO and are likely to cause problems. Second, the setup of your FBO looks very wrong to me. I’m not an FBO expert but first of all you’re not checking for framebuffer completeness, second you didn’t bind the FBO anywhere, and third you don’t need to read back the pixels if you’re trying to render into an OpenGL texture. I’d suggest you look for an FBO example or tutorial. A quick web search turned up this link for example (found by searching for “EXT_framebuffer_object example”).