Language:EN
Pages: 2
Rating : ⭐⭐⭐⭐⭐
Price: $10.99
Page 1 Preview
which used select and set the pixel format

Which used select and set the pixel format

660

CHAPTER 19

Wiggle: OpenGL on Windows

When a window is created, it first receives a WM_CREATE message from the operating system. This is the ideal location to create and set up the OpenGL rendering context. A window also receives a WM_DESTROY message when it is being destroyed. Naturally, this is the ideal place to put cleanup code. Listing 19.2 shows the SetDCPixelFormat format, which is used to select and set the pixel format, along with the window procedure for the application. This function contains the same basic functionality that we have been using with the GLUT framework.

LISTING 19.2 Setting the Pixel Format and Handling the Creation and Deletion of the OpenGL Rendering Context

{

int nPixelFormat;

PFD_SUPPORT_OPENGL | // Support OpenGL calls in window

PFD_DOUBLEBUFFER, // Double-buffered mode

LISTING 19.2

Continued

Putting It All Together 661

/////////////////////////////////////////////////////////////////////// // Window procedure, handles all messages for this program
LRESULT CALLBACK WndProc(HWND hWnd,
UINT message,
WPARAM wParam,
LPARAM lParam)
{
static HGLRC hRC = NULL; // Permanent rendering context
static HDC hDC = NULL; // Private GDI device context

switch (message)
{
// Window creation, set up for OpenGL
case WM_CREATE:
// Store the device context
hDC = GetDC(hWnd);

You are viewing 1/3rd of the document.Purchase the document to get full access instantly

Immediately available after payment
Both online and downloadable
No strings attached
How It Works
Login account
Login Your Account
Place in cart
Add to Cart
send in the money
Make payment
Document download
Download File
img

Uploaded by : Holly Cooper

PageId: DOCA7FFE09