Hi,
Making a renderer, all can be emulated for both OpenGL and Direct3D11 but Shader is different on D3D11 and OGL.
D3D11 use constant buffer since OpenGL not (maybe UBO, I don't know new spec of OpenGL).
Is it a way to have a class who works for both ?
Thanks
Shader class GL/D3D11
Started by Alundra, Nov 03 2012 07:58 AM
3 replies to this topic
Sponsor:
#2 GDNet+ - Reputation: 1749
Posted 04 November 2012 - 04:19 AM
I strongly suggest against so, it would be full of ifs
Use a common interface instead.
Modern GL has cbuffers as well as far as I understand but my GL is admittedly rusty.
Shader re-building is a big deal. I cannot say how much effort I've been spending on it. I suggest to take a look at Cg.
Use a common interface instead.
Modern GL has cbuffers as well as far as I understand but my GL is admittedly rusty.
Shader re-building is a big deal. I cannot say how much effort I've been spending on it. I suggest to take a look at Cg.
#3 Moderators - Reputation: 13569
Posted 04 November 2012 - 04:33 AM
UBO is core since 3.1, so that would be the easiest choice if you're ok with learning 3.1's API.D3D11 use constant buffer since OpenGL not (maybe UBO, I don't know new spec of OpenGL).
I've taken the approach of using the "constant buffer" concept in my cross-API shader class.
D3D9 doesn't support "constant buffers" either, so I emulate them for D3D9 (which is actually extremely efficient).
I'm still working on the GL2.1 version (without UBOs), but I'm also emulating "constant buffers" like I did for D3D9 (but this time it's more complicated), so that my shader interface is consistent across all platforms.
Edited by Hodgman, 04 November 2012 - 04:34 AM.






