glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- double width = GTK_WIDGET(opengl)->allocation.width;
- double height = GTK_WIDGET(opengl)->allocation.height;
+ GtkAllocation alloc;
+ gtk_widget_get_allocation(GTK_WIDGET(opengl), &alloc);
+ double width = alloc.width;
+ double height = alloc.height;
double ang = atan((height/2)/FOV_DIST)*2;
double atmos = 100000;
double near = MAX(elev*0.75 - atmos, 50); // View 100km of atmosphere
static gboolean run_mouse_move(GritsOpenGL *opengl, GdkEventMotion *event)
{
- gdouble height = GTK_WIDGET(opengl)->allocation.height;
+ GtkAllocation alloc;
+ gtk_widget_get_allocation(GTK_WIDGET(opengl), &alloc);
+
gdouble gl_x = event->x;
- gdouble gl_y = height - event->y;
+ gdouble gl_y = alloc.height - event->y;
gdouble delta = opengl->pickmode ? 200 : 2;
if (opengl->pickmode) {
/* Start ortho */
if (level->num >= GRITS_LEVEL_HUD) {
+ GtkAllocation alloc;
+ gtk_widget_get_allocation(GTK_WIDGET(opengl), &alloc);
glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity();
glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity();
- gint win_width = GTK_WIDGET(opengl)->allocation.width;
- gint win_height = GTK_WIDGET(opengl)->allocation.height;
- glOrtho(0, win_width, win_height, 0, 1000, -1000);
+ glOrtho(0, alloc.width, alloc.height, 0, 1000, -1000);
}
/* Draw unsorted objects without depth testing,
point->lat, point->lon, point->elev,
&px, &py, &pz);
- gint win_height = GTK_WIDGET(opengl)->allocation.height;
if (pz > 1)
return;
- glTranslated(px, win_height-py, 0);
+ GtkAllocation alloc;
+ gtk_widget_get_allocation(GTK_WIDGET(opengl), &alloc);
+ glTranslated(px, alloc.height-py, 0);
glRotatef(marker->angle, 0, 0, -1);
glTranslated(-marker->xoff, -marker->yoff, 0);
} else {
grits_viewer_get_rotation(env->viewer, &x, &y, &z);
/* Setup projection */
- gint win_width = GTK_WIDGET(opengl)->allocation.width;
- gint win_height = GTK_WIDGET(opengl)->allocation.height;
- float scale = CLAMP(MIN(win_width,win_height)/2.0 * 0.1, 40, 100);
+ GtkAllocation alloc;
+ gtk_widget_get_allocation(GTK_WIDGET(opengl), &alloc);
+ float scale = CLAMP(MIN(alloc.width,alloc.height)/2.0 * 0.1, 40, 100);
float offset = scale + 20;
- glTranslatef(win_width - offset, offset, 0);
+ glTranslatef(alloc.width - offset, offset, 0);
/* Setup state */
glClear(GL_DEPTH_BUFFER_BIT);
/* Info */
static void info_expose(GritsCallback *compass, GritsOpenGL *opengl, gpointer _env)
{
- gint win_width = GTK_WIDGET(opengl)->allocation.width;
- gint win_height = GTK_WIDGET(opengl)->allocation.height;
+ GtkAllocation alloc;
+ gtk_widget_get_allocation(GTK_WIDGET(opengl), &alloc);
/* Create cairo surface */
guint tex = 0;
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, tex);
glDisable(GL_CULL_FACE);
- glTranslatef(win_width - width, win_height - height, 0);
+ glTranslatef(alloc.width - width, alloc.height - height, 0);
glBegin(GL_QUADS);
glTexCoord2f(1, 0); glVertex3f(width, 0 , 0); // 0 - 3 0
glTexCoord2f(1, 1); glVertex3f(width, height, 0); // 1 - | |