I know this is not a supported library, but I wasn’t sure where else to ask.
Anyway, here’s my relevant code:
GPU_ShaderEnum GetShaderEnum(int i)
{
switch(i)
{
case 0:
return GPU_VERTEX_SHADER;
case 1:
return GPU_FRAGMENT_SHADER;
case 2:
return GPU_GEOMETRY_SHADER;
}
}
Uint32 My_GPU_LoadShader(int shader_type, char* filename)
{
FILE* fp = fopen("output.txt", "w");
fprintf(fp, "filename: %s\r\n", filename);
//It seems this will crash when I pass the parameter; it only succeeds when I give it a literal.
//Uint32 output = GPU_LoadShader(GetShaderEnum(shader_type), "mypath\myshader.vert");
Uint32 output = GPU_LoadShader(GetShaderEnum(shader_type), filename);
fprintf(fp, "Done loading!");
return output;
}
As I’ve commented, if I pass it the string literal, there’s no problem (or at least, it doesn’t crash the whole thing). But when I simply pass in filename, the whole exe crashes before it can fprintf “Done loading!” Even if I copy/paste the contents of that output file in order to get the string literal.
I checked to make sure my parameter was null terminated (it was), because it was the only thing I could think of.
The error reporting is kinda weird, since I’m calling this (C) function from Ada code, but it seems it might be relevant?
raised STORAGE_ERROR : stack overflow or erroneous memory access
Which is more or less the same thing as a segfault. So maybe that’s what it is behind the scenes?
It’s probably a really obvious newbie C thing. Any ideas?