-
Notifications
You must be signed in to change notification settings - Fork 1
/
FASTGPI.TXT
93 lines (69 loc) · 3.95 KB
/
FASTGPI.TXT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
Name: REVOLVE
Descripcion: Demonstrates Fast GPI Graphics
Date: 2023-05-07
Version: 1.07
----------------------------
DESCRIPTION
-----------
Method for Getting Fast Graphics through the OS/2 GPI.
People are often surprised and dismayed to find that the GPI can be very slow if it is used naively. One of the biggest mistakes is to try to write a large number of pixels using GpiSetPel(). To reassure people that fast screen writes CAN be achieved with the GPI and without needing to go to the MMPM direct-screen support (DIVE), I have provided this little example. As a bonus, it also shows how to use bitmaps, how to write a multi-threaded application, how to use semaphores, and how to set up a gray-scale palette. Also, you can learn about classical wave behavior
and its difference equation representation!
The basic technique for fast screen writes is to make a bitmap that corresponds to the screen. Then, using GpiSetBitmapBits(), this bitmap is updated and then blitted to the screen. This requires only two GPI calls to write an arbitrary number of pixels, instead of doing a call to set the color and a call to write the pixel for EACH pixel.
Here are miscellaneous notes.
1) The example implements a simulation of two interfering circular wave
sources in two dimensions. The output is displayed with a 32-level
grayscale.
2) A 256-color display at 1024x768 is assumed. The 256 colors are required
to get the gray-scale palette. That could be dispensable for other
applications. I have not tried this at other resolutions, but things
should work OK (or could be easily adjusted for).
3) Built with GCC 9.
4) The screens are written very fast [DisplayPlane()] but there is delay
between the screen writes due to the many thousands of floating-point
calculations needed to simulate the wave behavior. Most applications
will not be so compute-bound.
5) There may be a more direct method for getting the RGB mappings than
that used in PrepareGraphics(). Any ideas?
6) This trick is suitable for applications where you want to write a lot
of points often. If the drawing is sparse, you may be better off with
straight GPI calls (I haven't really analyzed this yet).
7) If you doubt the effectiveness of this trick, try implementing it with
GpiSetPel(). You'll be reminded of the DOS BIOS!
8) The example is multithreaded; one thread does the model, one does the main
window handling. Down with clock icons!!!
REQUIREMENTS
------------
- yum install git gcc make libc-devel binutils watcom-wrc watcom-wlink-hll
COMPILE INSTRUCTIONS
--------------------
This version of this sample was modified to compile on ArcaOS with GCC 9 compiler.
1) Remember to have correct header files your path. For GCC the correct ones are the included on the "libc-devel", not the ones from the OS/2 Toolkit. Check your config.sys for "SET INCLUDE=C:\usr\include"
2) Since I'm using the Watcom Resource Compiler (open source) instead of the classic rc.exe, and the the Watcom Linker, intead of the classic ilink.exe, add to your config.sys...
SET EMXOMFLD_LINKER=wl.exe
SET EMXOMFLD_TYPE=WLINK
SET EMXOMFLD_RC_TYPE=WRC
SET EMXOMFLD_RC=wrc.exe
3) Run "make" or "make 2>&1 |tee make.out" to get the log file.
TOOLS USED
----------
- ArcaOS - Verion 5.0.7
- wrc - Watcom Resource Compiler version 2.0beta1
- wl - Watcom Linker
- gcc - gcc (GCC) 9.2.0 20190812 (OS/2 RPM build 9.2.0-5.oc00)
- make - Version 3.81 k2 (2017-11-10)
TROUBLESHOOT
------------
The compile produce will run by just executing make on the directory, but a compile.cmd file is includes to store the log in a file. If you want to save the log file you can run it as "nmake 2>&1 |tee make.out". The log will be saved into the "make.out" file.
HISTORY
----------
- 1.07 - 2023-05-07
Changed version to compile on gcc and to run on ArcaOS 5.0.7.
- 1.06 - 1988
Original version by Charles Petzold
LICENSE
-------
The 3-Clause BSD License.
AUTHORS
-------
- Martin Iturbide (2023)
- Donald Graft