goat3d

view goatview/src/goatview.cc @ 95:da100bf13f7f

[goat3d] implemented animation loading [goatview] working on the animation controls
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 19 May 2014 06:42:40 +0300
parents 21319e71117f
children 32dccb16678f b43d33f3ba69
line source
1 #include <stdio.h>
2 #include <limits.h>
3 #include <map>
4 #include "opengl.h"
5 #include <QtOpenGL/QtOpenGL>
6 #include <vmath/vmath.h>
7 #include "goatview.h"
8 #include "goat3d.h"
10 static void draw_grid();
11 static void draw_grid(float sz, int nlines, float alpha = 1.0f);
12 static void draw_node(goat3d_node *node);
13 static void draw_mesh(goat3d_mesh *mesh);
14 static int next_pow2(int x);
16 goat3d *scene;
17 static SceneModel *sdata;
18 static GoatViewport *glview;
20 static long anim_time;
21 static float cam_theta, cam_phi = 25, cam_dist = 8;
22 static float fov = 60.0;
23 static bool use_nodes = true;
24 static bool use_lighting = true;
25 static bool use_textures = true;
27 void post_redisplay()
28 {
29 if(glview) {
30 glview->updateGL();
31 }
32 }
35 GoatView::GoatView()
36 {
37 glview = 0;
38 scene_model = 0;
40 QGLFormat glfmt = QGLFormat::defaultFormat();
41 glfmt.setSampleBuffers(true);
42 QGLFormat::setDefaultFormat(glfmt);
44 QSettings settings;
45 resize(settings.value("main/size", QSize(1024, 768)).toSize());
46 move(settings.value("main/pos", QPoint(100, 100)).toPoint());
47 use_nodes = settings.value("use_nodes", true).toBool();
48 use_lighting = settings.value("use_lighting", true).toBool();
49 use_textures = settings.value("use_textures", true).toBool();
51 make_center(); // must be first
52 make_menu();
53 make_dock();
55 statusBar();
57 setWindowTitle("GoatView");
58 }
60 GoatView::~GoatView()
61 {
62 delete scene_model;
63 sdata = 0;
64 }
66 void GoatView::closeEvent(QCloseEvent *ev)
67 {
68 QSettings settings;
69 settings.setValue("main/size", size());
70 settings.setValue("main/pos", pos());
71 settings.setValue("use_nodes", use_nodes);
72 settings.setValue("use_lighting", use_lighting);
73 }
76 bool GoatView::load_scene(const char *fname)
77 {
78 if(scene) {
79 goat3d_free(scene);
80 }
81 if(!(scene = goat3d_create()) || goat3d_load(scene, fname) == -1) {
82 QMessageBox::critical(this, "Error", "Failed to load scene file: " + QString(fname));
83 return false;
84 }
86 float bmin[3], bmax[3];
87 if(goat3d_get_bounds(scene, bmin, bmax) != -1) {
88 float bsize = (Vector3(bmax[0], bmax[1], bmax[2]) - Vector3(bmin[0], bmin[1], bmin[2])).length();
89 cam_dist = bsize / tan(DEG_TO_RAD(fov) / 2.0);
90 printf("bounds size: %f, cam_dist: %f\n", bsize, cam_dist);
91 }
93 scene_model->set_scene(scene);
94 treeview->expandAll();
95 treeview->resizeColumnToContents(0);
97 sdata = scene_model; // set the global sdata ptr
98 post_redisplay();
99 return true;
100 }
102 bool GoatView::load_anim(const char *fname)
103 {
104 if(!scene) {
105 QMessageBox::critical(this, "Error", "You must load a scene before loading any animations!");
106 return false;
107 }
109 if(goat3d_load_anim(scene, fname) == -1) {
110 QMessageBox::critical(this, "Error", QString("Failed to load animation: ") + QString(fname));
111 return false;
112 }
115 long tstart = LONG_MAX, tend = LONG_MIN;
116 int num_nodes = goat3d_get_node_count(scene);
117 for(int i=0; i<num_nodes; i++) {
118 goat3d_node *node = goat3d_get_node(scene, i);
119 if(goat3d_get_node_parent(node)) {
120 continue;
121 }
123 long t0, t1;
124 if(goat3d_get_anim_timeline(node, &t0, &t1) != -1) {
125 if(t0 < tstart) tstart = t0;
126 if(t1 > tend) tend = t1;
127 }
128 }
130 if(tstart != LONG_MAX) {
131 act_play->setDisabled(false);
132 act_rewind->setDisabled(false);
133 chk_loop->setDisabled(false);
135 slider_time->setDisabled(false);
136 slider_time->setMinimum(tstart);
137 slider_time->setMaximum(tend);
139 spin_time->setDisabled(false);
140 spin_time->setMinimum(tstart);
141 spin_time->setMaximum(tend);
142 }
144 post_redisplay();
145 return true;
146 }
148 bool GoatView::make_menu()
149 {
150 // file menu
151 QMenu *menu_file = menuBar()->addMenu("&File");
153 QAction *act_open_sce = new QAction("&Open Scene", this);
154 act_open_sce->setShortcuts(QKeySequence::Open);
155 connect(act_open_sce, &QAction::triggered, this, &GoatView::open_scene);
156 menu_file->addAction(act_open_sce);
158 QAction *act_open_anm = new QAction("Open &Animation", this);
159 connect(act_open_anm, &QAction::triggered, this, &GoatView::open_anim);
160 menu_file->addAction(act_open_anm);
162 QAction *act_quit = new QAction("&Quit", this);
163 act_quit->setShortcuts(QKeySequence::Quit);
164 connect(act_quit, &QAction::triggered, [&](){ qApp->quit(); });
165 menu_file->addAction(act_quit);
167 // view menu
168 QMenu *menu_view = menuBar()->addMenu("&View");
170 QAction *act_use_nodes = new QAction("use nodes", this);
171 act_use_nodes->setCheckable(true);
172 act_use_nodes->setChecked(use_nodes);
173 connect(act_use_nodes, &QAction::triggered, this,
174 [&](){ use_nodes = !use_nodes; post_redisplay(); });
175 menu_view->addAction(act_use_nodes);
177 QAction *act_use_lighting = new QAction("lighting", this);
178 act_use_lighting->setCheckable(true);
179 act_use_lighting->setChecked(use_lighting);
180 connect(act_use_lighting, &QAction::triggered, glview, &GoatViewport::toggle_lighting);
181 menu_view->addAction(act_use_lighting);
183 // help menu
184 QMenu *menu_help = menuBar()->addMenu("&Help");
186 QAction *act_about = new QAction("&About", this);
187 connect(act_about, &QAction::triggered, this, &GoatView::show_about);
188 menu_help->addAction(act_about);
189 return true;
190 }
192 bool GoatView::make_dock()
193 {
194 // ---- side-dock ----
195 QWidget *dock_cont = new QWidget;
196 QVBoxLayout *dock_vbox = new QVBoxLayout;
197 dock_cont->setLayout(dock_vbox);
199 QDockWidget *dock = new QDockWidget(this);
200 dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
201 dock->setWidget(dock_cont);
202 addDockWidget(Qt::LeftDockWidgetArea, dock);
204 // make the tree view widget
205 treeview = new QTreeView;
206 treeview->setAlternatingRowColors(true);
207 treeview->setSelectionMode(QAbstractItemView::SingleSelection);
208 dock_vbox->addWidget(treeview);
210 scene_model = new SceneModel;
211 connect(scene_model, &SceneModel::dataChanged, [&](){ post_redisplay(); });
212 treeview->setModel(scene_model);
214 connect(treeview->selectionModel(), &QItemSelectionModel::selectionChanged,
215 [&](){ scene_model->selchange(treeview->selectionModel()->selectedIndexes()); });
217 // misc
218 QPushButton *bn_quit = new QPushButton("quit");
219 dock_vbox->addWidget(bn_quit);
220 connect(bn_quit, &QPushButton::clicked, [&](){ qApp->quit(); });
222 // ---- bottom dock ----
223 dock_cont = new QWidget;
224 QHBoxLayout *dock_hbox = new QHBoxLayout;
225 dock_cont->setLayout(dock_hbox);
227 // animation control box
228 QGroupBox *grp_anim_ctl = new QGroupBox("Animation controls");
229 // TODO figure out how these fucking stretching policies work...
230 //grp_anim_ctl->sizePolicy().setHorizontalPolicy(QSizePolicy::Maximum);
231 grp_anim_ctl->sizePolicy().setHorizontalStretch(1);
232 dock_hbox->addWidget(grp_anim_ctl);
234 QVBoxLayout *anim_ctl_box = new QVBoxLayout;
235 grp_anim_ctl->setLayout(anim_ctl_box);
237 chk_loop = new QCheckBox("loop");
238 chk_loop->setDisabled(true);
239 chk_loop->setChecked(false);
240 anim_ctl_box->addWidget(chk_loop);
242 QToolBar *toolbar_ctl = new QToolBar;
243 anim_ctl_box->addWidget(toolbar_ctl);
245 act_rewind = new QAction(style()->standardIcon(QStyle::SP_MediaSkipBackward), "Rewind", this);
246 act_rewind->setDisabled(true);
247 connect(act_rewind, &QAction::triggered, [this](){ slider_time->setValue(slider_time->minimum()); });
248 toolbar_ctl->addAction(act_rewind);
250 act_play = new QAction(style()->standardIcon(QStyle::SP_MediaPlay), "Play", this);
251 act_play->setDisabled(true);
252 toolbar_ctl->addAction(act_play);
254 // slider and spinbox
255 QWidget *ssgroup = new QWidget;
256 ssgroup->sizePolicy().setHorizontalStretch(4);
257 dock_hbox->addWidget(ssgroup);
259 QGridLayout *ssgrid = new QGridLayout;
260 //dock_hbox->addLayout(ssgrid);
261 ssgroup->setLayout(ssgrid);
263 ssgrid->addWidget(new QLabel("msec"), 0, 0);
264 spin_time = new QSpinBox;
265 spin_time->setDisabled(true);
266 ssgrid->addWidget(spin_time, 0, 1);
268 slider_time = new QSlider(Qt::Orientation::Horizontal);
269 slider_time->setDisabled(true);
270 ssgrid->addWidget(slider_time, 1, 0, 1, 3);
272 connect(slider_time, &QSlider::valueChanged,
273 [&](){ anim_time = slider_time->value(); spin_time->setValue(anim_time); post_redisplay(); });
275 typedef void (QSpinBox::*ValueChangedIntFunc)(int);
276 connect(spin_time, (ValueChangedIntFunc)&QSpinBox::valueChanged,
277 [&](){ anim_time = spin_time->value(); slider_time->setValue(anim_time); post_redisplay(); });
279 dock = new QDockWidget(this);
280 dock->setAllowedAreas(Qt::BottomDockWidgetArea);
281 dock->setWidget(dock_cont);
282 addDockWidget(Qt::BottomDockWidgetArea, dock);
284 return true;
285 }
287 bool GoatView::make_center()
288 {
289 glview = ::glview = new GoatViewport(this);
290 setCentralWidget(glview);
291 return true;
292 }
294 void GoatView::open_scene()
295 {
296 std::string fname = QFileDialog::getOpenFileName(this, "Open scene file", "",
297 "Goat3D Scene (*.goatsce);;All Files (*)").toStdString();
298 if(fname.empty()) {
299 statusBar()->showMessage("Abort: No file selected!");
300 return;
301 }
303 statusBar()->showMessage("opening scene file");
304 if(!load_scene(fname.c_str())) {
305 statusBar()->showMessage("failed to load scene file");
306 return;
307 }
308 statusBar()->showMessage("Successfully loaded scene: " + QString(fname.c_str()));
309 }
311 void GoatView::open_anim()
312 {
313 std::string fname = QFileDialog::getOpenFileName(this, "Open animation file", "",
314 "Goat3D Animation (*.goatanm);;All Files (*)").toStdString();
315 if(fname.empty()) {
316 statusBar()->showMessage("Abot: No file selected!");
317 return;
318 }
320 statusBar()->showMessage("opening animation file");
321 if(!load_anim(fname.c_str())) {
322 statusBar()->showMessage("failed to load animation file");
323 return;
324 }
325 statusBar()->showMessage("Successfully loaded animation: " + QString(fname.c_str()));
326 }
329 // ---- OpenGL viewport ----
330 GoatViewport::GoatViewport(QWidget *main_win)
331 : QGLWidget(QGLFormat(QGL::DepthBuffer | QGL::SampleBuffers))
332 {
333 this->main_win = main_win;
334 initialized = false;
335 }
337 GoatViewport::~GoatViewport()
338 {
339 }
341 QSize GoatViewport::sizeHint() const
342 {
343 return QSize(800, 600);
344 }
346 #define CRITICAL(error, detail) \
347 do { \
348 fprintf(stderr, "%s: %s\n", error, detail); \
349 QMessageBox::critical(main_win, error, detail); \
350 abort(); \
351 } while(0)
353 void GoatViewport::initializeGL()
354 {
355 if(initialized) return;
356 initialized = true;
358 init_opengl();
360 if(!GLEW_ARB_transpose_matrix) {
361 CRITICAL("OpenGL initialization failed", "ARB_transpose_matrix extension not found!");
362 }
364 glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
366 glEnable(GL_DEPTH_TEST);
367 glEnable(GL_CULL_FACE);
368 if(use_lighting) {
369 glEnable(GL_LIGHTING);
370 }
371 glEnable(GL_LIGHT0);
373 float ldir[] = {-1, 1, 2, 0};
374 glLightfv(GL_LIGHT0, GL_POSITION, ldir);
376 glEnable(GL_MULTISAMPLE);
377 }
379 void GoatViewport::resizeGL(int xsz, int ysz)
380 {
381 glViewport(0, 0, xsz, ysz);
382 glMatrixMode(GL_PROJECTION);
383 glLoadIdentity();
384 gluPerspective(60.0, (float)xsz / (float)ysz, 0.5, 5000.0);
385 }
387 void GoatViewport::paintGL()
388 {
389 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
391 glMatrixMode(GL_MODELVIEW);
392 glLoadIdentity();
393 glTranslatef(0, 0, -cam_dist);
394 glRotatef(cam_phi, 1, 0, 0);
395 glRotatef(cam_theta, 0, 1, 0);
397 draw_grid();
399 if(!scene) return;
401 if(use_nodes) {
402 int node_count = goat3d_get_node_count(scene);
403 for(int i=0; i<node_count; i++) {
404 goat3d_node *node = goat3d_get_node(scene, i);
405 if(!goat3d_get_node_parent(node)) {
406 draw_node(node); // only draw root nodes, the rest will be drawn recursively
407 }
408 }
409 } else {
410 int mesh_count = goat3d_get_mesh_count(scene);
411 for(int i=0; i<mesh_count; i++) {
412 goat3d_mesh *mesh = goat3d_get_mesh(scene, i);
413 draw_mesh(mesh);
414 }
415 }
416 }
418 void GoatViewport::toggle_lighting()
419 {
420 use_lighting = !use_lighting;
421 if(use_lighting) {
422 glEnable(GL_LIGHTING);
423 } else {
424 glDisable(GL_LIGHTING);
425 }
426 updateGL();
427 }
429 #ifndef GLEW_ARB_transpose_matrix
430 #error "GLEW_ARB_transpose_matrix undefined?"
431 #endif
433 static void draw_grid()
434 {
435 float viewsz_orig = cam_dist * tan(DEG_TO_RAD(fov) / 2.0);
436 float sz1 = next_pow2((int)viewsz_orig);
437 float sz0 = sz1 / 2.0;
438 float t = (viewsz_orig - sz0) / (sz1 - sz0);
439 float alpha = t < 0.333333 ? 0.0 : (t > 0.666666 ? 1.0 : (t - 0.333333) / 0.333333);
441 glPushAttrib(GL_ENABLE_BIT | GL_DEPTH_BITS);
443 glEnable(GL_BLEND);
444 glDepthFunc(GL_ALWAYS);
446 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
447 draw_grid(sz0 * 2.0, 10, 1.0 - alpha);
448 draw_grid(sz1 * 2.0, 10, alpha);
450 glPopAttrib();
451 }
453 static void draw_grid(float sz, int nlines, float alpha)
454 {
455 float hsz = sz / 2.0;
456 float offs = sz / (float)nlines;
458 glPushAttrib(GL_ENABLE_BIT);
459 glDisable(GL_LIGHTING);
460 glDisable(GL_TEXTURE_2D);
462 glLineWidth(2.0);
463 glBegin(GL_LINES);
464 glColor4f(1, 0, 0, alpha);
465 glVertex3f(-hsz, 0, 0);
466 glVertex3f(hsz, 0, 0);
467 glColor4f(0, 0, 1, alpha);
468 glVertex3f(0, 0, -hsz);
469 glVertex3f(0, 0, hsz);
470 glEnd();
472 glLineWidth(1.0);
473 glBegin(GL_LINES);
474 glColor4f(0.5, 0.5, 0.5, alpha);
475 for(int i=0; i<nlines / 2; i++) {
476 float dist = (float)(i + 1) * offs;
477 for(int j=0; j<2; j++) {
478 float sign = j > 0 ? -1.0 : 1.0;
479 glVertex3f(-hsz, 0, dist * sign);
480 glVertex3f(hsz, 0, dist * sign);
481 glVertex3f(dist * sign, 0, -hsz);
482 glVertex3f(dist * sign, 0, hsz);
483 }
484 }
485 glEnd();
487 glPopAttrib();
488 }
490 static void draw_node(goat3d_node *node)
491 {
492 SceneNodeData *data = sdata ? sdata->get_node_data(node) : 0;
493 if(!data) return;
495 float xform[16];
496 goat3d_get_node_matrix(node, xform, anim_time);
498 glPushMatrix();
499 glMultTransposeMatrixf(xform);
501 if(data->visible) {
502 if(goat3d_get_node_type(node) == GOAT3D_NODE_MESH) {
503 goat3d_mesh *mesh = (goat3d_mesh*)goat3d_get_node_object(node);
505 draw_mesh(mesh);
507 if(data->selected) {
508 float bmin[3], bmax[3];
509 goat3d_get_mesh_bounds(mesh, bmin, bmax);
511 glPushAttrib(GL_ENABLE_BIT);
512 glDisable(GL_LIGHTING);
514 glColor3f(0.3, 1, 0.2);
516 glBegin(GL_LINE_LOOP);
517 glVertex3f(bmin[0], bmin[1], bmin[2]);
518 glVertex3f(bmax[0], bmin[1], bmin[2]);
519 glVertex3f(bmax[0], bmin[1], bmax[2]);
520 glVertex3f(bmin[0], bmin[1], bmax[2]);
521 glEnd();
522 glBegin(GL_LINE_LOOP);
523 glVertex3f(bmin[0], bmax[1], bmin[2]);
524 glVertex3f(bmax[0], bmax[1], bmin[2]);
525 glVertex3f(bmax[0], bmax[1], bmax[2]);
526 glVertex3f(bmin[0], bmax[1], bmax[2]);
527 glEnd();
528 glBegin(GL_LINES);
529 glVertex3f(bmin[0], bmin[1], bmin[2]);
530 glVertex3f(bmin[0], bmax[1], bmin[2]);
531 glVertex3f(bmin[0], bmin[1], bmax[2]);
532 glVertex3f(bmin[0], bmax[1], bmax[2]);
533 glVertex3f(bmax[0], bmin[1], bmin[2]);
534 glVertex3f(bmax[0], bmax[1], bmin[2]);
535 glVertex3f(bmax[0], bmin[1], bmax[2]);
536 glVertex3f(bmax[0], bmax[1], bmax[2]);
537 glEnd();
539 glPopAttrib();
540 }
541 }
542 }
544 int num_child = goat3d_get_node_child_count(node);
545 for(int i=0; i<num_child; i++) {
546 draw_node(goat3d_get_node_child(node, i));
547 }
549 glPopMatrix();
550 }
552 static void draw_mesh(goat3d_mesh *mesh)
553 {
554 static const float white[] = {1, 1, 1, 1};
555 static const float black[] = {0, 0, 0, 1};
557 const float *color;
558 goat3d_material *mtl = goat3d_get_mesh_mtl(mesh);
560 if(mtl && (color = goat3d_get_mtl_attrib(mtl, GOAT3D_MAT_ATTR_DIFFUSE))) {
561 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color);
562 glColor3fv(color);
563 } else {
564 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, white);
565 glColor3fv(white);
566 }
567 if(mtl && (color = goat3d_get_mtl_attrib(mtl, GOAT3D_MAT_ATTR_SPECULAR))) {
568 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, color);
569 } else {
570 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, black);
571 }
572 if(mtl && (color = goat3d_get_mtl_attrib(mtl, GOAT3D_MAT_ATTR_SHININESS))) {
573 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, color[0]);
574 } else {
575 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 60.0);
576 }
577 // TODO texture
580 int num_faces = goat3d_get_mesh_face_count(mesh);
581 int num_verts = goat3d_get_mesh_attrib_count(mesh, GOAT3D_MESH_ATTR_VERTEX);
583 glEnableClientState(GL_VERTEX_ARRAY);
584 glVertexPointer(3, GL_FLOAT, 0, goat3d_get_mesh_attribs(mesh, GOAT3D_MESH_ATTR_VERTEX));
586 float *data;
587 if((data = (float*)goat3d_get_mesh_attribs(mesh, GOAT3D_MESH_ATTR_NORMAL))) {
588 glEnableClientState(GL_NORMAL_ARRAY);
589 glNormalPointer(GL_FLOAT, 0, data);
590 }
591 if((data = (float*)goat3d_get_mesh_attribs(mesh, GOAT3D_MESH_ATTR_TEXCOORD))) {
592 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
593 glTexCoordPointer(2, GL_FLOAT, 0, data);
594 }
596 int *indices;
597 if((indices = goat3d_get_mesh_faces(mesh))) {
598 glDrawElements(GL_TRIANGLES, num_faces * 3, GL_UNSIGNED_INT, indices);
599 } else {
600 glDrawArrays(GL_TRIANGLES, 0, num_verts * 3);
601 }
603 glDisableClientState(GL_VERTEX_ARRAY);
604 glDisableClientState(GL_NORMAL_ARRAY);
605 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
606 }
609 static float prev_x, prev_y;
610 void GoatViewport::mousePressEvent(QMouseEvent *ev)
611 {
612 prev_x = ev->x();
613 prev_y = ev->y();
614 }
616 void GoatViewport::mouseMoveEvent(QMouseEvent *ev)
617 {
618 int dx = ev->x() - prev_x;
619 int dy = ev->y() - prev_y;
620 prev_x = ev->x();
621 prev_y = ev->y();
623 if(!dx && !dy) return;
625 if(ev->buttons() & Qt::LeftButton) {
626 cam_theta += dx * 0.5;
627 cam_phi += dy * 0.5;
629 if(cam_phi < -90) cam_phi = -90;
630 if(cam_phi > 90) cam_phi = 90;
631 }
632 if(ev->buttons() & Qt::RightButton) {
633 cam_dist += dy * 0.1;
635 if(cam_dist < 0.0) cam_dist = 0.0;
636 }
637 updateGL();
638 }
640 static const char *about_str =
641 "GoatView - Goat3D scene file viewer<br>"
642 "Copyright (C) 2014 John Tsiombikas &lt;<a href=\"mailto:nuclear@mutantstargoat.com\">nuclear@mutantstargoat.com</a>&gt;<br>"
643 "<br>"
644 "This program is free software: you can redistribute it and/or modify<br>"
645 "it under the terms of the GNU General Public License as published by<br>"
646 "the Free Software Foundation, either version 3 of the License, or<br>"
647 "(at your option) any later version.<br>"
648 "<br>"
649 "This program is distributed in the hope that it will be useful,<br>"
650 "but WITHOUT ANY WARRANTY; without even the implied warranty of<br>"
651 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br>"
652 "GNU General Public License for more details.<br>"
653 "<br>"
654 "You should have received a copy of the GNU General Public License<br>"
655 "along with this program. If not, see <a href=\"http://www.gnu.org/licenses/gpl\">http://www.gnu.org/licenses/gpl</a>.";
657 void GoatView::show_about()
658 {
659 QMessageBox::information(this, "About GoatView", about_str);
660 }
663 static int next_pow2(int x)
664 {
665 x--;
666 x = (x >> 1) | x;
667 x = (x >> 2) | x;
668 x = (x >> 4) | x;
669 x = (x >> 8) | x;
670 x = (x >> 16) | x;
671 return x + 1;
672 }