【发布时间】:2016-11-24 11:32:44
【问题描述】:
我可以使用 OpenGL 画一条线,结果如下:
但是,与我的游戏像素化风格相比,这条线看起来很流畅且格格不入。我更喜欢看起来更像这样的结果:
谁能给我一些提示,告诉我如何让 OpenGL 绘制这样的像素化线?
这是我的 renderLine() 方法(恐怕使用立即模式):
public static void renderLine(float x1, float y1, float x2, float y2,
float thickness, float[] colour) {
// Store model matrix to prevent contamination
glPushMatrix();
// Set colour and thickness
glColor4f(colour[0], colour[1], colour[2], colour[3]);
glLineWidth(thickness);
// Draw line
glBegin(GL_LINES);
{
glVertex2f(x1, y1);
glVertex2f(x2, y2);
}
glEnd();
// Restore previous state
glColor4f(1, 1, 1, 1);
glLineWidth(1.0f);
glPopMatrix();
}
【问题讨论】:
标签: opengl pixels antialiasing