Giter Site home page Giter Site logo

Comments (12)

memononen avatar memononen commented on August 16, 2024

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

from nanovg.

andrewcorrigan avatar andrewcorrigan commented on August 16, 2024

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

from nanovg.

andrewcorrigan avatar andrewcorrigan commented on August 16, 2024

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

from nanovg.

memononen avatar memononen commented on August 16, 2024

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.

from nanovg.

andrewcorrigan avatar andrewcorrigan commented on August 16, 2024

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

from nanovg.

andrewcorrigan avatar andrewcorrigan commented on August 16, 2024

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

from nanovg.

memononen avatar memononen commented on August 16, 2024

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

from nanovg.

andrewcorrigan avatar andrewcorrigan commented on August 16, 2024

I think so, it looks like:
wunderbutton

from nanovg.

memononen avatar memononen commented on August 16, 2024

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";

from nanovg.

andrewcorrigan avatar andrewcorrigan commented on August 16, 2024

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.

from nanovg.

andrewcorrigan avatar andrewcorrigan commented on August 16, 2024

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/

from nanovg.

memononen avatar memononen commented on August 16, 2024

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

from nanovg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.