/usr/include/osgEarth/ShaderLoader is in libosgearth-dev 2.7.0+dfsg-2+b3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | /* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
* Copyright 2015 Pelican Mapping
* http://osgearth.org
*
* osgEarth is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
#ifndef OSGEARTH_SHADER_LOADER_H
#define OSGEARTH_SHADER_LOADER_H 1
#include <osgEarth/Common>
#include <osgDB/Options>
#include <map>
namespace osgEarth
{
class VirtualProgram;
/**
* Functions to help load shader code.
*/
class OSGEARTH_EXPORT ShaderPackage
{
public:
/**
* Adds a function from this package to the VirtualProgram.
*/
bool load(
VirtualProgram* vp,
const std::string& filename,
const osgDB::Options* dbOptions =0L ) const;
/**
* Removes a function loaded by load from the VirtualProgram.
*/
bool unload(
VirtualProgram* vp,
const std::string& filename,
const osgDB::Options* dbOptions =0L ) const;
/**
* Adds all the functions in this package to the VirtualProgram.
*/
bool loadAll(
VirtualProgram* vp,
const osgDB::Options* dbOptions =0L ) const;
/**
* Removes all the functions in this package from the VirtualProgram.
*/
bool unloadAll(
VirtualProgram* vp,
const osgDB::Options* dbOptions =0L ) const;
/**
* Defs or undefs a GLSL #define proprocessor macro.
* Don't include the "#" in the defineName.
*/
void define(
const std::string& defineName,
bool defOrUndef);
/**
* Replaces the specified string with another string in the loaded
* shader source. Nested replacements are not supported.
*/
void replace(
const std::string& pattern,
const std::string& value);
public:
typedef std::map<std::string, std::string> SourceMap;
typedef std::map<std::string, std::string> ReplaceMap;
typedef std::map<std::string, bool> DefineMap;
const SourceMap& context() const { return _sources; }
void add(const std::string& filename, const std::string& inlineSource) {
_sources[filename] = inlineSource; }
protected:
SourceMap _sources;
DefineMap _defines;
ReplaceMap _replaces;
friend class ShaderLoader;
};
/**
* Base class for local shader file/source pairs.
*/
class OSGEARTH_EXPORT ShaderLoader
{
public:
/**
* Loads shader source from the specified filename, and calls
* setFunction() on the virtual program to install the shader.
* The shader much include #pragma definitions for both its
* entry point and its location, e.g.:
*
* #pragma vp_entryPoint "oe_my_shader"
* #pargma vp_location "VERTEX_VIEW"
*/
static bool load(
VirtualProgram* vp,
const std::string& filename,
const ShaderPackage& package,
const osgDB::Options* dbOptions =0L );
/**
* Removes a function loaded by load from the VirtualProgram.
*/
static bool unload(
VirtualProgram* vp,
const std::string& filename,
const ShaderPackage& package,
const osgDB::Options* dbOptions =0L );
/**
* Loads shader source from the specified filename. If the
* file can't be found in the OSG file path, use the source
* provided in backupSource.
*/
static std::string load(
const std::string& filename,
const std::string& backupSource,
const osgDB::Options* dbOptions =0L );
static std::string load(
const std::string& filename,
const ShaderPackage& package,
const osgDB::Options* dbOptions =0L );
};
} // namespace osgEarth
#endif // OSGEARTH_SHADER_LOADER
|