我试图在窗口的背景中获得非着色的每像素照明。它应该在左上角呈现完全白色,在左下角呈现完全黑色,但它的白色带有黑色边缘。由于某种原因,除了最右边和远边底边之外的所有像素都是完全白色的(边缘是黑色的))。为什么它没有正确渲染?
glViewport(0, 0, Display.getWidth(), Display.getHeight());
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, 2000, 2000, 0, 1, -1);
glMatrixMode(GL_MODELVIEW);
if (lighting != 0)
glDeleteLists(lighting, 1);
lighting = glGenLists(1);
glNewList(lighting, GL_COMPILE);
glDisable(GL_TEXTURE_2D);
glBegin(GL_POINTS);
for (int x = 1; x <= 2000; x++)
{
for (int y = 1; y <= 2000; y++)
{
double dist = new Point(x, y).distance(new Point(0, 0));
double brightness = 1 - (1 / 2000 * dist); //I tried just "1 / 2000 & dist" instead, but that just renders black everywhere
glColor3d(brightness, brightness, brightness);
glVertex2f(x, y);
}
}
glEnd();
glEndList();