Skip to content

Commit

Permalink
libgui|GLShader: Shader instances are reference counted
Browse files Browse the repository at this point in the history
Shaders can be shared by multiple programs; reference counting solves
lifetime management in this situation.
  • Loading branch information
skyjake committed Apr 21, 2013
1 parent 25fc2ba commit a524c1f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion doomsday/libgui/include/de/gui/glshader.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <de/libdeng2.h>
#include <de/Error>
#include <de/Counted>
#include <de/Asset>
#include <de/IByteArray>

Expand All @@ -32,9 +33,12 @@ namespace de {
/**
* GL shader.
*
* Shader instances are reference-counted so that they can be shared by many
* programs.
*
* @ingroup gl
*/
class LIBGUI_PUBLIC GLShader : public Asset
class LIBGUI_PUBLIC GLShader : public Counted, public Asset
{
public:
enum Type
Expand All @@ -52,6 +56,8 @@ class LIBGUI_PUBLIC GLShader : public Asset
public:
GLShader();

GLShader(Type shaderType, IByteArray const &source);

Type type() const;

GLuint glName() const;
Expand Down
5 changes: 5 additions & 0 deletions doomsday/libgui/src/glshader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ DENG2_PIMPL(GLShader)
GLShader::GLShader() : d(new Instance(this))
{}

GLShader::GLShader(Type shaderType, IByteArray const &source)
{
compile(shaderType, source);
}

GLShader::Type GLShader::type() const
{
return d->type;
Expand Down

0 comments on commit a524c1f

Please sign in to comment.