anael-seghezzi / CToy

Interactive C live coding environment
Other
1.35k stars 70 forks source link

Feature request: Add compatibility with sokol #5

Closed pjako closed 7 years ago

pjako commented 7 years ago

It would be nice to be able to use sokol with Ctoy beside OpenGL ES2 directly.

anael-seghezzi commented 7 years ago

Sokol is written in C, so I don't see why you can't. Specially if there is already a wrapper around OpenGL ES2.

anael-seghezzi commented 7 years ago

Just copy sokol source in Ctoy/src or so and use #define SOKOL_GLES2

pjako commented 7 years ago

Tried that already, getting a error in that case:

In file included from src/main.c:21:
In file included from src/hello_sokol.c:8:
In file included from src/sokol_gfx.h:859:
In file included from src/_sokol_gfx.impl.h:237:
src/_sokol_gfx_gl.impl.h:275: error: 'GL_HALF_FLOAT' undeclared

hello_sokol.c -> https://gist.github.com/pjako/0c89587d13b60d83ba8f441b3c6eece4

anael-seghezzi commented 7 years ago

GL_HALF_FLOAT is not part of OpenGL ES2 (OpenGL ES3 I think). _sokol_gfx_gl.impl.h should not call it if SOKOL_GLES2 is defined

pjako commented 7 years ago

Its an extension for OpenGL ES2. To have sokol to cover this case it needs some kind of no extensions macro

anael-seghezzi commented 7 years ago

Yes.

Of course as a workaround you can always declare:

define GL_HALF_FLOAT 0x140B

(see https://github.com/anael-seghezzi/CToy/blob/master/3rdparty/glad/include/glad/glad.h)

or even:

define GL_HALF_FLOAT assert(0)

pjako commented 7 years ago

unfortunate this is a rabbit hole. After adding all the simple #define stuff

In file included from src/main.c:21:
In file included from src/hello_sokol.c:3768:
In file included from src/sokol_gfx.h:859:
In file included from src/_sokol_gfx.impl.h:237:
src/_sokol_gfx_gl.impl.h:1748: warning: implicit declaration of function 'glVertexAttribDivisor'
In file included from src/main.c:21:
In file included from src/hello_sokol.c:3768:
In file included from src/sokol_gfx.h:859:
In file included from src/_sokol_gfx.impl.h:237:
src/_sokol_gfx_gl.impl.h:1828: warning: implicit declaration of function 'glDrawElementsInstanced'
In file included from src/main.c:21:
In file included from src/hello_sokol.c:3768:
In file included from src/sokol_gfx.h:859:
In file included from src/_sokol_gfx.impl.h:237:
src/_sokol_gfx_gl.impl.h:1839: warning: implicit declaration of function 'glDrawArraysInstanced'
anael-seghezzi commented 7 years ago

I see, also not part of OpenGLES2.