Open sonicdebris opened 9 years ago
Try changing the fragment precision from 'mediump' to 'highp' in nanovg_gl.h... I think there's a define for this too...
The easiest way to do that is to add a line here: https://github.com/memononen/nanovg/blob/master/src/nanovg_gl.h#L433
Change:
#elif defined NANOVG_GLES2
"#version 100\n"
"#define NANOVG_GL2 1\n"
to
#elif defined NANOVG_GLES2
"#version 100\n"
"#define NANOVG_GL2 1\n"
"precision highp float;\n"
If that does not work, remove this around line 467:
"#ifdef GL_ES\n"
"#if defined(GL_FRAGMENT_PRECISION_HIGH) || defined(NANOVG_GL3)\n"
" precision highp float;\n"
"#else\n"
" precision mediump float;\n"
"#endif\n"
"#endif\n"
tried both, but nothing, the wheel is still "segmented". I tried something simpler, substituting the call to renderDemo with a rect filled with a gradient:
NVGpaint bg = nvgLinearGradient(vg, 0,0,0, height,nvgRGBA(0,0,255,255), nvgRGBA(255,0,0,255));
nvgRect(vg,0,0,width,height);
nvgFillPaint(vg, bg);
nvgFill(vg);
with this result:
this happens both with and without the modifications you suggested.
The wheel is drawn using linear gradients in multiple segments. For some reason some radial gradients work just fine. All gradients use the same code, but different parameters to achieve radial or linear gradient.
Can you try to make the gradient start at some other location, say 100,100 -> width-100, height-100? I'm just trying to get the idea what might be wrong.
Yeah, I noticed that the radial gradient in the eyes looks ok. here's the result for (100,100)->(w-100,h-100):
I also tried ( w/2 , 100 ) -> (w/2, h-100), and I noticed that the gradient looks different switching between portrait and landscape:
I just tried again the test app I made, after downloading a "fresh" zip of the git repo. The gradient is now working!
I will perform further tests and I'd like to find a way to publish a polished test app (time to learn how to use git I suppose...), but since this might not happen very soon here's a zip with the current state of the app: https://www.dropbox.com/s/saspblk3yxanw60/nanoVGTest_android.zip?dl=0
I tested the app with a motorola moto g (stock android 4.4), and a Lg 4X (cyanogen 4.4).
All gradients are done using box gradient, maybe choosing smaller large
could fix it?
https://github.com/memononen/nanovg/blob/master/src/nanovg.c
The precision issues is quite sad... if someone has good tips how to solve it (maybe change the data), I'd like to hear about it.
I'm trying to use nanovg on android using ndk, putting together a test app to share back (really appreciated what you did here). I was able to compile and launch the renderDemo function. It basically works, but not everything. I am getting an egl surface and context in c++ from a java surface, and drawing in it using nanovg:
And I get this:
I am ignoring the text and images absence for now (it's just a matter of loading the resources using android's APIs). I'm concerned about gradients, as you can see from the color wheel.
I'm totally new to opengl, so I don't know what that could be, I'm searching but maybe it's something trivial that I overlooked. Any idea/hint?