PDA

View Full Version : Opengl and MFC



aus79er
04-05-2002, 01:27 PM
I don't know much about MFC programming.
But I create a single document MFC application using appwizard.
I made following changes
void CLineView::OnDraw(CDC* pDC)
{
CLineDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
drawline();

}

void CLineView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);

// TODO: Add your message handler code here
glViewport ( 0, 0, cx, cy ) ;
}

void CLineView::drawline( )
{
glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f ) ;
glClear ( GL_COLOR_BUFFER_BIT ) ;

glBegin ( GL_LINES ) ;

glColor3f ( 0.0f, 1.0f, 0.0f ) ;
glVertex2f ( 0.25f, 0.25f ) ;
glVertex2f ( 0.75f, 0.25f ) ;

glEnd( ) ;

glFlush( );
}

And I have declared the drawline function as public in class CLineView : public CView
This code is simple ,but still i don't see any thing.
I have included gl.h and in links (setting)opengl32.lib .
What can be the problem ?

Thanks
aus

J P
04-05-2002, 01:37 PM
I can't tell where you are calling swapbuffers(), see examples at www.mfcogl.com (http://www.mfcogl.com)

aus79er
04-06-2002, 03:18 PM
Thanks for the website.
I hadn't written setpixel function.

Now it works


Thanks,
aus