Example usage for org.lwjgl.opengl WGL wglCreateContext

List of usage examples for org.lwjgl.opengl WGL wglCreateContext

Introduction

In this page you can find the example usage for org.lwjgl.opengl WGL wglCreateContext.

Prototype

@NativeType("HGLRC")
public static long wglCreateContext(@NativeType("HDC") long hdc) 

Source Link

Document

Creates a new OpenGL rendering context, which is suitable for drawing on the device referenced by device.

Usage

From source file:go.graphics.swing.contextcreator.WGLContextCreator.java

License:Open Source License

@Override
protected void initContext() {
    hwnd = win32surfaceinfo.hwnd();/*from   w ww.  ja  va  2 s  .c  o  m*/
    hdc = win32surfaceinfo.hdc();

    PIXELFORMATDESCRIPTOR pfd = PIXELFORMATDESCRIPTOR.calloc();
    pfd.dwFlags(GDI32.PFD_DRAW_TO_WINDOW | GDI32.PFD_SUPPORT_OPENGL | GDI32.PFD_DOUBLEBUFFER);
    pfd.iPixelType(GDI32.PFD_TYPE_RGBA);
    pfd.cColorBits((byte) 32);
    pfd.cStencilBits((byte) 1);

    pfd.cDepthBits((byte) 24);

    pixel_format = GDI32.ChoosePixelFormat(hdc, pfd);
    if (pixel_format == 0)
        throw new Error("Could not find pixel format!");
    GDI32.SetPixelFormat(hdc, pixel_format, pfd);

    pfd.free();

    context = WGL.wglCreateContext(hdc);
    if (context == 0)
        throw new Error("Could not create WGL context!");
}