I miss AnsiString on Mobile...not only for Internet but for Shaders also.
I miss AnsiString on Mobile...not only for Internet but for Shaders also.
// FMX.Context.GLES.pas
const
GLESHeaderHigh: array [0..24] of byte =
(Byte('p'), Byte('r'), Byte('e'), Byte('c'), Byte('i'), Byte('s'), Byte('i'), Byte('o'), Byte('n'), Byte(' '),
Byte('h'), Byte('i'), Byte('g'), Byte('h'), Byte('p'), Byte(' '), Byte(' '), Byte(' '), Byte('f'), Byte('l'),
Byte('o'), Byte('a'), Byte('t'), Byte(';'), Byte(#13));
// FMX.Context.GLES.pas
const
GLESHeaderHigh: array [0..24] of byte =
(Byte('p'), Byte('r'), Byte('e'), Byte('c'), Byte('i'), Byte('s'), Byte('i'), Byte('o'), Byte('n'), Byte(' '),
Byte('h'), Byte('i'), Byte('g'), Byte('h'), Byte('p'), Byte(' '), Byte(' '), Byte(' '), Byte('f'), Byte('l'),
Byte('o'), Byte('a'), Byte('t'), Byte(';'), Byte(#13));
http://TEncoding.ASCII.GetBytes('precision highp float;'#13)
ReplyDeleteIt's not terribly elegant
And Shaders are actually stored as array of byte but they are (for OpenGL) just plain ASCII text.
ReplyDeleteThe DirectX version (provided regardless of the platform) are a binary dump of the fxc compiler output...but they could also be compiled in realtime from an ASCII version with D3DCompiler.
Does this help you? http://andy.jgknet.de/blog/2015/09/byte-strings-for-delphi-10-seattles-mobile-compilers/
ReplyDeleteConst
ReplyDeleteGLESHeaderHigh : MarshaledAString = 'precision highp float;'#13;
If you stick with ASCII only, doesn't Utf8String do the job?
ReplyDeleteUwe Raabe Utf8String on mobile platforms arrived only with Berlin
ReplyDeleteI wrote a small tool to convert the shader to a byte array. I know it is not the best way, but how often you change the code on runtime.
ReplyDeleteAlexey Kazantsev So, what?
ReplyDeleteJeroen Wiert Pluimers I know this, and I know that Embt don't want to reintroduce AnsiString...just pointing another situation where they are welcome ;)
ReplyDeletePaul TOTH I exactly know what you mean. It took weeks for me to get ARAT Synapse running under the new compiler. You might check this out: andy.jgknet.de - System.ByteStrings for 10.1 Berlin | Andy's Blog and Tools
ReplyDeletein fact, I used to put binary data in Delphi 6 stings, and Embt told me how bad this is. strings are for textual data, use Stream or TBytes for binary data...but now I have true plain ASCII textual data and I have to put them in UTF8 or TBytes...curious isn't it ? :D
ReplyDeletePaul TOTH 'now I have true plain ASCII textual data and I have to put them in UTF8' - if you're sticking to ASCII, there's zero difference between using the AnsiString and UTF8String types... or am I missing something...?
ReplyDeleteChris Rolliston probably the same difference between RawByteString and TBytes :) plus extra code to handle UTF8 that is not necessary. And as a french developper I could add some ANSI characters that do not fit in the ASCII table, Voilà :D
ReplyDeletePaul TOTH A UTF8String is an AnsiString though. It surely takes more effort to support Windows codepages on non-Windows platforms than UTF-8...
ReplyDeleteChris Rolliston yes and a RawByteString is an array of Byte. It's not the problem, it's not consistent to prohibit binary string for semantic reasons and using UTF8String to store non-UTF8 data.
ReplyDeletePaul TOTH 'yes and a RawByteString is an array of Byte' - well no, a RawByteString is an AnsiString too (i.e. an array of bytes + code page setting, managed by the long string support routines in System.pas). 'Using UTF8String to store non-UTF8 data' - I thought we were talking about 'plain ASCII text', as you put it in your first post...?
ReplyDeleteChris Rolliston ok, you don't agree with me, but I don't want to play with words (and you). Thanks ;)
ReplyDelete