Buenas gente del foro, tengo una consulta con SDL2 que ojalá algún gurú de esta librería sepa resolver...
Estaba creando una ventana con renderizado en OpenGL y mi problema es que al mover la ventana manteniendo click produce un temblor en el movimiento demasiado extraño. Con WinAPI no tengo problema en mi código pero al portar esto a SDL2 (porque deseo crear la aplicación multiplataforma) produce esa sacudida extraña...
// Main loop
bool bOpen = true;
while (bOpen)
{
SDL_Event event;
static bool bMouseClicked=false;
static int xMPos=0,yMPos=0;
while (SDL_PollEvent(&event))
{
if(event.type == SDL_MOUSEBUTTONDOWN)
{
if(event.button.button == SDL_BUTTON_LEFT)
{
bMouseClicked=true;
SDL_CaptureMouse(SDL_TRUE);
SDL_GetMouseState(&xMPos,&yMPos);
}
}
if(event.type == SDL_MOUSEBUTTONUP)
{
if(event.button.button == SDL_BUTTON_LEFT)
{
bMouseClicked=false;
SDL_CaptureMouse(SDL_FALSE);
}
}
if(event.type == SDL_MOUSEMOTION)
{
int xPos,yPos,xMPosN,yMPosN;
if(bMouseClicked)
{
SDL_GetWindowPosition(window,&xPos,&yPos);
SDL_GetMouseState(&xMPosN,&yMPosN);
xPos+=xMPosN-xMPos;
yPos+=yMPosN-yMPos;
SDL_SetWindowPosition(window,xPos,yPos);
//SDL_FlushEvent(SDL_WINDOWEVENT_MOVED);
//SDL_FlushEvents(SDL_WINDOWEVENT,SDL_SYSWMEVENT);
}
}
if (event.type == SDL_QUIT)
bOpen = false;
}
B#