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

@@ -67,6 +67,7 @@
"#define ArrayCount(array)",
"#define Assert(condition)",
"#define IsAlignedTo(pntr, alignment)",
"#define NotNull(expression)",
"#define PrintLine_D(formatStrNt, ...)",
"#define PrintLine_E(formatStrNt, ...)",
"#define PrintLine_I(formatStrNt, ...)",
@@ -92,16 +93,24 @@
"ArenaMark GetArenaMark(Arena* arena)",
"ArenaMark GetScratch()",
"ArenaMark GetScratch1(Arena* conflictArena)",
"GlEnum jsGlGetParameterEnum(GlEnum parameter)",
"GlId jsGlCreateBuffer()",
"GlId jsGlCreateProgram()",
"GlId jsGlCreateShader(GlEnum shaderType)",
"GlId jsGlCreateTexture()",
"GlId jsGlCreateVertexArray()",
"GlId jsGlGetUniformLocation(GlId programId, int nameLength, const char* namePntr)",
"bool jsGlGetParameterBool(GlEnum parameter)",
"bool jsGlGetProgramParameterBool(GlId programId, GlEnum parameter)",
"bool jsGlGetShaderParameterBool(GlId shaderId, GlEnum parameter)",
"char* jsGlGetParameterString(void* arenaPntr, GlEnum parameter)",
"char* jsGlGetProgramInfoLog(void* arenaPntr, GlId programId)",
"char* jsGlGetShaderInfoLog(void* arenaPntr, GlId shaderId)",
"float jsGlGetParameterFloat(GlEnum parameter)",
"inline void* ReallocMem(Arena* arena, void* oldPntr, u32 oldSize, u32 newSize)",
"inline void* ReallocMemUnaligned(Arena* arena, void* oldPntr, u32 oldSize, u32 newSize)",
"int jsGlGetError()",
"int jsGlGetParameterInt(GlEnum parameter)",
"int jsGlGetProgramParameterInt(GlId programId, GlEnum parameter)",
"int jsGlGetShaderParameterInt(GlId shaderId, GlEnum parameter)",
"void InitGlobalArenas(u32 scratchArenasSize)",