Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rendering not working on my Ubuntu 13.10/Linux system #3

Closed
andrewcorrigan opened this issue Jan 29, 2014 · 12 comments
Closed

rendering not working on my Ubuntu 13.10/Linux system #3

andrewcorrigan opened this issue Jan 29, 2014 · 12 comments

Comments

@andrewcorrigan
Copy link
Contributor

While I have compiled and ran nanovg successfully on my mac, I was recently trying to run the example code on my Ubuntu 13.10 laptop, which uses either an Intel or NVIDIA GPU (proprietary, binary driver) that I can select in the BIOS.

Running with either GPU, the example code doesn't render correctly, and only text appears,
rendered_incorrectly

Not being familiar with the underlying rendering technique, there wasn't much I could do to fix it, but I tried to narrow down the issue slightly, by modifying the shader alpha component calculation from "color.w *= strokeAlpha * scissor;", to just "color.w *= scissor;", in which case the rest of the scene appears, but the blending appears off:

hacked_shader

@memononen
Copy link
Owner

Hi, I have not test the shader on many computers yet, so some compatibility issues can be there.

Based on the images, looks like the sdroundrect() does not behave correctly on your set. Can you try to add:
"precision highp float;\n",
after the #version line in both of the shaders?

--mikko

@andrewcorrigan
Copy link
Contributor Author

Doesn't help. It looks the same as the original image.

@andrewcorrigan
Copy link
Contributor Author

FWIW, I think that when I ran on the Mac, it was also an NVIDIA GPU (650M)

@memononen
Copy link
Owner

My Mac has Intel HD4000, and I always thought they were the lowest common nominator :) What if you truncate the shader main() just to:

"void main(void) {\n"
" // Stroke - from [0..1] to clipped pyramid, where the slope is 1px.\n"
" float strokeAlpha = min(1.0, (1.0-abs(alpha.x_2.0-1.0))_strokeMult) * alpha.y;\n"
1.0);\n"
" vec4 color = innerCol;\n"
" // Combine alpha\n"
" color.w *= strokeAlpha;\n"
" gl_FragColor = color;\n"
"}\n";

If that works, you won't get clipping nor gradients, but it should confirm that the sdroundrect() is the culprit.

@andrewcorrigan
Copy link
Contributor Author

I ran that (after deleting the stray line 1.0);\n"), but it's still the same thing as the original image.

@andrewcorrigan
Copy link
Contributor Author

Here's another piece of information, if I comment out both calls to glBlendFunc in example.c, everything appears (but obviously rendered incorrectly):
blendfunc

@memononen
Copy link
Owner

Blending should not affect the shader. Does this shadertoy work for you?
https://www.shadertoy.com/view/MsS3zz

@andrewcorrigan
Copy link
Contributor Author

I think so, it looks like:
wunderbutton

@memononen
Copy link
Owner

ok, so oddly enough the same code works in one place but in another :(

Let's see if the inputs are ok. How does this shader look like:

"void main(void) {\n"
" gl_FragColor = vec4(alpha.x,alpha.x,alpha.x,1.0);\n"
"}\n";

@andrewcorrigan
Copy link
Contributor Author

I tried that out, and was curious, so I also tried out alpha.y, and then strokeMult. strokeMult was zero, even though the corresponding call to glUniform1f was passing in a value of something like 1.0. What I found is that none of the uniform variables are getting bound since every single call to glGetUniformLocation fails (returns -1, which is not reported by glGetError, so I added additional error checks). I should be to fix the issue of uniform variables not getting bound, will get back to you soon.

@andrewcorrigan
Copy link
Contributor Author

glGetUniformLocation wasn't the problem -- glUniform1f was simply not working. Apparently this issue is common when glUniform1f isn't dynamically loaded at run-time [1]. A workaround is to use GLEW, which loads the function at run-time. I've added that to my clone of your repository, and will issue a pull request in case you want to merge this workaround.

Thanks for all your help. I'm looking forward to really getting started using nanovg.

[1] http://encelo.netsons.org/2008/03/17/gluniform1f-is-working/

@memononen
Copy link
Owner

Thank you for taking the time to look into this! That would have been quite tricky to debug remotely :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants