Re: Painting a Pixel



You're calling gdk_gc_new() with a window param that's not been 
initialised yet.

Also, this won't really work too well :-( gdk does not remember any 
screen contents for you, so if part of your window is covered and then 
uncovered, your program needs to be able to repaint it.

Have you looked at the scribble example in the tutorial?

http://www.gtk.org/tutorial/ch-scribble.html

it does some basic drawing

Paulo J. Matos wrote:
> Hi all,
> 
> I've done the following to create a window and paint a white
> pixel in the window. I'm getting SIGSEGV from  gc =
> gdk_gc_new_with_values(window, &values, GDK_GC_FOREGROUND);
> 
> 
> #include <gdk/gdk.h>
> #include <stdlib.h>
> 
> int main(int argc, char *argv[]) {
> 
>   GdkWindow *window;
>   GdkGC *gc;
>   GdkWindowAttr attr;
>   GdkColor color;
>   GdkGCValues values;
> 
>   gdk_init(&argc, &argv);
> 
>   attr.title = "Test";
>   attr.x = 100;
>   attr.y = 100;
>   attr.width = 300;
>   attr.height = 300;
>   attr.wclass = GDK_INPUT_OUTPUT;
>   attr.window_type = GDK_WINDOW_TOPLEVEL;
> 
>   color.red = 65535;
>   color.blue = 65535;
>   color.green = 65535;
> 
>   values.foreground = color;
>   
>   gc = gdk_gc_new_with_values(window, &values, GDK_GC_FOREGROUND);
>   
>   window = gdk_window_new(NULL, &attr, GDK_WA_TITLE|GDK_WA_X|GDK_WA_Y);
>   
>   gdk_window_show(window);
> 
>   gdk_draw_point(window, gc, 10, 10);
> 
>   gtk_main();
> 
>   return 0;
> }
> 
> Any ideas?
> 
> Best regards,




========================================================== 
Fabric of Vision 
Dress and Drapery in Painting 

19 June - 8 September 2002 

For information and tickets: 
http://www.nationalgallery.org.uk/exhibitions/fabric/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]