I am trying to render an image by drawing it pixel for pixel (yes I know this isn't the most efficient but its more for learning purposes) and I got the weird problem that it draws white lines like this:
I use glut and visual studio 2013. This is my glutinit
:
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH | GLUT_ALPHA); // Double buffering, RGB format
glutInitWindowSize(width, heigth);
glutInitWindowPosition(0, 0);
glutCreateWindow("Test Plaatje");
glClearColor(1.0, 1.0, 1.0, 1.0);
glColor3f(1.0, 1.0, 1.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 1024, 0.0, 500);
glMatrixMode(GL_MODELVIEW);
and this is my rendering code with some variables explained:
...
std::vector<std::vector<RGB>> _map = std::vector<std::vector<RGB>>();
...
struct RGB
{
int R;
int G;
int B;
};
...
void Map::draw()
{
glBegin(GL_POINTS);
for (float x = 0; x < _w; x++)
{
for (float y = 0; y < _h; y++)
{
RGB pixel = _map[y][x];
glColor3ub(pixel.R, pixel.G, pixel.B);
glVertex2f(_p[0] + x, _p[1] + y);
}
}
glEnd();
}
I already tried shifting the pixels with some decimal value but that didn't work. I verified that the _map
is correct by dumping the pixel values to file. for reference this is what it should render:
I have no idea how to fix this. anyone have any ideas?