| 121 | }; |
| 122 | |
| 123 | LogoExample::LogoExample(ExampleShared& sharedData) : |
| 124 | ParticleDemo("Logo", sharedData) |
| 125 | { |
| 126 | Nz::ImageParams params; |
| 127 | params.loadFormat = Nz::PixelFormatType_RGBA8; |
| 128 | |
| 129 | if (!m_logo.LoadFromFile("resources/Logo.png", params)) |
| 130 | NazaraError("Failed to load logo!"); |
| 131 | |
| 132 | unsigned int width = m_logo.GetWidth(); |
| 133 | unsigned int height = m_logo.GetHeight(); |
| 134 | m_pixels.reserve(width * height); |
| 135 | |
| 136 | for (unsigned int x = 0; x < width; ++x) |
| 137 | { |
| 138 | for (unsigned int y = 0; y < height; ++y) |
| 139 | { |
| 140 | Nz::Color color = m_logo.GetPixelColor(x, y); |
| 141 | if (color.a == 0) |
| 142 | continue; |
| 143 | |
| 144 | PixelData data; |
| 145 | data.pos.Set(x, y); |
| 146 | data.color = color; |
| 147 | |
| 148 | m_pixels.push_back(data); |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | |
| 153 | Nz::MaterialRef material = Nz::Material::New(); |
| 154 | material->EnableBlending(true); |
| 155 | material->EnableDepthWrite(false); |
| 156 | material->EnableFaceCulling(false); |
| 157 | material->SetDstBlend(Nz::BlendFunc_InvSrcAlpha); |
| 158 | material->SetSrcBlend(Nz::BlendFunc_SrcAlpha); |
| 159 | |
| 160 | m_controller = new SpriteController; |
| 161 | m_renderer = new SpriteRenderer(std::move(material)); |
| 162 | |
| 163 | m_declaration = Nz::ParticleDeclaration::New(); |
| 164 | m_declaration->EnableComponent(Nz::ParticleComponent_Color, Nz::ComponentType_Color, NazaraOffsetOf(ParticleData, color)); |
| 165 | m_declaration->EnableComponent(Nz::ParticleComponent_Position, Nz::ComponentType_Float3, NazaraOffsetOf(ParticleData, position)); |
| 166 | m_declaration->EnableComponent(Nz::ParticleComponent_Userdata0, Nz::ComponentType_Float2, NazaraOffsetOf(ParticleData, destination)); |
| 167 | m_declaration->EnableComponent(Nz::ParticleComponent_Velocity, Nz::ComponentType_Float2, NazaraOffsetOf(ParticleData, velocity)); |
| 168 | } |
| 169 | |
| 170 | void LogoExample::Enter(Ndk::StateMachine& fsm) |
| 171 | { |
nothing calls this directly
no test coverage detected