Discussion:
[osg-users] [ANN] Cross-platform examples for Linux, macOS, Windows, Android, iOS, and Web
michael kapelko
2018-04-09 09:30:53 UTC
Permalink
Hi.

TL;DR
All hail the first cross-platform example on how to embed a binary
resource into executable:
https://github.com/OGStudio/openscenegraph-cross-platform-examples/blob/master/01.EmbedResource/README.md

Lengthy explanation.

Once the OpenSceneGraph cross-platform guide (
https://ogstudio.github.io/openscenegraph-cross-platform-guide/ ) has
been finished, I started developing a cross-platform game (
https://ogstudio.github.io/game-mahjong/ ).

Overtime I started to face different issues across platforms like
loading resources, loading images, etc.. It became clear that I should
share this knowledge. That's how cross-platform examples appeared:
https://github.com/OGStudio/openscenegraph-cross-platform-examples

Unlike the guide, examples are brief, don't provide videos and
screenshots for each step. Instead, each example focuses on the
crucial code necessary to perform a task.

I would be glad to hear of any specific thing you wanted explained for
OpenSceneGraph that might make a good addition to the examples.
HITESH KUMAR SINGHAL
2018-04-10 14:19:09 UTC
Permalink
Post by michael kapelko
Hi.
TL;DR
All hail the first cross-platform example on how to embed a binary
https://github.com/OGStudio/openscenegraph-cross-platform-examples/blob/master/01.EmbedResource/README.md
Lengthy explanation.
Once the OpenSceneGraph cross-platform guide (
https://ogstudio.github.io/openscenegraph-cross-platform-guide/ ) has
been finished, I started developing a cross-platform game (
https://ogstudio.github.io/game-mahjong/ ).
Overtime I started to face different issues across platforms like
loading resources, loading images, etc.. It became clear that I should
https://github.com/OGStudio/openscenegraph-cross-platform-examples
Unlike the guide, examples are brief, don't provide videos and
screenshots for each step. Instead, each example focuses on the
crucial code necessary to perform a task.
I would be glad to hear of any specific thing you wanted explained for
OpenSceneGraph that might make a good addition to the examples.
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
michael kapelko
2018-04-17 09:15:42 UTC
Permalink
Hi.

All hail the second cross-platform example on how to use PNG images
(embedded into application) with PNG/ImageIO plugins:
https://github.com/OGStudio/openscenegraph-cross-platform-examples/tree/master/02.TextureImage
Post by michael kapelko
Post by michael kapelko
Hi.
TL;DR
All hail the first cross-platform example on how to embed a binary
https://github.com/OGStudio/openscenegraph-cross-platform-examples/blob/master/01.EmbedResource/README.md
Lengthy explanation.
Once the OpenSceneGraph cross-platform guide (
https://ogstudio.github.io/openscenegraph-cross-platform-guide/ ) has
been finished, I started developing a cross-platform game (
https://ogstudio.github.io/game-mahjong/ ).
Overtime I started to face different issues across platforms like
loading resources, loading images, etc.. It became clear that I should
https://github.com/OGStudio/openscenegraph-cross-platform-examples
Unlike the guide, examples are brief, don't provide videos and
screenshots for each step. Instead, each example focuses on the
crucial code necessary to perform a task.
I would be glad to hear of any specific thing you wanted explained for
OpenSceneGraph that might make a good addition to the examples.
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Alberto Luaces
2018-04-17 10:28:21 UTC
Permalink
Post by michael kapelko
Hi.
All hail the second cross-platform example on how to use PNG images
https://github.com/OGStudio/openscenegraph-cross-platform-examples/tree/master/02.TextureImage
Thanks, nice resource!
--
Alberto
michael kapelko
2018-08-14 10:51:10 UTC
Permalink
Hi.

I've created three new cross-platform examples:

* HTTP(s) client (Mongoose, NSURLSession, HttpUrlConnection, Fetch API)
* Remote debugging (OSG app, intermediate Node.js server, JS debug UI)
* Node selection (handling input under Android and Web (Emscripten) )

They are available here:
https://github.com/OGStudio/openscenegraph-cross-platform-examples
Post by Alberto Luaces
Post by michael kapelko
Hi.
All hail the second cross-platform example on how to use PNG images
https://github.com/OGStudio/openscenegraph-cross-platform-examples/tree/master/02.TextureImage
Thanks, nice resource!
--
Alberto
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
michael kapelko
2018-09-25 09:08:56 UTC
Permalink
Hi.

I've created a new cross-platform example on running a sequence of
asynchronous operations (network loading, animations, etc):
https://github.com/OGStudio/openscenegraph-cross-platform-examples/tree/master/06.CommandSequence
Try the sample in your web browser (click on the box):
https://ogstudio.github.io/openscenegraph-cross-platform-examples-web-builds/examples/06/ex06-command-sequence.html
Post by michael kapelko
Hi.
* HTTP(s) client (Mongoose, NSURLSession, HttpUrlConnection, Fetch API)
* Remote debugging (OSG app, intermediate Node.js server, JS debug UI)
* Node selection (handling input under Android and Web (Emscripten) )
https://github.com/OGStudio/openscenegraph-cross-platform-examples
Post by Alberto Luaces
Post by michael kapelko
Hi.
All hail the second cross-platform example on how to use PNG images
https://github.com/OGStudio/openscenegraph-cross-platform-examples/tree/master/02.TextureImage
Thanks, nice resource!
--
Alberto
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Robert Osfield
2018-09-25 14:21:29 UTC
Permalink
Hi Michael,

Thanks for creating the new tutorial.

I had a quick look at the examples repository and am curious why do
you use "this->" every time you access a member variable or method?

Personally, as a style of coding I find it a bit odd to see it used so
pervasively, it's unusually enough that I found myself trying to
figure out what special reason there was in the code to do this, came
away confused about it's intent.

Cheers,
Robert.
michael kapelko
2018-09-26 08:15:40 UTC
Permalink
Hi, Robert.

I started to use explicit `this` to simplify reading and increase
"shareability" of code:
* I don't need to rely on IDE to highlight member or local
variables/functions for me, so I can get away with simpler and faster
tools (VIM, in my case)
* I can paste such code blocks anywhere, and a reader won't need to
run IDE to know this is member or local variable/function/etc.

So far this approach looks better to me. When I see code referencing
member variables/functions without `this`, I need to know what
particular color IDE uses to tell member/local variables apart. And to
make things more complicated, different IDEs use different colors :)
Post by Robert Osfield
Hi Michael,
Thanks for creating the new tutorial.
I had a quick look at the examples repository and am curious why do
you use "this->" every time you access a member variable or method?
Personally, as a style of coding I find it a bit odd to see it used so
pervasively, it's unusually enough that I found myself trying to
figure out what special reason there was in the code to do this, came
away confused about it's intent.
Cheers,
Robert.
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Robert Osfield
2018-09-26 14:17:23 UTC
Permalink
Hi Michael,
Post by michael kapelko
I started to use explicit `this` to simplify reading and increase
Doing something that very few other developers do is likely to reduce
"shareability", I'm experienced engineer and read lots of third party
code and found myself wondering why the code was different.
Post by michael kapelko
* I don't need to rely on IDE to highlight member or local
variables/functions for me, so I can get away with simpler and faster
tools (VIM, in my case)
* I can paste such code blocks anywhere, and a reader won't need to
run IDE to know this is member or local variable/function/etc.
If the code is well written then it should be relatively clear what a
global functions and what a local method calls. Most modern C++
programs have few global variables and functions so if you see a
function call it's generally safe to assume it's a local method, for
variables then it's most likely the variable is a local or member
variable. For the OSG we just prefect with _ to make it clear it's a
member variable rather than global, other codebases use m_ or keep the
class/structs simple enough that it's clear. Personally I don't use
m_ as I find it distracting and reduces the flow of readability, and
find this-> is even more verbose and distracting.
Post by michael kapelko
So far this approach looks better to me. When I see code referencing
member variables/functions without `this`, I need to know what
particular color IDE uses to tell member/local variables apart. And to
make things more complicated, different IDEs use different colors :)
this-> is a lot of typing you keep having to do just to make your code
intentions clear. Developers are used to code without it and should
be able to work out what is local or member variable/functions pretty
easily if the class/structs are kept straight forward and the member
function kepts small enough that you can see where local variables are
being written.

As for different IDE's doing different things. Personally the first
stop should be making the code clear enough that these bells and
whistles aren't required, and if they are added then the developer
will likely be just using one IDE for majority of their work and
shouldn't end up confused.

Personally I don't use IDE's, I just use the KDE kate editor and read
the class interfaces and implementations, it does highlighting of many
things by not discriminating between member vs local variables etc. I
don't have particular issues trying to read code.

When writing code for others to digest I think it is probably best to
avoid doing things that are unusual, and as a good practice the
CppCoreGuindelines are probably a good place to start as any.

Cheers,
Robert.
michael kapelko
2018-09-28 11:13:01 UTC
Permalink
Hi, Robert.

I agree with you that explicit usage of `this` is not something I see
frequently myself. That's a valid point. I've been on that side, too.
Probably, because I never asked myself about `this`.

My work is related to iOS development, so I've seen Apple ecosystem
migration from Objective-C to Swift. Objective-C requires `self` (aka
`this`), however, Swift does not. There have been debates about `self`
in Swift, too: https://github.com/raywenderlich/swift-style-guide/issues/7
This migration is what made me wonder if using `this` in C++ and
`self` in Swift has benefits.

I'd like to bring a few more thoughts why `this` is better than `_`,
`m`, or `m_`:
* altering variable names to reflect environment (member / local)
always seemed inappropriate to me
* `_`, `m`, or `m_` is really just a shortcut for using `this`

So, since everybody else was already distinguishing local variables
from memeber ones with some sort of Hungarian notation, I just tried
to be honest and use facilities provided by the language itself:
`this` pointer.
In case I find a serious drawback that would cost me hours of
development time, I would definitely go back to `this`less approach.
But so far I've seen no problem with `this` approach.
Post by Robert Osfield
Hi Michael,
Post by michael kapelko
I started to use explicit `this` to simplify reading and increase
Doing something that very few other developers do is likely to reduce
"shareability", I'm experienced engineer and read lots of third party
code and found myself wondering why the code was different.
Post by michael kapelko
* I don't need to rely on IDE to highlight member or local
variables/functions for me, so I can get away with simpler and faster
tools (VIM, in my case)
* I can paste such code blocks anywhere, and a reader won't need to
run IDE to know this is member or local variable/function/etc.
If the code is well written then it should be relatively clear what a
global functions and what a local method calls. Most modern C++
programs have few global variables and functions so if you see a
function call it's generally safe to assume it's a local method, for
variables then it's most likely the variable is a local or member
variable. For the OSG we just prefect with _ to make it clear it's a
member variable rather than global, other codebases use m_ or keep the
class/structs simple enough that it's clear. Personally I don't use
m_ as I find it distracting and reduces the flow of readability, and
find this-> is even more verbose and distracting.
Post by michael kapelko
So far this approach looks better to me. When I see code referencing
member variables/functions without `this`, I need to know what
particular color IDE uses to tell member/local variables apart. And to
make things more complicated, different IDEs use different colors :)
this-> is a lot of typing you keep having to do just to make your code
intentions clear. Developers are used to code without it and should
be able to work out what is local or member variable/functions pretty
easily if the class/structs are kept straight forward and the member
function kepts small enough that you can see where local variables are
being written.
As for different IDE's doing different things. Personally the first
stop should be making the code clear enough that these bells and
whistles aren't required, and if they are added then the developer
will likely be just using one IDE for majority of their work and
shouldn't end up confused.
Personally I don't use IDE's, I just use the KDE kate editor and read
the class interfaces and implementations, it does highlighting of many
things by not discriminating between member vs local variables etc. I
don't have particular issues trying to read code.
When writing code for others to digest I think it is probably best to
avoid doing things that are unusual, and as a good practice the
CppCoreGuindelines are probably a good place to start as any.
Cheers,
Robert.
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Robert Osfield
2018-09-28 13:48:34 UTC
Permalink
Post by michael kapelko
But so far I've seen no problem with `this` approach.
Well it compiles... and technically it's valid C++.

I don't believe it's a good practice though, you can do lots of crazy
things in C++ and still have it compile. The 6 extra characters that
I have to read that takes my concentration away from the important
stuff that has relevant meaning i.e. the variables names and methods
that are being called. The code is less readable. Code that is less
readable takes more effort to understand.

When writing a tutorial for others to learn from it's paramount that
the code is readable and represents best practice so those less
experienced in programming can learn it quicker and adopt those same
good practices. Using this-> isn't best practice C++, it's not even a
good practice, it's a practice that's makes the code less readable.

It makes it hard to recommend users have a look at your tutorials as I
really don't want users adopting dubious practices in their own code.

Robert.




However, for an experienced engineer to come at the code my response
was "WTF is going on here with use of "this->" everywhere". It
confused me what special glude

Continue reading on narkive:
Search results for '[osg-users] [ANN] Cross-platform examples for Linux, macOS, Windows, Android, iOS, and Web' (Questions and Answers)
64
replies
which is better java or c++ ?
started 2015-06-23 09:54:00 UTC
programming & design
Loading...