MCPcopy Create free account
hub / github.com/SFML/SFML / tryLoadGeometry

Function tryLoadGeometry

examples/shader/Shader.cpp:343–367  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

341}
342
343std::optional<Geometry> tryLoadGeometry()
344{
345 // Check if geometry shaders are supported
346 if (!sf::Shader::isGeometryAvailable())
347 return std::nullopt;
348
349 // Load the logo texture
350 sf::Texture logoTexture;
351 if (!logoTexture.loadFromFile("resources/logo.png"))
352 return std::nullopt;
353
354 logoTexture.setSmooth(true);
355
356 // Load the shader
357 sf::Shader shader;
358 if (!shader.loadFromFile("resources/billboard.vert", "resources/billboard.geom", "resources/billboard.frag"))
359 return std::nullopt;
360
361 shader.setUniform("texture", sf::Shader::CurrentTexture);
362
363 // Set the render resolution (used for proper scaling)
364 shader.setUniform("resolution", sf::Vector2f(800, 600));
365
366 return std::make_optional<Geometry>(std::move(logoTexture), std::move(shader));
367}
368
369} // namespace
370

Callers 1

mainFunction · 0.85

Calls 3

setUniformMethod · 0.80
loadFromFileMethod · 0.45
setSmoothMethod · 0.45

Tested by

no test coverage detected