1 #include <GLviewer/OutputAttachments/OutputWowDisplay.hh>
22 " gl_TexCoord[0] = gl_MultiTexCoord0;\r\n"
23 " gl_Position = ftransform();\r\n"
26 "uniform sampler2D tex;\r\n"
27 "uniform sampler2D dep;\r\n"
28 "uniform float w;\r\n"
29 "uniform float h;\r\n"
30 "uniform int header[256];\r\n"
31 "uniform float wow_disparity_M;\r\n"
32 "uniform float wow_disparity_Zd;\r\n"
33 "uniform float wow_disparity_vz;\r\n"
34 "uniform float wow_disparity_C;\r\n"
36 "float disparity(float Z)\r\n"
38 " return (wow_disparity_M*(1.0-(wow_disparity_vz/(Z-wow_disparity_Zd+wow_disparity_vz)))\r\n"
39 " + wow_disparity_C) / 255.0;\r\n"
45 " vec2 pos = gl_TexCoord[0].st;\r\n"
46 " if (mod(pos[1]*h,2.0) < 0.5)\r\n"
48 " color = vec4(0.0,0.0,0.0,0.0);\r\n"
53 " if (pos[0] < 0.5)\r\n"
58 " if (pos[1]*h>=h-1.0 && (pos[0]*w<256))\r\n"
61 " int xpos = int(pos[0]*w);\r\n"
62 " color = vec4(0.0,0.0, header[ xpos ]/255.0,1.0);\r\n"
67 " pos[0] = pos[0] * 2.0;\r\n"
68 " color = texture2D(tex,pos);\r\n"
74 " pos[0] = (pos[0]-0.5) * 2.0;\r\n"
76 " float depth = texture2D(dep,pos).z;\r\n"
77 " if (depth == 1.0)\r\n"
78 " color = vec4(0.0);\r\n"
80 " color = vec4(disparity(depth)/2.0);\r\n"
83 " gl_FragColor = color;\r\n"
92 unsigned char wow_content=0x02;
93 unsigned char wow_use_factor = 0x80;
94 unsigned char wow_use_offset = 0x40;
95 unsigned char wow_factor_UChar = wowFactor_;
96 unsigned char wow_Offset_UChar = wowOffset_;
97 unsigned char wow_use_factor_plut_offset = wow_use_factor+wow_use_offset;
99 unsigned char header[]= {0xF1,wow_content,wow_factor_UChar,wow_Offset_UChar,wow_use_factor_plut_offset,0x00,0x00,0x00,0x00,0x00};
102 unsigned long _register = 0;
103 for(
int i = 0; i < 10; ++i) {
104 unsigned char mask = 0x80;
105 unsigned char byte = header[i];
106 for (
int j = 0; j < 8; ++j)
108 bool topBit = (_register & 0x80000000) != 0;
110 _register ^= ((byte & mask) != 0? 0x1: 0x0);
113 _register ^= 0x04c11db7;
118 unsigned char *p = (
unsigned char*) &_register;
119 for(
size_t i = 0; i < 4; ++i)
121 header[i+6] = p[3-i];
127 for (
int x=0; x<256; ++x){
130 for (
int x=0; x<=9; ++x){
131 for (
int y=7; y>=0; --y){
132 int i = 2*(7-y)+16*x;
133 fullheader[i] = (((1<<(y))&(header[x])) << (7-(y)));
void SetUniform(const std::string &varName, float value)
int InitShader_()
creates strings with shader code and calls InitShader(vertex, fragment) from superclass ...
int Draw_()
standard draw from superclass does not suffice to set the header information for wow display...
virtual ~OutputWowDisplay()
int InitShader(std::string vertexCode, std::string fragmentCode)
can be called to create output attachment without having to derive new subclass will also create FBO ...
BIAS::glfShaderProgram shaderProg_
int StandardDraw_()
this function suffices for simple shaders that only need the standard uniforms to be set...
Class for extra rendering pass in GLProjection (for now only used in glutGLviewer) ...
Interface for render targets.