Subversion Repositories gelsvn

Rev

Rev 341 | Rev 363 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 341 Rev 357
Line 32... Line 32...
32
 
32
 
33
#include <CGLA/Vec2i.h>
33
#include <CGLA/Vec2i.h>
34
#include <CGLA/Vec2f.h>
34
#include <CGLA/Vec2f.h>
35
#include <CGLA/Vec3f.h>
35
#include <CGLA/Vec3f.h>
36
#include <CGLA/Mat4x4f.h>
36
#include <CGLA/Mat4x4f.h>
-
 
37
#include "glsl_shader.h"
37
#include "GLGraphics/gel_glut.h"
38
#include "GLGraphics/gel_glut.h"
38
#include "GLGraphics/QuatTrackBall.h"
39
#include "GLGraphics/QuatTrackBall.h"
39
#include "GLGraphics/draw.h"
40
#include "GLGraphics/draw.h"
40
#include "Geometry/TriMesh.h"
41
#include "Geometry/TriMesh.h"
41
#include "Geometry/obj_load.h"
42
#include "Geometry/obj_load.h"
Line 178... Line 179...
178
					mat.tex_id = tex_id;
179
					mat.tex_id = tex_id;
179
			}
180
			}
180
		}
181
		}
181
	}
182
	}
182
	
183
	
-
 
184
	void toggle_wire()
-
 
185
	{
-
 
186
		static bool wire= false;
-
 
187
		static string shader_path = "/Users/jab/SrcTree/Appsrc/wireframepaper/";
-
 
188
		static GLhandleARB prog_P0;
-
 
189
		
-
 
190
		wire = !wire;
-
 
191
		static bool washere = false;
-
 
192
		if(!washere)
-
 
193
		{
-
 
194
			washere = true;
-
 
195
			
-
 
196
			// Create s	haders directly from file
-
 
197
			GLuint vs = create_glsl_shader(GL_VERTEX_SHADER, shader_path, "tri.vert");
-
 
198
			GLuint gs = create_glsl_shader(GL_GEOMETRY_SHADER_EXT, shader_path, "tri.geom");
-
 
199
			GLuint fs = create_glsl_shader(GL_FRAGMENT_SHADER, shader_path, "tri.frag");
-
 
200
			
-
 
201
			// Create the program
-
 
202
			prog_P0 = glCreateProgram();
-
 
203
			
-
 
204
			// Attach all shaders
-
 
205
			if(vs) glAttachShader(prog_P0, vs);
-
 
206
			if(gs) glAttachShader(prog_P0, gs);
-
 
207
			if(fs) glAttachShader(prog_P0, fs);
-
 
208
			
-
 
209
			// Specify input and output for the geometry shader. Note that this must be
-
 
210
			// done before linking the program.
-
 
211
			glProgramParameteriEXT(prog_P0,GL_GEOMETRY_INPUT_TYPE_EXT,GL_TRIANGLES);
-
 
212
			glProgramParameteriEXT(prog_P0,GL_GEOMETRY_VERTICES_OUT_EXT,3);
-
 
213
			glProgramParameteriEXT(prog_P0,GL_GEOMETRY_OUTPUT_TYPE_EXT,GL_TRIANGLE_STRIP);
-
 
214
			
-
 
215
			// Link the program object and print out the info log
-
 
216
			glLinkProgram(prog_P0);
-
 
217
		}
-
 
218
		if(wire)
-
 
219
		{
-
 
220
			glUseProgram(prog_P0);
-
 
221
			// Set the value of a uniform
-
 
222
			glUniform2f(glGetUniformLocation(prog_P0,"WIN_SCALE"), win_size_x/2.0, win_size_y/2.0);
-
 
223
		}
-
 
224
		else
-
 
225
			glUseProgram(0);		
-
 
226
	}
-
 
227
	
183
	bool depth_pick(int x, int y,Vec3f& wp)
228
	bool depth_pick(int x, int y,Vec3f& wp)
184
	{
229
	{
185
		// Enquire about the viewport dimensions
230
		// Enquire about the viewport dimensions
186
		GLint viewport[4];
231
		GLint viewport[4];
187
		glGetIntegerv(GL_VIEWPORT, viewport);
232
		glGetIntegerv(GL_VIEWPORT, viewport);
Line 276... Line 321...
276
void keyboard(unsigned char key, int x, int y)
321
void keyboard(unsigned char key, int x, int y)
277
{
322
{
278
    switch(key)
323
    switch(key)
279
    {
324
    {
280
		case '\033': exit(0); break;
325
		case '\033': exit(0); break;
281
			//case '+': ball->closer(); break;
-
 
282
			//case '-': ball->farther(); break;
326
		case 'w': toggle_wire(); break;
283
			//default:
-
 
284
			//    ball->up_axis(key);
-
 
285
    }
327
    }
286
}
328
}
287
}
329
}
288
 
330
 
289
int main(int argc, char** argv)
331
int main(int argc, char** argv)
Line 297... Line 339...
297
    glutKeyboardFunc(keyboard);
339
    glutKeyboardFunc(keyboard);
298
    glutMotionFunc(mouse_motion);
340
    glutMotionFunc(mouse_motion);
299
    glutMouseFunc(mouse);
341
    glutMouseFunc(mouse);
300
    //glutIdleFunc(idle);
342
    //glutIdleFunc(idle);
301
	
343
	
-
 
344
	glewInit();
-
 
345
	
302
    // GL INIT
346
    // GL INIT
303
    glClearColor(.8f, 0.9f, 1.0f, 0.f);
347
    glClearColor(.8f, 0.9f, 1.0f, 0.f);
304
    glEnable(GL_DEPTH_TEST);
348
    glEnable(GL_DEPTH_TEST);
305
    glEnable(GL_LIGHTING);
349
    glEnable(GL_LIGHTING);
306
    glEnable(GL_LIGHT0);
350
    glEnable(GL_LIGHT0);