clearly the following only applies to a port. HOWEVER, it also hilights that your borrowed code is at fault.
You are writing for Linux w C, yet require someone else to implement functions that exist in libc it seems.
If kernel devs havent found these flaws yet and a solution for them, C devs are HOSED.
FPC, based off of C years ago when initially porting it, HAS the code you seek to solve some of your problems. Shurely you didnt do your homework well enough. If we cant port it, im sure C devs have found a solution.
--
Lib Graphics -- Turbo PASCAL's graphics.h in Linux
There are a few ways to do this and PASCAL dev group online has posted some ported headers for SDL.
What we seem to be forgetting is that X11 has these routines, they intentionally moved them out of core recently.
to avoid conflicts:
libPgraph.a is the common output nomenclature
on-the-fly code patch:
uses libPgraph; (unices)
uses Graph; (dos) [could be ported 16bit or dpmi32, as vesa allows for fpc]
What is it?
It is an implementation of TC graphics.h (reported to PASCAL) functions in Linux using SDL --
Simple DirectMedia Layer (www.libsdl.org for more).
The sole objective of this package is to enable people to run programs
written using libGraph(Borland) functions directly in Linux. It does not aim to be a
complete graphics solution.
Effort has been made to suppress flexibility and
genericity in order to provide an interface closer to the original.
Delphi lost this functionality-is no more available for Sindows.
For more power and flexibility use libSDL or libOpenGL directly. The website
(libsdl.org) contains a number of links to great useful, generic and powerful
support libraries for SDL.
What do I need ?
You need to have the following installed :
SDL-x.x.x.rpm -- the main SDL library
SDL-devel-x.x.x.rpm -- the developer package
SDL_image-x.x.x.rpm -- image library for fonts
SDL_image-devel-x.x.x.rpm -- image library developer
These libaries are a standard part of most current distributions
(which is why we chose SDL over SVGAlib in the first place). The libaries will
probably already be installed. You may have to install the developer packages.
SDL can render onto X (SDL/OGL output) or a framebuffered console(fbdev). Direct X11
rendering is possible under the assumption GTK/QT ui improves the look and feel.The VGA mode console
can be used directly through SVGAlib but we haven't tried it.This can only be invoked this way
IFF(and only if) X11 is NOT running.(IE: init 3, networking)
How to use ?
See INSTALL for instructions on how to compile.
Just include libPgraph in your PASCAL file ( as you normally would do).
While compiling your applications you must link with libgraph as in :
$ fpc foo.pas -lgraph -o (foo.bin)
You can now run your executable.
IMPORTANT :
If your program goes into an infinite loop press CTRL-C. The program will
quit in anywhere between 10 to 30 seconds(depending on CPU load).This should never happen if keyboard inst polled(and
it shouldnt be).
If the program doesn't exit you may have to restart the X-server
(just CTRL-BACKSPACE-ALT). Note that on some machines, you will have to init 3(drop to multi-usermode w networking)
to kill Xorg process.
We have not yet seen a complete lock-up requiring a reboot.
scanf isnt used in PASCAL, keyboard interrupt based input (w range checking) is used instead.
Write your code correctly (RTFM) if numbers instead of letters crash your application.
Scan thought the headers or a PASCAL REFERENCE manual to further inderstand invocation.
I dont want your flames, drop a bug report instead(preferably offering help).
DEVS:
Files :
(needs PASCAL rewrite)
(.h-> .inc and .c -> .pas or .pp)
In this package are :
graphics.h : the default header that includes all the others required
so that you don't have to do anything differently.
libgraph.c : the code for functions in graphics.h. These are mainly
the basic settings and initialization functions.
grtext.h : the functions for text manipulation -- This basic part
of this code has been borrowed from Karl Bartel's
<karlb@gmx.net> SFont library. We extended it to fit
our needs.
text.c : code for functions in grtext.h
shapes.h : functions for drawing various shapes, filling and positioning.
shapes.c : Code for the above definitions.
polygon.h : functions for drawing and filling polygons.
polygon.c : Code for above functions. These two functions were made
into a separate module because the code for fillpoly() is pretty
healthy all by itself and requires quite a few book-keeping
trivial functions.
Makefile : Pretty similar to my CoffeeOS one.
README : That's what you are reading.
(not necessary)
./Font : Directory containing font(.png) files. There are a number of different
colors but of the same font. Default font is white. Font-color
selection is still to be implemented. You can change the color by
changing the FONT definition in graphics.h to a different color file
and recompiling the library.
sample.c : small sample file to try out the library.
Just compile with
$ ./grc sample
and execute with
$ ./sample
This is an SDL port.Learning SDL is not necessary. This is a BGI interface port. Write for the BGI, and the code
should 'just work'.
Next step should be learning allegro/SDL, and then OpenGL(castle engine).
Text functions are via already ported FPC code and function as normal.
(the problem with the C port)
The following code:
initgraph( , , );
....
printf("Hello",,);
...
closegraph();
Is similar to OpenGL/SDL code. I have read a DX11 book while on the IKE.
(Thank my draftsman)
However, output is via consoleIO in a background window usually.
ARGV parsing code is written and ported already for FPC.(it should mimic python)
To try new functions :
If you have implemented a function which has not yet been included,
I suggest that you write it in a separate header or program and test it before
adding it to the main library. This way you can tweak it without recompiling
the library.
(FPC does this internally):
Libtool :
Libtool is used for cascaded linking of dynamic libraries. For more see
$ info libtool
clearly the following only applies to a port. HOWEVER, it also hilights that your borrowed code is at fault.
You are writing for Linux w C, yet require someone else to implement functions that exist in libc it seems.
If kernel devs havent found these flaws yet and a solution for them, C devs are HOSED. FPC, based off of C years ago when initially porting it, HAS the code you seek to solve some of your problems. Shurely you didnt do your homework well enough. If we cant port it, im sure C devs have found a solution.
-- Lib Graphics -- Turbo PASCAL's graphics.h in Linux
There are a few ways to do this and PASCAL dev group online has posted some ported headers for SDL. What we seem to be forgetting is that X11 has these routines, they intentionally moved them out of core recently.
to avoid conflicts:
on-the-fly code patch: uses libPgraph; (unices) uses Graph; (dos) [could be ported 16bit or dpmi32, as vesa allows for fpc]
What is it?
Simple DirectMedia Layer (www.libsdl.org for more).
written using libGraph(Borland) functions directly in Linux. It does not aim to be a complete graphics solution.
Effort has been made to suppress flexibility and genericity in order to provide an interface closer to the original.
Delphi lost this functionality-is no more available for Sindows.
(libsdl.org) contains a number of links to great useful, generic and powerful support libraries for SDL.
What do I need ?
(which is why we chose SDL over SVGAlib in the first place). The libaries will probably already be installed. You may have to install the developer packages.
can be used directly through SVGAlib but we haven't tried it.This can only be invoked this way IFF(and only if) X11 is NOT running.(IE: init 3, networking)
How to use ?
While compiling your applications you must link with libgraph as in :
IMPORTANT :
quit in anywhere between 10 to 30 seconds(depending on CPU load).This should never happen if keyboard inst polled(and it shouldnt be).
If the program doesn't exit you may have to restart the X-server (just CTRL-BACKSPACE-ALT). Note that on some machines, you will have to init 3(drop to multi-usermode w networking) to kill Xorg process.
We have not yet seen a complete lock-up requiring a reboot.
scanf isnt used in PASCAL, keyboard interrupt based input (w range checking) is used instead. Write your code correctly (RTFM) if numbers instead of letters crash your application.
Scan thought the headers or a PASCAL REFERENCE manual to further inderstand invocation.
I dont want your flames, drop a bug report instead(preferably offering help).
DEVS:
Files : (needs PASCAL rewrite) (.h-> .inc and .c -> .pas or .pp)
(not necessary)
This is an SDL port.Learning SDL is not necessary. This is a BGI interface port. Write for the BGI, and the code should 'just work'. Next step should be learning allegro/SDL, and then OpenGL(castle engine).
Text functions are via already ported FPC code and function as normal. (the problem with the C port)
The following code: initgraph( , , ); .... printf("Hello",,); ... closegraph();
Is similar to OpenGL/SDL code. I have read a DX11 book while on the IKE. (Thank my draftsman) However, output is via consoleIO in a background window usually. ARGV parsing code is written and ported already for FPC.(it should mimic python)
To try new functions :
I suggest that you write it in a separate header or program and test it before
adding it to the main library. This way you can tweak it without recompiling the library.
(FPC does this internally):
Libtool :