How do I render pixels (image data) to the screen?

GTK+ FAQ
<<< Previous | Development with GTK+: general questions | Next >>>

# How do I render pixels (image data) to the screen?

There are several ways to approach this. The simplest way is to use GdkRGB, see gdk/gdkrgb.h. You create an RGB buffer, render to your RGB buffer, then use GdkRGB routines to copy your RGB buffer to a drawing area or custom widget. The book "GTK+/Gnome Application Development" gives some details; GdkRGB is also documented in the GTK+ reference documentation.

If you're writing a game or other graphics-intensive application, you might consider a more elaborate solution. OpenGL is the graphics standard that will let you access hardware accelaration in future versions of XFree86; so for maximum speed, you probably want to use OpenGL. A GtkGLArea widget is available for using OpenGL with GTK+ (but GtkGLArea does not come with GTK+ itself). There are also several open source game libraries, such as ClanLib and Loki's Simple DirectMedia Layer library (SDL).

You do NOT want to use `gdk_draw_point()`, that will be extremely slow.

<<< Previous | Home | Next >>>
Shouldn't the text argument in the gtk_clist_* functions be declared const? | Up | How do I create a pixmap without having my window being realized/shown?