micahpearlman / MonkVG

MonkVG is an OpenVG 1.1 like vector graphics API implementation optimized for game use currently using an OpenGL ES backend that should be compatible with any HW that supports OpenGL ES 2.0 which includes most iOS and Android devices.
Other
376 stars 66 forks source link

openGL desktop: error: conflicting declaration 'typedef float GLdouble' #47

Closed milahu closed 2 years ago

milahu commented 3 years ago

im trying to compile MonkVG with openGL desktop

on openGL desktop, GLdouble == double on openGL mobile, GLdouble == float

(at least thats what i guess ...)

when i replace

sed -i 's|typedef float GLdouble;|typedef double GLdouble;|' glu/include/glu.h

then i hit another bug

in https://github.com/micahpearlman/MonkVG/blob/master/glu/libutil/project.c

    float in[4];
    float out[4];

should be

    GLdouble in[4];
    GLdouble out[4];

etc ...

more candidates

$ ~/bin/_rgrep -E '(^|[^a-zA-Z])float [a-zA-Z0-9]+\[(4|16)\]' 
./glu/libutil/project.c:249:    float in[4];
./glu/libutil/project.c:250:    float out[4];
./glu/libutil/project.c:284:    float finalMatrix[16];
./glu/libutil/project.c:285:    float in[4];
./glu/libutil/project.c:286:    float out[4];
./glu/libutil/project.c:325:    float finalMatrix[16];
./glu/libutil/project.c:326:    float in[4];
./glu/libutil/project.c:327:    float out[4];
./projects/MonkVG-Test-Quartz/tiger/test.c:6:static float overcolor[4] = {0,0,0,1};
./projects/MonkVG-Test-Quartz/tiger/main.c:132:         float color[4];
./projects/MonkVG-Test-Quartz/tiger/main.c:308:         float clearColor[4] = {1,1,1,1};
./projects/MonkVG-Test-iOS-OpenGL/tiger/test.c:6:static float overcolor[4] = {0,0,0,1};
./src/opengl/glPath.cpp:50:     void printMat44( float m[4][4] ) {
./src/opengl/glPaint.cpp:113:                           float finalcolor[4];
./src/opengl/glPaint.cpp:244:                           float finalcolor[4];
./src/opengl/glPaint.cpp:396:                           float finalcolor[4];
./src/opengl/glPaint.cpp:547:                           float finalcolor[4];

fix

sed -i -E 's,(^|[^a-zA-Z])float ([a-zA-Z0-9]+\[(4|16)\]),\1GLdouble \2,' glu/libutil/project.c

next problem: conflict in function type

 GLint GLAPIENTRY
 gluUnProject4(
     GLdouble winx, GLdouble winy, GLdouble winz, GLdouble clipw,
     const GLdouble modelMatrix[16], const GLdouble projMatrix[16], const GLint viewport[4],
-    GLclampd nearVal, GLclampd farVal,
+    GLdouble nearVal, GLdouble farVal,
     GLdouble *objx, GLdouble *objy, GLdouble *objz, GLdouble *objw
 )

fix

sed -i -E 's,GLclampd (nearVal|farVal),GLdouble \1,g' glu/libutil/project.c

not sure how to solve this for both desktop and mobile ...

now monkvg compiles : )

micahpearlman commented 2 years ago

In the olden days when I first implemented MonkVG for the original first versions of the iPhone & Android there was a significant performance hit using doubles over floats. Assuming this isn't an issue with modern hardware. shrug

milahu commented 2 years ago

there was a significant performance hit using doubles over floats

still should be ... gpu are optimized for float, except nvidia quadro, etc