void TouchscreenButton::Render(fplbase::Renderer& renderer) { static const float kButtonZDepth = 0.0f; if (!is_visible_) { return; } renderer.set_color(vec4(color_)); auto mat = (button_.is_down() && down_material_ != nullptr) ? down_material_ : up_current_ < up_materials_.size() ? up_materials_[up_current_] : nullptr; if (!mat) return; // This is an invisible button. const vec2 window_size = vec2(renderer.window_size()); const float texture_scale = window_size.y() * one_over_cannonical_window_height_; vec2 base_size = LoadVec2( is_highlighted_ ? button_def_->draw_scale_highlighted() : (button_.is_down() ? button_def_->draw_scale_pressed() : button_def_->draw_scale_normal())); auto pulse = sinf(static_cast<float>(elapsed_time_) / 100.0f); if (is_highlighted_) { base_size += mathfu::kOnes2f * pulse * 0.05f; } vec3 texture_size = texture_scale * vec3(mat->textures()[0]->size().x() * base_size.x(), -mat->textures()[0]->size().y() * base_size.y(), 0); vec3 position = vec3(button_def()->texture_position()->x() * window_size.x(), button_def()->texture_position()->y() * window_size.y(), kButtonZDepth); renderer.set_color(mathfu::kOnes4f); if (is_active_ || inactive_shader_ == nullptr) { shader_->Set(renderer); } else { inactive_shader_->Set(renderer); } mat->Set(renderer); fplbase::Mesh::RenderAAQuadAlongX(position - (texture_size / 2.0f), position + (texture_size / 2.0f), vec2(0, 1), vec2(1, 0)); #if defined(DEBUG_RENDER_BOUNDS) DebugRender(position, texture_size, renderer); #endif // DEBUG_RENDER_BOUNDS }
void cToneMappingShader::EndDraw() { if(m_pOriginalFrameBuffer) { m_pOriginalFrameBuffer->EndDraw(); DoDownSample(); DoBlur(this->m_pHoricontalBlur,m_pDownSampleBrightShader->GetFrameBuffer()); DoBlur(this->m_pVerticalBlur,m_pHoricontalBlur->GetFrameBuffer()); this->Use(); float l_fTextureCoordinate[] ={0,1,1,0}; DrawQuadWithTextureAndColorAndCoordinate(0.f,0.f,0.f,cGameApp::m_svGameResolution.x,cGameApp::m_svGameResolution.y,Vector4::One,l_fTextureCoordinate,Vector3::Zero,this->GetName()); //if( cGameApp::m_sucKeyData['D'] ) { DebugRender(); } } }
void Simulation::Run() { while (gameWindow.IsOpened()) { sf::Event ev; while (gameWindow.GetEvent(ev)) { switch (ev.Type) { case sf::Event::Closed: gameWindow.Close(); break; default: break; } } gameWindow.Clear(sf::Color(0, 0, 0)); //CalculatePos(); world->Clear(); for (unsigned int i = 0; i < entities.size(); i++) { entities[i]->Update(); entities[i]->Render(); world->Insert(entities[i]); world->Calculate(entities[i]); //std::cout << "test3" << std::endl; } //world->Render(this); DebugRender(); gameWindow.Display(); } }