Goal : Basically, what I'm trying to do is use SDL to make a window, then use SDL_ttf to print out the xy coordinates of the mouse in said window.
Issue : Instead of the current value of the stream removing then replacing the old value (aka updating), it just piles up (EG. moving mouse from left to right should change it from 1 to 2 to 3 etc. instead it shows 123).
here's the piece of code that I'm working with.
while(SDL_PollEvent(&event))
{
if(event.type == SDL_MOUSEMOTION)
{
SDL_FreeSurface(Mousecoords);
if(SDL_Flip(screen) == -1)
{
return 0;
}
int x = 0;
int y = 0;
x = event.motion.x;
y = event.motion.y;
xcoord << x;
ycoord << y;
Mousecoords = TTF_RenderText_Solid(font, xcoord.str().c_str(), textColor);
apply_surface(0,0,Mousecoords,screen);
if(SDL_Flip(screen) == -1)
{
return 0;
}
}