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

Function tryLoadEdge

examples/shader/Shader.cpp:310–341  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

308}
309
310std::optional<Edge> tryLoadEdge()
311{
312 // Create the off-screen surface
313 sf::RenderTexture surface;
314 if (!surface.resize({800, 600}))
315 return std::nullopt;
316
317 surface.setSmooth(true);
318
319 // Load the background texture
320 sf::Texture backgroundTexture;
321 if (!backgroundTexture.loadFromFile("resources/sfml.png"))
322 return std::nullopt;
323
324 backgroundTexture.setSmooth(true);
325
326 // Load the entity texture
327 sf::Texture entityTexture;
328 if (!entityTexture.loadFromFile("resources/devices.png"))
329 return std::nullopt;
330
331 entityTexture.setSmooth(true);
332
333 // Load the shader
334 sf::Shader shader;
335 if (!shader.loadFromFile("resources/edge.frag", sf::Shader::Type::Fragment))
336 return std::nullopt;
337
338 shader.setUniform("texture", sf::Shader::CurrentTexture);
339
340 return std::make_optional<Edge>(std::move(surface), std::move(backgroundTexture), std::move(entityTexture), std::move(shader));
341}
342
343std::optional<Geometry> tryLoadGeometry()
344{

Callers 1

mainFunction · 0.85

Calls 4

setUniformMethod · 0.80
resizeMethod · 0.45
setSmoothMethod · 0.45
loadFromFileMethod · 0.45

Tested by

no test coverage detected