Пример #1
0
void DrawingBuffer::reset(const IntSize& newSize)
{
    if (!m_context)
        return;

    IntSize adjustedSize;
    bool evictContext = false;
    bool isNewContext = m_size.isEmpty();
    if (s_allowContextEvictionOnCreate && isNewContext)
        adjustedSize = adjustSizeWithContextEviction(newSize, evictContext);
    else
        adjustedSize = adjustSize(newSize);

    if (adjustedSize.isEmpty())
        return;

    if (evictContext)
        m_contextEvictionManager->forciblyLoseOldestContext("WARNING: WebGL contexts have exceeded the maximum allowed backbuffer area. Oldest context will be lost.");

    if (adjustedSize != m_size) {
        do {
            // resize multisample FBO
            if (!resizeMultisampleFramebuffer(adjustedSize) || !resizeFramebuffer(adjustedSize)) {
                adjustedSize.scale(s_resourceAdjustedRatio);
                continue;
            }
            break;
        } while (!adjustedSize.isEmpty());

        setSize(adjustedSize);

        if (adjustedSize.isEmpty())
            return;
    }

    m_context->disable(GL_SCISSOR_TEST);
    m_context->clearColor(0, 0, 0, 0);
    m_context->colorMask(true, true, true, true);

    GLbitfield clearMask = GL_COLOR_BUFFER_BIT;
    if (m_attributes.depth) {
        m_context->clearDepth(1.0f);
        clearMask |= GL_DEPTH_BUFFER_BIT;
        m_context->depthMask(true);
    }
    if (m_attributes.stencil) {
        m_context->clearStencil(0);
        clearMask |= GL_STENCIL_BUFFER_BIT;
        m_context->stencilMaskSeparate(GL_FRONT, 0xFFFFFFFF);
    }

    clearFramebuffers(clearMask);
}
Пример #2
0
void GL3LightingManager::beginLightPass() {
    auto currentRenderTarget = _renderer->getGLRenderTargetManager()->getCurrentRenderTarget();
    auto width = currentRenderTarget->getWidth();
    auto height = currentRenderTarget->getHeight();

    // Make sure our framebuffer is big enough for the current render target
    resizeFramebuffer((uint32_t) width, (uint32_t) height);

    GLState->Framebuffer.pushBinding();
    GLState->Framebuffer.bind(_renderFrameBuffer);

    glClearColor(0.f, 0.f, 0.f, 1.f);
    GLState->setDepthMask(true);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
void HeadlessView::activate() {
    active = true;

    if (!glContext) {
        if (!display) {
            throw std::runtime_error("Display is not set");
        }
        createContext();
    }

    activateContext();

    if (!extensionsLoaded) {
        gl::InitializeExtensions(initializeExtension);
        extensionsLoaded = true;
    }

    if (needsResize) {
        clearBuffers();
        resizeFramebuffer();
        needsResize = false;
    }
}
Пример #4
0
void DrawingBuffer::reset(const IntSize& newSize)
{
    if (!m_context)
        return;

    IntSize adjustedSize;
    bool evictContext = false;
    bool isNewContext = m_size.isEmpty();
    if (s_allowContextEvictionOnCreate && isNewContext)
        adjustedSize = adjustSizeWithContextEviction(newSize, evictContext);
    else
        adjustedSize = adjustSize(newSize);

    if (adjustedSize.isEmpty())
        return;

    if (evictContext)
        m_contextEvictionManager->forciblyLoseOldestContext("WARNING: WebGL contexts have exceeded the maximum allowed backbuffer area. Oldest context will be lost.");

    if (adjustedSize != m_size) {
        do {
            // resize multisample FBO
            if (!resizeMultisampleFramebuffer(adjustedSize) || !resizeFramebuffer(adjustedSize)) {
                adjustedSize.scale(s_resourceAdjustedRatio);
                continue;
            }

#if OS(DARWIN)
            // FIXME: This can be removed once renderbufferStorageMultisample starts reporting GL_OUT_OF_MEMORY properly on OSX.
            if (!checkBufferIntegrity()) {
                adjustedSize.scale(s_resourceAdjustedRatio);
                continue;
            }
#endif
            break;
        } while (!adjustedSize.isEmpty());

        setSize(adjustedSize);

        if (adjustedSize.isEmpty())
            return;
    }

    m_context->disable(GraphicsContext3D::SCISSOR_TEST);
    m_context->clearColor(0, 0, 0, 0);
    m_context->colorMask(true, true, true, true);

    GC3Dbitfield clearMask = GraphicsContext3D::COLOR_BUFFER_BIT;
    if (m_attributes.depth) {
        m_context->clearDepth(1.0f);
        clearMask |= GraphicsContext3D::DEPTH_BUFFER_BIT;
        m_context->depthMask(true);
    }
    if (m_attributes.stencil) {
        m_context->clearStencil(0);
        clearMask |= GraphicsContext3D::STENCIL_BUFFER_BIT;
        m_context->stencilMaskSeparate(GraphicsContext3D::FRONT, 0xFFFFFFFF);
    }

    clearFramebuffers(clearMask);
}
Пример #5
0
void menu( int value )
{
	int newSize;

	switch (value) 
	{
		default:
			break;
		case 100:
			keys( 'h', 0, 0 );
			break;
		case 300:
			keys( '2', 0, 0 );
			break;
		case 301:
			keys( '1', 0, 0 );
			break;
		case 302:
			keys( '3', 0, 0 );
			break;
		case 500:
		case 501:
		case 502:
		case 503:
		case 504:
		case 505:
		case 506:
			newSize = 64*pow(2.0,value-500);
			numberOfPhotons = newSize;
			resizeFramebuffer( causticFB, numberOfPhotons );
			glBindBuffer( GL_PIXEL_PACK_BUFFER_EXT, causticLocationBuffer );
			glBufferData( GL_PIXEL_PACK_BUFFER_EXT, numberOfPhotons*numberOfPhotons*4*sizeof(float), NULL, GL_DYNAMIC_DRAW );
			glBindBuffer( GL_PIXEL_PACK_BUFFER_EXT, causticColorBuffer );
			glBufferData( GL_PIXEL_PACK_BUFFER_EXT, numberOfPhotons*numberOfPhotons*4*sizeof(float), NULL, GL_DYNAMIC_DRAW );
			needToRerenderCaustics = 1;
			glutPostRedisplay();
			break;
		case 520:
		case 521:
		case 522:
		case 523:
		case 524:
		case 525:
		case 526:
			newSize = 64*pow(2.0,value-520);
			causticMapSize = newSize;
			resizeFramebuffer( pseudoPhotonMapFB, causticMapSize );
			resizeFramebuffer( tempFB, causticMapSize );
			needToRerenderCaustics = 1;
			glutPostRedisplay();
			break;
		case 540:
		case 541:
		case 542:
			newSize = 256*pow(2.0,value-540);
			screenSize = newSize;
			backgroundBufSize = newSize;
			resizeFramebuffer( backgroundGeomFB, backgroundBufSize );
			screen_width = newSize;
			screen_height = newSize;
			glutReshapeWindow( screen_width, screen_height );
			if (screenCapture)
				free( screenCapture );
			screenCapture = (unsigned char *) malloc( sizeof(unsigned char) * screenSize * screenSize * 3 );
			ResizeTrackballWindow( screenSize, screenSize );
			needToRerenderCaustics = 1;
			glutPostRedisplay();
			break;
		case 560:
		case 561:
		case 562:
		case 563:
		case 564:
		case 565:
		case 566:
			newSize = 64*pow(2.0,value-560);
			mainbufferSize = newSize;
			resizeFramebuffer( fb, mainbufferSize );
			needToRerenderCaustics = 1;
			glutPostRedisplay();
			break;
		case 600: // original caustics mapping approach
			usingAdaptiveMultresolutionSplats = 0;
			useExperimentalApproach = 0;
			needToRerenderCaustics = 1;
			printf("    (-) Using original I3D 2006 work of Wyman and Davis...\n" );
			glutPostRedisplay();
			break;
		case 601: // multi-res approach
			useExperimentalApproach = 0;
			usingAdaptiveMultresolutionSplats = 1;
			needToRerenderCaustics = 1;
			printf("    (-) Using adaptive multiresolution splats (4 fixed radii splats)...\n" );
			glutPostRedisplay();
			break;
		case 602: // continuously varying splats
			useExperimentalApproach = 1;
			usingAdaptiveMultresolutionSplats = 0;
			needToRerenderCaustics = 1;
			printf("    (-) Using dynamically varying splat sizes...\n" );
			glutPostRedisplay();
			break;
		case 27: /* quit */
			exit(0);
			break;
	}
	if ( value >= 200 && value < 300 )
	{
		GLuint tmp1, tmp2;
		int loaded;

		displayLoadingMessage( GetModelIdentifier( value-200 ) );

		loaded = LoadRefractingModel( value-200, &tmp1, &tmp2 );
		if (!loaded)
		{
			printf("*** Error loading model: %s\n", GetModelIdentifier( value-200 ) );
			return;
		}

		glDeleteLists( currentObjectList, 1 );
		glDeleteLists( currentObjectNormalList, 1 );

		currentObjectList = tmp1;
		currentObjectNormalList = tmp2;

		printf("(+) Loaded model: %s\n", GetModelIdentifier( value-200 ) );
		needToRerenderCaustics = 1;
		currentModelNum = value-200;
		glutPostRedisplay();
	}
}