One texture lagging behind the other SDL C++

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



One texture lagging behind the other SDL C++



I have two textures which share the same position, but when rendered one lags behind the other. I have verified that they do share the same positions but printing them.



The code in my main loop looks like this:


objectOne.draw(window.renderer, timer.getDelta());
objectTwo.updatePosition(objectOne.get_x(),objectOne.get_y());
objectTwo.draw(window.renderer);
window.present();



Object one's draw:


void objectOne::draw(SDL_Renderer *_renderer, float delta)

getDeltaTime(delta);
input(_renderer);
move();

destination.x = _x;
destination.y = _y;



Object two's update position and draw function:


void objectTwo::updatePosition(int x, int y)

_x = x;
_y = y;


void objectTwo::draw(SDL_Renderer *_renderer)

destination.x = _x;
destination.y = _y;
SDL_RenderCopy(_renderer, twosTexture, NULL, &destination);



Images to give an idea of what I mean:
https://imgur.com/a/evNZv9T





Please define "one lags behind the other".
– Jesper Juhl
Aug 12 at 15:22





At a guess, it looks like you might be updating objectOne's destination after the render call, while objectTwo's destination is updated before. Hard to tell, though.
– 1201ProgramAlarm
Aug 12 at 15:49


objectOne


objectTwo





Where is the call that does the actual render for object one?
– divinas
Aug 12 at 17:10





Edit in a Minimal, Complete, and Verifiable example.
– genpfault
Aug 12 at 19:51









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard