Hello. I'm currently playing with HLSL shaders in Allegro, and was wondering if anyone knows how to force the compiler to use a higher version than PS_2_0.
One of my shaders has too much arithmetic (only 64 instructions allowed on PS_2_0) so I was hoping to bump it up to PS_3_0 or PS_4_0.
All of the things I've tried from online research seem to be very DirectX specific, and I can't quite work out how to do this in Allegro (or if it's even possible).
Any suggestions welcomed!
I think when allegro compiles the shaders, it sets the limit. You might have to hack allegro to use later versions of shaders.
Thanks Edgar.
I've ported over the HLSL to OpenGL, which runs it fine (with the same arithmetic). I think for now I'll stick with OpenGL, everyone has that nowadays right?
Cheers. GLSL it is.
Frustratingly OpenGL with allegro runs a little choppy on my laptop.
Regardless of complexity (a simple bitmap being blitted at 1280x720), if I run it using DirectX/3D it runs beautifully, if I run it using OpenGL (especially fullscreen) it "judders", like frames are being missed.
I'm using the good ol' logic of a timer (1.0 /60) and waiting for event, redraw, etc.
I suppose my on-board card prefers DirectX to OpenGL when it comes to allegro?
I looked into using interplation but couldn't get the math right in my head.
Any tips?
It may be a vsync issue. It's usually up to the driver to pick whether vsync is on or not, and that usually comes from the system graphics driver settings.
Guessing DX is better on your laptop, with an integrated chipset.
Most monitors also refresh on 59.97 HZ, not actually 60.0 .
I still can't work out whether it was a vsync issue or a too many frame being drawn issue, but I have found a solution that's working out really well.
I create the display as usual using al_create_display, but then I grab a HDC* to the opengl context, and instead of using al_flip_display() as usual, I call SwapBuffers wrapped within a combination of calls to glReadBuffer/glDrawBuffer, to make sure the same frame never gets drawn.
It's completely cured the jittery effect, it's performance now is on par with the Direct3D option.
Many bothans died to bring us this information, which is another way of saying MAN that took a lot of trial and error (and googling * shouting / fps).
EDIT:
And that's also running smooth with a single shader using 32 lights, just to make it an even better night!
I will be very interested to see your code after Krampus is over. 
What's a few Bothans? :/
I can't remember what I coded now, but I recall something where I tried out DirectX and OpenGL and found that OpenGL ran at half the frame rate under Allegro. Not sure what it was off hand now, been a while. Coded some stuff in straight Windows code + OpenGL and had no problems with some good frame rates.
It's easy enough to get PS_3_0, if you can compile Allegro yourself, just apply this patch:
Getting 4_0 and 5_0 is more complicated.