matus-chochlik / oglplus

OGLplus is a collection of open-source, cross-platform libraries which implement an object-oriented facade over the OpenGL® (version 3 and higher) and also OpenAL® (version 1.1) and EGL (version 1.4) C-language APIs. It provides wrappers which automate resource and object management and make the use of these libraries in C++ safer and more convenient.
http://oglplus.org/
Boost Software License 1.0
494 stars 71 forks source link

Shader classes design #41

Closed sasmaster closed 10 years ago

sasmaster commented 10 years ago

Hi.I wonder why the API has a separate class for each type of shaders.VertexShader,FragmentShader,GeometryShader etc...It seems to be like a over-engineered design,unless I miss something here...

matus-chochlik commented 10 years ago

Hi,

Well it allows you for example to say that a function accepts only a FragmentShader or only a ComputeShader and check that at compile-time. Like in:

// some function that would work only with geometry shader void Func(GeometryShader& gs);

// doing this will fail at compile-time VertexShader vs; Func(vs);

I've got some closed-source apps where we use this. But you don't have to use the {Vertex,Geometry,...,Fragment}Shader classes if you don't want to. There is the Shader class in which you specify the ShaderType at run-time. See for example here:

https://github.com/matus-chochlik/oglplus/blob/develop/example/standalone/002_dsa_buffer.cpp

sasmaster commented 10 years ago

Great ,now I see.Thanks for the clarification.

On Thu, Jan 2, 2014 at 10:06 AM, Matus Chochlik notifications@github.comwrote:

Hi,

Well it allows you for example to say that a function accepts only a FragmentShader or only a ComputeShader and check that at compile-time. Like in:

// some function that would work only with geometry shader void Func(GeometryShader& gs);

// doing this will fail at compile-time VertexShader vs; Func(vs);

I've got some closed-source apps where we use this. But you don't have to use the {Vertex,Geometry,...,Fragment}Shader classes if you don't want to. There is the Shader class in which you specify the ShaderType at run-time. See for example here:

https://github.com/matus-chochlik/oglplus/blob/develop/example/standalone/002_dsa_buffer.cpp

— Reply to this email directly or view it on GitHubhttps://github.com/matus-chochlik/oglplus/issues/41#issuecomment-31441048 .

Michael Ivanov Independent Pixel Commander onlygraphix.com Tel:+972 54 4962254