void BillboardSample::render(float elapsedTime) { // Clear the color and depth buffers clear(CLEAR_COLOR_DEPTH, Vector4::fromColor(0x355D90FF), 1.0f, 0); // Draw the ground _ground->draw(); // Get the scene camera Camera* camera = _scene->getActiveCamera(); for (unsigned int i = 0; i < BILLBOARD_COUNT; i++) { Node* node = _billboards[i]; // Rotate the node x/z to face the camera Matrix m; Matrix::createBillboard(node->getTranslationWorld(), camera->getNode()->getTranslationWorld(), camera->getNode()->getUpVectorWorld(), &m); Quaternion q; m.getRotation(&q); node->setRotation(q); if (node->getBoundingSphere().intersects(camera->getFrustum())) node->getDrawable()->draw(); } // draw the gamepad _gamepad->draw(); // draw the frame rate drawFrameRate(_font, Vector4::one(), 5, 1, getFrameRate()); }
void CreateSceneSample::render(float elapsedTime) { // Clear the color and depth buffers clear(CLEAR_COLOR_DEPTH, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0); // Visit all the nodes in the scene, drawing the models. _scene->visit(this, &CreateSceneSample::drawScene); drawFrameRate(_font, Vector4(0, 0.5f, 1, 1), 5, 1, getFrameRate()); }
void TriangleSample::render(float elapsedTime) { // Clear the color and depth buffers clear(CLEAR_COLOR_DEPTH, Vector4::zero(), 1.0f, 0); // Bind the view projection matrix to the model's parameter. This will transform the vertices when the model is drawn. _model->getMaterial()->getParameter("u_worldViewProjectionMatrix")->setValue(_worldViewProjectionMatrix); _model->draw(); drawFrameRate(_font, Vector4(0, 0.5f, 1, 1), 5, 1, getFrameRate()); }
void MeshGame::render(float elapsedTime) { // Clear the color and depth buffers. clear(CLEAR_COLOR_DEPTH, Vector4::zero(), 1.0f, 0); // Visit all the nodes in the scene, drawing the models/mesh. _scene->visit(this, &MeshGame::drawScene); // Draw the fps drawFrameRate(_font, Vector4(0, 0.5f, 1, 1), 5, 1, getFrameRate()); }
void GamepadSample::render(float elapsedTime) { clear(CLEAR_COLOR_DEPTH, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0); drawFrameRate(_font, Vector4(0, 0.5f, 1, 1), 5, 1, getFrameRate()); _font->start(); _font->drawText(_status.c_str(), 7, 27, Vector4::one(), 22); _font->finish(); _gamepad->draw(); }
void Audio3DTest::render(float elapsedTime) { // Clear the color and depth buffers clear(CLEAR_COLOR_DEPTH, Vector4::zero(), 1.0f, 0); // Visit all the nodes in the scene for drawing _scene->visit(this, &Audio3DTest::drawScene); drawDebugText(0, _font->getSize()); _gamepad->draw(); drawFrameRate(_font, Vector4(0, 0.5f, 1, 1), 5, 1, getFrameRate()); }
void ParticlesGame::render(float elapsedTime) { // Clear the color and depth buffers. clear(CLEAR_COLOR_DEPTH, BACKGROUND_COLOR, 1.0f, 0); // Visit all the nodes in the scene for drawing. _scene->visit(this, &ParticlesGame::drawScene, (void*)0); // Draw the UI. _form->draw(); // Draw the framerate and number of live particles. drawFrameRate(_font, Vector4(1, 1, 1, 1), 170, 40, getFrameRate()); }
void PostProcessSample::render(float elapsedTime) { Rectangle defaultViewport = Game::getInstance()->getViewport(); // Draw into the framebuffer Game::getInstance()->setViewport(Rectangle(FRAMEBUFFER_WIDTH, FRAMEBUFFER_HEIGHT)); FrameBuffer* previousFrameBuffer = _frameBuffer->bind(); clear(CLEAR_COLOR_DEPTH, Vector4::zero(), 1.0f, 0); _scene->visit(this, &PostProcessSample::drawScene); // Bind the current compositor Game::getInstance()->setViewport(defaultViewport); Compositor* compositor = _compositors[_compositorIndex]; FrameBuffer* compositorDstFrameBuffer = compositor->getDstFrameBuffer(); FrameBuffer* prevToCompositeFrameBuffer = NULL; if (compositorDstFrameBuffer) { prevToCompositeFrameBuffer = compositorDstFrameBuffer->bind(); } else { prevToCompositeFrameBuffer = previousFrameBuffer->bind(); } Game::getInstance()->clear(CLEAR_COLOR, Vector4(0, 0, 0, 1), 1.0f, 0); compositor->blit(defaultViewport); drawFrameRate(_font, Vector4(0, 0.5f, 1, 1), 5, 1, getFrameRate()); drawTechniqueId(compositor->getTechniqueId()); previousFrameBuffer->bind(); // Draw the pass through compositor at index 0 at quarter of the size and bottom right. dont clear the dest just draw last on top float quarterWidth = getWidth() / 4; float quarterHeight = getHeight() / 4; Rectangle offsetViewport = Rectangle(getWidth() - quarterWidth, 0, quarterWidth, quarterHeight); Game::getInstance()->setViewport(offsetViewport); compositor = _compositors[0]; compositor->blit(offsetViewport); Game::getInstance()->setViewport(defaultViewport); }
void MeshPrimitiveTest::render(float elapsedTime) { // Clear the color and depth buffers clear(CLEAR_COLOR_DEPTH, Vector4::zero(), 1.0f, 0); Matrix wvp; wvp.rotateY(_tilt.x * 0.01f); wvp.rotateX(_tilt.y * 0.01f); Matrix::multiply(wvp, _viewProjectionMatrix, &wvp); Matrix m; float offset = 0.5f; // Bind the view projection matrix to the model's paramter. This will transform the vertices when the model is drawn. m.setIdentity(); m.translate(-offset, offset, 0); Matrix::multiply(m, wvp, &m); _triangles->getMaterial()->getParameter("u_worldViewProjectionMatrix")->setValue(m); _triangles->draw(); m.setIdentity(); m.translate(0, offset, 0); Matrix::multiply(m, wvp, &m); _triangleStrip->getMaterial()->getParameter("u_worldViewProjectionMatrix")->setValue(m); _triangleStrip->draw(); m.setIdentity(); m.translate(-offset, -offset, 0); Matrix::multiply(m, wvp, &m); _lineStrip->getMaterial()->getParameter("u_worldViewProjectionMatrix")->setValue(m); _lineStrip->draw(); m.setIdentity(); m.translate(0, -offset, 0); Matrix::multiply(m, wvp, &m); _lines->getMaterial()->getParameter("u_worldViewProjectionMatrix")->setValue(m); _lines->draw(); drawFrameRate(_font, Vector4(0, 0.5f, 1, 1), 5, 1, getFrameRate()); }
void LightSample::render(float elapsedTime) { // Clear the color and depth buffers clear(CLEAR_COLOR_DEPTH, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0); _model->draw(); if(_directional->isSelected()) { _directionalLightQuadModel->draw(); } else if (_spot->isSelected()) { _spotLightQuadModel->draw(); } else if (_point->isSelected()) { _pointLightQuadModel->draw(); } _form->draw(); drawFrameRate(_font, Vector4(0, 0.5f, 1, 1), 5, 1, getFrameRate()); }
void SpriteBatchTest::render(float elapsedTime) { // Clear the color and depth buffers clear(CLEAR_COLOR_DEPTH, Vector4::zero(), 1.0f, 0); Rectangle dst(0, 0, 64, 64); Rectangle src(0, 0, 256, 256); _spriteBatch->start(); // Just a sprite dst from src no color tint _spriteBatch->draw(dst, src); // Color tint _spriteBatch->draw(Rectangle( 64, 0, 64, 64), src, Vector4::fromColor(0xF68B28FF)); _spriteBatch->draw(Rectangle(128, 0, 64, 64), src, Vector4::fromColor(0xDA2128FF)); _spriteBatch->draw(Rectangle(192, 0, 64, 64), src, Vector4::fromColor(0xE21B52FF)); _spriteBatch->draw(Rectangle(256, 0, 64, 64), src, Vector4::fromColor(0xE12991FF)); _spriteBatch->draw(Rectangle(320, 0, 64, 64), src, Vector4::fromColor(0x9A258FFF)); _spriteBatch->draw(Rectangle(384, 0, 64, 64), src, Vector4::fromColor(0x4D3F99FF)); _spriteBatch->draw(Rectangle(448, 0, 64, 64), src, Vector4::fromColor(0x0073BCFF)); _spriteBatch->draw(Rectangle(512, 0, 64, 64), src, Vector4::fromColor(0x00A8DFFF)); _spriteBatch->draw(Rectangle(576, 0, 64, 64), src, Vector4::fromColor(0x00AFADFF)); _spriteBatch->draw(Rectangle(640, 0, 64, 64), src, Vector4::fromColor(0x00A95CFF)); _spriteBatch->draw(Rectangle(704, 0, 64, 64), src, Vector4::fromColor(0x8CC747FF)); _spriteBatch->draw(Rectangle(768, 0, 64, 64), src, Vector4::fromColor(0xFFE710FF)); // Negative height draw over top of the first one _spriteBatch->draw(Rectangle(0, 0 , 64 * 2.0f, 64 * -2.0f), src); // Scale _spriteBatch->draw(Vector3(0, 64, 0), src, Vector2(dst.width * 2.0f, dst.height * 2.0f)); // rotate 90 _spriteBatch->draw(Vector3(128, 64, 0), src, Vector2(128, 128), Vector4(1, 1, 1, 1), Vector2(0.5f, 0.5f), MATH_DEG_TO_RAD(90)); _spriteBatch->draw(Vector3(256, 64, 0), src, Vector2(128, 128), Vector4(1, 1, 1, 1), Vector2(0.5f, 0.5f), MATH_DEG_TO_RAD(180)); _spriteBatch->draw(Vector3(384, 64, 0), src, Vector2(128, 128), Vector4(1, 1, 1, 1), Vector2(0.5f, 0.5f), MATH_DEG_TO_RAD(270)); _spriteBatch->draw(Vector3(512, 64, 0), src, Vector2(128, 128), Vector4(1, 1, 1, 1), Vector2(0.5f, 0.5f), MATH_DEG_TO_RAD(360)); _spriteBatch->draw(Vector3(640, 64, 0), src, Vector2(128, 128), Vector4(1, 1, 1, 1), Vector2(0.5f, 0.5f), MATH_DEG_TO_RAD(0)); // Lots of them now small unsigned int pointCount = 16; unsigned int x = 0; unsigned int y = 192; for (unsigned int i = 0; i < pointCount; i++) { for (unsigned int j = 0; j < pointCount; j++) { _spriteBatch->draw(Rectangle(x, y, 32, 32), src); x += 32; } x = 0; y += 32; } _spriteBatch->finish(); // Draw a second batch to ensure no problems _spriteBatch->start(); // 50% transparent _spriteBatch->draw(Rectangle(x + 512, y - 512, 512, 512), src, Vector4(1, 1, 1, 0.5f)); _spriteBatch->finish(); drawFrameRate(_font, Vector4(0, 0.5f, 1, 1), 5, 1, getFrameRate()); }