drawing on offscreen surface
- From: Prasanta Sadhukhan <psadhukhan gmail com>
- To: gtk-list gnome org
- Subject: drawing on offscreen surface
- Date: Wed, 8 Aug 2012 17:23:03 +0530
Hi,
I am trying to draw something on offscreen surface and then trying to render it on primary window. I started with simple primitives like rectangle but it seems to not draw anything except a blank white window. Here's my code.
Can anyone suggest as to what I need to do to draw a rectangle on an offscreen surface and then render to primary visible window?
Thanks in advance!!
=========================
#include <gtk/gtk.h>
int main(int argc, char* argv[])
{
// Initialize GTK+
gtk_init(&argc, &argv);
GtkWidget *main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size(GTK_WINDOW(main_window), 1200, 800);
GdkPixmap *pixmap = gdk_pixmap_new(main_window->window, 1200, 800, -1);
gdk_draw_rectangle(pixmap, main_window->style->black_gc, TRUE, 100, 100, 400, 400);
//gtk_widget_queue_draw_area(main_window, 100, 100, 400, 400);
GtkWidget *widget = gtk_image_new_from_pixmap(pixmap, NULL);
gtk_container_add(GTK_CONTAINER(main_window), widget);
// Make sure the main window and all its contents are visible
gtk_widget_show_all(main_window);
// Run the main GTK+ event loop
gtk_main();
return 0;
}
Regards
Prasanta
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]