goat3dgfx

diff examples/viewscn/src/main.cc @ 18:6f82b9b6d6c3

added the ability to render in fixed function with the mesh class
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 08 Dec 2013 01:35:30 +0200
parents f61cc1df533c
children 6236080aaea4
line diff
     1.1 --- a/examples/viewscn/src/main.cc	Sun Dec 01 02:25:29 2013 +0200
     1.2 +++ b/examples/viewscn/src/main.cc	Sun Dec 08 01:35:30 2013 +0200
     1.3 @@ -15,10 +15,12 @@
     1.4  static void motion(int x, int y);
     1.5  static bool parse_args(int argc, char **argv);
     1.6  
     1.7 -static float cam_theta, cam_phi;
     1.8 +static float cam_theta, cam_phi, cam_dist = 8;
     1.9  static const char *scene_filename;
    1.10  static Scene *scn;
    1.11  
    1.12 +static ShaderProg *sdr;
    1.13 +
    1.14  int main(int argc, char **argv)
    1.15  {
    1.16  	glutInit(&argc, argv);
    1.17 @@ -49,9 +51,15 @@
    1.18  {
    1.19  	glewInit();
    1.20  
    1.21 +	glClearColor(0.1, 0.1, 0.1, 1);
    1.22 +
    1.23  	glEnable(GL_DEPTH_TEST);
    1.24  	glEnable(GL_CULL_FACE);
    1.25  
    1.26 +	if(!(sdr = get_sdrprog("sdr/foo.v.glsl", "sdr/foo.p.glsl"))) {
    1.27 +		return false;
    1.28 +	}
    1.29 +
    1.30  	scn = new Scene;
    1.31  	if(!scn->load(scene_filename)) {
    1.32  		fatal_log("failed to load scene: %s\n", scene_filename);
    1.33 @@ -68,16 +76,28 @@
    1.34  
    1.35  static void display()
    1.36  {
    1.37 +	glClearColor(0.25, 0.25, 0.25, 1);
    1.38  	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    1.39  
    1.40  	Matrix4x4 view_matrix;
    1.41 +	view_matrix.translate(Vector3(0, 0, -cam_dist));
    1.42  	view_matrix.rotate(Vector3(1, 0, 0), M_PI * cam_phi / 180.0);
    1.43  	view_matrix.rotate(Vector3(0, 1, 0), M_PI * cam_theta / 180.0);
    1.44  	set_view_matrix(view_matrix);
    1.45  
    1.46 -	setup_gl_matrices();
    1.47 +	//setup_gl_matrices();
    1.48  
    1.49 +	bind_shader(sdr);
    1.50  	scn->draw();
    1.51 +	bind_shader(0);
    1.52 +
    1.53 +	/*glBegin(GL_QUADS);
    1.54 +	glColor3f(1, 1, 1);
    1.55 +	glVertex3f(-1, -1, 0);
    1.56 +	glVertex3f(1, -1, 0);
    1.57 +	glVertex3f(1, 1, 0);
    1.58 +	glVertex3f(-1, 1, 0);
    1.59 +	glEnd();*/
    1.60  
    1.61  	glutSwapBuffers();
    1.62  	CHECKGLERR;