Hello. In my previous thread I figured out how to render directly to a Canvas using JAWT and EGL+GLES
http://forum.lwjgl.org/index.php?topic=6970.0But now I have a different problem. The Application that I'm supposed to integrate this into is built using jLayeredFrame. However if I put my Canvas into it - the canvas is invisible on all layers except the topmost one. In other words, if anything else should be drawn on top of my Canvas - it completely disappears.
I tried putting it into jPanel as a container, and it exhiboits the same behavior. If jPanel is the topmost element - both it and Canvas can be drawn. If it's below something - only jPanel gets drawn, but not the canvas.
Anyway, if jPanel works, I thought I would render to that instead. However, I can't figure it out. Here's a bit of code:
private Canvas canvas;
private JPanel panel;
private JAWTDrawingSurface ds;
public long display;
private long eglDisplay;
public long drawable;
private long surface;
public static final JAWT awt;
static {
awt = JAWT.calloc();
awt.version(JAWT_VERSION_1_4);
if (!JAWT_GetAWT(awt))
throw new AssertionError("GetAWT failed");
}
public void Init2()
{
int error;
System.out.println("Window init2() started");
this.ds = JAWT_GetDrawingSurface(panel, awt.GetDrawingSurface());
//JAWTDrawingSurface ds = JAWT_GetDrawingSurface(canvas, awt.GetDrawingSurface());
try
{
lock();
try
{
JAWTDrawingSurfaceInfo dsi = JAWT_DrawingSurface_GetDrawingSurfaceInfo(ds, ds.GetDrawingSurfaceInfo());
JAWTX11DrawingSurfaceInfo dsiWin = JAWTX11DrawingSurfaceInfo.create(dsi.platformInfo());
int depth = dsiWin.depth();
this.display = dsiWin.display();
this.drawable = dsiWin.drawable();
long x = dsiWin.colormapID();
long y = dsiWin.visualID();
System.out.printf("EGL Display %d, drawable: \n", display, drawable);
eglDisplay = eglGetDisplay(display);
error = eglGetError();
EGLCapabilities egl;
try (MemoryStack stack = stackPush()) {
IntBuffer major = stack.mallocInt(1);
IntBuffer minor = stack.mallocInt(1);
if (!eglInitialize(eglDisplay, major, minor)) {
throw new IllegalStateException(String.format("Failed to initialize EGL [0x%X]", eglGetError()));
}
egl = EGL.createDisplayCapabilities(eglDisplay, major.get(0), minor.get(0));
}
System.out.println("EGL caps created");
error = eglGetError();
IntBuffer attrib_list = BufferUtils.createIntBuffer(18);
attrib_list.put(EGL_CONFORMANT).put(EGL_OPENGL_ES2_BIT);
attrib_list.put(EGL_DEPTH_SIZE).put(24);
attrib_list.put(EGL_NONE);
attrib_list.flip();
PointerBuffer fbConfigs = BufferUtils.createPointerBuffer(1);
IntBuffer numConfigs = BufferUtils.createIntBuffer(1);
boolean test2 = eglChooseConfig(eglDisplay, attrib_list, fbConfigs,numConfigs);
if (fbConfigs == null || fbConfigs.capacity() == 0) {
// No framebuffer configurations supported!
System.out.println("No supported framebuffer configurations found");
}
long test = numConfigs.get(0);
IntBuffer context_attrib_list = BufferUtils.createIntBuffer(18);
context_attrib_list.put(EGL_CONTEXT_MAJOR_VERSION).put(3);
context_attrib_list.put(EGL_CONTEXT_MINOR_VERSION).put(0);
context_attrib_list.put(EGL_NONE);
context_attrib_list.flip();
long context = eglCreateContext(eglDisplay,fbConfigs.get(0),EGL_NO_CONTEXT,context_attrib_list);
error = eglGetError();
surface = eglCreateWindowSurface(eglDisplay,fbConfigs.get(0),drawable,(int[])null);
error = eglGetError();
eglMakeCurrent(eglDisplay,surface,surface,context);
error = eglGetError();
GLESCapabilities gles = GLES.createCapabilities();
System.out.println("CLES caps created");
JAWT_DrawingSurface_FreeDrawingSurfaceInfo(dsi, ds.FreeDrawingSurfaceInfo());
}
finally
{
unlock();
}
}
catch (Exception e)
{
System.out.println("JAWT Failed");
}
if I pass Canvas to JAWT_GetDrawingSurface() - everything works fine.
But if I pass the jPanel - then it SEEMS to work fine, except not really. It doesn't throw any exceptions, and the display seems to be all good - both EGL and GLES are initialized just fine through it. The FrameBuffer objects are also correctly found.
But when it comes to eglCreateWindowSurface() - it generated EGL_BAD_ALLOC error code.
Also, you can see that something is wrong on the int depth = dsiWin.depth(); line. Because this parameter is supposed to be depth buffer size in bits for rendering context - and with Canvas it equals to 24. With jPanel it equals 32638 - which is OBVIOUSLY wrong. I suspect that while the display info is correct - everything else isn't, including drawable address, and thus you get EGL_BAD_ALLOC.
Which is a bit strange, because JAWT_GetDrawingSurface() requires awt.Component as input, which both Canvas and jPanel inherit from.
But anyway, can someone help me figure it out?