# CUBE Sample: Demonstrates an OpenGL Application

The CUBE sample is a simple OpenGL application. It demonstrates how to integrate OpenGL with the MFC single document interface (SDI), and how OpenGL's resource contexts are used in conjunction with device contexts.

For a more detailed explanation of OpenGL, refer to the Platform SDK.

Security Note
This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices.

# Building and Running the Sample

#### To build and run the CUBE sample

1. Open the solution cube.sln.

2. On the Build menu, click Build.

3. On the Debug menu, click Start Without Debugging.

When you start the sample, a three-dimensional colorful cube is drawn. To animate the cube, either click Play on the Edit menu or click the Play toolbar button.

# Keywords

This sample demonstrates the following keywords:

CCmdUI::SetCheck; CDC::GetSafeHdc; CDC::RealizePalette; CDC::SelectPalette; CDialog::DoModal; CDocument::OnNewDocument; CFrameWnd::Create; CFrameWnd::DockControlBar; CFrameWnd::EnableDocking; CFrameWnd::GetActiveView; CObject::AssertValid; CObject::Dump; CObject::Serialize; CPalette::CreatePalette; CView::GetDocument; CView::OnDraw; CWinApp::AddDocTemplate; CWinApp::InitInstance; CWinApp::LoadStdProfileSettings; CWinApp::OnFileNew; CWnd::DoDataExchange; CWnd::GetClientRect; CWnd::InvalidateRect; CWnd::KillTimer; CWnd::MessageBox; CWnd::OnCreate; CWnd::OnDestroy; CWnd::OnEraseBkgnd; CWnd::OnPaletteChanged; CWnd::OnQueryNewPalette; CWnd::OnSize; CWnd::OnTimer; CWnd::PreCreateWindow; CWnd::RedrawWindow; CWnd::SetTimer; ChoosePixelFormat; DescribePixelFormat; GetPixelFormat; LoadBitmap; PIXELFORMATDESCRIPTOR; PeekMessage; SetPixelFormat; SwapBuffers; glBegin; glClear; glClearColor; glClearDepth; glEnd; glFinish; glLoadIdentity; glMatrixMode; glPopMatrix; glPushMatrix; glRotatef; glTranslatef; glViewport; gluPerspective; wglCreateContext; wglDeleteContext; wglGetCurrentContext; wglGetCurrentDC; wglMakeCurrent

Note
Some samples, such as this one, have not been modified to reflect the changes in the Visual C++ wizards, libraries, and compiler, but still demonstrate how to complete your desired task.