int main(int argc, char **argv) { /* initialize random seed: */ srand ( time(NULL) ); // init GLUT and create window glutInit(&argc, argv); glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); glutInitWindowPosition(100,100); glutInitWindowSize(window_width,window_height); printf("window size: %dX%d\n", window_width, window_height); glutCreateWindow("Object Selection"); initializeWindow(); glutReshapeFunc(changeSize); //glutIdleFunc(renderScene); //use this for animations //glutSetCursor(GLUT_CURSOR_NONE); //glutEntryFunc(mouse_enter); glutMouseFunc(mouse_func); glutMotionFunc(mouse); //glutPassiveMotionFunc(mouseMovement); //check for mouse movement // enter GLUT event processing cycle glutDisplayFunc(renderScene); printf("rendering...\n"); glutMainLoop(); }
DropShadowWindow::DropShadowWindow(QWidget *parent) : BaseStyleWidget(parent) { setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog); setAttribute(Qt::WA_TranslucentBackground); initializeWindow(); }
bool JPController::Initialize (WNDPROC wndProc){ if(initializeWindow(wndProc)){ if (initializeRenderer()) return true; return false; } return false; }
ButtonPlayer::ButtonPlayer() : Thread(), Player("") { status = NONE; previousStatus = NONE; image = NULL; win = NULL; initializeWindow(); }
bool MissionFailedState::initialize() { // Inicializamos la ventana del estado. if(!initializeWindow("MissionFailed.layout", "MissionFailed")) return false; // Configuramos los eventos asociados a los botones de la ventana. SubscribeToClickedEvent("MissionFailed/TryAgainButton", &MissionFailedState::tryAgainButton, this); SubscribeToClickedEvent("MissionFailed/SpaceMapButton", &MissionFailedState::spaceMapButton, this); return true; }
bool MissionMenuState::initialize() { // Inicializamos la ventana del estado. if(!initializeWindow("MissionMenu.layout", "MissionMenu")) return false; // Configuramos los eventos asociados a los botones de la ventana. SubscribeToClickedEvent("MissionMenu/ReturnButton", &MissionMenuState::returnButton, this); SubscribeToClickedEvent("MissionMenu/ExitButton", &MissionMenuState::exitButton, this); return true; }
bool MainPlayerMenuState::initialize() { // Inicializamos la ventana del estado. if(!initializeWindow("MainPlayerMenu.layout", "MainPlayerMenu")) return false; // Configuramos los eventos asociados a los botones de la ventana. SubscribeToClickedEvent("MainPlayerMenu/NewGameButton", &MainPlayerMenuState::newGameButton, this); SubscribeToClickedEvent("MainPlayerMenu/LoadGameButton", &MainPlayerMenuState::loadGameButton, this); SubscribeToClickedEvent("MainPlayerMenu/OptionsButton", &MainPlayerMenuState::optionsButton, this); SubscribeToClickedEvent("MainPlayerMenu/ExitProfileButton", &MainPlayerMenuState::exitProfileButton, this); SubscribeToClickedEvent("MainPlayerMenu/ExitGameButton", &MainPlayerMenuState::exitGameButton, this); return true; }
int createWindow(Interface *gui, int player) { // initializes player conditions gui->player = player; gui->waitingForAnswer = FALSE; gui->gotCorrectAnswer = FALSE; // intializes blank window initializeWindow(&(gui->window), player); // adds items to window addItemsToWindow(gui); // shows everything in window gtk_widget_show_all(gui->window); }
AudioTest::AudioTest() : m_pullTimer(new QTimer(this)) , m_modeButton(0) , m_suspendResumeButton(0) , m_deviceBox(0) , m_device(QAudioDeviceInfo::defaultOutputDevice()) , m_generator(0) , m_audioOutput(0) , m_output(0) , m_buffer(BufferSize, 0) { initializeWindow(); initializeAudio(); }
void ShowButton::render(string mrl) { ISurface* surface; surface = ImagePlayer::renderImage(mrl); if (win == NULL) { initializeWindow(); } if (surface->setParent((void*)win)) { win->renderFrom(surface); } win->show(); win->raiseToTop(); delete surface; surface = NULL; }
int main() { srand(time(0)); GLFWwindow* window = initializeWindow(); if (window == NULL) return -1; glfwSetWindowPos(window, 300, 300); GameManager manager(window); // Enter main game loop //manager.displayEndScreen(0); manager.initMenus(); return 0; }
bool WorkshopState::initialize() { // Inicializamos la ventana del estado. if(!initializeWindow("Workshop.layout", "Workshop")) return false; // Configuramos los eventos asociados a los botones de la ventana. SubscribeToMultiColumnListSelectionChangedEvent("Workshop/Dialog/Parts", &WorkshopState::partSelected, this); SubscribeToClickedEvent("Workshop/PartButton1", &WorkshopState::partButton, this); SubscribeToClickedEvent("Workshop/PartButton2", &WorkshopState::partButton, this); SubscribeToClickedEvent("Workshop/PartButton3", &WorkshopState::partButton, this); SubscribeToClickedEvent("Workshop/PartButton4", &WorkshopState::partButton, this); SubscribeToClickedEvent("Workshop/HelpButton", &WorkshopState::helpButton, this); SubscribeToClickedEvent("Workshop/BackButton", &WorkshopState::backButton, this); SubscribeToClickedEvent("Workshop/Dialog/BuyButton", &WorkshopState::dialogBuyButton, this); SubscribeToClickedEvent("Workshop/Dialog/SelectButton", &WorkshopState::dialogSelectButton, this); SubscribeToClickedEvent("Workshop/Dialog/BackButton", &WorkshopState::dialogBackButton, this); // Obtenemos los objetos interactivos de la ventana actual. _mainPanel = Core::GUIManager::GetInstance()->getWindow("Workshop/MainPanel"); if(!_mainPanel) return false; _dialogPanel = Core::GUIManager::GetInstance()->getWindow("Workshop/PartsDialog"); if(!_dialogPanel) return false; _parts = Core::GUIManager::GetInstance()->getWindowAs<CEGUI::MultiColumnList>("Workshop/Dialog/Parts"); if(!_parts) return false; _properties = Core::GUIManager::GetInstance()->getWindow("Workshop/Dialog/Properties"); if(!_properties) return false; _money = Core::GUIManager::GetInstance()->getWindow("Workshop/Dialog/Money"); if(!_money) return false; _part1 = Core::GUIManager::GetInstance()->getWindowAs<CEGUI::PushButton>("Workshop/PartButton1"); if(!_part1) return false; _part2 = Core::GUIManager::GetInstance()->getWindowAs<CEGUI::PushButton>("Workshop/PartButton2"); if(!_part2) return false; _part3 = Core::GUIManager::GetInstance()->getWindowAs<CEGUI::PushButton>("Workshop/PartButton3"); if(!_part3) return false; _part4 = Core::GUIManager::GetInstance()->getWindowAs<CEGUI::PushButton>("Workshop/PartButton4"); if(!_part4) return false; return true; }
void Purity::Engine::initialize() { std::cout << "Initializing some stuff..." << std::endl; #ifdef __gnu_linux__ XInitThreads(); #endif mInputQueue = std::unique_ptr<std::queue<sf::Event>>(new std::queue<sf::Event>); initializeWindow(); initializeRenderer(); initializeSceneManager(); initializePhysicsSystem(); initializeInputManager(); luabind::globals(LuaManager::getManager()->getState())["GPurityEngine"] = this; }
int createSession(const char *file){ // creates and initiates a new session if(sessionCount==MAXSESSION){ printf("\nCANT HAVE ANYMORE STATUS !!\n"); return 0; } if(isExist(file)!=1){ printf("\nCANT CREATE NEW SESSION : FILE {%s} NOT FOUND !!",file); return 0; } int session = sessionCount; sessionCount++; addNewSession(session,file); char statusFile[100]; sprintf(statusFile,"status_%i.txt",session); resetFile(statusFile); char line[1000]; // launch the session and store windowid in windowId char windowID[100]; windowID[0] = '\0'; launchPdf(file,windowID); // initialize the new openned session initializeWindow(windowID); sprintf(line,"%s",windowID); addLine(statusFile,line); sprintf(line,"%s",file); addLine(statusFile,line); sprintf(line,"%d",PAGE_DEFAULT); addLine(statusFile,line); sprintf(line,"%d",ZOOM_DEFAULT); addLine(statusFile,line); sprintf(line,"%d",WIDTH_DEFAULT); addLine(statusFile,line); sprintf(line,"%d",HEIGHT_DEFAULT); addLine(statusFile,line); page[session] = PAGE_DEFAULT; zoom[session] = ZOOM_DEFAULT; width[session] = WIDTH_DEFAULT; height[session] = HEIGHT_DEFAULT; return 1; }
void ButtonPlayer::run() { lock(); if (win == NULL) { initializeWindow(); } if (image != NULL) { delete image; image = NULL; } switch (status) { case PAUSE: render("/misc/pauseButton.png"); break; case STOP: if (previousStatus == PAUSE) { win->hide(); } render("/misc/stopButton.png"); ::usleep(1000000); win->hide(); break; case PLAY: if (previousStatus == PAUSE) { win->hide(); } render("/misc/playButton.png"); ::usleep(1000000); win->hide(); break; default: break; } unlock(); }
static void android_handle_cmd(struct android_app* app, int cmd) { switch (cmd) { case APP_CMD_INIT_WINDOW: { //-- create a window to draw on initializeWindow(); //-- initialize the engine _core = new core(); _core->initialize(&_device); } break; case APP_CMD_DESTROY: { } break; case APP_CMD_TERM_WINDOW: { delete _core; unloadWindow(); } break; case APP_CMD_RESUME: { } break; case APP_CMD_PAUSE: { } break; } }
PDTest::PDTest() { initializeWindow(); }
int main(int argc, char **argv) { AllPoints all_points; EdgesPath path; all_points.number_of_points = 0; path.size = 0; #ifdef DRAW_RESULT { const int xBound = 800; const int yBound = 600; initializeWindow(argc, argv, xBound, yBound); } #endif // #ifdef DRAW_RESULT if (argc >= 2) { read_points_from_file(argv[1], &all_points); } else { #ifdef DRAW_RESULT read_from_screen(&all_points); #endif // #ifdef DRAW_RESULT } qsort(all_points.points, all_points.number_of_points, sizeof(Point), compare_points); { const int hk_subtasks_count = (all_points.number_of_points / MAX_HELD_KARP_POINTS) + (all_points.number_of_points % MAX_HELD_KARP_POINTS ? 1 : 0); Path *pathes = calloc(hk_subtasks_count, sizeof(Path)); int start_point = 0; int current_hk_part_index = 0; for (current_hk_part_index = 0; current_hk_part_index < hk_subtasks_count; ++current_hk_part_index) { int size = MAX_HELD_KARP_POINTS; int i = 0; Path partial_path; if (current_hk_part_index + 2 == hk_subtasks_count) { size = (all_points.number_of_points - start_point) / 2; } if (current_hk_part_index + 1 == hk_subtasks_count) { size = all_points.number_of_points - start_point; } partial_path = build_held_karp_path(all_points.points + start_point, size); for (i = 0; i < size; ++i) { partial_path.points[i] += start_point; } pathes[current_hk_part_index] = partial_path; start_point += size; } // sub optimally join partial pathes { // in first path we do not have any edges that are forbidden for removal to join HK-loops. int forbidden_endge_start = -1; for (current_hk_part_index = 1; current_hk_part_index < hk_subtasks_count; ++current_hk_part_index) { float best_cost = FLT_MAX; int prev = 0; int prev_loop_edge_start = -1; int curr_loop_edge_start = -1; Edge connecting_edge_1; Edge connecting_edge_2; // for each allowed edge from previous loop for (prev = 0; prev < pathes[current_hk_part_index - 1].size; ++prev) { int curr = 0; const int prev_start_index = pathes[current_hk_part_index - 1].points[prev]; const int prev_end_index = pathes[current_hk_part_index - 1].points[(prev + 1) % pathes[current_hk_part_index - 1].size]; const Point prev_start = all_points.points[prev_start_index]; const Point prev_end = all_points.points[prev_end_index]; if (forbidden_endge_start == prev) { continue; } // for each edge from current loop for (curr = 0; curr < pathes[current_hk_part_index].size; ++curr) { // check if removing both edges and connecting loops in this points will get optimal result const int curr_start_index = pathes[current_hk_part_index].points[curr]; const int curr_end_index = pathes[current_hk_part_index].points[(curr + 1) % pathes[current_hk_part_index].size]; const Point curr_start = all_points.points[curr_start_index]; const Point curr_end = all_points.points[curr_end_index]; const float removal_cost = distance(prev_start, prev_end) + distance(curr_start, curr_end); const float start_start_connect_cost = distance(prev_start, curr_start) + distance(prev_end, curr_end); const float start_end_connect_cost = distance(prev_start, curr_end) + distance(prev_end, curr_start); if (best_cost > start_start_connect_cost - removal_cost) { best_cost = start_start_connect_cost - removal_cost; prev_loop_edge_start = prev; curr_loop_edge_start = curr; connecting_edge_1.start = prev_start_index; connecting_edge_1.end = curr_start_index; connecting_edge_2.start = prev_end_index; connecting_edge_2.end = curr_end_index; } if (best_cost > start_end_connect_cost - removal_cost) { best_cost = start_end_connect_cost - removal_cost; prev_loop_edge_start = prev; curr_loop_edge_start = curr; connecting_edge_1.start = prev_start_index; connecting_edge_1.end = curr_end_index; connecting_edge_2.start = prev_end_index; connecting_edge_2.end = curr_start_index; } } } for (prev = 0; prev < pathes[current_hk_part_index - 1].size; ++prev) { // append all edges from previous loop except forbidden and selected for removal const int prev_start_index = pathes[current_hk_part_index - 1].points[prev]; const int prev_end_index = pathes[current_hk_part_index - 1].points[(prev + 1) % pathes[current_hk_part_index - 1].size]; if (forbidden_endge_start == prev || prev_loop_edge_start == prev) { continue; } append_edge(&path, prev_start_index, prev_end_index); } { // append two extra edges added instead of removed ones append_edge(&path, connecting_edge_1.start, connecting_edge_1.end); append_edge(&path, connecting_edge_2.start, connecting_edge_2.end); } forbidden_endge_start = curr_loop_edge_start; } { int prev = 0; for (prev = 0; prev < pathes[hk_subtasks_count - 1].size; ++prev) { // append all edges from last loop except forbidden one const int prev_start_index = pathes[hk_subtasks_count - 1].points[prev]; const int prev_end_index = pathes[hk_subtasks_count - 1].points[(prev + 1) % pathes[hk_subtasks_count - 1].size]; if (forbidden_endge_start == prev) { continue; } append_edge(&path, prev_start_index, prev_end_index); } } } free(pathes); } #ifdef DRAW_RESULT // run message loop with displaying points and found path display_results(&all_points, &path); #endif // #ifdef DRAW_RESULT }
bool HippoAbstractWindow::createWindow(void) { if (!defaultPositionSet_ && (windowStyle_ & WS_OVERLAPPEDWINDOW)) { RECT workArea; int centerX = 0; int centerY = 0; if (::SystemParametersInfo(SPI_GETWORKAREA, 0, &workArea, 0)) { centerX = (workArea.left + workArea.right - getWidth()) / 2; centerY = (workArea.bottom + workArea.top - getHeight()) / 2; } #if 0 g_debug("SIZING: work area %d,%d %dx%d centering window at %d,%d", workArea.left, workArea.top, workArea.right - workArea.left, workArea.bottom - workArea.top, centerX, centerY); #endif x_ = centerX; y_ = centerY; } HippoRectangle rect; if (selfSizing_) { rect.x = CW_USEDEFAULT; rect.y = CW_USEDEFAULT; rect.width = CW_USEDEFAULT; rect.height = CW_USEDEFAULT; } else { getClientArea(&rect); convertClientRectToWindowRect(&rect); /* from this point on, x/y/width/height are defined to match the * actual x/y/width/height we've set on window_, unless we're self sizing */ /* Note that WM_SIZE is * sent right away but we ignore it since we haven't set ourselves * as window data. */ #if 0 g_debug("SIZING: creating window at window rect %d,%d %dx%d client rect %d,%d %dx%d", rect.x, rect.y, rect.width, rect.height, x_, y_, width_, height_); #endif } #if 0 g_debug("Create window style %x WS_OVERLAPPEDWINDOW=%x WS_VISIBLE=%x WS_DISABLED=%x WS_CHILD=%x WS_POPUP=%x WS_CAPTION=%x WS_SYSMENU=%x WS_MINIMIZEBOX=%x", windowStyle_, windowStyle_ & WS_OVERLAPPEDWINDOW, windowStyle_ & WS_VISIBLE, windowStyle_ & WS_DISABLED, windowStyle_ & WS_CHILD, windowStyle_ & WS_POPUP, windowStyle_ & WS_CAPTION, windowStyle_ & WS_SYSMENU, windowStyle_ & WS_MINIMIZEBOX); #endif window_ = CreateWindowEx(extendedStyle_, className_, title_, windowStyle_, rect.x, rect.y, rect.width, rect.height, (useParent_ && ui_) ? ui_->getWindow() : (createWithParent_ ? createWithParent_->window_ : NULL), NULL, instance_, NULL); if (!window_) { hippoDebugLastErr(L"Couldn't create window!"); return false; } if (selfSizing_) { // Get the default sizes Windows picked, // though this is somewhat pointless since right // now selfSizing_ is used for common controls // and we don't get WM_SIZE/WM_MOVE on those // so won't be keeping this up to date anyhow queryCurrentClientRect(&rect); x_ = rect.x; y_ = rect.y; width_ = rect.width; height_ = rect.height; } else { // Sanity check we set what we wanted HippoRectangle actual; HippoRectangle believed; getClientArea(&believed); queryCurrentClientRect(&actual); if (!hippo_rectangle_equal(&believed, &actual)) { g_warning("window class %s not created with expected dimensions, actual %d,%d %dx%d believed %d,%d %dx%d", HippoUStr(getClassName()).c_str(), actual.x, actual.y, actual.width, actual.height, believed.x, believed.y, believed.width, believed.height); // Fix up and try to continue x_ = actual.x; y_ = actual.y; width_ = actual.width; height_ = actual.height; } } //EnableScrollBar(window_, SB_BOTH, ESB_DISABLE_BOTH); hippoSetWindowData<HippoAbstractWindow>(window_, this); g_assert(ui_ != NULL); ui_->registerMessageHook(window_, this); initializeWindow(); return true; }
void gkEngine::initialize() { if (m_initialized) return; gkUserDefs& defs = getUserDefs(); gkLogger::enable(defs.log, defs.verbose); if (defs.rendersystem == OGRE_RS_UNKNOWN) { gkPrintf("Unknown rendersystem!\n"); return; } Ogre::Root* root = new Ogre::Root("", ""); m_private->root = root; m_private->plugin_factory->createRenderSystem(root, defs.rendersystem); m_private->plugin_factory->createParticleSystem(root); m_private->archive_factory->addArchiveFactory(); const Ogre::RenderSystemList& renderers = root->getAvailableRenderers(); if (renderers.empty()) { gkPrintf("No rendersystems present\n"); return; } root->setRenderSystem(renderers[0]); #if defined(_MSC_VER) && defined(OGRE_BUILD_RENDERSYSTEM_GLES2) renderers[0]->setConfigOption("RTT Preferred Mode", "Copy"); //angleproject gles2 #endif root->initialise(false); m_private->windowsystem = new gkWindowSystem(); // gk Managers new gkResourceGroupManager(); new gkSceneManager(); #ifdef OGREKIT_USE_NNODE new gkNodeManager(); #endif new gkBlendLoader(); new gkTextManager(); new gkMessageManager(); new gkMeshManager(); new gkSkeletonManager(); #ifdef OGREKIT_USE_PARTICLE new gkParticleManager(); #endif new gkHUDManager(); new gkGroupManager(); new gkGameObjectManager(); new gkAnimationManager(); #ifdef OGREKIT_USE_LUA new gkLuaManager(); #endif #if defined(OGREKIT_COMPILE_OGRE_SCRIPTS) || defined(OGREKIT_COMPILE_LIBROCKET) new gkFontManager(); #endif #ifdef OGREKIT_COMPILE_LIBROCKET new gkGUIManager(); #endif #ifdef OGREKIT_OPENAL_SOUND new gkSoundManager(); #endif #ifdef OGREKIT_USE_COMPOSITOR new gkCompositorManager(); #endif initializeWindow(); if (!defs.resources.empty()) loadResources(defs.resources); #ifdef OGREKIT_USE_RTSHADER_SYSTEM defs.hasFixedCapability = renderers[0]->getCapabilities()->hasCapability(Ogre::RSC_FIXED_FUNCTION); gkResourceGroupManager::getSingleton().initRTShaderSystem( m_private->plugin_factory->getShaderLanguage(), defs.shaderCachePath, defs.hasFixedCapability); #endif // create the builtin resource group gkResourceGroupManager::getSingleton().createResourceGroup(GK_BUILTIN_GROUP); gkResourceGroupManager::getSingleton().initialiseAllResourceGroups(); #ifdef OGREKIT_USE_PARTICLE gkParticleManager::getSingleton().initialize(); #endif #ifdef OGREKIT_USE_COMPOSITOR gkCompositorManager::getSingleton().initialize(); #endif // debug info m_private->debug = new gkDebugScreen(); m_private->debug->initialize(); m_private->debugPage = new gkDebugPropertyPage(); m_private->debugPage->initialize(); m_private->debugFps = new gkDebugFps(); m_private->debugFps->initialize(); m_private->debugFps->show(defs.debugFps); // statistics and profiling new gkStats(); m_initialized = true; }