Share via


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 Windows SDK.

Security noteSecurity Note

This sample code is intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Microsoft provides this sample code "AS IS" with no warranties.

To get samples and instructions for installing them:

To access samples from Visual Studio

  • On the Help menu, click Samples.

    By default, these samples are installed in drive:\Program Files\Microsoft Visual Studio 10.0\Samples\.

  • For the most recent version of this sample and a list of other samples, see Visual Studio Samples on the MSDN Web site.

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.

See Also

Other Resources

MFC Samples