OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

Cross-platform examples for Linux, macOS, Windows, Android, iOS, and Web


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> Announcement [ANN]
View previous topic :: View next topic  
Author Message
kornerr
Appreciator


Joined: 01 Oct 2013
Posts: 283

PostPosted: Tue Aug 14, 2018 10:51 am    Post subject:
Cross-platform examples for Linux, macOS, Windows, Android, iOS, and Web
Reply with quote

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
On Tue, 17 Apr 2018 at 13:28, Alberto Luaces <> wrote:
Quote:

michael kapelko writes:

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

Thanks, nice resource!

--
Alberto




------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
kornerr
Appreciator


Joined: 01 Oct 2013
Posts: 283

PostPosted: Tue Sep 25, 2018 9:08 am    Post subject:
Cross-platform examples for Linux, macOS, Windows, Android, iOS, and Web
Reply with quote

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
On Tue, 14 Aug 2018 at 13:51, michael kapelko <> wrote:
Quote:

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
On Tue, 17 Apr 2018 at 13:28, Alberto Luaces <> wrote:
Quote:

michael kapelko writes:

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

Thanks, nice resource!

--
Alberto




------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12145

PostPosted: Tue Sep 25, 2018 2:21 pm    Post subject:
Cross-platform examples for Linux, macOS, Windows, Android, iOS, and Web
Reply with quote

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.


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
kornerr
Appreciator


Joined: 01 Oct 2013
Posts: 283

PostPosted: Wed Sep 26, 2018 8:16 am    Post subject:
Cross-platform examples for Linux, macOS, Windows, Android, iOS, and Web
Reply with quote

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

On Tue, 25 Sep 2018 at 17:21, Robert Osfield <> wrote:
Quote:

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.



------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12145

PostPosted: Wed Sep 26, 2018 2:17 pm    Post subject:
Cross-platform examples for Linux, macOS, Windows, Android, iOS, and Web
Reply with quote

Hi Michael,

On Wed, 26 Sep 2018 at 09:16, michael kapelko <> wrote:
Quote:
I started to use explicit `this` to simplify reading and increase
"shareability" of code:

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.

Quote:
* 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.

Quote:
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 Smile

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.


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
kornerr
Appreciator


Joined: 01 Oct 2013
Posts: 283

PostPosted: Fri Sep 28, 2018 11:13 am    Post subject:
Cross-platform examples for Linux, macOS, Windows, Android, iOS, and Web
Reply with quote

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.

On Wed, 26 Sep 2018 at 17:17, Robert Osfield <> wrote:
Quote:

Hi Michael,

On Wed, 26 Sep 2018 at 09:16, michael kapelko <> wrote:
Quote:
I started to use explicit `this` to simplify reading and increase
"shareability" of code:

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.

Quote:
* 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.

Quote:
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 Smile

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.



------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12145

PostPosted: Fri Sep 28, 2018 1:48 pm    Post subject:
Cross-platform examples for Linux, macOS, Windows, Android, iOS, and Web
Reply with quote

On Fri, 28 Sep 2018 at 12:13, michael kapelko <> wrote:
Quote:
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


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> Announcement [ANN] All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts A question of "ShaderPipeline di... loening General 0 Tue Nov 13, 2018 5:31 pm View latest post
No new posts Building on macOS 10.14 Ulrich Hertlein General 1 Sun Nov 11, 2018 12:45 pm View latest post
No new posts Unable to run example (QTCreator, CMa... Nirodha General [forum] 1 Wed Oct 31, 2018 11:04 pm View latest post
No new posts OSG 3.6.3 Windows VC++ Binaries Posted DeadParrot Announcement [ANN] 3 Mon Oct 29, 2018 8:48 pm View latest post
No new posts Osgdem created terrains not displayin... D.J. Caldwell General 3 Wed Oct 24, 2018 7:32 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP