OnMouseMove swap and clear problem
-
Hello, i need help with this onMouseMove function... what i am doing here is drawing a line on the left and right side. On the left it;s all OpenGL AVI on the right i am calling my own function to draw the same lines as i move a mouse... however my problem is with MakeCurrent and clear screen here... because when i draw a line and rotate it ... there are bunch of lines all around. I don't know what i am doing wrong and where i need this swap buffer.... can someone please tell me how to get rid of those multiple lines when i move my mouse:
void CtestopenglView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
wglMakeCurrent(m_hDC,m_hRC);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClear(GL_COLOR_BUFFER_BIT);
::SwapBuffers(m_hDC);
if(m_drawenabled)
{
m_start = point;
glPushMatrix();
glColor3f(0.0,0.0,0.0);
DrawLine(m_start.x+300, m_start.y, m_end.x+300, m_end.y);glBegin(GL\_LINES); glVertex3d(m\_start.x, m\_start.y,0); glVertex3d(m\_end.x, m\_end.y,0); glEnd(); glPopMatrix(); m\_start = point; glPushMatrix(); glColor3f(1.0,1.0,1.0); DrawLine(m\_start.x+300, m\_start.y, m\_end.x+300, m\_end.y); glBegin(GL\_LINES); glVertex3d(m\_start.x, m\_start.y,0); glVertex3d(m\_end.x, m\_end.y,0); glEnd(); glPopMatrix(); } CView::OnMouseMove(nFlags, point); wglMakeCurrent(m\_hDC,NULL); wglMakeCurrent(m\_hDC,m\_hRC); glFlush(); ::SwapBuffers(m\_hDC);
}
thanks
-
Hello, i need help with this onMouseMove function... what i am doing here is drawing a line on the left and right side. On the left it;s all OpenGL AVI on the right i am calling my own function to draw the same lines as i move a mouse... however my problem is with MakeCurrent and clear screen here... because when i draw a line and rotate it ... there are bunch of lines all around. I don't know what i am doing wrong and where i need this swap buffer.... can someone please tell me how to get rid of those multiple lines when i move my mouse:
void CtestopenglView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
wglMakeCurrent(m_hDC,m_hRC);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClear(GL_COLOR_BUFFER_BIT);
::SwapBuffers(m_hDC);
if(m_drawenabled)
{
m_start = point;
glPushMatrix();
glColor3f(0.0,0.0,0.0);
DrawLine(m_start.x+300, m_start.y, m_end.x+300, m_end.y);glBegin(GL\_LINES); glVertex3d(m\_start.x, m\_start.y,0); glVertex3d(m\_end.x, m\_end.y,0); glEnd(); glPopMatrix(); m\_start = point; glPushMatrix(); glColor3f(1.0,1.0,1.0); DrawLine(m\_start.x+300, m\_start.y, m\_end.x+300, m\_end.y); glBegin(GL\_LINES); glVertex3d(m\_start.x, m\_start.y,0); glVertex3d(m\_end.x, m\_end.y,0); glEnd(); glPopMatrix(); } CView::OnMouseMove(nFlags, point); wglMakeCurrent(m\_hDC,NULL); wglMakeCurrent(m\_hDC,m\_hRC); glFlush(); ::SwapBuffers(m\_hDC);
}
thanks
What happens if you get rid of the first
SwapBuffers
call? I have a feeling that the glClear won't be clearing the buffer you're drawing on, and also that you only need one SwapBuffer call per iteration (you'll be drawing on the back buffer and swapping it to the front once it's drawn on?, then doing the same thing with the other buffer at the next iteration)Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
-
What happens if you get rid of the first
SwapBuffers
call? I have a feeling that the glClear won't be clearing the buffer you're drawing on, and also that you only need one SwapBuffer call per iteration (you'll be drawing on the back buffer and swapping it to the front once it's drawn on?, then doing the same thing with the other buffer at the next iteration)Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
hey, if i take out the first swap only i do get one line on the screen ... however it does not stay on the screen when i try to draw another... it dissapears... i need to keep on drawing the lines and keep on the screen...so that i could write something like WE right now after taking that swap out and trying to draw second line of the W first line is no longer on the screen... what should i do
-
Hello, i need help with this onMouseMove function... what i am doing here is drawing a line on the left and right side. On the left it;s all OpenGL AVI on the right i am calling my own function to draw the same lines as i move a mouse... however my problem is with MakeCurrent and clear screen here... because when i draw a line and rotate it ... there are bunch of lines all around. I don't know what i am doing wrong and where i need this swap buffer.... can someone please tell me how to get rid of those multiple lines when i move my mouse:
void CtestopenglView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
wglMakeCurrent(m_hDC,m_hRC);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClear(GL_COLOR_BUFFER_BIT);
::SwapBuffers(m_hDC);
if(m_drawenabled)
{
m_start = point;
glPushMatrix();
glColor3f(0.0,0.0,0.0);
DrawLine(m_start.x+300, m_start.y, m_end.x+300, m_end.y);glBegin(GL\_LINES); glVertex3d(m\_start.x, m\_start.y,0); glVertex3d(m\_end.x, m\_end.y,0); glEnd(); glPopMatrix(); m\_start = point; glPushMatrix(); glColor3f(1.0,1.0,1.0); DrawLine(m\_start.x+300, m\_start.y, m\_end.x+300, m\_end.y); glBegin(GL\_LINES); glVertex3d(m\_start.x, m\_start.y,0); glVertex3d(m\_end.x, m\_end.y,0); glEnd(); glPopMatrix(); } CView::OnMouseMove(nFlags, point); wglMakeCurrent(m\_hDC,NULL); wglMakeCurrent(m\_hDC,m\_hRC); glFlush(); ::SwapBuffers(m\_hDC);
}
thanks
For msg based painting you should only draw in the paint handler. In the mouse handler save any mouse specific state that's important then invalidate the area that needs to be redrawn.
...cmk The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying. - John Carmack