10.11.2014 Views

Master's Thesis - Studierstube Augmented Reality Project - Graz ...

Master's Thesis - Studierstube Augmented Reality Project - Graz ...

Master's Thesis - Studierstube Augmented Reality Project - Graz ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

4.4 Visualization Framework<br />

• shallows::RenderTexture2D(texture_ptr tex) defines textures to store (shader/render)<br />

results off screen<br />

• shallows::Program and the derived shallows::GLProgram define a GLSL shader<br />

object. A shader object can be invoked by simple command functions like ...::run()<br />

or ...::activate() and initialized with the file containing the shader (or an application<br />

internal string) by ...::readFile(const char*) or similar functions.<br />

• Additional input for each shader can be submitted by functions like<br />

...::setParamx*(const char *name,...) 1 and for input textures<br />

...::setInputTexture(const char *name, ...) where char* name always refer<br />

to a string similar to the variable’s/texture’s name as defined in a shader as<br />

uniform variable; see next paragraph 4.4.1.2 for ”uniform variables”.<br />

Basically, these four kinds of objects are the main requirements for using any shader<br />

instead of an implementation with direct OpenGL commands. Nevertheless, these<br />

classes should always be instanced with boost shared pointers [Abrahams2007] to ensure<br />

a smart and correct memory management. Certainly there are also additionally<br />

more complex functions available for special needs but with this basic equipment many<br />

algorithms can be implemented.<br />

GLSL<br />

GLSL is a C-like high level language to perform even complex operation on graphics<br />

hardware vertex or fragment processing units. In the next lists only the data types,<br />

some important built-in functions and always available values and these values which<br />

have to be set necessarily in each program are defined.<br />

For using more of GLSL’s<br />

capabilities the interested reader is referred to [Fernandes2007; Tatarchuk2004]. First<br />

of all, listing 4.1 shows the simplest possible shader. Actually, these GLSL-shader does<br />

nothing else than passing through values.<br />

Listing 4.1: A very simple vertex and fragment shader in Shallows notation. They will<br />

do nothing else than passing through the given input vertices and colorize interpolated<br />

fragments between with a given texture.<br />

1 [ Vertex shader ]<br />

2<br />

1 ”x*” can refer to 1f, 1i, ... 4fv, 4iv, Matrix4fv as type qualifier.<br />

74

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!