tesspot

diff src/test.c @ 2:178a9e3c3c8c

isolines
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 03 Dec 2012 07:30:39 +0200
parents befe01bbd27f
children
line diff
     1.1 --- a/src/test.c	Sun Dec 02 17:16:32 2012 +0200
     1.2 +++ b/src/test.c	Mon Dec 03 07:30:39 2012 +0200
     1.3 @@ -7,7 +7,7 @@
     1.4  #include "teapot_data.h"
     1.5  
     1.6  void disp(void);
     1.7 -void draw_teapot(void);
     1.8 +void draw_teapot(float scale);
     1.9  void draw_teapot_patch(struct vec3 *bez_cp, int *index, int flip, float rot);
    1.10  void set_material(float dr, float dg, float db, float sr, float sg, float sb, float shin);
    1.11  void reshape(int x, int y);
    1.12 @@ -25,6 +25,8 @@
    1.13  
    1.14  int main(int argc, char **argv)
    1.15  {
    1.16 +	float amb[] = {0.05, 0.05, 0.05, 0.0};
    1.17 +
    1.18  	glutInit(&argc, argv);
    1.19  	glutInitWindowSize(1280, 800);
    1.20  	glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
    1.21 @@ -35,10 +37,12 @@
    1.22  	glutKeyboardFunc(keyb);
    1.23  	glutMouseFunc(mouse);
    1.24  	glutMotionFunc(motion);
    1.25 +	glutIdleFunc(glutPostRedisplay);
    1.26  
    1.27  	glewInit();
    1.28  
    1.29 -	glClearColor(0.07, 0.07, 0.07, 1);
    1.30 +	glLightModelfv(GL_LIGHT_MODEL_AMBIENT, amb);
    1.31 +	glClearColor(amb[0], amb[1], amb[2], 1);
    1.32  
    1.33  	glEnable(GL_CULL_FACE);
    1.34  	glEnable(GL_DEPTH_TEST);
    1.35 @@ -51,6 +55,7 @@
    1.36  	printf("maximum tesselation levels: %d\n", max_tess_level);
    1.37  
    1.38  	glPatchParameteri(GL_PATCH_VERTICES, 16);
    1.39 +	glProvokingVertex(GL_FIRST_VERTEX_CONVENTION);
    1.40  
    1.41  	{
    1.42  		unsigned int vsdr, tcsdr, tesdr, psdr;
    1.43 @@ -94,17 +99,21 @@
    1.44  
    1.45  	set_material(0.2, 0.35, 1.0, 1.0, 1.0, 1.0, 60.0);
    1.46  
    1.47 -	draw_teapot();
    1.48 +	draw_teapot(2.0);
    1.49  
    1.50  	glutSwapBuffers();
    1.51  }
    1.52  
    1.53 -void draw_teapot(void)
    1.54 +void draw_teapot(float scale)
    1.55  {
    1.56  	int i;
    1.57  
    1.58 +	scale /= 2.0;
    1.59 +
    1.60  	glPushMatrix();
    1.61 +	glTranslatef(0, -3.15 * scale * 0.5, 0);
    1.62  	glRotatef(-90.0, 1, 0, 0);
    1.63 +	glScalef(scale, scale, scale);
    1.64  
    1.65  	glUseProgram(prog);
    1.66  	set_uniform_int(prog, "tess_level", tess_level);