File: Utility.h

package info (click to toggle)
openscenegraph 3.2.3%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 32,824 kB
  • sloc: cpp: 370,040; ansic: 9,071; java: 1,020; yacc: 548; objc: 288; makefile: 285; xml: 155; lex: 151
file content (57 lines) | stat: -rw-r--r-- 1,307 bytes parent folder | download | duplicates (12)
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
/*
  Steffen Frey
  Fachpraktikum Graphik-Programmierung 2007
  Institut fuer Visualisierung und Interaktive Systeme
  Universitaet Stuttgart
 */


#ifndef _UTILITY_H_
#define _UTILITY_H_

#include <string>
#include <sstream>
#include <osg/Program>
#include <osg/Texture2D>

namespace Utility
{
/*!
  Reads a file and returns a string
 */
bool readFile(const char* fName, std::string& s);

/*!
  Converts a number to a string
 */
std::string toString(double d);

/*!
  Create a osg shader program consisting of a vertex shader and a 
  fragment shader
 */
osg::Program* createProgram(std::string vs, std::string fs);

/*!
This is a random generator to generate noise patterns.
The returned values range from -1 to 1
*/
double getNoise(unsigned x, unsigned y, unsigned random);

/*!
  Returns a smoothed noise version of the value that is read from the noise
  texture
 */
double smoothNoise(unsigned width, unsigned height, unsigned x, unsigned y, unsigned char* noise);

/*!
  Creates a two dimensional color texture and apply some standard settings
 */
 osg::Texture2D* newColorTexture2D(unsigned width, unsigned height, unsigned accuracy);

/*!
  Get a quad with screen size in order to show a texture full screen
 */
osg::Geode* getCanvasQuad(unsigned width, unsigned height, double depth=-1);
}
#endif