Add cAllocMem to cwasm.c which the javascript side can use to allocate memory from an opaque Arena pointer that was passed to it. Used this to implement jsGlGetParameterString, jsGlGetShaderInfoLog, and jsGlGetProgramInfoLog in gl_functions.js. Added NotNull macro and fixed bug in ScratchBegin macro. Added a bool return for App_Initialize which allows us to stop the main loop from beginning (which prevents log spew when something goes wrong)

This commit is contained in:
2025-09-01 21:53:24 -07:00
parent 7c61189d3a
commit b62f0d279b
10 changed files with 135 additions and 18 deletions

View File

@@ -10,6 +10,12 @@ Date: 09\01\2025
typedef int GlId; // Really this is just an index into a javascript array that holds the real reference to the WebGL object
typedef int GlEnum;
MAYBE_EXTERN_C int jsGlGetError();
MAYBE_EXTERN_C bool jsGlGetParameterBool(GlEnum parameter);
MAYBE_EXTERN_C GlEnum jsGlGetParameterEnum(GlEnum parameter);
MAYBE_EXTERN_C int jsGlGetParameterInt(GlEnum parameter);
MAYBE_EXTERN_C float jsGlGetParameterFloat(GlEnum parameter);
MAYBE_EXTERN_C char* jsGlGetParameterString(void* arenaPntr, GlEnum parameter);
MAYBE_EXTERN_C void jsGlEnable(GlEnum capability);
MAYBE_EXTERN_C void jsGlDisable(GlEnum capability);
MAYBE_EXTERN_C void jsGlBlendFunc(GlEnum srcFactor, GlEnum dstFactor);
@@ -38,10 +44,12 @@ MAYBE_EXTERN_C void jsGlShaderSource(GlId shaderId, int sourceLength, const char
MAYBE_EXTERN_C void jsGlCompileShader(GlId shaderId);
MAYBE_EXTERN_C bool jsGlGetShaderParameterBool(GlId shaderId, GlEnum parameter);
MAYBE_EXTERN_C int jsGlGetShaderParameterInt(GlId shaderId, GlEnum parameter);
MAYBE_EXTERN_C char* jsGlGetShaderInfoLog(void* arenaPntr, GlId shaderId);
MAYBE_EXTERN_C void jsGlDeleteProgram(GlId programId);
MAYBE_EXTERN_C GlId jsGlCreateProgram();
MAYBE_EXTERN_C void jsGlAttachShader(GlId programId, GlId shaderId);
MAYBE_EXTERN_C void jsGlLinkProgram(GlId programId);
MAYBE_EXTERN_C char* jsGlGetProgramInfoLog(void* arenaPntr, GlId programId);
MAYBE_EXTERN_C void jsGlUseProgram(GlId programId);
MAYBE_EXTERN_C bool jsGlGetProgramParameterBool(GlId programId, GlEnum parameter);
MAYBE_EXTERN_C int jsGlGetProgramParameterInt(GlId programId, GlEnum parameter);