Exemplo n.º 1
0
void Render::settingsLoop(int musVol, int effVol, string col1, string col2, string grav) {
	render();
	startRendering();

	//colorShading();

	glEnable(GL_TEXTURE_2D);
	glEnable(GL_BLEND);

	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	//Update volume button
	settingsButtons->at(0).tekst = "Music volume: " + to_string(musVol) + "%";
	settingsButtons->at(1).tekst = "Effects volume: " + to_string(effVol) + "%";

	settingsButtons->at(3).tekst = "Orb Color: " + col1;
	settingsButtons->at(4).tekst = "Orb Light Color: " + col2;

	settingsButtons->at(6).tekst = "Gravity: " + grav;

	for (int i = 0; i < settingsButtons->size(); i++) {
		//Render text
		renderText(menuFont, settingsButtons->at(i).color, settingsButtons->at(i).posX, settingsButtons->at(i).posY, 0, settingsButtons->at(i).tekst);
	}

	endRendering();
	SDL_GL_SwapWindow(init->window);
}
Exemplo n.º 2
0
void Render::scoreLoop(vector <int> scores, int scoreFinal, int scorePos, bool inGame) {
	render();
	startRendering();

	//colorShading();

	glEnable(GL_TEXTURE_2D);
	glEnable(GL_BLEND);

	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	//Only render if opened after a ended game
	scoreButtons->at(0).disabled = true;
	scoreButtons->at(1).tekst = "Back";
	scoreTexts->at(0).color = HIGHSCORE_COLOR_NEW;

	if (inGame) {
		//Render text
		scoreTexts->at(0).tekst = "Score: " + to_string(scoreFinal);
		renderText(menuFont, scoreTexts->at(0).color, scoreTexts->at(0).posX, scoreTexts->at(0).posY, 0, scoreTexts->at(0).tekst);

		//Set appropriate name for menu button
		scoreButtons->at(1).tekst = "Main Menu";

		//Render "retry" button
		scoreButtons->at(0).disabled = false;
		renderText(menuFont, scoreButtons->at(0).color, scoreButtons->at(0).posX, scoreButtons->at(0).posY, 0, scoreButtons->at(0).tekst);
	}

	for (int i = 1; i < scoreTexts->size(); i++) {
		//If highscore list element
		if (i >= 2 && i < 2 + HIGHSCORES) {
			//Update scoretext
			if (scores[i - 2] >= 0) {
				scoreTexts->at(i).tekst = to_string(i - 1) + ": " + to_string(scores[i - 2]);
			}
			else {
				scoreTexts->at(i).tekst = to_string(i - 1) + ": ---";
			}

			if ((i - 2) == scorePos) {
				//Highlight new highscore
				scoreTexts->at(i).color = HIGHSCORE_COLOR_NEW;
			}
			else {
				//Set normal color to others
				scoreTexts->at(i).color = HIGHSCORE_COLOR_NORMAL;
			}
		}

		//Render text
		renderText(menuFont, scoreTexts->at(i).color, scoreTexts->at(i).posX, scoreTexts->at(i).posY, 0, scoreTexts->at(i).tekst);
	}

	//Render "goto main menu" button
	renderText(menuFont, scoreButtons->at(1).color, scoreButtons->at(1).posX, scoreButtons->at(1).posY, 0, scoreButtons->at(1).tekst);

	endRendering();
	SDL_GL_SwapWindow(init->window);
}
Exemplo n.º 3
0
void Render::mainLoop(string fps, string puz, string par, string sco, string tim, string csp){

	
	gameLoopShading();
	//mainLoopShading(colorShader, 1);
	particleVBO->draw();
	mainCharParticleVBO->draw();
	//mainCharParticleVBO->draw();

		glEnable(GL_TEXTURE_2D);
		glEnable(GL_BLEND);

		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

		int textX = 20;
		int textY = 20;

		if (fps != "") {
			renderText(font, MENU_COLOR_NORMAL, 20, screenHeight - 50, 0, fps);
		}
		if (puz != "") {
			renderText(font, MENU_COLOR_NORMAL, textX, textY, 0, puz);
			textY += 50;
		}
		if (par != "") {
			renderText(font, MENU_COLOR_NORMAL, textX, textY, 0, par);
			textY += 50;
		}
		if (sco != "") {
			renderText(font, MENU_COLOR_NORMAL, textX, textY, 0, sco);
			textY += 50;
		}
		if (csp != "") {
			renderText(font, MENU_COLOR_NORMAL, textX, textY, 0, csp);
			textY += 50;
		}
		if (tim != "") {
			int timeX = (screenWidth / 2) - ((tim.size() / 2) * 20);
			int timeY = 40;
			renderText(font, MENU_COLOR_NORMAL, timeX, timeY, 0, tim);
		}

		glDisable(GL_TEXTURE_2D);
		glDisable(GL_BLEND);
		
		endRendering();
		SDL_GL_SwapWindow(init->window);
		
}
Exemplo n.º 4
0
void AnimationExportWidget::startRendering() {
    // gather some useful params
    fps_ = spinRecordingFPS_->value();
    startframe_= fps_ * (spinStartTime_->time().hour() * 3600 + spinStartTime_->time().minute()*60+ spinStartTime_->time().second());
    endframe_ = fps_ * (spinEndTime_->time().hour() * 3600 + spinEndTime_->time().minute()*60+ spinEndTime_->time().second());
    currentFrame_ = startframe_;
    duration_= endframe_;

    // set accurate recording dimension
    canvasSize_ = canvas_->getSize();
    canvas_->resize(spinWidth_->value(), spinHeight_->value());
    qApp->processEvents();

#ifdef VRN_WITH_FFMPEG
    if (renderState_== Recording) {
        tgt::Texture* texture_ = painter_->getCanvasRenderer()->getImageColorTexture();
        try {
            ffmpegEncoder_.startVideoEncoding(recordPathName_.c_str(), fps_, spinWidth_->value(), spinHeight_->value(),
                                              texture_->getFormat(), texture_->getDataType());
        }
        catch (tgt::Exception& e) {
            QMessageBox::critical(this, tr("Video Export Failed"),
                                  tr("Failed to initialize video export:\n%1").arg(e.what()));
            return;
        }
    }
#endif // VRN_WITH_FFMPEG

    setWidgetState();
    canvas_->resize(spinWidth_->value(), spinHeight_->value());
    QProgressDialog progress(tr("Exporting Animation..."), tr("Abort"), 0, (int)(duration_ /fpsFactor_), this);
    progress.setWindowTitle(tr("Exporting"));
    if (fps_ > 0) {
        for(int i = 0; i < duration_ /fpsFactor_; ++i) {
            renderingStep();
            progress.setValue(i);
            qApp->processEvents();

            if (currentFrame_ > duration_ / fpsFactor_ || progress.wasCanceled()){
                break;
            }
        }
        endRendering();
    }
}
Exemplo n.º 5
0
void Render::pauseLoop(){
	render();
	startRendering();

	//colorShading();

	glEnable(GL_TEXTURE_2D);
	glEnable(GL_BLEND);

	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	for (int i = 0; i < pauseObjects->size(); i++){
		renderText(menuFont, pauseObjects->at(i).color, pauseObjects->at(i).posX, pauseObjects->at(i).posY, 0, pauseObjects->at(i).tekst);
	}

	endRendering();
	SDL_GL_SwapWindow(init->window);
}
Exemplo n.º 6
0
void AnimationExportWidget::renderingStep(){
    if (animation_ == 0)
        return;
    tgtAssert(canvas_, "No canvas");

    if (currentFrame_ > duration_ / fpsFactor_){
        endRendering();
    }
    else {
        animation_->renderAt((float)currentFrame_*fpsFactor_/ fps_);
        #ifdef VRN_WITH_FFMPEG
        if ((renderState_== Recording) &&(painter_->getCanvasRenderer())) {
            if (canvas_->getSize() != tgt::ivec2(spinWidth_->value(), spinHeight_->value())) {
                canvas_->resize(spinWidth_->value(), spinHeight_->value());
                canvas_->repaint();
            }

            tgt::Texture* texture = painter_->getCanvasRenderer()->getImageColorTexture();
            if (texture && texture->getDimensions().xy() == tgt::ivec2(spinWidth_->value(), spinHeight_->value())) {
                texture->downloadTexture();
                ffmpegEncoder_.nextFrame(texture->getPixelData());
            }
            else {
                LERRORC("voreenqt.AnimationExportWidget",
                        "Frame texture could not be downloaded or dimensions do not match");
            }
        } else {
        #endif
            // render frame to file
            char fn[1024];
            sprintf(fn, "%s%05d%s", std::string(recordPathName_ + "/frame").c_str(), currentFrame_, ".png");
            try {
                painter_->renderToSnapshot(fn, tgt::ivec2(spinWidth_->value(), spinHeight_->value()));
            } catch (...) {}
        #ifdef VRN_WITH_FFMPEG
        }
        #endif
        ++currentFrame_;
    }
}
Exemplo n.º 7
0
//----------------------------------------------------------------------------//
void CEGuiBaseApplication::renderSingleFrame(const float elapsed)
{
    CEGUI::System& gui_system(CEGUI::System::getSingleton());

    gui_system.injectTimePulse(elapsed);
    d_sampleApp->update(static_cast<float>(elapsed));

    updateFPS(elapsed);
    updateLogo(elapsed);

    beginRendering(elapsed);

    CEGUI::Renderer* gui_renderer(gui_system.getRenderer());
    gui_renderer->beginRendering();

    d_sampleApp->renderGUIContexts();

    gui_renderer->endRendering();
    CEGUI::WindowManager::getSingleton().cleanDeadPool();

    endRendering();
}
Exemplo n.º 8
0
void Render::mainMenu(string fps){

	render();
	startRendering();	

	//colorShading();

	glEnable(GL_TEXTURE_2D);
	glEnable(GL_BLEND);

	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);


	renderText(font, MENU_COLOR_NORMAL, 20, screenHeight - 50, 0, fps);
	for (int i = 0; i < menuObjects->size(); i++){
		TTF_Font *useFont = menuFont;
		SDL_Color useColor = menuObjects->at(i).color;
		if (i == 4) {
			useFont = titleFont;
			useColor = TITLE_COLOR;
		}
		renderText(useFont, useColor, menuObjects->at(i).posX, menuObjects->at(i).posY, 0, menuObjects->at(i).tekst);
	}

	endRendering();
	glDisable(GL_TEXTURE_2D);
	glDisable(GL_BLEND);
	SDL_GL_SwapWindow(init->window);
	/*
	GLfloat lightpos[] = { 0.5, 1.0, 1., 0.0 };
	glUseProgram(*shader->GetShaderProgram());
	GLint LightPos = glGetUniformLocation(*shader->GetShaderProgram(), "LightPos");
	glProgramUniform3f(*shader->GetShaderProgram(), LightPos, lightpos[0], lightpos[1], lightpos[2]);
	if (mUniformTexture != -1) {
		glUniform1i(mUniformTexture, 0);
	}
	glUseProgram(0);*/
}
Exemplo n.º 9
0
void AnimationExportWidget::closeEvent(QCloseEvent* e) {
    currentFrame_ = static_cast<int>(duration_ / fpsFactor_ + 1);
    endRendering();
    QDialog::closeEvent(e);
}