Jump to content
  • Advertisement
Sign in to follow this  

MFC OpenGL Invalidate Flickering

This topic is 2652 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Dear Friends
I am wirting an application for drawing a rectangle on the screen using opengl and mfc. So I implemented the OnPaint function, OnDraw function is also giving the same problem. It's drawing fine. I want to implement pan, zoom, and rotate functionalities. Now everytime the mouse moves I am calling Invalidate() or otherwise I can call Invalidate() in the ::OnDraw function. Pan, zoom and rotate everything is happening but its heavily flickering. I have serached a lot and tried all means like return 1 in the OnEraseBackground() functio for WM_ERASEBACKGROUND etc. But I am getting still flickering . Please help getting rid of this problem. Check the code snippet below.

void CRevolutionProjView::OnPaint()
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CRect RectAff;
glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f ) ;
glPushMatrix( ) ;
glTranslatef(trans[0], trans[1], trans[2]);
glRotatef(rot[0], 1.0f, 0.0f, 0.0f);
glRotatef(rot[1], 0.0f, 1.0f, 0.0f);
glPopMatrix( ) ;
glFinish( ) ;
// Do not call CView::OnPaint() for painting messages

void CRevolutionProjView::OnMouseMove(UINT nFlags, CPoint point)
newP = point;
// TODO: Add your message handler code here and/or call default
int dx = oldP.x - newP.x;
int dy = newP.y - oldP.y;
case PAN:
trans[0] -= dx/100.0f;
trans[1] -= dy/100.0f;
// Invalidate();
case ZOOM:
trans[2] -= (dx+dy) / 100.0f;
// Invalidate();
case ROTATE:
rot[0] += (dy * 180.0f) / 500.0f;
rot[1] -= (dx * 180.0f) / 500.0f;
#define clamp(x) x = x > 360.0f ? x-360.0f : x < -360.0f ? x+=360.0f : x
// Invalidate();


oldP = newP;

CView::OnMouseMove(nFlags, point);

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!