Shader class GL/D3D11

Started by
2 comments, last by Alundra 11 years, 5 months ago
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
Advertisement
I strongly suggest against so, it would be full of [font=courier new,courier,monospace]if[/font]s
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.

Previously "Krohm"


D3D11 use constant buffer since OpenGL not (maybe UBO, I don't know new spec of OpenGL).
UBO is core since 3.1, so that would be the easiest choice if you're ok with learning 3.1's API.

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.
Ok, so one class who handle "vertex + pixel", the renderer has one function "SetShader" who bind the "compiled shader" on opengl and "vertex+pixel" on d3d11 right ?

This topic is closed to new replies.

Advertisement