Re: Drawing in memory with no GUI



Ok I hope that I'm replying to the right mail
(today is friday and this mail is dated tuesday ...
probably some overseas time zone related bug)

first of all,
        before useing the gtk library you have to call
"gtk_init()" but you need you "DISPLAY" environment var
to be set which is not the case.

if you're going to use functions in the gdk library
and as a result glib; you can add the following lines to
the beginning of your code:

g_type_init(G_TYPE_DEBUG_NONE);
gdk_rgb_init();

theese are called inside "gtk_init()"
only this way you dont need to have
an X server running.


Cheers,
        -Tristan

Kaney wrote:

Hi
New list member.  I'm more of a science guy 1st/programmer 2nd.  I'm a
Physics prof at a small Univ in OK and I'm doing a sabbatical with the
National Severe Storms lab in Norman.  I have successfully written a
couple of small Gnome apps that display lightning data loops, etc.

My problem is that I want to be able to generate an image with code
that runs strictly from the command line.  The Linux box I need to
use, boots into the command line - no GUI has been started.  I just
want to set up a pixmap in memory, draw on it (lines, circles, points
based on data in files) and then read out the pixels into a simple
image file (*.ppm).  It compiles OK using
g++ -Wall -o DrawTest DrawTest.cc `gtk-config --cflags --libs`, but
when it runs I get a segmentation fault/core dump message.  I whittled
down the code so there's only two lines left (it crashes on the 2nd
one)!

#include <stdlib.h>
#include <stdio.h>
#include <gtk/gtk.h>

int main(int argc,char *argv[])
  {
  GdkPixmap *pixmap;
  pixmap = gdk_pixmap_new(NULL,400,400,8);

/*  ------stuff--- */
  }

I really did try to dig through my books first, but everything is
geared toward being in a windowing environment.  Can I do this with
the GDK library?  I would greatly appreciate any advice anyone might
have.  Thanks.

Brian Kaney
Tahlequah , OK
Assist. Physics Prof - Northeastern State Univ.
Visiting Researcher - National Severe Storms Lab



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