bool Kengine::Init(int argc, char** argv) { // Initialize GLUT and GLEW InitGlut(argc, argv); // TODO: Setup GLUI glewInit(); // Initialize Shader shader = new Shader; if (!shader->Init("vert.glsl", "frag.glsl")) return false; shader->Enable(); // Set the Renderable class to use the shader Renderable::BindShader(shader); camera = new Camera; camera->Init(glm::vec3(3.f, 4.f, 3.f), glm::vec3(.0f, .0f, .0f), glm::vec3(.0f, 1.f, .0f)); userInput = new UserInput; userInput->BindCamera(camera); level = new Level; level->Init(argv[1]); InitCallbacks(); return true; }
void GLFWBackendRun(ICallbacks* pCallbacks) { if (!pCallbacks) { OGLDEV_ERROR("callbacks not specified"); exit(1); } glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glFrontFace(GL_CW); glCullFace(GL_BACK); glEnable(GL_CULL_FACE); if (sWithDepth) { glEnable(GL_DEPTH_TEST); } s_pCallbacks = pCallbacks; InitCallbacks(); while (!glfwWindowShouldClose(s_pWindow)) { s_pCallbacks->RenderSceneCB(); glfwSwapBuffers(s_pWindow); glfwPollEvents(); } }
//Called to revert to old event management. void EventManager::checkForShutDownEventManager( void ) { if (m_responders.empty() && globalEventManagerPtr != NULL) { //There are no more responders. We assume no more of our windows, and reset mouse callbacks. //If we don't have a global event manager, we already did this. InitCallbacks(); //Get rid of global event manager object until we need it again. delete globalEventManagerPtr; globalEventManagerPtr = NULL; } }
bool StudioFrame::SaveAs() { wxFileDialog openFileDialog(this, _("Save oaml.defs"), wxEmptyString, "oaml.defs", "*.defs", wxFD_SAVE); if (openFileDialog.ShowModal() == wxID_CANCEL) return false; defsPath = openFileDialog.GetPath(); wxFileName fname(defsPath); projectPath = fname.GetPathWithSep(); InitCallbacks(projectPath); fileHistory->AddFileToHistory(defsPath); Save(); return true; }
void GLUTBackendRun(ICallbacks* pCallbacks){ if (!pCallbacks){ fprintf(stderr, "%s : callbacks not specified!\n", __FUNCTION__); return; } glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glFrontFace(GL_CW); glCullFace(GL_BACK); glEnable(GL_CULL_FACE); s_pCallbacks = pCallbacks; InitCallbacks(); glutMainLoop(); }
void SDLBackendRun(ICallbacks* pCallbacks, SDL_Window* Window){ if (!pCallbacks){ fprintf(stderr, "%s : callbacks not specified!\n", __FUNCTION__); return; } glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glEnable(GL_DEPTH_TEST); glFrontFace(GL_CW); glCullFace(GL_BACK); glEnable(GL_CULL_FACE); s_pCallbacks = pCallbacks; InitCallbacks(Window); }
void StudioFrame::Load(std::string filename) { defsPath = filename; wxFileName fname(defsPath); projectPath = fname.GetPathWithSep(); InitCallbacks(projectPath); if (oaml->Init(fname.GetFullName().ToStdString().c_str()) != OAML_OK) { wxMessageBox(_("Error loading project")); for (size_t i=0; i<fileHistory->GetCount(); i++) { if (fileHistory->GetHistoryFile(i) == fname.GetFullPath()) { fileHistory->RemoveFileFromHistory(i); break; } } return; } fileHistory->AddFileToHistory(filename); musicList->ClearAll(); sfxList->ClearAll(); oamlTracksInfo *info = oaml->GetTracksInfo(); for (size_t i=0; i<info->tracks.size(); i++) { oamlTrackInfo *track = &info->tracks[i]; if (track->musicTrack) { musicList->InsertItem(musicList->GetItemCount(), wxString(track->name)); } else if (track->sfxTrack) { sfxList->InsertItem(sfxList->GetItemCount(), wxString(track->name)); } } settingsFrame->OnLoad(); }
bool Kengine::Init(int argc, char** argv) { if (argc < 2) { return false; } kengine = this; InitGlut(argc, argv); glewInit(); // Initialize Shader shader = new Shader; if (!shader->Init("vert.glsl", "frag.glsl")) return false; shader->Enable(); // Set the Renderable class to use the shader Renderable::UseShader(shader); c[1] = new FreelookCamera; c[1]->Init(); c[0] = new ArcballCamera; c[0]->Init(); c[2] = new TopDown; c[2]->Init(); _projection = new Projection; _projection->Init(); _projection->fovy(45.f); _projection->znear(0.1f); _projection->zfar(10000.f); _projection->screenWidth(640); _projection->screenHeight(480); userInput = new UserInput; userInput->BindCamera(c[0]); _levelMgr = new LevelManager; _levelMgr->Initialize(); // can't fail yet if (_levelMgr->LoadLevels() != 0x1) { return false; } _levelMgr->_uin = userInput; _levelMgr->PlayLevel(0); userInput->SetLevelManager(_levelMgr); _menu = new GameMenu; _menu->Initialize(); _menu->SetLevelManager(_levelMgr); _menu->ActivateLevelManagerContext(); userInput->SetLevelMenuContext(_menu->LevelContext()); userInput->SetGameMenuContext(_menu->GameContext()); InitCallbacks(); return true; }
void CUIActorMenu::Construct() { CUIXml uiXml; uiXml.Load (CONFIG_PATH, UI_PATH, "actor_menu.xml"); CUIXmlInit xml_init; xml_init.InitWindow (uiXml, "main", 0, this); m_hint_wnd = UIHelper::CreateHint (uiXml, "hint_wnd"); m_LeftBackground = new CUIStatic(); m_LeftBackground->SetAutoDelete (true); AttachChild (m_LeftBackground); xml_init.InitStatic (uiXml, "left_background", 0, m_LeftBackground); m_pUpgradeWnd = new CUIInventoryUpgradeWnd(); AttachChild (m_pUpgradeWnd); m_pUpgradeWnd->SetAutoDelete (true); m_pUpgradeWnd->Init (); m_ActorCharacterInfo = new CUICharacterInfo(); m_ActorCharacterInfo->SetAutoDelete( true ); AttachChild( m_ActorCharacterInfo ); m_ActorCharacterInfo->InitCharacterInfo( &uiXml, "actor_ch_info" ); m_PartnerCharacterInfo = new CUICharacterInfo(); m_PartnerCharacterInfo->SetAutoDelete( true ); AttachChild( m_PartnerCharacterInfo ); m_PartnerCharacterInfo->InitCharacterInfo( &uiXml, "partner_ch_info" ); m_RightDelimiter = UIHelper::CreateStatic(uiXml, "right_delimiter", this); m_ActorTradeCaption = UIHelper::CreateStatic(uiXml, "right_delimiter:trade_caption", m_RightDelimiter); m_ActorTradePrice = UIHelper::CreateStatic(uiXml, "right_delimiter:trade_price", m_RightDelimiter); m_ActorTradeWeightMax = UIHelper::CreateStatic(uiXml, "right_delimiter:trade_weight_max", m_RightDelimiter); m_ActorTradeCaption->AdjustWidthToText(); m_LeftDelimiter = UIHelper::CreateStatic(uiXml, "left_delimiter", this); m_PartnerTradeCaption = UIHelper::CreateStatic(uiXml, "left_delimiter:trade_caption", m_LeftDelimiter); m_PartnerTradePrice = UIHelper::CreateStatic(uiXml, "left_delimiter:trade_price", m_LeftDelimiter); m_PartnerTradeWeightMax = UIHelper::CreateStatic(uiXml, "left_delimiter:trade_weight_max", m_LeftDelimiter); m_PartnerTradeCaption->AdjustWidthToText(); m_ActorBottomInfo = UIHelper::CreateStatic(uiXml, "actor_weight_caption", this); m_ActorWeight = UIHelper::CreateStatic(uiXml, "actor_weight", this); m_ActorWeightMax = UIHelper::CreateStatic(uiXml, "actor_weight_max", this); m_ActorBottomInfo->AdjustWidthToText(); m_PartnerBottomInfo = UIHelper::CreateStatic(uiXml, "partner_weight_caption", this); m_PartnerWeight = UIHelper::CreateStatic(uiXml, "partner_weight", this); m_PartnerBottomInfo->AdjustWidthToText(); m_PartnerWeight_end_x = m_PartnerWeight->GetWndPos().x; m_pInventoryBagList = UIHelper::CreateDragDropListEx(uiXml, "dragdrop_bag", this); m_pInventoryBeltList = UIHelper::CreateDragDropListEx(uiXml, "dragdrop_belt", this); m_pInventoryOutfitList = UIHelper::CreateDragDropListEx(uiXml, "dragdrop_outfit", this); m_pInventoryDetectorList = UIHelper::CreateDragDropListEx(uiXml, "dragdrop_detector", this); m_pInventoryPistolList = UIHelper::CreateDragDropListEx(uiXml, "dragdrop_pistol", this); m_pInventoryAutomaticList = UIHelper::CreateDragDropListEx(uiXml, "dragdrop_automatic", this); m_pTradeActorBagList = UIHelper::CreateDragDropListEx(uiXml, "dragdrop_actor_trade_bag", this); m_pTradeActorList = UIHelper::CreateDragDropListEx(uiXml, "dragdrop_actor_trade", this); m_pTradePartnerBagList = UIHelper::CreateDragDropListEx(uiXml, "dragdrop_partner_bag", this); m_pTradePartnerList = UIHelper::CreateDragDropListEx(uiXml, "dragdrop_partner_trade", this); #ifdef INV_KNIFE_SLOT m_pInventoryKnifeList = UIHelper::CreateDragDropListEx(uiXml, "dragdrop_knife", this); #endif #ifdef INV_TORCH_SLOT m_pInventoryTorchList = UIHelper::CreateDragDropListEx(uiXml, "dragdrop_torch", this); #endif #ifdef INV_BINO_SLOT m_pInventoryBinoList = UIHelper::CreateDragDropListEx(uiXml, "dragdrop_bino", this); #endif #ifdef DRAG_DROP_TRASH m_pTrashList = UIHelper::CreateDragDropListEx(uiXml, "dragdrop_trash", this); m_pTrashList->m_f_item_drop = CUIDragDropListEx::DRAG_DROP_EVENT(this, &CUIActorMenu::OnItemDrop); m_pTrashList->m_f_drag_event = CUIDragDropListEx::DRAG_ITEM_EVENT(this, &CUIActorMenu::OnDragItemOnTrash); #endif #ifdef EXT_BELT e_af_count = uiXml.ReadAttribInt("dragdrop_belt", 0, "rows_num", 5); //+ clamp(e_af_count, u32(5), u32(16)); e_af_count_base = e_af_count - 5;// reserv for outfit m_belt_list_over.resize(e_af_count); #endif //EXT_BELT m_belt_list_over[0] = UIHelper::CreateStatic(uiXml, "belt_list_over", this); Fvector2 pos; pos = m_belt_list_over[0]->GetWndPos(); float dy = uiXml.ReadAttribFlt("belt_list_over", 0, "dy", 10.0f); for ( u8 i = 1; i < e_af_count; ++i ) { pos.y += dy; m_belt_list_over[i] = UIHelper::CreateStatic(uiXml, "belt_list_over", this); m_belt_list_over[i]->SetWndPos( pos ); } m_ActorMoney = UIHelper::CreateStatic(uiXml, "actor_money_static", this); m_PartnerMoney = UIHelper::CreateStatic(uiXml, "partner_money_static", this); m_trade_button = UIHelper::Create3tButtonEx(uiXml, "trade_button", this); m_takeall_button = UIHelper::Create3tButtonEx(uiXml, "takeall_button", this); m_exit_button = UIHelper::Create3tButtonEx(uiXml, "exit_button", this); m_clock_value = UIHelper::CreateStatic(uiXml, "clock_value", this); m_pDeadBodyBagList = new CUIDragDropListEx(); AttachChild (m_pDeadBodyBagList); m_pDeadBodyBagList->SetAutoDelete (true); xml_init.InitDragDropListEx (uiXml, "dragdrop_deadbody_bag", 0, m_pDeadBodyBagList); m_ActorStateInfo = new ui_actor_state_wnd(); m_ActorStateInfo->init_from_xml (uiXml, "actor_state_info"); m_ActorStateInfo->SetAutoDelete (true); AttachChild (m_ActorStateInfo); XML_NODE* stored_root = uiXml.GetLocalRoot (); uiXml.SetLocalRoot (uiXml.NavigateToNode ("action_sounds",0)); ::Sound->create (sounds[eSndOpen], uiXml.Read("snd_open", 0, NULL),st_Effect,sg_SourceType); ::Sound->create (sounds[eSndClose], uiXml.Read("snd_close", 0, NULL),st_Effect,sg_SourceType); ::Sound->create (sounds[eItemToSlot], uiXml.Read("snd_item_to_slot", 0, NULL),st_Effect,sg_SourceType); ::Sound->create (sounds[eItemToBelt], uiXml.Read("snd_item_to_belt", 0, NULL),st_Effect,sg_SourceType); ::Sound->create (sounds[eItemToRuck], uiXml.Read("snd_item_to_ruck", 0, NULL),st_Effect,sg_SourceType); ::Sound->create (sounds[eProperties], uiXml.Read("snd_properties", 0, NULL),st_Effect,sg_SourceType); ::Sound->create (sounds[eDropItem], uiXml.Read("snd_drop_item", 0, NULL),st_Effect,sg_SourceType); ::Sound->create (sounds[eAttachAddon], uiXml.Read("snd_attach_addon", 0, NULL),st_Effect,sg_SourceType); ::Sound->create (sounds[eDetachAddon], uiXml.Read("snd_detach_addon", 0, NULL),st_Effect,sg_SourceType); ::Sound->create (sounds[eItemUse], uiXml.Read("snd_item_use", 0, NULL),st_Effect,sg_SourceType); uiXml.SetLocalRoot (stored_root); m_ItemInfo = new CUIItemInfo(); //- m_ItemInfo->SetAutoDelete (true); //- AttachChild (m_ItemInfo); m_ItemInfo->InitItemInfo ("actor_menu_item.xml"); m_upgrade_info = NULL; if ( ai().get_alife() ) { m_upgrade_info = new UIInvUpgradeInfo(); m_upgrade_info->SetAutoDelete (true); AttachChild (m_upgrade_info); m_upgrade_info->init_from_xml ("actor_menu_item.xml"); } m_message_box_yes_no = new CUIMessageBoxEx(); m_message_box_yes_no->InitMessageBox( "message_box_yes_no" ); m_message_box_yes_no->SetAutoDelete (true); m_message_box_yes_no->SetText ( "" ); m_message_box_ok = new CUIMessageBoxEx(); m_message_box_ok->InitMessageBox ( "message_box_ok" ); m_message_box_ok->SetAutoDelete (true); m_message_box_ok->SetText ( "" ); m_UIPropertiesBox = new CUIPropertiesBox(); AttachChild (m_UIPropertiesBox); m_UIPropertiesBox->InitPropertiesBox(Fvector2().set(0,0),Fvector2().set(300,300)); m_UIPropertiesBox->Hide (); m_UIPropertiesBox->SetWindowName ( "property_box" ); InitCallbacks (); BindDragDropListEvents (m_pInventoryBeltList); BindDragDropListEvents (m_pInventoryPistolList); BindDragDropListEvents (m_pInventoryAutomaticList); BindDragDropListEvents (m_pInventoryOutfitList); BindDragDropListEvents (m_pInventoryDetectorList); BindDragDropListEvents (m_pInventoryBagList); BindDragDropListEvents (m_pTradeActorBagList); BindDragDropListEvents (m_pTradeActorList); BindDragDropListEvents (m_pTradePartnerBagList); BindDragDropListEvents (m_pTradePartnerList); BindDragDropListEvents (m_pDeadBodyBagList); #ifdef INV_KNIFE_SLOT BindDragDropListEvents (m_pInventoryKnifeList); #endif #ifdef INV_TORCH_SLOT BindDragDropListEvents (m_pInventoryTorchList); #endif #ifdef INV_BINO_SLOT BindDragDropListEvents (m_pInventoryBinoList); #endif #ifdef DRAG_DROP_TRASH m_allowed_drops[iTrashSlot].push_back(iActorBag); m_allowed_drops[iTrashSlot].push_back(iActorSlot); m_allowed_drops[iTrashSlot].push_back(iActorBelt); #endif m_allowed_drops[iActorSlot].push_back(iActorBag); m_allowed_drops[iActorSlot].push_back(iActorTrade); m_allowed_drops[iActorSlot].push_back(iDeadBodyBag); m_allowed_drops[iActorBag].push_back(iActorSlot); m_allowed_drops[iActorBag].push_back(iActorBelt); m_allowed_drops[iActorBag].push_back(iActorTrade); m_allowed_drops[iActorBag].push_back(iDeadBodyBag); m_allowed_drops[iActorBag].push_back(iActorBag); m_allowed_drops[iActorBelt].push_back(iActorBag); m_allowed_drops[iActorBelt].push_back(iActorTrade); m_allowed_drops[iActorBelt].push_back(iDeadBodyBag); m_allowed_drops[iActorBelt].push_back(iActorBelt); m_allowed_drops[iActorTrade].push_back(iActorSlot); m_allowed_drops[iActorTrade].push_back(iActorBag); m_allowed_drops[iActorTrade].push_back(iActorBelt); m_allowed_drops[iActorTrade].push_back(iActorTrade); m_allowed_drops[iPartnerTradeBag].push_back(iPartnerTrade); m_allowed_drops[iPartnerTradeBag].push_back(iPartnerTradeBag); m_allowed_drops[iPartnerTrade].push_back(iPartnerTradeBag); m_allowed_drops[iPartnerTrade].push_back(iPartnerTrade); m_allowed_drops[iDeadBodyBag].push_back(iActorSlot); m_allowed_drops[iDeadBodyBag].push_back(iActorBag); m_allowed_drops[iDeadBodyBag].push_back(iActorBelt); m_allowed_drops[iDeadBodyBag].push_back(iDeadBodyBag); m_upgrade_selected = NULL; SetCurrentItem (NULL); SetActor (NULL); SetPartner (NULL); SetInvBox (NULL); m_actor_trade = NULL; m_partner_trade = NULL; m_repair_mode = false; DeInitInventoryMode (); DeInitTradeMode (); DeInitUpgradeMode (); DeInitDeadBodySearchMode (); }