简体   繁体   中英

Java LWJGL: Buttons flickering

I'm currently trying to create a game title menu in LWJGL, but when I hover over one of my buttons, it starts to flicker and changes really fast between the DEFAULT and the HOVER state. After about 0.5 seconds, the flickering stops and it shows the hover texture. When moving the mouse away from the button again, the same thing happens and after 0.5 seconds it shows the default texture again.

I'm using the latest Eclipse, Java, jinput and LWJGL versions.

What I've already tried:

  • Display.sync(123) --> high numbers make the flickering last longer, low numbers (1-5) stop the flickering but I obviously don't want to have 5 FPS.
  • Display.setVSyncEnabled(true) --> doesn't change anything

Source code:

(Removed: The source code was not related to the problem and the post was too long... See my answer below for the solution.)

Thanks in advance! (I'm trying to fix this for a few days now...)

EDIT: Is has probably nothing to do with my mouse as I changed the isHovering method so it uses the system time. It still flickers. Thanks for any help!

Fixed it, finally!

For anyone else who has this problem and is able to understand my bad English: I accidently put the Display.update() call in my game loop instead of the render loop so it was called too often.

Good luck if you've got the same problem!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM