Esempio n. 1
0
	void draw(){
		const float *eyePos = camera.getEyePos();
		const float *target = camera.getTarget();
		const float *upVector = camera.getUpVector();
		int index = current / total;
		glMatrixMode(GL_MODELVIEW);
		glLoadIdentity();
		gluLookAt(eyePos[0], eyePos[1], eyePos[2], target[0], target[1], target[2], 
			upVector[0], upVector[1], upVector[2]);
		SurfaceGeometryF tmp;
		Drawer drawer;
		tmp.rows = tmp.cols = 100;
		tmp.startX = tmp.startY = -1.0;
		tmp.endX = tmp.endY = 1.0;
		tmp.calculateNorm = true;
		tmp.evalFunc = calc;
		for(size_t i = 0;i < surfs.size();++ i){
			surf = surfs[i].surf;
			mat(&surfs[i].color);
			//cout << surfs[i].color.x() << ' ' << surfs[i].color.y() << ' ' << surfs[i].color.z() << endl;
			drawer.draw(tmp);
		}
		if(index + 1 < surfs.size()){
			surf = interpolated.surf;			
			mat(&interpolated.color);
			drawer.draw(tmp);
		}
	}
Esempio n. 2
0
// Draw the game according the the time elapsed since the last draw
// The elapsed time is in seconds
void MainMenu::draw(const Drawer& drawer, float elapsedTime)
{
	drawer.clear(_backgroundColor);

	drawer.draw(_mainMenu);

	drawer.present();
}
Esempio n. 3
0
void display(){
	GLfloat texParams[4] = {0, 0, 0.5, 0.5};
	const float *eyePos = camera.getEyePos();
	const float *target = camera.getTarget();
	const float *upVector = camera.getUpVector();
	GLfloat white[] = {1.0, 1.0, 1.0, 1.0};
	GLfloat yellow[]= {1.0, 1.0, 0.0, 1.0};
	GLfloat mat_shininess[]={ 30.0 };
	SurfaceGeometryF tmp;
	Drawer drawer;
	//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
	tmp.startX = tmp.startY = -4;
	tmp.endX = tmp.endY = 4;
	tmp.rows = tmp.cols = slice;
	tmp.evalFunc = tmpFunc;
	tmp.normFunc = normFunc;
	tmp.hasTexture = true;
	if(tmp.normFunc == NULL)
		tmp.calculateNorm = true;
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	gluLookAt(eyePos[0], eyePos[1], eyePos[2], target[0], target[1], target[2], 
			upVector[0], upVector[1], upVector[2]);
	//glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
	//glTexGenfv(GL_S, GL_OBJECT_PLANE, texParams);
        glMaterialfv(GL_FRONT, GL_DIFFUSE, white );
        glMaterialfv(GL_BACK, GL_DIFFUSE, yellow );
        glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess );
	{
		GLuint texName;
		glGenTextures(1,&texName);                 // define texture for sixth face
		//glEnable(GL_TEXTURE_2D);
		glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
		glBindTexture(GL_TEXTURE_2D,texName);
		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
		glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA8,texture.textWidth,texture.textHeight,
		             0,GL_RGB,GL_UNSIGNED_BYTE,texture.texImage);
		drawer.draw(tmp);
		glDeleteTextures(1, &texName);
	}
	glutSwapBuffers();
}
Esempio n. 4
0
void display(){
	const float *eyePos = camera.getEyePos();
	const float *target = camera.getTarget();
	const float *upVector = camera.getUpVector();
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	gluLookAt(eyePos[0], eyePos[1], eyePos[2], target[0], target[1], target[2], 
			upVector[0], upVector[1], upVector[2]);
	glLightfv(GL_LIGHT0, GL_POSITION, light_pos0 ); // light 0
	glLightfv(GL_LIGHT1, GL_POSITION, light_pos1 ); // light 1
	Drawer drawer;
	ParametricSurfaceGeometryF g;
	g.startU = g.startV = -len;
	g.endU = g.endV = len;
	g.rows = 500;
	g.cols = 500;
	g.evalFunc = paramFunc;
	g.normFunc = NULL;
	//g.calculateNorm = false;
	//glColor3f(1.0, 1.0, 1.0);
	//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
	drawer.draw(g);
	glLineWidth(2);
	glBegin(GL_LINES);
		glColor3f(1.0, 0.0, 0.0);
		glVertex3f(-2, 0, 0);
		glVertex3f(2, 0, 0);
		glColor3f(0.0, 1.0, 0.0);
		glVertex3f(0, -2, 0);
		glVertex3f(0, 2, 0);
		glColor3f(0.0, 0.0, 1.0);
		glVertex3f(0, 0, -2);
		glVertex3f(0, 0, 2);
	glEnd();
	glutSwapBuffers();
}