Re: Trivial simple OpenGl working example

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

On Saturday, 10 July 2021 at 19:43:07 UTC, Danny Arends wrote:

On Saturday, 10 July 2021 at 12:41:19 UTC, Виталий Фадеев wrote:

[...]


Just disable shader compilation using dub, the shader only 
needs to be compiled once. Since you're on linux it fails to 
execute glslc.exe (the windows executable). If you compiled 
them yourself you can remove it from dub prebuild commands


Thanks, Danny Arends!
I fixed the configuration in dub.json, and in the application.d I 
fixed VK_API_VERSION_1_0. It worked!


Look in to the pull requests:

https://github.com/DannyArends/CalderaD/pulls



Re: Trivial simple OpenGl working example

2021-07-10 Thread Danny Arends via Digitalmars-d-learn

On Saturday, 10 July 2021 at 12:41:19 UTC, Виталий Фадеев wrote:

On Saturday, 10 July 2021 at 08:36:07 UTC, Danny Arends wrote:

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

[...]


OpenGL is being replaced by vulcan, just to plug my little 
project:


http://github.com/DannyArends/CalderaD

Pretty beafy, but well vulkan is a lot more verbose compared 
to OpenGL


Thank, Danny Arends! I see you.

I got error:

# glslc app/src/main/assets/data/shaders/wavefront.vert -o 
app/src/main/assets/data/shaders/vert.spv


# glslc app/src/main/assets/data/shaders/wavefront.frag -o 
app/src/main/assets/data/shaders/frag.spv


# dub
Performing "debug" build using /usr/bin/dmd for x86_64.
bindbc-loader 0.3.2: target for configuration "yesBC" is up to 
date.
bindbc-sdl 0.21.4: target for configuration "dynamicBC" is up 
to date.

calderad ~master: building configuration "default"...
Running pre-build commands...
/bin/sh: 1: glslc.exe: not found
Command failed with exit code 127: glslc.exe 
app/src/main/assets/data/shaders/wavefront.vert -o 
app/src/main/assets/data/shaders/vert.spv


Just disable shader compilation using dub, the shader only needs 
to be compiled once. Since you're on linux it fails to execute 
glslc.exe (the windows executable). If you compiled them yourself 
you can remove it from dub prebuild commands


Re: Trivial simple OpenGl working example

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

On Saturday, 10 July 2021 at 08:36:07 UTC, Danny Arends wrote:

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 ?


OpenGL is being replaced by vulcan, just to plug my little 
project:


http://github.com/DannyArends/CalderaD

Pretty beafy, but well vulkan is a lot more verbose compared to 
OpenGL


Thank, Danny Arends! I see you.

I got error:

# glslc app/src/main/assets/data/shaders/wavefront.vert -o 
app/src/main/assets/data/shaders/vert.spv


# glslc app/src/main/assets/data/shaders/wavefront.frag -o 
app/src/main/assets/data/shaders/frag.spv


# dub
Performing "debug" build using /usr/bin/dmd for x86_64.
bindbc-loader 0.3.2: target for configuration "yesBC" is up to 
date.
bindbc-sdl 0.21.4: target for configuration "dynamicBC" is up to 
date.

calderad ~master: building configuration "default"...
Running pre-build commands...
/bin/sh: 1: glslc.exe: not found
Command failed with exit code 127: glslc.exe 
app/src/main/assets/data/shaders/wavefront.vert -o 
app/src/main/assets/data/shaders/vert.spv





Re: Trivial simple OpenGl working example

2021-07-10 Thread Danny Arends 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 ?


OpenGL is being replaced by vulcan, just to plug my little 
project:


http://github.com/DannyArends/CalderaD

Pretty beafy, but well vulkan is a lot more verbose compared to 
OpenGL




Re: Trivial simple OpenGl working example

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

On Friday, 9 July 2021 at 19:15:44 UTC, H. S. Teoh wrote:
On Fri, Jul 09, 2021 at 05:11:06AM +, Виталий Фадеев via 
Digitalmars-d-learn wrote: [...]

[...]

[...]

[...]


Generally, text rendering on OpenGL is a huge pain to 
implement. This is not specific to D, but to OpenGL in general, 
because OpenGL itself does not have direct support for text 
rendering at all.  The usual route is to use an existing 
text-rendering library like FreeType to rasterize your text, 
then upload it as a texture to the GPU and render it as a quad.


[...]


Thank, H. S. Teoh!


Re: Trivial simple OpenGl working example

2021-07-09 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jul 09, 2021 at 05:11:06AM +, Виталий Фадеев via 
Digitalmars-d-learn wrote:
[...]
> 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.
[...]
> What about text rendering ?

Generally, text rendering on OpenGL is a huge pain to implement. This is
not specific to D, but to OpenGL in general, because OpenGL itself does
not have direct support for text rendering at all.  The usual route is
to use an existing text-rendering library like FreeType to rasterize
your text, then upload it as a texture to the GPU and render it as a
quad.

If you want to do a more modern approach, you could use signed distance
fields, but that requires some deep knowledge of how shaders work unless
you can find an off-the-shelf library that does it for you. You may
still end up needing FreeType or equivalent anyway, to get the SDFs in
the first place.

Here's something to start you off, if you don't already have an approach
in mind:

https://learnopengl.com/In-Practice/Text-Rendering


T

-- 
Chance favours the prepared mind. -- Louis Pasteur


Re: Trivial simple OpenGl working example

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

On Friday, 9 July 2021 at 06:16:08 UTC, Ferhat Kurtulmuş wrote:

On Friday, 9 July 2021 at 05:17:28 UTC, Виталий Фадеев wrote:

[...]



[...]


Dear Vitaly (Google translates it like that :)), I didn't touch 
that game for a while. I have just tried to compile and those 
are the steps to build and run it:


[...]


You may also need to use the exact version of "bettercmath": 
"0.3.1".


Re: Trivial simple OpenGl working example

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

On Friday, 9 July 2021 at 05:17:28 UTC, Виталий Фадеев wrote:
On Thursday, 8 July 2021 at 17:20:14 UTC, Ferhat Kurtulmuş 
wrote:

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

Hi!




Each ends with error.


Dear Vitaly (Google translates it like that :)), I didn't touch 
that game for a while. I have just tried to compile and those are 
the steps to build and run it:


Using a Windows 10 x64. (Webassembly build needs crazy efforts, 
don't try it for now. If you are on a posix system please delete 
*.a folders from the root folder because they are for webassembly)


1) Open the dub.json or dub.selections.json, and change "bcaa": 
"~>0.0.5" to "bcaa": "0.0.5" (Recently a contributor and I have 
made some breaking changes in bcaa).


2) Have those lib and dll files in the root folder of the project:

chipmunk.lib // I manually compiled this one
libfreetype-6.dl
libjpeg-9.dll
libpng16-16.dll
libtiff-5.dll
libwebp-7.dll
SDL2_image.dll
SDL2_image.lib
SDL2_ttf.dll
SDL2_ttf.lib
SDL2.dll
SDL2.lib
zlib1.dll

basically, those are win 64-bit builds of SDL2, its friends, and 
their dependencies. If you provide an email, I can send them to 
you via wetransfer.


For posix builds, you will have to figure those out.


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: 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: 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: 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 ?