X-Git-Url: http://pileus.org/git/?p=grits;a=blobdiff_plain;f=src%2Fplugins%2Fexample.c;h=3d6a6683964c5fcef1241ee46b9225864d6664a9;hp=01ef9cad5f11a9647723eae9d8bc382041492b97;hb=d01fb11de5bcf91224348bf41abb6788d0af2545;hpb=372f8b7c6c2f487508fd345a83b92c709c94baa1 diff --git a/src/plugins/example.c b/src/plugins/example.c index 01ef9ca..3d6a668 100644 --- a/src/plugins/example.c +++ b/src/plugins/example.c @@ -24,58 +24,6 @@ #include "example.h" -/**************** - * GObject code * - ****************/ -/* Plugin init */ -static gboolean rotate(gpointer _self); -static void gis_plugin_example_plugin_init(GisPluginInterface *iface); -static void gis_plugin_example_expose(GisPlugin *_self); -static GtkWidget *gis_plugin_example_get_config(GisPlugin *_self); -G_DEFINE_TYPE_WITH_CODE(GisPluginExample, gis_plugin_example, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE(GIS_TYPE_PLUGIN, - gis_plugin_example_plugin_init)); -static void gis_plugin_example_plugin_init(GisPluginInterface *iface) -{ - g_debug("GisPluginExample: plugin_init"); - /* Add methods to the interface */ - iface->expose = gis_plugin_example_expose; - iface->get_config = gis_plugin_example_get_config; -} -/* Class/Object init */ -static void gis_plugin_example_init(GisPluginExample *self) -{ - g_debug("GisPluginExample: init"); - /* Set defaults */ - self->button = GTK_TOGGLE_BUTTON(gtk_toggle_button_new_with_label("Rotate")); - self->rotate_id = g_timeout_add(1000/60, rotate, self); - self->rotation = 30.0; - self->opengl = NULL; -} -static void gis_plugin_example_dispose(GObject *gobject) -{ - g_debug("GisPluginExample: dispose"); - GisPluginExample *self = GIS_PLUGIN_EXAMPLE(gobject); - g_source_remove(self->rotate_id); - /* Drop references */ - G_OBJECT_CLASS(gis_plugin_example_parent_class)->dispose(gobject); -} -static void gis_plugin_example_finalize(GObject *gobject) -{ - g_debug("GisPluginExample: finalize"); - GisPluginExample *self = GIS_PLUGIN_EXAMPLE(gobject); - /* Free data */ - G_OBJECT_CLASS(gis_plugin_example_parent_class)->finalize(gobject); - -} -static void gis_plugin_example_class_init(GisPluginExampleClass *klass) -{ - g_debug("GisPluginExample: class_init"); - GObjectClass *gobject_class = (GObjectClass*)klass; - gobject_class->dispose = gis_plugin_example_dispose; - gobject_class->finalize = gis_plugin_example_finalize; -} - /*********** * Helpers * ***********/ @@ -89,6 +37,7 @@ static gboolean rotate(gpointer _self) return TRUE; } + /*********** * Methods * ***********/ @@ -111,33 +60,75 @@ static void gis_plugin_example_expose(GisPlugin *_self) { GisPluginExample *self = GIS_PLUGIN_EXAMPLE(_self); g_debug("GisPluginExample: expose"); - glDisable(GL_TEXTURE_2D); - glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); - glOrtho(-1,1,-1,1,-10,10); - glMatrixMode(GL_MODELVIEW ); glPushMatrix(); glLoadIdentity(); - float light_ambient[] = {0.1f, 0.1f, 0.0f}; - float light_diffuse[] = {0.9f, 0.9f, 0.9f}; + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(1,-1, -1,1, -10,10); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + float light_ambient[] = {0.1f, 0.1f, 0.0f, 1.0f}; + float light_diffuse[] = {0.9f, 0.9f, 0.9f, 1.0f}; float light_position[] = {-30.0f, 50.0f, 40.0f, 1.0f}; glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); glLightfv(GL_LIGHT0, GL_POSITION, light_position); - glEnable(GL_LIGHT0); - glEnable(GL_LIGHTING); glEnable(GL_COLOR_MATERIAL); - glTranslatef(0.5, -0.5, -2); - glRotatef(self->rotation, 1, 0, 1); + glTranslatef(-0.5, -0.5, -2); + glRotatef(self->rotation, 1, 1, 0); glColor4f(0.9, 0.9, 0.7, 1.0); + glDisable(GL_CULL_FACE); gdk_gl_draw_teapot(TRUE, 0.25); - glColor4f(1.0, 1.0, 1.0, 1.0); +} - glDisable(GL_LIGHT0); - glDisable(GL_LIGHTING); - glDisable(GL_COLOR_MATERIAL); - glMatrixMode(GL_PROJECTION); glPopMatrix(); - glMatrixMode(GL_MODELVIEW ); glPopMatrix(); - return; +/**************** + * GObject code * + ****************/ +/* Plugin init */ +static void gis_plugin_example_plugin_init(GisPluginInterface *iface); +G_DEFINE_TYPE_WITH_CODE(GisPluginExample, gis_plugin_example, G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE(GIS_TYPE_PLUGIN, + gis_plugin_example_plugin_init)); +static void gis_plugin_example_plugin_init(GisPluginInterface *iface) +{ + g_debug("GisPluginExample: plugin_init"); + /* Add methods to the interface */ + iface->expose = gis_plugin_example_expose; + iface->get_config = gis_plugin_example_get_config; } +/* Class/Object init */ +static void gis_plugin_example_init(GisPluginExample *self) +{ + g_debug("GisPluginExample: init"); + /* Set defaults */ + self->button = GTK_TOGGLE_BUTTON(gtk_toggle_button_new_with_label("Rotate")); + self->rotate_id = g_timeout_add(1000/60, rotate, self); + self->rotation = 30.0; + self->opengl = NULL; +} +static void gis_plugin_example_dispose(GObject *gobject) +{ + g_debug("GisPluginExample: dispose"); + GisPluginExample *self = GIS_PLUGIN_EXAMPLE(gobject); + g_source_remove(self->rotate_id); + /* Drop references */ + G_OBJECT_CLASS(gis_plugin_example_parent_class)->dispose(gobject); +} +static void gis_plugin_example_finalize(GObject *gobject) +{ + g_debug("GisPluginExample: finalize"); + GisPluginExample *self = GIS_PLUGIN_EXAMPLE(gobject); + /* Free data */ + G_OBJECT_CLASS(gis_plugin_example_parent_class)->finalize(gobject); +} +static void gis_plugin_example_class_init(GisPluginExampleClass *klass) +{ + g_debug("GisPluginExample: class_init"); + GObjectClass *gobject_class = (GObjectClass*)klass; + gobject_class->dispose = gis_plugin_example_dispose; + gobject_class->finalize = gis_plugin_example_finalize; +}