Jump to content

  • Log In with Google      Sign In   
  • Create Account


Shader class GL/D3D11


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Alundra   Members   -  Reputation: 774

Like
0Likes
Like

Posted 03 November 2012 - 07:58 AM

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

Sponsor:

#2 Krohm   Crossbones+   -  Reputation: 2964

Like
0Likes
Like

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.

#3 Hodgman   Moderators   -  Reputation: 27857

Like
1Likes
Like

Posted 04 November 2012 - 04:33 AM

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.

Edited by Hodgman, 04 November 2012 - 04:34 AM.


#4 Alundra   Members   -  Reputation: 774

Like
0Likes
Like

Posted 04 November 2012 - 11:40 AM

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 ?




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS