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


C++ GLContext类代码示例

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


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

示例1: renderFX

void Canvas::renderWindow(WindowPtr pWindow, MCFBOPtr pFBO, const IntRect& viewport)
{
    GLContext* pContext = pWindow->getGLContext();
    pContext->activate();

    GLContextManager::get()->uploadDataForContext();
    renderFX(pContext);
    glm::mat4 projMat;
    if (pFBO) {
        pFBO->activate(pContext);
        glm::vec2 size = m_pRootNode->getSize();
        projMat = glm::ortho(0.f, size.x, 0.f, size.y);
        glViewport(0, 0, GLsizei(size.x), GLsizei(size.y));
    } else {
        glproc::BindFramebuffer(GL_FRAMEBUFFER, 0);
        projMat = glm::ortho(float(viewport.tl.x), float(viewport.br.x), 
                float(viewport.br.y), float(viewport.tl.y));
        IntPoint windowSize = pWindow->getSize();
        glViewport(0, 0, windowSize.x, windowSize.y);
    }
    {
        ScopeTimer Timer(VATransferProfilingZone);
        m_pVertexArray->update(pContext);
    }
    clearGLBuffers(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT,
            !pFBO);
    GLContext::checkError("Canvas::renderWindow: glViewport()");
    m_pVertexArray->activate(pContext);
    {
        ScopeTimer timer(RootRenderProfilingZone);
        m_pRootNode->maybeRender(pContext, projMat);
    }
    renderOutlines(pContext, projMat);
}
开发者ID:eladm29,项目名称:libavg,代码行数:34,代码来源:Canvas.cpp

示例2: Timer

void RasterNode::renderFX()
{
    if (m_bFXDirty || m_pSurface->isDirty() || m_pFXNode->isDirty()) {
        ScopeTimer Timer(FXProfilingZone);
        GLContext* pContext = GLContext::getCurrent();
        StandardShader::get()->setAlpha(1.0f);
        m_pSurface->activate(getMediaSize());

        m_pFBO->activate();
        clearGLBuffers(GL_COLOR_BUFFER_BIT, false);

        bool bPremultipliedAlpha = m_pSurface->isPremultipliedAlpha();
        if (bPremultipliedAlpha) {
            glproc::BlendColor(1.0f, 1.0f, 1.0f, 1.0f);
        }
        pContext->setBlendMode(GLContext::BLEND_BLEND, bPremultipliedAlpha);
        m_pImagingProjection->setColor(m_Color);
        m_pImagingProjection->draw(StandardShader::get()->getShader());
/*
        static int i=0;
        stringstream ss;
        ss << "node" << i << ".png";
        BitmapPtr pBmp = m_pFBO->getImage(0);
        pBmp->save(ss.str());
*/  
        m_pFXNode->apply(m_pFBO->getTex()->getCurTex());
        
/*        
        stringstream ss1;
        ss1 << "nodefx" << i << ".png";
        i++;
        m_pFXNode->getImage()->save(ss1.str());
*/
    }
}
开发者ID:tradzik,项目名称:libavg,代码行数:35,代码来源:RasterNode.cpp

示例3: swapBuffersIfNeeded

void ImageBufferData::swapBuffersIfNeeded()
{
    if (!m_bufferChanged)
        return;

    GLContext* previousActiveContext = GLContext::getCurrent();
    cairo_surface_flush(m_surface.get());

    if (!m_compositorTexture) {
        createCompositorBuffer();
        LockHolder holder(m_platformLayerProxy->lock());
        m_platformLayerProxy->pushNextBuffer(std::make_unique<TextureMapperPlatformLayerBuffer>(m_compositorTexture, m_size, TextureMapperGL::ShouldBlend));
    }

    // It would be great if we could just swap the buffers here as we do with webgl, but that breaks the cases
    // where one frame uses the content already rendered in the previous frame. So we just copy the content
    // into the compositor buffer.
    cairo_set_source_surface(m_compositorCr.get(), m_surface.get(), 0, 0);
    cairo_set_operator(m_compositorCr.get(), CAIRO_OPERATOR_SOURCE);
    cairo_paint(m_compositorCr.get());

    m_bufferChanged = false;
    if (previousActiveContext)
        previousActiveContext->makeContextCurrent();
}
开发者ID:valbok,项目名称:WebKitForWayland,代码行数:25,代码来源:ImageBufferCairo.cpp

示例4:

void
GLBlitTextureImageHelper::SetBlitFramebufferForDestTexture(GLuint aTexture)
{
    GLContext *gl = mCompositor->gl();
    if (!mBlitFramebuffer) {
        gl->fGenFramebuffers(1, &mBlitFramebuffer);
    }

    gl->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, mBlitFramebuffer);
    gl->fFramebufferTexture2D(LOCAL_GL_FRAMEBUFFER,
                               LOCAL_GL_COLOR_ATTACHMENT0,
                               LOCAL_GL_TEXTURE_2D,
                               aTexture,
                               0);

    GLenum result = gl->fCheckFramebufferStatus(LOCAL_GL_FRAMEBUFFER);
    if (aTexture && (result != LOCAL_GL_FRAMEBUFFER_COMPLETE)) {
        nsAutoCString msg;
        msg.AppendLiteral("Framebuffer not complete -- error 0x");
        msg.AppendInt(result, 16);
        // Note: if you are hitting this, it is likely that
        // your texture is not texture complete -- that is, you
        // allocated a texture name, but didn't actually define its
        // size via a call to TexImage2D.
        NS_RUNTIMEABORT(msg.get());
    }
}
开发者ID:msliu,项目名称:gecko-dev,代码行数:27,代码来源:GLBlitTextureImageHelper.cpp

示例5: GLTextureSource

bool
GLTextureHost::Lock()
{
  GLContext* gl = this->gl();
  if (!gl || !gl->MakeCurrent()) {
    return false;
  }

  if (mSync) {
    if (!gl->MakeCurrent()) {
      return false;
    }
    gl->fWaitSync(mSync, 0, LOCAL_GL_TIMEOUT_IGNORED);
    gl->fDeleteSync(mSync);
    mSync = 0;
  }

  if (!mTextureSource) {
    gfx::SurfaceFormat format = mHasAlpha ? gfx::SurfaceFormat::R8G8B8A8
                                          : gfx::SurfaceFormat::R8G8B8X8;
    mTextureSource = new GLTextureSource(mProvider,
                                         mTexture,
                                         mTarget,
                                         mSize,
                                         format,
                                         false /* owned by the client */);
  }

  return true;
}
开发者ID:luke-chang,项目名称:gecko-1,代码行数:30,代码来源:TextureHostOGL.cpp

示例6: GetOpenGLContext

void GLDriver::ShareOpenGLContext(HGLRC contextA, HGLRC contextB)
{
  GLContext * aContext = GetOpenGLContext(contextA);
  GLContext * bContext = GetOpenGLContext(contextB);

  //If both contexts were retrieved, assign the context data
  if(aContext && bContext)
  {
    //Share the internal list data
    if(!aContext->ShareLists(bContext))
    {
      LOGERR(("ShareOpenGLContext - Unable to share internal lists"));
    }

    //Flag to the plugin manager that the share has occured
    if(pluginManager)
    {
      pluginManager->OnGLContextShareLists(contextA,contextB);
    }
  }
  else
  {
    LOGERR(("ShareOpenGLContext - Unable to get internal contexts"));
  }
}
开发者ID:jrco,项目名称:nau,代码行数:25,代码来源:GLDriver.cpp

示例7: assert

	void InterfaceManager::reportFPS(void)
	{
		WavesGlobalState *wgs = WavesGlobalState::getInstance();
		assert(wgs != NULL);

		FPSMonitor &fpsMonitor = wgs->getFPSMonitor();
		fpsMonitor.markRender(glutGet(GLUT_ELAPSED_TIME));
		float fps = fpsMonitor.getFPS();
		float bpm = wgs->getBpm();

		glMatrixMode(GL_MODELVIEW);
		glPushMatrix();

		glPushAttrib(GL_CURRENT_BIT | GL_LINE_WIDTH);
		glLineWidth(1.0f);
		glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

		GLContext *currContext = GLContext::getCurrentContext();
		assert(currContext != NULL);

		char str[16];
		sprintf(str, "BPM: %3.1f", bpm);
		glTranslatef(0.01f, 0.01f, 0.0f);
		currContext->renderString(str, Vector2f(0.07f, 0.0125f));

		sprintf(str, "FPS: %2.1f", fps);
		glTranslatef(0.00f, 0.0175f, 0.0f);		
		currContext->renderString(str, Vector2f(0.0625f, 0.0125f));

		glPopAttrib();
		glPopMatrix();
	}
开发者ID:jonathanhook,项目名称:Waves,代码行数:32,代码来源:InterfaceManager.cpp

示例8: initOpenGL

void GLGraphicsImpl::initOpenGL( GLContext& context ) {
    //Is this the first time we've called this function?
    //If m_initialized is "false", set it to "true" and continue.
    //Otherwise, stop here.
    bool expect = false;
    if( !m_initialized.compare_exchange_strong( expect, true ) )
        return;

    //Activate our context temporarily
    context.begin();

    //Now that a context is loaded we can load extensions
    loadOpenGLExtensions();

    //Get the version of OpenGL we're using and log it
    GLint major, minor;
    glGetIntegerv( GL_MAJOR_VERSION, &major );
    glGetIntegerv( GL_MINOR_VERSION, &minor );

    logInfo( ( boost::format( "OpenGL version is %d.%d." ) % major % minor ).str() );

    //Log supported extensions
    GLint extensions;
    glGetIntegerv( GL_NUM_EXTENSIONS, &extensions );
    logInfo( "Supported extensions:" );
    for( GLuint i = 0; i < (GLuint)extensions; ++i )
        logInfo( (
            boost::format( "%4d:    %s" ) %
            (i+1) %
            glGetStringi( GL_EXTENSIONS, i )
        ).str() );

    //Done using it
    context.end();
}
开发者ID:theJ8910,项目名称:Brimstone,代码行数:35,代码来源:GLGraphicsImpl.cpp

示例9: blt

void RasterNode::blt(const glm::mat4& transform, const glm::vec2& destSize)
{
    GLContext* pContext = GLContext::getCurrent();
    FRect destRect;
    
    StandardShaderPtr pShader = pContext->getStandardShader();
    float opacity = getEffectiveOpacity();
    pContext->setBlendColor(glm::vec4(1.0f, 1.0f, 1.0f, opacity));
    pShader->setAlpha(opacity);
    if (m_pFXNode) {
        pContext->setBlendMode(m_BlendMode, true);
        m_pFXNode->getTex()->activate(GL_TEXTURE0);
        pShader->setColorModel(0);
        pShader->disableColorspaceMatrix();
        pShader->setGamma(glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
        pShader->setPremultipliedAlpha(true);
        pShader->setMask(false);

        FRect relDestRect = m_pFXNode->getRelDestRect();
        destRect = FRect(relDestRect.tl.x*destSize.x, relDestRect.tl.y*destSize.y,
                relDestRect.br.x*destSize.x, relDestRect.br.y*destSize.y);
    } else {
        m_pSurface->activate(getMediaSize());
        pContext->setBlendMode(m_BlendMode, m_pSurface->isPremultipliedAlpha());
        destRect = FRect(glm::vec2(0,0), destSize);
    }
    glm::vec3 pos(destRect.tl.x, destRect.tl.y, 0);
    glm::vec3 scaleVec(destRect.size().x, destRect.size().y, 1);
    glm::mat4 localTransform = glm::translate(transform, pos);
    localTransform = glm::scale(localTransform, scaleVec);
    pShader->setTransform(localTransform);
    pShader->activate();
    m_pSubVA->draw();
}
开发者ID:tradzik,项目名称:libavg,代码行数:34,代码来源:RasterNode.cpp

示例10: glGenTextures

void ImageBufferData::createCairoGLSurface()
{
    GLContext::sharingContext()->makeContextCurrent();

    // We must generate the texture ourselves, because there is no Cairo API for extracting it
    // from a pre-existing surface.
    glGenTextures(1, &m_texture);
    glBindTexture(GL_TEXTURE_2D, m_texture);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

    glTexImage2D(GL_TEXTURE_2D, 0 /* level */, GL_RGBA, m_size.width(), m_size.height(), 0 /* border */, GL_RGBA, GL_UNSIGNED_BYTE, 0);

    GLContext* context = GLContext::sharingContext();
    cairo_device_t* device = context->cairoDevice();

    // Thread-awareness is a huge performance hit on non-Intel drivers.
    cairo_gl_device_set_thread_aware(device, FALSE);

    m_surface = adoptRef(cairo_gl_surface_create_for_texture(device, CAIRO_CONTENT_COLOR_ALPHA, m_texture, m_size.width(), m_size.height()));
    clearSurface(m_surface.get());
}
开发者ID:sanjeev-zerocode,项目名称:webkit,代码行数:26,代码来源:ImageBufferCairo.cpp

示例11: PLATFORM

bool MediaPlayerPrivateGStreamerBase::ensureGstGLContext()
{
    if (m_glContext)
        return true;

    if (!m_glDisplay) {
        const auto& sharedDisplay = PlatformDisplay::sharedDisplay();
#if PLATFORM(X11)
        m_glDisplay = GST_GL_DISPLAY(gst_gl_display_x11_new_with_display(downcast<PlatformDisplayX11>(sharedDisplay).native()));
#elif PLATFORM(WAYLAND)
        m_glDisplay = GST_GL_DISPLAY(gst_gl_display_egl_new_with_egl_display(downcast<PlatformDisplayWayland>(sharedDisplay).native()));
#endif
    }

    GLContext* webkitContext = GLContext::sharingContext();
    // EGL and GLX are mutually exclusive, no need for ifdefs here.
    GstGLPlatform glPlatform = webkitContext->isEGLContext() ? GST_GL_PLATFORM_EGL : GST_GL_PLATFORM_GLX;

#if USE(OPENGL_ES_2)
    GstGLAPI glAPI = GST_GL_API_GLES2;
#elif USE(OPENGL)
    GstGLAPI glAPI = GST_GL_API_OPENGL;
#else
    ASSERT_NOT_REACHED();
#endif

    PlatformGraphicsContext3D contextHandle = webkitContext->platformContext();
    if (!contextHandle)
        return false;

    m_glContext = gst_gl_context_new_wrapped(m_glDisplay.get(), reinterpret_cast<guintptr>(contextHandle), glPlatform, glAPI);

    return true;
}
开发者ID:rhythmkay,项目名称:webkit,代码行数:34,代码来源:MediaPlayerPrivateGStreamerBase.cpp

示例12: autoRB

void
WebGLRenderbuffer::RenderbufferStorage(GLenum internalFormat, GLsizei width, GLsizei height) const {
    GLContext* gl = mContext->gl;

    GLenum primaryFormat = internalFormat;
    GLenum secondaryFormat = 0;

    if (NeedsDepthStencilEmu(mContext->gl, primaryFormat)) {
        primaryFormat = DepthStencilDepthFormat(gl);
        secondaryFormat = LOCAL_GL_STENCIL_INDEX8;
    }

    gl->fRenderbufferStorage(LOCAL_GL_RENDERBUFFER, primaryFormat, width, height);
    
    if (!mSecondaryRB) {
        MOZ_ASSERT(!secondaryFormat);
        return;
    }
    // We can't leave the secondary RB unspecified either, since we should
    // handle the case where we attach a non-depth-stencil RB to a
    // depth-stencil attachment point, or attach this depth-stencil RB to a
    // non-depth-stencil attachment point.
    ScopedBindRenderbuffer autoRB(gl, mSecondaryRB);
    if (secondaryFormat) {
        gl->fRenderbufferStorage(LOCAL_GL_RENDERBUFFER, secondaryFormat, width, height);
    } else {
        gl->fRenderbufferStorage(LOCAL_GL_RENDERBUFFER, LOCAL_GL_RGBA4, 1, 1);
    }
}
开发者ID:ak352,项目名称:mozilla-central,代码行数:29,代码来源:WebGLRenderbuffer.cpp

示例13: pBmp

BitmapPtr BmpTextureMover::moveTextureToBmp(GLTexture& tex, int mipmapLevel)
{
    GLContext* pContext = GLContext::getCurrent();
    unsigned fbo = pContext->genFBO();
    glproc::BindFramebuffer(GL_FRAMEBUFFER, fbo);
    glproc::FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
                                 tex.getID(), mipmapLevel);
    FBO::checkError("BmpTextureMover::moveTextureToBmp");
    IntPoint size = tex.getMipmapSize(mipmapLevel);
    BitmapPtr pBmp(new Bitmap(size, getPF()));
    if (GLContext::getMain()->isGLES() && getPF() == B5G6R5) {
        BitmapPtr pTmpBmp(new Bitmap(size, R8G8B8));
        glReadPixels(0, 0, size.x, size.y, GL_RGB, GL_UNSIGNED_BYTE, pTmpBmp->getPixels());
        FilterFlipRGB().applyInPlace(pTmpBmp);
        pBmp->copyPixels(*pTmpBmp);
    } else {
        int glPixelFormat = tex.getGLFormat(getPF());
        glReadPixels(0, 0, size.x, size.y, glPixelFormat, tex.getGLType(getPF()),
                     pBmp->getPixels());
    }
    GLContext::checkError("BmpTextureMover::moveTextureToBmp: glReadPixels()");
    glproc::FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
                                 0, 0);
    pContext->returnFBOToCache(fbo);
    glproc::BindFramebuffer(GL_FRAMEBUFFER, 0);
    return pBmp;

}
开发者ID:pararthshah,项目名称:libavg-vaapi,代码行数:28,代码来源:BmpTextureMover.cpp

示例14: protect

void LayerTreeHostGtk::flushAndRenderLayers()
{
    {
        RefPtr<LayerTreeHostGtk> protect(this);
        m_webPage->layoutIfNeeded();

        if (!m_isValid)
            return;
    }

    GLContext* context = glContext();
    if (!context || !context->makeContextCurrent())
        return;

    m_lastFlushTime = currentTime();
    if (!flushPendingLayerChanges())
        return;

    // Our model is very simple. We always composite and render the tree immediately after updating it.
    compositeLayersToContext();

    if (m_notifyAfterScheduledLayerFlush) {
        // Let the drawing area know that we've done a flush of the layer changes.
        static_cast<DrawingAreaImpl*>(m_webPage->drawingArea())->layerHostDidFlushLayers();
        m_notifyAfterScheduledLayerFlush = false;
    }
}
开发者ID:CannedFish,项目名称:webkitgtk,代码行数:27,代码来源:LayerTreeHostGtk.cpp

示例15: EnsureGLContext

void EnsureGLContext(const GrGLInterface* i)
{
    const SkiaGLGlue* contextSkia = reinterpret_cast<const SkiaGLGlue*>(i->fCallbackData);
    MOZ_ASSERT(contextSkia);
    GLContext* gl = contextSkia->GetGLContext();
    gl->MakeCurrent();
    SetStaticGLContext(gl);
}
开发者ID:Jar-win,项目名称:Waterfox,代码行数:8,代码来源:SkiaGLGlue.cpp


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