Commit 58710c28 authored by Frédéric Larue's avatar Frédéric Larue
Browse files

Function added to DisplayableInterface enabling to load the content of a...

Function added to DisplayableInterface enabling to load the content of a resource file to a QString.
parent 80d8ab03
......@@ -43,12 +43,7 @@ private:
{
QString res;
for( auto &rscName : resourceNames )
{
QFile rscFile( rscName );
if( !rscFile.open( QIODevice::ReadOnly | QIODevice::Text ) )
qDebug() << "Unable to load resource \"" << rscName << "\".";
res += (char*) rscFile.map( 0, rscFile.size() );
}
res += getResourceContent( rscName );
return res;
}
......@@ -56,6 +51,16 @@ protected:
/** Recover the current viewer to which this Displayable is associated. */
inline GLViewer* getViewer() const { return m_Viewer; }
inline QString getResourceContent( const QString &resourceName ) const
{
QString content;
QFile rscFile( resourceName );
if( !rscFile.open( QIODevice::ReadOnly | QIODevice::Text ) )
qDebug() << "Unable to load resource \"" << resourceName << "\".";
else
content = (char*) rscFile.map( 0, rscFile.size() );
return content;
}
inline bool shaderFromResources( GPU::Shader &shader,
const QString &vshResourceName,
const QString &fshResourceName,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment