Re: [fpc-pascal] named parameter
> On May 28, 2017, at 5:22 PM, Mark Morgan Lloyd >wrote: > >> IMO though it does improve readability in long functions with lots of >> parameters, like windows api style procedures that have 5 or more >> parameters and you can't figure out which param is >> which > You mean like this? function Foo (theString: string; options: set of TFoo): boolean; begin end; Foo(theString: 'foo', options: []); Objective-C has this mandatory and it made for stupidly long method names that just looked terrible but it was optional Pascal makes it look nicer. The declaration syntax is already the same as the label for the calling syntax so that seems like a nice fit. Regards, Ryan Joseph ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] GLM library alternative?
> On May 29, 2017, at 8:24 AM, Anthony Walterwrote: > > And these matrices are compatible with OpenGL functions. > Thanks for sharing. I got your matrix multiplication functions to work in the order I expected and helped me find a bug. Btw, given what we just learned about loops in FPC I would remove the nested for..loops in your matrix overloads. Regards, Ryan Joseph ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] GLM library alternative?
All SupraEngine.Math matrices are also compatible with OpenGL (and Vulkan, of course). SupraEngine.Math's TMatrix3x3 and TMatrix4x4 implementation have also advanced stuff as such as lerp, nlerp, slerp interpolation method functions, decomposing (into Perspective, Translation, Scale, Skew and Rotation components), recomposing (from Perspective, Translation, Scale, Skew and Rotation components). And SupraEngine.Math have also GLSL-style and in the most cases GLSL-Function-Parameter-compatible functions as such as Cross, Dot, Normalize, FaceForward, Reflect, Refract, Clamp, Mix, Step, SmoothStep, etc. Example usages: FaceNormal := (p2 - p0).Cross(p1 - p0).Normalize; // or alternatively also: FaceNormal := Normalize(Cross(p2 - p0,p1 - p0)); if FaceNormal.Dot((Normals[NormalIndices[0]]+ Normals[NormalIndices[1]]+ Normals[NormalIndices[2]]).Normalize) < 0.0 then begin FaceNormal := -FaceNormal; end; TriangleTangent:=((p2-p0)*(uv1.v-uv0.v))-((p1-p0)*(uv2.v-uv0.v)); TriangleBitangent:=((p2-p0)*(uv1.u-uv0.u))-((p1-p0)*(uv2.u-uv0.u)); TriangleTangent:=(TriangleTangent-(TriangleNormal*TriangleTangent.Dot(TriangleNormal))).Normalize; TriangleBitangent:=(TriangleBitangent-(TriangleNormal*TriangleBitangent.Dot(TriangleNormal))).Normalize; if (TriangleBitangent.Cross(TriangleTangent)).Dot(TriangleNormal)<0.0 then begin TriangleTangent:=-TriangleTangent; TriangleBitangent:=-TriangleBitangent; end; Matrix := Transform.Matrix * Matrix; Vector := Matrix * Vector; (like at GLSL) Vector := Vector * Matrix; (in the other way transposed mul like at GLSL) Vector := Quaternion * Vector; Vector := Vector * Quaternion; (with the same transposed-matrix-like effect) Vector := DualQuaternion * Vector; Vector := Vector * DualQuaternion; (with the same transposed-matrix-like effect) RightVector := Matrix.Right.xyz; UpVector := Matrix.Up.xyz; ForwardVector := Matrix.Forwards.xyz; TranslationVector := Matrix.Translation.xyz; Matrix := Matrix.Normalize; Matrix := Matrix.OrthoNormalize; Matrix := Matrix.RobustOrthoNormalize; Quaternion := Matrix.ToQuaternion; QTangent := Matrix.ToQTangent; Matrix3x3 := Matrix4x4.ToMatrix3x3; ModelMatrix := Matrix4x4Identity; ViewMatrix := TMatrix4x4.CreateTranslation(0.0, 0.0, -4.0); ProjectionMatrix := TMatrix4x4.CreatePerspective(45.0, Width / Heighz, 1.0, 1024.0); ModelViewMatrix := ModelMatrix * ViewMatrix; InverseModelViewMatrix := ModelViewMatrix.Inverse; ModelViewProjectionMatrix := ModelMatrix * ViewMatrix * ProjectionMatrix; InverseModelViewProjectionMatrix := ModelViewMatrixProjection.Inverse; TangentSpaceRotationMatrix := ModelViewMatrix.Inverse.Transpose; InverseTangentSpaceRotationMatrix := TangentSpaceRotationMatrix.Transpose; ClipMatrix := CreateProjectionMatrixClip(ProjectionMatrix, ClipPlane); etc. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] GLM library alternative?
> On May 28, 2017, at 10:33 PM, Ryan Josephwrote: > > projTransform := TMatrix4x4.CreatePerspective(60.0, 500 / 500, 0.1, > 10.0); > modelTransform := TMatrix4x4.CreateTranslation(0, 0, -3.0) * > TMat4.CreateRotateX(54); I found out the problem. I was expecting the multiply to work like with GLM where you could do: translation * rotation but with the operator overloads I need to do protation * translation. Anthony’s multiply matrix 4 operators did this in the order I expected and how I figured it out. Not sure why and it’s probably not safe to swap the parameters because it would likely break other parts of the unit. Regards, Ryan Joseph ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] GLM library alternative?
You might want to try using this geometry library I've written to go along with OpenGL, fixed function or otherwise: https://github.com/sysrpl/Bare.Game/blob/master/source/bare.geometry.pas#L317 Basic usage might be like this: var M: TMatrix; V: TVertex; begin M.Identity; M.Translate(10, 0, 0); V := M * Vec(10, 10, 10); M.Rotate(0, 10, 0); V := M * V; WriteLn('X: ', V.X, ' Y: ', V.Y, 'Z: ', V.Z) M.Scale(0.5, 0.5, 0.5); V := M * V; WriteLn('X: ', V.X, ' Y: ', V.Y, 'Z: ', V.Z) end; And these matrices are compatible with OpenGL functions. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] named parameter
In our previous episode, Bernd Oppolzer said: > IMO, it's not about named parameters; > furthermore, it is not about readability, but this IMO > is a maintenance issue. > > Think about a procedure that has two parameters and a lot of callers > and you want to add a third one. > > it would be nice if you could specify a default value for the new > third parameter and don't have to change all the callers that use > only two. Yes, that is why Visual Basic had it, but I thought the whole concept was nowadays considered old fashioned and baroque. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] ptccrt missing keys
Having some kind of Keyboard Mode selection Variable that defaults to TP compatibility would be a great option. James -Original Message- From: fpc-pascal [mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf Of Nikolay Nikolov Sent: Sunday, May 28, 2017 9:52 AM To: fpc-pascal@lists.freepascal.org Subject: Re: [fpc-pascal] ptccrt missing keys On 05/26/2017 10:49 PM, James Richters wrote: >> It's great that it's finally working for you. And yes, ptccrt supports most >> alt and ctrl key combinations, but if you find some key combination missing, >> please report it - it is easy to add. > I could really use F11 and F12 including shift, alt, and crtl if possible > from the prccrt graphics window. I suspect there is some fundamental reason > why F11 and F12 aren't usable, because F11 and F12 don't work in crt either. > But here is what does work in crt that would be great if would also work in > ptccrt. > > lots of missing keys Unfortunately, all of the missing keys and differences from ptccrt (including the very odd ones) stem from the fact that ptccrt behaves _exactly_ like the crt unit in Turbo Pascal 7 under DOS, with a 100% IBM compatible keyboard and BIOS. This includes the lack of support for extended keys (like F11 and F12). The Windows crt unit doesn't conform strictly to that, however, so that's why there are differences. I don't want to sacrifice the DOS/TP7 crt unit compatibility, so I'll have to think of something, but it'll take a little time. Perhaps I'll add different keyboard compatibility "modes" or something like that. Nikolay ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] ptccrt missing keys
On 05/26/2017 10:49 PM, James Richters wrote: It's great that it's finally working for you. And yes, ptccrt supports most alt and ctrl key combinations, but if you find some key combination missing, please report it - it is easy to add. I could really use F11 and F12 including shift, alt, and crtl if possible from the prccrt graphics window. I suspect there is some fundamental reason why F11 and F12 aren't usable, because F11 and F12 don't work in crt either. But here is what does work in crt that would be great if would also work in ptccrt. lots of missing keys Unfortunately, all of the missing keys and differences from ptccrt (including the very odd ones) stem from the fact that ptccrt behaves _exactly_ like the crt unit in Turbo Pascal 7 under DOS, with a 100% IBM compatible keyboard and BIOS. This includes the lack of support for extended keys (like F11 and F12). The Windows crt unit doesn't conform strictly to that, however, so that's why there are differences. I don't want to sacrifice the DOS/TP7 crt unit compatibility, so I'll have to think of something, but it'll take a little time. Perhaps I'll add different keyboard compatibility "modes" or something like that. Nikolay ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] GLM library alternative?
On GitHub I've already some SupraEngine subprojects, for example: - https://github.com/BeRo1985/pasmp My parallel-processing/multi-processing library for Object Pascal - https://github.com/BeRo1985/kraft My newer 3D physics Engine for Object Pascal - https://github.com/BeRo1985/pasvulkan Vulkan header generator and Vulkan OOP-style API wrapper for Object Pascal (it had also news articles on http://www.phoronix.com/scan.php?page=news_item=PasVulkan-Vulkan--Pascal-Bind and https://www.khronos.org/news/tags/tag/Pascal ) - https://github.com/BeRo1985/pasdblstrutils Pascal library for cross-compiler consistent and exact conversion between double-precision floating point number values and strings - https://github.com/BeRo1985/pasenet Pascal port of ENet with IPv6 support - etc. But the SupraEngine main core project itself is still closed source (as long as it is not yet ready), except these already excerpt-uploaded (for users of this mailing list) zlib-licensed Math units, because SupraEngine will have a UE4-style licensing model, say, when it will be released, it will be free and quasi-open-source for free projects (it does not matter whether it are open source or closed source projects), but it will be revenue-share-based for non-free paid projects. A lawyer (a corresponding lawyer I have already in the selection) will formulate the appropriate license text for it, but this will be the last task, just before the release. But because the engine market is already largely saturated, it will be primarly for projects (at least for the first time), for example, Supraleiter (here some prototype videos with the old OpenGL-based engine: https://www.youtube.com/watch?v=SWanRYNNTUA=PLoqdQblnX8vS11pAzGXOak3nsC4UoaC4-=4 and https://www.youtube.com/watch?v=dR8OJoHWuGs=3=PLoqdQblnX8vS11pAzGXOak3nsC4UoaC4- and https://youtu.be/_SVL0_Z3WL8 and https://youtu.be/-mi2wOnks_A ), a StarTrek Voyager first-person-shooter (here some prototype videos, which had made my graphic-artist-contact testwise with UE4: http://www.indiedb.com/games/voyager-game-project/videos/scorpion#imagebox and http://www.indiedb.com/games/voyager-game-project/videos/deltaflyer-12-10-2016#imagebox and http://www.indiedb.com/games/voyager-game-project/videos/bridge-preview-9#imagebox ), etc. And I've testwise partly-reverse.engineered and partly-reimplemented the first two Original WipeOut titles (in ObjectPascal of course): https://youtu.be/MI_jtU2kiQk and https://youtu.be/zKpAWaByyyc for to test my newer physics engine in a real test game, as preparation for usage in my Supraleiter game project with the then new Vulkan-based SupraEngine. On Sun, May 28, 2017 at 10:22 AM, denisgolovanwrote: > 28.05.2017, 09:55, "Benjamin Rosseaux" : > > > I've put some units of my still work-in-progress UE4-style SupraEngine on > my root server, after I've read this mailing list thread => > > http://rootserver.rosseaux.net/stuff/supraengineunits/ > > > > Looks nice. Thanks for sharing. > How about publishing it on Github with small readme to ease contributions? > > -- > Regards, > Denis Golovan > > > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal > ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] fpc code for Java class and Android.
Hello Paul. > How simple can we make this? I have some videos showing ideU/polydev features, maybe it can be useful ? Huh, maybe we could open a new topic in fpc-other ? Fre;D - Many thanks ;-) -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/fpc-code-for-Java-class-and-Android-tp5728166p5728922.html Sent from the Free Pascal - General mailing list archive at Nabble.com. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] GLM library alternative?
I know that issue, so that the record constructors in the SupraEngine.Math.pas are fully optional, so therefore you do must not using these :-) It's just a optional option for key-tap-lazy peoples, since all record member fields are also free directly accessible and public visible. On Sun, May 28, 2017 at 9:28 AM, Ryan Josephwrote: > > > On May 28, 2017, at 1:54 PM, Benjamin Rosseaux > wrote: > > > > I've put some units of my still work-in-progress UE4-style SupraEngine > on my root server, after I've read this mailing list thread => > > Thanks for sharing. The GLM functions I wanted seem to be here so I’m > going to try them. > > Btw, I’m not sure Sven fixed this or is going to but we found out record > constructors were not producing optimal instructions when compared to > static inline class functions so you may want to change those. I had to go > back and make changes to some low-level record constructors after I found > this out also. > > Regards, > Ryan Joseph > > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal > ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] GLM library alternative?
Fixed, repacked & reuploaded as ZIP in the same directory On Sun, May 28, 2017 at 10:32 AM, Ryan Josephwrote: > > > On May 28, 2017, at 3:22 PM, denisgolovan > wrote: > > > > Looks nice. Thanks for sharing. > > How about publishing it on Github with small readme to ease > contributions? > > > > There’s some dead 403 links also btw. > > Regards, > Ryan Joseph > > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal > ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] GLM library alternative?
Ryan Joseph wrote: I’m trying to following some OpenGL tutorials to learn the matrix transforms but I’m getting stuck because I don’t have the c++ GLM library which everyone is using. I see FPC has a matrix class but it doesn’t include all the helpers in GLM like rotation, transform, perspective transforms (https://open.gl/transformations). If I knew enough I think I could just build these myself but I’ll likely introduce a bunch of errors at first. Has anyone converted these to Pascal before or having some similar I could look at? Regards, Ryan Joseph I use my own vector/matrix library VectorUtils3, which is written in plain C (thereby FPC friendly), and included in the common code of my OpenGL demo library: http://computer-graphics.se/demopage/ Actually, there is also an FPC version of VectorUtils, FPC interfaces to most of my common code, and even a bunch of demos that I made FPC for. (Modern OpenGL, not old-style code, no immediate mode.) I never uploaded them anywhere, since there didn't seem to be much interest, but if someone wants them, no problem. /Ingemar ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] named parameter
On 27/05/17 20:30, nore...@z505.com wrote: IMO though it does improve readability in long functions with lots of parameters, like windows api style procedures that have 5 or more parameters and you can't figure out which param is which I had an interesting case a couple of years ago where a procedure called itself recursively, but with a couple of the parameters shifted in relative position. Messing that up when I added an extra parameter caused a difficult-to find bug, so I think that some sort of identify-by-name arrangment (I'm not saying pass-by-name because of its historical meaning) would be useful. procedure SendMechCodeToLineASCII(mc: word; bcd, apl: boolean; crlf: boolean= false; lf: boolean= false; echo: boolean= false; loopback: boolean= false); .. (* CR expansion, local echo etc. Note recursive echo of LF if CR is expanded, *) (* this is to keep the VM/CMS "Sixpack" happy since otherwise the first line of *) (* output always tries to overwrite the command that instigated it (but with*) (* bits of the command showing through non-destructive spaces). *) (* *) (* Note intentional shift of parameter positions in the recursive call below. *) if (mc = Op_CarrierReturn) and crlf then SendMechCodeToLineASCII(Op_Index, bcd, apl, {crlf :=} loopback, {lf :=} false, {echo := } true, {loopback :=} false); if echo then PseudoEventQueue.Enqueue($8000 + canonical(mc)) end end { SendMechCodeToLineASCII } ; -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] named parameter
On 27/05/17 11:26, Bernd Oppolzer wrote: > it would be nice if you could specify a default value for the new > third parameter and don't have to change all the callers that use > only two. > [snip] > procecure P (x : integer; y : boolean; c: char := ' '); > > the first two parameters are mandatory, the third is optional. > Calls to P with 2 and 3 parameters are both valid. You realize you can already do this, right? See https://www.freepascal.org/docs-html/ref/refsu64.html#x176-19800014.4.1 -- Ewald ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] GLM library alternative?
> On May 28, 2017, at 3:22 PM, denisgolovanwrote: > > Looks nice. Thanks for sharing. > How about publishing it on Github with small readme to ease contributions? > There’s some dead 403 links also btw. Regards, Ryan Joseph ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] GLM library alternative?
28.05.2017, 09:55, "Benjamin Rosseaux": I've put some units of my still work-in-progress UE4-style SupraEngine on my root server, after I've read this mailing list thread => http://rootserver.rosseaux.net/stuff/supraengineunits/ Looks nice. Thanks for sharing.How about publishing it on Github with small readme to ease contributions? -- Regards,Denis Golovan ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] GLM library alternative?
> On May 28, 2017, at 1:54 PM, Benjamin Rosseauxwrote: > > I've put some units of my still work-in-progress UE4-style SupraEngine on my > root server, after I've read this mailing list thread => Thanks for sharing. The GLM functions I wanted seem to be here so I’m going to try them. Btw, I’m not sure Sven fixed this or is going to but we found out record constructors were not producing optimal instructions when compared to static inline class functions so you may want to change those. I had to go back and make changes to some low-level record constructors after I found this out also. Regards, Ryan Joseph ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] GLM library alternative?
I've put some units of my still work-in-progress UE4-style SupraEngine on my root server, after I've read this mailing list thread => http://rootserver.rosseaux.net/stuff/supraengineunits/ where the SupraEngine.Math.pas + SupraEngine.Math.*.inc + SupraEngine.Types.Standard.pas will be maybe interesting for you. It's a complete 3D Math unit based on overloaded operators, advanced records, etc. and even with GLSL-style swizzle support, where you can type something like My3DVector.xzy := MyOther3DVector.yyx; My4DVector.zyx := TVector3.Create(3.0, 2.0, 1.0); or even My2DVector.yx := My3DVector.yz; etc. Furthermore many routines are SSE optimized for the x86-32 and x86-64 targets. This is the result of many years of evolution-based work, starting from the original math routines of my old PAPPE physics engine, which I've always further developed over the years (incl. many refactorings and rewrites). And if you will do using it, then you add the following line to your start of your code (where the Math unit must be in the uses clause): SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide, exOverflow, exUnderflow, exPrecision]); for disable some floating point exceptions, which could occur at 3D stuff, especially divide-by-zero exceptions at speed-SIMD-optimized normalization operations. And credits would be nice :) Regards, Benjamin 'BeRo' Rosseaux On Sat, May 27, 2017 at 12:37 PM, Ryan Josephwrote: > > > On May 27, 2017, at 5:16 PM, Mark Morgan Lloyd < > markmll.fpc-pas...@telemetry.co.uk> wrote: > > > > But working from a hazy recollection of such things, it's possible to > merge the translation/rotation matrices so that the final transformation > can be reduced to a single operation. > > Oh I’m sorry, I’m using 3.x core and the fixed pipeline has been removed > which glRotate etc… were part of. I’m using this now but I wanted to learn > the “new” stuff some. > > Regards, > Ryan Joseph > > ___ > fpc-pascal maillist - fpc-pascal@lists.freepascal.org > http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal > ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal