Game Development Reference
In-Depth Information
int CWGLExampleDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
int nPixelFormat;
m_hDC = ::GetDC(m_hWnd);
static PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW |
PFD_SUPPORT_OPENGL |
PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA,
24, //Colour bits
0,0,0,0,0,0,0,0,0,0,0,0,0,
16, //Depth Buffer bits
0,0,0,0,0,0,0};
nPixelFormat = ChoosePixelFormat(m_hDC, &pfd);
VERIFY(SetPixelFormat(m_hDC, nPixelFormat, &pfd));
m_hRC = wglCreateContext(m_hDC);
VERIFY(wglMakeCurrent(m_hDC,m_hRC));
// Hidden surface removal
glEnable(GL_DEPTH_TEST);
// counter-clock-wise polygons face out
glFrontFace(GL_CCW);
// Do not calculate backfacing polygons
glEnable(GL_CULL_FACE);
// Turquoise background
glClearColor(0.0f, 0.2f, 0.3f, 0.0f );
return 0;
}
We must remember to tidy up when the window is destroyed, so we
override the OnDestroy event:
void CSomeGLView::OnDestroy()
{
if(wglGetCurrentContext()!=NULL){
// make the rendering context not current
wglMakeCurrent(NULL, NULL) ;
Search Nedrilad ::




Custom Search