[mainpage]
[tags]
A GPL portable graphics library
DEGFX is a small extremely portable graphics library. It has only 6 (!) platform dependant functions. It uses a clean
object oriented C API with reference counting and delete locking for (almost) all the objects. The library supports transparency for bitmaps and
all drawing functions and antialiased fonts. The user has very fast pixel level access to bitmaps using
iterators. DEGFX uses the DEDS library for data structures.
Compared to other portable graphics libraries DEGFX is:
- Smaller and simpler than Allegro or SDL
- Fast alpha-blending (transparency, anti-aliasing) built into all drawing functions
- Color conversions are completely hidden to the user
- More graphic functions (line, blit) than SDL
- More portable than SDL (doesn't need threads)
- Guaranteed flicker-free graphics without double buffering the entire display
- Library source is completly self-contained - You dont have to link to external libraries, not even to DEGFX!
- Easy to determine which modules (drivers, fonts etc...) are included in the executable
- Portable gui available (DEPUI)
DEGFX uses a different approach than most graphics libraries.
- DEGFX works works internally only a single pixel format chosen at compile time. This can be argb8888, rgb555 or rgb332
color encodings. This makes the library internally very simple. Bitmap are only converted to the screen color depth when
actually writing to the screen. This has the advantage
that the library internals are very simple and allows transparency and alpha-blending to be used even for monochrome,
4-bit and 8-bit displays. Admittedly a program that makes heavy use of antialiasing and transparency might not look very
good on a 4-bit display.
- DEGFX uses a buffer system to guarantee no screen flicker when drawing but uses much less memory than the usual method
of double buffering the entire screen. Only a portion of the screen is buffered at a time and the users
redraw callback function is called multiple times with different clipping settings. Because a clipped graphics drawing
can be made very fast, calling the update function many times is hardly slower than full screen double buffering but uses
much less memory. In fact the smaller buffer can often be faster than full screen double buffering because of better
cache behavior. In any case you can change how much memory you want to use for the screen buffer (even during runtime) so
you can do do full double buffering if you want to, or use minimal memory and (maybe) have a slightly slower screen update speed.
- DEGFX does not require linking to a library, you include the DEGFX C source code directly into you own programs.
So installing or removing DEGFX from your system is as simple as moving or deleting a directory from your
compilers include path. Using this method can cause long compile times since you are essentially compiling the library
every time you compile your program. But if you include DEGFX in a separate object file you can solve this problem.
- DEGFX uses #define flags to determine which modules to use. This guarantees that only the portions of DEGFX that you
actually use get included in your executable.
Some Features:
- Object oriented C API with attention to maximum type safety.
- Fast, unified transparency support
- Plot a solid blue pixel: mx_pixel(x, y, MXRGB(0,0,255));
- Same pixel with 50% transparency: mx_pixel(x, y, MXRGBT(0,0,255,128));
- RBG and RGBT colors are compile time macro for fast execution
- Transparency works for ALL displays even 8 bit and 4 bit graphic modes
- Unified reference counting for many objects
- Copying to screen is localized by buffer system so banked modes work almost as fast as linear modes
- Bitmap support:
- Pixel RGB colors are compile time constants
- Color conversions are completely hidden from user
- Unified transparency support
- Drawing functions: pixel, line, blit, etc...
- Drawing functions are simple and fast because only 32 bit ARGB is needed
- Very fast pixel-level access using iterators
- Functions to load bitmaps from files (PCX, TGA, GIF)
- Named colors (derived from X11 rgb.txt)
- Reference counting and delete locking
- Font support:
- Support for bitmapped fonts and antialiased fonts
- UTF-8 encoding
- Loadable from bitmap (similar format as Allegro)
- Allegro's TTF2PCX utility can be used to make loadable TTF fonts
- Reference counting and delete locking
- Simple mouse and keyboard support
- DEGFX source compiles inside your own source code
- Installing/removing the library means simply copying/deleting a directory in your compilers include path
- No need to use library tools
- Currently available drivers:
- DOS - DJGPP VESA 2.0(linear) and VESA 1.2(banked)
- DOS - DJGPP standard VGA (640x480x4)
- DOS - DJGPP VGA mode 13h (320x200x8)
- DOS - Borland Turbo C++ 3.1 using BGI graphics
- Linux - Svgalib *** has problems on some displays because
vga_setrgbcolor()
does not always function properly. ***
- Win32 - MINGW32 using GDI
- Win32 - Borlands free compiler BCC32 using GDI
- Win32 - Open Watcom target Win32 (GDI)
- Sinclair QL - QDOS *** in development ***
- Low memory requirements when using 'partial' double buffer
- Buffering mode can be changed on the fly
- Extremely portable: only 6 (!) platform dependant functions
- start, stop, poll, dirty, keypress, mouse info
- Runs on almost any hardware, even my 40 MHz 386 test machine
- Compiles with no changes on MSB first or LSB first hardware
- Open source and GPL licence
(../include/degfx/degfx.h)modules:
documented objects:
- MX_BITMAP
A bitmap type
- MX_BITMAP* mx_bitmap(int x2, int y2)
Create a bitmap
- MX_BITMAP* mx_bitmap_tga(const char* filename)
Load a bitmap from a TGA file
- MX_BITMAP* mx_bitmap_gif(const char* filename)
Load a bitmap from a GIF file
- MX_BITMAP* mx_bitmap_pcx(const char* filename)
Load a bitmap from a PCX file
- MX_BITMAP* mx_bitmap_pcx_greyscale(const char* filename)
Load a bitmap from a PCX file and convert it to greyscale
- MX_BITMAP* mx_bitmap_clone(const MX_BITMAP* other)
Make a complete copy of a bitmap
- unsigned mx_bitmap_clip(MX_BITMAP* bitmap, const MX_RECT* newclip)
Set a bitmaps clipping area
- const MX_RECT* mx_bitmap_clip_get(const MX_BITMAP* bitmap)
Return a bitmaps clipping area
- void mx_bitmap_offset(MX_BITMAP* bitmap, int x1, int y1)
Offset a bitmap
- typedef MX_PIXEL* MX_BITMAP_ITER;
Fast pixel-level iterator for a bitmap
- MX_BITMAP_ITER mx_bitmap_iter(const MX_BITMAP* bitmap, int x1, int y1)
Return pixel-level iterator at a given position
- MX_BITMAP_ITER mx_bitmap_begin(const MX_BITMAP* bitmap)
Return pixel-level iterator at the top left position
- MX_BITMAP_ITER mx_bitmap_end(const MX_BITMAP* bitmap)
Return pixel-level iterator at the lower right position
- MX_PIXEL mx_bitmap_getpixel(const MX_BITMAP* bitmap, int x1, int y1)
Return pixel a a given position
- void mx_bitmap_pixel(MX_BITMAP* bitmap, int x1, int y1, MX_PIXEL color)
Draw a pixel on a bitmap
- void mx_bitmap_vline(MX_BITMAP* bitmap, int x1, int y1, int y2, MX_PIXEL color)
Draw a vertical line on a bitmap
- void mx_bitmap_hline(MX_BITMAP* bitmap, int x1, int y1, int x2, MX_PIXEL color)
Draw a horizontal line on a bitmap
- void mx_bitmap_line(MX_BITMAP* bitmap, int x1, int y1, int x2, int y2, MX_PIXEL color)
Draw a line on a bitmap
- void mx_bitmap_rectfill(MX_BITMAP* bitmap, int x1, int y1, int x2, int y2, MX_PIXEL color)
Draw a filled rectangle on a bitmap
- void mx_bitmap_clear(MX_BITMAP* bitmap, MX_PIXEL color)
Clear a bitmap to a solid color
- void mx_bitmap_blit(const MX_BITMAP* src, MX_BITMAP* dest, int sx, int sy, int dx, int dy, int w, int h)
Blit a bitmap onto another bitmap
- void mx_bitmap_blitcopy(const MX_BITMAP* src, MX_BITMAP* dest, int sx, int sy, int dx, int dy, int w, int h)
Blit a bitmap onto another bitmap
- void mx_bitmap_blittrans(const MX_BITMAP* src, MX_BITMAP* dest, int sx, int sy, int dx, int dy, int w, int h, unsigned long trans)
Blit a bitmap onto another bitmap
- void mx_bitmap_blitstretch(const MX_BITMAP* src, MX_BITMAP* dest, int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh)
Stretch-blit a bitmap onto another bitmap
- void mx_bitmap_box(MX_BITMAP* bitmap, int x1, int y1, int x2, int y2, int width, MX_PIXEL light, MX_PIXEL dark)
Draw a box on a bitmap
- void mx_bitmap_frame(MX_BITMAP* bitmap, int x1, int y1, int x2, int y2, int width, MX_PIXEL light, MX_PIXEL dark, MX_PIXEL fill)
Draw a frame on a bitmap
- void mx_bitmap_decorate(const MX_BITMAP* src, MX_BITMAP* dest, int x, int y, int x1, int y1, int x2, int y2)
Blitting function for drawing gui objects
- unsigned mx_bitmap_collision(const MX_BITMAP* src, const MX_BITMAP* dest, int sx, int sy, int dx, int dy, unsigned int thresh)
Check if two bitmaps overlap on any pixels
- #define mx_iter(x,y)
Get an iterator to a given position on the screen
- #define mx_getpixel(x,y)
Return the pixel at a given position on the screen
- #define mx_pixel(x,y,c)
Draw a pixel on the screen
- #define mx_vline(x,y1,y2,c)
Draw a vertical line on the screen
- #define mx_hline(x1,y,x2,c)
Draw a horizontal line on the screen
- #define mx_line(x1,y1,x2,y2,c)
Draw a line on the screen
- #define mx_rectfill(x1,y1,x2,y2,c)
Draw a filled rectangle on the screen
- #define mx_clear(c)
Clear the screen to a solid color
- #define mx_blit(s,sx,sy,dx,dy,w,h)
Blit a bitmap onto the screen
- #define mx_blitcopy(s,sx,sy,dx,dy,w,h)
Blit a bitmap onto the screen
- #define mx_blittrans(s,sx,sy,dx,dy,w,h,t)
Blit a bitmap onto the screen
- #define mx_blitstretch(s,sx,sy,sw,sh,dx,dy,dw,dh)
Stretch-blit a bitmap onto the screen
- #define mx_box(x1,y1,x2,y2,w,l,d)
Draw a box on the screen
- #define mx_frame(x1,y1,x2,y2,w,l,d,f)
Draw a frame on the screen
- #define mx_decorate(s,x,y,x1,y1,x2,y2)
Blitting function for drawing gui objects on the screen
- bitmap.h" unsigned mx_bitmap_collision(const MX_BITMAP* src, const MX_BITMAP* dest, int sx, int sy, int dx, int dy, unsigned int thresh)
- bitmap.h" void mx_bitmap_decorate(const MX_BITMAP* src, MX_BITMAP* dest, int x, int y, int x1, int y1, int x2, int y2)
- bitmap.h" MX_BITMAP_ITER mx_bitmap_iter(const MX_BITMAP* bitmap, int x1, int y1)
- #define MXRGB(r, g, b)
Construct a pixel out of a r, g, b
- #define MXRGBT(r, g, b, a)
Construct a pixel out of a r, g, b and transparency
- #define MXT(c)
The transparency of a pixel
- #define MXR(c)
Red component of a pixel
- #define MXG(c)
Green component of a pixel
- #define MXB(c)
Blue component of a pixel
- #define MXTRANS(c, a)
Set pixel transparency
- #define MXBLENDT(c1, c2, a1)
Blend two pixels with transparency
- #define MXBLEND(c1, c2)
Blend two pixels using the transparency component of the first pixel.
- #define MXCOLOR_alice
Macros for named colors
- # define MXSCREEN
Screen bitmap
- void mx_font_default(MX_FONT* font)
- unsigned mx_gfx_start(MX_GFX_ARGS* userargs)
Start DEGFX and set the graphics mode
- void mx_gfx_stop(void)
Stop DEGFX
- const MX_GFX_ARGS* mx_gfx_info(void)
- void mx_gfx_redraw(MX_REDRAW_FUNC redraw)
- void mx_gfx_dirty(const MX_RECT* rect)
Mark part of the screen as dirty
- unsigned mx_gfx_poll(void)
Poll the DEGFX grpahics/keyboard/mouse system
- unsigned mx_gfx_pointer(int* x, int* y, int* b)
Get the mouse position and state
- unsigned mx_gfx_hidepointer(unsigned hide)
Hide the pointer
- unsigned mx_gfx_key(int* scan, int* ascii)
Return keypress information
- MX_GFX_ARGS
Graphic driver information
- #define mx_driver_fullscreen
- #define mx_driver_windowed
- #define mx_driver_vga
- #define mx_driver_13h
- MX_FONT
A font
- void mx_font_default(MX_FONT* font)
Set the default font
- void mx_font_bitmap_draw(const MX_FONT* font, struct MX_BITMAP* bitmap, const char* text, int len, int x, const int y, const MX_PIXEL fore)
Draw text onto a bitmap
- void mx_font_bitmap_drawblock(const MX_FONT* font, struct MX_BITMAP* bitmap, const char* text, int len, int x, int y, const MX_PIXEL fore)
Draw a block of text onto a bitmap
- #define mx_font_draw(f,t,l,x,y,fore)
Draw text onto the screen
- #define mx_font_drawblock(f,t,l,x,y,fore)
Draw a block of text onto the screen
- unsigned int mx_font_height(const MX_FONT* font)
Return the height of a font
- unsigned int mx_font_width(const MX_FONT* font, const char* text, int len)
Return the width of a portion of text
- void mx_font_blocksize(const MX_FONT* font, const char* text, int len, int* tw, int* th, int* last)
Return the size of a block for a portion of text
- void mx_font_bitmap_drawblock(const MX_FONT* font, MX_BITMAP* bitmap, const char* text, int len, int x, int y, const MX_PIXEL fore)
Draw multi-line text onto a bitmap
- void mx_font_bitmap_draw(const MX_FONT* font, MX_BITMAP* bitmap, const char* text, int len, int x, const int y, const MX_PIXEL fore)
Draw text onto a bitmap
- unsigned int mx_font_width(const MX_FONT* font, const char* text, int num)
The width in pixels of some text
- MX_FONT* mx_font_bitmap(const MX_BITMAP* bitmap, int start)
Load a font from a bitmap.
- MX_FONT* mx_font_pcx(const char* filename, int start)
Load a font from a PCX file.
Generated by MXDOC 2.2 on Sun Feb 4 15:16:27 2007