STBTrueType fails with new driver

Started by Waffles, August 02, 2015, 22:46:48

Previous topic - Next topic

Waffles

So a few days ago I finally managed to get STBTrueType working. Then yesterday, I updated my NVIDIA drivers, and everything started failing again. After trying just about everything short of a goat sacrifice, on a whim I decided to fiddle around with my window hints. I removed the hints that explicitly assign an OpenGL profile and, like magic, my font rendering worked again.

Using this line, the font rendering doesn't work:
GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_PROFILE, GLFW.GLFW_OPENGL_CORE_PROFILE);


Using this line, it does:
GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_PROFILE, GLFW.GLFW_OPENGL_COMPAT_PROFILE);


I'm not quite sure what's going on here, does STBTrueType depend on some deprecated functions or something? Although I suppose that doesn't make any sense, since it worked just a few days ago? To be fair, my NVIDIA drivers were supposed to be updated a few months ago, but I'm not sure that should make any difference, should it?

Cornix

Drivers can have bugs too. It might be that either the new ones are too strict, or the old ones were not strict enough.
However, I dont know what is causing the problem with STBTrueType; I have not worked with it yet.

spasi

STB does not call any OpenGL functions internally. It sounds like you're using deprecated functionality to render the font texture, which is not available under the core profile. What error are you getting exactly? Try a debug context with a debug message callback and also use "-Dorg.lwjgl.util.Debug=true" when launching the JVM.

Waffles

When using the core profile I get all the quads rendered in the right place, but with a completely black texture. I also tried simply rendering the entire texture created by STB on screen and it shows up completely black. I've been rendering it with a very basic vertex & fragment shader; multiply vertex by matrix, output texture. I can't imagine using deprecated functionality, since I'm using the same shader program for my regular textures and those still seem to work under the core profile..

Anyways, when I enable the debug I get the following output:

[LWJGL] Version 3.0.0a | Windows 8.1 | amd64
[LWJGL] MemoryUtil MemoryAccessor: MemoryAccessorUnsafe
[LWJGL] Failed to locate address for GL function glNamedBufferPageCommitmentARB
[LWJGL] [GL] GL_ARB_sparse_buffer was reported as available but an entry point is missing.
[LWJGL] Failed to locate address for GL function wglCopyImageSubDataNV
[LWJGL] [GL] WGL_NV_copy_image was reported as available but an entry point is missing.


By debug message callback do you mean the thing set by GLWF.glwfSetErrorCallback? That's not throwing any errors at any rate.

spasi

Quote from: Zeno on August 03, 2015, 23:14:23By debug message callback do you mean the thing set by GLWF.glwfSetErrorCallback? That's not throwing any errors at any rate.

I meant the OpenGL debug functionality. It is provided by a few different extensions, but LWJGL provides a shortcut that makes it easy to setup:

glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);
// ..create window..
glfwMakeContextCurrent(window);
Closure debugProc = GLContext.createFromCurrent().setupDebugMessageCallback();


Make sure to store the debugProc closure so that it doesn't get GCed, just like GLFW callbacks.

(also note that the above code is for 3.0.0a and is slightly different in the latest LWJGL 3.0.0b build)

Waffles

Yes, that did give some more information on the problem.

During this call buffering the font data an error is thrown:
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_ALPHA, tsize, tsize, 0, GL11.GL_ALPHA, GL11.GL_UNSIGNED_BYTE, data)


GL_ALPHA is apparently invalid as an internalformat. A bit of snooping around revealed that GL_ALPHA is no longer useable in the core profile. I got these values from the demo at GitHub, which doesn't use the core profile to begin with, so that explains a lot.

I didn't give this a second thought before this issue, but am I right in thinking this means STB's font data uses a single float value per pixel? So I need to use GL_RED instead, and swap it around to the alpha channel in my fragment shader?

spasi

Quote from: Zeno on August 04, 2015, 10:50:40I didn't give this a second thought before this issue, but am I right in thinking this means STB's font data uses a single float value per pixel?

It's an unsigned byte per pixel, not a float.

Cornix

To answer your question: Yes, you need to use GL_RED.

Waffles

Ok great, I imagine I should get it to work now, thank you very much.