How to enable anti aliasing in LWJGL 3

Viewed 75

How to enable anti-aliasing in LWJGL 3?

For LWJGL 2 the approach is to configure multisampling via: Display.create(new PixelFormat(...));

But this class does not exist in LWJGL 3 anymore, so how to enable anti-aliasing in the default framebuffer in LWJGL 3?

2 Answers

GLFW (which should be included in LWJGL 3) has a way to set the number of samples in the default framebuffer.

GLFW.glfwWindowHint(GLFW.GLFW_SAMPLES, ...);

import org.lwjgl.GLFW; and use the function GLFW.glfwWindowHint(GLFW_SAMPLES, X); before you create your window. X is the amount of multi samples per pixel. This enables MSAA. 4 is the sweet spot (in my opinion), 8 gives best looking results for every modern hardware, upper values may or may not work, depending on whether the user's hardware supports it or not.

P.S. Make sure you AA is enabled in your graphics card's control panel. Otherwise you won't see a difference as these are just "hints" for your card.

Related