GL20.glGetShaderInfoLog returns an empty bytebuffer?

Started by CuppoJava, May 27, 2009, 00:17:02

Previous topic - Next topic

CuppoJava

Hi,
I'm having a hard time getting GL20.glGetShaderInfoLog to work. I'm wondering whether it's my problem, or whether it's LWJGL, or even whether it's my graphics card (Intel 9400m on a Macbook)

IntBuffer intbuffer = IntBuffer.allocate(1);
ByteBufer infobuffer = ByteBuffer.allocate(32768);
GL20.glGetShaderInfoLog(shader, intbuffer, infobuffer);

intbuffer has one element (113),
but infobuffer is still full of zeroes.

Am I doing something wrong?
Thanks a lot for your help
  -Patrick

Ciardhubh

I have a similar problem with a small game of mine on Mac:
http://lwjgl.org/forum/index.php/topic,2837.msg15659.html#msg15659

However, I don't just get an empty buffer but the game crashes altogether with a rather nasty exception, when I query the info log. Unfortunately I don't have access to a Mac, so I couldn't find a solution. Everything works fine on two windows PCs.

By the way, you don't have to allocate such a large infobuffer. You can query the info log length before getting the log:
        IntBuffer infoLogLength = BufferUtils.createIntBuffer(1);
        GL20.glGetShader(shaderName, GL20.GL_INFO_LOG_LENGTH, infoLogLength);
        ByteBuffer infoLog = BufferUtils.createByteBuffer(infoLogLength.get(0));
        infoLogLength.clear();
        GL20.glGetShaderInfoLog(shaderName, infoLogLength, infoLog);
        byte[] infoLogBytes = new byte[infoLogLength.get(0)];
        infoLog.get(infoLogBytes, 0, infoLogLength.get(0));

CuppoJava

Thanks very much Clardhubh for the reply.
My game isn't crashing. Which is good. It's not a show-stopper for me.

But it's going to be a pain to debug any shader longer than three lines, if I can't get access to the info log.

It would be ideal, if someone that got the shader info log to work on a mac, post his code. Or at least let us know that it's possible.

Thanks a lot for your help
  -Patrick

Fool Running

I think your buffer is filled with zeros because you are using a ByteBuffer that is backed by an array instead of a native buffer.
I had the same issue trying to get pixel information using a ByteBuffer that was backed by an array. When I used a native buffer, it worked fine.

This was in Linux, but I'm guessing it would be the same on every platform.
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

CuppoJava

That was exactly my problem Fool Running! Thank you very much.

Do you have any general rules for when to use direct vs. non-direct buffers? I've been using array-backed buffers the entire time, and it's worked so far for every function except glGetShaderInfoLog.

Fool Running

I think the time it might make the most difference is getting data from OpenGL. Sending data seems to work fine using array backed buffers.

I'm not really sure about that, though. ;D
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

Ciardhubh

Quote from: CuppoJava on May 28, 2009, 17:48:08
That was exactly my problem Fool Running!

So it wasn't the same as my problem after all. Then again, if non-direct buffers worked for you in other OpenGL calls, glGetShaderInfoLog might treat buffers differently in general.

Would you mind trying my game, please? I'd love to know whether it runs on Mac at all or whether it was just an isolated incident.

Direct Web Start link:
http://ciardhubh.de/games/space_folds/SpaceFolds.jnlp

Thread:
http://lwjgl.org/forum/index.php/topic,2837.msg15659.html

elias

The templates seem to miss checks for direct buffers. I'll poke spasi :o)

  - elias

spasi