101 104














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

 




Previous
Table of Contents
Next




wglGetProcAddress

Purpose
Returns the address of an OpenGL extension function for use with the current rendering context.
Include File
<wingdi.h>
Syntax
PROC wglGetProcAddress(LPCSTR lpszProc);
Description
Extension functions are functions that either
are not yet part of the OpenGL standard or are proprietary to a specific
vendor implementation of OpenGL, usually adding some platform-specific
performance feature. Many extensions are supported by more than one
vendor. To use these functions, you must call wglGetProcAddress and
specify the name of the extension function exactly. In this way you can
also test for the presence of a particular extension. The exact address
can vary for different pixel formats, so be careful not to store the
address returned and try to use it across rendering contexts, unless you
can be certain that the pixel format of both will be the same. You can
call glString(GL_EXTENSION) to receive a space-delimited string
containing any extensions that may be present (see Chapter 5 for more
details).


Parameters

lpszProc

LPCSTR: The name of the extension function. The case and spelling must exactly match that of the desired extension function.
Returns
If the extension function does not exist, the
return value is NULL; otherwise, the return is the address of the
specified extension function.


Example
The following code segment retrieves the address of the Windows-specific extension function glAddSwapHintRectWIN. This extension allows you to accelerate buffer swapping by telling OpenGL that only certain regions of the window actually need to be copied. This feature is demonstrated in the supplementary example program SWAPHINT in the GL_EXT subdirectory.

// Find out if a particular extension is handled
char *szBuffer;
szBuffer = (char *)glString(GL_EXTENSION);

// If it is handled, get the new function's address and call it.
if(strcmp(szBuffer,"GL_WIN_swap_hint") == 0)
{
PROC pSwapHint;
pSwapHint = wglGetCurrentDC(“glAddSwapHintRectWIN");
// Call the function
pSwapHint(40.0f, 40.0f, 50.0f, 50.2f);
}
else
{
// If not supported, handle some other way
.
.
}


See Also
glGetString


wglMakeCurrent

Purpose
Makes a given OpenGL rendering context current for the calling thread and associates it with the specified device context.
Include File
<wingdi.h>
Syntax
BOOL wglMakeCurrent(HDC hdc, HGLRC hglrc);
Description
This function makes the specified rendering
context the current rendering context for the calling thread. This
rendering context is associated with the given Windows device context.
The device context need not be the same as that used in the call to
wglCreateContext, as long as the pixel format is the same for both and
they both exist on the same physical device (not, say, the screen and a
printer). Any out-standing OpenGL commands for the previous rendering
context are flushed before the new rendering context is made current.
This function can also be used to make no rendering context active, by
calling it with NULL for the hglrc parameter.


Parameters

hdc

HDC: The device context that will be used for all OpenGL drawing operations performed by the calling thread.
hglrc

HGLRC: The rendering context to make current for the calling thread.
Returns
True on success, or False if an error occurs. If an error occurs, no rendering context will remain current for the calling thread.
Example
See the example for wglCreateContext.
See Also
wglCreateContext, wglDeleteContext,
wglGetCurrentContext, wglGetCurrentDC


wglShareLists

Purpose
Allows multiple rendering contexts to share display lists.
Include File
<wingdi.h>
Syntax
BOOL wglShareLists(HGLRC hRC1, HGLRC hRC2);
Description
A display list is a list of “precompiled"
OpenGL commands and functions (see Chapter 10). Memory is allocated for
the storage of display lists within each rendering context. As display
lists are created within that rendering context, it has access to its
own display list memory. This function allows multiple rendering
contexts to share this memory. This is particularly useful when large
display lists are used by multiple rendering contexts or threads to save
memory. Any number of rendering contexts may share the same memory for
display lists. This memory will not be freed until the last rendering
context using that space is deleted. When using a shared display list
space between threads, display list creation and usage should be
synchronized.


Parameters

hRC1

HGLRC: Specifies the rendering context with which to share display list memory.
hRC2

HGLRC: Specifies the rendering context that will share the display list memory with hRC1. No display lists for hRC2 should be created until after its display list memory is shared.
Returns
True if the display list space is shared; False if they are not.
Example
See the tank/robot simulator directory (\TANK) from Chapter 10Å‚s subdirectory on the CD. This program uses multiple windows to produce various views of the same scene simultaneously. To save memory, the rendering contexts for these windows all share the same display list memory space, by using this function.
See Also
glIsList, glNewList, glCallList, glCallLists,
glListBase, glDeleteLists, glEndList, glGenLists






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:
t informatyk12[01] 02 101
odp cz 112[01] 0X 101
27 (101)

więcej podobnych podstron