Re: better video rendering in d

2023-03-25 Thread Ogi via Digitalmars-d-learn
On Tuesday, 21 March 2023 at 16:57:49 UTC, monkyyy wrote: My current method of making videos of using raylib to generate screenshots, throwing those screenshots into a folder and calling a magic ffmpeg command is ... slow. Why not use ffmpeg as a library? Here are the

Solving optimization problems with D

2023-01-01 Thread Ogi via Digitalmars-d-learn
I’ve read this [series if articles](https://www.gamedeveloper.com/design/decision-modeling-and-optimization-in-game-design-part-1-introduction) about using Excel Solver for all kinds of optimization problems. This is very neat, but of course, I would prefer to write models with code instead,

Re: Interfacing with basic C++ class

2022-09-30 Thread Ogi via Digitalmars-d-learn
On Thursday, 29 September 2022 at 12:49:06 UTC, Riccardo M wrote: On Thursday, 29 September 2022 at 11:13:15 UTC, Ogi wrote: So it turns out that D's structs are a much better match for C++'s classes in this case. But why is this? Can you elaborate? It must have to do with the fact that D

Re: Interfacing with basic C++ class

2022-09-29 Thread Ogi via Digitalmars-d-learn
On Wednesday, 28 September 2022 at 19:57:10 UTC, Riccardo M wrote: I think I am stuck in the easiest of the issues and yet it seems I cannot get around this. I have a C++ file: ``` class MyClass { public: int field; MyClass(int a) : field(a) {} int add(int asd) { return asd

Re: Compile time int to string conversion in BetterC

2022-08-19 Thread Ogi via Digitalmars-d-learn
On Wednesday, 17 August 2022 at 10:38:33 UTC, Dennis wrote: I had the same problem, and came up with the following trick: ```D enum itoa(int i) = i.stringof; enum major = 3; enum minor = 2; enum patch = 1; enum versionString = itoa!major ~ "." ~ itoa!minor ~ "." ~ itoa!patch; static

Compile time int to string conversion in BetterC

2022-08-17 Thread Ogi via Digitalmars-d-learn
It’s 2022 already and BetterC still imposes limits at compile time and makes things awkward. I have 3 integer enums that represents my library version. And I want to generate a "1.2.3" enum from them. This is a trivial thing to do in standard D but I can’t find a way to do it with BetterC

Re: So how do I find and remove an element from DList?

2020-07-10 Thread Ogi via Digitalmars-d-learn
On Friday, 10 July 2020 at 19:23:57 UTC, Steven Schveighoffer wrote: It's not linear over the size of the list, it's linear over the size of the range. If you are always removing 1 element, it's effectively O(1). -Steve I see. Thanks!

So how do I find and remove an element from DList?

2020-07-10 Thread Ogi via Digitalmars-d-learn
auto list = DList!int([1, 2, 3, 4]); list.remove(list[].find(2).take(1)); Error: function std.container.dlist.DList!int.DList.remove(Range r) is not callable using argument types (Take!(Range)) It works if I replace `remove` with `linearRemove`, but that defeats the whole purpose of using a

Can’t use UFCS to create InputRange?

2020-04-29 Thread Ogi via Digitalmars-d-learn
struct R {} int front(R r) { return 42; } void popFront(R r) {} bool empty(R r) { return false; } void main() { import std.range.primitives : isInputRange; static assert(isInputRange!R); } Error: static assert: `isInputRange!(R)` is false Whats really weird is that if I replace

Re: Is there any writeln like functions without GC?

2019-11-12 Thread Ogi via Digitalmars-d-learn
If your goal is to debug your @nogc code, you can use writeln in debug statement: @nogc void main() { debug writeln("hello, debug world!"); }