645 646














Open GL Super Bible:MFC-Based OpenGL Programming















To access the contents, click the chapter and section titles.


Open GL Super Bible


(Publisher: Macmillan Computer Publishing)

Author(s): Waite group Press

ISBN: 1571690735

Publication Date: 08/01/96



function isIE4()
{
return( navigator.appName.indexOf("Microsoft") != -1 && (navigator.appVersion.charAt(0)==
'4')
); }
function
bookMarkit() {varurl="http://www.itknowledge.com/PSUser/EWBookMarks.html?url="+window.location+"&isbn=0";
parent.location.href=url;
//var win = window.open(url,"myitk");
//if(!isIE4())
// win.focus();

}

 




Previous
Table of Contents
Next




So use the Class Wizard once again to add the two palette message handlers to the CMainFrame class. These handlers simply find the active view and post the palette messages to it unchanged, allowing the view to respond as needed. These message handlers are listed in Listing 21-4.

Listing 21-4 CMainFrame code to route palette-handling messages to the view

// Route message to CView-derived class
void CMainFrame::OnPaletteChanged(CWnd* pFocusWnd)
{
CView* pView = GetActiveView();
if (pView)
{
// OnPaletteChanged is not public, so send a message.
pView->SendMessage(WM_PALETTECHANGED,
(WPARAM)(pFocusWnd->GetSafeHwnd()),
(LPARAM)0);
}
}

// Route message to CView-derived class.
BOOL CMainFrame::OnQueryNewPalette()
{
CView* pView = GetActiveView();
if (pView)
{
// OnQueryNewPalette is not public, so send a message.
return pView->SendMessage(WM_QUERYNEWPALETTE,
(WPARAM)0,
(LPARAM)0);
}

return FALSE;
}

We also added a WM_TIMER handler and created a timer in our view class to create an animated OpenGL scene (Figure 21-4). The timer function simply invalidates the window, forcing a repaint. In our glcode.c module the rendering function increments a rotation angle each time the screen is redrawn, thus creating the animation effect. All of this code is in the \MFCGL directory on the CD.


Figure 21-4  Final animated output of our MFC sample
Summary
This chapter covered the specific mechanics of using OpenGL from an MFC-based program, demonstrating where to set the Windows styles required for OpenGL, where and when to set the pixel format, and creation of the rendering context. The example program also illustrates when and where to make the rendering context current, and how to realize an MFC CPalette when needed.

You should be able to take the sample application from this chapter and easily add your own custom OpenGL code. In addition, the frameworkwith all the OpenGL code in the glcode.c modulemakes it easy to port existing C/OpenGL samples to our MFC shell program. You can study additional examples in many of the sample programs in this book, which are implemented in C, and in C++ using MFC and OWL (see Chapter 22).



Previous
Table of Contents
Next














 


Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.












Wyszukiwarka

Podobne podstrony:
645 Informacja dodatkowa wprowadzenie do sprawozdania finasowego
2002 08 Szkoła konstruktorówid!646
Nuestro Círculo 645 UN SALVAJE
Nokia? 00 RM 645 SM L1L2 v1 0
645 (2)
645 648
646,23,artykul
646 Informacja dodatkowa dodatkowe objaśnienia i nformacje
index (645)
645,41,artykul

więcej podobnych podstron