使用棧中的資源管理堆中的東西
osg環境已經配置好的基礎上,**只是為了讓大家理解超級指標這個概念,有很多**的地方還是不太恰當,比如友元類的使用上,大家不必細究。
#include
#include
#include
#ifdef _debug
#pragma comment(lib, "osgd.lib")
#pragma comment(lib, "osggad.lib")
#pragma comment(lib, "osgdbd.lib")
#pragma comment(lib, "osgutild.lib")
#pragma comment(lib, "os**iewerd.lib")
#else
#pragma comment(lib, "osg.lib")
#pragma comment(lib, "osgga.lib")
#pragma comment(lib, "osgdb.lib")
#pragma comment(lib, "osgutil.lib")
#pragma comment(lib, "os**iewer.lib")
#pragma comment(lib, "openthreads.lib")
#endif
class
real
~real()
void
ref(
)void
unref()
}private
:int count;};
template
<
class
t>
class
ref_pter
ref_pter
(t *ptr)}~
ref_pter()
} ref_pter operator
=(t *pa)
if(temp)
return
*this;}
t*get(
)operator t *()
const
t*operator
->()
t*operator*(
)private
: t * _ptr;};
void
main()
#include
#include
#include
#ifdef _debug
#pragma comment(lib, "osgd.lib")
#pragma comment(lib, "osggad.lib")
#pragma comment(lib, "osgdbd.lib")
#pragma comment(lib, "osgutild.lib")
#pragma comment(lib, "os**iewerd.lib")
#else
#pragma comment(lib, "osg.lib")
#pragma comment(lib, "osgga.lib")
#pragma comment(lib, "osgdb.lib")
#pragma comment(lib, "osgutil.lib")
#pragma comment(lib, "os**iewer.lib")
#pragma comment(lib, "openthreads.lib")
#endif
class
real
~real()
void
ref(
)void
unref()
}public
:int count;};
template
<
class
t>
class
ref_pter
ref_pter
(t *ptr)}~
ref_pter()
} ref_pter operator
=(t *pa)
if(temp)
return
*this;}
t*get(
)operator t *()
const
t*operator
->()
t*operator*(
)private
: t * _ptr;};
void
main()
*** 備註:其中的ref()函式和unref函式,都是osg本身的函式,所以名字只能叫這個,如果改一下函式名可能就會有錯誤,具體深入的了解,還要看一下openscenegraph的原始碼。 OSG智慧型指標 osg ref ptr
在osg開發時 特別是剛上手 有一點比較重要然後容易忽略的是,在osg程式開發中,要盡量使用osg ref ptr。這個智慧型指標構建起osg的物件樹 絕大部分osg類都是繼承於osg referenced,即可計數物件 類似於qt的物件樹,負責其記憶體的管理。當然其記憶體管理策略不是我們關心的,我...
osg多執行緒 osg小結
還有很多osg的功能沒有涉及到。osg的人機互動 osg動畫 osg讀寫機制 osg的動態更新和裁剪 osg的多執行緒渲染 等等。由於這些功能不能簡單到靠乙個例子可以講解明白,所以我打算把他們放到osg 部分闡述。好,那做一下總結前幾篇主要是介紹一些osg的基礎功能,以及基礎概念。對於很多大牛來說我...
osg專案小結
乙個說大不大,說小又不小的專案終於差不多做完了,本以為可以休息下然後好好的做個總結,沒想到下乙個更大的專案又來了。這樣只能隨便總結下了遇到的問題及教訓。1,遇到問題怎麼辦?首先不急,不要浮躁,靜下心來。特別是當乙個問題花了一天,兩天,甚至乙個星期,乙個月都沒能解決的時候,自己就會變得很浮躁,失去耐心...