I don't understand...
Call Stack:
Why does this crash when I attempt to destroy the shader? I haven't even attempted to attach a source yet. I've read through the documentation here, looked at the examples here and checked my allegro.log for anything odd. This is frustrating beyond belief.
]]>What version of Allegro are you using?
When it crashes type bt full and check the local variables.
]]>Wow. Never used GDB before. Nor did I know that existed before you mentioned it.
Is that what you're looking for? I'm using a static x64 version of Allegro 5.2.2.
]]>It looks like a bug in Allegro, the only way to avoid it (aside from not destroying the shader) is to actually add sources and build it.
]]>When I run this, it creates the shader and correctly finds both of the shader files with fopen(). The platform is identified as ALLEGRO_SHADER_HLSL and line 36 is run. My console then prints "Failed to attach shader source." I don't know how to write HLSL shaders yet so I used ex_prim_shader_pixel.glsl and ex_prim_shader_pixel.hlsl from here. This is the GDB output:
]]>
The destructor crash is fixed on the master branch, but that's unrelated to your issues with attaching the source. Could you try seeing if al_get_shader_log returns anything?
]]>If I use the example shader I found here then print al_get_shader_log after attaching the source, I get the following error:
If I use the following pixel shader I found here...
...then it successfully attaches, builds, then destroys. Finally! I haven't learned HLSL so I don't understand what VS_OUTPUT is. In the past, I used SFML which defaulted to GLSL. Is there any reason why allegro is forcing me to use HLSL? Would I get a performance penalty if I switched to GLSL? Is that even possible on Windows 8.1? Would it be portable?
On another note, could there please be an allegro error to reflect this quirk with shaders? It would be nice if you got a printout like "Cannot destroy a shader without attaching source." when you attempt doing so. It would've saved me several days and a lot of frustration getting this to work. The shader was going to be for something very minor, anyways.
]]>Oh, VS_OUTPUT is defined in the vertex shader, I guess you had to attach both for it to work.
You can use GLSL too if you want, there is a tiny performance penalty but nothing that should prevent you from using it. Do this by adding al_set_new_display_flags(ALLEGRO_OPENGL) before creating the display.
As for destroying the shaders, your original code will work in the next release without the crash.
]]>Also, if you want your game to ever work anywhere besides Windows, you will want GLSL anyway
]]>Ah, I see. In that case, I'll switch to OpenGL and use that for all platforms. Thanks for helping me!
]]>