SDLPP: Don't save textures before render
Since textures should only be manipulated in the main thread (as well as rendering), let programmers deal with ensuring the texture is available during rendercopy
This commit is contained in:
parent
392bc4f203
commit
f92a94ef01
@ -119,7 +119,4 @@ void RenderObject::copyTo( std::shared_ptr< RenderObject > other ) {
|
|||||||
}
|
}
|
||||||
other->colidedWith.clear();
|
other->colidedWith.clear();
|
||||||
}
|
}
|
||||||
void RenderObject::saveCurTexture() {
|
|
||||||
cur_texture = texture;
|
|
||||||
}
|
|
||||||
} // namespace SDLPP
|
} // namespace SDLPP
|
||||||
|
@ -16,6 +16,7 @@ class SDLPPSCOPE RenderObject {
|
|||||||
public:
|
public:
|
||||||
RenderObject( const std::shared_ptr< Renderer > &r ) : renderer( r ) {}
|
RenderObject( const std::shared_ptr< Renderer > &r ) : renderer( r ) {}
|
||||||
virtual ~RenderObject() {}
|
virtual ~RenderObject() {}
|
||||||
|
// TODO maybe do basic render() that all descandants can inherit?
|
||||||
virtual void render() = 0;
|
virtual void render() = 0;
|
||||||
virtual int leftmost() = 0;
|
virtual int leftmost() = 0;
|
||||||
virtual int topmost() = 0;
|
virtual int topmost() = 0;
|
||||||
@ -78,7 +79,6 @@ public:
|
|||||||
bool isStatic();
|
bool isStatic();
|
||||||
void setStatic( bool stat = true );
|
void setStatic( bool stat = true );
|
||||||
std::shared_ptr< Renderer > getRenderer() const;
|
std::shared_ptr< Renderer > getRenderer() const;
|
||||||
void saveCurTexture();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void copyTo( std::shared_ptr< RenderObject > other );
|
virtual void copyTo( std::shared_ptr< RenderObject > other );
|
||||||
|
@ -120,11 +120,9 @@ void Scene::renderScene( bool clear_renderer ) {
|
|||||||
if ( background && background->getTexturePtr() )
|
if ( background && background->getTexturePtr() )
|
||||||
SDL_RenderCopy( renderer->getRendererPtr(), background->getTexturePtr(),
|
SDL_RenderCopy( renderer->getRendererPtr(), background->getTexturePtr(),
|
||||||
NULL, NULL );
|
NULL, NULL );
|
||||||
for ( const auto &x : render_objects ) {
|
for ( const auto &x : render_objects )
|
||||||
x->saveCurTexture();
|
|
||||||
x->render();
|
x->render();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
void Scene::presentScene() {
|
void Scene::presentScene() {
|
||||||
SDL_RenderPresent( renderer->getRendererPtr() );
|
SDL_RenderPresent( renderer->getRendererPtr() );
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user