Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Alternative GFXlib released
#1
Just released an alternative GFXlib for FreeBasic, which is completely compatible with official GFXlib. I attach here the readme.txt included in the package:
Quote:FB Alternative GFX Library
--------------------------

by Angelo Mottola, © Jan 2005 - a.mottola@gmail.com


What's this you may ask; we already have a GFXLIB for FB!
Well, I don't know about you, but when it came out, I didn't really like some
issues of Sterling's lib. While I appreciate a lot his efforts for emulating
QB gfx quirks, he made the lib to use SDL as a backend for gfx output, and I
don't blame him as at the time there was a certain pressure from V1ctor to get
the lib done, so he could have included it with the next FB release.

But using SDL had two side effects I really didn't like: being dependent on a
separate library (you need to ship the SDL DLL with your exes if you're using
the official GFX lib), and the need for FLIPping regularly in order to keep
the screen contents updated.

So I started this project, and it turned out better than I expected. This
alternative GFX library is almost a complete rewrite of Sterling's one: just
the coordinates handling (think VIEW and WINDOW) is heavily based on his work,
the rest is original.

Now the differences: this alternative GFX lib features:

* Not dependent on any external library: it uses a tiny internal drivers
architecture, and for now a DirectDraw driver is complete for Win32. A GDI
driver may follow for systems where DX is not installed, as well as an X11
driver for Linux.

* No need to FLIP. Uses a threaded system to keep the screen contents updated
automatically; only dirty lines are updated.

* Emulation for QB modes 1, 2, 7, 8, 9, 10, 11, 12 and 13.

* Always uses fast 8bit buffers internally; no support for hires/hicolor
modes: use a real gfx library instead.

* Windowed/fullscreen modes. Switch between the two at any time with ALT-ENTER

* Support for all QB primitives, including arcs via CIRCLE, DRAW, PAINT
(although these two still need support into the compiler; currently you need
to declare them before you can use them: see below) and all PUT modes (PSET,
PRESET, AND, OR, XOR, also still lack support in the compiler for now).

* PUT respects clipping, and supports transparency for color 0

* Uses MMX optimized memcpy/memset routines for a lot of internal stuff; I
could have used MMX elsewhere too, but IMHO it'd just increase your EXEs
size without being really worth the little performance bump.

* CLS works as in QB, respecting the viewport: to specify a clear color, just
use "COLOR ,color" before calling CLS.

* PAINT supports patterns, but only 8x8 (supplied string must be 64 characters
long), and assumes each pattern string character to specify a pixel, despite
current mode (emulated) depth.

* Supports emulation of IN and OUT for VGA palette read/write, as well as WAIT
for vertical blank synchronization (this last one still has no support at
compiler level).


Well, I think it's all. Now until the compiler supports DRAW and PAINT, you can
use the declarations in the section below to use them in your programs.



How to use the library
----------------------

The library works as a clean drop-in replacement for official GFX lib: just
replace the libfbgbx.a in your FreeBasic/lib directory with the one shipped
within this package and you're done.
If you want to rebuild the sources, be sure to unzip the library archive into
your FreeBasic/src directory, preserving the zip file directory structure;
building requires FB runtime sources to be available in FreeBasic/src/rtlib.

Since the compiler itself still doesn't support DRAW and PAINT, you need to
declare them yourself at the beginning of your programs if you want to use
them. Here are the declarations:


declare sub draw alias "fb_GfxDraw" (byref cmd as string)

declare sub paint alias "fb_GfxPaint" (byval x as single, byval y as single, _
byval color as integer = &hFFFF0000, byval border as integer = &hFFFF0000, _
byref pattern as string, byval mode as integer = 0, _
byval coord_type as integer = 4)



Final words
-----------

I would like to thank Sterling for his hard work on the official GFX lib. He
was a pioneer and I can't spend enough words to thank him; anyway, as I have
already said, even if his lib does the job, it has its flaws IMHO. For those
of you who would like not to be dependent on an external lib while keeping
your EXE size still small, this lib is for you. And it's for you also if
you'd like to easily port your old QB games, even those using not just mode
13.
If you want hires/hicolor though, go elsewhere: this lib is primarly meant to
be a slim, standalone library with compatibility with QB in mind. For real gfx
work, use a first-class real world gfx library, like SDL or Allegro (when it's
ported to FB of course).
So that's it. You can download my gfxlib alternative from my site here:

http://www.ecplusplus.com/index.php?page...fxlib2.zip
ngelo Mottola - EC++
Reply
#2
There's an error in your documentation:
Quote:* CLS works as in QB, respecting the viewport: to specify a clear color, just
use COLOR ,color.
I'd knock on wood, but my desk is particle board.
Reply
#3
hu? That's correct. To specify a background color color to the COLOR statement, you do
Code:
COLOR ,color

Btw, I forgot to say in the docs that I also emulate WAIT &h3da, 8 (wait for vertical sync), even though that's still not supported at compiler level...
ngelo Mottola - EC++
Reply
#4
Attempting to compile qbgfxtest.bas in the examples\gfx folder and get the following error:

qbgfxtest.o(.text+0x15a):fake: undefined reference to `fb_GfxFlip@8'
ature has its way of warning a person away from danger: The distinct black and white coloration on a skunk, the chilling buzz of a rattlesanke, a redneck handing you his beer and saying "Watch this!"
Reply
#5
Your example uses FLIP. Remove it, my gfxlib does not need FLIP.
ngelo Mottola - EC++
Reply
#6
I figured that out, but you might want to state in the doc that FLIP has to be removed instead of just "not needed".
ature has its way of warning a person away from danger: The distinct black and white coloration on a skunk, the chilling buzz of a rattlesanke, a redneck handing you his beer and saying "Watch this!"
Reply
#7
Point taken. :roll:
ngelo Mottola - EC++
Reply
#8
Actually a "dummy" FLIP in your library would make it more of a clean drop-in as existing code would not have to be edited. Then you really could just say "not needed"...
ature has its way of warning a person away from danger: The distinct black and white coloration on a skunk, the chilling buzz of a rattlesanke, a redneck handing you his beer and saying "Watch this!"
Reply
#9
Quote:hu? That's correct. To specify a background color color to the COLOR statement, you do
Code:
COLOR ,color
Then your documentation is still incorrect, as it doesn't make this point very clear. You listed this in the paragraph about CLS, thus it is assumed that you're referring to a CLS method, not a COLOR method. Dig? Big Grin
I'd knock on wood, but my desk is particle board.
Reply
#10
Nek, whats so unclear?

It works just like QB:

Color , 5
Cls 'All bg will now be color 5
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)