Re: [Vala] OpenGL and gtkglext Bindings!!!
- From: "Matías De la Puente" <mfpuente ar gmail com>
- To: "Zeeshan Ali Khattak" <zeenix gmail com>
- Cc: vala-list gnome org
- Subject: Re: [Vala] OpenGL and gtkglext Bindings!!!
- Date: Wed, 6 Aug 2008 19:28:59 -0300
Hi Everyone:
I updated the opengl vapi files, they have some writing errors but they work fine...
I made a glx binding but still testing ...
Zeeshan: I make the parameter nullable but the other think I can't make it work. I think it is a vala bug...
here is an example to test:
using GLib;
using Gtk;
using Gdk;
using GL;
public class Simple : Gtk.Window
{
private bool on_configure_event (Gtk.DrawingArea widget, Gdk.EventConfigure event)
{
Gdk.GL.Context glcontext = Gtk.GL.GtkWidgetExtension.get_gl_context (widget);
Gdk.GL.Drawable gldrawable = Gtk.GL.GtkWidgetExtension.get_gl_drawable (widget);
if (!(bool)gldrawable.gl_begin (glcontext))
return false;
GL.Viewport (0, 0, (GLsizei)widget.allocation.width, (GLsizei)widget.allocation.height);
gldrawable.gl_end ();
return true;
}
private bool on_expose_event (Gtk.DrawingArea widget, Gdk.EventExpose event)
{
Gdk.GL.Context glcontext = Gtk.GL.GtkWidgetExtension.get_gl_context (widget);
Gdk.GL.Drawable gldrawable = Gtk.GL.GtkWidgetExtension.get_gl_drawable (widget);
if (!(bool)gldrawable.gl_begin (glcontext))
return false;
GL.Clear (GL.Consts.COLOR_BUFFER_BIT);
GL.Begin (GL.Consts.TRIANGLES);
GL.Indexi (0);
GL.Color3f (1.0f, 0.0f, 0.0f);
GL.Vertex2i (0, 1);
GL.Indexi (0);
GL.Color3f (0.0f, 1.0f, 0.0f);
GL.Vertex2i (-1, -1);
GL.Indexi (0);
GL.Color3f (0.0f, 0.0f, 1.0f);
GL.Vertex2i (1, -1);
GL.End ();
if (gldrawable.is_double_buffered ())
gldrawable.swap_buffers ();
else
GL.Flush ();
gldrawable.gl_end ();
return true;
}
construct
{
title = "simple";
set_reallocate_redraws (true);
destroy += Gtk.main_quit;
Gdk.GL.Config glconfig = new Gdk.GL.Config.by_mode (Gdk.GL.ConfigMode.RGB | Gdk.GL.ConfigMode.DOUBLE);
Colormap colormap = glconfig.get_colormap ();
DrawingArea drawing_area = new DrawingArea ();
drawing_area.set_size_request (200, 200);
Gtk.GL.GtkWidgetExtension.set_gl_capability (drawing_area, glconfig, null, true, Gdk.GL.RenderType.RGBA_TYPE);
drawing_area.configure_event += on_configure_event;
drawing_area.expose_event += on_expose_event;
add (drawing_area);
}
public static void main (string[] args)
{
Gtk.init (ref args);
Gtk.GL.init (ref args);
var simple = new Simple ();
simple.show_all ();
Gtk.main ();
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]