gcc的declaration does not declare anything
是一個很經(jīng)典的問題
有以下解決方案
1.加上 -fpermissive
2.修改相關(guān)頭文件次序
3.修改當(dāng)前變量名
這不一定是程序的問題(O_O)?
發(fā)布蓋莫音頻引擎1.1版本(第二次發(fā)布)
蓋莫音頻引擎1.1版本是在蓋莫音頻引擎1.0基礎(chǔ)上發(fā)展而來
支持 ogg,wav,mp33種常見音頻格式
使用多線程,流式播放音頻
支持低通,次音效等幾種音效(沒有支持更多音效和xram的原因是機器聲卡能力有限)
真3d音效
可使用于 linux,win2,xbox,蘋果機等平臺
可替代fmod音頻引擎
可在以下幾個站點下載它:
csdn:http://download.csdn.net/source/2137526代碼下載網(wǎng):http://www.libcode.com.cn/show.php?sid=84程序員聯(lián)合網(wǎng):http://www.pudn.com/downloads231/sourcecode/others/detail1090515.htmldemo程序代碼如下:
1 #include <cstdlib>
2 #include <iostream>
3 #include <GEngine/AudioDevice.hpp>
4 #include <cmath>
5
6 using namespace std;
7 using namespace core;
8
9 int main(int argc, char *argv[])
10 {
11 core::AudioDevice* device = InitAudioDevice();
12 uint16 number = device->GetAudioDeviceNumber();
13 cout<<"音頻設(shè)備個數(shù):"<<number<<endl;
14 for(int i = 0; i < number ; i++) //! std::copy(begin.end.ostream
)
15 {
16 std::cout<<device->GetDeviceByIndex(i)<<std::endl;
17 }
18
19 cout<<"init is: "<<device->Init(device->GetDeviceByIndex(0),4,0)<<endl;
20 AudioSource* audio = device->GetAudioSource();
21 AudioListener* listener = device->GetAudioListener();
22 audio->AttachLowPassFiler();
23 audio->AttachAuxiliaryEffect();
24 audio->Play("..\\audio//theme2.ogg",true);
25 audio->SetSourcePosition(Vector3f(10,10,10));
26 audio->SetRelative(false);
27 audio->SetMaxDistance(100);
28 audio->SetMinDistance(10);
29 audio->SetVolume(1.2f);
30 listener->SetPosition(Vector3f(100,10,10));
31 float t = 0.0f;
32 int step = 0;
33 while(1)
34 {
35 if(step == 300)
36 {
37 step = 0;
38 t+= 0.01;
39 }
40 listener->Move(Vector3f(100*sinf(t),0,100*cosf(t)));
41 audio->Move(Vector3f(0,1,-1));
42 step++;
43 }
44 device->Deinit();
45 DeinitAudioDevice();
46
47 system("PAUSE");
48 return EXIT_SUCCESS;
49 }
精簡版的蓋莫音頻引擎只包含1個頭文件,1個a/lib,一個so/dll文件!
發(fā)布版本為win32下的gcc版本
蓋莫家園在這里:
蓋莫Engine游戲引擎網(wǎng):www.gaimo.net蓋莫論壇:http://bbs.gameres.com/showforum.asp?forumid=113許可證:
本版本使用于非商業(yè)完全免費
使用于商業(yè)只需要付給少量許可費以供繼續(xù)開發(fā)和維護即可!
有疑問請聯(lián)系email:ccsdu2009@126.com
成都蓋莫軟件技術(shù)工作室
如果所給例子出現(xiàn)異常請確保已經(jīng)安裝openal,如果異常依然存在則重新編譯示例即可運行
1.出現(xiàn)有些組件不一致的問題則打開注冊表regedit
刪除會話管理器中的PendingFileRenameOperations相
2.安裝front page失敗則操作如下:
找一個安裝好了的vc7.1
復(fù)制C:\Program Files\Common Files\Microsoft Shared\web server extensions\40\bin中的dll到目標機器對應(yīng)位置
3.再次安裝
ok
這是蓋莫游戲引擎的第一次正式發(fā)布
蓋莫游戲引擎是在csdu2004私人書寫的蓋莫游戲引擎基礎(chǔ)上發(fā)展而成
前期以各種方式發(fā)布過0.87,1.03,1.1,1.2,1.3,1.4.1.5,1.6
本次發(fā)布版本為2.10版本
當(dāng)然該版本也是首次正式對外發(fā)布
sdk內(nèi)置16個小demo例子
你可以自由使用本sdk.
當(dāng)然如果發(fā)現(xiàn)任何bug的話請告訴我們以便我們完善之(email:ccsdu2009@126.com)
本次版本采用devc++編寫而成
當(dāng)然你也可以使用codeblock編譯器
如果你有興趣討論本游戲引擎,你可以加入qq群:20997748 蓋莫0群-蓋莫引擎討論
如果你想加入本游戲引擎的開發(fā),請發(fā)郵件到ccsdu2009@126.com
下載在這里(<10M):
代碼下載網(wǎng):
http://www.libcode.com.cn/show.php?sid=83csdn:
http://download.csdn.net/source/2121828附注下次版本更新計劃:
1.進一步調(diào)整引擎構(gòu)架
2.支持3d音效
3.支持視頻播放
4.大幅度使用腳本文件
5.加入公告板
6.二叉樹,八叉樹,四叉樹的使用
7.md2,md3模型的支持
8.物理引擎的進一步強化
9.其他
有些東西由于很少用時間久了就忘了
以后有什么東東的話就放在這里了:
1.vc由dll導(dǎo)出def
e.g:dumpbin /exports avutil.dll /out:avutil.def
2.def 到lib文件
修改生成的def格式如下:
LIBRARY "avformat"
EXPORTS;
av_register_all
guess_format
...
執(zhí)行
lib /def:avformat.def /machine:i386 /out:avformat.lib
c++純虛函數(shù)方法調(diào)用原因:一個可以的原因是由于修改了代碼但是編譯器并沒有及時更新造成的
3.multiple types in one declaration
出現(xiàn)該錯誤的原因可能在于所在行對象的上個數(shù)據(jù)結(jié)構(gòu)末尾缺少一個;所致
摘要: 引擎中的光照系統(tǒng)是在就存在了的只是感覺一直有點問題,索性重新設(shè)計了.光照系統(tǒng)的有關(guān)對象和單元有:渲染基類RenderBase對象基類Object光描述符LightDesc光類Light光管理器LightManager在引擎中我們認識光是一種資源所以光管理器是從資源管理器中獲得的也就是:RefPtr<LightManager> lightmanager = resourcem...
閱讀全文
游戲引擎中的文件系統(tǒng)是非常重要的一環(huán),基本的文件系統(tǒng)功能不外乎以下功能:
1.打開文件
2.檢測文件是否存在
3.獲取給定文件目錄列表
4.文件其它操作
5.各類文件的處理(日志,xml等等)
蓋莫游戲引擎也有必要有自己內(nèi)置的文件系統(tǒng)來管理引擎所使用的文件或者資源。
以下是簡單的測試例子:
1 #include <GEngine/Gaimo.hpp>
2 using namespace std;
3
4 int main(int argc, char **argv)
5 {
6 //! 初始化引擎設(shè)備并得到設(shè)備指針
7 core::Device* device = core::InitDevice("蓋莫引擎文件系統(tǒng)測試");
8 core::Render::SetClearColor(core::Color(0.5f,0.6f,0.6f));
9
10 //! 獲取文件系統(tǒng)指針
11 core::RefPtr<core::FileSystem> filesystem = device->GetFileSystem();
12 //! 獲取引擎資源管理器
13 core::ResourceManager* resmgr = device->GetResourceManager();
14
15 filesystem->AddToSearchPath("..\\font\\font.zip");
16 bool flag = filesystem->IsExists("accid.ttf");
17 if(flag == false)
18 {
19 ShowMessage(不存在字體文件accid.ttf)
20 device->Close();
21 device->Drop();
22 return -1;
23 }
24
25 //! 讀取文件數(shù)據(jù)
26 core::RefPtr<core::ReadFile> file = filesystem->OpenRead("accid.ttf");
27
28 //! 使用給定字體文件(ttf)
29 core::RefPtr<core::Text> font = resmgr->GetText("newfont",file,18);
30
31 int fps;
32 char text[255];
33 BEGIN_LOOP(device)
34 glClear(GL_COLOR_BUFFER_BIT);
35 fps = device->GetFPS();
36 sprintf(text,"fps is: %d",fps);
37 font->Render(540,0,text);
38 font->Render(200,80, "This demo is testing GEngine's FileySystem.");
39 font->Render(250,105, "GaimoSoft Studio.");
40 END_LOOP(device)
41
42 device->Close();
43 device->Drop();
44
45 return 0;
46 }
47
48
下面是簡單的貼圖:

從代碼中可以看出引擎對zip壓縮格式是內(nèi)置支持的
在蓋莫游戲引擎的書寫過程中先后書寫了資源管理器,場景管理器,模型管理器等管理器類.之后感覺很有必要寫一個泛型的管理器類了.這個可以少做一些重復(fù)性的工作了。
管理器類無非就是獲取當(dāng)前對象個數(shù),對象生成,對象按名索取等等
經(jīng)過考慮,草料書寫如下:
1 namespace core
2 {
3
4 ////////////////////////////////////////////////////////////
5 //! 定義引擎泛型管理器類
6 ////////////////////////////////////////////////////////////
7 template<class Obj = Object, class Type = std::string>
8 class Manager
9 {
10 public:
11 typedef Type ThisType;
12 typedef Obj ThisObj;
13 typedef std::map<ThisType,RefPtr<ThisObj> > Table;
14 //! typedef std::map<ThisType,RefPtr<ThisObj> >::iterator TableItr;
15
16 ////////////////////////////////////////////////////////
17 //! 構(gòu)造,析構(gòu)場景管理器
18 ////////////////////////////////////////////////////////
19 Manager(){}
20 virtual ~Manager() = 0;
21 public:
22
23 ////////////////////////////////////////////////////////////
24 /// 獲取當(dāng)前管理器中的對象個數(shù)
25 ////////////////////////////////////////////////////////////
26 inline uint32 GetObjectNumber()const{return objects.size();}
27
28 ////////////////////////////////////////////////////////////
29 /// 檢測當(dāng)前管理器中是否存在對象
30 ////////////////////////////////////////////////////////////
31 inline bool HasObject()const{return !objects.empty();}
32
33 ////////////////////////////////////////////////////////////
34 /// 獲取給定索引的對象(如果對象不存在則生成一個新的對象)
35 ////////////////////////////////////////////////////////////
36 inline RefPtr<Object> GetObject(const Type& name)
37 {
38 if(objects.find(name) != objects.end())
39 return objects[name];
40 return NULL;
41 }
42
43 ////////////////////////////////////////////////////////////
44 /// 生成一個新的對象
45 ////////////////////////////////////////////////////////////
46 virtual RefPtr<ThisObj> CreateObject(const Type& name) = 0;
47
48 ////////////////////////////////////////////////////////////
49 /// 銷毀指定名字的對象
50 ////////////////////////////////////////////////////////////
51 inline bool KillObject(const Type& name)
52 {
53 std::map<std::string,RefPtr<Model> >::iterator itr = objects.find(name);
54 if(itr == objects.end())
55 return false;
56 objects.erase(name);
57 return NULL;
58 }
59
60 ////////////////////////////////////////////////////////////
61 /// 管理器對象清空
62 ////////////////////////////////////////////////////////////
63 inline void ClearObject(){objects.clear();}
64 protected:
65 Table objects;
66 };
67
68 template<class Obj, class Type>
69 Manager<Obj,Type>::~Manager()
70 {
71 ClearObject();
72 }
73
其中使用std::map作為基本的管理器容器
同時其中CreateObject函數(shù)是一個虛擬函數(shù)需要重載之
然后我們就可以這樣寫具體的的管理器了.
比如:
1 class ModelManager : public Manager<Model,std::string>
2 {
3 public:
4 RefPtr<Model> CreateObject(const std::string &);
5 };
這是使用蓋莫游戲引擎做的基于ode物理引擎的摩擦力測試的小例子
代碼如下:
1 //! 2010.03.05
2 /////////////////////////////////////////////////////
3 /// 蓋莫游戲引擎蓋莫引擎物理場景測試3
4 /////////////////////////////////////////////////////
5 #include <GEngine/Gaimo.hpp>
6 using namespace std;
7
8 #define LENGTH 4
9 #define MASS 0.4
10 #define FORCE 0.6
11 #define MU 1.0
12 #define GRAVITY 9.8
13
14 //! 盒子紋理
15 int cubeid = 0;
16
17 dGeomID ground;
18 core::PhysicsEngine<dWorldID,dSpaceID,dJointGroupID,dBodyID,dGeomID> engine;
19 core::PhysicsBody<dBodyID,dGeomID,1> box[3];
20
21 //! 碰撞檢測回調(diào)函數(shù)
22 static void nearCallback(void *data, dGeomID o1, dGeomID o2);
23
24 //! 初始化物理場景
25 void Init();
26 //! 物理場景更新
27 void PhysicsLoop();
28
29 int main(int argc, char **argv)
30 {
31 Init();
32
33 //! 初始化引擎設(shè)備并得到設(shè)備指針
34 core::Device* device = core::InitDevice("蓋莫引擎物理場景-摩擦力測試");
35 //! 得到引擎場景指針
36 core::RefPtr<core::SceneManager> scenemanager = device->GetSceneManager();
37 //! 得到引擎資源指針
38 core::ResourceManager* resourcemanager = device->GetResourceManager();
39
40 //! 得到圖形和其紋理
41 core::RefPtr<core::Image> box = resourcemanager->GetImage("box","..\\image/tile.tga");
42 core::RefPtr<core::Texture> boxtexture = resourcemanager->GetTexture("box",box);
43 boxtexture->Bind();
44 cubeid = boxtexture->GetTextureId();
45
46 //! 獲取全局攝像機
47 core::RefPtr<core::Camera> camera = scenemanager->GetGlobalCamera(Vector3f(-5,100,17),
48 Vector3f(18,1,17),
49 Vector3f(0,1,0));
50 camera->SetViewport(0,0,640,480);
51 camera->SetPerspective(50.0f,640.0f/480.0f,0.1f,1000.0f);
52 glClearDepth(1.0f);
53 glDepthFunc(GL_LEQUAL);
54 glEnable(GL_DEPTH_TEST);
55 glEnable(GL_CULL_FACE);
56 glShadeModel(GL_SMOOTH);
57 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
58 core::Render::SetClearColor(core::Color::Blue);
59
60 BEGIN_LOOP(device)
61 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
62 glLoadIdentity();
63 camera->SetPerspective(45.0f,640.0f/480.0f,0.1f,1000.0f);
64 camera->Render();
65 PhysicsLoop();
66 END_LOOP(device)
67
68 device->Close();
69 device->Drop();
70
71 return 0;
72 }
73
74 //! 初始化物理場景
75 void Init()
76 {
77 engine.SetGravity(0,-GRAVITY,0);
78 ground = engine.SetPlane(0,1,0,0);
79 engine.SetCollideCallBack(&nearCallback);
80
81 box[0].body = engine.GetBody("body1",Vector3f(2*LENGTH,0.25*LENGTH,LENGTH*2));
82 box[1].body = engine.GetBody("body2",Vector3f(2*LENGTH,0.25*LENGTH,LENGTH*6));
83 box[2].body = engine.GetBody("body3",Vector3f(2*LENGTH,0.25*LENGTH,LENGTH*10));
84 for(int i = 0; i < 3; i++)
85 {
86 dMass m;
87 dMassSetBox(&m,1,LENGTH,LENGTH*0.5,LENGTH);
88 dMassAdjust(&m,MASS);
89 dBodySetMass(box[i].body,&m);
90 box[i].geom[0] = dCreateBox(engine.GetSpace(),LENGTH,0.5*LENGTH,LENGTH);
91 dGeomSetBody(box[i].geom[0],box[i].body);
92 }
93 }
94
95 static void nearCallback(void *data, dGeomID o1, dGeomID o2)
96 {
97 int i;
98
99 //! 僅僅考慮和地面的碰撞
100 int g1 = (o1 == ground);
101 int g2 = (o2 == ground);
102 if (!(g1 ^ g2))
103 return;
104
105 dBodyID b1 = dGeomGetBody(o1);
106 dBodyID b2 = dGeomGetBody(o2);
107
108 dContact contact[3];
109 for (i=0; i<3; i++)
110 {
111 contact[i].surface.mode = dContactSoftCFM | dContactApprox1;
112 contact[i].surface.mu = MU;
113 contact[i].surface.soft_cfm = 0.01;
114 }
115 if(int numc = dCollide (o1,o2,3,&contact[0].geom,sizeof(dContact)))
116 {
117 for (i=0; i<numc; i++)
118 {
119 dJointID c = dJointCreateContact(engine.GetWorld(),engine.GetContactGroup(),contact+i);
120 dJointAttach (c,b1,b2);
121 }
122 }
123 }
124
125 //! 物理場景更新
126 void PhysicsLoop()
127 {
128 engine.Simulation();
129
130 const float sides[3] = {2*LENGTH,LENGTH*0.5f,2*LENGTH};
131
132 dBodyAddForce(box[0].body,FORCE*5,0,0);
133 dBodyAddForce(box[1].body,FORCE*7,0,0);
134 dBodyAddForce(box[2].body,FORCE*9,0,0);
135
136 const dReal* pos = dBodyGetPosition(box[0].body);
137 const dReal* mat = dBodyGetRotation(box[0].body);
138 core::Render::RenderCube(cubeid,(const float*)pos,(const float*)mat,sides);
139 pos = dBodyGetPosition(box[1].body);
140 mat = dBodyGetRotation(box[1].body);
141 core::Render::RenderCube(cubeid,(const float*)pos,(const float*)mat,sides);
142 pos = dBodyGetPosition(box[2].body);
143 mat = dBodyGetRotation(box[2].body);
144 core::Render::RenderCube(cubeid,(const float*)pos,(const float*)mat,sides);
145 }
可以看出三個盒子的物理屬性都是一致的,除了其位置之外
在模擬過程中給3個盒子施加的力是不同的
本例子是使用蓋莫游戲引擎+ode做的第三簡單demo
這是對關(guān)節(jié)合頁的測試代碼:
1 //! 2010.03.05
2 /////////////////////////////////////////////////////
3 /// 蓋莫游戲引擎蓋莫引擎物理場景測試3
4 /////////////////////////////////////////////////////
5 #include <GEngine/Gaimo.hpp>
6 using namespace std;
7
8 //! 盒子大小和質(zhì)量
9 #define SIDE (8.0f)
10 #define MASS (1.0)
11 //! 盒子紋理
12 int cubeid = 0;
13
14 core::PhysicsEngine<dWorldID,dSpaceID,dJointGroupID,dBodyID,dGeomID> engine;
15 core::PhysicsBody<dBodyID,dGeomID,1> object[2];
16 dJointID hinge;
17 const std::string name[] = {"b1","b2"};
18
19 //! 初始化物理場景
20 void Init();
21 //! 物理場景更新
22 void PhysicsLoop();
23
24 int main(int argc, char **argv)
25 {
26 Init();
27
28 //! 初始化引擎設(shè)備并得到設(shè)備指針
29 core::Device* device = core::InitDevice("蓋莫引擎物理場景測試3");
30 //! 得到引擎場景指針
31 core::RefPtr<core::SceneManager> scenemanager = device->GetSceneManager();
32 //! 得到引擎資源指針
33 core::ResourceManager* resourcemanager = device->GetResourceManager();
34
35 //! 得到logo圖形和其紋理
36 core::RefPtr<core::Image> box = resourcemanager->GetImage("box","..\\image/logo.jpg");
37 core::RefPtr<core::Texture> boxtexture = resourcemanager->GetTexture("logo",box);
38 boxtexture->Bind();
39 cubeid = boxtexture->GetTextureId();
40
41 //! 獲取全局攝像機
42 core::RefPtr<core::Camera> camera = scenemanager->GetGlobalCamera(Vector3f(30,30,30),
43 Vector3f(0,0,0),
44 Vector3f(0,1,0));
45 camera->SetViewport(0,0,640,480);
46 camera->SetPerspective(50.0f,640.0f/480.0f,0.1f,1000.0f);
47 glClearDepth(1.0f);
48 glEnable(GL_DEPTH_TEST);
49 glShadeModel(GL_SMOOTH);
50 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
51
52 BEGIN_LOOP(device)
53 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
54 glLoadIdentity();
55 core::Render::SetClearColor(core::Color::Blue);
56 camera->SetPerspective(45.0f,640.0f/480.0f,0.1f,1000.0f);
57 camera->Render();
58 PhysicsLoop();
59 END_LOOP(device)
60
61 device->Close();
62 device->Drop();
63
64 return 0;
65 }
66
67 //! 初始化物理場景
68 void Init()
69 {
70 //! 設(shè)置調(diào)整盒子質(zhì)量
71 dMass m;
72 dMassSetBox(&m,1,SIDE,SIDE,SIDE);
73 dMassAdjust(&m,MASS);
74 //! 從軸和角度獲取四元數(shù)
75 dQuaternion q;
76 dQFromAxisAndAngle(q,1,1,0,0.25*M_PI);
77 //! 設(shè)置盒子1物理參數(shù)
78 object[0].body = engine.GetBody(name[0],Vector3f(0.5*SIDE,0.5*SIDE,1));
79 dBodySetMass (object[0].body,&m);
80 dBodySetQuaternion (object[0].body,q);
81 //! 設(shè)置盒子2物理參數(shù)
82 object[1].body = engine.GetBody(name[1],Vector3f(-0.5*SIDE,-0.5*SIDE,1));
83 dBodySetMass (object[1].body,&m);
84 dBodySetQuaternion(object[1].body,q);
85 //! 生成合頁關(guān)節(jié)并設(shè)置參數(shù)
86 hinge = dJointCreateHinge(engine.GetWorld(),0);
87 dJointAttach (hinge,object[0].body,object[1].body);
88 dJointSetHingeAnchor(hinge,0,0,1);
89 dJointSetHingeAxis(hinge,1,-1,1.41421356);
90 }
91
92 //! 物理場景更新
93 void PhysicsLoop()
94 {
95 //! 角阻尼常量
96 const dReal kd = -0.3;
97
98 static dReal a=0;
99 const dReal *w = dBodyGetAngularVel(object[0].body);
100 dBodyAddTorque (object[0].body,kd*w[0],kd*w[1]+0.15*cos(a),kd*w[2]+0.15*sin(a));
101 dWorldStep(engine.GetWorld(),0.05);
102 a += 0.01;
103
104 dReal sides1[3] = {SIDE,SIDE,SIDE};
105 dReal sides2[3] = {SIDE,SIDE,SIDE*0.8f};
106 const dReal *pos,*mat;
107 pos = dBodyGetPosition(object[0].body);
108 mat = dBodyGetRotation(object[0].body);
109 core::Render::RenderCube(cubeid,(float*)pos,(float*)mat,(float*)sides1);
110 pos = dBodyGetPosition(object[1].body);
111 mat = dBodyGetRotation(object[1].body);
112 core::Render::RenderCube(cubeid,(float*)pos,(float*)mat,(float*)sides2);
113 }
貼圖為:
1.

2.