/** * Initialize drawable for row-interleaved stereo. */ void vrInitRowInterleaved() { if (rowInterDrawable.isReady()) { return; } typedef GLBufferT<Vertex2Tex> VBuf; VBuf *buf = new VBuf; rowInterDrawable.addBuffer(buf); rowInterDrawable.program().build( // Vertex shader: Block("in highp vec4 aVertex; " "in highp vec2 aUV; " "out highp vec2 vUV; " "void main(void) {" "gl_Position = aVertex; " "vUV = aUV; }"), // Fragment shader: Block("uniform sampler2D uTex; " "uniform sampler2D uTex2; " "in highp vec2 vUV; " "void main(void) { " //"if (int(mod(gl_FragCoord.y - 1023.5, 2.0)) != 1) { discard; }\n" //"if ((int(gl_FragCoord.y) & 1) == 0) { discard; }" "out_FragColor = ((int(gl_FragCoord.y) & 1) == 0 ? texture(uTex, vUV) :" "texture(uTex2, vUV)); }")) << rowInterUniformTex << rowInterUniformTex2; buf->setVertices(gl::TriangleStrip, VBuf::Builder().makeQuad(Rectanglef(-1, -1, 2, 2), Rectanglef(0, 0, 1, 1)), gl::Static); }
void initBlur() { if (blur) return; blur.reset(new BlurState); // The blurred version of the view is downsampled. blur->size = (self().root().viewSize() / GuiWidget::toDevicePixels(4)).max(Vector2ui(1, 1)); for (int i = 0; i < 2; ++i) { // Multisampling is disabled in the blurs for now. blur->fb[i].reset(new GLTextureFramebuffer(Image::RGB_888, blur->size, 1)); blur->fb[i]->glInit(); blur->fb[i]->colorTexture().setFilter(gl::Linear, gl::Linear, gl::MipNone); } // Set up the drawble. DefaultVertexBuf *buf = new DefaultVertexBuf; blur->drawable.addBuffer(buf); buf->setVertices(gl::TriangleStrip, DefaultVertexBuf::Builder().makeQuad( Rectanglef(0, 0, 1, 1), Vector4f(1, 1, 1, 1), Rectanglef(0, 0, 1, 1)), gl::Static); blur->uBlurStep = Vector2f(1.f / float(blur->size.x), 1.f / float(blur->size.y)); self().root().shaders().build(blur->drawable.program(), "fx.blur.horizontal") << blur->uMvpMatrix << blur->uTex << blur->uBlurStep << blur->uWindow; blur->drawable.addProgram("vert"); self().root().shaders().build(blur->drawable.program("vert"), "fx.blur.vertical") << blur->uMvpMatrix << blur->uTex << blur->uColor << blur->uBlurStep << blur->uWindow; }
void GameOverScreen::atEntry() { Game::getInstance()->getGraphics()->setBackground( TextureSection::ptr(new TextureSection(L"Images/background_game_over.png"))); mainMenyButton.reset(new Button( TextureSection(L"Images/NewBI/BackBtn1.png"), TextureSection(L"Images/NewBI/BackBtn2.png"), Rectanglef(glm::vec2(0.02f, 0.02f), glm::vec2(0.1f, 0.075f)), 0)); glm::vec2 letterRatio(0.5f, 1.f); glm::vec3 white(1.f); std::string res; std::string winningPlayerName; std::string losingPlayerName; unsigned int winnerScore; unsigned int loserScore; if (myScore >= opponentScore) { res = "You Won!"; winningPlayerName = myName; losingPlayerName = opponentName; winnerScore = myScore; loserScore = opponentScore; } else { res = "You Lost!"; winningPlayerName = opponentName; losingPlayerName = myName; winnerScore = opponentScore; loserScore = myScore; } result.reset(new Label( glm::vec2(0.2f, 0.65f), 0.15f * letterRatio, res, 0, white)); winningPlayer.reset(new Label( glm::vec2(0.15f, 0.4f), 0.075f * letterRatio, winningPlayerName, 0, white)); losingPlayer.reset(new Label( glm::vec2(0.15f, 0.25f), 0.075f * letterRatio, losingPlayerName, 0, white)); winScore.reset(new Label( glm::vec2(0.7f, 0.4f), 0.075f * letterRatio, boost::lexical_cast<std::string>(winnerScore), 0, white)); loseScore.reset(new Label( glm::vec2(0.7f, 0.25f), 0.075f * letterRatio, boost::lexical_cast<std::string>(loserScore), 0, white)); }