Пример #1
0
void Subtitle::checkCapability()
{
    if (priv->last_can_render == canRender())
        return;
    priv->last_can_render = canRender();
    emit canRenderChanged();
}
Пример #2
0
void CascadedShadowPass::finalize() {
	if(canRender()) {
		
		Cvar_SetVarValue(&gfx_sky, 1);
		Cvar_SetVarValue(&gfx_GLSLQuality, saveGLSLQuality);
		Cvar_SetVarValue(&gfx_grass, saveGrass);
		Cvar_SetVarValue(&gfx_clouds, saveClouds);
		
		//GL_CullFace(GL_BACK);
		
		GL_Enable(GL_POLYGON_SMOOTH);
		glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);
		glShadeModel(GL_SMOOTH);
		Cvar_SetVarValue(&terrain_layer2, layer2_enabled);
		Cvar_SetVarValue(&terrain_layer3, layer3_enabled);

		//glScreen->makeTarget();
	}
	
	Pass::finalize();
	
#ifdef DEBUG
	GLSL_catchLastError("CascadedShadowPass::finalize(): ");
#endif
}
Пример #3
0
void ShadowPass::finalize() {
	if(canRender()) {
		
		Cvar_SetVarValue(&gfx_sky, 1);
		Cvar_SetVarValue(&gfx_GLSLQuality, saveGLSLQuality);
		Cvar_SetVarValue(&gfx_grass, saveGrass);
		
		//GL_CullFace(GL_BACK);
		
		GL_Enable(GL_POLYGON_SMOOTH);
		if(!gfx_shadowDebug.integer)
			glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);
		glShadeModel(GL_SMOOTH);
		Cvar_SetVarValue(&terrain_layer2, layer2_enabled);
		Cvar_SetVarValue(&terrain_layer3, layer3_enabled);
	}

	GLSL_catchLastError("ShadowPass::finalize(): ");
	
	//GL_BuildShadowTextureMatrix(viewer);
	
	//GL_PopCamera();
	
	Pass::finalize();
}
Пример #4
0
void MarkdownPlugin::onViewNoteLoaded(INoteView* view, const WIZDOCUMENTDATA& doc, bool bOk)
{
    if (!bOk)
        return;

    if (canRender(view, doc))
        render(view->noteFrame());
}
Пример #5
0
//--------------------------------------------------------------------------------------------------
///  
//--------------------------------------------------------------------------------------------------
void caf::Viewer::paintEvent(QPaintEvent* event)
{
    makeCurrent();

    cvf::ref<cvf::OpenGLContext> myOglContext = cvfOpenGLContext();
    CVF_CHECK_OGL(myOglContext.p());
    CVF_ASSERT(myOglContext->isContextValid());

    QPainter painter(this);

    if (m_renderingSequence.isNull() || !canRender())
    {
        QColor bgClr(128, 128, 128);
        painter.fillRect(rect(), bgClr);
        return;
    }

#if QT_VERSION >= 0x040600
    // Qt 4.6
    painter.beginNativePainting();
#endif

    if (isShadersSupported())
    {
        cvfqt::OpenGLContext::saveOpenGLState(myOglContext.p());
    }

    optimizeClippingPlanes();

    // Do normal drawing
    m_renderingSequence->render(myOglContext.p());
    CVF_CHECK_OGL(cvfOpenGLContext());

    if (isShadersSupported())
    {
        cvfqt::OpenGLContext::restoreOpenGLState(myOglContext.p());
    }

#if QT_VERSION >= 0x040600
    // Qt 4.6
    painter.endNativePainting();
#endif

    // Call virtual method to allow subclasses to paint on the OpenGlCanvas
    this->paintOverlayItems(&painter); 

    if (m_showPerfInfoHud && isShadersSupported())
    {
        cvfqt::PerformanceInfoHud hud;
        hud.addStrings(m_renderingSequence->performanceInfo());
        hud.addStrings(*m_mainCamera);
        hud.addString(QString("PaintCount: %1").arg(m_paintCounter++));
        hud.draw(&painter, width(), height());
    }
}
Пример #6
0
void CascadedShadowPass::setup(GLRenderer *r) {
	
	if(gfx_shadowDebug.integer)
		target = glScreen;
	else
		target = shadowTarget;

	Pass::setup(r);
	
	if(!gfx_postProcessing.integer)
		target->makeTarget();
	
	saveGLSLQuality = gfx_GLSLQuality.integer;
	saveGrass = gfx_grass.integer;
	saveClouds = gfx_clouds.integer;
	
	if(!canRender()) {
		
		glScreen->makeTarget();
		return;
	}
	
	Cvar_SetVarValue(&gfx_sky, 0);
	Cvar_SetVarValue(&gfx_GLSLQuality, 1);
	Cvar_SetVarValue(&gfx_grass, 0);
	Cvar_SetVarValue(&gfx_clouds, 0);
	
	if(shadowSplit==0)
		updateSplitDist(shadowFrusta, scene_cam->nearclip, scene_cam->farclip);
	
	if(gfx_shadowQuality.integer >= 2) {
		GL_PopCamera();
		GL_PushCSMCamera(viewer, scene_cam, shadowSplit);   //CSM or UniformSM
	}

	if(!gfx_shadowDebug.integer)
		((GLDepthRenderTarget*)target)->makeTargetLayer(shadowSplit);
	
	shadowSplit++;
	
	glClear(GL_DEPTH_BUFFER_BIT);
	
	GL_Disable(GL_LIGHTING);
	GL_Disable(GL_POLYGON_SMOOTH);
	if(!gfx_shadowDebug.integer)
		glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE);
	glShadeModel(GL_FLAT);
	//GL_CullFace(GL_FRONT);
	
	layer2_enabled = terrain_layer2.integer;
	layer3_enabled = terrain_layer3.integer;
	Cvar_SetVarValue(&terrain_layer2, 0);
	Cvar_SetVarValue(&terrain_layer3, 0);
}
Пример #7
0
qreal ScFace::charWidth(QChar ch, qreal size, QChar ch2) const
{
	if (!canRender(ch)) // calls loadGlyph()
		return size;
	else if (ch.unicode() == 28 || ch.unicode() == 13 || ch.unicode() == 9)
		return ch.unicode() == 9 ? 1.0 : 0.0;
	else {
		gid_type gl1 = char2CMap(ch);
		gid_type gl2 = char2CMap(ch2);
		qreal width = glyphWidth(gl1, size);
		if (gl2 != 0)
			width += glyphKerning(gl1, gl2, size);
//		qDebug() << QString("scface::glyphkerning: %1_%2 = %3 (%4, %5)").arg(ch).arg(ch2).arg(glyphKerning(gl1, gl2,size)).arg(gl1).arg(gl2);
		return width;
	}
}
Пример #8
0
void ShadowPass::setup(GLRenderer *r) {
	if(!gfx_shadowDebug.integer)
		target = shadowTarget;
	else target = glScreen;
	
	Pass::setup(r);
	
	saveGLSLQuality = gfx_GLSLQuality.integer;
	saveGrass = gfx_grass.integer;
	
	if(!canRender())
		return;
	
	Cvar_SetVarValue(&gfx_sky, 0);
	Cvar_SetVarValue(&gfx_GLSLQuality, 1);
	Cvar_SetVarValue(&gfx_grass, 0);
	
	/*updateSplitDist(shadowFrusta, scene_cam->nearclip, scene_cam->farclip);
	shadowSplit = 0;
	
	if(gfx_shadowQuality.integer != 3) {
		GL_PopCamera();
		GL_PushCSMCamera(viewer, scene_cam, shadowSplit);   //CSM or UniformSM
	}*/
	
	GL_Disable(GL_LIGHTING);
	GL_Disable(GL_POLYGON_SMOOTH);
	if(!gfx_shadowDebug.integer)
		glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE);
	glShadeModel(GL_FLAT);
	//GL_CullFace(GL_FRONT);
	
	layer2_enabled = terrain_layer2.integer;
	layer3_enabled = terrain_layer3.integer;
	Cvar_SetVarValue(&terrain_layer2, 0);
	Cvar_SetVarValue(&terrain_layer3, 0);
}
Пример #9
0
QImage Subtitle::getImage(int width, int height, QRect* boundingRect)
{
    QMutexLocker lock(&priv->mutex);
    Q_UNUSED(lock);
    if (!isLoaded())
        return QImage();
    if (width == 0 || height == 0)
        return QImage();
#if 0
    if (!priv->current_count) //seems ok to use this code
        return QImage();
    // always render the image to support animations
    if (!priv->update_image
            && width == priv->current_image.width() && height == priv->current_image.height())
        return priv->current_image;
#endif
    priv->update_image = false;
    if (!canRender())
        return QImage();
    priv->processor->setFrameSize(width, height);
    // TODO: store bounding rect here and not in processor
    priv->current_image = priv->processor->getImage(priv->t - priv->delay, boundingRect);
    return priv->current_image;
}
Пример #10
0
Common::Error ZVision::run() {
	initialize();

	// Check if a saved game is to be loaded from the launcher
	if (ConfMan.hasKey("save_slot"))
		_saveManager->loadGame(ConfMan.getInt("save_slot"));

	bool foundAllFonts = true;

	// Before starting, make absolutely sure that the user has copied the needed fonts
	for (int i = 0; i < FONT_COUNT; i++) {
		FontStyle curFont = getSystemFont(i);
		Common::String freeFontBoldItalic = Common::String("Bold") + curFont.freeFontItalicName;

		const char *fontSuffixes[4] = { "", "bd", "i", "bi" };
		const char *freeFontSuffixes[4] = { "", "Bold", curFont.freeFontItalicName, freeFontBoldItalic.c_str() };
		const char *liberationFontSuffixes[4] = { "-Regular", "-Bold", "-Italic", "-BoldItalic" };

		for (int j = 0; j < 4; j++) {
			Common::String fontName = curFont.fontBase;
			if (fontName == "censcbk" && j > 0)
				fontName = "schlbk";
			fontName += fontSuffixes[j];
			fontName += ".ttf";

			if (fontName == "schlbkbd.ttf")
				fontName = "schlbkb.ttf";
			if (fontName == "garabi.ttf")
				continue;
			if (fontName == "garai.ttf")
				fontName = "garait.ttf";

			Common::String freeFontName = curFont.freeFontBase;
			freeFontName += freeFontSuffixes[j];
			freeFontName += ".ttf";

			Common::String liberationFontName = curFont.liberationFontBase;
			liberationFontName += liberationFontSuffixes[j];
			liberationFontName += ".ttf";

			if (!Common::File::exists(fontName) && !_searchManager->hasFile(fontName) &&
				!Common::File::exists(liberationFontName) && !_searchManager->hasFile(liberationFontName) &&
				!Common::File::exists(freeFontName) && !_searchManager->hasFile(freeFontName)) {
				foundAllFonts = false;
				break;
			}
		}

		if (!foundAllFonts)
			break;
	}

	if (!foundAllFonts) {
		GUI::MessageDialog dialog(
				"Before playing this game, you'll need to copy the required "
				"fonts into ScummVM's extras directory, or into the game directory. "
				"On Windows, you'll need the following font files from the Windows "
				"font directory: Times New Roman, Century Schoolbook, Garamond, "
				"Courier New and Arial. Alternatively, you can download the "
				"Liberation Fonts or the GNU FreeFont package. You'll need all the "
				"fonts from the font package you choose, i.e., LiberationMono, "
				"LiberationSans and LiberationSerif, or FreeMono, FreeSans and "
				"FreeSerif respectively."
		);
		dialog.runModal();
		quitGame();
		return Common::kUnknownError;
	}

	// Main loop
	while (!shouldQuit()) {
		_clock.update();
		uint32 currentTime = _clock.getLastMeasuredTime();
		uint32 deltaTime = _clock.getDeltaTime();

		_cursorManager->setItemID(_scriptManager->getStateValue(StateKey_InventoryItem));

		processEvents();
		_renderManager->updateRotation();

		_scriptManager->update(deltaTime);
		_menu->process(deltaTime);

		// Render the backBuffer to the screen
		_renderManager->prepareBackground();
		_renderManager->renderMenuToScreen();
		_renderManager->processSubs(deltaTime);
		_renderManager->renderSceneToScreen();

		// Update the screen
		if (canRender()) {
			_system->updateScreen();
			_renderedFrameCount++;
		} else {
			_frameRenderDelay--;
		}

		// Calculate the frame delay based off a desired frame time
		int delay = _desiredFrameTime - int32(_system->getMillis() - currentTime);
		// Ensure non-negative
		delay = delay < 0 ? 0 : delay;

		if (_doubleFPS) {
			delay >>= 1;
		}

		if (canSaveGameStateCurrently() && shouldPerformAutoSave(_saveManager->getLastSaveTime())) {
			_saveManager->autoSave();
		}

		_system->delayMillis(delay);
	}

	return Common::kNoError;
}