21IMPLEMENT_DYNCREATE(CGlProcView,
CExView)
24CGlProcView::CGlProcView()
34CGlProcView::~CGlProcView()
41void CGlProcView::ExecRender()
43 if (!WGLGetCurrent(this->m_pDC, this->m_hRC))
return;
47 ::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
54 ::glEnable(GL_NORMALIZE);
55 ::glEnable(GL_AUTO_NORMAL);
58 if (dispFunc!=NULL) (*dispFunc)();
61 ::glDisable(GL_AUTO_NORMAL);
62 ::glDisable(GL_NORMALIZE);
67 SwapBuffers(m_pDC->GetSafeHdc());
68 if (postFunc!=NULL) (*postFunc)();
79void CGlProcView::OnInitialUpdate()
84 if (xsize<=0) xsize = 400;
85 if (ysize<=0) ysize = 400;
90 sizeXYRate = (float)ysize/(
float)xsize;
93 InitDevice(xsize, ysize);
96 WGLGetCurrent(this->m_pDC, this->m_hRC);
108BEGIN_MESSAGE_MAP(CGlProcView, CGlBaseView)
115void CGlProcView::OnSize(UINT nType,
int cx,
int cy)
117 if (!WGLGetCurrent(this->m_pDC, this->m_hRC))
return;
119 CGlBaseView::OnSize(nType, cx, cy);
122 if(0>=cx || 0>=cy)
return;
124 ::glViewport(0, 0, cx, cy);
125 ::glMatrixMode(GL_PROJECTION);
127 ::gluPerspective(40.0f, (GLfloat)cx/(GLfloat)cy, 0.1f, 20.0f);
128 ::glMatrixMode(GL_MODELVIEW);
132 ::glTranslatef( 0.0f, 0.0f, -5.0f );
133 ::glRotatef( 0.0f, 0.0f, 0.0f, 0.0f );
137int CGlProcView::OnCreate(LPCREATESTRUCT lpCreateStruct)
141 if (CGlBaseView::OnCreate(lpCreateStruct)==-1)
return -1;
147void CGlProcView::OnDestroy()
149 CGlBaseView::OnDestroy();
156void CGlProcView::AssertValid()
const
158 CGlBaseView::AssertValid();
163void CGlProcView::Dump(CDumpContext& dc)
const
165 CGlBaseView::Dump(dc);