In linux, you can use the ncurses library to use the terminal as a text buffer: move the cursor around, and write text. It can also draw windows and other hi-level widgets.
For gotoxy
see move
and wmove
from ncurses (link).
For cprintf
see printw
.
You can clear the screen simply with clear()
.
In ncurses you also need to refresh the screen with refresh()
after printw
and clear()
.
Example program, which uses all the mentioned functions in ncurses:
#include <curses.h>
int main(int argc, char *argv[])
{
initscr();
clear();
move(15, 20);
printw("Test program: %s", argv[0]);
refresh();
getch();
endwin();
return 0;
}
Compile in gcc with: gcc program.c -lcurses
As for graphics, you have to choose a particular library.
If you need a similar experience as the low-level graphics.h, you are probably looking for directfb or svgalib.
If you want to render graphics in a window, SDL will be helpful.