ZealOS/docs/Doc/GraphicsOverview.DD.html

129 lines
15 KiB
HTML
Raw Normal View History

2021-07-03 05:07:57 +01:00
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
<meta name="generator" content="ZealOS V0.13">
2021-07-03 05:07:57 +01:00
<style type="text/css">
body {background-color:#fef1f0;}
.cF0{color:#000000;background-color:#fef1f0;}
.cF1{color:#0148a4;background-color:#fef1f0;}
.cF2{color:#3b7901;background-color:#fef1f0;}
.cF3{color:#057c7e;background-color:#fef1f0;}
.cF4{color:#bb2020;background-color:#fef1f0;}
.cF5{color:#9e42ae;background-color:#fef1f0;}
.cF6{color:#b57901;background-color:#fef1f0;}
.cF7{color:#b2b6af;background-color:#fef1f0;}
.cF8{color:#555753;background-color:#fef1f0;}
.cF9{color:#678fbb;background-color:#fef1f0;}
.cFA{color:#82bc49;background-color:#fef1f0;}
.cFB{color:#0097a2;background-color:#fef1f0;}
.cFC{color:#e26a6a;background-color:#fef1f0;}
.cFD{color:#c671bc;background-color:#fef1f0;}
.cFE{color:#c7ab00;background-color:#fef1f0;}
.cFF{color:#fef1f0;background-color:#fef1f0;}
2021-07-03 05:07:57 +01:00
</style>
</head>
<body>
<pre style="font-family:monospace;font-size:12pt">
<a name="l1"></a><span class=cF5> Graphics Overview</span><span class=cF0>
2021-07-03 05:07:57 +01:00
<a name="l2"></a>
<a name="l3"></a>Dive into </span><a href="https://zeal-operating-system.github.io/ZealOS/Doc/DemoIndex.DD.html#l1"><span class=cF4>Demo Index</span></a><span class=cF0> to learn.
2021-07-03 05:07:57 +01:00
<a name="l4"></a>
<a name="l5"></a>The order layers are drawn on top of each other is:
<a name="l6"></a>
<a name="l7"></a>
<a name="l8"></a>
<a name="l9"></a>
<a name="l10"></a>
<a name="l11"></a>
<a name="l12"></a>
<a name="l13"></a>
<a name="l14"></a>
<a name="l15"></a>
<a name="l16"></a></span><span class=cFA>
<a name="l17"></a>/* Graphics Not Rendered in HTML */</span><span class=cF0>
<a name="l18"></a>
<a name="l19"></a>
<a name="l20"></a>
<a name="l21"></a>
<a name="l22"></a>
<a name="l23"></a>
<a name="l24"></a>
<a name="l25"></a>
<a name="l26"></a>
<a name="l27"></a>
<a name="l28"></a>
<a name="l29"></a>
<a name="l30"></a>
<a name="l31"></a>
<a name="l32"></a>
<a name="l33"></a>
<a name="l34"></a>
<a name="l35"></a>
<a name="l36"></a>
<a name="l37"></a>
<a name="l38"></a>
<a name="l39"></a>
<a name="l40"></a>
<a name="l41"></a>
<a name="l42"></a>
<a name="l43"></a>
<a name="l44"></a>
<a name="l45"></a>* See </span><a href="https://zeal-operating-system.github.io/ZealOS/System/Gr/GrScreen.CC.html#l415"><span class=cF4>GrUpdateScreen</span></a><span class=cF0>(), </span><a href="https://zeal-operating-system.github.io/ZealOS/System/Gr/GrScreen.CC.html#l69"><span class=cF4>GrUpdateTasks</span></a><span class=cF0>() and </span><a href="https://zeal-operating-system.github.io/ZealOS/System/Gr/GrScreen.CC.html#l19"><span class=cF4>GrUpdateTaskWin</span></a><span class=cF0>() called by the WinMgr task 60fps. Notice the task's </span><a href="https://zeal-operating-system.github.io/ZealOS/System/Gr/GrScreen.CC.html#l41"><span class=cF4>draw_it</span></a><span class=cF0>()
<a name="l46"></a>callback being called. Only tasks on </span><span class=cF2>Core0</span><span class=cF0> are allowed to have windows. There is one window per task, no child windows.
<a name="l47"></a>You can have pop-up child tasks.
2021-07-03 05:07:57 +01:00
<a name="l48"></a>
<a name="l49"></a>* </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l4304"><span class=cF4>CDC</span></a><span class=cF0>s (device contexts) are a data type for controlling graphics on the screen or graphics in mem. The device context
<a name="l50"></a>structure has thick and color. You use </span><a href="https://zeal-operating-system.github.io/ZealOS/System/Gr/GrDC.CC.html#l182"><span class=cF4>DCAlias</span></a><span class=cF0>() to create your own structure, with its own color and thick. Free it with </span><span class=cF4>
<a name="l51"></a></span><a href="https://zeal-operating-system.github.io/ZealOS/System/Gr/GrDC.CC.html#l230"><span class=cF4>DCDel</span></a><span class=cF0>() when finished.
2021-07-03 05:07:57 +01:00
<a name="l52"></a>
<a name="l53"></a>* </span><span class=cF4>gr.dc</span><span class=cF0> is a device context for persistent data on the screen, not needing to be redrawn. You create an alias for this by
<a name="l54"></a>using </span><a href="https://zeal-operating-system.github.io/ZealOS/System/Gr/GrDC.CC.html#l182"><span class=cF4>DCAlias</span></a><span class=cF0>() and work with that. See </span><a href="https://zeal-operating-system.github.io/ZealOS/Demo/Graphics/NetOfDots.CC.html#l1"><span class=cF4>::/Demo/Graphics/NetOfDots.CC</span></a><span class=cF0>.
2021-07-03 05:07:57 +01:00
<a name="l55"></a>
<a name="l56"></a>* There are various flavors of line and point plotting routines. </span><a href="https://zeal-operating-system.github.io/ZealOS/System/Gr/GrPrimatives.CC.html#l663"><span class=cF4>GrLine</span></a><span class=cF0>() and </span><a href="https://zeal-operating-system.github.io/ZealOS/System/Gr/GrPrimatives.CC.html#l61"><span class=cF4>GrPlot</span></a><span class=cF0>() are the simplest. The others allow
<a name="l57"></a>3D graphics and rotations.
2021-07-03 05:07:57 +01:00
<a name="l58"></a>
<a name="l59"></a>* See </span><a href="https://zeal-operating-system.github.io/ZealOS/Doc/Transform.DD.html#l1"><span class=cF4>::/Doc/Transform.DD</span></a><span class=cF0> for adding a transformation.
2021-07-03 05:07:57 +01:00
<a name="l60"></a>
<a name="l61"></a>* You change the </span><span class=cF2>Fs-&gt;draw_it</span><span class=cF0> var to point to your </span><span class=cF2>DrawIt()</span><span class=cF0> function which gets called each screen refresh (60 fps). You draw
<a name="l62"></a>everything in the window over and over again. See </span><a href="https://zeal-operating-system.github.io/ZealOS/Demo/Graphics/Box.CC.html#l1"><span class=cF4>::/Demo/Graphics/Box.CC</span></a><span class=cF0>.
2021-07-03 05:07:57 +01:00
<a name="l63"></a>
<a name="l64"></a>* Use the graphic sprite resource editor, </span><span class=cF2>&lt;CTRL-r&gt;</span><span class=cF0>, to create a sprite that can be plotted with </span><a href="https://zeal-operating-system.github.io/ZealOS/System/Gr/GrSpritePlot.CC.html#l18"><span class=cF4>Sprite3</span></a><span class=cF0>() or output to the cmd
<a name="l65"></a>line with </span><a href="https://zeal-operating-system.github.io/ZealOS/System/Gr/GrSpritePlot.CC.html#l536"><span class=cF4>Sprite</span></a><span class=cF0>(). Use </span><span class=cF2>$IB,&quot;&quot;,BI=1$</span><span class=cF0> in a src program to insert the addr of sprite binary data item #1. To learn how the
2021-07-03 05:07:57 +01:00
<a name="l66"></a>numbers work, after creating a sprite with </span><span class=cF2>&lt;CTRL-r&gt;</span><span class=cF0>, toggle to plain text with </span><span class=cF2>&lt;CTRL-t&gt;</span><span class=cF0> and check its num. Make an assignment
<a name="l67"></a>to a ptr var or pass to </span><a href="https://zeal-operating-system.github.io/ZealOS/System/Gr/GrSpritePlot.CC.html#l18"><span class=cF4>Sprite3</span></a><span class=cF0>() with </span><span class=cF2>$IB,&quot;&quot;,BI=n$</span><span class=cF0>. Use </span><span class=cF2>&lt;CTRL-r&gt;</span><span class=cF0>'s &quot;Pointer to Sprite&quot; to make a </span><span class=cF2>$IB...$</span><span class=cF0> entry. See </span><span class=cF4>
<a name="l68"></a></span><a href="https://zeal-operating-system.github.io/ZealOS/Demo/Graphics/SpritePlot.CC.html#l1"><span class=cF4>::/Demo/Graphics/SpritePlot.CC</span></a><span class=cF0> and </span><a href="https://zeal-operating-system.github.io/ZealOS/Demo/Graphics/SpritePlot3D.CC.html#l1"><span class=cF4>::/Demo/Graphics/SpritePlot3D.CC</span></a><span class=cF0>. The origin (zero point) for a sprite is defined by the
<a name="l69"></a>cursor location when you pressed </span><span class=cF2>&lt;CTRL-r&gt;</span><span class=cF0> to make it. You can edit a sprite by clicking the cursor on it and pressing </span><span class=cF2>&lt;CTRL-r
<a name="l70"></a>&gt;</span><span class=cF0> again.
2021-07-03 05:07:57 +01:00
<a name="l71"></a>
<a name="l72"></a>* Set </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l4278"><span class=cF4>DCF_SYMMETRY</span></a><span class=cF0> in the </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l4304"><span class=cF4>CDC</span></a><span class=cF2>.flags</span><span class=cF0> and call </span><a href="https://zeal-operating-system.github.io/ZealOS/System/Gr/GrMath.CC.html#l236"><span class=cF4>DCSymmetrySet</span></a><span class=cF0>() or </span><a href="https://zeal-operating-system.github.io/ZealOS/System/Gr/GrMath.CC.html#l259"><span class=cF4>DCSymmetry3Set</span></a><span class=cF0>(). This will plot a mirror image in addition
<a name="l73"></a>to the primary image. Set </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l4282"><span class=cF4>DCF_JUST_MIRROR</span></a><span class=cF0> to plot just the image, but this required </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l4278"><span class=cF4>DCF_SYMMETRY</span></a><span class=cF0> to be set at the same time.
<a name="l74"></a> Note: You can only have one symmetry active at a time including in </span><a href="https://zeal-operating-system.github.io/ZealOS/System/Gr/Gr.HH.html#l157"><span class=cF4>CSprite</span></a><span class=cF0>s.
2021-07-03 05:07:57 +01:00
<a name="l75"></a>
<a name="l76"></a>* Use </span><a href="https://zeal-operating-system.github.io/ZealOS/System/Gr/GrDC.CC.html#l205"><span class=cF4>DCNew</span></a><span class=cF0>() to create a mem bitmap which can be used to work off-screen and which can be </span><a href="https://zeal-operating-system.github.io/ZealOS/System/Gr/GrBitMap.CC.html#l93"><span class=cF4>GrBlot</span></a><span class=cF0>ed onto the screen. If you
<a name="l77"></a>set </span><span class=cF2>brush</span><span class=cF0> member of </span><span class=cF2>CDC</span><span class=cF0> to another </span><span class=cF2>CDC</span><span class=cF0>, all the graphic routines will </span><a href="https://zeal-operating-system.github.io/ZealOS/System/Gr/GrBitMap.CC.html#l93"><span class=cF4>GrBlot</span></a><span class=cF0>() the brush instead of </span><a href="https://zeal-operating-system.github.io/ZealOS/System/Gr/GrPrimatives.CC.html#l61"><span class=cF4>GrPlot</span></a><span class=cF0>(). See </span><span class=cF4>
<a name="l78"></a></span><a href="https://zeal-operating-system.github.io/ZealOS/Demo/Graphics/Blot.CC.html#l1"><span class=cF4>::/Demo/Graphics/Blot.CC</span></a><span class=cF0>.
2021-07-03 05:07:57 +01:00
<a name="l79"></a>
<a name="l80"></a>* There are a few </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l3605"><span class=cF4>raster operations</span></a><span class=cF0> available. They go in bits 8-11 of the </span><span class=cF2>dc-&gt;color</span><span class=cF0> member var which is a </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l3646"><span class=cF4>CColorROPU32</span></a><span class=cF0>. </span><span class=cF4>
<a name="l81"></a></span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l3607"><span class=cF4>ROP_COLLISION</span></a><span class=cF0> is special. It counts the num of pixs drawn on non-background locations. Using </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l3607"><span class=cF4>ROP_COLLISION</span></a><span class=cF0> with vector </span><span class=cF4>
<a name="l82"></a></span><a href="https://zeal-operating-system.github.io/ZealOS/System/Gr/Gr.HH.html#l157"><span class=cF4>CSprite</span></a><span class=cF0>'s is tricky because overlapping pixs from lines in the </span><a href="https://zeal-operating-system.github.io/ZealOS/System/Gr/Gr.HH.html#l157"><span class=cF4>CSprite</span></a><span class=cF0> reg as collisions. You can either work with a nonzero
<a name="l83"></a>count or convert your </span><a href="https://zeal-operating-system.github.io/ZealOS/System/Gr/Gr.HH.html#l157"><span class=cF4>CSprite</span></a><span class=cF0> to a bitmap if your subelements draw on top of each other. Be sure to set </span><span class=cF4>-&gt;bkcolor</span><span class=cF0> before
<a name="l84"></a>using </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l3607"><span class=cF4>ROP_COLLISION</span></a><span class=cF0>. See </span><a href="https://zeal-operating-system.github.io/ZealOS/Demo/Graphics/Collision.CC.html#l1"><span class=cF4>::/Demo/Graphics/Collision.CC</span></a><span class=cF0> and </span><a href="https://zeal-operating-system.github.io/ZealOS/Apps/Titanium/Titanium.CC.html#l555"><span class=cF4>Titanium</span></a><span class=cF0>.
2021-07-03 05:07:57 +01:00
<a name="l85"></a>
<a name="l86"></a>* The </span><span class=cF4>-&gt;dither_probability_u16</span><span class=cF0> member of </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l4304"><span class=cF4>CDC</span></a><span class=cF0> is a </span><span class=cF2>U16</span><span class=cF0> used to statistically sel between two colors to get something resembling
<a name="l87"></a>more shades of color. See </span><a href="https://zeal-operating-system.github.io/ZealOS/Demo/Graphics/SunMoon.CC.html#l1"><span class=cF4>::/Demo/Graphics/SunMoon.CC</span></a><span class=cF0> and </span><a href="https://zeal-operating-system.github.io/ZealOS/Demo/Graphics/Shading.CC.html#l1"><span class=cF4>::/Demo/Graphics/Shading.CC</span></a><span class=cF0>. It works with many graphic
<a name="l88"></a>routines, but not those with pens.
2021-07-03 05:07:57 +01:00
<a name="l89"></a>
<a name="l90"></a>* There is a mechanism built-in for generating motion based on differential equations, which allows realistic physics. You
<a name="l91"></a>create an </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l281"><span class=cF4>CMathODE</span></a><span class=cF0> struct with </span><a href="https://zeal-operating-system.github.io/ZealOS/System/MathODE.CC.html#l31"><span class=cF4>ODENew</span></a><span class=cF0>(), passing it the num of vars in the state vect. For realistic physics, you usually
<a name="l92"></a>have 2 state vars for each dimension (for each mass) because motion is governed by F=mA which is a 2nd order equation. The
<a name="l93"></a>two states are pos and velocity and to solve these you need to supply the derivative of pos and velocity. The derivative of
<a name="l94"></a>pos is usually simply the current velocity and the derivative of velocity is the acceleration (the sum of forces on a mass
<a name="l95"></a>divided by mass). To help provide meaningful names for values in the state vect, you can create an </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l230"><span class=cF4>COrder2D3</span></a><span class=cF0> ptr and point
<a name="l96"></a>it to a mass in the state vect. Six elements in the state vect are required for each mass.
2021-07-03 05:07:57 +01:00
<a name="l97"></a>
<a name="l98"></a>See </span><span class=cF4><u>Math/CMathODE</u></span><span class=cF0>.
<a name="l99"></a>See </span><a href="https://zeal-operating-system.github.io/ZealOS/Demo/Games/Rocket.CC.html#l1"><span class=cF4>::/Demo/Games/Rocket.CC</span></a><span class=cF0>.
2021-07-03 05:07:57 +01:00
</span></pre></body>
</html>