Original Post
Hi ppl. I am trying to code a somewhat simple paint program.(c++) I was able to draw primitives like lines rectangles or triangles so far. I am using an array of structs to hold data about these primitives and in the display function i am clearing the screen and painting each element.Something like that. Now i need to implement a free brush and what random thing user draws cant be hold in a struct.(Just random dots god knows how many)So my initial design became useless for i cant call something like drawBrushTrails(). This will be impossibly difficult if i try to impelement "seed fill". So i tried to get all pixel color data and paint on it and reget the pixel data. Something like this. Irrelevant lines are exculuded. However this isnt what i want either because now whatever user does stays on screen. For example while drawing a line user clicks somewhere marking the begging of a line, then moves the mouse to somewhere else and clicks a second time ti end drawing. But program shows intermediate lines (like ms paint) and they stay on screen making the whole approach useless. I am pretty sure some of you have already walked these paths. Any idea or link or code will be much appretiated.
glClearColor(1.0,1.0,1.0,1.0); // Set the color to use in glClear.
glClear(GL_COLOR_BUFFER_BIT); // Fill the window with the color.
drawItems(); // Draw all the items that the user has created.
glutSwapBuffers(); // Makes the drawing appear on the screen!
void myGlutIdle( void )
{
glReadBuffer(GL_BACK);
glReadPixels(0,0,arrayW,arrayH,
GL_RGB,GL_UNSIGNED_BYTE,(void *)pixelMap);
glutPostRedisplay();
}
void display() {
glDrawPixels(arrayW,arrayH,GL_RGB,GL_UNSIGNED_BYTE,pixelMap);//Paint all data
drawItems(); // Draw all the items that the user has created.
glutSwapBuffers(); // Makes the drawing appear on the screen!
}