egl::Error DXGISwapChainWindowSurfaceWGL::swap()
{
    mFunctionsGL->flush();

    egl::Error error = setObjectsLocked(false);
    if (error.isError())
    {
        return error;
    }

    HRESULT result = mSwapChain->Present(mSwapInterval, 0);
    mFirstSwap     = false;

    error = setObjectsLocked(true);
    if (error.isError())
    {
        return error;
    }

    if (FAILED(result))
    {
        return egl::Error(EGL_BAD_ALLOC, "Failed to present swap chain, result: 0x%X", result);
    }

    return checkForResize();
}
Пример #2
0
    Entity World::createEntity()
    {
        checkForResize(1);

        m_entityCache.alive.emplace_back(*this, m_entityIdPool.create());
        return m_entityCache.alive.back();
    }
Пример #3
0
egl::Error WindowSurfaceGLX::swap(const gl::Context *context)
{
    // We need to swap before resizing as some drivers clobber the back buffer
    // when the window is resized.
    mGLXDisplay->setSwapInterval(mGLXWindow, &mSwapControl);
    mGLX.swapBuffers(mGLXWindow);

    egl::Error error = checkForResize();
    if (error.isError())
    {
        return error;
    }

    return egl::NoError();
}
Пример #4
0
    std::vector<Entity> World::createEntities(std::size_t amount)
    {
        std::vector<Entity> temp;
        temp.reserve(amount);

        checkForResize(amount);

        for(decltype(amount) i = 0; i < amount; ++i)
        {
            Entity e{*this, m_entityIdPool.create()};
            m_entityCache.alive.push_back(e);
            temp.push_back(e);
        }

        return temp;
    }
egl::Error DXGISwapChainWindowSurfaceWGL::swap(const gl::Context *context)
{
    mFunctionsGL->flush();

    ANGLE_TRY(setObjectsLocked(false));

    HRESULT result = mSwapChain->Present(mSwapInterval, 0);
    mFirstSwap     = false;

    ANGLE_TRY(setObjectsLocked(true));

    if (FAILED(result))
    {
        return egl::EglBadAlloc() << "Failed to present swap chain, " << gl::FmtHR(result);
    }

    return checkForResize();
}
egl::Error DXGISwapChainWindowSurfaceWGL::postSubBuffer(EGLint x,
                                                        EGLint y,
                                                        EGLint width,
                                                        EGLint height)
{
    ASSERT(mSwapChain1 != nullptr);

    mFunctionsGL->flush();

    egl::Error error = setObjectsLocked(false);
    if (error.isError())
    {
        return error;
    }

    HRESULT result = S_OK;
    if (mFirstSwap)
    {
        result     = mSwapChain1->Present(mSwapInterval, 0);
        mFirstSwap = false;
    }
    else
    {
        RECT rect = {static_cast<LONG>(x), static_cast<LONG>(mHeight - y - height),
                     static_cast<LONG>(x + width), static_cast<LONG>(mHeight - y)};
        DXGI_PRESENT_PARAMETERS params = {1, &rect, nullptr, nullptr};
        result                         = mSwapChain1->Present1(mSwapInterval, 0, &params);
    }

    error = setObjectsLocked(true);
    if (error.isError())
    {
        return error;
    }

    if (FAILED(result))
    {
        return egl::Error(EGL_BAD_ALLOC, "Failed to present swap chain, result: 0x%X", result);
    }

    return checkForResize();
}
egl::Error DXGISwapChainWindowSurfaceWGL::postSubBuffer(const gl::Context *context,
                                                        EGLint x,
                                                        EGLint y,
                                                        EGLint width,
                                                        EGLint height)
{
    ASSERT(width > 0 && height > 0);
    ASSERT(mSwapChain1 != nullptr);

    mFunctionsGL->flush();

    ANGLE_TRY(setObjectsLocked(false));

    HRESULT result = S_OK;
    if (mFirstSwap)
    {
        result     = mSwapChain1->Present(mSwapInterval, 0);
        mFirstSwap = false;
    }
    else
    {
        RECT rect = {static_cast<LONG>(x), static_cast<LONG>(mHeight - y - height),
                     static_cast<LONG>(x + width), static_cast<LONG>(mHeight - y)};
        DXGI_PRESENT_PARAMETERS params = {1, &rect, nullptr, nullptr};
        result                         = mSwapChain1->Present1(mSwapInterval, 0, &params);
    }

    ANGLE_TRY(setObjectsLocked(true));

    if (FAILED(result))
    {
        return egl::EglBadAlloc() << "Failed to present swap chain, " << gl::FmtHR(result);
    }

    return checkForResize();
}