Esempio n. 1
0
void MythRenderOpenGL1::EnableShaderObject(uint obj)
{
    if ((!obj && !m_active_prog) ||
        (obj && (obj == m_active_prog)))
        return;

    makeCurrent();

    if (!obj && m_active_prog)
    {
        glDisable(GL_FRAGMENT_PROGRAM_ARB);
        m_active_prog = 0;
        doneCurrent();
        return;
    }

    if (!m_programs.contains(obj))
        return;

    if (!m_active_prog)
        glEnable(GL_FRAGMENT_PROGRAM_ARB);

    if (obj != m_active_prog)
    {
        m_glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, obj);
        m_active_prog = obj;
    }

    doneCurrent();
}
Esempio n. 2
0
void PlotGl::run()
{
	static std::atomic<std::size_t> iThread(0);
	std::size_t iThisThread = ++iThread;
	tl::log_debug("GL thread ", iThisThread, " started.");

	makeCurrent();
	initializeGLThread();

	t_real_gl dTime = 0.;
	while(m_bRenderThreadActive)
	{
		if(m_bDoResize)
		{
			std::lock_guard<QMutex> _lck(m_mutex);
			resizeGLThread(m_iW, m_iH);
			m_bDoResize = 0;
		}

		if(isVisible())
		{
			tickThread(dTime);
			paintGLThread();
		}

		long fps = isVisible() ? RENDER_FPS : (RENDER_FPS/10);
		long lns = long(1e9) / fps;
		sleep_nano(lns);
		dTime += t_real_gl(lns) * 1e-9;
	}

	doneCurrent();
	freeGLThread();
	tl::log_debug("GL thread ", iThisThread, " ended.");
}
Esempio n. 3
0
QFFmpegGLWidget::~QFFmpegGLWidget()
{
    // And now release all OpenGL resources.
    makeCurrent();

    doneCurrent();
}
Esempio n. 4
0
void QGLXContext::swapBuffers()
{
    Q_XCB_NOOP(m_screen->connection());
    glXSwapBuffers(DISPLAY_FROM_XCB(m_screen), m_drawable);
    doneCurrent();
    Q_XCB_NOOP(m_screen->connection());
}
Esempio n. 5
0
void POIsImageWidget::paintEvent(QPaintEvent *paintEvent) {

	//--- Make this widget the current context for OpenGL drawing
	makeCurrent();

	//Save current state, QPainter modifies MODELVIEW matrix.
	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();

	setupViewPort(width(), height());

	glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();

	drawBackgroundImage();

	//Restore state after drawing pure openGL
	glMatrixMode(GL_MODELVIEW);
	glPopMatrix();

	QPainter painter;
	painter.begin(this);
	drawPOIs(&painter);
	painter.end();

	//--- Set OpenGL drawing context to no area
	doneCurrent();

}
Esempio n. 6
0
/*!
    Returns the registered object that is under the mouse position
    specified by \a point.  This function may need to regenerate
    the contents of the pick buffer by repainting the scene
    with paintGL().

    \sa registerObject()
*/
QObject *QGLView::objectForPoint(const QPoint &point)
{
    // Check the window boundaries in case a mouse move has
    // moved the pointer outside the window.
    if (!rect().contains(point))
        return 0;

    // Do we need to refresh the pick buffer contents?
    QGLPainter painter(this);
    if (d->pickBufferForceUpdate) {
        // Initialize the painter, which will make the window context current.
        painter.setPicking(true);
        painter.clearPickObjects();

        // Create a framebuffer object as big as the window to act
        // as the pick buffer if we are single buffered.  If we are
        // double-buffered, then use the window back buffer.
        bool useBackBuffer = doubleBuffer();
        if (!useBackBuffer) {
            QSize fbosize = size();
            fbosize = QSize(powerOfTwo(fbosize.width()), powerOfTwo(fbosize.height()));
            if (!d->fbo) {
                d->fbo = new QGLFramebufferObject(fbosize, QGLFramebufferObject::CombinedDepthStencil);
            } else if (d->fbo->size() != fbosize) {
                delete d->fbo;
                d->fbo = new QGLFramebufferObject(fbosize, QGLFramebufferObject::CombinedDepthStencil);
            }
        }

        // Render the pick version of the scene into the framebuffer object.
        if (d->fbo)
            d->fbo->bind();
        painter.clear();
        painter.setEye(QGL::NoEye);
        painter.setCamera(d->camera);
        paintGL(&painter);
        painter.setPicking(false);

        // The pick buffer contents are now valid, unless we are using
        // the back buffer - we cannot rely upon it being valid next time.
        d->pickBufferForceUpdate = useBackBuffer;
        d->pickBufferMaybeInvalid = false;
    } else {
        // Bind the framebuffer object to the window's context.
        makeCurrent();
        if (d->fbo)
            d->fbo->bind();
    }

    // Pick the object under the mouse.
    int objectId = painter.pickObject(point.x(), height() - 1 - point.y());
    QObject *object = d->objects.value(objectId, 0);
    
    // Release the framebuffer object and return.
    painter.end();
    if (d->fbo)
        d->fbo->release();
    doneCurrent();
    return object;
}
Esempio n. 7
0
	Context::Context(Context *shared)
		: ContextSysBase()
	{
		assert( Context::current() == shared );

		mTarget = nullptr;
		mGLFormat = shared->mGLFormat;
		GPU::RenderTargetWin* previousSharedTarget = shared->mTarget;
		
		init();

		if ( shared->mGLFormat.versionMajor >= 3 )
		{
			initNewContext(shared->mHGLRC);
		}
		else
		{
			initOldContext();
			wglShareLists(shared->mHGLRC, mHGLRC);
		}

		shared->doneCurrent();

		makeCurrent();
		{
			GLenum wglewInitResult = wglewInit();
			GLenum glewInitResult = glewInit();
			assert(GLEW_OK == wglewInitResult && GLEW_OK == glewInitResult);
		}
		doneCurrent();

		shared->makeCurrent(previousSharedTarget);
	}
Esempio n. 8
0
	Context::~Context()
	{
		doneCurrent();
		wglDeleteContext(mHGLRC);

		delete mHiddenWindow;
	}
Esempio n. 9
0
GlxBackend::~GlxBackend()
{
    if (isFailed()) {
        m_overlayWindow->destroy();
    }
    // TODO: cleanup in error case
    // do cleanup after initBuffer()
    cleanupGL();
    doneCurrent();

    gs_tripleBufferUndetected = true;
    gs_tripleBufferNeedsDetection = false;

    if (ctx)
        glXDestroyContext(display(), ctx);

    if (glxWindow)
        glXDestroyWindow(display(), glxWindow);

    if (window)
        XDestroyWindow(display(), window);

    overlayWindow()->destroy();
    delete m_overlayWindow;
}
Esempio n. 10
0
/*!
  If this is the current context for the thread, doneCurrent is called
*/
QPlatformGLContext::~QPlatformGLContext()
{
    if (QPlatformGLContext::currentContext() == this) {
        doneCurrent();
    }

}
Esempio n. 11
0
Scene::~Scene()
{
makeCurrent();      // тут используется текущий контекст системы, т.к. QOpenGLWidget::currentContext() уже нет
delete m_triangle;
    delete spherepoints;
doneCurrent();
}
Esempio n. 12
0
    void copyFromTexture(uint32_t texture, const IntRect& sourceRect)
    {
        makeCurrent();
        int x = sourceRect.x();
        int y = sourceRect.y();
        int width = sourceRect.width();
        int height = sourceRect.height();

        glPushAttrib(GL_ALL_ATTRIB_BITS);
        GLint previousFBO;
        glGetIntegerv(GL_FRAMEBUFFER_BINDING, &previousFBO);

        GLuint originFBO;
        pGlGenFramebuffers(1, &originFBO);
        pGlBindFramebuffer(GL_READ_FRAMEBUFFER, originFBO);
        glBindTexture(GL_TEXTURE_2D, texture);
        pGlFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);

        pGlBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
        pGlBlitFramebuffer(x, y, width, height, x, y, width, height, GL_COLOR_BUFFER_BIT, GL_LINEAR);

        pGlFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
        glBindTexture(GL_TEXTURE_2D, 0);
        pGlBindFramebuffer(GL_FRAMEBUFFER, previousFBO);
        pGlDeleteFramebuffers(1, &originFBO);

        glPopAttrib();

        swapBuffers();
        doneCurrent();
    }
Esempio n. 13
0
void CompasWidget::cleanup(){
	makeCurrent();
	m_logoVbo.destroy();
	delete m_program;
	m_program = 0;
	doneCurrent();
}
Esempio n. 14
0
GLSubView::GLSubView(Session *sPtr, QWidget *parent) :
    QGLWidget(parent),
    sessionPtr(sPtr)
{
    makeCurrent();

    initializeOpenGLFunctions();

    glGenBuffers(1, &gratVBO);
    glGenBuffers(1, &gratBorderVBO);

    glBindBuffer(GL_ARRAY_BUFFER, gratVBO);
    glBufferData(GL_ARRAY_BUFFER, sizeof(linearInnerPoints),
                 linearInnerPoints, GL_DYNAMIC_DRAW);
    glBindBuffer(GL_ARRAY_BUFFER, gratBorderVBO);
    glBufferData(GL_ARRAY_BUFFER, sizeof(linearBorderPoints),
                 linearBorderPoints, GL_DYNAMIC_DRAW);

    innerGratPoints = linearInnerCount;
    borderGratPoints = linearBorderCount;

    doneCurrent();

    setAutoFillBackground(false);
}
bool QQnxGLContext::makeCurrent(QPlatformSurface *surface)
{
    qGLContextDebug() << Q_FUNC_INFO;

    Q_ASSERT(surface->surface()->surfaceType() == QSurface::OpenGLSurface);

    // Set current rendering API
    EGLBoolean eglResult = eglBindAPI(EGL_OPENGL_ES_API);
    if (eglResult != EGL_TRUE)
        qFatal("QQnxGLContext: failed to set EGL API, err=%d", eglGetError());

    QQnxEglWindow *platformWindow = dynamic_cast<QQnxEglWindow*>(surface);
    if (!platformWindow)
        return false;

    platformWindow->setPlatformOpenGLContext(this);

    if (m_currentEglSurface == EGL_NO_SURFACE || m_currentEglSurface != platformWindow->getSurface()) {
        m_currentEglSurface = platformWindow->getSurface();
        doneCurrent();
    }

    eglResult = eglMakeCurrent(ms_eglDisplay, m_currentEglSurface, m_currentEglSurface, m_eglContext);
    if (eglResult != EGL_TRUE) {
        checkEGLError("eglMakeCurrent");
        qWarning("QQNX: failed to set current EGL context, err=%d", eglGetError());
        return false;
    }
    return (eglResult == EGL_TRUE);
}
Esempio n. 16
0
void
AGLViewer::getCurrentViewImageBuffer(size_t &aWidth, size_t &aHeight, boost::shared_array< uint8 > &aBuffer )
{
	makeCurrent();
	soglu::getImageBufferFromTexture(aWidth, aHeight, aBuffer, mFrameBufferObject.GetColorBuffer());	
	doneCurrent();
}
Esempio n. 17
0
void ImageViewerPanel::updateTexture()
{
	makeCurrent();
	if (textures != nullptr)
	{
		switch (texType)
		{
		case DISPLAY_TYPE::BEAUTY:
			glTextureStorage2D(tex, 1, GL_RGBA32F, imgsize[0], imgsize[1]);
			glTextureSubImage2D(tex, 0, 0, 0, imgsize[0], imgsize[1], GL_RGBA, GL_FLOAT, textures);
			break;
		case DISPLAY_TYPE::P:
		case DISPLAY_TYPE::N:
		case DISPLAY_TYPE::DPDU:
		case DISPLAY_TYPE::DPDV:
			glTextureStorage2D(tex, 1, GL_RGB32F, imgsize[0], imgsize[1]);
			glTextureSubImage2D(tex, 0, 0, 0, imgsize[0], imgsize[1], GL_RGB, GL_FLOAT, textures);
			break;
		default:
			break;
		}
		
	}
	else
	{
		glTextureStorage2D(tex, 1, GL_RGBA32F, 0, 0);
		glTextureSubImage2D(tex, 0, 0, 0, 0, 0, GL_RGBA, GL_FLOAT, 0);
	}
	doneCurrent();
}
Esempio n. 18
0
RendererWidget::RendererWidget(QWidget *parent) : QGLWidget(parent)

{
    setMinimumSize(100,100);
    setAutoBufferSwap(false);
    doneCurrent();
}
Esempio n. 19
0
void QGLContext::reset()
{
    Q_D(QGLContext);
    if (!d->valid)
        return;
    d->cleanup();

    d->crWin = false;
    d->sharing = false;
    d->valid = false;
    d->transpColor = QColor();
    d->initDone = false;
    QGLContextGroup::removeShare(this);
    if (d->guiGlContext) {
        if (QOpenGLContext::currentContext() == d->guiGlContext)
            doneCurrent();
        if (d->ownContext) {
            if (d->guiGlContext->thread() == QThread::currentThread())
                delete d->guiGlContext;
            else
                d->guiGlContext->deleteLater();
        } else
            d->guiGlContext->setQGLContextHandle(0,0);
        d->guiGlContext = 0;
    }
    d->ownContext = false;
}
Esempio n. 20
0
MythRenderOpenGL2::~MythRenderOpenGL2()
{
    if (!isValid())
        return;
    makeCurrent();
    DeleteOpenGLResources();
    doneCurrent();
}
Esempio n. 21
0
void StreamViewer::bindStreamData(const unsigned char* data) {
	makeCurrent();
	glBindTexture(GL_TEXTURE_2D, textureId);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width(), height(),
                 0, GL_BGRA, GL_UNSIGNED_BYTE, (GLvoid*) data);
	update();
	doneCurrent();
}
Visualizer::~Visualizer()
{
    arrayBuf.destroy();
       indexBuf.destroy();
       makeCurrent();
          delete texture;
          doneCurrent();
}
Esempio n. 23
0
void view::cleanup()
{
    makeCurrent();
    m_logoVbo.destroy();
    //delete m_program;
    m_program = 0;
    doneCurrent();
}
Esempio n. 24
0
CGLWidget::~CGLWidget()
{
    makeCurrent();
    m_vbo.destroy();
    delete m_program;
    m_program = 0;
    doneCurrent();
}
Esempio n. 25
0
// Destroy an EGL surface object.  If it was current on this context
// then call doneCurrent() for it first.
void QEglContext::destroySurface(EGLSurface surface)
{
    if (surface != EGL_NO_SURFACE) {
        if (surface == currentSurface)
            doneCurrent();
        eglDestroySurface(display(), surface);
    }
}
Esempio n. 26
0
void GLWidget::cleanup()
{
	makeCurrent();
	delete ssao;
	delete phong;
	delete toon;
	doneCurrent();
}
Esempio n. 27
0
MainWidget::~MainWidget()
{
    // Make sure the context is current when deleting the texture
    // and the buffers.
    makeCurrent();
    delete geometries;
    doneCurrent();
}
Esempio n. 28
0
//MouseEvent
void GLPanel::mouseMoveEvent(QMouseEvent *evento)
{
    this->x = evento->x();
    this->y = evento->y();
    makeCurrent();
    doneCurrent();
    emit MousePos();
}
Esempio n. 29
0
GLWidget::~GLWidget()
{
    makeCurrent();
    vbo.destroy();
    for (int i = 0; i < 6; ++i)
        delete textures[i];
    delete program;
    doneCurrent();
}
Esempio n. 30
0
AGLViewer::~AGLViewer()
{
	makeCurrent();
	mFrameBufferObject.Finalize();
	mPickManager.finalize();
	doneCurrent();

	deselect();
}