Login  Register

LWJGL-FX (fast JavaFX integration) port to JOGL

Posted by aqd on Aug 16, 2014; 5:29pm
URL: https://forum.jogamp.org/LWJGL-FX-fast-JavaFX-integration-port-to-JOGL-tp4032802.html

Hello guys! I just ported the LWJGL-FX (fast JavaFX/OpenGL integration) to JOGL. I wonder how I should implement the following stuff correctly?
  1. org.lwjgl.opengl.ContextCapabilities has a huge numbers of boolean fields such as "GL_ATI_fragment_shader" etc, indicating the availability of each extensions. Where are these in JOGL? (not by getExtension("extension name") I hope...)

  2. In their AMD specific RenderStream there is:
    			final ByteBuffer buffer = BufferUtils.createByteBuffer(renderBytes + PAGE_SIZE);
    			final int pageOffset = (int)(MemoryUtil.getAddress(buffer) % PAGE_SIZE);
    			buffer.position(PAGE_SIZE - pageOffset); // Aligns to page
    			buffer.limit(buffer.capacity() - pageOffset); // Caps remaining() to renderBytes
    			pinnedBuffers[i] = buffer.slice().order(ByteOrder.nativeOrder());
    			gl.glBufferData(GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, pinnedBuffers[i].remaining(), pinnedBuffers[i], GL_STREAM_READ);

    which seems to rely on the physical position of buffer object (the MemoryUtil.getAddress is to native call), but wouldn't it just break if GC happens to move objects around?? I set the offset to be always 0 in my port and it's still working, with no apparent performance penalty

    EDIT: I tested ported AMD code - the glBufferData(GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD failed with GL_INVALID_ENUM​: Invalid binding target, thrown by jogamp.opengl.GLBufferStateTracker.checkTargetName! (but works in LWJGL). I modified GLBufferStateTracker to allow it and now it seems to work fine!



  3. They have many calls such as
    glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY, height * stride, pinnedBuffers[index]);
    which is non-standard. The last argument (buffer) can be ignored, but they also send the parameter length which only exists in glMapBufferRange. It's said in LWJGL docs the parameter is meant to speed things up, but when I use JOGL's glMapBufferRange(target, offset=0, length, access) it always returns null. The standard glMapBuffer(target, access) works for me however. But why?

  4. Why in JOGL document it says GLContext.getGL() may return null outside of GLEventListener calls? In GLPanel it seems available after GLContext.makeCurrent(), which works for my port too. Should I worry about it being changed into null?