MCPcopy Create free account
hub / github.com/TankOs/SFGUI / WipeStateCache

Method WipeStateCache

src/SFGUI/Renderer.cpp:488–526  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

486}
487
488void Renderer::WipeStateCache( sf::RenderTarget& target ) const {
489 // Make SFML disable it's **************** vertex cache without us
490 // having to call ResetGLStates() and disturbing OpenGL needlessly.
491 // This would be sooo much easier if we could somehow set
492 // myCache.UseVertexCache = false;
493 // in window by ourself every frame.
494 // SFML doesn't like to play nice with other VBO / Vertex Array
495 // users, that's for sure... It assumes that the array pointers
496 // don't get changed between calls to Draw() unless ResetGLStates()
497 // is explicitly called in between. Why do we need to call OpenGL
498 // 10+ times just to reset something this simple? No logic.
499
500 //static sf::VertexArray resetter_array( sf::TrianglesStrip, 5 );
501 //window.Draw( resetter_array );
502
503 // Or... even more evil... use memset to blank the StatesCache of
504 // the RenderWindow with zeros. Thankfully, because we are using
505 // the data structures directly from the SFML headers, if Laurent
506 // decides to change their size one day we won't even notice.
507 struct StatesCache {
508 bool glStatesSet;
509 bool ViewChanged;
510 sf::BlendMode LastBlendMode;
511 std::uint64_t LastTextureId;
512 bool UseVertexCache;
513 sf::Vertex VertexCache[4];
514 };
515
516 // All your cache are belong to us.
517 memset( reinterpret_cast<char*>( &target ) + sizeof( sf::RenderTarget ) - sizeof( StatesCache ) + 1, 0, sizeof( StatesCache ) - 1 );
518
519 // This is to make it forget it's cached viewport.
520 // Seriously... caching the viewport? Come on...
521 memset( reinterpret_cast<char*>( &target ) + sizeof( sf::RenderTarget ) - sizeof( StatesCache ) + 1, 1, 1 );
522
523 // Since we wiped SFML's cache of its bound texture, we
524 // should make sure that it stays coherent with reality :).
525 sf::Texture::bind( 0 );
526}
527
528/// @cond
529

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected