[gtkglarea] examples: Use accessor functions intead direct access
- From: Javier Jardón <jjardon src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkglarea] examples: Use accessor functions intead direct access
- Date: Thu, 20 Mar 2014 01:24:31 +0000 (UTC)
commit 410dedb7da8d9b329916a9aa842e0e492eaeaded
Author: Javier Jardón <jjardon gnome org>
Date: Thu Mar 20 00:48:11 2014 +0000
examples: Use accessor functions intead direct access
examples/simple.c | 8 ++++++--
examples/viewlw.c | 10 +++++++---
examples/zktor.c | 8 ++++++--
3 files changed, 19 insertions(+), 7 deletions(-)
---
diff --git a/examples/simple.c b/examples/simple.c
index 3948fdd..49833fe 100644
--- a/examples/simple.c
+++ b/examples/simple.c
@@ -26,7 +26,9 @@ gint init(GtkWidget *widget)
/* OpenGL functions can be called only if make_current returns true */
if (gtk_gl_area_make_current(GTK_GL_AREA(widget)))
{
- glViewport(0,0, widget->allocation.width, widget->allocation.height);
+ GtkAllocation allocation;
+ gtk_widget_get_allocation (widget, &allocation);
+ glViewport(0, 0, allocation.width, allocation.height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0,100, 100,0, -1,1);
@@ -72,7 +74,9 @@ gint reshape(GtkWidget *widget, GdkEventConfigure *event)
/* OpenGL functions can be called only if make_current returns true */
if (gtk_gl_area_make_current(GTK_GL_AREA(widget)))
{
- glViewport(0,0, widget->allocation.width, widget->allocation.height);
+ GtkAllocation allocation;
+ gtk_widget_get_allocation (widget, &allocation);
+ glViewport(0, 0, allocation.width, allocation.height);
}
return TRUE;
}
diff --git a/examples/viewlw.c b/examples/viewlw.c
index 7ac9f43..8ec279c 100644
--- a/examples/viewlw.c
+++ b/examples/viewlw.c
@@ -141,7 +141,9 @@ gint glarea_configure(GtkWidget *widget, GdkEventConfigure *event)
{
/* OpenGL calls can be done only if make_current returns true */
if (gtk_gl_area_make_current(GTK_GL_AREA(widget))) {
- glViewport(0,0, widget->allocation.width, widget->allocation.height);
+ GtkAllocation allocation;
+ gtk_widget_get_allocation (widget, &allocation);
+ glViewport(0, 0, allocation.width, allocation.height);
}
return TRUE;
}
@@ -174,6 +176,7 @@ gint glarea_motion_notify(GtkWidget *widget, GdkEventMotion *event)
int x, y;
GdkRectangle area;
GdkModifierType state;
+ GtkAllocation allocation;
mesh_info *info = (mesh_info*)gtk_object_get_data(GTK_OBJECT(widget), "mesh_info");
if (event->is_hint) {
@@ -189,8 +192,9 @@ gint glarea_motion_notify(GtkWidget *widget, GdkEventMotion *event)
area.x = 0;
area.y = 0;
- area.width = widget->allocation.width;
- area.height = widget->allocation.height;
+ gtk_widget_get_allocation (widget, &allocation);
+ area.width = allocation.width;
+ area.height = allocation.height;
if (state & GDK_BUTTON1_MASK) {
/* drag in progress, simulate trackball */
diff --git a/examples/zktor.c b/examples/zktor.c
index c642d4d..cba8d69 100644
--- a/examples/zktor.c
+++ b/examples/zktor.c
@@ -743,7 +743,9 @@ gint init(GtkWidget *widget)
#endif
/* set viewport */
- glViewport(0,0, widget->allocation.width, widget->allocation.height);
+ GtkAllocation allocation;
+ gtk_widget_get_allocation (widget, &allocation);
+ glViewport(0, 0, allocation.width, allocation.height);
#if !defined(WIN32)
/* generate font display lists */
@@ -781,7 +783,9 @@ gint reshape(GtkWidget *widget, GdkEventConfigure *event)
/* OpenGL functions can be called only if make_current returns true */
if (gtk_gl_area_make_current(GTK_GL_AREA(widget)))
{
- glViewport(0,0, widget->allocation.width, widget->allocation.height);
+ GtkAllocation allocation;
+ gtk_widget_get_allocation (widget, &allocation);
+ glViewport(0, 0, allocation.width, allocation.height);
}
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]