Java Code Examples for org.lwjgl.opengl.WGL#wglMakeCurrent()

The following examples show how to use org.lwjgl.opengl.WGL#wglMakeCurrent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PlatformWin32GLCanvas.java    From lwjgl3-awt with MIT License 5 votes vote down vote up
public boolean makeCurrent(long context) {
    if (context == 0L)
        return WGL.wglMakeCurrent(0L, 0L);
    long hdc = User32.GetDC(hwnd);
    if (hdc == 0L)
    	return false;
    boolean ret = WGL.wglMakeCurrent(hdc, context);
    User32.ReleaseDC(hwnd, hdc);
    return ret;
}
 
Example 2
Source File: WGLContextCreator.java    From settlers-remake with MIT License 5 votes vote down vote up
@Override
public void makeCurrent(boolean draw) {
	if(draw) {
		WGL.wglMakeCurrent(windowDrawable, context);
	} else {
		WGL.wglMakeCurrent(0, 0);
	}
}
 
Example 3
Source File: WGLContextCreator.java    From settlers-remake with MIT License 5 votes vote down vote up
@Override
protected void onNewConnection() {
	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);

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

	pfd.free();


	context = WGL.wglCreateContext(windowDrawable);
	WGL.wglMakeCurrent(windowDrawable, context);
	WGLCapabilities caps = GL.createCapabilitiesWGL();
	if(caps.WGL_ARB_create_context && caps.WGL_ARB_create_context_profile) {
		WGL.wglDeleteContext(context);
		context = 0;

		int i = debug ? 0 : 3;
		while(context == 0 && ctx_attrs.length > i) {
			context = WGLARBCreateContext.wglCreateContextAttribsARB(windowDrawable, 0, ctx_attrs[i]);
		}
	} else {
		if(debug) {
			WGL.wglDeleteContext(context);
			throw new Error("WGL could not create a debug context!");
		}
	}

	if(context == 0) throw new Error("Could not create WGL context!");
	parent.wrapNewContext();
}
 
Example 4
Source File: PlatformWin32GLCanvas.java    From lwjgl3-swt with MIT License 4 votes vote down vote up
public boolean makeCurrent(GLCanvas canvas, long context) {
    long hDC = User32.GetDC(canvas.handle);
    boolean ret = WGL.wglMakeCurrent(hDC, context);
    User32.ReleaseDC(canvas.handle, hDC);
    return ret;
}