115 lines
6.1 KiB
Plaintext
115 lines
6.1 KiB
Plaintext
$FG,5$$TX+CX,"Graphics Overview"$$FG$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$SP,"",1$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$WW,1$
|
|
* See $LK,"GrUpdateScreen","MN:GrUpdateScreen"$() and $LK,"GrUpdateWins","MN:GrUpdateWins"$(). Only tasks on $FG,2$core0$FG$ are allowed to have windows. There is one window per task, no child windows.
|
|
|
|
* $LK,"CDC","MN:CDC"$s (device contexts) are a data type for controlling graphics on the screen or graphics in mem. The device context structure has pen width and color. You use $LK,"DCAlias","MN:DCAlias"$() to create your own structure, with its own color and pen width. Free it with $LK,"DCDel","MN:DCDel"$() when finished.
|
|
|
|
* You change the "$FG,2$Fs->draw_it$FG$" var to point to your "$FG,2$DrawIt()$FG$" function which gets called each screen refresh (60 fps). You draw everything in the window over and over again. See $LK-A,"::/TempleOS/Demo/Graphics/Box.CPP"$.
|
|
|
|
* $FG,4$gr_dc$FG$ is a device context for persistent data on the screen, not needing to be redrawn. You create an alias for this by using $LK,"DCAlias","MN:DCAlias"$() and work with that. See $LK-A,"::/TempleOS/Demo/Graphics/DotNet.CPP"$.
|
|
|
|
* Use $LK,"DCNew","MN:DCNew"$() to create a mem bitmap which can be used to work off-screen and which can be $LK,"GrBlot","MN:GrBlot"$ed onto the screen. 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","MN:GrBlot"$() the brush instead of $LK,"GrPlot","MN:GrPlot"$(). See $LK-A,"::/TempleOS/Demo/Graphics/Blot.CPP"$.
|
|
|
|
* There are various flavors of line and point plotting routines. $LK,"GrLine","MN:GrLine"$() and $LK,"GrPlot","MN:GrPlot"$() are the simplest. The others allow 3D graphics and rotations.
|
|
|
|
* See $LK-A,"::/TempleOS/Doc/Transform.TXT"$ for adding a transformation.
|
|
|
|
* Set $LK,"DCF_SYMMETRY","MN:DCF_SYMMETRY"$ in the $LK,"CDC","MN:CDC"$$FG,2$.flags$FG$ and call $LK,"GrSetSymmetry","MN:GrSetSymmetry"$() or $LK,"GrSetSymmetry3","MN:GrSetSymmetry3"$(). This will plot a mirror image in addition to the primary image. Set $LK,"DCF_JUST_MIRROR","MN:DCF_JUST_MIRROR"$ to plot just the image, but this required $LK,"DCF_SYMMETRY","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","MN:CSprite"$s.
|
|
|
|
* Use the resource editor, $FG,2$<CTRL-R>$FG$, to create a sprite that can be plotted with $LK,"SpritePlot3","MN:SpritePlot3"$(). Use $FG,2$$$IB,"",1$$$FG$ in a src program to insert the addr of sprite #1. After creating a sprite with $FG,2$<CTRL-R>$FG$ in your src code, toggle to plain text with $FG,2$<CTRL-T>$FG$ and check its num. Then, make an assignment to a ptr var with $FG,2$$$IB,"",n$$$FG$ as the value. See $LK-A,"::/TempleOS/Demo/Graphics/SpritePlot.CPP"$ and $LK-A,"::/TempleOS/Demo/Graphics/SpritePlot3D.CPP"$.) The origin (zero point) for a sprite is defined by the cursor location when you press $FG,2$<CTRL-R>$FG$. The "$FG,2$x$FG$", "$FG,2$y$FG$" and "$FG,2$z$FG$" values you pass to $LK,"SpritePlot3","MN:SpritePlot3"$() shift it around. You can edit a sprite by clicking the cursor on it and pressing $FG,2$<CTRL-R>$FG$ again.
|
|
|
|
* There is a mechanism built-in for generating motion based on differential equations, which allows realistic physics. You create an $LK,"CMathODE","MN:CMathODE"$ struct with $LK,"ODENew","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","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","HI:Math/CMathODE"$.
|
|
See $LK-A,"::/TempleOS/Demo/Games/Rocket.CPP"$.
|
|
|
|
* There are a few $LK,"raster operations","MN:ROP_EQU"$ available. They go in bits 8-11 of the $FG,2$dc->color$FG$ member var.
|
|
|
|
* $LK,"ROP_COLLISION","MN:ROP_COLLISION"$ is special. It counts the num of pixels drawn on non-background locations. Using $LK,"ROP_COLLISION","MN:ROP_COLLISION"$ with vector $LK,"CSprite","MN:CSprite"$'s is tricky because overlapping pixels from lines in the $LK,"CSprite","MN:CSprite"$ register as collisions. You can either work with a nonzero count or convert your $LK,"CSprite","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","MN:ROP_COLLISION"$. See $LK-A,"::/TempleOS/Demo/Graphics/PixelCollision.CPP"$ and $LK-A,"::/TempleOS/Apps/TimeOut/TimeOut.CPP"$.
|
|
|
|
* The $FG,4$->dither_probability$FG$ member of $LK,"CDC","MN:CDC"$ is a $FG,2$U16$FG$ used to statistically select between two colors. See $LK-A,"::/TempleOS/Demo/Graphics/Shading.CPP"$. It works with many graphic routines, but not those with pens.
|
|
|