Example #1
0
File: Widget.cpp Project: lieff/g3d
void EventCoordinateMapper::update(RenderDevice* rd) {
    // Ignore depth-only rendering for shadow maps and early z
    if (rd->colorWrite()) {
        m_lastProjection = Projection(rd->projectionMatrix());
        m_lastCameraToWorldMatrix = rd->cameraToWorldMatrix();
        m_lastViewport = rd->viewport();
        
        OSWindow* osWindow = rd->window();
        m_lastGuardBandOffset = max(Point2(0.0f, 0.0f), (m_lastViewport.wh() - osWindow->clientRect().wh()) / 2.0f);
    }
}
Example #2
0
void VideoRecordDialog::startRecording() {
    debugAssert(isNull(m_video));

    // Create the video file
    VideoOutput::Settings settings = m_settingsTemplate[m_templateIndex];
    OSWindow* window = const_cast<OSWindow*>(OSWindow::current());
    settings.width = window->width();
    settings.height = window->height();

    if (m_halfSize) {
        settings.width /= 2;
        settings.height /= 2;
    }

    double kps = 1000;
    double baseRate = 1500;
    if (settings.codec == VideoOutput::CODEC_ID_WMV2) {
        // WMV is lower quality
        baseRate = 3000;
    }
    settings.bitrate = iRound(m_quality * baseRate * kps * settings.width * settings.height / (640 * 480));
    settings.fps = m_playbackFPS;

    const String& filename = ScreenshotDialog::nextFilenameBase(m_filenamePrefix) + "." + m_settingsTemplate[m_templateIndex].extension;
    m_video = VideoOutput::create(filename, settings);

    if (m_app) {
        m_oldSimTimeStep = m_app->simStepDuration();
        m_oldRealTimeTargetDuration = m_app->realTimeTargetDuration();

        m_app->setFrameDuration(1.0f / m_recordFPS, GApp::MATCH_REAL_TIME_TARGET);
    }

    m_recordButton->setCaption("Stop (" + m_hotKeyString + ")");
    setVisible(false);

    // Change the window caption as well
    const String& c = window->caption();
    const String& appendix = " - Recording " + m_hotKeyString + " to stop";
    if (! endsWith(c, appendix)) {
        window->setCaption(c + appendix);
    }
}
Example #3
0
void GuiMenu::show(WidgetManager* manager, GuiWindow* superior, GuiControl* eventSource, const Vector2& position, bool modal, const GuiControl::Callback& actionCallback) {
    m_actionCallback = actionCallback;
    m_superior = superior;
    m_eventSource = eventSource;
    manager->add(this);

    // Clamp position to screen bounds
    OSWindow* osWindow = (superior != NULL) ? superior->window() : RenderDevice::lastRenderDeviceCreated->window();
    const Vector2 high(osWindow->width() - m_rect.width(), osWindow->height() - m_rect.height());
    Vector2 actualPos = position.min(high).max(Vector2(0,0));

    moveTo(actualPos);
    manager->setFocusedWidget(this);

    if (modal) {
        showModal(superior);
    } else {
        setVisible(true);
    }
}
Example #4
0
void VideoRecordDialog::stopRecording() {
    debugAssert(m_video);

    // Save the movie
    m_video->commit();
    String oldFilename = m_video->filename();
    String newFilename = oldFilename;
    m_video.reset();

    if (ScreenshotDialog::create(window(), theme(), FilePath::parent(newFilename))->getFilename(newFilename, "Save Movie")) {
        newFilename = trimWhitespace(newFilename);

        if (newFilename.empty()) {
            // Cancelled--delete the file
            FileSystem::removeFile(oldFilename);
        } else {
            if (oldFilename != newFilename) {
                FileSystem::rename(oldFilename, newFilename);
            }
            saveMessage(newFilename);
        }
    }

    if (m_app) {
        // Restore the app state
        m_app->setFrameDuration(m_oldRealTimeTargetDuration, m_oldSimTimeStep);
    }

    // Reset the GUI
    m_recordButton->setCaption("Record Now (" + m_hotKeyString + ")");

    // Restore the window caption as well
    OSWindow* window = const_cast<OSWindow*>(OSWindow::current());
    const String& c = window->caption();
    const String& appendix = " - Recording " + m_hotKeyString + " to stop";
    if (endsWith(c, appendix)) {
        window->setCaption(c.substr(0, c.size() - appendix.size()));
    }
}
bool IsPlatformAvailable(const PlatformParameters &param)
{
    switch (param.getRenderer())
    {
      case EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE:
        break;

      case EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE:
#ifndef ANGLE_ENABLE_D3D9
        return false;
#endif
        break;

      case EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE:
#ifndef ANGLE_ENABLE_D3D11
        return false;
#endif
        break;

      case EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE:
      case EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE:
#ifndef ANGLE_ENABLE_OPENGL
        return false;
#endif
        break;

      default:
        UNREACHABLE();
        break;
    }

    static std::map<PlatformParameters, bool> paramAvailabilityCache;
    auto iter = paramAvailabilityCache.find(param);
    if (iter != paramAvailabilityCache.end())
    {
        return iter->second;
    }
    else
    {
        OSWindow *osWindow = CreateOSWindow();
        bool result = osWindow->initialize("CONFIG_TESTER", 1, 1);

        if (result)
        {
            EGLWindow *eglWindow = new EGLWindow(1, 1, param.majorVersion, param.eglParameters);
            result = eglWindow->initializeGL(osWindow);

            eglWindow->destroyGL();
            SafeDelete(eglWindow);
        }

        osWindow->destroy();
        SafeDelete(osWindow);

        paramAvailabilityCache[param] = result;

        if (!result)
        {
            std::cout << "Skipping tests using configuration " << param << " because it is not available." << std::endl;
        }

        return result;
    }
}