コード例 #1
0
ファイル: box_drawable.cpp プロジェクト: lschuetze/FlappyBox
void BoxDrawable::visualize(::view::GlRenderer& r, ::view::GlutWindow& w)
{
	using namespace std::chrono;
	_object->setDegree(duration_cast<milliseconds>(r.game_model()->timestamp().time_since_epoch()).count() / 10 % 360);

	glRotated(_object->degree(), 0.0f, 0.0f, 1.0f);
	glTranslated(0., 0., _object->position()(2));

	glBegin(GL_LINES);
	glColor3f(0.75f, 0.75f, 0.75f);

	//bottom quarter
	glVertex3f(-1.0f, -1.0f, -1.0f);
	glVertex3f(1.0f, -1.0f, -1.0f);

	glVertex3f(-1.0f, -1.0f, -1.0f);
	glVertex3f(-1.0f, 1.0f, -1.0f);

	glVertex3f(1.0f, -1.0f, -1.0f);
	glVertex3f(1.0f, 1.0f, -1.0f);

	glVertex3f(1.0f, 1.0f, -1.0f);
	glVertex3f(-1.0f, 1.0f, -1.0f);

	//upwards
	glVertex3f(-1.0f, -1.0f, -1.0f);
	glVertex3f(-1.0f, -1.0f, 1.0f);

	glVertex3f(-1.0f, 1.0f, -1.0f);
	glVertex3f(-1.0f, 1.0f, 1.0f);

	glVertex3f(1.0f, -1.0f, -1.0f);
	glVertex3f(1.0f, -1.0f, 1.0f);

	glVertex3f(1.0f, 1.0f, -1.0f);
	glVertex3f(1.0f, 1.0f, 1.0f);

	//top quarter
	glVertex3f(-1.0f, -1.0f, 1.0f);
	glVertex3f(1.0f, -1.0f, 1.0f);

	glVertex3f(-1.0f, -1.0f, 1.0f);
	glVertex3f(-1.0f, 1.0f, 1.0f);

	glVertex3f(1.0f, -1.0f, 1.0f);
	glVertex3f(1.0f, 1.0f, 1.0f);

	glVertex3f(1.0f, 1.0f, 1.0f);
	glVertex3f(-1.0f, 1.0f, 1.0f);

	glEnd();

	w.invalidate();
}
コード例 #2
0
ファイル: particle_gl_drawable.cpp プロジェクト: 2bt/CppCG
void ParticleGlDrawable::visualize(::view::GlRenderer& r, ::view::GlutWindow& w) {
	double timestep_sec = r.game_model()->timestep().count();

	glColor3f(0, _model->hue(), 0);
	glEnable(GL_BLEND);
    glEnable(GL_POINT_SMOOTH);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glPointSize((1 - _model->age()) * 10);

	glBegin(GL_POINTS);
	vec3_type pos = _model->position();
	glVertex3f(pos[0], pos[1], pos[2]);
	glEnd();

	glDisable(GL_BLEND);

}