org.lwjgl.system.windows.GDI32 Java Examples

The following examples show how to use org.lwjgl.system.windows.GDI32. 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 swapBuffers() {
    long hdc = User32.GetDC(hwnd);
    if (hdc == 0L)
    	return false;
    boolean ret = GDI32.SwapBuffers(hdc);
    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
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 #3
Source File: PlatformWin32GLCanvas.java    From lwjgl3-swt with MIT License 4 votes vote down vote up
public boolean swapBuffers(GLCanvas canvas) {
    long hDC = User32.GetDC(canvas.handle);
    boolean ret = GDI32.SwapBuffers(hDC);
    User32.ReleaseDC(canvas.handle, hDC);
    return ret;
}
 
Example #4
Source File: WGLContextCreator.java    From settlers-remake with MIT License 4 votes vote down vote up
public WGLContextCreator(GLContainer container, boolean debug) {
	super(container, debug);
	// do we have gdi and wgl support ?
	GDI32.getLibrary().getName();
}
 
Example #5
Source File: WGLContextCreator.java    From settlers-remake with MIT License 4 votes vote down vote up
@Override
protected void swapBuffers() {
	GDI32.SwapBuffers(windowDrawable);
}