DEV Community

Discussion on: Hello, bgfx!

Collapse
 
jpvanoosten profile image
Jeremiah van Oosten

This line:

FILE *file = fopen(FILENAME, "rb");
Enter fullscreen mode Exit fullscreen mode

Should be

FILE *file = fopen(filePath, "rb");
Enter fullscreen mode Exit fullscreen mode
Collapse
 
allanjake profile image
Jake Allan

this returns null for me.
filePath ends up being "shaders/dx11/vs_cubes.binýýýý"
hard coding this to "shaders/dx11/vs_cubes.bin" results in no change despite the file being present...

Any idea why?

Collapse
 
versine profile image
versine

Because he uses memcpy, a null terminator never gets written to the end of the string. You need to allocate with "char* filePath = (char*)calloc(1, shaderLen + fileLen + 1);", then there will be a zero at the end of the string

Collapse
 
laurens_schunk_fef8060912 profile image
Laurens Schunk

I should have read this. I took me a good 10 minutes to figure out why I was segfaulting