077 078














Open GL Super Bible:OpenGL for Windows: OpenGL + Win32 = Wiggle















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




Chapter 4OpenGL for Windows: OpenGL + Win32 = Wiggle

What youłll learn in this chapter:


OpenGL Tasks in a Window Without the AUX Library
Functions Youłll Use



Create and use rendering contexts
wglCreateContext, wglDeleteContext, wglMakeCurrent

Request and select a pixel format
ChoosePixelFormat, SetPixelFormat

Respond to window messages
WM_PAINT, WM_CREATE, WM_DESTROY, WM_SIZE

Use double buffering in Windows
SwapBuffers



OpenGL is purely a graphics API, with user interaction and the screen/window handled by the host environment. To facilitate this partnership, each environment usually has some extensions that “glue" OpenGL to its own window management and user interface functions. This glue is code that associates OpenGL drawing commands to a particular window. It is also necessary to provide functions for setting buffer modes, color depths, and other drawing characteristics.

For Microsoft Windows, the glue code is embodied in six new wiggle functions added to OpenGL (called wiggle because they are prefixed with wgl rather than gl), and five new Win32 functions added to the Windows NT and 95 GDI. These gluing functions are explained in this chapter, where we will dispense with using the AUX library for our OpenGL framework.
In Chapter 3 we used the AUX library as a learning tool to introduce the fundamentals of OpenGL programming in C. You have learned how to draw some 2D and 3D objects and how to specify a coordinate system and viewing perspective, without having to consider Windows programming details. Now it is time to break from our “Windowless" examination of OpenGL and see how it works in the Windows environment. Unless you are content with a single window, no menus, no printing ability, no dialogs, and few of the other features of a modern user interface, you need to learn how to use OpenGL in your Win32 applications.
Starting with this chapter, we will build full-fledged Windows applications that can take advantage of all the operating systemłs features. You will see what characteristics a Windows window must have in order to support OpenGL graphics. You will learn which messages a well-behaved OpenGL window should handle, and how. The concepts of this chapter are introduced gradually, as we use C to build a model OpenGL program that will provide the initial framework for all future examples.
Thus far in this book, youłve needed no prior knowledge of 3D graphics and only a rudimentary knowledge of C programming. From this point on, however, we assume you have at least an entry-level knowledge of Windows programming. (Otherwise, wełd have wound up writing a book twice the size of this one, and wełd have had to spend more time on the details of Windows programming and less on OpenGL programming.) If you are new to Windows, or if you cut your teeth on one of the Application Frameworks and arenłt all that familiar with Windows procedures, message routing, and so forth, youłll want to check out some of the recommended reading in Appendix B, Further Reading, before going too much further in this text.
Drawing in Windows Windows
With the AUX library we had only one window, and OpenGL always knew that we wanted to draw in that window (where else would we go?). Your own Windows applications, however, will often have more than one window. In fact, dialog boxes, controls, and even menus are actually windows at a fundamental level; itłs nearly impossible to have a useful program that contains only one window. So how does OpenGL know where to draw when you execute your rendering code? Before we try to answer this question, letłs first review how we normally draw in a window without using OpenGL.




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:
077 078
077 NEWPHASE
I F 077
076 078
073 078
The Modern Dispatch 078 Cyberpunk Genre Adventure Generator
2010 01 02, str 077 080
SHSpec 078 6111C09 Effective Auditing
2010 SP Kat prawo cywilne cz Iid 078
075 078 x35zsxgjfs36haxmxvzawmvecesrmqoeiqk26eq

więcej podobnych podstron