Re: Is this code correct?

2023-04-07 Thread z via Digitalmars-d-learn

On Saturday, 1 April 2023 at 15:32:27 UTC, Dennis wrote:

On Friday, 31 March 2023 at 13:11:58 UTC, z wrote:
I've tried to search before but was only able to find articles 
for 3D triangles, and documentation for OpenGL, which i don't 
use.


The first function you posted takes a 3D triangle as input, so 
I assumed you're working in 3D. What are you working on?



Determines if a triangle is visible.


You haven't defined what 'visible' means for a geometric 
triangle.


explained to the best of my ability : 
https://d.godbolt.org/z/4a8zPGsGo
the "angle bias" i was trying to explain about is present, when 
`rot = 0` the `mask` is supposed to only have three `true` 
values.(that of the "front" triangle.)


You haven't defined what 'visible' means for a geometric 
triangle.


Problem is, all i have is an assembly dump and the data it 
interacts with, both of which are very(very) old.


Re: DlangUI Layout Justification

2023-04-07 Thread Adam D Ruppe via Digitalmars-d-learn

On Friday, 7 April 2023 at 15:52:02 UTC, Ali Çehreli wrote:
I don't know how relevant it is but there is also Hipreme 
Engine that supports Android:


I think the question is if you are doing games vs doing other 
applications. There's some overlap between game and gui, but not 
actually that much. Both draw things to the screen and accept 
user input... but even these two things they tend to do quite 
differently.


Guis tend to favor responsiveness. I know, there's people saying 
"games have to be even more responsive!" but let me finish: 
games tend to favor *predictability*. (Some exceptions of course.)


A gui will want to respond to input as soon as it can. If I can 
press a key and see a response on screen in one millisecond, 
great! Or, on the other hand, if it takes 200 ms... not so great, 
but I can maybe still live with it.


A game will want to respond to input *on a strict schedule*. 
Responding too fast might break its rules - the world physics 
aren't infinitely precise and are designed with certain limits in 
mind. It might also give an unfair advantage to some players over 
others. Responding too slowly means players will miss their jumps 
and other frustrating feelings of lack of control. But notice 
that if something is *predictably* slow, players will get used to 
it - a lot of things deliberately have some delay according to 
the rules of the game. Something is only ever "too slow" if it is 
inconsistently slow.


Thus it is common for games to poll input on a timer, whereas 
guis wait for input on events.


Both games and guis draw, but games tend to draw many active 
things at once, showing a game world that is changing with the 
passage of time, and guis tend to draw one difference at a time, 
in response to either a user input or some request finishing. 
Sure, some guis will do large animations that are similar to how 
a game works, but these are exceptional circumstances; most the 
time, a game is drawing to keep the screen in sync with the state 
of the game world and most the time a gui is idle, waiting for 
something to happen.


That's just the differences in functionality where they overlap. 
Other things are very different. Games often (but not always) 
value predictable latency audio, to maintain its a/v sync. Guis, 
being idle more often than not, can typically defer opening an 
audio device until they need it, then close it as soon as that 
effect is done. Most games contain themselves to one large, 
multi-role window. Guis often use several, with varying roles 
including temporary single-purpose windows (e.g. popup menus and 
toolips). Guis need to implement a variety of input patterns that 
games rarely care about - interprocess drag and drop, copy and 
paste, ui automation and accessibility apis; guis are more often 
part of a bigger cooperative whole than just on their own. Games 
just want to take whatever global input they get into their own 
self-contained game world, and games are more likely to care 
about joysticks and gamepads than guis.


One library can help with both games and guis but it is unlikely 
to be a complete solution for either, certainly not both.


Re: DlangUI Layout Justification

2023-04-07 Thread Ali Çehreli via Digitalmars-d-learn

On 3/9/23 07:09, Ron Tarrant wrote:


Many thanks, ryuukk. I'll check it out.


I don't know how relevant it is but there is also Hipreme Engine that 
supports Android:


  https://forum.dlang.org/thread/fecijdotstuclyzzc...@forum.dlang.org

Ali



Re: Code organization, dub, etc.

2023-04-07 Thread Ali Çehreli via Digitalmars-d-learn

On 3/13/23 07:30, Joe wrote:

> whether DLang (the Foundation and/or the
> community) would consider working with the CMake and clang-format
> communities to get them to support D in their products

That would be great. I hope it will eventually happen.

I've used CMake on existing projects only as a tool that is better than 
some others. Witnessing CMake being replaced by even better tools like 
Bazel, should CMake be a target or should Bazel, etc. take precedence?


Ali



Re: member func is best choice for pointers?

2023-04-07 Thread Ali Çehreli via Digitalmars-d-learn

On 4/6/23 07:26, a11e99z wrote:
> ```d
> import std, core.lifetime;
>
> struct Node {
>  Node* pNext;
>  void func() { "Node::func %s".writeln( pNext); }

That's a member function, which works with the obj.func() syntax.

However, there is another feature of D that is in play here: Members can 
directly be accessed through pointers without dereferencing.


  pn.func()

has the same effect as

  (*pn).func()

(That's why D does not use C's -> operator).

> }
> void func( Node* p ) { "::func %s(%s)".writeln( p, p == null ? p :
> p.next); }

Ok, that function can be called normally as

  func(pn)

or with UFCS as

  pn.func()

However, UFCS takes place only when there is no such member.

I understand how this can be surprising but it is still within spec: 
There does exist a member with the name 'func', so UFCS is not applied.


One can rightly argue that automatic pointer dereferencing should take 
place after UFCS consideration but apparently that's not the case. If 
that were the case, I suspect there would be other programmers who would 
be looking for the current behavior.


Ali