61 #include "GlutExaminer.hh" 62 #include "../Utils/StopWatch.hh" 75 GlutExaminer(
const char* _title,
int _width,
int _height)
76 : GlutViewer(_title, _width, _height),
78 center_(
Vec3f(0.0,0.0,0.0)),
91 trackball_.set_center(
Vec3f(0,0,0));
103 glutSolidTeapot(0.5);
111 GlutExaminer::mouse(
int button,
int state,
int x,
int y)
113 if (state == GLUT_DOWN) trackball_.mouse_press(button, x, y);
114 else trackball_.mouse_release(button, x, y);
123 GlutExaminer::motion(
int x,
int y)
125 trackball_.mouse_move(x, y);
134 GlutExaminer::keyboard(
int key,
int x,
int y)
140 std::cerr <<
"Performance test: ";
141 double fps = measure_fps();
142 std::cerr << fps <<
" FPS\n";
148 GlutViewer::keyboard(key, x, y);
159 GlutExaminer::setup_scene(
const Vec3f& _center,
float _radius)
164 trackball_.set_center(_center);
166 near_ = 0.01f * radius_;
167 far_ = 10.0f * radius_;
178 GlutExaminer::view_all()
180 ACG::Vec3d t = (-(glstate_.modelview().transform_point(center_))
181 -
Vec3d(0.0f, 0.0f, 3.0f*radius_));
182 glstate_.translate(t[0], t[1], t[2], MULT_FROM_LEFT);
190 GlutExaminer::measure_fps()
192 const Vec3d t = glstate_.modelview().transform_point(center_);
194 glMatrixMode(GL_MODELVIEW);
197 StopWatch timer; timer.start();
199 for (
int i=0; i<72; ++i)
201 glstate_.translate(-t[0], -t[1], -t[2], MULT_FROM_LEFT);
202 glstate_.rotate(5.0f, 0.0f, 1.0f, 0.0f, MULT_FROM_LEFT);
203 glstate_.translate( t[0], t[1], t[2], MULT_FROM_LEFT);
208 double elapsed = timer.stop();
213 return (1000.0 / elapsed * 72.0);
static void enable(GLenum _cap)
replaces glEnable, but supports locking
VectorT< float, 3 > Vec3f
Namespace providing different geometric functions concerning angles.
VectorT< double, 3 > Vec3d
static void shadeModel(GLenum _mode)
replaces glShadeModel, supports locking