Comments (13)
I made a potential fix for this. Can you check if it works properly?
If I add the client API hint and version + precision, I'm not able to test it anymore on my machine, but the code works fine if I comment out those two things. Please note that I added the changes behind a NANOVG_GLES2 define which you need to define before including nanovg_gl2.h
from nanovg.
That works.
But, I have an additional request :)
My code does runtime detection of OpenGL version, and therefore I am compiling in all of the GL2, GLES2, GL3 renderers, each in separate compilation units, but linking all in to a single static library. To avoid collisions, can NANOVG_GLES2 modify the names of the two non-static functions? Otherwise I won't be able to simultaneously compile in GL2 and GLES2 support. Alternatively, could we dispatch GL2 vs GLES2 (vs GLES3?) with a runtime option to nvgCreateGL2?
#ifdef NANOVG_GLES2
struct NVGcontext* nvgCreateGLES2(int atlasw, int atlash, int edgeaa);
void nvgDeleteGLES2(struct NVGcontext* ctx);
#else
struct NVGcontext* nvgCreateGL2(int atlasw, int atlash, int edgeaa);
void nvgDeleteGL2(struct NVGcontext* ctx);
#endif
Also, why not reduce NANOVG_GLES2 + NANOVG_GL2_IMPLEMENTATION to NANOVG_GLES2_IMPLEMENTATION?
from nanovg.
Sorry, one other thing, I would actually prefer GL_ALPHA over GL_LUMINANCE. Even though this is the GL(ES2) backend, this way it could still compile with only glcorearb.h, which contains GL_ALPHA, but not GL_LUMINANCE.
from nanovg.
NANOVG_GLES2_IMPLEMENTATION and the different name for create is good idea, I'll do that.
I was using luminance as it behaved really close to red in shaders, alpha should not be hard to do.
I'm not familiar with glcorearb.h, in what case it is used?
from nanovg.
glcorearb.h only includes what is required for the desktop OpenGL 3.2+ core profile, which my code restricts itself to, even when supporting OpenGL (ES) 2.
I didn't realize there was a difference between luminance in alpha in terms of it's behavior in shaders. If that's the case, then never mind. It was really just an internal need for my project, which I can deal with.
from nanovg.
Ah, now got the glcorearb.h, thanks for clarifying it :)
According to the docs GL_RED should be available in ES 3.0 [1]
Generally I would like to use GL_ALPHA format, as it makes it easy to use it in the pixel shader, it exands to (1,1,1,a), so same texture lookup can be used to rgba and alpha textures. 3.2 core profile does not support that, which requires to to use GL_RED for single channel textures. This shader line deals with it:
" color = texType == 0 ? color : vec4(1,1,1,color.x);\n"
Since luminance expands to L,L,L,1 the same shader can be used for luminance and red.
I'd like to use GL_RED in the gl3 back end for ES 3.0 too, do you know if that compiles fine?
[1] http://www.khronos.org/registry/gles/specs/3.0/es_spec_3.0.0.pdf
from nanovg.
I tried to use NANOVG_GLES2_IMPLEMENTATION, but that does not allow me to change the create function to nvgCreateGLESx() as the header in mean to work without specifying the implementation. Do you have preferences on that?
from nanovg.
Ah ok, the only other thing for it to run on my system with a GLES3 context is that the internal format has to be GL_R8 rather than GL_RED:
glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, w, h, 0, GL_RED, GL_UNSIGNED_BYTE, data);
The other command works with
glTexSubImage2D(GL_TEXTURE_2D, 0, x,y, w,h, GL_RED, GL_UNSIGNED_BYTE, data);
from nanovg.
Update with your most recent comments, can you try it out?
from nanovg.
The GLES3 version compiles and runs fine with the latest changes.
I see what you mean regarding the defines. How about having something in nanovg_gl2.h where
#ifdef NANOVG_GLES2_IMPLEMENTATION
# define NANOVG_GLES2
#endif
so that internally nanovg_gl2.h interprets NANOVG_GLES2_IMPLEMENTATION as implying NANOVG_GLES2 so that the user only needs to write a single #define:
// just include NanoVG GLES2 prototypes
#define NANOVG_GLES2
#include <nanovg_gl2.h>
// include NanoVG GLES2 prototypes and implementation
#define NANOVG_GLES2_IMPLEMENTATION
#include <nanovg_gl2.h>
from nanovg.
That sounds like good solution.
from nanovg.
Sorry, I messed that up... Fixing it
from nanovg.
I think everything from this discussion is resolved.
from nanovg.
Related Issues (20)
- FONS_GLYPH_BITMAP_OPTIONAL doesn't inhibit FT_LOAD in fons__tt_buildGlyphBitmap
- Fundamental text layout problem in nanovg
- Layer based drawing HOT 3
- outlines donβt draw properly HOT 2
- Edges of the curve are drawn at an angle HOT 9
- Draw an Arc with a Hole HOT 2
- Multiple scissors HOT 3
- Draw fill problems for complex polygons HOT 2
- Fix for MinGW: Replace -lGLEW with -lglew32
- support android ARGB format HOT 1
- Memory leak with freetype fonts [fix] HOT 4
- nvgArc does some ugly overdraw HOT 2
- [nvgTextBounds] string ending with space does not return expected bounds HOT 2
- `nvgArc` and `nvgArcTo` parameters correspondence and conversion
- building into a shared library HOT 6
- Transformation from Screen Space to World Space? HOT 1
- Arab, Hebrew and Persian
- ANSI Color Escape Sequences HOT 2
- Richtext HOT 2
- Proposal: Support for different NVGcontext types
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nanovg.