龙芯系统下,GTK与OPENGL共舞
龙芯操作系统下,GTK的版本是3.14,并不支持直接与OPENGL互操作。
查询了一些资料,在GtkDrawingArea上画出简单的OPENGL图形。
首先基于gtk的网站demo,链接如下:
https://wiki.gnome.org/Projects/Vala/OpenGLSamples
Using GLX: Coloured Triangle#
原始vala代码如下:
using Gtk;
using Gdk;
using GLX;
using GL;
class GLXSample : Gtk.Window {
private X.Display xdisplay;
private GLX.Context context;
private XVisualInfo xvinfo;
public GLXSample () {
this.title = "OpenGL with GLX";
set_reallocate_redraws (true);
destroy.connect (Gtk.main_quit);
int[] attrlist = {
GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DOUBLEBUFFER, 0
};
this.xdisplay = x11_get_default_xdisplay ();
if (!glXQueryExtension (xdisplay, null, null)) {
stderr.printf ("OpenGL not supported\n");
}
this.xvinfo = glXChooseVisual (xdisplay, x11_get_default_screen (), attrlist);
if (xvinfo == null) {
stderr.printf ("Error configuring OpenGL\n");
}
var drawing_area = new DrawingArea ();
drawing_area.set_size_request (300, 300);
drawing_area.set_double_buffered (false);
this.context = glXCreateContext (xdisplay, xvinfo, null, true);
drawing_area.configure_event.connect (on_configure_event);
drawing_area.expose_event.connect (on_expose_event);
add (drawing_area);
}
private bool on_configure_event (Widget widget, Gdk.EventConfigure event) {
if (!glXMakeCurrent (xdisplay, x11_drawable_get_xid (widget.window), context))
return false;
glViewport (0, 0, (GLsizei) widget.allocation.width,
(GLsizei) widget.allocation.height);
return true;
}
private bool on_expose_event (Widget widget, Gdk.EventExpose event) {
if (!glXMakeCurrent (xdisplay, x11_drawable_get_xid (widget.window), context))
return false;
glClear (GL_COLOR_BUFFER_BIT);
glBegin (GL_TRIANGLES);
glIndexi (0);
glColor3f (1.0f, 0.0f, 0.0f);
glVertex2i (0, 1);
glIndexi (0);
glColor3f (0.0f, 1.0f, 0.0f);
glVertex2i (-1, -1);
glIndexi (0);
glColor3f (0.0f, 0.0f, 1.0f);
glVertex2i (1, -1);
glEnd ();
glXSwapBuffers (xdisplay, x11_drawable_get_xid (widget.window));
return true;
}
}
void main (string[] args) {
Gtk.init (ref args);
var sample = new GLXSample ();
sample.show_all ();
Gtk.main ();
}
编译命令:
$ valac --pkg gtk+-2.0 --pkg gdk-x11-2.0 --pkg gl --pkg glx glx-sample.vala
从这儿看,基于的是gtk+-2.0,同时需要gl.vapi与glx.vapi,可以到
https://wiki.gnome.org/Projects/Vala/ExternalBindings
下去获取
在ubuntu 18.04编译时,有部分编译错误,修正后的vala代码(编译通过,并不能运行)
using Gtk;
using Gdk;
using GLX;
using GL;
class GLXSample : Gtk.Window {
private X.Display xdisplay;
private GLX.Context context;
private XVisualInfo xvinfo;
public GLXSample () {
this.title = "OpenGL with GLX";
set_reallocate_redraws (true);
destroy.connect (Gtk.main_quit);
int[] attrlist = {
GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DOUBLEBUFFER, 0
};
this.xdisplay ;//= x11_get_default_xdisplay ();
if (!glXQueryExtension (xdisplay, null, null)) {
stderr.printf ("OpenGL not supported\n");
}
this.xvinfo = glXChooseVisual (xdisplay, x11_get_default_screen (), attrlist);
if (xvinfo == null) {
stderr.printf ("Error configuring OpenGL\n");
}
var drawing_area = new DrawingArea ();
drawing_area.set_size_request (300, 300);
drawing_area.set_double_buffered (false);
this.context = glXCreateContext (xdisplay, xvinfo, null, true);
drawing_area.configure_event.connect (on_configure_event);
drawing_area.expose_event.connect (on_expose_event);
add (drawing_area);
}
private bool on_configure_event (Widget widget, Gdk.EventConfigure event) {
if (!glXMakeCurrent (xdisplay, x11_drawable_get_xid (widget.window), context))
return false;
glViewport (0, 0, (GLsizei) widget.allocation.width,
(GLsizei) widget.allocation.height);
return true;
}
private bool on_expose_event (Widget widget, Gdk.EventExpose event) {
if (!glXMakeCurrent (xdisplay, x11_drawable_get_xid (widget.window), context))
return false;
glClear (GL_COLOR_BUFFER_BIT);
glBegin (GL_TRIANGLES);
glIndexi (0);
glColor3f (1.0f, 0.0f, 0.0f);
glVertex2i (0, 1);
glIndexi (0);
glColor3f (0.0f, 1.0f, 0.0f);
glVertex2i (-1, -1);
glIndexi (0);
glColor3f (0.0f, 0.0f, 1.0f);
glVertex2i (1, -1);
glEnd ();
glXSwapBuffers (xdisplay, x11_drawable_get_xid (widget.window));
return true;
}
}
void main (string[] args) {
Gtk.init (ref args);
var sample = new GLXSample ();
sample.show_all ();
Gtk.main ();
}
针对gtk+-3.0的编译链接命令需要修改为:
$ valac --pkg gtk+-3.0 --pkg gdk-x11-3.0 --pkg gl --pkg glx glx-sample.vala
相应的vala代码为:
using Gtk;
using Gdk.X11;
using Gdk;
using GLX;
using GL;
class GLXSample : Gtk.Window {
//private X.Display xdisplay;
private GLX.Context context;
private XVisualInfo xvinfo;
public GLXSample () {
this.title = "OpenGL with GLX";
set_reallocate_redraws (true);
destroy.connect (Gtk.main_quit);
int[] attrlist = {
GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DOUBLEBUFFER, 0
};
var drawing_area = new DrawingArea ();
drawing_area.set_size_request (300, 300);
drawing_area.set_double_buffered (false);
drawing_area.show();
var gdk_display = drawing_area.get_display() as Gdk.X11.Display;
//var xdisplay = gdk_display.get_xdisplay ();
if (!glXQueryExtension (gdk_display.get_xdisplay (), null, null)) {
stderr.printf ("OpenGL not supported\n");
}
var gdk_screen = gdk_display.get_default_screen () as Gdk.X11.Screen;
this.xvinfo = glXChooseVisual (gdk_display.get_xdisplay (), gdk_screen.get_screen_number(), attrlist);
if (xvinfo == null) {
stderr.printf ("Error configuring OpenGL\n");
}
this.context = glXCreateContext (gdk_display.get_xdisplay (), xvinfo, null, true);
drawing_area.size_allocate.connect (on_size_allocate_event);
drawing_area.draw.connect (on_draw_event);
add (drawing_area);
}
private void on_size_allocate_event (Widget widget, Gtk.Allocation allocation) {
var gdk_window = widget.get_window();
if (!(gdk_window is Gdk.Window))
return;
var gdk_display = widget.get_display() as Gdk.X11.Display;
//var xdisplay = gdk_display.get_xdisplay ();
if (!glXMakeCurrent (gdk_display.get_xdisplay (), Gdk.X11Window.get_xid(gdk_window), context))
return ;//false;
glViewport (0, 0, (GLsizei) allocation.width,
(GLsizei) allocation.height);
return ;//true;
}
private bool on_draw_event (Widget widget, Cairo.Context cr) {
var gdk_window = widget.get_window() as Gdk.X11.Window;
if (!(gdk_window is Gdk.Window))
return false;
var gdk_display = widget.get_display() as Gdk.X11.Display;
//var xdisplay = gdk_display.get_xdisplay ();
if (!glXMakeCurrent (gdk_display.get_xdisplay (), gdk_window.get_xid(), context))
return false;
glClear (GL_COLOR_BUFFER_BIT);
glBegin (GL_TRIANGLES);
glIndexi (0);
glColor3f (1.0f, 0.0f, 0.0f);
glVertex2i (0, 1);
glIndexi (0);
glColor3f (0.0f, 1.0f, 0.0f);
glVertex2i (-1, -1);
glIndexi (0);
glColor3f (0.0f, 0.0f, 1.0f);
glVertex2i (1, -1);
glEnd ();
glXSwapBuffers (gdk_display.get_xdisplay (), gdk_window.get_xid());//x11_drawable_get_xid (widget.window));
return true;
}
}
void main (string[] args) {
Gtk.init (ref args);
var sample = new GLXSample ();
sample.show_all ();
Gtk.main ();
}
vala生成的代码中,基于opengl的会自动包含glew.h,狗屎,又不一定要用到,注释掉后的c代码
/* gtk3_glx-sample.c generated by valac 0.40.23, the Vala compiler
* generated from gtk3_glx-sample.vala, do not modify */
#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <GL/glx.h>
#include <gdk/gdkx.h>
#include <stdio.h>
#include <gdk/gdk.h>
#include <cairo.h>
//#include <GL/glew.h>
#include <stdlib.h>
#include <string.h>
#define TYPE_GLX_SAMPLE (glx_sample_get_type ())
#define GLX_SAMPLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GLX_SAMPLE, GLXSample))
#define GLX_SAMPLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GLX_SAMPLE, GLXSampleClass))
#define IS_GLX_SAMPLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GLX_SAMPLE))
#define IS_GLX_SAMPLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GLX_SAMPLE))
#define GLX_SAMPLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GLX_SAMPLE, GLXSampleClass))
typedef struct _GLXSample GLXSample;
typedef struct _GLXSampleClass GLXSampleClass;
typedef struct _GLXSamplePrivate GLXSamplePrivate;
enum {
GLX_SAMPLE_0_PROPERTY,
GLX_SAMPLE_NUM_PROPERTIES
};
static GParamSpec* glx_sample_properties[GLX_SAMPLE_NUM_PROPERTIES];
#define _XFree0(var) ((var == NULL) ? NULL : (var = (XFree (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
struct _GLXSample {
GtkWindow parent_instance;
GLXSamplePrivate * priv;
};
struct _GLXSampleClass {
GtkWindowClass parent_class;
};
struct _GLXSamplePrivate {
GLXContext context;
XVisualInfo* xvinfo;
};
static gpointer glx_sample_parent_class = NULL;
GType glx_sample_get_type (void) G_GNUC_CONST;
#define GLX_SAMPLE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_GLX_SAMPLE, GLXSamplePrivate))
GLXSample* glx_sample_new (void);
GLXSample* glx_sample_construct (GType object_type);
static void _gtk_main_quit_gtk_widget_destroy (GtkWidget* _sender,
gpointer self);
static void glx_sample_on_size_allocate_event (GLXSample* self,
GtkWidget* widget,
GtkAllocation* allocation);
static void _glx_sample_on_size_allocate_event_gtk_widget_size_allocate (GtkWidget* _sender,
GtkAllocation* allocation,
gpointer self);
static gboolean glx_sample_on_draw_event (GLXSample* self,
GtkWidget* widget,
cairo_t* cr);
static gboolean _glx_sample_on_draw_event_gtk_widget_draw (GtkWidget* _sender,
cairo_t* cr,
gpointer self);
static void glx_sample_finalize (GObject * obj);
void _vala_main (gchar** args,
int args_length1);
static void
_gtk_main_quit_gtk_widget_destroy (GtkWidget* _sender,
gpointer self)
{
gtk_main_quit ();
}
static gpointer
_g_object_ref0 (gpointer self)
{
return self ? g_object_ref (self) : NULL;
}
static void
_glx_sample_on_size_allocate_event_gtk_widget_size_allocate (GtkWidget* _sender,
GtkAllocation* allocation,
gpointer self)
{
glx_sample_on_size_allocate_event ((GLXSample*) self, _sender, allocation);
}
static gboolean
_glx_sample_on_draw_event_gtk_widget_draw (GtkWidget* _sender,
cairo_t* cr,
gpointer self)
{
gboolean result;
result = glx_sample_on_draw_event ((GLXSample*) self, _sender, cr);
return result;
}
GLXSample*
glx_sample_construct (GType object_type)
{
GLXSample * self = NULL;
gint* attrlist = NULL;
gint* _tmp0_;
gint attrlist_length1;
gint _attrlist_size_;
GtkDrawingArea* drawing_area = NULL;
GtkDrawingArea* _tmp1_;
GtkDrawingArea* _tmp2_;
GtkDrawingArea* _tmp3_;
GtkDrawingArea* _tmp4_;
GdkX11Display* gdk_display = NULL;
GtkDrawingArea* _tmp5_;
GdkDisplay* _tmp6_;
GdkX11Display* _tmp7_;
GdkX11Display* _tmp8_;
Display* _tmp9_;
GdkX11Screen* gdk_screen = NULL;
GdkX11Display* _tmp11_;
GdkScreen* _tmp12_;
GdkX11Screen* _tmp13_;
GdkX11Display* _tmp14_;
Display* _tmp15_;
GdkX11Screen* _tmp16_;
gint* _tmp17_;
gint _tmp17__length1;
XVisualInfo* _tmp18_;
XVisualInfo* _tmp19_;
GdkX11Display* _tmp21_;
Display* _tmp22_;
XVisualInfo* _tmp23_;
GtkDrawingArea* _tmp24_;
GtkDrawingArea* _tmp25_;
GtkDrawingArea* _tmp26_;
self = (GLXSample*) g_object_new (object_type, NULL);
gtk_window_set_title ((GtkWindow*) self, "OpenGL with GLX");
gtk_container_set_reallocate_redraws ((GtkContainer*) self, TRUE);
g_signal_connect ((GtkWidget*) self, "destroy", (GCallback) _gtk_main_quit_gtk_widget_destroy, NULL);
_tmp0_ = g_new0 (gint, 9);
_tmp0_[0] = GLX_RGBA;
_tmp0_[1] = GLX_RED_SIZE;
_tmp0_[2] = 1;
_tmp0_[3] = GLX_GREEN_SIZE;
_tmp0_[4] = 1;
_tmp0_[5] = GLX_BLUE_SIZE;
_tmp0_[6] = 1;
_tmp0_[7] = GLX_DOUBLEBUFFER;
_tmp0_[8] = 0;
attrlist = _tmp0_;
attrlist_length1 = 9;
_attrlist_size_ = attrlist_length1;
_tmp1_ = (GtkDrawingArea*) gtk_drawing_area_new ();
g_object_ref_sink (_tmp1_);
drawing_area = _tmp1_;
_tmp2_ = drawing_area;
gtk_widget_set_size_request ((GtkWidget*) _tmp2_, 300, 300);
_tmp3_ = drawing_area;
gtk_widget_set_double_buffered ((GtkWidget*) _tmp3_, FALSE);
_tmp4_ = drawing_area;
gtk_widget_show ((GtkWidget*) _tmp4_);
_tmp5_ = drawing_area;
_tmp6_ = gtk_widget_get_display ((GtkWidget*) _tmp5_);
_tmp7_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp6_, gdk_x11_display_get_type ()) ? ((GdkX11Display*) _tmp6_) : NULL);
gdk_display = _tmp7_;
_tmp8_ = gdk_display;
_tmp9_ = gdk_x11_display_get_xdisplay (_tmp8_);
if (!glXQueryExtension (_tmp9_, NULL, NULL)) {
FILE* _tmp10_;
_tmp10_ = stderr;
fprintf (_tmp10_, "OpenGL not supported\n");
}
_tmp11_ = gdk_display;
_tmp12_ = gdk_display_get_default_screen ((GdkDisplay*) _tmp11_);
_tmp13_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp12_, gdk_x11_screen_get_type ()) ? ((GdkX11Screen*) _tmp12_) : NULL);
gdk_screen = _tmp13_;
_tmp14_ = gdk_display;
_tmp15_ = gdk_x11_display_get_xdisplay (_tmp14_);
_tmp16_ = gdk_screen;
_tmp17_ = attrlist;
_tmp17__length1 = attrlist_length1;
_tmp18_ = glXChooseVisual (_tmp15_, gdk_x11_screen_get_screen_number (_tmp16_), _tmp17_);
_XFree0 (self->priv->xvinfo);
self->priv->xvinfo = _tmp18_;
_tmp19_ = self->priv->xvinfo;
if (_tmp19_ == NULL) {
FILE* _tmp20_;
_tmp20_ = stderr;
fprintf (_tmp20_, "Error configuring OpenGL\n");
}
_tmp21_ = gdk_display;
_tmp22_ = gdk_x11_display_get_xdisplay (_tmp21_);
_tmp23_ = self->priv->xvinfo;
self->priv->context = glXCreateContext (_tmp22_, _tmp23_, NULL, TRUE);
_tmp24_ = drawing_area;
g_signal_connect_object ((GtkWidget*) _tmp24_, "size-allocate", (GCallback) _glx_sample_on_size_allocate_event_gtk_widget_size_allocate, self, 0);
_tmp25_ = drawing_area;
g_signal_connect_object ((GtkWidget*) _tmp25_, "draw", (GCallback) _glx_sample_on_draw_event_gtk_widget_draw, self, 0);
_tmp26_ = drawing_area;
gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp26_);
_g_object_unref0 (gdk_screen);
_g_object_unref0 (gdk_display);
_g_object_unref0 (drawing_area);
attrlist = (g_free (attrlist), NULL);
return self;
}
GLXSample*
glx_sample_new (void)
{
return glx_sample_construct (TYPE_GLX_SAMPLE);
}
static void
glx_sample_on_size_allocate_event (GLXSample* self,
GtkWidget* widget,
GtkAllocation* allocation)
{
GdkWindow* gdk_window = NULL;
GdkWindow* _tmp0_;
GdkWindow* _tmp1_;
GdkWindow* _tmp2_;
GdkX11Display* gdk_display = NULL;
GdkDisplay* _tmp3_;
GdkX11Display* _tmp4_;
GdkX11Display* _tmp5_;
Display* _tmp6_;
GdkWindow* _tmp7_;
GLXContext _tmp8_;
GtkAllocation _tmp9_;
gint _tmp10_;
GtkAllocation _tmp11_;
gint _tmp12_;
g_return_if_fail (self != NULL);
g_return_if_fail (widget != NULL);
g_return_if_fail (allocation != NULL);
_tmp0_ = gtk_widget_get_window (widget);
_tmp1_ = _g_object_ref0 (_tmp0_);
gdk_window = _tmp1_;
_tmp2_ = gdk_window;
if (!G_TYPE_CHECK_INSTANCE_TYPE (_tmp2_, gdk_window_get_type ())) {
_g_object_unref0 (gdk_window);
return;
}
_tmp3_ = gtk_widget_get_display (widget);
_tmp4_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp3_, gdk_x11_display_get_type ()) ? ((GdkX11Display*) _tmp3_) : NULL);
gdk_display = _tmp4_;
_tmp5_ = gdk_display;
_tmp6_ = gdk_x11_display_get_xdisplay (_tmp5_);
_tmp7_ = gdk_window;
_tmp8_ = self->priv->context;
if (!glXMakeCurrent (_tmp6_, (GLXDrawable) gdk_x11_window_get_xid (_tmp7_), _tmp8_)) {
_g_object_unref0 (gdk_display);
_g_object_unref0 (gdk_window);
return;
}
_tmp9_ = *allocation;
_tmp10_ = _tmp9_.width;
_tmp11_ = *allocation;
_tmp12_ = _tmp11_.height;
glViewport ((GLint) 0, (GLint) 0, (GLsizei) _tmp10_, (GLsizei) _tmp12_);
_g_object_unref0 (gdk_display);
_g_object_unref0 (gdk_window);
return;
}
static gboolean
glx_sample_on_draw_event (GLXSample* self,
GtkWidget* widget,
cairo_t* cr)
{
gboolean result = FALSE;
GdkX11Window* gdk_window = NULL;
GdkWindow* _tmp0_;
GdkX11Window* _tmp1_;
GdkX11Window* _tmp2_;
GdkX11Display* gdk_display = NULL;
GdkDisplay* _tmp3_;
GdkX11Display* _tmp4_;
GdkX11Display* _tmp5_;
Display* _tmp6_;
GdkX11Window* _tmp7_;
GLXContext _tmp8_;
GdkX11Display* _tmp9_;
Display* _tmp10_;
GdkX11Window* _tmp11_;
g_return_val_if_fail (self != NULL, FALSE);
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (cr != NULL, FALSE);
_tmp0_ = gtk_widget_get_window (widget);
_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, gdk_x11_window_get_type ()) ? ((GdkX11Window*) _tmp0_) : NULL);
gdk_window = _tmp1_;
_tmp2_ = gdk_window;
if (!G_TYPE_CHECK_INSTANCE_TYPE (_tmp2_, gdk_window_get_type ())) {
result = FALSE;
_g_object_unref0 (gdk_window);
return result;
}
_tmp3_ = gtk_widget_get_display (widget);
_tmp4_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp3_, gdk_x11_display_get_type ()) ? ((GdkX11Display*) _tmp3_) : NULL);
gdk_display = _tmp4_;
_tmp5_ = gdk_display;
_tmp6_ = gdk_x11_display_get_xdisplay (_tmp5_);
_tmp7_ = gdk_window;
_tmp8_ = self->priv->context;
if (!glXMakeCurrent (_tmp6_, (GLXDrawable) gdk_x11_window_get_xid (_tmp7_), _tmp8_)) {
result = FALSE;
_g_object_unref0 (gdk_display);
_g_object_unref0 (gdk_window);
return result;
}
glClear ((GLbitfield) GL_COLOR_BUFFER_BIT);
glBegin ((GLenum) GL_TRIANGLES);
glIndexi ((GLint) 0);
glColor3f ((GLfloat) 1.0f, (GLfloat) 0.0f, (GLfloat) 0.0f);
glVertex2i ((GLint) 0, (GLint) 1);
glIndexi ((GLint) 0);
glColor3f ((GLfloat) 0.0f, (GLfloat) 1.0f, (GLfloat) 0.0f);
glVertex2i ((GLint) -1, (GLint) -1);
glIndexi ((GLint) 0);
glColor3f ((GLfloat) 0.0f, (GLfloat) 0.0f, (GLfloat) 1.0f);
glVertex2i ((GLint) 1, (GLint) -1);
glEnd ();
_tmp9_ = gdk_display;
_tmp10_ = gdk_x11_display_get_xdisplay (_tmp9_);
_tmp11_ = gdk_window;
glXSwapBuffers (_tmp10_, (GLXDrawable) gdk_x11_window_get_xid (_tmp11_));
result = TRUE;
_g_object_unref0 (gdk_display);
_g_object_unref0 (gdk_window);
return result;
}
static void
glx_sample_class_init (GLXSampleClass * klass)
{
glx_sample_parent_class = g_type_class_peek_parent (klass);
g_type_class_add_private (klass, sizeof (GLXSamplePrivate));
G_OBJECT_CLASS (klass)->finalize = glx_sample_finalize;
}
static void
glx_sample_instance_init (GLXSample * self)
{
self->priv = GLX_SAMPLE_GET_PRIVATE (self);
}
static void
glx_sample_finalize (GObject * obj)
{
GLXSample * self;
self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_GLX_SAMPLE, GLXSample);
_XFree0 (self->priv->xvinfo);
G_OBJECT_CLASS (glx_sample_parent_class)->finalize (obj);
}
GType
glx_sample_get_type (void)
{
static volatile gsize glx_sample_type_id__volatile = 0;
if (g_once_init_enter (&glx_sample_type_id__volatile)) {
static const GTypeInfo g_define_type_info = { sizeof (GLXSampleClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) glx_sample_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GLXSample), 0, (GInstanceInitFunc) glx_sample_instance_init, NULL };
GType glx_sample_type_id;
glx_sample_type_id = g_type_register_static (gtk_window_get_type (), "GLXSample", &g_define_type_info, 0);
g_once_init_leave (&glx_sample_type_id__volatile, glx_sample_type_id);
}
return glx_sample_type_id__volatile;
}
void
_vala_main (gchar** args,
int args_length1)
{
GLXSample* sample = NULL;
GLXSample* _tmp0_;
gtk_init (&args_length1, &args);
_tmp0_ = glx_sample_new ();
g_object_ref_sink (_tmp0_);
sample = _tmp0_;
gtk_widget_show_all ((GtkWidget*) sample);
gtk_main ();
_g_object_unref0 (sample);
}
int
main (int argc,
char ** argv)
{
_vala_main (argv, argc);
return 0;
}