Click to See Complete Forum and Search --> : Graphic programming with C++


Yosuke_
10-09-2004, 04:56 AM
Hi!
I was wondering how to draw a pixel or something on the screen in console programm. I think that I need to #include <x11.h> but is there any tutorial about this, and is there any other way? Thank you!

bwkaz
10-09-2004, 08:58 AM
In a console program, you cannot draw pixels on the screen. You can have text mode, or you can have graphics mode, pick one.

(Actually that's not strictly true, because if your user enables a framebuffer console, you might be able to use something like svgalib to draw pixels. But there are several problems with this. First, it's not portable even on one system -- if your user runs your program in an xterm, it won't work. Second, it's not portable between systems, because not everybody has framebuffer console turned on. And not everybody uses the Linux VC driver either -- many people don't even use Linux. Third, svgalib requires root privileges, which is something I personally don't like doing to any program.)

If you need to draw pixels, it would be a good idea to make the whole program X-based. Use a toolkit, though, don't try to include <X11/X.h> or anything like that manually, because X programming is arcane at best.

If you're already stuck using C++, then Qt isn't too bad, though I don't think it looks all that great. There's also gtkmm (a C++ wrapper around gtk). If, however, you're only using C features but still compiling with C++, then first, stop doing that and compile with the C compiler (so you don't pull in a bunch of unneeded libraries and the compatibility issues that go along with them), and second, use gtk on its own, since its native binding is C.

-=Gerrit=-
10-09-2004, 03:56 PM
the only way to show items on a console is using stuff like they do on televisions with TELETEXT. You can set te background and stuff (see the yast console configurator of SuSE). This can be ran when X is crashed.

But it is not that graphical, because you have a limited number of horizontal and vertical CHAR positions.

So what was said before, tray it in X or on the QT stuff with C++ (allows you to create window apps)

709394
10-09-2004, 06:28 PM
try wxWidgets at http://wxwidgets.org/

Cross plate-form GUI for C++.