Changeset 668


Ignore:
Timestamp:
Feb 19, 2011, 10:09:20 PM (11 years ago)
Author:
sam
Message:

Protect the Shader constructor and provide a static creation method that
will let us cache shaders.

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/shader.cpp

    r659 r668  
    4545 */
    4646
     47Shader *Shader::Create(char const *vert, char const *frag)
     48{
     49    return new Shader(vert, frag);
     50}
     51
     52void Shader::Destroy(Shader *shader)
     53{
     54    delete shader;
     55}
     56
    4757Shader::Shader(char const *vert, char const *frag)
    4858  : data(new ShaderData())
     
    7787int Shader::GetAttribLocation(char const *attr) const
    7888{
    79     return glGetAttribLocation(data->prog_id, attr);   
     89    return glGetAttribLocation(data->prog_id, attr);
    8090}
    8191
  • trunk/src/shader.h

    r659 r668  
    1111//
    1212// The Shader class
    13 // --------------
     13// ----------------
    1414//
    1515
     
    2222{
    2323public:
    24     Shader(char const *vert, char const *frag);
    25     ~Shader();
     24    static Shader *Create(char const *vert, char const *frag);
     25    static void Destroy(Shader *shader);
    2626
    2727    int GetAttribLocation(char const *attr) const;
     
    2929
    3030    void Bind() const;
     31
     32protected:
     33    Shader(char const *vert, char const *frag);
     34    ~Shader();
    3135
    3236private:
  • trunk/src/video.cpp

    r667 r668  
    8686
    8787#if LOL_EXPERIMENTAL
    88     stdshader = new Shader(vertexshader, fragmentshader);
     88    stdshader = Shader::Create(vertexshader, fragmentshader);
    8989#endif
    9090}
     
    169169{
    170170#if LOL_EXPERIMENTAL
    171     delete stdshader;
     171    Shader::Destroy(stdshader);
    172172#endif
    173173}
Note: See TracChangeset for help on using the changeset viewer.