bool GCubeApp::OnAppInitialized(void) { // フレーム作成 Frame *pFrame = new Frame(); pFrame->Construct(); pFrame->SetName(L"GCube"); // フォーム作成 Form *pForm = new Form(); if (settings->showStatusBar) { pForm->Construct(FORM_STYLE_INDICATOR); } else { pForm->Construct(FORM_STYLE_NORMAL); } pForm->AddTouchEventListener(*this); pForm->AddOrientationEventListener(*this); pFrame->AddControl(pForm); pFrame->SetCurrentForm(pForm); // 画面の向き enum Orientation orientation = ORIENTATION_NONE; if (settings->orientationPortrait) { if (settings->orientationLandscapeLeft || settings->orientationLandscapeRight) { orientation = ORIENTATION_AUTOMATIC; } else { orientation = ORIENTATION_PORTRAIT; } } else { if (settings->orientationPortraitUpsideDown) { if (settings->orientationLandscapeLeft || settings->orientationLandscapeRight) { orientation = ORIENTATION_AUTOMATIC_FOUR_DIRECTION; } else { orientation = ORIENTATION_PORTRAIT_REVERSE; } } else { if (settings->orientationLandscapeLeft) { orientation = ORIENTATION_LANDSCAPE_REVERSE; } else { if (settings->orientationLandscapeRight) { orientation = ORIENTATION_LANDSCAPE; } } } } pFrame->SetOrientation(orientation); pForm->SetOrientation(orientation); pFrame->SetMultipointTouchEnabled(true); AddFrame(*pFrame); { __player = new Tizen::Graphics::Opengl::GlPlayer; __player->Construct(Tizen::Graphics::Opengl::EGL_CONTEXT_CLIENT_VERSION_2_X, pForm); __player->SetFps(settings->frameRate); __player->SetEglAttributePreset(Tizen::Graphics::Opengl::EGL_ATTRIBUTES_PRESET_ARGB8888); EGLint eglConfigList[] = { EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, EGL_ALPHA_SIZE, 8, EGL_DEPTH_SIZE, 16, EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_NONE }; __player->SetEglAttributeList(eglConfigList); __player->Start(); } __renderer = new GlRendererTemplate(); __player->SetIGlRenderer(__renderer); int w = __renderer->GetTargetControlWidth(); int h = __renderer->GetTargetControlHeight(); if (settings->debugButtonPos > 0) { // デバッグボタン作成 // TODO: XMLで作成 int dy = 0; if (settings->showStatusBar) { dy = 60; } Button* pDebugButton = new Button(); if (settings->debugButtonPos == 1) { pDebugButton->Construct(Rectangle(w-80, h-80-dy, 70, 70), L"D"); } else if (settings->debugButtonPos == 2) { pDebugButton->Construct(Rectangle(10, h-80-dy, 70, 70), L"D"); } else if (settings->debugButtonPos == 3) { pDebugButton->Construct(Rectangle(w-80, 10, 70, 70), L"D"); } else { pDebugButton->Construct(Rectangle(10, 10, 70, 70), L"D"); } pDebugButton->SetActionId(ID_DEBUG_BUTTON); pDebugButton->AddActionEventListener(*this); pForm->AddControl(pDebugButton); // ポップアップ作成 __pPopup = new Popup(); __pPopup->Construct(true, Dimension(600, 800)); __pPopup->SetTitleText(L"DebugConsole"); // ポップアップを閉じるボタン作成 Button* pCloseButton = new Button(); pCloseButton->Construct(Rectangle(30, 600, 250, 80), L"Cancel"); pCloseButton->SetActionId(ID_BUTTON_CLOSE_POPUP); pCloseButton->AddActionEventListener(*this); __pPopup->AddControl(pCloseButton); // OKボタン作成 Button* pOKButton = new Button(); pOKButton->Construct(Rectangle(320, 600, 250, 80), L"OK"); pOKButton->SetActionId(ID_BUTTON_OK_POPUP); pOKButton->AddActionEventListener(*this); __pPopup->AddControl(pOKButton); // テキスト入力 __pEditField = new EditField(); __pEditField->Construct(Rectangle(30, 500, 540, 80)); __pPopup->AddControl(__pEditField); // 説明テキスト std::vector<char> textBuff; GCGetResourceData("etc/debug.txt", textBuff); textBuff.push_back('\n'); String text = String(&textBuff[0]); TextBox *pTextBox = new TextBox(); pTextBox->Construct(Rectangle(30, 50, 540, 430)); pTextBox->SetTextSize(18); pTextBox->SetText(text); __pPopup->AddControl(pTextBox); } // サイズを通知 DeviceOrientation o = this->ConvertOrientState(pFrame->GetOrientationStatus()); gcube->onSizeChanged(w, h, o); if (settings->useOrientationSensor) { __sensorManager.Construct(); this->CreateSensor(); } return true; }