~ubuntu-branches/ubuntu/trusty/openscenegraph/trusty

« back to all changes in this revision

Viewing changes to OpenSceneGraph/src/osg/Shader.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Cyril Brulebois
  • Date: 2008-07-29 04:34:38 UTC
  • mfrom: (1.1.6 upstream) (2.1.3 lenny)
  • Revision ID: james.westby@ubuntu.com-20080729043438-no1h9h0dpsrlzp1y
* Non-maintainer upload.
* No longer try to detect (using /proc/cpuinfo when available) how many
  CPUs are available, fixing the FTBFS (due to -j0) on various platforms
  (Closes: #477353). The right way to do it is to support parallel=n in
  DEB_BUILD_OPTIONS (see Debian Policy §4.9.1), and adequate support has
  been implemented.
* Add patch to fix FTBFS due to the build system now refusing to handle
  whitespaces (Policy CMP0004 say the logs), thanks to Andreas Putzo who
  provided it (Closes: #482239):
   - debian/patches/fix-cmp0004-build-failure.dpatch
* Remove myself from Uploaders, as requested a while ago, done by Luk in
  his 2.2.0-2.1 NMU, which was never acknowledged.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 
2
2
 * Copyright (C) 2003-2005 3Dlabs Inc. Ltd.
3
3
 * Copyright (C) 2004-2005 Nathan Cournia
 
4
 * Copyright (C) 2008 Zebra Imaging
4
5
 *
5
6
 * This application is open source and may be redistributed and/or modified   
6
7
 * freely and without restriction, both in commericial and non commericial
13
14
*/
14
15
 
15
16
/* file:   src/osg/Shader.cpp
16
 
 * author: Mike Weiblen 2005-06-15
 
17
 * author: Mike Weiblen 2008-01-02
17
18
*/
18
19
 
19
20
#include <fstream>
83
84
    availableTime -= elapsedTime;
84
85
}
85
86
 
 
87
void Shader::discardDeletedGlShaders(unsigned int contextID)
 
88
{
 
89
    OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedGlShaderCache);
 
90
 
 
91
    GlShaderHandleList& pList = s_deletedGlShaderCache[contextID];
 
92
    pList.clear();
 
93
}
86
94
 
87
95
///////////////////////////////////////////////////////////////////////////
88
96
// osg::Shader
102
110
Shader::Shader(const Shader& rhs, const osg::CopyOp& copyop):
103
111
    osg::Object( rhs, copyop ),
104
112
    _type(rhs._type),
105
 
    _shaderSource(rhs._shaderSource)
 
113
    _shaderSource(rhs._shaderSource),
 
114
    _shaderFileName(rhs._shaderFileName)
106
115
{
107
116
}
108
117
 
134
143
 
135
144
    if( getShaderSource() < rhs.getShaderSource() ) return -1;
136
145
    if( rhs.getShaderSource() < getShaderSource() ) return 1;
 
146
 
 
147
    if( getFileName() < rhs.getFileName() ) return -1;
 
148
    if( rhs.getFileName() < getFileName() ) return 1;
137
149
    return 0;
138
150
}
139
151
 
163
175
    }
164
176
 
165
177
    osg::notify(osg::INFO)<<"Loading shader source file \""<<fileName<<"\""<<std::endl;
 
178
    _shaderFileName = fileName;
166
179
 
167
180
    sourceFile.seekg(0, std::ios::end);
168
181
    int length = sourceFile.tellg();
184
197
    {
185
198
        case VERTEX:    return "VERTEX";
186
199
        case FRAGMENT:  return "FRAGMENT";
 
200
        case GEOMETRY:  return "GEOMETRY";
187
201
        default:        return "UNDEFINED";
188
202
    }
189
203
}
193
207
{
194
208
    if( tname == "VERTEX" )     return VERTEX;
195
209
    if( tname == "FRAGMENT" )   return FRAGMENT;
 
210
    if( tname == "GEOMETRY" )   return GEOMETRY;
196
211
    return UNDEFINED;
197
212
}
198
213
 
240
255
    if( pcs ) pcs->attachShader( program );
241
256
}
242
257
 
 
258
void Shader::detachShader(unsigned int contextID, GLuint program) const
 
259
{
 
260
    PerContextShader* pcs = getPCS( contextID );
 
261
    if( pcs ) pcs->detachShader( program );
 
262
}
 
263
 
243
264
 
244
265
bool Shader::getGlShaderInfoLog(unsigned int contextID, std::string& log) const
245
266
{
373
394
{
374
395
    _extensions->glDetachShader( program, _glShaderHandle );
375
396
}
376
 
 
377
 
/*EOF*/