Anyway, I found that it happens with any version of Minecraft that is modified. Works fine when I run vanilla MC 1.8, 1.8.8, etc, but then is broken when trying to run Forge and Optifine versions.
I deleted everything related to Minecraft on my computer after copying my current .minecraft folder. The problem was fixed after I reinstalled the game, but then it happened again when I replaced the new .minecraft folder with the old one.