hello world编写

HelloWorld是所有语言必学的入门程序,特此将代码奉上

#include <dtABC/application.h>

#include <dtCore/refptr.h>

 

namespace dtCore

{

     class Object;

     class OrbitMotionModel;

}

 

class HelloWorld:public dtABC::Application

{

public:

     HelloWorld(const std::string &configFileName);

 

     virtual ~HelloWorld();

 

     virtual void Config();

private:

     dtCore::RefPtr<dtCore::Object>mText;

     dtCore::RefPtr<dtCore::OrbitMotionModel>mOrbitMotionModel;

};

#include "HelloWorld.h"

#include <dtCore/globals.h>

#include <dtCore/scene.h>

#include <dtCore/object.h>

#include <dtCore/transform.h>

#include <dtCore/orbitmotionmodel.h>

#include <osgDB/FileUtils>

 

using namespace dtCore;

 

HelloWorld::HelloWorld(const std::string &configFileName):

dtABC::Application(configFileName),

mText(0),

mOrbitMotionModel(0)

{

     if(osgDB::findDataFile(configFileName).empty())

         GenerateDefaultConfigFile();

}

 

HelloWorld::~HelloWorld()

{

 

}

 

void HelloWorld::Config()

{

     mText = new dtCore::Object("Text");

     mText->LoadFile("Hello.flt");

 

     dtABC:GetScene()->AddDrawable(mText.get());

 

     //

     Transform camPos(0.f, -200.0f, 20.0, 0.f, 10.f, 0.f);

     GetCamera()->SetTransform(camPos);

 

     mOrbitMotionModel = new dtCore::OrbitMotionModel(GetKeyboard(), GetMouse());

     mOrbitMotionModel->SetTarget(GetCamera());

}

 

int main()

{

     dtCore::SetDataFilePathList(".;" + dtCore::GetDeltaDataPathList());

 

     dtCore::RefPtr<HelloWorld>app = new HelloWorld("config.xml");

     app->Config();

     app->Run();

     return 0;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值