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.05" >
< style type = "text/css" >
body {background-color:#000000;}
.cF0{color:#ffffff;background-color:#000000;}
.cF1{color:#3465a4;background-color:#000000;}
.cF2{color:#4e9a06;background-color:#000000;}
.cF3{color:#06989a;background-color:#000000;}
.cF4{color:#a24444;background-color:#000000;}
.cF5{color:#75507b;background-color:#000000;}
.cF6{color:#ce982f;background-color:#000000;}
.cF7{color:#bcc0b9;background-color:#000000;}
.cF8{color:#555753;background-color:#000000;}
.cF9{color:#729fcf;background-color:#000000;}
.cFA{color:#82bc49;background-color:#000000;}
.cFB{color:#34e2e2;background-color:#000000;}
.cFC{color:#ac3535;background-color:#000000;}
.cFD{color:#ad7fa8;background-color:#000000;}
.cFE{color:#fce94f;background-color:#000000;}
.cFF{color:#000000;background-color:#000000;}
< / style >
< / head >
< body >
< pre style = "font-family:courier;font-size:10pt" >
< a name = "l1" > < / a > < span class = cF0 > #< / span > < span class = cF1 > help_index< / span > < span class = cF0 > < / span > < span class = cF6 > " Graphics/Math/3D Transformation" < / span > < span class = cF0 >
< a name = "l2" > < / a > #< / span > < span class = cF1 > help_file< / span > < span class = cF0 > < / span > < span class = cF6 > " ::/Doc/Transform" < / span > < span class = cF0 >
< a name = "l3" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l4" > < / a > #< / span > < span class = cF1 > define< / span > < span class = cF0 > < / span > < span class = cF3 > GR_SCALE< / span > < span class = cF0 > (< / span > < span class = cFE > 1< / span > < span class = cF0 > < < < / span > < span class = cFE > 32< / span > < span class = cF0 > )
2021-07-03 05:07:57 +01:00
< a name = "l5" > < / a >
< a name = "l6" > < / a > < / span > < span class = cF1 > public< / span > < span class = cF0 > < / span > < span class = cF1 > U0< / span > < span class = cF0 > < / span > < span class = cF5 > Mat4x4MulXYZ< / span > < span class = cF0 > (< / span > < span class = cF9 > I64< / span > < span class = cF0 > *r, < / span > < span class = cF9 > I64< / span > < span class = cF0 > *_x, < / span > < span class = cF9 > I64< / span > < span class = cF0 > *_y, < / span > < span class = cF9 > I64< / span > < span class = cF0 > *_z)
2021-07-03 07:51:43 +01:00
< a name = "l7" > < / a > {< / span > < span class = cF2 > //Rotate 3D point using 4x4 matrix. Uses < / span > < a href = "https://tomawezome.github.io/ZealOS/Demo/Lectures/FixedPoint.html#l1" > < span class = cF4 > fixed-point< / span > < / a > < span class = cF2 > .< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l8" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > x1, y1, z1, xx = *_x, yy = *_y, zz = *_z;
2021-07-03 05:07:57 +01:00
< a name = "l9" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l10" > < / a > x1 = (r[< / span > < span class = cFE > 0< / span > < span class = cF0 > * < / span > < span class = cFE > 4< / span > < span class = cF0 > + < / span > < span class = cFE > 0< / span > < span class = cF0 > ] * xx + r[< / span > < span class = cFE > 0< / span > < span class = cF0 > * < / span > < span class = cFE > 4< / span > < span class = cF0 > + < / span > < span class = cFE > 1< / span > < span class = cF0 > ] * yy + r[< / span > < span class = cFE > 0< / span > < span class = cF0 > * < / span > < span class = cFE > 4< / span > < span class = cF0 > + < / span > < span class = cFE > 2< / span > < span class = cF0 > ] * zz + r[< / span > < span class = cFE > 0< / span > < span class = cF0 > * < / span > < span class = cFE > 4< / span > < span class = cF0 > + < / span > < span class = cFE > 3< / span > < span class = cF0 > ]) > > < / span > < span class = cFE > 32< / span > < span class = cF0 > ;
< a name = "l11" > < / a > y1 = (r[< / span > < span class = cFE > 1< / span > < span class = cF0 > * < / span > < span class = cFE > 4< / span > < span class = cF0 > + < / span > < span class = cFE > 0< / span > < span class = cF0 > ] * xx + r[< / span > < span class = cFE > 1< / span > < span class = cF0 > * < / span > < span class = cFE > 4< / span > < span class = cF0 > + < / span > < span class = cFE > 1< / span > < span class = cF0 > ] * yy + r[< / span > < span class = cFE > 1< / span > < span class = cF0 > * < / span > < span class = cFE > 4< / span > < span class = cF0 > + < / span > < span class = cFE > 2< / span > < span class = cF0 > ] * zz + r[< / span > < span class = cFE > 1< / span > < span class = cF0 > * < / span > < span class = cFE > 4< / span > < span class = cF0 > + < / span > < span class = cFE > 3< / span > < span class = cF0 > ]) > > < / span > < span class = cFE > 32< / span > < span class = cF0 > ;
< a name = "l12" > < / a > z1 = (r[< / span > < span class = cFE > 2< / span > < span class = cF0 > * < / span > < span class = cFE > 4< / span > < span class = cF0 > + < / span > < span class = cFE > 0< / span > < span class = cF0 > ] * xx + r[< / span > < span class = cFE > 2< / span > < span class = cF0 > * < / span > < span class = cFE > 4< / span > < span class = cF0 > + < / span > < span class = cFE > 1< / span > < span class = cF0 > ] * yy + r[< / span > < span class = cFE > 2< / span > < span class = cF0 > * < / span > < span class = cFE > 4< / span > < span class = cF0 > + < / span > < span class = cFE > 2< / span > < span class = cF0 > ] * zz + r[< / span > < span class = cFE > 2< / span > < span class = cF0 > * < / span > < span class = cFE > 4< / span > < span class = cF0 > + < / span > < span class = cFE > 3< / span > < span class = cF0 > ]) > > < / span > < span class = cFE > 32< / span > < span class = cF0 > ;
< a name = "l13" > < / a > *_x = x1;
< a name = "l14" > < / a > *_y = y1;
< a name = "l15" > < / a > *_z = z1;
2021-07-03 05:07:57 +01:00
< a name = "l16" > < / a > }
< a name = "l17" > < / a >
< a name = "l18" > < / a > < / span > < span class = cF1 > public< / span > < span class = cF0 > < / span > < span class = cF1 > U0< / span > < span class = cF0 > < / span > < span class = cF5 > DCTransform< / span > < span class = cF0 > (< / span > < span class = cF9 > CDC< / span > < span class = cF0 > *dc, < / span > < span class = cF9 > I64< / span > < span class = cF0 > *_x, < / span > < span class = cF9 > I64< / span > < span class = cF0 > *_y, < / span > < span class = cF9 > I64< / span > < span class = cF0 > *_z)
< a name = "l19" > < / a > {< / span > < span class = cF2 > //This is the default dc-> transform() callback.< / span > < span class = cF0 >
2021-07-03 07:51:43 +01:00
< a name = "l20" > < / a > < / span > < span class = cF2 > //Uses < / span > < a href = "https://tomawezome.github.io/ZealOS/Demo/Lectures/FixedPoint.html#l1" > < span class = cF4 > fixed-point< / span > < / a > < span class = cF2 > .< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l21" > < / a > < / span > < span class = cF5 > Mat4x4MulXYZ< / span > < span class = cF0 > (dc-> r, _x, _y, _z);
< a name = "l22" > < / a > *_x += dc-> x;
< a name = "l23" > < / a > *_y += dc-> y;
< a name = "l24" > < / a > *_z += dc-> z;
2021-07-03 05:07:57 +01:00
< a name = "l25" > < / a > }
< a name = "l26" > < / a >
< a name = "l27" > < / a > < / span > < span class = cF1 > public< / span > < span class = cF0 > < / span > < span class = cF9 > I64< / span > < span class = cF0 > *< / span > < span class = cF5 > Mat4x4IdentEqu< / span > < span class = cF0 > (< / span > < span class = cF9 > I64< / span > < span class = cF0 > *r)
2021-07-03 07:51:43 +01:00
< a name = "l28" > < / a > {< / span > < span class = cF2 > //Set matrix to identity. Uses < / span > < a href = "https://tomawezome.github.io/ZealOS/Demo/Lectures/FixedPoint.html#l1" > < span class = cF4 > fixed-point< / span > < / a > < span class = cF2 > .< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l29" > < / a > < / span > < span class = cF5 > MemSet< / span > < span class = cF0 > (r, < / span > < span class = cFE > 0< / span > < span class = cF0 > , < / span > < span class = cF1 > sizeof< / span > < span class = cF7 > (< / span > < span class = cF9 > I64< / span > < span class = cF7 > )< / span > < span class = cF0 > *< / span > < span class = cFE > 16< / span > < span class = cF0 > );
< a name = "l30" > < / a > r[< / span > < span class = cFE > 0< / span > < span class = cF0 > * < / span > < span class = cFE > 4< / span > < span class = cF0 > + < / span > < span class = cFE > 0< / span > < span class = cF0 > ].i32[< / span > < span class = cFE > 1< / span > < span class = cF0 > ] = < / span > < span class = cFE > 1< / span > < span class = cF0 > ;
< a name = "l31" > < / a > r[< / span > < span class = cFE > 1< / span > < span class = cF0 > * < / span > < span class = cFE > 4< / span > < span class = cF0 > + < / span > < span class = cFE > 1< / span > < span class = cF0 > ].i32[< / span > < span class = cFE > 1< / span > < span class = cF0 > ] = < / span > < span class = cFE > 1< / span > < span class = cF0 > ;
< a name = "l32" > < / a > r[< / span > < span class = cFE > 2< / span > < span class = cF0 > * < / span > < span class = cFE > 4< / span > < span class = cF0 > + < / span > < span class = cFE > 2< / span > < span class = cF0 > ].i32[< / span > < span class = cFE > 1< / span > < span class = cF0 > ] = < / span > < span class = cFE > 1< / span > < span class = cF0 > ;
< a name = "l33" > < / a > r[< / span > < span class = cFE > 3< / span > < span class = cF0 > * < / span > < span class = cFE > 4< / span > < span class = cF0 > + < / span > < span class = cFE > 3< / span > < span class = cF0 > ].i32[< / span > < span class = cFE > 1< / span > < span class = cF0 > ] = < / span > < span class = cFE > 1< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l34" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l35" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > r;
2021-07-03 05:07:57 +01:00
< a name = "l36" > < / a > }
< a name = "l37" > < / a >
< a name = "l38" > < / a > < / span > < span class = cF1 > public< / span > < span class = cF0 > < / span > < span class = cF9 > I64< / span > < span class = cF0 > *< / span > < span class = cF5 > Mat4x4IdentNew< / span > < span class = cF0 > (< / span > < span class = cF9 > CTask< / span > < span class = cF0 > *mem_task=< / span > < span class = cF3 > NULL< / span > < span class = cF0 > )
2021-07-03 07:51:43 +01:00
< a name = "l39" > < / a > {< / span > < span class = cF2 > //MAlloc an identity matrix. Uses < / span > < a href = "https://tomawezome.github.io/ZealOS/Demo/Lectures/FixedPoint.html#l1" > < span class = cF4 > fixed-point< / span > < / a > < span class = cF2 > .< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l40" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > < / span > < span class = cF5 > Mat4x4IdentEqu< / span > < span class = cF0 > (< / span > < span class = cF5 > MAlloc< / span > < span class = cF7 > (< / span > < span class = cF1 > sizeof< / span > < span class = cF0 > (< / span > < span class = cF9 > I64< / span > < span class = cF0 > ) * < / span > < span class = cFE > 16< / span > < span class = cF0 > , mem_task< / span > < span class = cF7 > )< / span > < span class = cF0 > );
2021-07-03 05:07:57 +01:00
< a name = "l41" > < / a > }
< a name = "l42" > < / a >
< a name = "l43" > < / a > < / span > < span class = cF1 > public< / span > < span class = cF0 > < / span > < span class = cF9 > I64< / span > < span class = cF0 > < / span > < span class = cF5 > Mat4x4NormSqr65536< / span > < span class = cF0 > (< / span > < span class = cF9 > I64< / span > < span class = cF0 > *r)
< a name = "l44" > < / a > {< / span > < span class = cF2 > //Norm Squared of r.< / span > < span class = cF0 >
< a name = "l45" > < / a > < / span > < span class = cF2 > //(1.0/Sqrt(3))*65536=37837.22< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l46" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > < / span > < span class = cF5 > SqrI64< / span > < span class = cF0 > (< / span > < span class = cF7 > (< / span > < span class = cF0 > r[< / span > < span class = cFE > 0< / span > < span class = cF0 > * < / span > < span class = cFE > 4< / span > < span class = cF0 > + < / span > < span class = cFE > 0< / span > < span class = cF0 > ] * < / span > < span class = cFE > 37838< / span > < span class = cF0 > + r[< / span > < span class = cFE > 0< / span > < span class = cF0 > * < / span > < span class = cFE > 4< / span > < span class = cF0 > + < / span > < span class = cFE > 1< / span > < span class = cF0 > ] * < / span > < span class = cFE > 37838< / span > < span class = cF0 > + r[< / span > < span class = cFE > 0< / span > < span class = cF0 > * < / span > < span class = cFE > 4< / span > < span class = cF0 > + < / span > < span class = cFE > 2< / span > < span class = cF0 > ] * < / span > < span class = cFE > 37838< / span > < span class = cF7 > )< / span > < span class = cF0 > > > < / span > < span class = cFE > 32< / span > < span class = cF0 > ) +
< a name = "l47" > < / a > < / span > < span class = cF5 > SqrI64< / span > < span class = cF0 > (< / span > < span class = cF7 > (< / span > < span class = cF0 > r[< / span > < span class = cFE > 1< / span > < span class = cF0 > * < / span > < span class = cFE > 4< / span > < span class = cF0 > + < / span > < span class = cFE > 0< / span > < span class = cF0 > ] * < / span > < span class = cFE > 37837< / span > < span class = cF0 > + r[< / span > < span class = cFE > 1< / span > < span class = cF0 > * < / span > < span class = cFE > 4< / span > < span class = cF0 > + < / span > < span class = cFE > 1< / span > < span class = cF0 > ] * < / span > < span class = cFE > 37837< / span > < span class = cF0 > + r[< / span > < span class = cFE > 1< / span > < span class = cF0 > * < / span > < span class = cFE > 4< / span > < span class = cF0 > + < / span > < span class = cFE > 2< / span > < span class = cF0 > ] * < / span > < span class = cFE > 37837< / span > < span class = cF7 > )< / span > < span class = cF0 > > > < / span > < span class = cFE > 32< / span > < span class = cF0 > ) +
< a name = "l48" > < / a > < / span > < span class = cF5 > SqrI64< / span > < span class = cF0 > (< / span > < span class = cF7 > (< / span > < span class = cF0 > r[< / span > < span class = cFE > 2< / span > < span class = cF0 > * < / span > < span class = cFE > 4< / span > < span class = cF0 > + < / span > < span class = cFE > 0< / span > < span class = cF0 > ] * < / span > < span class = cFE > 37837< / span > < span class = cF0 > + r[< / span > < span class = cFE > 2< / span > < span class = cF0 > * < / span > < span class = cFE > 4< / span > < span class = cF0 > + < / span > < span class = cFE > 1< / span > < span class = cF0 > ] * < / span > < span class = cFE > 37837< / span > < span class = cF0 > + r[< / span > < span class = cFE > 2< / span > < span class = cF0 > * < / span > < span class = cFE > 4< / span > < span class = cF0 > + < / span > < span class = cFE > 2< / span > < span class = cF0 > ] * < / span > < span class = cFE > 37837< / span > < span class = cF7 > )< / span > < span class = cF0 > > > < / span > < span class = cFE > 32< / span > < span class = cF0 > );
2021-07-03 05:07:57 +01:00
< a name = "l49" > < / a > }
< a name = "l50" > < / a >
< a name = "l51" > < / a > < / span > < span class = cF1 > public< / span > < span class = cF0 > < / span > < span class = cF1 > U0< / span > < span class = cF0 > < / span > < span class = cF5 > DCMat4x4Set< / span > < span class = cF0 > (< / span > < span class = cF9 > CDC< / span > < span class = cF0 > *dc=< / span > < span class = cF3 > NULL< / span > < span class = cF0 > , < / span > < span class = cF9 > I64< / span > < span class = cF0 > *r)
2021-07-03 07:51:43 +01:00
< a name = "l52" > < / a > {< / span > < span class = cF2 > //Set device context's rot matrix. Will be < / span > < a href = "https://tomawezome.github.io/ZealOS/Kernel/Memory/MAllocFree.html#l387" > < span class = cF4 > Free< / span > < / a > < span class = cF2 > d() in < / span > < a href = "https://tomawezome.github.io/ZealOS/System/Gr/GrDC.html#l230" > < span class = cF4 > DCDel< / span > < / a > < span class = cF2 > ().Uses < / span > < a href = "https://tomawezome.github.io/ZealOS/Demo/Lectures/FixedPoint.html#l1" > < span class = cF4 > fixed-point< / span > < / a > < span class = cF2 > .< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l53" > < / a > < / span > < span class = cF2 > //The main purpose is to set matrix norm for thick scaling.< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l54" > < / a > < / span > < span class = cF2 > //NULL as dc means gr.dc< / span > < span class = cF0 >
< a name = "l55" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (!dc)
< a name = "l56" > < / a > dc = < / span > < span class = cFB > gr< / span > < span class = cF0 > .dc;
< a name = "l57" > < / a > dc-> r = r;
< a name = "l58" > < / a > dc-> r_norm = < / span > < span class = cF5 > Sqrt< / span > < span class = cF0 > (< / span > < span class = cF5 > Mat4x4NormSqr65536< / span > < span class = cF7 > (< / span > < span class = cF0 > r< / span > < span class = cF7 > )< / span > < span class = cF0 > ) * < / span > < span class = cFE > 65536< / span > < span class = cF0 > ; < / span > < span class = cF2 > //scaled 32 bits< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l59" > < / a > }
< a name = "l60" > < / a >
< a name = "l61" > < / a > #< / span > < span class = cF1 > help_index< / span > < span class = cF0 > < / span > < span class = cF6 > " Graphics/Mesh" < / span > < span class = cF0 >
< a name = "l62" > < / a > < / span > < span class = cF1 > public< / span > < span class = cF0 > < / span > < span class = cF1 > U0< / span > < span class = cF0 > < / span > < span class = cF5 > DCLighting< / span > < span class = cF0 > (< / span > < span class = cF9 > CDC< / span > < span class = cF0 > *dc, < / span > < span class = cF9 > CD3I32< / span > < span class = cF0 > *p1, < / span > < span class = cF9 > CD3I32< / span > < span class = cF0 > *p2, < / span > < span class = cF9 > CD3I32< / span > < span class = cF0 > *p3, < / span > < span class = cF9 > CColorROPU32< / span > < span class = cF0 > color)
< a name = "l63" > < / a > {< / span > < span class = cF2 > //This is the default dc-> lighting() callback.< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l64" > < / a > < / span > < span class = cF9 > CD3I32< / span > < span class = cF0 > v1, v2;
< a name = "l65" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > i, vn_x, vn_y, vn_z;
< a name = "l66" > < / a > < / span > < span class = cF1 > F64< / span > < span class = cF0 > d;
2021-07-03 05:07:57 +01:00
< a name = "l67" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l68" > < / a > v1.x = p1-> x - p2-> x;
< a name = "l69" > < / a > v1.y = p1-> y - p2-> y;
< a name = "l70" > < / a > v1.z = p1-> z - p2-> z;
2021-07-03 05:07:57 +01:00
< a name = "l71" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l72" > < / a > v2.x = p3-> x - p2-> x;
< a name = "l73" > < / a > v2.y = p3-> y - p2-> y;
< a name = "l74" > < / a > v2.z = p3-> z - p2-> z;
2021-07-03 05:07:57 +01:00
< a name = "l75" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l76" > < / a > < / span > < span class = cF2 > //V1 and V2 are vects along two sides< / span > < span class = cF0 >
< a name = "l77" > < / a > < / span > < span class = cF2 > //of the tri joined at p2.< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l78" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l79" > < / a > vn_x = v1.y * v2.z - v1.z * v2.y;
< a name = "l80" > < / a > vn_y = v1.z * v2.x - v1.x * v2.z;
< a name = "l81" > < / a > vn_z = v1.x * v2.y - v1.y * v2.x;
< a name = "l82" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (d =< / span > < span class = cF5 > Sqrt< / span > < span class = cF7 > (< / span > < span class = cF5 > SqrI64< / span > < span class = cF0 > (vn_x) + < / span > < span class = cF5 > SqrI64< / span > < span class = cF0 > (vn_y) + < / span > < span class = cF5 > SqrI64< / span > < span class = cF0 > (vn_z)< / span > < span class = cF7 > )< / span > < span class = cF0 > )
< a name = "l83" > < / a > d = < / span > < span class = cFE > 1< / span > < span class = cF0 > < < < / span > < span class = cFE > 16< / span > < span class = cF0 > / d;
< a name = "l84" > < / a > vn_x *= d;
< a name = "l85" > < / a > vn_y *= d;
< a name = "l86" > < / a > vn_z *= d;
2021-07-03 05:07:57 +01:00
< a name = "l87" > < / a > < / span > < span class = cF2 > //Vn is the cross product of V1 and V3< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l88" > < / a > < / span > < span class = cF2 > //which means it is perpendicular. It< / span > < span class = cF0 >
< a name = "l89" > < / a > < / span > < span class = cF2 > //is the normal vect to the surface.< / span > < span class = cF0 >
< a name = "l90" > < / a > < / span > < span class = cF2 > //It has been scaled to length 65536.< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l91" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l92" > < / a > < / span > < span class = cF2 > //Light source has been scaled to length 65536.< / span > < span class = cF0 >
< a name = "l93" > < / a > i = (vn_x * dc-> ls.x + vn_y * dc-> ls.y + vn_z * dc-> ls.z) > > < / span > < span class = cFE > 16< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l94" > < / a > < / span > < span class = cF2 > //The dot product of the light source< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l95" > < / a > < / span > < span class = cF2 > //vect and the surface normal< / span > < span class = cF0 >
< a name = "l96" > < / a > < / span > < span class = cF2 > //gives an illumination number.< / span > < span class = cF0 >
< a name = "l97" > < / a > < / span > < span class = cF2 > //65536*65536> > 16=65536< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l98" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l99" > < / a > < / span > < span class = cF2 > //ZealOS will generate a random U16< / span > < span class = cF0 >
< a name = "l100" > < / a > < / span > < span class = cF2 > //and compare to dither_probability_u16 and< / span > < span class = cF0 >
< a name = "l101" > < / a > < / span > < span class = cF2 > //will pick from two colors.< / span > < span class = cF0 >
< a name = "l102" > < / a > < / span > < span class = cF2 > //Probability dithering does not work with thick> 1 at this time.< / span > < span class = cF0 >
< a name = "l103" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (color.c0.rop & < / span > < span class = cF3 > ROPBF_TWO_SIDED< / span > < span class = cF0 > )
< a name = "l104" > < / a > < / span > < span class = cF7 > {< / span > < span class = cF0 >
< a name = "l105" > < / a > color.c0.rop & = ~< / span > < span class = cF3 > ROPBF_TWO_SIDED< / span > < span class = cF0 > ;
< a name = "l106" > < / a > i = < / span > < span class = cF5 > AbsI64< / span > < span class = cF0 > (i) < < < / span > < span class = cFE > 1< / span > < span class = cF0 > ;
< a name = "l107" > < / a > < / span > < span class = cF7 > }< / span > < span class = cF0 >
< a name = "l108" > < / a > < / span > < span class = cF1 > else< / span > < span class = cF0 >
< a name = "l109" > < / a > i += < / span > < span class = cFE > 65536< / span > < span class = cF0 > ;
< a name = "l110" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (color.c0.rop & < / span > < span class = cF3 > ROPBF_HALF_RANGE_COLOR< / span > < span class = cF0 > )
< a name = "l111" > < / a > < / span > < span class = cF7 > {< / span > < span class = cF0 >
< a name = "l112" > < / a > color.c0.rop & = ~< / span > < span class = cF3 > ROPBF_HALF_RANGE_COLOR< / span > < span class = cF0 > ;
< a name = "l113" > < / a > i > > = < / span > < span class = cFE > 1< / span > < span class = cF0 > ;
< a name = "l114" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (color > = < / span > < span class = cFE > 8< / span > < span class = cF0 > )
< a name = "l115" > < / a > {
< a name = "l116" > < / a > color -= < / span > < span class = cFE > 8< / span > < span class = cF0 > ;
< a name = "l117" > < / a > i += < / span > < span class = cFE > 65536< / span > < span class = cF0 > ;
< a name = "l118" > < / a > }
< a name = "l119" > < / a > < / span > < span class = cF7 > }< / span > < span class = cF0 >
< a name = "l120" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (i < < / span > < span class = cFE > 65536< / span > < span class = cF0 > )
< a name = "l121" > < / a > < / span > < span class = cF7 > {< / span > < span class = cF0 >
< a name = "l122" > < / a > dc-> color = < / span > < span class = cF3 > ROPF_PROBABILITY_DITHER< / span > < span class = cF0 > + color < < < / span > < span class = cFE > 16< / span > < span class = cF0 > + < / span > < span class = cF3 > BLACK< / span > < span class = cF0 > ;
< a name = "l123" > < / a > dc-> dither_probability_u16 = i;
< a name = "l124" > < / a > < / span > < span class = cF7 > }< / span > < span class = cF0 >
< a name = "l125" > < / a > < / span > < span class = cF1 > else< / span > < span class = cF0 >
< a name = "l126" > < / a > < / span > < span class = cF7 > {< / span > < span class = cF0 >
< a name = "l127" > < / a > dc-> color = < / span > < span class = cF3 > ROPF_PROBABILITY_DITHER< / span > < span class = cF0 > + (color ^ < / span > < span class = cFE > 8< / span > < span class = cF0 > ) < < < / span > < span class = cFE > 16< / span > < span class = cF0 > + color;
< a name = "l128" > < / a > dc-> dither_probability_u16 = i - < / span > < span class = cFE > 65536< / span > < span class = cF0 > ;
< a name = "l129" > < / a > < / span > < span class = cF7 > }< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l130" > < / a > }
< a name = "l131" > < / a >
< a name = "l132" > < / a > #< / span > < span class = cF1 > help_index< / span > < span class = cF0 > < / span > < span class = cF6 > " Graphics/Device Contexts" < / span > < span class = cF0 >
< a name = "l133" > < / a > < / span > < span class = cF1 > public< / span > < span class = cF0 > < / span > < span class = cF1 > U0< / span > < span class = cF0 > < / span > < span class = cF5 > DCFill< / span > < span class = cF0 > (< / span > < span class = cF9 > CDC< / span > < span class = cF0 > *dc=< / span > < span class = cF3 > NULL< / span > < span class = cF0 > , < / span > < span class = cF9 > CColorROPU32< / span > < span class = cF0 > val=< / span > < span class = cF3 > TRANSPARENT< / span > < span class = cF0 > )
< a name = "l134" > < / a > {< / span > < span class = cF2 > //Fill entire device context with color.< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l135" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (!dc)
< a name = "l136" > < / a > dc = < / span > < span class = cFB > gr< / span > < span class = cF0 > .dc;
< a name = "l137" > < / a > < / span > < span class = cF5 > MemSet< / span > < span class = cF0 > (dc-> body, val, dc-> width_internal * dc-> height);
2021-07-03 05:07:57 +01:00
< a name = "l138" > < / a > }
< a name = "l139" > < / a >
< a name = "l140" > < / a > < / span > < span class = cF1 > public< / span > < span class = cF0 > < / span > < span class = cF1 > U0< / span > < span class = cF0 > < / span > < span class = cF5 > DCClear< / span > < span class = cF0 > (< / span > < span class = cF9 > CDC< / span > < span class = cF0 > *dc=< / span > < span class = cF3 > NULL< / span > < span class = cF0 > )
< a name = "l141" > < / a > {< / span > < span class = cF2 > //Set entire device context image body to 0 (BLACK).< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l142" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (!dc)
< a name = "l143" > < / a > dc = < / span > < span class = cFB > gr< / span > < span class = cF0 > .dc;
< a name = "l144" > < / a > < / span > < span class = cF5 > DCFill< / span > < span class = cF0 > (dc, < / span > < span class = cFE > 0< / span > < span class = cF0 > );
2021-07-03 05:07:57 +01:00
< a name = "l145" > < / a > }
< a name = "l146" > < / a >
< a name = "l147" > < / a > < / span > < span class = cF1 > public< / span > < span class = cF0 > < / span > < span class = cF1 > U0< / span > < span class = cF0 > < / span > < span class = cF5 > DCReset< / span > < span class = cF0 > (< / span > < span class = cF9 > CDC< / span > < span class = cF0 > *dc)
2021-07-03 07:51:43 +01:00
< a name = "l148" > < / a > {< / span > < span class = cF2 > //Reset < / span > < a href = "https://tomawezome.github.io/ZealOS/Kernel/KernelA.html#l4261" > < span class = cF4 > CDC< / span > < / a > < span class = cF2 > structure members but not image body, itself.< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l149" > < / a > dc-> color = < / span > < span class = cF3 > BLACK< / span > < span class = cF0 > ;
< a name = "l150" > < / a > dc-> color2 = < / span > < span class = cF3 > BLACK< / span > < span class = cF0 > ;
< a name = "l151" > < / a > dc-> bkcolor = < / span > < span class = cF3 > BLACK< / span > < span class = cF0 > ;
< a name = "l152" > < / a > dc-> collision_count = < / span > < span class = cFE > 0< / span > < span class = cF0 > ;
< a name = "l153" > < / a > dc-> thick = < / span > < span class = cFE > 1< / span > < span class = cF0 > ;
< a name = "l154" > < / a > dc-> ls.x = < / span > < span class = cFE > 37837< / span > < span class = cF0 > ; < / span > < span class = cF2 > //1< < 16/Sqrt(3)< / span > < span class = cF0 >
< a name = "l155" > < / a > dc-> ls.y = < / span > < span class = cFE > 37837< / span > < span class = cF0 > ;
< a name = "l156" > < / a > dc-> ls.z = < / span > < span class = cFE > 37837< / span > < span class = cF0 > ;
< a name = "l157" > < / a > dc-> x = < / span > < span class = cFE > 0< / span > < span class = cF0 > ;
< a name = "l158" > < / a > dc-> y = < / span > < span class = cFE > 0< / span > < span class = cF0 > ;
< a name = "l159" > < / a > dc-> z = < / span > < span class = cFE > 0< / span > < span class = cF0 > ;
< a name = "l160" > < / a > dc-> transform = & < / span > < span class = cF5 > DCTransform< / span > < span class = cF0 > ;
< a name = "l161" > < / a > dc-> lighting = & < / span > < span class = cF5 > DCLighting< / span > < span class = cF0 > ;
< a name = "l162" > < / a > < / span > < span class = cF5 > Mat4x4IdentEqu< / span > < span class = cF0 > (dc-> r);
< a name = "l163" > < / a > dc-> r_norm = < / span > < span class = cF3 > GR_SCALE< / span > < span class = cF0 > ;
< a name = "l164" > < / a > dc-> flags & = ~(< / span > < span class = cF3 > DCF_SYMMETRY< / span > < span class = cF0 > | < / span > < span class = cF3 > DCF_TRANSFORMATION< / span > < span class = cF0 > | < / span > < span class = cF3 > DCF_JUST_MIRROR< / span > < span class = cF0 > );
< a name = "l165" > < / a > < / span > < span class = cF5 > MemCopy< / span > < span class = cF0 > (dc-> palette, < / span > < span class = cFB > gr_palette_std< / span > < span class = cF0 > , < / span > < span class = cF1 > sizeof< / span > < span class = cF7 > (< / span > < span class = cF9 > CBGR48< / span > < span class = cF7 > )< / span > < span class = cF0 > * < / span > < span class = cF3 > COLORS_NUM< / span > < span class = cF0 > );
2021-07-03 05:07:57 +01:00
< a name = "l166" > < / a > }
< a name = "l167" > < / a >
< a name = "l168" > < / a > < / span > < span class = cF1 > public< / span > < span class = cF0 > < / span > < span class = cF1 > U0< / span > < span class = cF0 > < / span > < span class = cF5 > DCExtentsInit< / span > < span class = cF0 > (< / span > < span class = cF9 > CDC< / span > < span class = cF0 > *dc=< / span > < span class = cF3 > NULL< / span > < span class = cF0 > )
< a name = "l169" > < / a > {< / span > < span class = cF2 > //Init markers for extent of next newly drawn graphics.< / span > < span class = cF0 >
< a name = "l170" > < / a > < / span > < span class = cF2 > //NULL means gr.dc< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l171" > < / a > < / span > < span class = cF2 > //See < / span > < a href = "https://tomawezome.github.io/ZealOS/Demo/Graphics/Extents.html#l1" > < span class = cF4 > ::/Demo/Graphics/Extents.CC< / span > < / a > < span class = cF0 >
< a name = "l172" > < / a > < / span > < span class = cF2 > //You should clear the record flag yourself< / span > < span class = cF0 >
< a name = "l173" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (!dc)
< a name = "l174" > < / a > dc = < / span > < span class = cFB > gr< / span > < span class = cF0 > .dc;
< a name = "l175" > < / a > dc-> flags |= < / span > < span class = cF3 > DCF_RECORD_EXTENTS< / span > < span class = cF0 > ;
< a name = "l176" > < / a > dc-> min_x = < / span > < span class = cF3 > I64_MAX< / span > < span class = cF0 > ;
< a name = "l177" > < / a > dc-> max_x = < / span > < span class = cF3 > I64_MIN< / span > < span class = cF0 > ;
< a name = "l178" > < / a > dc-> min_y = < / span > < span class = cF3 > I64_MAX< / span > < span class = cF0 > ;
< a name = "l179" > < / a > dc-> max_y = < / span > < span class = cF3 > I64_MIN< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l180" > < / a > }
< a name = "l181" > < / a >
< a name = "l182" > < / a > < / span > < span class = cF1 > public< / span > < span class = cF0 > < / span > < span class = cF9 > CDC< / span > < span class = cF0 > *< / span > < span class = cF5 > DCAlias< / span > < span class = cF0 > (< / span > < span class = cF9 > CDC< / span > < span class = cF0 > *dc=< / span > < span class = cF3 > NULL< / span > < span class = cF0 > , < / span > < span class = cF9 > CTask< / span > < span class = cF0 > *task=< / span > < span class = cF3 > NULL< / span > < span class = cF0 > )
< a name = "l183" > < / a > {< / span > < span class = cF2 > //Create alias of dc, so can change pen, color, etc.< / span > < span class = cF0 >
< a name = "l184" > < / a > < / span > < span class = cF2 > //NULL means gr.dc< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l185" > < / a > < / span > < span class = cF9 > CDC< / span > < span class = cF0 > *res;
2021-07-03 05:07:57 +01:00
< a name = "l186" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l187" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (!dc)
< a name = "l188" > < / a > dc = < / span > < span class = cFB > gr< / span > < span class = cF0 > .dc;
< a name = "l189" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (!task)
< a name = "l190" > < / a > task = < / span > < span class = cF5 > Fs< / span > < span class = cF0 > ;
< a name = "l191" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (dc-> dc_signature != < / span > < span class = cF3 > DCS_SIGNATURE_VAL< / span > < span class = cF0 > )
< a name = "l192" > < / a > < / span > < span class = cF5 > throw< / span > < span class = cF0 > (< / span > < span class = cF6 > 'Graphics'< / span > < span class = cF0 > );
2021-07-03 05:07:57 +01:00
< a name = "l193" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l194" > < / a > res = < / span > < span class = cF5 > MAlloc< / span > < span class = cF0 > (< / span > < span class = cF1 > sizeof< / span > < span class = cF7 > (< / span > < span class = cF9 > CDC< / span > < span class = cF7 > )< / span > < span class = cF0 > , task);
< a name = "l195" > < / a > < / span > < span class = cF5 > MemCopy< / span > < span class = cF0 > (res, dc, < / span > < span class = cF1 > sizeof< / span > < span class = cF7 > (< / span > < span class = cF9 > CDC< / span > < span class = cF7 > )< / span > < span class = cF0 > );
< a name = "l196" > < / a > res-> win_task = res-> mem_task = task;
< a name = "l197" > < / a > res-> r = < / span > < span class = cF5 > MAlloc< / span > < span class = cF0 > (< / span > < span class = cFE > 16< / span > < span class = cF0 > * < / span > < span class = cF1 > sizeof< / span > < span class = cF7 > (< / span > < span class = cF9 > I64< / span > < span class = cF7 > )< / span > < span class = cF0 > , task);
< a name = "l198" > < / a > < / span > < span class = cF5 > DCReset< / span > < span class = cF0 > (res);
< a name = "l199" > < / a > res-> flags |= < / span > < span class = cF3 > DCF_ALIAS< / span > < span class = cF0 > ;
< a name = "l200" > < / a > res-> alias = dc;
2021-07-03 05:07:57 +01:00
< a name = "l201" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l202" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > res;
2021-07-03 05:07:57 +01:00
< a name = "l203" > < / a > }
< a name = "l204" > < / a >
< a name = "l205" > < / a > < / span > < span class = cF1 > public< / span > < span class = cF0 > < / span > < span class = cF9 > CDC< / span > < span class = cF0 > *< / span > < span class = cF5 > DCNew< / span > < span class = cF0 > (< / span > < span class = cF9 > I64< / span > < span class = cF0 > width, < / span > < span class = cF9 > I64< / span > < span class = cF0 > height, < / span > < span class = cF9 > CTask< / span > < span class = cF0 > *task=< / span > < span class = cF3 > NULL< / span > < span class = cF0 > , < / span > < span class = cF1 > Bool< / span > < span class = cF0 > null_bitmap=< / span > < span class = cF3 > FALSE< / span > < span class = cF0 > )
< a name = "l206" > < / a > {< / span > < span class = cF2 > //Create new width x height device context.< / span > < span class = cF0 >
< a name = "l207" > < / a > < / span > < span class = cF2 > //Internally only allows widths which are divisible by 8.< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l208" > < / a > < / span > < span class = cF2 > //Don't forget these < / span > < span class = cF9 > < u > sizeof(CDC)< / u > < / span > < span class = cF2 > .< / span > < span class = cF0 >
< a name = "l209" > < / a > < / span > < span class = cF9 > CDC< / span > < span class = cF0 > *res;
2021-07-03 05:07:57 +01:00
< a name = "l210" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l211" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (!task)
< a name = "l212" > < / a > task = < / span > < span class = cF5 > Fs< / span > < span class = cF0 > ;
< a name = "l213" > < / a > res=< / span > < span class = cF5 > CAlloc< / span > < span class = cF0 > (< / span > < span class = cF1 > sizeof< / span > < span class = cF7 > (< / span > < span class = cF9 > CDC< / span > < span class = cF7 > )< / span > < span class = cF0 > , task);
< a name = "l214" > < / a > res-> win_task = task;
< a name = "l215" > < / a > res-> mem_task = task;
< a name = "l216" > < / a > res-> width = width;
< a name = "l217" > < / a > res-> width_internal = (width + < / span > < span class = cFE > 7< / span > < span class = cF0 > ) & ~< / span > < span class = cFE > 7< / span > < span class = cF0 > ;
< a name = "l218" > < / a > res-> height = height;
< a name = "l219" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (null_bitmap)
< a name = "l220" > < / a > res-> flags |= < / span > < span class = cF3 > DCF_DONT_DRAW< / span > < span class = cF0 > ;
< a name = "l221" > < / a > < / span > < span class = cF1 > else< / span > < span class = cF0 >
< a name = "l222" > < / a > res-> body = < / span > < span class = cF5 > CAlloc< / span > < span class = cF0 > (res-> width_internal * res-> height, task);
< a name = "l223" > < / a > res-> r = < / span > < span class = cF5 > MAlloc< / span > < span class = cF0 > (< / span > < span class = cFE > 16< / span > < span class = cF0 > * < / span > < span class = cF1 > sizeof< / span > < span class = cF7 > (< / span > < span class = cF9 > I64< / span > < span class = cF7 > )< / span > < span class = cF0 > , task);
< a name = "l224" > < / a > < / span > < span class = cF5 > DCReset< / span > < span class = cF0 > (res);
< a name = "l225" > < / a > res-> dc_signature = < / span > < span class = cF3 > DCS_SIGNATURE_VAL< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l226" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l227" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > res;
2021-07-03 05:07:57 +01:00
< a name = "l228" > < / a > }
< a name = "l229" > < / a >
< a name = "l230" > < / a > < / span > < span class = cF1 > public< / span > < span class = cF0 > < / span > < span class = cF1 > U0< / span > < span class = cF0 > < / span > < span class = cF5 > DCDel< / span > < span class = cF0 > (< / span > < span class = cF9 > CDC< / span > < span class = cF0 > *dc)
< a name = "l231" > < / a > {< / span > < span class = cF2 > //Free dc, image body, rot mat and depth buf.< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l232" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (!dc)
< a name = "l233" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > ;
< a name = "l234" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (dc-> dc_signature != < / span > < span class = cF3 > DCS_SIGNATURE_VAL< / span > < span class = cF0 > )
< a name = "l235" > < / a > < / span > < span class = cF5 > throw< / span > < span class = cF0 > (< / span > < span class = cF6 > 'Graphics'< / span > < span class = cF0 > );
< a name = "l236" > < / a > dc-> dc_signature = < / span > < span class = cFE > 0< / span > < span class = cF0 > ;
< a name = "l237" > < / a > < / span > < span class = cF5 > Free< / span > < span class = cF0 > (dc-> r);
< a name = "l238" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (!< / span > < span class = cF7 > (< / span > < span class = cF0 > dc-> flags & < / span > < span class = cF3 > DCF_ALIAS< / span > < span class = cF7 > )< / span > < span class = cF0 > )
< a name = "l239" > < / a > < / span > < span class = cF5 > Free< / span > < span class = cF0 > (dc-> body);
< a name = "l240" > < / a > < / span > < span class = cF5 > Free< / span > < span class = cF0 > (dc-> depth_buf);
< a name = "l241" > < / a > < / span > < span class = cF5 > Free< / span > < span class = cF0 > (dc);
2021-07-03 05:07:57 +01:00
< a name = "l242" > < / a > }
< a name = "l243" > < / a >
< a name = "l244" > < / a > < / span > < span class = cF1 > public< / span > < span class = cF0 > < / span > < span class = cF9 > I64< / span > < span class = cF0 > < / span > < span class = cF5 > DCSize< / span > < span class = cF0 > (< / span > < span class = cF9 > CDC< / span > < span class = cF0 > *dc)
< a name = "l245" > < / a > {< / span > < span class = cF2 > //Mem size of header, image body and depth buffer.< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l246" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (dc)
< a name = "l247" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > < / span > < span class = cF5 > MSize2< / span > < span class = cF0 > (dc) + < / span > < span class = cF5 > MSize2< / span > < span class = cF0 > (dc-> body) + < / span > < span class = cF5 > MSize2< / span > < span class = cF0 > (dc-> depth_buf);
< a name = "l248" > < / a > < / span > < span class = cF1 > else< / span > < span class = cF0 >
< a name = "l249" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > < / span > < span class = cFE > 0< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l250" > < / a > }
< a name = "l251" > < / a >
< a name = "l252" > < / a > < / span > < span class = cF1 > public< / span > < span class = cF0 > < / span > < span class = cF9 > I32< / span > < span class = cF0 > *< / span > < span class = cF5 > DCDepthBufReset< / span > < span class = cF0 > (< / span > < span class = cF9 > CDC< / span > < span class = cF0 > *dc)
< a name = "l253" > < / a > {< / span > < span class = cF2 > //Reset device context depth buf to far away.< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l254" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (dc-> depth_buf)
< a name = "l255" > < / a > < / span > < span class = cF5 > MemSetU32< / span > < span class = cF0 > (dc-> depth_buf, < / span > < span class = cF3 > I32_MAX< / span > < span class = cF0 > , dc-> width_internal * dc-> height);
2021-07-03 05:07:57 +01:00
< a name = "l256" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l257" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > dc-> depth_buf;
2021-07-03 05:07:57 +01:00
< a name = "l258" > < / a > }
< a name = "l259" > < / a >
< a name = "l260" > < / a > < / span > < span class = cF1 > public< / span > < span class = cF0 > < / span > < span class = cF9 > I32< / span > < span class = cF0 > *< / span > < span class = cF5 > DCDepthBufAlloc< / span > < span class = cF0 > (< / span > < span class = cF9 > CDC< / span > < span class = cF0 > *dc)
< a name = "l261" > < / a > {< / span > < span class = cF2 > //Alloc a 32-bit depth buffer for device context.< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l262" > < / a > < / span > < span class = cF5 > Free< / span > < span class = cF0 > (dc-> depth_buf);
< a name = "l263" > < / a > dc-> depth_buf = < / span > < span class = cF5 > MAlloc< / span > < span class = cF0 > (dc-> width_internal * dc-> height * < / span > < span class = cF1 > sizeof< / span > < span class = cF7 > (< / span > < span class = cF9 > I32< / span > < span class = cF7 > )< / span > < span class = cF0 > , dc-> mem_task);
2021-07-03 05:07:57 +01:00
< a name = "l264" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l265" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > < / span > < span class = cF5 > DCDepthBufReset< / span > < span class = cF0 > (dc);
2021-07-03 05:07:57 +01:00
< a name = "l266" > < / a > }
< a name = "l267" > < / a >
< a name = "l268" > < / a > < / span > < span class = cF1 > public< / span > < span class = cF0 > < / span > < span class = cF9 > CDC< / span > < span class = cF0 > *< / span > < span class = cF5 > DCCopy< / span > < span class = cF0 > (< / span > < span class = cF9 > CDC< / span > < span class = cF0 > *dc, < / span > < span class = cF9 > CTask< / span > < span class = cF0 > *task=< / span > < span class = cF3 > NULL< / span > < span class = cF0 > )
< a name = "l269" > < / a > {< / span > < span class = cF2 > //Alloc copy of dc, including image body, rot mat and depth buf.< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l270" > < / a > < / span > < span class = cF9 > CDC< / span > < span class = cF0 > *res;
2021-07-03 05:07:57 +01:00
< a name = "l271" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l272" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (!dc)
< a name = "l273" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > < / span > < span class = cF3 > NULL< / span > < span class = cF0 > ;
< a name = "l274" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (dc-> dc_signature != < / span > < span class = cF3 > DCS_SIGNATURE_VAL< / span > < span class = cF0 > )
< a name = "l275" > < / a > < / span > < span class = cF5 > throw< / span > < span class = cF0 > (< / span > < span class = cF6 > 'Graphics'< / span > < span class = cF0 > );
< a name = "l276" > < / a > res = < / span > < span class = cF5 > MAllocIdent< / span > < span class = cF0 > (dc, task);
< a name = "l277" > < / a > < / span > < span class = cF5 > DCMat4x4Set< / span > < span class = cF0 > (res, < / span > < span class = cF5 > Mat4x4New< / span > < span class = cF7 > (< / span > < span class = cF0 > dc-> r, task< / span > < span class = cF7 > )< / span > < span class = cF0 > );
< a name = "l278" > < / a > res-> mem_task = task;
< a name = "l279" > < / a > res-> body = < / span > < span class = cF5 > MAllocIdent< / span > < span class = cF0 > (dc-> body, task);
< a name = "l280" > < / a > res-> depth_buf = < / span > < span class = cF5 > MAllocIdent< / span > < span class = cF0 > (dc-> depth_buf, task);
2021-07-03 05:07:57 +01:00
< a name = "l281" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l282" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > res;
2021-07-03 05:07:57 +01:00
< a name = "l283" > < / a > }
< a name = "l284" > < / a >
< a name = "l285" > < / a > < / span > < span class = cF1 > public< / span > < span class = cF0 > < / span > < span class = cF1 > U0< / span > < span class = cF0 > < / span > < span class = cF5 > DCMono< / span > < span class = cF0 > (< / span > < span class = cF9 > CDC< / span > < span class = cF0 > *dc, < / span > < span class = cF9 > I64< / span > < span class = cF0 > quest=< / span > < span class = cF3 > TRANSPARENT< / span > < span class = cF0 > , < / span > < span class = cF9 > I64< / span > < span class = cF0 > true_color=< / span > < span class = cFE > 0< / span > < span class = cF0 > , < / span > < span class = cF9 > I64< / span > < span class = cF0 > false_color=< / span > < span class = cF3 > COLOR_MONO< / span > < span class = cF0 > )
< a name = "l286" > < / a > {< / span > < span class = cF2 > //Set entire device context to one of two colors.< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l287" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > i;
< a name = "l288" > < / a > < / span > < span class = cF1 > U8< / span > < span class = cF0 > *dst;
2021-07-03 05:07:57 +01:00
< a name = "l289" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l290" > < / a > dst = dc-> body;
< a name = "l291" > < / a > i = dc-> width_internal * dc-> height;
< a name = "l292" > < / a > < / span > < span class = cF1 > while< / span > < span class = cF0 > (i--)
< a name = "l293" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (*dst == quest)
< a name = "l294" > < / a > *dst++ = true_color;
< a name = "l295" > < / a > < / span > < span class = cF1 > else< / span > < span class = cF0 >
< a name = "l296" > < / a > *dst++ = false_color;
2021-07-03 05:07:57 +01:00
< a name = "l297" > < / a > }
< a name = "l298" > < / a >
< a name = "l299" > < / a > < / span > < span class = cF1 > public< / span > < span class = cF0 > < / span > < span class = cF9 > I64< / span > < span class = cF0 > < / span > < span class = cF5 > DCColorChange< / span > < span class = cF0 > (< / span > < span class = cF9 > CDC< / span > < span class = cF0 > *dc, < / span > < span class = cF9 > I64< / span > < span class = cF0 > src_color, < / span > < span class = cF9 > I64< / span > < span class = cF0 > dst_color=< / span > < span class = cF3 > TRANSPARENT< / span > < span class = cF0 > )
< a name = "l300" > < / a > {< / span > < span class = cF2 > //Find and replace src color with dst in device context.< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l301" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > i, res = < / span > < span class = cFE > 0< / span > < span class = cF0 > ;
< a name = "l302" > < / a > < / span > < span class = cF1 > U8< / span > < span class = cF0 > *dst;
2021-07-03 05:07:57 +01:00
< a name = "l303" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l304" > < / a > dst = dc-> body;
< a name = "l305" > < / a > i = dc-> width_internal * dc-> height;
< a name = "l306" > < / a > < / span > < span class = cF1 > while< / span > < span class = cF0 > (i--)
< a name = "l307" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (*dst == src_color)
< a name = "l308" > < / a > < / span > < span class = cF7 > {< / span > < span class = cF0 >
< a name = "l309" > < / a > *dst++ = dst_color;
< a name = "l310" > < / a > res++;
< a name = "l311" > < / a > < / span > < span class = cF7 > }< / span > < span class = cF0 >
< a name = "l312" > < / a > < / span > < span class = cF1 > else< / span > < span class = cF0 >
< a name = "l313" > < / a > dst++;
2021-07-03 05:07:57 +01:00
< a name = "l314" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l315" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > res;
2021-07-03 05:07:57 +01:00
< a name = "l316" > < / a > }
< a name = "l317" > < / a >
< a name = "l318" > < / a > < / span > < span class = cF1 > public< / span > < span class = cF0 > < / span > < span class = cF1 > U8< / span > < span class = cF0 > *< / span > < span class = cF5 > DCSave< / span > < span class = cF0 > (< / span > < span class = cF9 > CDC< / span > < span class = cF0 > *dc, < / span > < span class = cF9 > I64< / span > < span class = cF0 > *_size=< / span > < span class = cF3 > NULL< / span > < span class = cF0 > , < / span > < span class = cF9 > I64< / span > < span class = cF0 > dcsf_flags=< / span > < span class = cF3 > NONE< / span > < span class = cF0 > )
< a name = "l319" > < / a > {< / span > < span class = cF2 > //Stores device context to mem, perhaps, with compression.< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l320" > < / a > < / span > < span class = cF1 > U8< / span > < span class = cF0 > *res, *ptr, *body;
< a name = "l321" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > body_size = dc-> width_internal * dc-> height, total_size, flags;
< a name = "l322" > < / a > < / span > < span class = cF9 > CBGR48< / span > < span class = cF0 > palette[< / span > < span class = cF3 > COLORS_NUM< / span > < span class = cF0 > ];
2021-07-03 05:07:57 +01:00
< a name = "l323" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l324" > < / a > body = dc-> body;
2021-07-03 05:07:57 +01:00
< a name = "l325" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l326" > < / a > total_size = < / span > < span class = cF1 > offset< / span > < span class = cF0 > (< / span > < span class = cF9 > CDC< / span > < span class = cF0 > .< / span > < span class = cF1 > end< / span > < span class = cF0 > ) - < / span > < span class = cF1 > offset< / span > < span class = cF0 > (< / span > < span class = cF9 > CDC< / span > < span class = cF0 > .< / span > < span class = cF1 > start< / span > < span class = cF0 > ) + body_size;
< a name = "l327" > < / a > flags = < / span > < span class = cFE > 0< / span > < span class = cF0 > ;
2021-07-03 05:07:57 +01:00
< a name = "l328" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l329" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (dcsf_flags & < / span > < span class = cF3 > DCSF_PALETTE_GET< / span > < span class = cF0 > )
< a name = "l330" > < / a > < / span > < span class = cF5 > GrPaletteGet< / span > < span class = cF0 > (palette);
< a name = "l331" > < / a > < / span > < span class = cF1 > else< / span > < span class = cF0 >
< a name = "l332" > < / a > < / span > < span class = cF5 > MemCopy< / span > < span class = cF0 > (palette, & dc-> palette, < / span > < span class = cF3 > COLORS_NUM< / span > < span class = cF0 > * < / span > < span class = cF1 > sizeof< / span > < span class = cF7 > (< / span > < span class = cF9 > CBGR48< / span > < span class = cF7 > )< / span > < span class = cF0 > );
< a name = "l333" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (< / span > < span class = cF5 > MemCompare< / span > < span class = cF7 > (< / span > < span class = cF0 > palette, < / span > < span class = cFB > gr_palette_std< / span > < span class = cF0 > , < / span > < span class = cF3 > COLORS_NUM< / span > < span class = cF0 > * < / span > < span class = cF1 > sizeof< / span > < span class = cF0 > (< / span > < span class = cF9 > CBGR48< / span > < span class = cF0 > )< / span > < span class = cF7 > )< / span > < span class = cF0 > )
< a name = "l334" > < / a > < / span > < span class = cF7 > {< / span > < span class = cF0 >
< a name = "l335" > < / a > flags |= < / span > < span class = cF3 > DCF_PALETTE< / span > < span class = cF0 > ;
< a name = "l336" > < / a > total_size += < / span > < span class = cF3 > COLORS_NUM< / span > < span class = cF0 > * < / span > < span class = cF1 > sizeof< / span > < span class = cF0 > (< / span > < span class = cF9 > CBGR48< / span > < span class = cF0 > );
< a name = "l337" > < / a > < / span > < span class = cF7 > }< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l338" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l339" > < / a > ptr = res = < / span > < span class = cF5 > MAlloc< / span > < span class = cF0 > (total_size);
2021-07-03 05:07:57 +01:00
< a name = "l340" > < / a >
< a name = "l341" > < / a > #< / span > < span class = cF1 > assert< / span > < span class = cF0 > !< / span > < span class = cF1 > offset< / span > < span class = cF0 > (< / span > < span class = cF9 > CDC< / span > < span class = cF0 > .< / span > < span class = cF1 > start< / span > < span class = cF0 > )
2021-07-04 23:11:34 +01:00
< a name = "l342" > < / a > < / span > < span class = cF5 > MemCopy< / span > < span class = cF0 > (ptr, & dc-> < / span > < span class = cF1 > start< / span > < span class = cF0 > , < / span > < span class = cF1 > offset< / span > < span class = cF7 > (< / span > < span class = cF9 > CDC< / span > < span class = cF0 > .< / span > < span class = cF1 > end< / span > < span class = cF7 > )< / span > < span class = cF0 > - < / span > < span class = cF1 > offset< / span > < span class = cF7 > (< / span > < span class = cF9 > CDC< / span > < span class = cF0 > .< / span > < span class = cF1 > start< / span > < span class = cF7 > )< / span > < span class = cF0 > );
< a name = "l343" > < / a > ptr(< / span > < span class = cF9 > CDC< / span > < span class = cF0 > *)-> flags = flags;
< a name = "l344" > < / a > ptr += < / span > < span class = cF1 > offset< / span > < span class = cF0 > (< / span > < span class = cF9 > CDC< / span > < span class = cF0 > .< / span > < span class = cF1 > end< / span > < span class = cF0 > ) - < / span > < span class = cF1 > offset< / span > < span class = cF0 > (< / span > < span class = cF9 > CDC< / span > < span class = cF0 > .< / span > < span class = cF1 > start< / span > < span class = cF0 > );
2021-07-03 05:07:57 +01:00
< a name = "l345" > < / a >
< a name = "l346" > < / a > #< / span > < span class = cF1 > assert< / span > < span class = cF0 > < / span > < span class = cF1 > offset< / span > < span class = cF0 > (< / span > < span class = cF9 > CDC< / span > < span class = cF0 > .< / span > < span class = cF1 > end< / span > < span class = cF0 > ) == < / span > < span class = cF1 > offset< / span > < span class = cF0 > (< / span > < span class = cF9 > CDC< / span > < span class = cF0 > .palette)
2021-07-04 23:11:34 +01:00
< a name = "l347" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (flags & < / span > < span class = cF3 > DCF_PALETTE< / span > < span class = cF0 > )
< a name = "l348" > < / a > < / span > < span class = cF7 > {< / span > < span class = cF0 >
< a name = "l349" > < / a > < / span > < span class = cF5 > MemCopy< / span > < span class = cF0 > (ptr, palette, < / span > < span class = cF3 > COLORS_NUM< / span > < span class = cF0 > * < / span > < span class = cF1 > sizeof< / span > < span class = cF7 > (< / span > < span class = cF9 > CBGR48< / span > < span class = cF7 > )< / span > < span class = cF0 > );
< a name = "l350" > < / a > ptr += < / span > < span class = cF3 > COLORS_NUM< / span > < span class = cF0 > * < / span > < span class = cF1 > sizeof< / span > < span class = cF0 > (< / span > < span class = cF9 > CBGR48< / span > < span class = cF0 > );
< a name = "l351" > < / a > < / span > < span class = cF7 > }< / span > < span class = cF0 >
2021-07-03 05:07:57 +01:00
< a name = "l352" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l353" > < / a > < / span > < span class = cF5 > MemCopy< / span > < span class = cF0 > (ptr, body, body_size);
< a name = "l354" > < / a > ptr += body_size;
2021-07-03 05:07:57 +01:00
< a name = "l355" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l356" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (_size)
< a name = "l357" > < / a > *_size = total_size;
2021-07-03 05:07:57 +01:00
< a name = "l358" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l359" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > res;
2021-07-03 05:07:57 +01:00
< a name = "l360" > < / a > }
< a name = "l361" > < / a >
< a name = "l362" > < / a > < / span > < span class = cF1 > public< / span > < span class = cF0 > < / span > < span class = cF9 > CDC< / span > < span class = cF0 > *< / span > < span class = cF5 > DCLoad< / span > < span class = cF0 > (< / span > < span class = cF1 > U8< / span > < span class = cF0 > *src, < / span > < span class = cF9 > I64< / span > < span class = cF0 > *_size=< / span > < span class = cF3 > NULL< / span > < span class = cF0 > , < / span > < span class = cF9 > CTask< / span > < span class = cF0 > *task=< / span > < span class = cF3 > NULL< / span > < span class = cF0 > )
< a name = "l363" > < / a > {< / span > < span class = cF2 > //Loads device context from mem.< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l364" > < / a > < / span > < span class = cF9 > CDC< / span > < span class = cF0 > *res;
< a name = "l365" > < / a > < / span > < span class = cF1 > U8< / span > < span class = cF0 > *ptr = src;
< a name = "l366" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > body_size;
2021-07-03 05:07:57 +01:00
< a name = "l367" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l368" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (!task)
< a name = "l369" > < / a > task = < / span > < span class = cF5 > Fs< / span > < span class = cF0 > ;
< a name = "l370" > < / a > res = < / span > < span class = cF5 > CAlloc< / span > < span class = cF0 > (< / span > < span class = cF1 > sizeof< / span > < span class = cF7 > (< / span > < span class = cF9 > CDC< / span > < span class = cF7 > )< / span > < span class = cF0 > , task);
< a name = "l371" > < / a > res-> win_task = task;
< a name = "l372" > < / a > res-> mem_task = task;
< a name = "l373" > < / a > < / span > < span class = cF5 > MemCopy< / span > < span class = cF0 > (& res-> < / span > < span class = cF1 > start< / span > < span class = cF0 > , ptr, < / span > < span class = cF1 > offset< / span > < span class = cF7 > (< / span > < span class = cF9 > CDC< / span > < span class = cF0 > .< / span > < span class = cF1 > end< / span > < span class = cF7 > )< / span > < span class = cF0 > - < / span > < span class = cF1 > offset< / span > < span class = cF7 > (< / span > < span class = cF9 > CDC< / span > < span class = cF0 > .< / span > < span class = cF1 > start< / span > < span class = cF7 > )< / span > < span class = cF0 > );
< a name = "l374" > < / a > ptr += < / span > < span class = cF1 > offset< / span > < span class = cF0 > (< / span > < span class = cF9 > CDC< / span > < span class = cF0 > .< / span > < span class = cF1 > end< / span > < span class = cF0 > ) - < / span > < span class = cF1 > offset< / span > < span class = cF0 > (< / span > < span class = cF9 > CDC< / span > < span class = cF0 > .< / span > < span class = cF1 > start< / span > < span class = cF0 > );
2021-07-03 05:07:57 +01:00
< a name = "l375" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l376" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (res-> flags & < / span > < span class = cF3 > DCF_PALETTE< / span > < span class = cF0 > )
< a name = "l377" > < / a > < / span > < span class = cF7 > {< / span > < span class = cF0 >
< a name = "l378" > < / a > < / span > < span class = cF5 > MemCopy< / span > < span class = cF0 > (& res-> palette, ptr, < / span > < span class = cF3 > COLORS_NUM< / span > < span class = cF0 > * < / span > < span class = cF1 > sizeof< / span > < span class = cF7 > (< / span > < span class = cF9 > CBGR48< / span > < span class = cF7 > )< / span > < span class = cF0 > );
< a name = "l379" > < / a > ptr += < / span > < span class = cF3 > COLORS_NUM< / span > < span class = cF0 > * < / span > < span class = cF1 > sizeof< / span > < span class = cF0 > (< / span > < span class = cF9 > CBGR48< / span > < span class = cF0 > );
< a name = "l380" > < / a > < / span > < span class = cF7 > }< / span > < span class = cF0 >
< a name = "l381" > < / a > < / span > < span class = cF1 > else< / span > < span class = cF0 >
< a name = "l382" > < / a > < / span > < span class = cF5 > MemCopy< / span > < span class = cF0 > (& res-> palette, < / span > < span class = cFB > gr_palette_std< / span > < span class = cF0 > , < / span > < span class = cF3 > COLORS_NUM< / span > < span class = cF0 > * < / span > < span class = cF1 > sizeof< / span > < span class = cF7 > (< / span > < span class = cF9 > CBGR48< / span > < span class = cF7 > )< / span > < span class = cF0 > );
2021-07-03 05:07:57 +01:00
< a name = "l383" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l384" > < / a > body_size = res-> width_internal * res-> height;
< a name = "l385" > < / a > res-> body = < / span > < span class = cF5 > MAlloc< / span > < span class = cF0 > (body_size, task);
< a name = "l386" > < / a > < / span > < span class = cF5 > MemCopy< / span > < span class = cF0 > (res-> body, ptr, body_size);
< a name = "l387" > < / a > ptr += body_size;
< a name = "l388" > < / a > res-> thick = < / span > < span class = cFE > 1< / span > < span class = cF0 > ;
< a name = "l389" > < / a > res-> r = < / span > < span class = cF5 > Mat4x4IdentNew< / span > < span class = cF0 > (task);
< a name = "l390" > < / a > res-> r_norm.u32[< / span > < span class = cFE > 1< / span > < span class = cF0 > ] = < / span > < span class = cFE > 1< / span > < span class = cF0 > ;
< a name = "l391" > < / a > res-> dc_signature = < / span > < span class = cF3 > DCS_SIGNATURE_VAL< / span > < span class = cF0 > ;
< a name = "l392" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (_size)
< a name = "l393" > < / a > *_size = ptr - src;
2021-07-03 05:07:57 +01:00
< a name = "l394" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l395" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > res;
2021-07-03 05:07:57 +01:00
< a name = "l396" > < / a > }
< a name = "l397" > < / a >
< a name = "l398" > < / a > #< / span > < span class = cF1 > help_index< / span > < span class = cF0 > < / span > < span class = cF6 > " Graphics/GR Files" < / span > < span class = cF0 >
< a name = "l399" > < / a > #< / span > < span class = cF1 > help_file< / span > < span class = cF0 > < / span > < span class = cF6 > " ::/Doc/GRFiles" < / span > < span class = cF0 >
< a name = "l400" > < / a > #< / span > < span class = cF1 > help_index< / span > < span class = cF0 > < / span > < span class = cF6 > " Graphics/Device Contexts;Graphics/GR Files" < / span > < span class = cF0 >
< a name = "l401" > < / a >
< a name = "l402" > < / a > #< / span > < span class = cF1 > define< / span > < span class = cF0 > < / span > < span class = cF3 > GR_FILE_MAX< / span > < span class = cF0 > (< / span > < span class = cF1 > offset< / span > < span class = cF7 > (< / span > < span class = cF9 > CDC< / span > < span class = cF0 > .< / span > < span class = cF1 > end< / span > < span class = cF7 > )< / span > < span class = cF0 > - < / span > < span class = cF1 > offset< / span > < span class = cF7 > (< / span > < span class = cF9 > CDC< / span > < span class = cF0 > .< / span > < span class = cF1 > start< / span > < span class = cF7 > )< / span > < span class = cF0 > + < / span > < span class = cF3 > COLORS_NUM< / span > < span class = cF0 > * < / span > < span class = cF1 > sizeof< / span > < span class = cF7 > (< / span > < span class = cF9 > CBGR48< / span > < span class = cF7 > )< / span > < span class = cF0 > + < / span > < span class = cF3 > GR_WIDTH< / span > < span class = cF0 > * < / span > < span class = cF3 > GR_HEIGHT< / span > < span class = cF0 > )
< a name = "l403" > < / a >
< a name = "l404" > < / a > < / span > < span class = cF1 > public< / span > < span class = cF0 > < / span > < span class = cF9 > I64< / span > < span class = cF0 > < / span > < span class = cF5 > GRWrite< / span > < span class = cF0 > (< / span > < span class = cF1 > U8< / span > < span class = cF0 > *filename, < / span > < span class = cF9 > CDC< / span > < span class = cF0 > *dc, < / span > < span class = cF9 > I64< / span > < span class = cF0 > dcsf_flags=< / span > < span class = cF3 > NONE< / span > < span class = cF0 > )
< a name = "l405" > < / a > {< / span > < span class = cF2 > //ZealOS GR File.< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l406" > < / a > < / span > < span class = cF9 > I64< / span > < span class = cF0 > size;
< a name = "l407" > < / a > < / span > < span class = cF1 > U8< / span > < span class = cF0 > *st = < / span > < span class = cF5 > ExtDefault< / span > < span class = cF0 > (filename, < / span > < span class = cF6 > " GR" < / span > < span class = cF0 > ), *src = < / span > < span class = cF5 > DCSave< / span > < span class = cF0 > (dc, & size, dcsf_flags);
< a name = "l408" > < / a > < / span > < span class = cF5 > FileWrite< / span > < span class = cF0 > (st, src, size);
< a name = "l409" > < / a > < / span > < span class = cF5 > Free< / span > < span class = cF0 > (st);
< a name = "l410" > < / a > < / span > < span class = cF5 > Free< / span > < span class = cF0 > (src);
2021-07-03 05:07:57 +01:00
< a name = "l411" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l412" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > size;
2021-07-03 05:07:57 +01:00
< a name = "l413" > < / a > }
< a name = "l414" > < / a >
< a name = "l415" > < / a > < / span > < span class = cF1 > public< / span > < span class = cF0 > < / span > < span class = cF9 > CDC< / span > < span class = cF0 > *< / span > < span class = cF5 > GRRead< / span > < span class = cF0 > (< / span > < span class = cF1 > U8< / span > < span class = cF0 > *filename, < / span > < span class = cF9 > CTask< / span > < span class = cF0 > *task=< / span > < span class = cF3 > NULL< / span > < span class = cF0 > )
< a name = "l416" > < / a > {< / span > < span class = cF2 > //ZealOS GR File.< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l417" > < / a > < / span > < span class = cF9 > CDC< / span > < span class = cF0 > *dc = < / span > < span class = cF3 > NULL< / span > < span class = cF0 > ;
< a name = "l418" > < / a > < / span > < span class = cF1 > U8< / span > < span class = cF0 > *st = < / span > < span class = cF5 > ExtDefault< / span > < span class = cF0 > (filename, < / span > < span class = cF6 > " GR" < / span > < span class = cF0 > ), *src = < / span > < span class = cF5 > FileRead< / span > < span class = cF0 > (st);
< a name = "l419" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (src)
< a name = "l420" > < / a > dc = < / span > < span class = cF5 > DCLoad< / span > < span class = cF0 > (src,, task);
< a name = "l421" > < / a > < / span > < span class = cF5 > Free< / span > < span class = cF0 > (src);
< a name = "l422" > < / a > < / span > < span class = cF5 > Free< / span > < span class = cF0 > (st);
2021-07-03 05:07:57 +01:00
< a name = "l423" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l424" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > dc;
2021-07-03 05:07:57 +01:00
< a name = "l425" > < / a > }
< a name = "l426" > < / a >
< a name = "l427" > < / a > #< / span > < span class = cF1 > help_index< / span > < span class = cF0 > < / span > < span class = cF6 > " Graphics/Sprite;Graphics/GR Files;DolDoc/Output;StdOut/DolDoc" < / span > < span class = cF0 >
< a name = "l428" > < / a > < / span > < span class = cF1 > public< / span > < span class = cF0 > < / span > < span class = cF1 > U0< / span > < span class = cF0 > < / span > < span class = cF5 > DocGR< / span > < span class = cF0 > (< / span > < span class = cF9 > CDoc< / span > < span class = cF0 > *doc=< / span > < span class = cF3 > NULL< / span > < span class = cF0 > , < / span > < span class = cF1 > U8< / span > < span class = cF0 > *filename)
< a name = "l429" > < / a > {< / span > < span class = cF2 > //Put a GR file into a document as asprite.< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l430" > < / a > < / span > < span class = cF9 > CDC< / span > < span class = cF0 > *dc = < / span > < span class = cF5 > GRRead< / span > < span class = cF0 > (filename);
< a name = "l431" > < / a > < / span > < span class = cF9 > CSprite< / span > < span class = cF0 > *elems = < / span > < span class = cF5 > DC2Sprite< / span > < span class = cF0 > (dc);
2021-07-03 05:07:57 +01:00
< a name = "l432" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l433" > < / a > < / span > < span class = cF5 > DocSprite< / span > < span class = cF0 > (doc, elems);
< a name = "l434" > < / a > < / span > < span class = cF5 > Free< / span > < span class = cF0 > (elems);
< a name = "l435" > < / a > < / span > < span class = cF5 > DCDel< / span > < span class = cF0 > (dc);
2021-07-03 05:07:57 +01:00
< a name = "l436" > < / a > }
< a name = "l437" > < / a >
< a name = "l438" > < / a > #< / span > < span class = cF1 > help_index< / span > < span class = cF0 > < / span > < span class = cF6 > " Graphics/Device Contexts;Graphics/Screen" < / span > < span class = cF0 >
< a name = "l439" > < / a > < / span > < span class = cF1 > public< / span > < span class = cF0 > < / span > < span class = cF9 > CDC< / span > < span class = cF0 > *< / span > < span class = cF5 > DCScreenCapture< / span > < span class = cF0 > (< / span > < span class = cF1 > Bool< / span > < span class = cF0 > include_zoom=< / span > < span class = cF3 > TRUE< / span > < span class = cF0 > , < / span > < span class = cF9 > CTask< / span > < span class = cF0 > *task=< / span > < span class = cF3 > NULL< / span > < span class = cF0 > )
< a name = "l440" > < / a > {< / span > < span class = cF2 > //Capture screen to a device context.< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l441" > < / a > < / span > < span class = cF9 > CDC< / span > < span class = cF0 > *dc;
< a name = "l442" > < / a > < / span > < span class = cF1 > U8< / span > < span class = cF0 > *dst;
2021-07-03 05:07:57 +01:00
< a name = "l443" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l444" > < / a > < / span > < span class = cF5 > Refresh< / span > < span class = cF0 > (< / span > < span class = cFE > 0< / span > < span class = cF0 > , < / span > < span class = cF3 > FALSE< / span > < span class = cF0 > );
< a name = "l445" > < / a > < / span > < span class = cF1 > if< / span > < span class = cF0 > (include_zoom)
< a name = "l446" > < / a > dc = < / span > < span class = cF5 > DCCopy< / span > < span class = cF0 > (< / span > < span class = cFB > gr< / span > < span class = cF0 > .screen_image, task);
< a name = "l447" > < / a > < / span > < span class = cF1 > else< / span > < span class = cF0 >
< a name = "l448" > < / a > dc = < / span > < span class = cF5 > DCCopy< / span > < span class = cF0 > (< / span > < span class = cFB > gr< / span > < span class = cF0 > .dc1, task);
< a name = "l449" > < / a > dc-> flags & = ~< / span > < span class = cF3 > DCF_SCREEN_BITMAP< / span > < span class = cF0 > ;
< a name = "l450" > < / a > dst = < / span > < span class = cF5 > MAlloc< / span > < span class = cF0 > (dc-> width_internal * dc-> height, task);
2021-07-03 05:07:57 +01:00
< a name = "l451" > < / a > < / span > < span class = cF2 > //Pick background color that never occurs. COLOR_INVALID< / span > < span class = cF0 >
2021-07-04 23:11:34 +01:00
< a name = "l452" > < / a > < / span > < span class = cF5 > GrBitMap4ToBitMap8< / span > < span class = cF0 > (dst, dc-> body, < / span > < span class = cF7 > (< / span > < span class = cF0 > dc-> width_internal * dc-> height< / span > < span class = cF7 > )< / span > < span class = cF0 > > > < / span > < span class = cFE > 1< / span > < span class = cF0 > , < / span > < span class = cF3 > COLOR_INVALID< / span > < span class = cF0 > );
< a name = "l453" > < / a > < / span > < span class = cF5 > Free< / span > < span class = cF0 > (dc-> body);
< a name = "l454" > < / a > dc-> body = dst;
2021-07-03 05:07:57 +01:00
< a name = "l455" > < / a >
2021-07-04 23:11:34 +01:00
< a name = "l456" > < / a > < / span > < span class = cF1 > return< / span > < span class = cF0 > dc;
2021-07-03 05:07:57 +01:00
< a name = "l457" > < / a > }
< / span > < / pre > < / body >
< / html >