当前位置: 首页>>代码示例>>C++>>正文


C++ eglSwapInterval函数代码示例

本文整理汇总了C++中eglSwapInterval函数的典型用法代码示例。如果您正苦于以下问题:C++ eglSwapInterval函数的具体用法?C++ eglSwapInterval怎么用?C++ eglSwapInterval使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了eglSwapInterval函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: m_depth

QTaskOneScreen::QTaskOneScreen(EGLNativeDisplayType display)
    : m_depth(32)
    , m_format(QImage::Format_Invalid)
    , m_platformContext(0)
    , m_surface(0)
{
#ifdef QEGL_EXTRA_DEBUG
    qWarning("QTaskOneScreen %p\n", this);
#endif

    EGLint major, minor;
#ifdef QEGL_EXTRA_DEBUG
    EGLint index;
#endif
    if (!eglBindAPI(EGL_OPENGL_ES_API)) {
        qWarning("Could not bind GL_ES API\n");
        qFatal("EGL error");
    }

    m_dpy = eglGetDisplay(display);
    disp = m_dpy;
    if (m_dpy == EGL_NO_DISPLAY) {
        qWarning("Could not open egl display\n");
        qFatal("EGL error");
    }
    qWarning("Opened display %p\n", m_dpy);

    if (!eglInitialize(m_dpy, &major, &minor)) {
        qWarning("Could not initialize egl display\n");
        qFatal("EGL error");
    }

    qWarning("Initialized display %d %d\n", major, minor);

    int swapInterval = 1;
    QByteArray swapIntervalString = qgetenv("QT_QPA_EGLFS_SWAPINTERVAL");
    if (!swapIntervalString.isEmpty()) {
        bool ok;
        swapInterval = swapIntervalString.toInt(&ok);
        if (!ok)
            swapInterval = 1;
    }
    eglSwapInterval(m_dpy, swapInterval);

    m_cursor = new QTaskOneCursor(this);
}
开发者ID:RS102839,项目名称:qt,代码行数:46,代码来源:qtaskonescreen.cpp

示例2: qgetenv

bool QEglFSContext::makeCurrent(QPlatformSurface *surface)
{
    bool current = QEGLPlatformContext::makeCurrent(surface);
    if (current && !m_swapIntervalConfigured) {
        m_swapIntervalConfigured = true;
        int swapInterval = 1;
        QByteArray swapIntervalString = qgetenv("QT_QPA_EGLFS_SWAPINTERVAL");
        if (!swapIntervalString.isEmpty()) {
            bool ok;
            swapInterval = swapIntervalString.toInt(&ok);
            if (!ok)
                swapInterval = 1;
        }
        eglSwapInterval(eglDisplay(), swapInterval);
    }
    return current;
}
开发者ID:mer-hybris,项目名称:qt5-qpa-hwcomposer-plugin,代码行数:17,代码来源:qeglfscontext.cpp

示例3: Q_ASSERT

bool QEGLPlatformContext::makeCurrent(QPlatformSurface *surface)
{
    Q_ASSERT(surface->surface()->supportsOpenGL());

    eglBindAPI(m_api);

    EGLSurface eglSurface = eglSurfaceForPlatformSurface(surface);

    if (eglSurface == EGL_NO_SURFACE)
        return false;

    // shortcut: on some GPUs, eglMakeCurrent is not a cheap operation
    if (eglGetCurrentContext() == m_eglContext &&
        eglGetCurrentDisplay() == m_eglDisplay &&
        eglGetCurrentSurface(EGL_READ) == eglSurface &&
        eglGetCurrentSurface(EGL_DRAW) == eglSurface) {
        return true;
    }

    const bool ok = eglMakeCurrent(m_eglDisplay, eglSurface, eglSurface, m_eglContext);
    if (ok) {
        if (!m_swapIntervalEnvChecked) {
            m_swapIntervalEnvChecked = true;
            if (qEnvironmentVariableIsSet("QT_QPA_EGLFS_SWAPINTERVAL")) {
                QByteArray swapIntervalString = qgetenv("QT_QPA_EGLFS_SWAPINTERVAL");
                bool intervalOk;
                const int swapInterval = swapIntervalString.toInt(&intervalOk);
                if (intervalOk)
                    m_swapIntervalFromEnv = swapInterval;
            }
        }
        const int requestedSwapInterval = m_swapIntervalFromEnv >= 0
            ? m_swapIntervalFromEnv
            : surface->format().swapInterval();
        if (requestedSwapInterval >= 0 && m_swapInterval != requestedSwapInterval) {
            m_swapInterval = requestedSwapInterval;
            if (eglSurface != EGL_NO_SURFACE) // skip if using surfaceless context
                eglSwapInterval(eglDisplay(), m_swapInterval);
        }
    } else {
        qWarning("QEGLPlatformContext: eglMakeCurrent failed: %x", eglGetError());
    }

    return ok;
}
开发者ID:Sagaragrawal,项目名称:2gisqt5android,代码行数:45,代码来源:qeglplatformcontext.cpp

示例4: makeCurrent

void EglFSWaylandContext::swapBuffers(QPlatformSurface *surface)
{
    EglFSWaylandWindow *window = static_cast<EglFSWaylandWindow *>(surface);
    EGLSurface eglSurface = window->surface();

    makeCurrent(surface);

    StateGuard stateGuard;

    if (!m_blitter)
        m_blitter = new EglFSWaylandBlitter(this);
    m_blitter->blit(window);

    eglSwapInterval(eglDisplay(), format().swapInterval());
    eglSwapBuffers(eglDisplay(), eglSurface);

    //window.setCanResize(true);
}
开发者ID:comicfans,项目名称:greenisland,代码行数:18,代码来源:eglfswaylandcontext.cpp

示例5: TEST_F

TEST_F(SurfaceTextureGLToGLTest, EglDestroySurfaceUnrefsBuffers) {
    sp<GraphicBuffer> buffers[2];

    // This test requires async mode to run on a single thread.
    EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mProducerEglSurface,
            mProducerEglSurface, mProducerEglContext));
    ASSERT_EQ(EGL_SUCCESS, eglGetError());
    EXPECT_TRUE(eglSwapInterval(mEglDisplay, 0));
    ASSERT_EQ(EGL_SUCCESS, eglGetError());

    for (int i = 0; i < 2; i++) {
        // Produce a frame
        EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mProducerEglSurface,
                mProducerEglSurface, mProducerEglContext));
        ASSERT_EQ(EGL_SUCCESS, eglGetError());
        glClear(GL_COLOR_BUFFER_BIT);
        eglSwapBuffers(mEglDisplay, mProducerEglSurface);

        // Consume a frame
        EXPECT_TRUE(eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
                mEglContext));
        ASSERT_EQ(EGL_SUCCESS, eglGetError());
        mFW->waitForFrame();
        ASSERT_EQ(NO_ERROR, mST->updateTexImage());
        buffers[i] = mST->getCurrentBuffer();
    }

    // Destroy the GL texture object to release its ref on buffers[2].
    GLuint texID = TEX_ID;
    glDeleteTextures(1, &texID);

    // Destroy the EGLSurface
    EXPECT_TRUE(eglDestroySurface(mEglDisplay, mProducerEglSurface));
    ASSERT_EQ(EGL_SUCCESS, eglGetError());
    mProducerEglSurface = EGL_NO_SURFACE;

    // This test should have the only reference to buffer 0.
    EXPECT_EQ(1, buffers[0]->getStrongCount());

    // The GLConsumer should hold a single reference to buffer 1 in its
    // mCurrentBuffer member.  All of the references in the slots should have
    // been released.
    EXPECT_EQ(2, buffers[1]->getStrongCount());
}
开发者ID:AOSP-JF,项目名称:platform_frameworks_native,代码行数:44,代码来源:SurfaceTextureGLToGL_test.cpp

示例6: BX_UNUSED

	void GlContext::resize(uint32_t _width, uint32_t _height, uint32_t _flags)
	{
		BX_UNUSED(_width, _height);

#	if BX_PLATFORM_ANDROID
		if (NULL != m_display)
		{
			EGLint format;
			eglGetConfigAttrib(m_display, m_config, EGL_NATIVE_VISUAL_ID, &format);
			ANativeWindow_setBuffersGeometry( (ANativeWindow*)g_platformData.nwh, _width, _height, format);
		}
#	endif // BX_PLATFORM_ANDROID

		if (NULL != m_display)
		{
			bool vsync = !!(_flags&BGFX_RESET_VSYNC);
			eglSwapInterval(m_display, vsync ? 1 : 0);
		}
	}
开发者ID:rovarma,项目名称:bgfx,代码行数:19,代码来源:glcontext_egl.cpp

示例7: eglGetCurrentSurface

    void EGLWindow::setVSyncEnabled(bool vsync) {
        mVSync = vsync;
        // we need to make our context current to set vsync
        // store previous context to restore when finished.
        ::EGLSurface oldRead = eglGetCurrentSurface(EGL_READ);
        EGL_CHECK_ERROR
        ::EGLSurface oldDraw = eglGetCurrentSurface(EGL_DRAW);
        EGL_CHECK_ERROR
        ::EGLContext  oldContext  = eglGetCurrentContext();
        EGL_CHECK_ERROR
        ::EGLDisplay dpy = mGLSupport->getGLDisplay();

        mContext->setCurrent();

        if (! mIsExternalGLControl )
        {
            eglSwapInterval(dpy, vsync ? mVSyncInterval : 0);
            EGL_CHECK_ERROR
        }
开发者ID:yiliu1203,项目名称:OGRE,代码行数:19,代码来源:OgreEGLWindow.cpp

示例8: egl_set_swap_interval

void egl_set_swap_interval(void *data, unsigned interval)
{
   /* Can be called before initialization.
    * Some contexts require that swap interval 
    * is known at startup time.
    */
   g_interval = interval;

   if (g_egl_dpy  == EGL_NO_DISPLAY)
      return;
   if (!(eglGetCurrentContext()))
      return;

   RARCH_LOG("[EGL]: eglSwapInterval(%u)\n", interval);
   if (!eglSwapInterval(g_egl_dpy, interval))
   {
      RARCH_ERR("[EGL]: eglSwapInterval() failed.\n");
      egl_report_error();
   }
}
开发者ID:Ced2911,项目名称:RetroArch,代码行数:20,代码来源:egl_common.c

示例9: eglMakeCurrent

bool CEGLWrapper::BindContext(EGLDisplay display, EGLSurface surface, EGLContext context)
{
    EGLBoolean status;
    status = eglMakeCurrent(display, surface, surface, context);
    CheckError();

    // For EGL backend, it needs to clear all the back buffers of the window
    // surface before drawing anything, otherwise the image will be blinking
    // heavily.  The default eglWindowSurface has 3 gdl surfaces as the back
    // buffer, that's why glClear should be called 3 times.
    eglSwapInterval(display, 0);
    glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
    glClear (GL_COLOR_BUFFER_BIT);
    eglSwapBuffers(display, surface);
    glClear (GL_COLOR_BUFFER_BIT);
    eglSwapBuffers(display, surface);
    glClear (GL_COLOR_BUFFER_BIT);
    eglSwapBuffers(display, surface);

    return status;
}
开发者ID:ugers,项目名称:xbmc,代码行数:21,代码来源:EGLWrapper.cpp

示例10: eglSwapBuffers

EGLint GLContext::Swap() {
  bool b = eglSwapBuffers(display_, surface_);
  if (!b) {
    EGLint err = eglGetError();
    if (err == EGL_BAD_SURFACE) {
      //Recreate surface
      InitEGLSurface();
      err = EGL_SUCCESS; //Still consider glContext is valid
    } else if (err == EGL_CONTEXT_LOST || err == EGL_BAD_CONTEXT) {
      //Context has been lost!!
      context_valid_ = false;
      Terminate();
      InitEGLContext();
    }

    return err;
  }
  if (restoreInterval_ && swapInterval_ != SWAPINTERVAL_DEFAULT) {
    eglSwapInterval(display_, swapInterval_); //Restore Swap interval
  }
  return EGL_SUCCESS;
}
开发者ID:Ratel13,项目名称:cpp-android-basic-samples,代码行数:22,代码来源:GLContext.cpp

示例11: Java_org_yabause_android_YabauseRunnable_initViewport

int Java_org_yabause_android_YabauseRunnable_initViewport( int width, int height)
{
   int swidth;
   int sheight;
   int error;
   char * buf;

   g_Display = eglGetCurrentDisplay();
   g_Surface = eglGetCurrentSurface(EGL_READ);
   g_Context = eglGetCurrentContext();

   eglQuerySurface(g_Display,g_Surface,EGL_WIDTH,&swidth);
   eglQuerySurface(g_Display,g_Surface,EGL_HEIGHT,&sheight);
   
   glViewport(0,0,swidth,sheight);
   
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   glOrthof(0, 320, 224, 0, 1, 0);
   
   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();

   glMatrixMode(GL_TEXTURE);
   glLoadIdentity();
   
   glDisable(GL_BLEND);
   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
   
   yprintf(glGetString(GL_VENDOR));
   yprintf(glGetString(GL_RENDERER));
   yprintf(glGetString(GL_VERSION));
   yprintf(glGetString(GL_EXTENSIONS));
   yprintf(eglQueryString(g_Display,EGL_EXTENSIONS));
   eglSwapInterval(g_Display,0);
   eglMakeCurrent(g_Display,EGL_NO_SURFACE,EGL_NO_SURFACE,EGL_NO_CONTEXT);
   return 0;
}
开发者ID:esperknight,项目名称:yabause,代码行数:38,代码来源:yui.c

示例12: ALOGW

bool EglManager::makeCurrent(EGLSurface surface, EGLint* errOut) {
    if (isCurrent(surface)) return false;

    if (surface == EGL_NO_SURFACE) {
        // Ensure we always have a valid surface & context
        surface = mPBufferSurface;
    }
    if (!eglMakeCurrent(mEglDisplay, surface, surface, mEglContext)) {
        if (errOut) {
            *errOut = eglGetError();
            ALOGW("Failed to make current on surface %p, error=%s", (void*)surface,
                  egl_error_str(*errOut));
        } else {
            LOG_ALWAYS_FATAL("Failed to make current on surface %p, error=%s", (void*)surface,
                             eglErrorString());
        }
    }
    mCurrentSurface = surface;
    if (Properties::disableVsync) {
        eglSwapInterval(mEglDisplay, 0);
    }
    return true;
}
开发者ID:AlanCheen,项目名称:platform_frameworks_base,代码行数:23,代码来源:EglManager.cpp

示例13: egl_make_swapbuffers_nonblock

static void
egl_make_swapbuffers_nonblock(struct egl_state *egl)
{
	EGLint a = EGL_MIN_SWAP_INTERVAL;
	EGLint b = EGL_MAX_SWAP_INTERVAL;

	if (!eglGetConfigAttrib(egl->dpy, egl->conf, a, &a) ||
	    !eglGetConfigAttrib(egl->dpy, egl->conf, b, &b)) {
		fprintf(stderr, "warning: swap interval range unknown\n");
	} else if (a > 0) {
		fprintf(stderr, "warning: minimum swap interval is %d, "
			"while 0 is required to not deadlock on resize.\n", a);
	}

	/*
	 * We rely on the Wayland compositor to sync to vblank anyway.
	 * We just need to be able to call eglSwapBuffers() without the
	 * risk of waiting for a frame callback in it.
	 */
	if (!eglSwapInterval(egl->dpy, 0)) {
		fprintf(stderr, "error: eglSwapInterval() failed.\n");
	}
}
开发者ID:ErwanDouaille,项目名称:westonHack,代码行数:23,代码来源:subsurfaces.c

示例14: PND_gl_setswapinterval

int
PND_gl_setswapinterval(_THIS, int interval)
{
    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
    EGLBoolean status;

    if (phdata->egl_initialized != SDL_TRUE) {
        return SDL_SetError("PND: EGL initialization failed, no OpenGL ES support");
    }

    /* Check if OpenGL ES connection has been initialized */
    if (phdata->egl_display != EGL_NO_DISPLAY) {
        /* Set swap OpenGL ES interval */
        status = eglSwapInterval(phdata->egl_display, interval);
        if (status == EGL_TRUE) {
            /* Return success to upper level */
            phdata->swapinterval = interval;
            return 0;
        }
    }

    /* Failed to set swap interval */
    return SDL_SetError("PND: Cannot set swap interval");
}
开发者ID:AMDmi3,项目名称:symwars3,代码行数:24,代码来源:SDL_pandora.c

示例15: gfx_ctx_qnx_set_swap_interval

static void gfx_ctx_qnx_set_swap_interval(void *data, unsigned interval)
{
   (void)data;
   eglSwapInterval(g_egl_dpy, interval);
}
开发者ID:TroggleMonkey,项目名称:RetroArch,代码行数:5,代码来源:bbqnx_ctx.c


注:本文中的eglSwapInterval函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。