virtualglobebook / OpenGlobe

A 3D engine for virtual globes (think Google Earth or NASA World Wind) designed to illustrate the engine design and rendering techniques described in our book. OpenGlobe is written in C# and uses OpenGL 3.3 core profile (via OpenTK). See the web site linked below for more information
http://www.virtualglobebook.com
Other
346 stars 113 forks source link

Private void Dispose(bool disposing) method in GL3x Names classes are confusing #4

Open PlutoniumHeart opened 10 years ago

PlutoniumHeart commented 10 years ago

Hi, I am going through the code in Source/Renderer/GL3x/Names folder, and noticed that the private methods used in those classes take a bool type input 'disposing' however this input is never used in this method. Is there a particular reason why it should take a bool type input?

I am also not quite sure why in the FinalizerThreadContextGL3x class we will have to create a NtiveWindow and GraphicsContext.

Thank you!

pjcozzi commented 10 years ago

The Dispose methods are part of the IDisposable interface so we have to implement both functions. See http://msdn.microsoft.com/en-us/library/system.idisposable(v=vs.110).aspx

// Dispose(bool disposing) executes in two distinct scenarios. 
// If disposing equals true, the method has been called directly 
// or indirectly by a user's code. Managed and unmanaged resources 
// can be disposed. 
// If disposing equals false, the method has been called by the 
// runtime from inside the finalizer and you should not reference 
// other objects. Only unmanaged resources can be disposed. 

Its been a few years, but I believe object destructors (like in TextureNameGL3x, for example) may be called when no GL context is current, so FinalizerThreadContextGL3x ensures a shared context is current so the GL resource can be deleted.

Also, @kring and I are not really maintaining this project other than merging the occasional pull request. If you are interested in an open-source web globe, we are working on Cesium.

PlutoniumHeart commented 10 years ago

Thank you very much for the reply, I understand that this code is not maintained any more, I was reading the book. By the way, when I read about the Tessellation part, I thought you guys are going to talk about the tessellation shader, but then the shader was not in the 3.3 core profile, do you think tessellation discussed in chapter 4 can be achieved by using tessellation shader in GL4?

Also I took a look at Cesium, I am not quite sure if I like WebGL or programming in a browser at all... And I am most familiar with C/C++, and only has limited knowledge about C# (That's why I am asking this simple question), and has no idea about Java at all. I followed the Cesium repository for sometime, and I can see it is very active, may be in time, I will start learning Java, and participate in it as well.

pjcozzi commented 10 years ago

do you think tessellation discussed in chapter 4 can be achieved by using tessellation shader in GL4?

Definitely. Here's a good intro to tessellation shaders: http://prideout.net/blog/?p=48