/*
- * Copyright (C) 2009-2010 Andy Spencer <andy753421@gmail.com>
+ * Copyright (C) 2009-2011 Andy Spencer <andy753421@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include <glib.h>
#include <math.h>
#include <string.h>
-#include <GL/gl.h>
-#include <GL/glu.h>
+#include "gtkgl.h"
#include "gpqueue.h"
#include "grits-util.h"
#include "roam.h"
sphere->polys = 8;
sphere->triangles = g_pqueue_new((GCompareDataFunc)tri_cmp, NULL);
sphere->diamonds = g_pqueue_new((GCompareDataFunc)dia_cmp, NULL);
+ sphere->view = g_new0(RoamView, 1);
RoamPoint *vertexes[] = {
roam_point_new( 90, 0, 0), // 0 (North)
*/
void roam_sphere_update_view(RoamSphere *sphere)
{
- if (!sphere->view)
- sphere->view = g_new0(RoamView, 1);
glGetDoublev (GL_MODELVIEW_MATRIX, sphere->view->model);
glGetDoublev (GL_PROJECTION_MATRIX, sphere->view->proj);
glGetIntegerv(GL_VIEWPORT, sphere->view->view);
void roam_sphere_update_errors(RoamSphere *sphere)
{
g_debug("RoamSphere: update_errors - polys=%d", sphere->polys);
+
+ static int version = 0;
+ if (version == sphere->view->version)
+ return;
+ version = sphere->view->version;
+
GPtrArray *tris = g_pqueue_get_array(sphere->triangles);
GPtrArray *dias = g_pqueue_get_array(sphere->diamonds);
- roam_sphere_update_view(sphere);
-
for (int i = 0; i < tris->len; i++) {
RoamTriangle *triangle = tris->pdata[i];
roam_triangle_update_errors(triangle, sphere);