A TempleOS distro for heretics
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

117 lines
6.6 KiB

$WW,1$$FG,5$$TX+CX,"Graphics Overview"$$FG$
Dive into $LK,"Demo Index",A="FI:::/Doc/DemoIndex.DD"$ to learn.
The order layers are drawn on top of each other is:
$SP,"",BI=1$
* See $LK,"GrUpdateScrn",A="MN:GrUpdateScrn"$(), $LK,"GrUpdateTasks",A="MN:GrUpdateTasks"$() and $LK,"GrUpdateTaskWin",A="MN:GrUpdateTaskWin"$() called by the WinMgr task 30fps. Notice the task's $LK,"draw_it",A="FF:::/Adam/Gr/GrScrn.HC,draw_it"$() callback being called. Only tasks on $FG,2$Core0$FG$ are allowed to have windows. There is one window per task, no child windows. You can have pop-up child tasks.
* $LK,"CDC",A="MN:CDC"$s (device contexts) are a data type for controlling graphics on the scrn or graphics in mem. The device context structure has thick and color. You use $LK,"DCAlias",A="MN:DCAlias"$() to create your own structure, with its own color and thick. Free it with $LK,"DCDel",A="MN:DCDel"$() when finished.
* $FG,4$gr.dc$FG$ is a device context for persistent data on the scrn, not needing to be redrawn. You create an alias for this by using $LK,"DCAlias",A="MN:DCAlias"$() and work with that. See $LK,"::/Demo/Graphics/NetOfDots.HC"$.
* There are various flavors of line and point plotting routines. $LK,"GrLine",A="MN:GrLine"$() and $LK,"GrPlot",A="MN:GrPlot"$() are the simplest. The others allow 3D graphics and rotations.
* See $LK,"::/Doc/Transform.DD"$ for adding a transformation.
* You change the $FG,2$Fs->draw_it$FG$ var to point to your $FG,2$DrawIt()$FG$ function which gets called each scrn refresh (30 fps). You draw everything in the window over and over again. See $LK,"::/Demo/Graphics/Box.HC"$.
* Use the graphic sprite resource editor, $FG,2$<CTRL-r>$FG$, to create a sprite that can be plotted with $LK,"Sprite3",A="MN:Sprite3"$() or output to the cmd line with $LK,"Sprite",A="MN:Sprite"$(). Use $FG,2$$$IB,"",BI=1$$$FG$ in a src program to insert the addr of sprite binary data item #1. To learn how the numbers work, after creating a sprite with $FG,2$<CTRL-r>$FG$, toggle to plain text with $FG,2$<CTRL-t>$FG$ and check its num. Make an assignment to a ptr var or pass to $LK,"Sprite3",A="MN:Sprite3"$() with $FG,2$$$IB,"",BI=n$$$FG$. Use $FG,2$<CTRL-r>$FG$'s "Pointer to Sprite" to make a $FG,2$$$IB...$$$FG$ entry. See $LK,"::/Demo/Graphics/SpritePlot.HC"$ and $LK,"::/Demo/Graphics/SpritePlot3D.HC"$. The origin (zero point) for a sprite is defined by the cursor location when you pressed $FG,2$<CTRL-r>$FG$ to make it. You can edit a sprite by clicking the cursor on it and pressing $FG,2$<CTRL-r>$FG$ again.
* Set $LK,"DCF_SYMMETRY",A="MN:DCF_SYMMETRY"$ in the $LK,"CDC",A="MN:CDC"$$FG,2$.flags$FG$ and call $LK,"DCSymmetrySet",A="MN:DCSymmetrySet"$() or $LK,"DCSymmetry3Set",A="MN:DCSymmetry3Set"$(). This will plot a mirror image in addition to the primary image. Set $LK,"DCF_JUST_MIRROR",A="MN:DCF_JUST_MIRROR"$ to plot just the image, but this required $LK,"DCF_SYMMETRY",A="MN:DCF_SYMMETRY"$ to be set at the same time. Note: You can only have one symmetry active at a time including in $LK,"CSprite",A="MN:CSprite"$s.
* Use $LK,"DCNew",A="MN:DCNew"$() to create a mem bitmap which can be used to work off-scrn and which can be $LK,"GrBlot",A="MN:GrBlot"$ed onto the scrn. If you set $FG,2$brush$FG$ member of $FG,2$CDC$FG$ to another $FG,2$CDC$FG$, all the graphic routines will $LK,"GrBlot",A="MN:GrBlot"$() the brush instead of $LK,"GrPlot",A="MN:GrPlot"$(). See $LK,"::/Demo/Graphics/Blot.HC"$.
* There are a few $LK,"raster operations",A="MN:ROP_EQU"$ available. They go in bits 8-11 of the $FG,2$dc->color$FG$ member var which is a $LK,"CColorROPU32",A="MN:CColorROPU32"$. $LK,"ROP_COLLISION",A="MN:ROP_COLLISION"$ is special. It counts the num of pixs drawn on non-background locations. Using $LK,"ROP_COLLISION",A="MN:ROP_COLLISION"$ with vector $LK,"CSprite",A="MN:CSprite"$'s is tricky because overlapping pixs from lines in the $LK,"CSprite",A="MN:CSprite"$ reg as collisions. You can either work with a nonzero count or convert your $LK,"CSprite",A="MN:CSprite"$ to a bitmap if your subelements draw on top of each other. Be sure to set $FG,4$->bkcolor$FG$ before using $LK,"ROP_COLLISION",A="MN:ROP_COLLISION"$. See $LK,"::/Demo/Graphics/Collision.HC"$ and $LK,"Titanium",A="FF:::/Apps/Titanium/Titanium.HC,ROP_COLLISION"$.
* The $FG,4$->dither_probability_u16$FG$ member of $LK,"CDC",A="MN:CDC"$ is a $FG,2$U16$FG$ used to statistically sel between two colors to get something resembling more shades of color. See $LK,"::/Demo/Graphics/SunMoon.HC"$ and $LK,"::/Demo/Graphics/Shading.HC"$. It works with many graphic routines, but not those with pens.
* There is a mechanism built-in for generating motion based on differential equations, which allows realistic physics. You create an $LK,"CMathODE",A="MN:CMathODE"$ struct with $LK,"ODENew",A="MN:ODENew"$(), passing it the num of vars in the state vect. For realistic physics, you usually have 2 state vars for each dimension (for each mass) because motion is governed by F=mA which is a 2nd order equation. The two states are pos and velocity and to solve these you need to supply the derivative of pos and velocity. The derivative of pos is usually simply the current velocity and the derivative of velocity is the acceleration (the sum of forces on a mass divided by mass). To help provide meaningful names for values in the state vect, you can create an $LK,"COrder2D3",A="MN:COrder2D3"$ ptr and point it to a mass in the state vect. Six elements in the state vect are required for each mass.
See $LK,"Math/CMathODE",A="HI:Math/CMathODE"$.
See $LK,"::/Demo/Games/Rocket.HC"$.
<
H<EFBFBD><EFBFBD><EFBFBD><EFBFBD>H<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
8<EFBFBD><EFBFBD><EFBFBD><EFBFBD>84
8404
<EFBFBD><EFBFBD>
<EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD>
0 
@<EFBFBD>
@ @
P<EFBFBD><EFBFBD><EFBFBD><EFBFBD>P<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
X<EFBFBD><EFBFBD><EFBFBD><EFBFBD>X<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
P<EFBFBD><EFBFBD><EFBFBD><EFBFBD>@<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@<EFBFBD><EFBFBD><EFBFBD><EFBFBD>@
@ 8
X<EFBFBD><EFBFBD><EFBFBD><EFBFBD>H<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
H<EFBFBD><EFBFBD><EFBFBD><EFBFBD>H
HH
HH
H @
@ T
(,,
TT
T<EFBFBD>
Th
hh
h<EFBFBD>
h|
<EFBFBD>|<EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD>
|<EFBFBD>|
|<EFBFBD>
<EFBFBD><EFBFBD>
H<EFBFBD><EFBFBD><EFBFBD><EFBFBD>8<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
pp
(\ \
0H(H
(,'@
,<EFBFBD>
 p
((\
0<EFBFBD><EFBFBD><EFBFBD><EFBFBD>0H
@<EFBFBD><EFBFBD><EFBFBD><EFBFBD>@
88
00,
@<EFBFBD><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
8(d<EFBFBD><EFBFBD><EFBFBD><EFBFBD>gr.textbase lags a refresh\<EFBFBD><EFBFBD><EFBFBD><EFBFBD>task0 docsT<EFBFBD><EFBFBD><EFBFBD><EFBFBD>task0->draw_it()L<EFBFBD><EFBFBD><EFBFBD><EFBFBD>task0->next_ctrlD task0->last_ctrl< task1 docs44task1->draw_it(),Htask1->next_ctrl$\task1->last_ctrlpgr.dc persistent layer<EFBFBD>gr.fp_final_screen_update()