Re: Trivial simple OpenGl working example

2021-07-08 Thread Виталий Фадеев via Digitalmars-d-learn

On Thursday, 8 July 2021 at 16:11:17 UTC, Guillaume Piolat wrote:

On Thursday, 8 July 2021 at 14:09:30 UTC, drug wrote:

08.07.2021 16:51, Виталий Фадеев пишет:

Hi!

I searching trivial simple D/OpenGL working in 2021 year 
example.


It may be triangle.
It may be based on any library: SDL, GLFW, Derelict, etc.

Can you help me ?



https://github.com/drug007/gfm7/tree/master/examples/simpleshader

it's not trivial though but it works (tested in linux)
just `dub fetch gfm7` then go to 
`path\to\gfm7\examples\simpleshader` and run `dub`.


All kudos to Guillaume Piolat, original author of gfm library.


If like me you hate OpenGL :) you can can also get 
software-rendered DPI-aware triangles with the "turtle" package:

https://code.dlang.org/packages/turtle

(Courtesy of Cerjones for the software renderer. )


Thank, Guillaume Piolat.

I using CPU Pentium B970 It is old CPU, but even it contains a 
graphics accelerator.
Mesa DRI Intel(R) HD Graphics 2000 (SNB GT1), has 4 conveers on 
GPU.

Smartphones also contains GPU.
Because OpenGL has high priority.

CPU render, may be later.

Thanks, I noticed turtle, dg2d. It has clipping, it usefull.
What about text rendering ?



Re: Trivial simple OpenGl working example

2021-07-08 Thread Виталий Фадеев via Digitalmars-d-learn

On Thursday, 8 July 2021 at 16:32:44 UTC, drug wrote:

08.07.2021 19:11, Виталий Фадеев пишет:


I fix source code, as drug say.




I've fixed the issue upstream, shortly gfm7 v1.1.2 will be 
available.


Drug, thank! I using!


Re: Error: Outside Unicode code space

2021-07-08 Thread Adam D Ruppe via Digitalmars-d-learn

On Friday, 9 July 2021 at 03:09:52 UTC, Tony wrote:
The editor I am using (Code::Blocks) displays the characters 
just fine. So it seems that the error message should be "Error: 
Outside the ASCII code space".


D supports stuff outside the ASCII code space just fine.

Are you sure the file is saved as utf 8? if it is something like 
Windows 1252 it can still often be displayed but dmd won't know 
what to make of it.


Error: Outside Unicode code space

2021-07-08 Thread Tony via Digitalmars-d-learn
I copied some text from a web page into a comment and I get the 
error

"Error: Outside Unicode code space".

This appears to be an incorrect error message. It is upset about 
double quotes that lean forward or backwards, and apostrophes 
that lean backwards. And dashes that aren't the keyboard dash 
character.


The editor I am using (Code::Blocks) displays the characters just 
fine. So it seems that the error message should be "Error: 
Outside the ASCII code space".


Re: how to make D program footprint smaller ?

2021-07-08 Thread dangbinghoo via Digitalmars-d-learn

On Friday, 9 July 2021 at 01:51:55 UTC, dangbinghoo wrote:

On Thursday, 8 July 2021 at 11:18:26 UTC, russhy wrote:

On Thursday, 8 July 2021 at 10:01:33 UTC, dangbinghoo wrote:

I have tried to add

```
  "dflags": ["--link-defaultlib-shared"],
  "lflags": ["--as-needed"],
```

to dub.json, and my compiler is ldc2, with 800 loc program 
used `hibernated` and `asdf` package. it compiled to 27MB 
binary not stripped and even 4MB size after stripped. (When 
compiled to ARM, the binary is 3.6MB which is a little bit 
smaller, but link flags won't opt. this either!)


I tried the link flags above, but it seems that the stripped 
binary is in some size.


any suggestions for optimizing this?


thanks!
---
dbh


try:

```
"dflags-ldc": [
"-linkonce-templates",
"--Oz"
],
```

but yeah
Are you using lot of templates in your code? buffer as global?

my 20k LOC game's exe is only just 1.46mb (on windows), but 
that's because i don't use std at all


thanks for your suggestion. I just tried that flags but it 
seems not working for me.


and I just use the `nm` tool with `x86_64-pc-linux-gnu-gcc-nm 
--size-sort myprg` to get all symbols in the binary, it showed 
up that. the executable linked with tons of vibe.d symbols.


the situation is that: my program relies on another source 
library which depends on vibe.d, the problem is that the source 
library is just a set of various tools, my program is using a 
little sub of that library, which has nothing imported with 
vibe.d.


BUT: the final program compiled with dub seems simply linked 
all symbols of the sourcelibrary to the executable.


So, it there any flags that opt. this like gcc? just to link 
only needed symbols?


thanks!

dbh.


I tried to delete the dependency of `vibe.d` and `hibernated` 
package(just an experiment, I finally need them in other 
process-executables). it shows up that deleting `vibe.d` 
decreases the size to 1.8MB (stripped) and deleting `vibe.d` and 
`hibernated` result-in a size of only 530KB(stripped), this is 
the size it should be.


I don't know this is related to dub or LDC itself, but obviously, 
THIS IS A REAL PROBLEM about D compiling.


as questioned in the previous thread, I need to find out 
something like `--as-needed` options available for D.



thanks!




Re: how to make D program footprint smaller ?

2021-07-08 Thread dangbinghoo via Digitalmars-d-learn

On Thursday, 8 July 2021 at 11:18:26 UTC, russhy wrote:

On Thursday, 8 July 2021 at 10:01:33 UTC, dangbinghoo wrote:

I have tried to add

```
  "dflags": ["--link-defaultlib-shared"],
  "lflags": ["--as-needed"],
```

to dub.json, and my compiler is ldc2, with 800 loc program 
used `hibernated` and `asdf` package. it compiled to 27MB 
binary not stripped and even 4MB size after stripped. (When 
compiled to ARM, the binary is 3.6MB which is a little bit 
smaller, but link flags won't opt. this either!)


I tried the link flags above, but it seems that the stripped 
binary is in some size.


any suggestions for optimizing this?


thanks!
---
dbh


try:

```
"dflags-ldc": [
"-linkonce-templates",
"--Oz"
],
```

but yeah
Are you using lot of templates in your code? buffer as global?

my 20k LOC game's exe is only just 1.46mb (on windows), but 
that's because i don't use std at all


thanks for your suggestion. I just tried that flags but it seems 
not working for me.


and I just use the `nm` tool with `x86_64-pc-linux-gnu-gcc-nm 
--size-sort myprg` to get all symbols in the binary, it showed up 
that. the executable linked with tons of vibe.d symbols.


the situation is that: my program relies on another source 
library which depends on vibe.d, the problem is that the source 
library is just a set of various tools, my program is using a 
little sub of that library, which has nothing imported with 
vibe.d.


BUT: the final program compiled with dub seems simply linked all 
symbols of the sourcelibrary to the executable.


So, it there any flags that opt. this like gcc? just to link only 
needed symbols?


thanks!

dbh.




Re: UFCS doubt

2021-07-08 Thread Dennis via Digitalmars-d-learn

On Thursday, 8 July 2021 at 23:31:57 UTC, Antonio wrote:
"It works as described in the manual, not as expected" (from 
MySQL haters club :-p) .


Yeah, 50/285 people answering the question "What language 
features do you miss?" chose "UFCS for local symbols" in the 
[State of D survey 
(2018)](https://rawgit.com/wilzbach/state-of-d/master/report.html), but no one has championed a language change for it yet.


Re: UFCS doubt

2021-07-08 Thread Antonio via Digitalmars-d-learn

On Thursday, 8 July 2021 at 22:31:49 UTC, Dennis wrote:

On Thursday, 8 July 2021 at 22:24:26 UTC, Antonio wrote:
I supossed  that ```mfp(c,20)``` and ```c.mfp(20)``` should be 
equivalent because UFCS in second example, but it is not... 
why?


UFCS does not work for nested functions.

Functions declared in a local scope are not found when 
searching for a matching UFCS function.

...
Rationale: Local function symbols are not considered by UFCS 
to avoid unexpected name conflicts. See below problematic 
examples.


https://dlang.org/spec/function.html#pseudo-member


Thanks.

I read the example and the assumption of "name conflict" does not 
seem to be justified (from my point of view)


i.e. Without dot notation, this example must fail
```
int front(int[] arr) { return arr[0]; }
void main()
{
int[] a =[1,2,3];
auto front = 1;   // front is now a variable
auto y = front(a);   // Error, front is not a function
}
```
Changing to y = a.front() should not change the behavior (it is 
only a notation change )... but it does!!!

```
int front(int[] arr) { return arr[0]; }
void main()
{
int[] a =[1,2,3];
auto front = 1;   // front is now a variable
auto y = a.front() // NO ERROR!!!
}
```

"It works as described in the manual, not as expected" (from 
MySQL haters club :-p) .




Re: UFCS doubt

2021-07-08 Thread jfondren via Digitalmars-d-learn

On Thursday, 8 July 2021 at 22:24:26 UTC, Antonio wrote:

onlineapp.d(9): Error: no property `mfp` for type `onlineapp.C`

I supossed  that ```mfp(c,20)``` and ```c.mfp(20)``` should be 
equivalent because UFCS in second example, but it is not... why?


https://dlang.org/spec/function.html#pseudo-member

6. Functions declared in a local scope are not found when 
searching for a matching UFCS function.


Re: UFCS doubt

2021-07-08 Thread Dennis via Digitalmars-d-learn

On Thursday, 8 July 2021 at 22:24:26 UTC, Antonio wrote:
I supossed  that ```mfp(c,20)``` and ```c.mfp(20)``` should be 
equivalent because UFCS in second example, but it is not... why?


UFCS does not work for nested functions.

Functions declared in a local scope are not found when 
searching for a matching UFCS function.

...
Rationale: Local function symbols are not considered by UFCS to 
avoid unexpected name conflicts. See below problematic examples.


https://dlang.org/spec/function.html#pseudo-member




Re: UFCS doubt

2021-07-08 Thread Adam Ruppe via Digitalmars-d-learn

On Thursday, 8 July 2021 at 22:24:26 UTC, Antonio wrote:
I supossed  that ```mfp(c,20)``` and ```c.mfp(20)``` should be 
equivalent because UFCS in second example, but it is not... why?


UFCS only works with functions defined at top level, not nested 
inside other functions. That's just how it is defined i don't 
really know why.


UFCS doubt

2021-07-08 Thread Antonio via Digitalmars-d-learn
In this example (extracted from 
https://digitalmars.com/articles/b68.html), this works:

```
class C {
  int a;
  int foo(int i) { return i + a; }
}

auto mfp = (C self, int i)=>self.foo(i);

void main(){
  auto c = new C;
  assert( c.mfp(20)==20);
}
```

but this fails

```
class C {
  int a;
  int foo(int i) { return i + a; }
}

void main(){
  auto mfp = (C self, int i)=>self.foo(i);
  auto c = new C;
  assert( c.mfp(20)==20);
}
```

onlineapp.d(9): Error: no property `mfp` for type `onlineapp.C`

I supossed  that ```mfp(c,20)``` and ```c.mfp(20)``` should be 
equivalent because UFCS in second example, but it is not... why?





Re: assert(false) and GC

2021-07-08 Thread jmh530 via Digitalmars-d-learn

On Thursday, 8 July 2021 at 18:11:50 UTC, DLearner wrote:

Hi

Please confirm that:
`
   assert(false, __FUNCTION__ ~ "This is an error message");
`

Will _not_ trigger GC issues, as the text is entirely known at 
compile time.


Best regards


Consider below. Only z will generate an error. This is called 
string literal concatenation, which comes from C [1].


```d
@nogc void main() {
string x = __FUNCTION__ ~ "This is an error message";
string y = "This is an error message";
string z = __FUNCTION__ ~ y;
}
```

[1] 
https://en.wikipedia.org/wiki/String_literal#String_literal_concatenation


assert(false) and GC

2021-07-08 Thread DLearner via Digitalmars-d-learn

Hi

Please confirm that:
`
   assert(false, __FUNCTION__ ~ "This is an error message");
`

Will _not_ trigger GC issues, as the text is entirely known at 
compile time.


Best regards


Re: Trivial simple OpenGl working example

2021-07-08 Thread Ferhat Kurtulmuş via Digitalmars-d-learn

On Thursday, 8 July 2021 at 13:51:51 UTC, Виталий Фадеев wrote:

Hi!

I searching trivial simple D/OpenGL working in 2021 year 
example.


It may be triangle.
It may be based on any library: SDL, GLFW, Derelict, etc.

Can you help me ?


this one of mine [1] was very simple in the beginning. It even 
runs on browser now.


[1] https://github.com/aferust/drawee


Re: Trivial simple OpenGl working example

2021-07-08 Thread drug via Digitalmars-d-learn

08.07.2021 19:11, Виталий Фадеев пишет:


I fix source code, as drug say.




I've fixed the issue upstream, shortly gfm7 v1.1.2 will be available.


Re: float price; if (price == float.nan) { // initialized } else { // uninitialized } ... valid ?

2021-07-08 Thread bauss via Digitalmars-d-learn

On Wednesday, 30 June 2021 at 16:41:40 UTC, someone wrote:

On Wednesday, 30 June 2021 at 16:24:38 UTC, Andre Pany wrote:

Side note: in case you want to work with money, you may 
consider using a specific data type like 
https://code.dlang.org/packages/money instead of float/double.


Yes, I've seen it, and in a previous-unrelated post I commented 
I am planning to use it (or something similar) because floats 
and currency are a horrible combo. I am not using it right now 
because I want to learn the language and encountering 
situations like this one helps me a lot, otherwise, I would 
have never noted such NaN behavior -to me, there are a lots of 
things that could fly under the radar at this moment. And by 
the way, looking at the code, money seems a quite simple 
non-nonsense implementation making it a solid candidate :)


Thanks for the tip Andre !


What you actually should do when working with money which is what 
a lot of banking solutions etc. do is working with cents only in 
2 decimal places.


So 25.98 would be represented as 2598.

It makes sure that you’ll never have rounding errors or floating 
point representations that are wrong.


Re: Trivial simple OpenGl working example

2021-07-08 Thread Виталий Фадеев via Digitalmars-d-learn

On Thursday, 8 July 2021 at 16:01:37 UTC, Dennis wrote:

On Thursday, 8 July 2021 at 14:20:16 UTC, Виталий Фадеев wrote:

Has dub flag for disable "warnings are treated as errors" ?


You have to edit the package file to include `buildRequirements 
"allowWarnings"`, see 
https://dub.pm/package-format-sdl.html#build-requirements


Dennis. thank.

# gfm7/examples/simpleshader/dub.json
{
"targetType": "executable",
"name": "simpleshader",
"sourcePaths": [ "." ],
"importPaths": [ "." ],
"mainSourceFile": "simpleshader.d",

"dependencies":
{
"gfm7:sdl2": {"path": "../../",.
"buildRequirements": [ "allowWarnings" ]
},
"gfm7:opengl": {"path": "../../"},
"gfm7:logger": {"path": "../../"}
},
"versions": [ "SDL_205", "GL_33", "GL_ARB"],

"buildRequirements": [ "allowWarnings" ]
}


No effect. Same error.
I fix source code, as drug say.




Re: Trivial simple OpenGl working example

2021-07-08 Thread Guillaume Piolat via Digitalmars-d-learn

On Thursday, 8 July 2021 at 14:09:30 UTC, drug wrote:

08.07.2021 16:51, Виталий Фадеев пишет:

Hi!

I searching trivial simple D/OpenGL working in 2021 year 
example.


It may be triangle.
It may be based on any library: SDL, GLFW, Derelict, etc.

Can you help me ?



https://github.com/drug007/gfm7/tree/master/examples/simpleshader

it's not trivial though but it works (tested in linux)
just `dub fetch gfm7` then go to 
`path\to\gfm7\examples\simpleshader` and run `dub`.


All kudos to Guillaume Piolat, original author of gfm library.


If like me you hate OpenGL :) you can can also get 
software-rendered DPI-aware triangles with the "turtle" package:

https://code.dlang.org/packages/turtle

(Courtesy of Cerjones for the software renderer. )


Re: float price; if (price == float.nan) { // initialized } else { // uninitialized } ... valid ?

2021-07-08 Thread bauss via Digitalmars-d-learn

On Wednesday, 30 June 2021 at 16:19:35 UTC, someone wrote:

On Wednesday, 30 June 2021 at 10:38:05 UTC, jmh530 wrote:


You've never given something away for free?


... more often than usual LoL

Now, seriously, something for free has not a price = 0, it has 
NO price, that's what null is for; we use zero for the lack of 
null.


Actually a price can be 0, say if you have a sale that gives 100 
% off then the price doesn’t magically disappear. It could be 
that the 100 % off is only for specific people or businesses. Or 
that they pay fees instead of the price of a product, in which 
case there’s a fee price but a product with the price of 0 
because otherwise you’ll have accounting problems since you can’t 
make accounting on records without prices, because mathematically 
that makes no sense.


Re: Trivial simple OpenGl working example

2021-07-08 Thread Виталий Фадеев via Digitalmars-d-learn

On Thursday, 8 July 2021 at 15:57:53 UTC, drug wrote:

08.07.2021 18:46, Виталий Фадеев пишет:

On Thursday, 8 July 2021 at 15:30:07 UTC, drug wrote:

08.07.2021 17:20, Виталий Фадеев пишет:

[...]


I failed to reproduce that. What platform you use and what is 
the compiler version?


drug, Linux, Ubuntu, x64
# uname -a
Linux unknown 5.11.0-22-generic #23-Ubuntu SMP Thu Jun 17 
00:34:23 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux


# dmd --version
DMD64 D Compiler v2.097.0

# dub --version
DUB version 1.26.0, built on Jun  3 2021

#  pkg-config --modversion sdl2
2.0.14


Yes, it's reproducible with dmd 2.097. Trivial fix is deleting 
that line `../../sdl2/gfm/sdl2/timer.d:69` then it works.


Thank, drug.
I think some like this:

  env DFLAGS=-wi dub run

or like this

  "buildRequirements": [ "allowWarnings" ]

without gfm/sdl2/timer.d editing.

Yes, you right. It can be removed. I will do it.

try
{
SDL2Timer timer = cast(SDL2Timer)param;
return timer.onTimer(interval);
}
catch (Throwable e)
{
// No Throwable is supposed to cross C callbacks 
boundaries

// Crash immediately
exit(-1);
return 0; // <--HERE WARMING
}

It is worked! Thank!




Re: Trivial simple OpenGl working example

2021-07-08 Thread drug via Digitalmars-d-learn

08.07.2021 18:46, Виталий Фадеев пишет:

On Thursday, 8 July 2021 at 15:30:07 UTC, drug wrote:

08.07.2021 17:20, Виталий Фадеев пишет:

[...]


I failed to reproduce that. What platform you use and what is the 
compiler version?


drug, Linux, Ubuntu, x64
# uname -a
Linux unknown 5.11.0-22-generic #23-Ubuntu SMP Thu Jun 17 00:34:23 UTC 
2021 x86_64 x86_64 x86_64 GNU/Linux


# dmd --version
DMD64 D Compiler v2.097.0

# dub --version
DUB version 1.26.0, built on Jun  3 2021

#  pkg-config --modversion sdl2
2.0.14


Yes, it's reproducible with dmd 2.097. Trivial fix is deleting that line 
`../../sdl2/gfm/sdl2/timer.d:69` then it works.


Re: Trivial simple OpenGl working example

2021-07-08 Thread Dennis via Digitalmars-d-learn

On Thursday, 8 July 2021 at 14:20:16 UTC, Виталий Фадеев wrote:

Has dub flag for disable "warnings are treated as errors" ?


You have to edit the package file to include `buildRequirements 
"allowWarnings"`, see 
https://dub.pm/package-format-sdl.html#build-requirements


Re: Trivial simple OpenGl working example

2021-07-08 Thread Виталий Фадеев via Digitalmars-d-learn

On Thursday, 8 July 2021 at 15:30:07 UTC, drug wrote:

08.07.2021 17:20, Виталий Фадеев пишет:

[...]


I failed to reproduce that. What platform you use and what is 
the compiler version?


drug, Linux, Ubuntu, x64
# uname -a
Linux unknown 5.11.0-22-generic #23-Ubuntu SMP Thu Jun 17 
00:34:23 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux


# dmd --version
DMD64 D Compiler v2.097.0

# dub --version
DUB version 1.26.0, built on Jun  3 2021

#  pkg-config --modversion sdl2
2.0.14


Re: Trivial simple OpenGl working example

2021-07-08 Thread drug via Digitalmars-d-learn

08.07.2021 17:20, Виталий Фадеев пишет:


vital@unknown:~/src/dtest/working-example/gfm7/examples/simpleshader$ 
dub run

Fetching bindbc-opengl 0.15.0 (getting selected version)...
Fetching colorize 1.0.5 (getting selected version)...
Fetching gfm 8.0.6 (getting selected version)...
Fetching bindbc-sdl 0.19.2 (getting selected version)...
Fetching intel-intrinsics 1.4.0 (getting selected version)...
Fetching bindbc-loader 0.3.2 (getting selected version)...
Performing "debug" build using /usr/bin/dmd for x86_64.
colorize 1.0.5: building configuration "library"...
gfm7:logger 1.1.1: building configuration "library"...
bindbc-loader 0.3.2: building configuration "noBC"...
bindbc-opengl 0.15.0: building configuration "dynamic"...
intel-intrinsics 1.4.0: building configuration "library"...
gfm:math 8.0.6: building configuration "library"...
gfm7:opengl 1.1.1: building configuration "unittest"...
bindbc-sdl 0.19.2: building configuration "dynamic"...
gfm7:sdl2 1.1.1: building configuration "library"...
../../sdl2/gfm/sdl2/timer.d(69,13): Warning: statement is not reachable
Error: warnings are treated as errors
    Use -wi if you wish to treat warnings only as informational.
/usr/bin/dmd failed with exit code 1.

Error.
Has dub flag for disable "warnings are treated as errors" ?


I failed to reproduce that. What platform you use and what is the 
compiler version?


Re: Trivial simple OpenGl working example

2021-07-08 Thread Виталий Фадеев via Digitalmars-d-learn

On Thursday, 8 July 2021 at 14:20:25 UTC, Adam D Ruppe wrote:

On Thursday, 8 July 2021 at 13:51:51 UTC, Виталий Фадеев wrote:

It may be based on any library: SDL, GLFW, Derelict, etc.


my library

http://arsd-official.dpldocs.info/arsd.simpledisplay.html#topic-modern-opengl

arsd-official:simpledisplay dependency on dub, or just download 
color.d and simpledisplay.d from 
https://github.com/adamdruppe/arsd and compile them with your 
sample program (dmd yourprog.d color.d simpledisplay.d) and you 
should be able to run with it.


but my bindings aren't as complete as the others suggested here.


Adam, thank!


Re: Trivial simple OpenGl working example

2021-07-08 Thread Виталий Фадеев via Digitalmars-d-learn

On Thursday, 8 July 2021 at 14:09:38 UTC, Dennis wrote:

On Thursday, 8 July 2021 at 13:51:51 UTC, Виталий Фадеев wrote:
I searching trivial simple D/OpenGL working in 2021 year 
example.


https://github.com/dkorpel/glfw-d/tree/master/examples/triangle-gl

Uses bindbc-opengl + glfw-d (my package), example uses OpenGL 
3.3. Should works on Windows and Linux out of the box, if not, 
please open an issue.


Dennis, Thank! Worked!
I happy!


Re: Trivial simple OpenGl working example

2021-07-08 Thread Adam D Ruppe via Digitalmars-d-learn

On Thursday, 8 July 2021 at 13:51:51 UTC, Виталий Фадеев wrote:

It may be based on any library: SDL, GLFW, Derelict, etc.


my library

http://arsd-official.dpldocs.info/arsd.simpledisplay.html#topic-modern-opengl

arsd-official:simpledisplay dependency on dub, or just download 
color.d and simpledisplay.d from 
https://github.com/adamdruppe/arsd and compile them with your 
sample program (dmd yourprog.d color.d simpledisplay.d) and you 
should be able to run with it.


but my bindings aren't as complete as the others suggested here.


Re: Trivial simple OpenGl working example

2021-07-08 Thread Виталий Фадеев via Digitalmars-d-learn

On Thursday, 8 July 2021 at 14:09:30 UTC, drug wrote:

08.07.2021 16:51, Виталий Фадеев пишет:

Hi!

I searching trivial simple D/OpenGL working in 2021 year 
example.


It may be triangle.
It may be based on any library: SDL, GLFW, Derelict, etc.

Can you help me ?



https://github.com/drug007/gfm7/tree/master/examples/simpleshader

it's not trivial though but it works (tested in linux)
just `dub fetch gfm7` then go to 
`path\to\gfm7\examples\simpleshader` and run `dub`.


All kudos to Guillaume Piolat, original author of gfm library.


Thank, drug. But llok at this:

vital@unknown:~/src/dtest/working-example/gfm7/examples/simpleshader$ dub run
Fetching bindbc-opengl 0.15.0 (getting selected version)...
Fetching colorize 1.0.5 (getting selected version)...
Fetching gfm 8.0.6 (getting selected version)...
Fetching bindbc-sdl 0.19.2 (getting selected version)...
Fetching intel-intrinsics 1.4.0 (getting selected version)...
Fetching bindbc-loader 0.3.2 (getting selected version)...
Performing "debug" build using /usr/bin/dmd for x86_64.
colorize 1.0.5: building configuration "library"...
gfm7:logger 1.1.1: building configuration "library"...
bindbc-loader 0.3.2: building configuration "noBC"...
bindbc-opengl 0.15.0: building configuration "dynamic"...
intel-intrinsics 1.4.0: building configuration "library"...
gfm:math 8.0.6: building configuration "library"...
gfm7:opengl 1.1.1: building configuration "unittest"...
bindbc-sdl 0.19.2: building configuration "dynamic"...
gfm7:sdl2 1.1.1: building configuration "library"...
../../sdl2/gfm/sdl2/timer.d(69,13): Warning: statement is not 
reachable

Error: warnings are treated as errors
   Use -wi if you wish to treat warnings only as 
informational.

/usr/bin/dmd failed with exit code 1.

Error.
Has dub flag for disable "warnings are treated as errors" ?


Re: Trivial simple OpenGl working example

2021-07-08 Thread Dennis via Digitalmars-d-learn

On Thursday, 8 July 2021 at 13:51:51 UTC, Виталий Фадеев wrote:
I searching trivial simple D/OpenGL working in 2021 year 
example.


https://github.com/dkorpel/glfw-d/tree/master/examples/triangle-gl

Uses bindbc-opengl + glfw-d (my package), example uses OpenGL 
3.3. Should works on Windows and Linux out of the box, if not, 
please open an issue.


Re: Trivial simple OpenGl working example

2021-07-08 Thread drug via Digitalmars-d-learn

08.07.2021 16:51, Виталий Фадеев пишет:

Hi!

I searching trivial simple D/OpenGL working in 2021 year example.

It may be triangle.
It may be based on any library: SDL, GLFW, Derelict, etc.

Can you help me ?



https://github.com/drug007/gfm7/tree/master/examples/simpleshader

it's not trivial though but it works (tested in linux)
just `dub fetch gfm7` then go to `path\to\gfm7\examples\simpleshader` 
and run `dub`.


All kudos to Guillaume Piolat, original author of gfm library.


Trivial simple OpenGl working example

2021-07-08 Thread Виталий Фадеев via Digitalmars-d-learn

Hi!

I searching trivial simple D/OpenGL working in 2021 year example.

It may be triangle.
It may be based on any library: SDL, GLFW, Derelict, etc.

Can you help me ?



Re: What is the D equivalent of C++'s method pointers?

2021-07-08 Thread Tejas via Digitalmars-d-learn

On Thursday, 8 July 2021 at 12:04:01 UTC, Paul Backus wrote:


https://digitalmars.com/articles/b68.html


Thank you very much :D



Re: What is the D equivalent of C++'s method pointers?

2021-07-08 Thread Paul Backus via Digitalmars-d-learn

On Thursday, 8 July 2021 at 11:53:42 UTC, Tejas wrote:

Given a class ```Employee``` , if I have the following code
```
int (Employee::*methodPtr) () const { ::getSalary };
Employee employee { "John", "Doe" };
cout << (employee.*methodPtr)() << endl;

```

What is the equivalent D code?

Ditto for pointer to class instances:

```
int (Employee::*methodPtr) () const { ::getSalary };
Employee* employee { new Employee { "John", "Doe" } };
cout << (employee->*methodPtr)() << endl;

```


https://digitalmars.com/articles/b68.html


Re: What is the D equivalent of C++'s method pointers?

2021-07-08 Thread Tejas via Digitalmars-d-learn

On Thursday, 8 July 2021 at 11:53:42 UTC, Tejas wrote:

Given a class ```Employee``` , if I have the following code
```
int (Employee::*methodPtr) () const { ::getSalary };
Employee employee { "John", "Doe" };
cout << (employee.*methodPtr)() << endl;

```

What is the equivalent D code?

Ditto for pointer to class instances:

```
int (Employee::*methodPtr) () const { ::getSalary };
Employee* employee { new Employee { "John", "Doe" } };
cout << (employee->*methodPtr)() << endl;

```


All I found was this post from 2005(!):

https://forum.dlang.org/thread/dfhe54$1ipt$1...@digitaldaemon.com




What is the D equivalent of C++'s method pointers?

2021-07-08 Thread Tejas via Digitalmars-d-learn

Given a class ```Employee``` , if I have the following code
```
int (Employee::*methodPtr) () const { ::getSalary };
Employee employee { "John", "Doe" };
cout << (employee.*methodPtr)() << endl;

```

What is the equivalent D code?

Ditto for pointer to class instances:

```
int (Employee::*methodPtr) () const { ::getSalary };
Employee* employee { new Employee { "John", "Doe" } };
cout << (employee->*methodPtr)() << endl;

```


Re: Download a file into array (using std.net.curl.download)

2021-07-08 Thread notna via Digitalmars-d-learn
On Wednesday, 7 July 2021 at 13:49:50 UTC, MoonlightSentinel 
wrote:

On Wednesday, 7 July 2021 at 10:27:47 UTC, notna wrote:

On Windows:
[...]
Nice and helpful Error messages is on the top of our desires 
list, right?


It's hard to give proper error backtraces without debug 
information (-g).
Anyways, I can reproduce the error when compiling with `-m32` 
(the default), using `-m32mscoff` and `-m64` works as expected. 
You should probably avoid `-m32` in general (as dub does btw).


for what it's worth...

due to license restrictions and costs we are not allowed to have 
the MS toolchain installed on our office clients... tried it now 
@HOME with the '-m64' switch anabled, as suggested by you, and 
can confirm, it also "just works"...


Re: how to make D program footprint smaller ?

2021-07-08 Thread russhy via Digitalmars-d-learn

On Thursday, 8 July 2021 at 10:01:33 UTC, dangbinghoo wrote:

I have tried to add

```
  "dflags": ["--link-defaultlib-shared"],
  "lflags": ["--as-needed"],
```

to dub.json, and my compiler is ldc2, with 800 loc program used 
`hibernated` and `asdf` package. it compiled to 27MB binary not 
stripped and even 4MB size after stripped. (When compiled to 
ARM, the binary is 3.6MB which is a little bit smaller, but 
link flags won't opt. this either!)


I tried the link flags above, but it seems that the stripped 
binary is in some size.


any suggestions for optimizing this?


thanks!
---
dbh


try:

```
"dflags-ldc": [
"-linkonce-templates",
"--Oz"
],
```

but yeah
Are you using lot of templates in your code? buffer as global?

my 20k LOC game's exe is only just 1.46mb (on windows), but 
that's because i don't use std at all


how to make D program footprint smaller ?

2021-07-08 Thread dangbinghoo via Digitalmars-d-learn

I have tried to add

```
  "dflags": ["--link-defaultlib-shared"],
  "lflags": ["--as-needed"],
```

to dub.json, and my compiler is ldc2, with 800 loc program used 
`hibernated` and `asdf` package. it compiled to 27MB binary not 
stripped and even 4MB size after stripped. (When compiled to ARM, 
the binary is 3.6MB which is a little bit smaller, but link flags 
won't opt. this either!)


I tried the link flags above, but it seems that the stripped 
binary is in some size.


any suggestions for optimizing this?


thanks!
---
dbh