void snippet_locations() { //! [13] QSettings obj1("MySoft", "Star Runner"); //! [13] //! [14] QSettings obj2("MySoft"); QSettings obj3(QSettings::SystemScope, "MySoft", "Star Runner"); QSettings obj4(QSettings::SystemScope, "MySoft"); //! [14] { //! [15] QSettings settings(QSettings::IniFormat, QSettings::UserScope, "MySoft", "Star Runner"); //! [15] } { QSettings settings("starrunner.ini", QSettings::IniFormat); } { QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft", QSettings::NativeFormat); } }
TEST(DynamicObject, Constructors) { kora::dynamic_t::object_t obj1; EXPECT_TRUE(obj1.empty()); obj1["key"] = 5; kora::dynamic_t::object_t obj2(obj1); EXPECT_EQ(1, obj2.count("key")); EXPECT_EQ(5, obj2.at("key")); kora::dynamic_t::object_t obj3(std::move(obj2)); EXPECT_EQ(1, obj3.count("key")); EXPECT_EQ(5, obj3.at("key")); std::map<std::string, kora::dynamic_t> map; map["key2"] = 6; kora::dynamic_t::object_t obj4(map); EXPECT_EQ(1, obj4.count("key2")); EXPECT_EQ(6, obj4.at("key2")); kora::dynamic_t::object_t obj5(std::move(map)); EXPECT_EQ(1, obj5.count("key2")); EXPECT_EQ(6, obj5.at("key2")); kora::dynamic_t::object_t obj6(obj5.begin(), obj5.end()); EXPECT_EQ(1, obj6.size()); EXPECT_EQ(1, obj6.count("key2")); EXPECT_EQ(6, obj6.at("key2")); }
TEST(AmfObjectTraitsTest, Equality) { AmfObjectTraits obj1("foo", false, true); AmfObjectTraits obj2("foo", false, false); AmfObjectTraits obj3("foo", true, false); AmfObjectTraits obj4("foo", false, false); AmfObjectTraits obj5("bar", false, true); AmfObjectTraits obj1e("foo", false, true); EXPECT_NE(obj1, obj2); EXPECT_NE(obj1, obj3); EXPECT_NE(obj1, obj4); EXPECT_NE(obj1, obj5); EXPECT_EQ(obj1, obj1e); // Verify attributes are also compared. obj1.addAttribute("attr"); EXPECT_NE(obj1, obj1e); obj1e.addAttribute("attr"); EXPECT_EQ(obj1, obj1e); // Verify attributes can't be duplicated. obj1.addAttribute("attr"); EXPECT_EQ(obj1, obj1e); }
Triangle Triangle::operator +(Triangle & obj2){ Triangle obj3(0,0); obj3.Width = this->getWidth() + obj2.getWidth(); obj3.Hight = this->getHeight() + obj2.getHeight(); return obj3; }
int main(int argc, char const *argv[]) { HasPtr obj1(new int, 1); HasPtr obj2 = obj1; HasPtr obj3(NULL, 1); obj3 = obj1; return 0; }
void main() { Array<int> obj(5,5); try { // inserting elements into array obj.insert(3,9); obj.insert(2,8); obj.insert(1,7); obj.insert(0,6); obj.insert(-1,5); // creating another object and trying out functions Array<int> obj1(10,5); obj1=obj; obj.print(); cout<<obj[5]<<endl; cout<<obj[6]<<endl; cout<<obj[7]<<endl; cout<<obj[8]<<endl; obj1.print(); // printing array obj1.bubble(); // bubble sort obj1.print(); // printing array cout<<obj.getBase()<<endl; obj.setBase(10); cout<<obj.getBase()<<endl; cout<<"Array has size "<<obj.getLength()<<endl; Array<int> obj2(6); // trying for the second array obj2.insert(3,0); obj2.insert(7,1); obj2.insert(3,5); obj2.insert(4,3); obj2.insert(2,2); // trying out function for the first derivative cout<<"Polynom: "; obj2.print(); int stepen=2; Array<int> obj3(6); obj3.nThDerivative(obj2,stepen); cout<<stepen<<". nThDerivative:"; obj3.print(); /*Array<int> obj4(6); obj4=obj2.nThDerivative(1); obj4.print();*/ } catch(char* e) { cout<<e<<endl; } }
int main() { MyClass obj(5); obj.show(); MyClass obj1(1); MyClass obj2(2); MyClass obj3(3); std::cout << "Done!" << std::endl; system("pause"); return 0; }
int main() { Test obj1; //Test obj2(); // 잘못된 사용. (compiler warning) Test obj3(1); std::cout << std::endl << "=====case1-1: Test& tr1=====" << std::endl; Test& tr1 = rvoFunc(); // ok //? 이거 안되는거 아닌가..? std::cout << "Return value received." << std::endl; std::cout << "val: " << tr1.val << std::endl; tr1.val = 10; std::cout << "val: " << tr1.val << std::endl; std::cout << std::endl << "=====case1-2: Test t1=====" << std::endl; Test t1 = rvoFunc(); // ok std::cout << "Return value received." << std::endl; std::cout << "val: " << t1.val << std::endl; std::cout << std::endl << "=====case1-3: const Test& tcr1=====" << std::endl; const Test& tcr1 = rvoFunc(); // ok std::cout << "Return value received." << std::endl; std::cout << "val: " << tcr1.val << std::endl; //tcr1.val = 3; // error: 식이 수정할 수 있는 lvalue여야 합니다. /********* rvoFunc2() Test *********/ std::cout << std::endl << "=====case2-1: Test& tr2=====" << std::endl; Test& tr2 = rvoFunc2(); // ok //? 이거 안되는거 아닌가..? std::cout << "Return value received." << std::endl; std::cout << "val: " << tr2.val << std::endl; tr2.val = 10; std::cout << "val: " << tr2.val << std::endl; std::cout << "Test::s_cid: " << Test::get_s_cid() << std::endl; std::cout << std::endl << "=====case2-2: Test t2=====" << std::endl; Test t2 = rvoFunc2(); // ok. but 바로 deleted std::cout << "Return value received." << std::endl; std::cout << "val: " << t2.val << std::endl; std::cout << "Test::s_cid: " << Test::get_s_cid() << std::endl; std::cout << std::endl << "=====case2-3: const Test& tcr2=====" << std::endl; const Test& tcr2 = rvoFunc2(); // ok std::cout << "Return value received." << std::endl; std::cout << "val: " << tcr2.val << std::endl; //tcr1.val = 3; // error: 식이 수정할 수 있는 lvalue여야 합니다. std::cout << "Test::s_cid: " << Test::get_s_cid() << std::endl; std::cout << std::endl << "=====Program ends=====" << std::endl; return 0; }
TEST_F(TesteLista, retiraEspecificoDuplo) { Objeto obj0(0); Objeto obj1(1); Objeto obj2(2); Objeto obj3(3); Objeto obj4(4); lobj.adicionaDuplo(obj0); lobj.adicionaDuplo(obj1); lobj.adicionaDuplo(obj2); lobj.adicionaDuplo(obj3); lobj.adicionaDuplo(obj4); ASSERT_EQ(lobj.retiraEspecificoDuplo(obj3), 3); }
int main () { Container obj1; obj1->Display(); cout << "-------------------------------" <<endl; Container obj2(10); obj2->Display(); cout << "-------------------------------" <<endl; Container obj3("1234"); obj3->Display(); cout << "-------------------------------" <<endl; Container obj4(10,11); obj4->Display(); cout << "-------------------------------" <<endl; }
TEST(RefCountedUnitTest, TestInitialRefCountIsOne) { dsn::ref_ptr<InitialRefCountIsOne> obj(new InitialRefCountIsOne()); EXPECT_TRUE(obj->get_count() == 1); obj = nullptr; dsn::ref_ptr<InitialRefCountIsOne> obj2(new InitialRefCountIsOne); EXPECT_TRUE(obj2->get_count() == 1); obj2 = nullptr; dsn::ref_ptr<Other> obj3(new Other()); EXPECT_TRUE(obj3->get_count() == 1); obj3 = nullptr; }
Triangle Triangle::operator -(Triangle & obj2){ Triangle obj3(0,0); if(this->getWidth()>obj2.getWidth()){ obj3.Width = this->getWidth() - obj2.getWidth(); } else{ obj3.Width = obj2.getWidth() - this->getWidth(); } if(this->getHeight()>obj2.getHeight()){ obj3.Hight = this->getHeight() - obj2.getHeight(); } else{ obj3.Hight = obj2.getHeight() - this->getHeight(); } return obj3; }
ArrLine merge( ArrLine &obj1, ArrLine &obj2){ ArrLine obj3(obj1 + obj2); Array<char> temp; for (int i = obj3.get_real_size() - 1; i >= 0; i--) { for (int j = 0; j < i; j++) { if (obj3[j] < obj3[j + 1]) { temp = obj3[j]; obj3[j] = obj3[j + 1]; obj3[j + 1] = temp; } } } return obj3; }
int main(int argc, char* argv[]) { SCompareEntry obj1(20); SCompareEntry obj2(30); SCompareEntry obj3(10); std::set<SCompareEntry> obj_set; obj_set.insert(obj1); obj_set.insert(obj2); obj_set.insert(obj3); std::pair<std::set<SCompareEntry>::iterator, bool> ret = obj_set.insert(obj3); if (!ret.second) { std::cout << "insert failure:" << ret.first->m_key.get_id() << std::endl; } for (auto itr: obj_set) { std::cout << itr.m_key.get_id() << std::endl; } return 0; }
Triangle Triangle::operator /(Triangle & obj2){ Triangle obj3(0,0); if(obj2.getWidth()!=0){ obj3.Width = this->getWidth() / obj2.getWidth(); } else if(this->getWidth()!=0){ obj3.Width = obj2.getWidth() / this->getWidth(); } else{ obj3.setWidth(0); } if(obj2.getHeight()!=0){ obj3.Hight = this->getHeight() / obj2.getHeight(); } else if(this->getHeight()!=0){ obj3.Hight = obj2.getHeight() / this->getHeight(); } else{ obj3.setHeight(0); } return obj3; }
void test() { object_list list; entity obj1(list); std::cout << "OK\n"; entity obj2(list); std::cout << "OK\n"; entity obj3(list); std::cout << "OK\n"; entity obj4(list); std::cout << "OK\n"; npc mob1(list, 100, 200); std::cout << "OK\n"; std::cout << "Size list:" << list.return_size(); std::cout << "\nID:" << list.return_ID(0) << "\nTitle:" << list.return_title(list.return_ID(0)) << "\nPosition. X:" << *list.return_pos(list.return_ID(0)).x << " Y:" << *list.return_pos(list.return_ID(0)).y << std::endl; std::cout << "\nID:" << list.return_ID(1) << "\nTitle:" << list.return_title(list.return_ID(1)) << "\nPosition. X:" << *list.return_pos(list.return_ID(1)).x << " Y:" << *list.return_pos(list.return_ID(1)).y << std::endl; std::cout << "\nID:" << list.return_ID(2) << "\nTitle:" << list.return_title(list.return_ID(2)) << "\nPosition. X:" << *list.return_pos(list.return_ID(2)).x << " Y:" << *list.return_pos(list.return_ID(2)).y << std::endl; std::cout << "\nID:" << list.return_ID(3) << "\nTitle:" << list.return_title(list.return_ID(3)) << "\nPosition. X:" << *list.return_pos(list.return_ID(3)).x << " Y:" << *list.return_pos(list.return_ID(3)).y << std::endl; std::cout << "\nID:" << list.return_ID(4) << "\nTitle:" << list.return_title(list.return_ID(4)) << "\nPosition. X:" << *list.return_pos(list.return_ID(4)).x << " Y:" << *list.return_pos(list.return_ID(4)).y << std::endl; int trag = list.return_ID(2); std::cout << "\n\nPosition. X:" << *list.return_pos(list.return_ID(4)).x << " Y:" << *list.return_pos(list.return_ID(4)).y << std::endl; mob1.set_target(list.return_pos(list.return_ID(2))); bool go = true; mob1.move_to(go); std::cout << "\n\nPosition. X:" << *list.return_pos(list.return_ID(4)).x << " Y:" << *list.return_pos(list.return_ID(4)).y << std::endl; std::system("Pause"); }
int main( void ) { std::auto_ptr<GameObject> obj1( new Foo() ); std::auto_ptr<GameObject> obj2( new Baz() ); std::auto_ptr<GameObject> obj3( new Bar() ); try { CollisionMap::getInstance()( *obj1, *obj2 ); CollisionMap::getInstance()( *obj2, *obj1 ); CollisionMap::getInstance()( *obj2, *obj3 ); CollisionMap::getInstance()( *obj3, *obj2 ); CollisionMap::getInstance()( *obj3, *obj1 ); CollisionMap::getInstance()( *obj1, *obj3 ); } catch ( UnknownCollisionException & e ) { std::cout << e.what() << std::endl; return 1; } return 0; }
void class21Driver(){ int width; int height; int choice; Rectangle obj3(0,0); Triangle Tobj3(0,0); cout<<"Enter the width for object 1:"; cin>>width; cout<<"Enter the height for object 1:"; cin>>height; Rectangle obj1(width,height); Triangle Tobj1(width,height); cout<<"Enter the width for object 2:"; cin>>width; cout<<"Enter the height for object 2:"; cin>>height; Rectangle obj2(width,height); Triangle Tobj2(width,height); cout<<"Please enter your choice from below.\n"; cout<<"1.Adding 2.Deducting 3.Multiplying 4.Devideing 5.Exit"<<endl; cin>>choice; while (choice!=5) { switch (choice) { case 1: cout<<"Adding"<<endl; cout<<"------------Rectangle---------------"<<endl; obj3 = obj1+obj2; obj3.getArea(); obj3.printInfo(); cout<<"------------Triangle---------------"<<endl; Tobj3 = Tobj1+Tobj2; Tobj3.getArea(); Tobj3.printInfo(); break; case 2: cout<<"Deducting"<<endl; cout<<"------------Rectangle---------------"<<endl; obj3 = obj1-obj2; obj3.getArea(); obj3.printInfo(); cout<<"------------Triangle---------------"<<endl; Tobj3 = Tobj1-Tobj2; Tobj3.getArea(); Tobj3.printInfo(); break; case 3: cout<<"Multiplying"<<endl; cout<<"------------Rectangle---------------"<<endl; obj3 = obj1*obj2; obj3.getArea(); obj3.printInfo(); cout<<"------------Triangle---------------"<<endl; Tobj3 = Tobj1*Tobj2; Tobj3.getArea(); Tobj3.printInfo(); break; case 4: cout<<"Multiplying"<<endl; cout<<"------------Rectangle---------------"<<endl; obj3 = obj1/obj2; obj3.getArea(); obj3.printInfo(); cout<<"------------Triangle---------------"<<endl; Tobj3 = Tobj1/Tobj2; Tobj3.getArea(); Tobj3.printInfo(); break; case 5: break; default: cout<<"Invalid number. Please try again"<<endl; cout<<"Please enter your choice from below.\n"; cout<<"1.Adding 2.Deducting 3.Multiplying 4.Devideing 5.Exit"<<endl; cin>>choice; break; } cout<<"Please enter your choice from below.\n"; cout<<"1.Adding 2.Deducting 3.Multiplying 4.Devideing 5.Exit"<<endl; cin>>choice; } }
int main() { srand(static_cast<unsigned int>(time(NULL))); std::vector<int> set1(10,0); set1[9] = 31; set1[8] = 30; set1[7] = 24; set1[6] = 15; set1[5] = 13; set1[4] = 10; set1[3] = 9; set1[2] = 5; set1[1] = 4; set1[0] = 2; MySet obj1(set1); std::cout << "Set 1: " << obj1 << std::endl << std::endl; //Insert for (int i = 0; i < 20; i++) { int randNum = rand() % 1000; std::cout << "Lets insert " << randNum << " into the set"; obj1.insert(randNum); std::cout << obj1 << std::endl << std::endl; } //Remove for (int i = 0; i < 20; i++) { int randNum = rand() % 20; std::cout << "Lets remove " << randNum << " into the set"; obj1.remove(randNum); std::cout << obj1 << std::endl << std::endl; } std::cout << std::endl << std::endl; //New Set std::vector<int> set2(30,0); for (int i = 0; i < set2.size(); i++) { set2[i] = rand() % 1000; } MySet obj2(set2); std::cout << "Set 2: " << obj2 << std::endl; std::vector<int> set3(30, 0); for (int i = 0; i < set3.size(); i++) { set3[i] = rand() % 1000; } MySet obj3(set3); std::cout << "Set 3: " << obj3 << std::endl; //Add std::cout << "Set 3 + Set 2: "; std::cout << (obj3 + obj2) << std::endl << std::endl; //Sub std::cout << "Set 3 - Set 2: "; std::cout << (obj3 - obj2) << std::endl << std::endl; //Intersect std::cout << "Set 3 & Set 2: "; std::cout << (obj3 & obj2) << std::endl << std::endl; //Equals std::cout << "Set 3 == Set 2: "; std::cout << (obj3 == obj2 ? "Yes" : "No") << std::endl << std::endl << std::endl; //New Set std::vector<int> set4(30, 0); for (int i = 0; i < set4.size(); i++) { set4[i] = rand() % 1000; } MySet obj4(set4); std::cout << "Set 4: " << obj4 << std::endl; MySet obj5(set4); std::cout << "Set 5: " << obj5 << std::endl; //Equals std::cout << "Set 4 == Set 5: "; std::cout << (obj4 == obj5 ? "Yes" : "No") << std::endl; return 0; }
int main ( int argc , char **argv ) { #if 0 BackGenEngine::BLogger logger; BackGenEngine::BDynamicModuleSystem dm ( &logger ); dm.loadModule ( "../../modules/asset/image/BImageAsset" ); #endif #if 0 DIR *dh;//directory handle struct dirent *file;//a 'directory entity' AKA file dh = opendir ( "./" ); while ( file = readdir ( dh ) ) { printf ( "%s\n", file->d_name ); } return 0; #endif #if 0 BoxE::Core::BSettings s; s.setValue ( "a", 'a' ); std::cout << "a: " << s.value ( "a" ).value<char>(); #endif BoxE::Math::BMatrix4x4f m1; m1.setToIdentity(); m1.rotateX ( 90 ); BoxE::Math::BMatrix4x4f m2 ( m1.getInverse() ); BoxE::Math::BMatrix4x4f m3 ( m1 * m2 ); #if 0 BackGenEngine::BLogger logger; BackGenEngine::BActionManager actionm; BackGenEngine::BDynamicModuleSystem mod_sys ( &logger ); mod_sys.loadModule ( "../../modules/component/transformation/BTransformationComponent" ); mod_sys.loadModule ( "../../modules/component/meshrenderer/BMeshRendererComponent" ); mod_sys.loadModule ( "../../modules/component/cubemesh/BCubeMesh" ); mod_sys.loadModule ( "../../modules/asset/image/BImageAsset" ); mod_sys.loadModule ( "../../modules/asset/texture/BTextureAsset" ); mod_sys.loadModule ( "../../modules/asset/material/BMaterialAsset" ); mod_sys.loadModule ( "../../modules/asset_loader/image_tga/TGAloader" ); mod_sys.loadModule ( "../../modules/asset_loader/texture/Textureloader" ); mod_sys.loadModule ( "../../modules/asset_saver/texture/TextureSaver" ); BSDLWindow window ( "pokus", BackGenEngine::BAbstractWindow::screen_resolution_t ( 800, 600, 0 ), 32, false, &logger ); window.init(); window.show(); BOpenGLRenderer renderer ( &logger ); renderer.init(); renderer.onScreenChanged ( BoxE::Math::BVector3f ( 800, 600 , 0 ), false ); BackGenEngine::BProject project ( 0, &mod_sys, &logger ); project.setBaseDir ( "/home/backgen/pokusgame/" ); BackGenEngine::BScene scene ( &renderer, &logger ); BackGenEngine::BLayer *pc_layer = scene.getLayersManager().createLayer ( "vrstva1", BackGenEngine::BLayer::GUI ); //mod_sys.loadModule ( "../../modules/component/transformation/BTransformationComponent" ); //project.setName ( "Testing" ); //window.show(); BackGenEngine::BObject *pc_triangles = new BackGenEngine::BObject ( "Object1", 0 ); BackGenEngine::BAbstractComponent *pc_transform = mod_sys.createComponent ( "Transformation", &scene ); ( ( BTransformationComponent * ) pc_transform )->position().setXYZ ( 0.0f, 0.0f, -5.0f ); BackGenEngine::BAbstractComponent *pc_cubemesh = mod_sys.createComponent ( "CubeMesh", &scene ); BackGenEngine::BAbstractComponent *pc_meshrenderer = mod_sys.createComponent ( "MeshRenderer", &scene ); pc_triangles->insertComponent ( pc_transform ); pc_triangles->insertComponent ( pc_cubemesh ); pc_triangles->insertComponent ( pc_meshrenderer ); /* PokusRenderComponent *pc_rendr_comp = new PokusRenderComponent ( &scene ); pc_triangles->insertComponent ( pc_rendr_comp );*/ pc_layer->insertObject ( pc_triangles ); BackGenEngine::BButtonAction quitAction ( "Quit", BackGenEngine::BAbstractWindow::BK_ESCAPE, &window ); actionm.insert ( &quitAction ); BackGenEngine::BActionManager::actions_hash_t::ConstIterator iter = actionm.constBegin(); /* BoxE::Math::BMatrix4x4f ortho; ortho.setOrthographic ( 0, 800, 0, 600, 0.0f, 1.0f ); renderer.pushMatrix ( BOpenGLRenderer::MT_PROJECTION ); renderer.setMatrix ( BOpenGLRenderer::MT_PROJECTION, ortho );*/ BackGenEngine::BObject *pc_camera_object = new BackGenEngine::BObject ( "Camera", 0 ); BBaseCameraComponent *pc_camera_component = new BBaseCameraComponent ( &scene ); pc_camera_component->resize ( 800, 600 ); pc_camera_component->insertLayer ( pc_layer ); /* glViewport ( 0, 0, 800, 600 ); glMatrixMode ( GL_PROJECTION ); glLoadIdentity(); glOrtho ( 0, 800, 0, 600, -1, 1 );*/ BImageAsset *pc_image = ( BImageAsset * ) mod_sys.createAsset ( "Image", &project, &renderer, &project.getAssetManager(), &logger ); pc_image->setName ( "image1" ); pc_image->setPath ( "skin.tga" ); pc_image->use(); BTextureAsset *pc_texture = ( BTextureAsset * ) mod_sys.createAsset ( "Texture", &project, &renderer, &project.getAssetManager(), &logger ); pc_texture->setImage ( pc_image ); pc_texture->setMipmaping ( true ); //pc_texture->setPath( "texture1.texture" ); BMaterialAsset *pc_material = ( BMaterialAsset * ) mod_sys.createAsset ( "Material", &project, &renderer, &project.getAssetManager(), &logger ); pc_material->setTextureUnit ( 0, pc_texture ); ( ( BMeshRendererComponent * ) pc_meshrenderer )->setMaterialAsset ( pc_material ); ( ( BMeshRendererComponent * ) pc_meshrenderer )->setTiling ( BoxE::Math::BVector2f ( 2.0f, 2.0f ) ); float i = 0; BoxE::Math::BMatrix4x4f rot; while ( !window.update() && quitAction.isUp() ) { i += 1; ( ( BTransformationComponent * ) pc_transform )->rotation().y ( i ); pc_camera_component->render(); renderer.beginRender ( true, true, BoxE::Math::BVector3f ( 0.0f, 0.0f, 0.0f ) ); renderer.drawSreenTexture ( pc_camera_component->getOutputTexture() ); //renderer.drawSreenTexture ( pc_texture->getTexture() ); renderer.endRender(); SDL_GL_SwapBuffers( ); // renderer.popMatrix ( BOpenGLRenderer::MT_PROJECTION ); //renderer.popMatrix ( BOpenGLRenderer::MT_WORLD ); }; #endif //BoxE::Math::BMatrix4x4f matrix( BoxE::Math::BMatrix4x4f::IDENTITY ); #if 0 BackGenEngine::BObject obj1 ( "obj1" ); BackGenEngine::BObject obj2 ( "obj2", &obj1 ); BackGenEngine::BObject obj3 ( "obj3" ); BackGenEngine::BObject obj4 ( "obj4", &obj1 ); BackGenEngine::BObject::objects_list_t::ConstIterator it = obj1.constObjectsBegin(); while ( it != obj1.constObjectsEnd() ) { std::cout << ( *it )->name() << std::endl; ++it; } obj1.name ( "OBJ1" ); BackGenEngine::BLayersManager lm; BackGenEngine::BLayer layer1 ( "layer", BackGenEngine::BLayer::NORMAL ); layer1.insertObject ( &obj1 ); BackGenEngine::BLayer *layer2 = lm.createLayer ( "layer1", BackGenEngine::BLayer::NORMAL ); if ( lm.removeLayer ( "layer1" ) ) { std::cout << obj1.layer()->name() << std::endl; } BackGenEngine::BTagsManager tm; BackGenEngine::BTag *tag1 = tm.createTag ( "tag1" ); BackGenEngine::BTag *tag2 = tm.createTag ( "tag1" ); tm.removeTag ( tag1 ); if ( tm.containTag ( "tag1" ) ) { std::cout << "obsahuje" << std::endl; } #endif #if 0 BackGenEngine::BLogger logger; BackGenEngine::BActionManager actionm; BSDLWindow window ( "TestApp", BackGenEngine::BAbstractWindow::screen_resolution_t ( 800, 600, 0 ), 32, false, &logger ); window.init(); window.show(); window.onKeyDown().connect ( &on_key_down ); window.onMouseMotion().connect ( &mouse ); BackGenEngine::BButtonAction quitAction ( "Quit", BackGenEngine::BAbstractWindow::BK_ESCAPE, &window ); actionm.insert ( &quitAction ); BackGenEngine::BActionManager::actions_hash_t::ConstIterator iter = actionm.constBegin(); while ( !window.update() && quitAction.isUp() ) { }; #endif #if 0 BoxE::Core::BLibrary SDL ( "SDL" ); if ( !SDL.load() ) { std::cout << "ERROR: " << SDL.errorString().constData() << std::endl; } void *a = SDL.resolv ( "SDL_Init" ); if ( !a ) { std::cout << "ERROR: " << SDL.errorString().constData() << std::endl; } //void* a = BoxE::Core::BLibrary::resolve( "/usr/lib/libSDL.so", "SDL_Init" ); #endif #if 0 BoxE::Core::BFile out2; out2.setFilename ( "a.txt" ); // out2.open(BoxE::Core::BIODevice::WriteOnly); BoxE::Core::BTextStream stream ( &out2 ); // stream << "1"; out2.close(); out2.open ( BoxE::Core::BIODevice::ReadOnly ); std::cout << stream.readAll().constData() << std::endl; #endif return 0; }
int run() { if (!initialize()) { return 1; } app_scene.initialize(); qts::resource_cache<qts::mesh_loader> mesh_cache; qts::static_object obj1("models/cow-nonormals.obj", mesh_cache); qts::static_object obj2("models/sponza.obj", mesh_cache); qts::static_object obj3("models/cow-nonormals.obj", mesh_cache); qts::static_object obj4("models/ladybird.obj", mesh_cache); obj1.transform = glm::translate(obj1.transform, glm::vec3(-100.0f, 0.0f, 0.0f)); obj3.transform = glm::translate(obj3.transform, glm::vec3( 100.0f, 500.0f, 0.0f)); qts::resource_cache<qts::bsp_map_loader> bsp_map_cache; bsp_map_cache.get_resource("maps/q3ctf1.bsp"); app_scene.append(obj1); app_scene.append(obj2); app_scene.append(obj3); app_scene.append(obj4); uint64_t frame_id = 0; int key, action, type; int mouse_x, mouse_y; decltype(keybindings)::const_iterator keybinding_iter; while (glfwGetWindowParam(GLFW_OPENED) && ++frame_id) { glfwSwapBuffers(); while (0 < input_events.size()) { std::tie(key, action, type) = input_events.front(); keybinding_iter = keybindings.find(std::make_tuple(key, action, type)); if (std::end(keybindings) != keybinding_iter) { keybinding_iter->second(game_state); } if (GLFW_PRESS == action) { active_keys.insert(key); } else if (GLFW_RELEASE == action) { active_keys.erase(key); } input_events.pop(); } if (game_state.quit_requested) { glfwCloseWindow(); } if (qts::game_state::mouse_mode::LOCKED == game_state.current_mouse_mode) { int current_mouse_x, current_mouse_y; int dx, dy; auto& rotation = game_state.active_camera->rotation; glfwGetMousePos(¤t_mouse_x, ¤t_mouse_y); dx = (current_mouse_x - mouse_x); dy = (current_mouse_y - mouse_y); rotation = rotation * (glm::quat(1.0f, glm::vec3(dy * 0.000f, dx * 0.001f, 0.0f))); rotation = (glm::quat(1.0f, glm::vec3(dy * 0.001f, dx * 0.000f, 0.0f))) * rotation; rotation = glm::normalize(rotation); mouse_x = current_mouse_x; mouse_y = current_mouse_y; } for (auto& kp: game_state.active_effects) { kp.second(game_state); } app_scene.render(*game_state.active_camera); std::this_thread::sleep_for(std::chrono::milliseconds(1)); } return 0; }