This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function LoadPNG(const Stream: TStream; out Data: PByteArray; out Width, Height: LongInt): Boolean; | |
| const | |
| IHDR = $52444849; | |
| IDAT = $54414449; | |
| IEND = $444E4549; | |
| PLTE = $45544C50; | |
| tRNS = $534E5274; | |
| var | |
| i, j : LongInt; | |
| Bits : Byte; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function LoadJPG(const Stream: TStream; out Data: PByteArray; out Width, Height: LongInt): Boolean; | |
| type | |
| THuffmanTable = record | |
| Bits : array [0..15] of Byte; | |
| HVal : array [Byte] of Byte; | |
| Size : array [Byte] of Byte; | |
| Code : array [Byte] of Word; | |
| end; | |
| TQTable = array [0..63] of Single; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| constructor TTexture.Create(const FileName: string); | |
| type | |
| TLoadFormat = (lfNULL, lfDXT1c, lfDXT1a, lfDXT3, lfDXT5, lfA8, lfL8, lfAL8, | |
| lfBGRA8, lfBGR8, lfBGR5A1, lfBGR565, lfBGRA4, lfR16F, lfR32F, | |
| lfGR16F, lfGR32F, lfBGRA16F, lfBGRA32F); | |
| TDDS = record | |
| dwMagic : LongWord; | |
| dwSize : LongInt; | |
| dwFlags : LongWord; | |
| dwHeight : LongWord; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| TVec3f = {$IFDEF FPC} object {$ELSE} record {$ENDIF} | |
| x, y, z : Single; | |
| {$IFNDEF FPC} | |
| class operator Equal(const a, b: TVec3f): Boolean; | |
| class operator Add(const a, b: TVec3f): TVec3f; | |
| class operator Subtract(const a, b: TVec3f): TVec3f; | |
| class operator Multiply(const a, b: TVec3f): TVec3f; | |
| class operator Multiply(const v: TVec3f; x: Single): TVec3f; | |
| {$ENDIF} | |
| function Dot(const v: TVec3f): Single; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| TQuat = {$IFDEF FPC} object {$ELSE} record {$ENDIF} | |
| x, y, z, w : Single; | |
| {$IFNDEF FPC} | |
| class operator Equal(const q1, q2: TQuat): Boolean; | |
| class operator Add(const q1, q2: TQuat): TQuat; | |
| class operator Subtract(const q1, q2: TQuat): TQuat; | |
| class operator Multiply(const q: TQuat; x: Single): TQuat; | |
| class operator Multiply(const q1, q2: TQuat): TQuat; | |
| class operator Multiply(const q: TQuat; const v: TVec3f): TVec3f; | |
| {$ENDIF} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| TMat4f = {$IFDEF FPC} object {$ELSE} record {$ENDIF} | |
| private | |
| function GetPos: TVec3f; // https://gist.github.com/XProger/da9a74ae8b37905b421a | |
| procedure SetPos(const v: TVec3f); | |
| function GetRot: TQuat; // https://gist.github.com/XProger/def254d40a237cc0f0b2 | |
| procedure SetRot(const q: TQuat); | |
| public | |
| e00, e10, e20, e30, | |
| e01, e11, e21, e31, | |
| e02, e12, e22, e32, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| uint32 blend(uint32 color1, uint32 color2, uint8 alpha) { | |
| uint32 rb = color1 & 0xff00ff; | |
| uint32 g = color1 & 0x00ff00; | |
| rb += ((color2 & 0xff00ff) - rb) * alpha >> 8; | |
| g += ((color2 & 0x00ff00) - g) * alpha >> 8; | |
| return (rb & 0xff00ff) | (g & 0xff00); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| \S+\s*\r\n |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| mode out color out alpha | |
| -------------- -------------- ----------- | |
| layer/over: ( sc+(1-sa)*dc , sa+da-sa*da ) | |
| multiply: ( sc*dc , sa+da-sa*da ) | |
| screen: ( sa*da - (da-dc)*(sa-sc) , sa+da-sa*da ) | |
| lighten: ( max(sa*dc,sc*da) , sa+da-sa*da ) | |
| darken: ( min(sa*dc,sc*da) , sa+da-sa*da ) | |
| add: ( min(dc+sc,1) , min(sa+da,1) ) | |
| subtract: ( max(dc-sc,0) , min(sa+da,1) ) | |
| difference: ( abs(sa*dc-sc*da) , sa+da-sa*da ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| float powf_fast(float a, float b) { | |
| union { float d; int x; } u = { a }; | |
| u.x = (int)(b * (u.x - 1064866805) + 1064866805); | |
| return u.d; | |
| } |