Subversion Repositories gelsvn

Rev

Rev 409 | Rev 416 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 409 Rev 412
1
/*
1
/*
2
 *  harmonics.cpp
2
 *  harmonics.cpp
3
 *  GEL
3
 *  GEL
4
 *
4
 *
5
 *  Created by J. Andreas Bærentzen on 01/09/08.
5
 *  Created by J. Andreas Bærentzen on 01/09/08.
6
 *  Copyright 2008 __MyCompanyName__. All rights reserved.
6
 *  Copyright 2008 __MyCompanyName__. All rights reserved.
7
 *
7
 *
8
 */
8
 */
9
 
9
 
10
#include <iostream>
10
#include <iostream>
11
#include <CGLA/Vec3f.h>
11
#include <CGLA/Vec3f.h>
12
#include <CGLA/Vec3d.h>
12
#include <CGLA/Vec3d.h>
13
#include <LinAlg/Matrix.h>
13
#include <LinAlg/Matrix.h>
14
#include <LinAlg/Vector.h>
14
#include <LinAlg/Vector.h>
15
#include <LinAlg/LapackFunc.h>
15
#include <LinAlg/LapackFunc.h>
16
 
16
 
17
#include <GL/glew.h>
17
#include <GL/glew.h>
18
#include <GLGraphics/glsl_shader.h>
18
#include <GLGraphics/glsl_shader.h>
19
 
19
 
20
#include <HMesh/Manifold.h>
20
#include <HMesh/Manifold.h>
21
#include <HMesh/VertexCirculator.h>
21
#include <HMesh/VertexCirculator.h>
22
#include <HMesh/FaceCirculator.h>
22
#include <HMesh/FaceCirculator.h>
23
#include <HMesh/build_manifold.h>
23
#include <HMesh/build_manifold.h>
24
#include <HMesh/mesh_optimization.h>
24
#include <HMesh/mesh_optimization.h>
25
#include <HMesh/triangulate.h>
25
#include <HMesh/triangulate.h>
26
#include <HMesh/load.h>
26
#include <HMesh/load.h>
27
#include <HMesh/x3d_save.h>
27
#include <HMesh/x3d_save.h>
28
 
28
 
29
#include <GLConsole/GLConsole.h>
29
#include <GLConsole/GLConsole.h>
30
 
30
 
31
#include "harmonics.h"
31
#include "harmonics.h"
32
 
32
 
33
using namespace CGLA;
33
using namespace CGLA;
34
using namespace std;
34
using namespace std;
35
using namespace HMesh;
35
using namespace HMesh;
36
using namespace Geometry;
36
using namespace Geometry;
37
using namespace GLGraphics;
37
using namespace GLGraphics;
38
using namespace LinAlg;
38
using namespace LinAlg;
-
 
39
using namespace CVarUtils;
39
 
40
 
40
bool Harmonics::is_initialized=false;
41
bool Harmonics::is_initialized=false;
41
GLuint Harmonics::prog_P0;
42
GLuint Harmonics::prog_P0;
42
 
43
 
43
 
44
 
44
namespace
45
namespace
45
{
46
{
46
 
47
 
47
	string vss =
48
	string vss =
48
"#version 120\n"
49
"#version 120\n"
49
"#extension GL_EXT_gpu_shader4 : enable\n"
50
"#extension GL_EXT_gpu_shader4 : enable\n"
50
"	\n"
51
"	\n"
51
"	\n"
52
"	\n"
52
"	attribute float eigenvalue;\n"
53
"	attribute float eigenvalue;\n"
53
"	attribute float eigenvalue2;\n"
54
"	attribute float eigenvalue2;\n"
54
"	varying vec3 normal;\n"
55
"	varying vec3 normal;\n"
55
"	varying float eig;\n"
56
"	varying float eig;\n"
56
"	varying float eig2;\n"
57
"	varying float eig2;\n"
57
"	\n"
58
"	\n"
58
"	void main(void)\n"
59
"	void main(void)\n"
59
"	{\n"
60
"	{\n"
60
"		gl_Position =  ftransform();\n"
61
"		gl_Position =  ftransform();\n"
61
"		normal = normalize(gl_NormalMatrix * gl_Normal);\n"
62
"		normal = normalize(gl_NormalMatrix * gl_Normal);\n"
62
"		eig = eigenvalue;\n"
63
"		eig = eigenvalue;\n"
63
"		eig2 = eigenvalue2;\n"
64
"		eig2 = eigenvalue2;\n"
64
"	}\n";
65
"	}\n";
65
	
66
	
66
string fss = 	
67
string fss = 	
67
"#version 120\n"
68
"#version 120\n"
68
"#extension GL_EXT_gpu_shader4 : enable\n"
69
"#extension GL_EXT_gpu_shader4 : enable\n"
69
"	\n"
70
"	\n"
70
"	varying vec3 normal;\n"
71
"	varying vec3 normal;\n"
71
"	varying float eig;\n"
72
"	varying float eig;\n"
72
"	varying float eig2;\n"
73
"	varying float eig2;\n"
73
"	uniform float eig_max;\n"
74
"	uniform float eig_max;\n"
74
"	uniform float eig_max2;\n"
75
"	uniform float eig_max2;\n"
75
"	uniform bool do_highlight;\n"
76
"	uniform bool do_highlight;\n"
76
"	uniform bool do_diffuse;\n"
77
"	uniform bool do_diffuse;\n"
77
"	const vec3 light_dir = vec3(0,0,1);\n"
78
"	const vec3 light_dir = vec3(0,0,1);\n"
78
"	\n"
79
"	\n"
79
"	void main()\n"
80
"	void main()\n"
80
"	{\n"
81
"	{\n"
81
"		float dot_ln = dot(light_dir, normal);\n"
82
"		float dot_ln = dot(light_dir, normal);\n"
82
"		\n"
83
"		\n"
83
"		float eig_norm = eig/eig_max;\n"
84
"		float eig_norm = eig/eig_max;\n"
84
"		float stripe_signal = 100 * eig_norm;\n"
85
"		float stripe_signal = 100 * eig_norm;\n"
85
"		vec4 stripe_col = abs(stripe_signal) < 3.14 ? vec4(1,1,0,0) : vec4(.1,.1,.1,0);\n"
86
"		vec4 stripe_col = abs(stripe_signal) < 3.14 ? vec4(1,1,0,0) : vec4(.1,.1,.1,0);\n"
86
"		\n"
87
"		\n"
87
"		gl_FragColor = eig_norm * vec4(-1,0,1,0);\n"
88
"		gl_FragColor = eig_norm * vec4(-1,0,1,0);\n"
88
"		if(do_diffuse)   gl_FragColor *= dot_ln;\n"
89
"		if(do_diffuse)   gl_FragColor *= dot_ln;\n"
89
"		if(do_highlight) gl_FragColor += dot_ln*dot_ln*dot_ln*dot_ln*dot_ln*dot_ln*dot_ln*vec4(.5,.5,.5,0);\n"
90
"		if(do_highlight) gl_FragColor += dot_ln*dot_ln*dot_ln*dot_ln*dot_ln*dot_ln*dot_ln*vec4(.5,.5,.5,0);\n"
90
"		gl_FragColor += stripe_col * smoothstep(0.8,1.0,cos(stripe_signal));\n"
91
"		gl_FragColor += stripe_col * smoothstep(0.8,1.0,cos(stripe_signal));\n"
91
"	}\n";
92
"	}\n";
92
	
93
	
93
	double voronoi_area(VertexIter v)
94
	double voronoi_area(VertexIter v)
94
	{
95
	{
95
	double area_mixed = 0;
96
	double area_mixed = 0;
96
	//For each triangle T from the 1-ring neighborhood of x
97
	//For each triangle T from the 1-ring neighborhood of x
97
	for(VertexCirculator vc(v); !vc.end(); ++vc)
98
	for(VertexCirculator vc(v); !vc.end(); ++vc)
98
	{
99
	{
99
		FaceIter f = vc.get_face();
100
		FaceIter f = vc.get_face();
100
		double f_area = area(f);
101
		double f_area = area(f);
101
		
102
		
102
		HalfEdgeIter he = vc.get_halfedge();
103
		HalfEdgeIter he = vc.get_halfedge();
103
		Vec3d v1(he->vert->pos);
104
		Vec3d v1(he->vert->pos);
104
		Vec3d v2(he->next->vert->pos);
105
		Vec3d v2(he->next->vert->pos);
105
		Vec3d v0(he->next->next->vert->pos);
106
		Vec3d v0(he->next->next->vert->pos);
106
		
107
		
107
		double a0 = acos(dot(v1-v0, v2-v0)/(length(v1-v0)*length(v2-v0)));
108
		double a0 = acos(dot(v1-v0, v2-v0)/(length(v1-v0)*length(v2-v0)));
108
		double a1 = acos(dot(v2-v1, v0-v1)/(length(v2-v1)*length(v0-v1)));
109
		double a1 = acos(dot(v2-v1, v0-v1)/(length(v2-v1)*length(v0-v1)));
109
		double a2 = acos(dot(v0-v2, v1-v2)/(length(v0-v2)*length(v1-v2)));
110
		double a2 = acos(dot(v0-v2, v1-v2)/(length(v0-v2)*length(v1-v2)));
110
		
111
		
111
		if(a0>(M_PI/2.0) && a1>(M_PI/2.0) && a2>(M_PI/2.0)) // f is non-obtuse
112
		if(a0>(M_PI/2.0) && a1>(M_PI/2.0) && a2>(M_PI/2.0)) // f is non-obtuse
112
		{
113
		{
113
			// Add Voronoi formula (see Section 3.3)
114
			// Add Voronoi formula (see Section 3.3)
114
			area_mixed += (1.0/8) * 
115
			area_mixed += (1.0/8) * 
115
			((1.0/tan(a1)) * sqr_length(v2-v0) + 
116
			((1.0/tan(a1)) * sqr_length(v2-v0) + 
116
			 (1.0/tan(a2)) * sqr_length(v1-v0));
117
			 (1.0/tan(a2)) * sqr_length(v1-v0));
117
		}
118
		}
118
		else // Voronoi inappropriate
119
		else // Voronoi inappropriate
119
		{
120
		{
120
			// Add either area(f)/4 or area(f)/2
121
			// Add either area(f)/4 or area(f)/2
121
			if(a0>M_PI/2.0)// the angle of f at x is obtuse
122
			if(a0>M_PI/2.0)// the angle of f at x is obtuse
122
				area_mixed += f_area/2;
123
				area_mixed += f_area/2;
123
			else
124
			else
124
				area_mixed += f_area/4;
125
				area_mixed += f_area/4;
125
		}
126
		}
126
	}
127
	}
127
	return area_mixed;
128
	return area_mixed;
128
}
129
}
129
 
130
 
130
	double barycentric_area(VertexIter v)
131
	double barycentric_area(VertexIter v)
131
	{
132
	{
132
	double barea = 0;
133
	double barea = 0;
133
	//For each triangle T from the 1-ring neighborhood of x
134
	//For each triangle T from the 1-ring neighborhood of x
134
	for(VertexCirculator vc(v); !vc.end(); ++vc)
135
	for(VertexCirculator vc(v); !vc.end(); ++vc)
135
	{
136
	{
136
		FaceIter f = vc.get_face();
137
		FaceIter f = vc.get_face();
137
		barea += area(f)/3.0;
138
		barea += area(f)/3.0;
138
	}
139
	}
139
	return barea;
140
	return barea;
140
}
141
}
141
 
142
 
142
}
143
}
143
 
144
 
144
void Harmonics::make_laplace_operator()
145
void Harmonics::make_laplace_operator()
145
{
146
{
146
	Q.Resize(mani.no_vertices(), mani.no_vertices());
147
	Q.Resize(mani.no_vertices(), mani.no_vertices());
147
	
148
	
148
	for(VertexIter v = mani.vertices_begin(); v != mani.vertices_end(); ++v)
149
	for(VertexIter v = mani.vertices_begin(); v != mani.vertices_end(); ++v)
149
		if(!is_boundary(v))
150
		if(!is_boundary(v))
150
		{
151
		{
151
			int i = v->touched;
152
			int i = v->touched;
152
			double area_i = voronoi_area(v);
153
			double area_i = voronoi_area(v);
153
			Vec3d vertex(v->pos);
154
			Vec3d vertex(v->pos);
154
			Vec3d curv_normal(0);
155
			Vec3d curv_normal(0);
155
			double a_sum = 0;
156
			double a_sum = 0;
156
			for(VertexCirculator vc(v); !vc.end(); ++vc)
157
			for(VertexCirculator vc(v); !vc.end(); ++vc)
157
			{
158
			{
158
				int j = vc.get_vertex()->touched;
159
				int j = vc.get_vertex()->touched;
159
				double area_j = voronoi_area(vc.get_vertex());
160
				double area_j = voronoi_area(vc.get_vertex());
160
				HalfEdgeIter h = vc.get_halfedge();
161
				HalfEdgeIter h = vc.get_halfedge();
161
				Vec3d nbr(h->vert->pos);
162
				Vec3d nbr(h->vert->pos);
162
				Vec3d left(h->next->vert->pos);
163
				Vec3d left(h->next->vert->pos);
163
				Vec3d right(h->opp->prev->opp->vert->pos);
164
				Vec3d right(h->opp->prev->opp->vert->pos);
164
				
165
				
165
				double d_left = dot(normalize(nbr-left),
166
				double d_left = dot(normalize(nbr-left),
166
									normalize(vertex-left));
167
									normalize(vertex-left));
167
				double d_right = dot(normalize(nbr-right),
168
				double d_right = dot(normalize(nbr-right),
168
									 normalize(vertex-right));
169
									 normalize(vertex-right));
169
				double a_left  = acos(min(1.0, max(-1.0, d_left)));
170
				double a_left  = acos(min(1.0, max(-1.0, d_left)));
170
				double a_right = acos(min(1.0, max(-1.0, d_right)));
171
				double a_right = acos(min(1.0, max(-1.0, d_right)));
171
				
172
				
172
				double w = 1.0/tan(a_left) + 1.0/tan(a_right);
173
				double w = 1.0/tan(a_left) + 1.0/tan(a_right);
173
				
174
				
174
				Q[i][j] = -w/sqrt(area_i*area_j);						
175
				Q[i][j] = -w/sqrt(area_i*area_j);						
175
				//Q[i][j] = -1;						
176
				//Q[i][j] = -1;						
176
				a_sum += Q[i][j];
177
				a_sum += Q[i][j];
177
			}
178
			}
178
			Q[i][i] = -a_sum;
179
			Q[i][i] = -a_sum;
179
		}
180
		}
180
	EigenSolutionsSym(Q,V);
181
	EigenSolutionsSym(Q,V);
181
	
182
	
182
}
183
}
183
 
184
 
184
 
185
 
185
Harmonics::Harmonics(Manifold& _mani):mani(_mani)
186
Harmonics::Harmonics(Manifold& _mani):mani(_mani)
186
{
187
{
187
	assert(is_initialized);
188
	assert(is_initialized);
188
		
189
		
189
	triangulate(mani);
190
	triangulate(mani);
190
	mani.enumerate_vertices();
191
	mani.enumerate_vertices();
191
	maximum_eigenvalue = mani.no_vertices()-1;
192
	maximum_eigenvalue = mani.no_vertices()-1;
192
	make_laplace_operator();
193
	make_laplace_operator();
193
	
194
	
194
	proj.resize(maximum_eigenvalue);
195
	proj.resize(maximum_eigenvalue);
195
	max_eig_values.resize(maximum_eigenvalue, 1e-10f);
196
	max_eig_values.resize(maximum_eigenvalue, 1e-10f);
196
 
197
 
197
	for(int es=0; es<maximum_eigenvalue; ++es)
198
	for(int es=0; es<maximum_eigenvalue; ++es)
198
	{
199
	{
199
		proj[es] = Vec3d(0.0);
200
		proj[es] = Vec3d(0.0);
200
		for(VertexIter v=mani.vertices_begin(); v != mani.vertices_end(); ++v)
201
		for(VertexIter v=mani.vertices_begin(); v != mani.vertices_end(); ++v)
201
		{
202
		{
202
 
203
 
203
			proj[es] +=  Vec3d(v->pos) * Q[es][v->touched];
204
			proj[es] +=  Vec3d(v->pos) * Q[es][v->touched];
204
			max_eig_values[es] = max(max_eig_values[es], static_cast<float>(abs(Q[es][v->touched])));
205
			max_eig_values[es] = max(max_eig_values[es], static_cast<float>(abs(Q[es][v->touched])));
205
		}
206
		}
206
	}
207
	}
207
}
208
}
208
 
209
 
209
void Harmonics::add_frequency(int es, float scale)
210
void Harmonics::add_frequency(int es, float scale)
210
{
211
{
211
	if(es<maximum_eigenvalue)
212
	if(es<maximum_eigenvalue)
212
		for(VertexIter v=mani.vertices_begin(); v != mani.vertices_end(); ++v)
213
		for(VertexIter v=mani.vertices_begin(); v != mani.vertices_end(); ++v)
213
		{
214
		{
214
			Vec3f p = Vec3f(proj[es]);
215
			Vec3f p = Vec3f(proj[es]);
215
			double Qval = Q[es][v->touched];
216
			double Qval = Q[es][v->touched];
216
			
217
			
217
			v->pos += p * Qval * scale; 	
218
			v->pos += p * Qval * scale; 	
218
		}
219
		}
219
}
220
}
220
 
221
 
221
void Harmonics::reset_shape()
222
void Harmonics::reset_shape()
222
{
223
{
223
	for(VertexIter v=mani.vertices_begin(); v != mani.vertices_end(); ++v)
224
	for(VertexIter v=mani.vertices_begin(); v != mani.vertices_end(); ++v)
224
		v->pos = Vec3f(0);	
225
		v->pos = Vec3f(0);	
225
}
226
}
226
void Harmonics::partial_reconstruct(int E0, int E1, float scale)
227
void Harmonics::partial_reconstruct(int E0, int E1, float scale)
227
{
228
{
228
	for(int es=E0;es<=E1;++es)
229
	for(int es=E0;es<=E1;++es)
229
		add_frequency(es, scale);
230
		add_frequency(es, scale);
230
}
231
}
231
 
232
 
232
 
-
 
233
template<typename T>
-
 
234
T& get_CVar_ref(const std::string& s)
-
 
235
{
-
 
236
	return *reinterpret_cast<T*> (GetCVarData(s));
-
 
237
}
-
 
238
 
-
 
239
void Harmonics::parse_key(unsigned char key)
233
void Harmonics::parse_key(unsigned char key)
240
{
234
{
241
		int& display_eigenvalue = get_CVar_ref<int>("display.harmonics.eigenvalue");
235
		int& display_eigenvalue = GetCVarRef<int>("display.harmonics.eigenvalue");
242
		int& display_diffuse = get_CVar_ref<int>("display.harmonics.diffuse");
236
		int& display_diffuse = GetCVarRef<int>("display.harmonics.diffuse");
243
		int& display_highlight = get_CVar_ref<int>("display.harmonics.highlight");
237
		int& display_highlight = GetCVarRef<int>("display.harmonics.highlight");
244
		switch(key) {
238
		switch(key) {
245
			case '+': 
239
			case '+': 
246
				display_eigenvalue = min(display_eigenvalue+1, maximum_eigenvalue); 
240
				display_eigenvalue = min(display_eigenvalue+1, maximum_eigenvalue); 
247
				break;
241
				break;
248
			case '-': 
242
			case '-': 
249
				display_eigenvalue = max(display_eigenvalue-1, 0); 
243
				display_eigenvalue = max(display_eigenvalue-1, 0); 
250
				break;
244
				break;
251
			case 'd':	
245
			case 'd':	
252
				display_diffuse = !display_diffuse; 
246
				display_diffuse = !display_diffuse; 
253
				break;
247
				break;
254
			case 'h':
248
			case 'h':
255
				display_highlight = !display_highlight;
249
				display_highlight = !display_highlight;
256
				break;			
250
				break;			
257
		}
251
		}
258
 
252
 
259
}
253
}
260
 
254
 
261
void Harmonics::draw()
255
void Harmonics::draw()
262
{
256
{
263
	int& display_eigen = get_CVar_ref<int>("display.harmonics.eigenvalue");
257
	int& display_eigen = GetCVarRef<int>("display.harmonics.eigenvalue");
264
	int& display_eigen2 = get_CVar_ref<int>("display.harmonics.eigenvalue");
258
	int& display_eigen2 = GetCVarRef<int>("display.harmonics.eigenvalue");
265
	int& do_diffuse = get_CVar_ref<int>("display.harmonics.diffuse");
259
	int& do_diffuse = GetCVarRef<int>("display.harmonics.diffuse");
266
	int& do_highlight = get_CVar_ref<int>("display.harmonics.highlight");
260
	int& do_highlight = GetCVarRef<int>("display.harmonics.highlight");
267
 
261
 
268
 
262
 
269
	glUseProgram(prog_P0);
263
	glUseProgram(prog_P0);
270
	glUniform1f(glGetUniformLocation(prog_P0,"eig_max"),max_eig_values[display_eigen]);
264
	glUniform1f(glGetUniformLocation(prog_P0,"eig_max"),max_eig_values[display_eigen]);
271
	glUniform1f(glGetUniformLocation(prog_P0,"eig_max2"),max_eig_values[display_eigen2]);
265
	glUniform1f(glGetUniformLocation(prog_P0,"eig_max2"),max_eig_values[display_eigen2]);
272
	glUniform1i(glGetUniformLocation(prog_P0,"do_diffuse"),do_diffuse);
266
	glUniform1i(glGetUniformLocation(prog_P0,"do_diffuse"),do_diffuse);
273
   	glUniform1i(glGetUniformLocation(prog_P0,"do_highlight"),do_highlight);
267
   	glUniform1i(glGetUniformLocation(prog_P0,"do_highlight"),do_highlight);
274
	GLuint attrib = glGetAttribLocationARB(prog_P0, "eigenvalue");
268
	GLuint attrib = glGetAttribLocationARB(prog_P0, "eigenvalue");
275
	GLuint attrib2 = glGetAttribLocationARB(prog_P0, "eigenvalue2");
269
	GLuint attrib2 = glGetAttribLocationARB(prog_P0, "eigenvalue2");
276
	
270
	
277
	glFrontFace(GL_CW);
271
	glFrontFace(GL_CW);
278
	for(FaceIter f=mani.faces_begin(); f != mani.faces_end(); ++f)
272
	for(FaceIter f=mani.faces_begin(); f != mani.faces_end(); ++f)
279
	{
273
	{
280
		FaceCirculator fc(f);
274
		FaceCirculator fc(f);
281
		glBegin(GL_TRIANGLES);
275
		glBegin(GL_TRIANGLES);
282
		while(!fc.end())
276
		while(!fc.end())
283
		{
277
		{
284
			int i = fc.get_vertex()->touched;
278
			int i = fc.get_vertex()->touched;
285
			glVertexAttrib1f(attrib,Q[display_eigen][i]);
279
			glVertexAttrib1f(attrib,Q[display_eigen][i]);
286
			glVertexAttrib1f(attrib2,Q[display_eigen2][i]);
280
			glVertexAttrib1f(attrib2,Q[display_eigen2][i]);
287
			glNormal3fv(normal(fc.get_vertex()).get());
281
			glNormal3fv(normal(fc.get_vertex()).get());
288
			glVertex3fv(fc.get_vertex()->pos.get());
282
			glVertex3fv(fc.get_vertex()->pos.get());
289
			++fc;
283
			++fc;
290
		}
284
		}
291
		glEnd();
285
		glEnd();
292
	}
286
	}
293
	glFrontFace(GL_CCW);
287
	glFrontFace(GL_CCW);
294
	glUseProgram(0);
288
	glUseProgram(0);
295
}
289
}
296
 
290
 
297
void Harmonics::init()
291
void Harmonics::init()
298
{
292
{
299
	is_initialized = true;
293
	is_initialized = true;
300
	string shader_path = "/Users/jab/GEL/apps/MeshEdit/";
294
	string shader_path = "/Users/jab/GEL/apps/MeshEdit/";
301
	GLuint vs = create_glsl_shader(GL_VERTEX_SHADER, vss);
295
	GLuint vs = create_glsl_shader(GL_VERTEX_SHADER, vss);
302
	GLuint fs = create_glsl_shader(GL_FRAGMENT_SHADER, fss);
296
	GLuint fs = create_glsl_shader(GL_FRAGMENT_SHADER, fss);
303
	
297
	
304
	// Create the program
298
	// Create the program
305
	prog_P0 = glCreateProgram();
299
	prog_P0 = glCreateProgram();
306
	
300
	
307
	// Attach all shaders
301
	// Attach all shaders
308
	if(vs) glAttachShader(prog_P0, vs);
302
	if(vs) glAttachShader(prog_P0, vs);
309
	if(fs) glAttachShader(prog_P0, fs);
303
	if(fs) glAttachShader(prog_P0, fs);
310
	
304
	
311
	// Link the program object and print out the info log
305
	// Link the program object and print out the info log
312
	glLinkProgram(prog_P0);
306
	glLinkProgram(prog_P0);
313
	print_glsl_program_log(prog_P0);
307
	print_glsl_program_log(prog_P0);
314
	
308
	
315
	// Install program object as part of current state
309
	// Install program object as part of current state
316
	glUseProgram(0);
310
	glUseProgram(0);
317
	
311
	
318
	static CVar<int> display_eigen("display.harmonics.eigenvalue",0);
312
	CreateCVar("display.harmonics.eigenvalue",0);
319
	static CVar<int> display_eigen2("display.harmonics.eigenvalue2",0);
313
	CreateCVar("display.harmonics.eigenvalue2",0);
320
	static CVar<int> do_highlight("display.harmonics.highlight",1);
314
	CreateCVar("display.harmonics.highlight",1);
321
	static CVar<int> do_diffuse("display.harmonics.diffuse",1);
315
	CreateCVar("display.harmonics.diffuse",1);
322
 
316
 
323
}
317
}
324
 
318