Rev 292 | Rev 296 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
/*******************************************************************************
* draw.c - implementation for libggi-based drawing on the GNU/Linux
* framebuffer device.
*
* Copyright (c) 2006, Ira W. Snyder (devel@irasnyder.com)
******************************************************************************/
#include <ggi/ggi.h>
#include <stdio.h>
#include "draw.h"
/* Initialize GGI for drawing */
void draw_init ()
{
/* Initialize the palette */
palette[BLACK].r = 0;
palette[BLACK].g = 0;
palette[BLACK].b = 0;
palette[RED].r = 0xffff;
palette[RED].g = 0;
palette[RED].b = 0;
palette[GREEN].r = 0;
palette[GREEN].g = 0xffff;
palette[GREEN].b = 0;
palette[BLUE].r = 0;
palette[BLUE].g = 0;
palette[BLUE].b = 0xffff;
palette[WHITE].r = 0xffff;
palette[WHITE].g = 0xffff;
palette[WHITE].b = 0xffff;
/* Intialize GGI itself */
if (ggiInit () != 0)
{
printf ("Error initialising GGI!\n");
exit (1);
}
/* Try to open the screen */
if ((vis = ggiOpen (NULL)) == NULL)
{
printf ("Error opening visual!\n");
ggiExit ();
exit (1);
}
/* Try to set the screen mode */
if (ggiSetSimpleMode (vis, GGI_AUTO, GGI_AUTO, 0, GT_AUTO))
{
printf ("Set the GGI_DISPLAY variable to the palemu!\n");
exit (1);
}
/* load the palette to the screen */
ggiSetPalette (vis, 0, 5, palette);
}
/* Close GGI when we're done drawing */
void draw_close ()
{
ggiClose (vis);
ggiExit ();
}
void draw_clearscreen ()
{
ggiSetGCForeground (vis, BLACK);
ggiFillscreen (vis);
ggiFlush (vis);
}
void draw_putpixel (int x, int y, int color)
{
ggiSetGCForeground (vis, color);
ggiDrawPixel (vis, x, y);
ggiFlush (vis);
}
void draw_box (int x, int y, int width, int height, int color)
{
ggiSetGCForeground (vis, color);
ggiDrawBox (vis, x, y, width, height);
ggiFlush (vis);
}
void draw_line (int x1, int y1, int x2, int y2, int color)
{
ggiSetGCForeground (vis, color);
ggiDrawLine (vis, x1, y1, x2, y2);
ggiFlush (vis);
}
void draw_putc (int x, int y, char c, int color)
{
ggiSetGCForeground (vis, color);
ggiPutc (vis, x, y, c);
ggiFlush (vis);
}
void draw_puts (int x, int y, const char *str, int color)
{
ggiSetGCForeground (vis, color);
ggiPuts (vis, x, y, str);
ggiFlush (vis);
}