Hi, im a newbie on OpenGL and what im trying to do is to render a square with 2 for-loops setting it pixel by pixel. The problem is that when i render it on some coordinates it works just fine but i have discovered that i get one horizontal and one vertical line going through the rectangle. I am doing this in XOR-mode and i need to keep doing that.
Pleas, please help me with this weird problem. Listed below is all my code.
#include <GL/glut.h>
#include <windows.h>
void myinit(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glColor3f(1.0, 1.0, 1.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 500.0, 0.0, 500.0);
glMatrixMode(GL_MODELVIEW);
//enable XOR'ing
glEnable(GL_COLOR_LOGIC_OP);
glLogicOp(GL_XOR);
}
void display( void )
{
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POINTS);
for(int y = 100; y <= 300; y++)
{
for(int x = 200; x <= 400; x++)
{
glVertex2i(x, y);
}
}
glEnd();
glFlush(); /* clear buffers /
}
void main(int argc, char* argv)
{
/* Standard GLUT initialization */
glutInit(&argc,argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(500,500);
glutInitWindowPosition(0,0); glutCreateWindow(“Test”);
glutDisplayFunc(display);
myinit(); /* set attributes */
glutMainLoop(); /* enter event loop */
}