Hi guys, I got a question regarding drawing objects with sub pixel accuracy. I have 2 vertical lines that are 1.5 pixels apart, as I slowly move them horizontally across the screen, I see a seam appearing/disappearing between the 2 lines. Is there any way to get rid of this artifact without increase the screen resolution? Thanks in advance.
Try to google “wu line”.
How is that supposed to help him? Are you suggesting he should anti-alias per hand? very funny.
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
These two commands are called directly after initializing “g” (Graphics2D)
If you’re not sure about the effects, try them seperately. You’ll immediately see what they do.
First of all, pretty sure he’s using LWJGL, not Java2D, and second, relminator’s response may not have been too detailed but for low-level stuff like LWJGL it is important to know how these things work.
Of course, I only looked at the question and not his 9 projects and they’re all 3D, hehe. Still surprised that he would run into problems like this… Shows how much I know!
If using OpenGL related library, this should do it:
glEnable( GL_LINE_SMOOTH );
glEnable( GL_POLYGON_SMOOTH );
glHint( GL_LINE_SMOOTH_HINT, GL_NICEST );
glHint( GL_POLYGON_SMOOTH_HINT, GL_NICEST );
EDIT:
And I think you need blending enabled:
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);