Tham khảo tài liệu 'beginning opengl game programming 2004 phần 2', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 14 Chapter 2 Creating a Simple OpenGL Application Note WGL provides considerable functionality in addition to what s been listed here. However the additional features are either rather advanced and require extensions or very specialized so we won t be covering them in this volume. The Rendering Context For an operating system to be able to work with OpenGL it needs a means of connecting OpenGL to a window. If it allows multiple applications to be running at once it also needs a way to prevent multiple OpenGL applications from interfering with each other. This is done through the use of a rendering context. In Windows the Graphics Device Interface or GDI uses a device context to remember settings about drawing modes and commands. The rendering context serves the same purpose for OpenGL. Keep in mind however that a rendering context does not replace a device context on Windows. The two interact to ensure that your application behaves properly. In fact you need to set up the device context first and then create the rendering context with a matching pixel format. We ll get into the details of this shortly. You can actually create multiple rendering contexts for a single application. This is useful for applications such as 3D modelers where you have multiple windows or viewports and each needs to keep track of its settings independently. You could also use it to have one rendering context manage your primary display while another manages user interface components. The only catch is that there can be only one active rendering context per thread at any given time though you can have multiple threads each with its own context rendering to a single window at once. Let s take a look at the most important WGL functions for managing contexts. wglCreateContext Before you can use a rendering context you need to create one. You do this through HGLRC wglCreateContext HDC hDC hDC is the handle for the device context that you previously created for your Windows application. You .