Moved ProgramBinary into osg::Program scope
This commit is contained in:
@@ -35,50 +35,6 @@ namespace osg {
|
||||
|
||||
class State;
|
||||
|
||||
/** Simple class for wrapping up the data used in glProgramBinary and glGetProgramBinary.
|
||||
* On the first run of your application Programs should be assigned an empty ProgramBinary.
|
||||
* Before your application exits it should retrieve the program binary via
|
||||
* Program::PerContextProgram::compileProgramBinary and save it to disk.
|
||||
* When your application is run subsequently, load your binary from disk and use it to set
|
||||
* the data of a ProgramBinary, and set the ProgramBinary on the associated Program.
|
||||
* This will typically result in Program::compileGLObjects executing much faster.*/
|
||||
class OSG_EXPORT ProgramBinary : public osg::Object
|
||||
{
|
||||
public:
|
||||
|
||||
ProgramBinary();
|
||||
|
||||
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
|
||||
ProgramBinary(const ProgramBinary& rhs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
META_Object(osg, ProgramBinary);
|
||||
|
||||
/** Allocated a data buffer of specified size/*/
|
||||
void allocate(unsigned int size);
|
||||
|
||||
/** Assign program binary data, copying the specified data into locally stored data buffer, the original data can then be deleted.*/
|
||||
void assign(unsigned int size, const unsigned char* data);
|
||||
|
||||
/** Set the format of the program binary data.*/
|
||||
void setFormat(GLenum format) {_format = format;}
|
||||
|
||||
/** Get the format of the program binary data.*/
|
||||
GLenum getFormat() const {return _format;}
|
||||
|
||||
/** Get the size of the program binary data.*/
|
||||
unsigned int getSize() const { return _data.size(); }
|
||||
|
||||
/** Get a ptr to the program binary data.*/
|
||||
unsigned char* getData() { return _data.empty() ? 0 : &(_data.front()); }
|
||||
|
||||
/** Get a const ptr to the program binary data.*/
|
||||
const unsigned char* getData() const { return _data.empty() ? 0 : &(_data.front()); }
|
||||
|
||||
protected:
|
||||
std::vector<unsigned char> _data;
|
||||
GLenum _format;
|
||||
};
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
/** osg::Program is an application-level abstraction of an OpenGL glProgram.
|
||||
@@ -167,6 +123,51 @@ class OSG_EXPORT Program : public osg::StateAttribute
|
||||
/** Remove a uniform block binding. */
|
||||
void removeBindUniformBlock(const std::string& name);
|
||||
|
||||
/** Simple class for wrapping up the data used in glProgramBinary and glGetProgramBinary.
|
||||
* On the first run of your application Programs should be assigned an empty ProgramBinary.
|
||||
* Before your application exits it should retrieve the program binary via
|
||||
* Program::PerContextProgram::compileProgramBinary and save it to disk.
|
||||
* When your application is run subsequently, load your binary from disk and use it to set
|
||||
* the data of a ProgramBinary, and set the ProgramBinary on the associated Program.
|
||||
* This will typically result in Program::compileGLObjects executing much faster.*/
|
||||
class OSG_EXPORT ProgramBinary : public osg::Object
|
||||
{
|
||||
public:
|
||||
|
||||
ProgramBinary();
|
||||
|
||||
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
|
||||
ProgramBinary(const ProgramBinary& rhs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
META_Object(osg, ProgramBinary);
|
||||
|
||||
/** Allocated a data buffer of specified size/*/
|
||||
void allocate(unsigned int size);
|
||||
|
||||
/** Assign program binary data, copying the specified data into locally stored data buffer, the original data can then be deleted.*/
|
||||
void assign(unsigned int size, const unsigned char* data);
|
||||
|
||||
/** Set the format of the program binary data.*/
|
||||
void setFormat(GLenum format) {_format = format;}
|
||||
|
||||
/** Get the format of the program binary data.*/
|
||||
GLenum getFormat() const {return _format;}
|
||||
|
||||
/** Get the size of the program binary data.*/
|
||||
unsigned int getSize() const { return _data.size(); }
|
||||
|
||||
/** Get a ptr to the program binary data.*/
|
||||
unsigned char* getData() { return _data.empty() ? 0 : &(_data.front()); }
|
||||
|
||||
/** Get a const ptr to the program binary data.*/
|
||||
const unsigned char* getData() const { return _data.empty() ? 0 : &(_data.front()); }
|
||||
|
||||
protected:
|
||||
std::vector<unsigned char> _data;
|
||||
GLenum _format;
|
||||
};
|
||||
|
||||
|
||||
/** Set the Program using a ProgramBinary. If a ProgramBinary is not yet
|
||||
* available then setting an empty one signals that compileProgramBinary
|
||||
* will be called later.*/
|
||||
|
||||
Reference in New Issue
Block a user