/** * Constructs a new Cursor, with the given parameters. Mouse must have been created before you can create * Cursor objects. Cursor images are in ARGB format, but only one bit transparancy is guaranteed to be supported. * So to maximize portability, lwjgl applications should only create cursor images with 0x00 or 0xff as alpha values. * The constructor will copy the images and delays, so there's no need to keep them around. * * @param width cursor image width * @param height cursor image height * @param xHotspot the x coordinate of the cursor hotspot * @param yHotspot the y coordinate of the cursor hotspot * @param numImages number of cursor images specified. Must be 1 if animations are not supported. * @param images A buffer containing the images. The origin is at the lower left corner, like OpenGL. * @param delays An int buffer of animation frame delays, if numImages is greater than 1, else null * @throws LWJGLException if the cursor could not be created for any reason */ public Cursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException { synchronized (OpenGLPackageAccess.global_lock) { if ((getCapabilities() & CURSOR_ONE_BIT_TRANSPARENCY) == 0) throw new LWJGLException("Native cursors not supported"); BufferChecks.checkBufferSize(images, width*height*numImages); if (delays != null) BufferChecks.checkBufferSize(delays, numImages); if (!Mouse.isCreated()) throw new IllegalStateException("Mouse must be created before creating cursor objects"); if (width*height*numImages > images.remaining()) throw new IllegalArgumentException("width*height*numImages > images.remaining()"); if (xHotspot >= width || xHotspot < 0) throw new IllegalArgumentException("xHotspot > width || xHotspot < 0"); if (yHotspot >= height || yHotspot < 0) throw new IllegalArgumentException("yHotspot > height || yHotspot < 0"); Sys.initialize(); // Hmm yHotspot = height - 1 - yHotspot; // create cursor (or cursors if multiple images supplied) cursors = createCursors(width, height, xHotspot, yHotspot, numImages, images, delays); } }
/** * Returns the available EGLConfigs on the speficied display. The number of available EGLConfigs * is returned in the num_config parameter. The configs array may be null. If it is null, a new * array will be allocated, with size equal to the result of {@link #eglGetConfigsNum(EGLDisplay)} eglGetConfigsNum}. * If it is not null, no more than {@code configs.length} EGLConfigs will be returned. If the array is bigger * than the number of available EGLConfigs, the remaining array elements will not be affected. * * @param dpy the EGLDisplay * @param configs the EGLConfigs array * @param num_config the number of available EGLConfigs returned * * @return the available EGLConfigs * * @throws org.lwjgl.LWJGLException if an EGL error occurs */ static EGLConfig[] eglGetConfigs(EGLDisplay dpy, EGLConfig[] configs, IntBuffer num_config) throws LWJGLException { //LWJGLUtil.log("eglGetConfigs"); BufferChecks.checkBuffer(num_config, 1); if ( configs == null ) { if ( !neglGetConfigs(dpy.getPointer(), 0L, 0, MemoryUtil.getAddress(num_config)) ) throwEGLError("Failed to get number of available EGL configs."); configs = new EGLConfig[num_config.get(num_config.position())]; } final PointerBuffer configs_buffer = APIUtil.getBufferPointer(configs.length); if ( !neglGetConfigs(dpy.getPointer(), MemoryUtil.getAddress0(configs_buffer), configs.length, MemoryUtil.getAddress(num_config)) ) throwEGLError("Failed to get EGL configs."); final int config_size = num_config.get(num_config.position()); for ( int i = 0; i < config_size; i++ ) configs[i] = new EGLConfig(dpy, configs_buffer.get(i)); return configs; }
/** * Queries an attribute associated with the current context. This method is the cross-platform * equivalent of glXQueryContext and wglQueryCurrentContextNV. * * @param attrib the attribute to query * @param value the buffer to store the value in */ public static boolean glQueryContextNV(int attrib, IntBuffer value) { checkExtension(); BufferChecks.checkBuffer(value, 1); ContextGL ctx = ContextGL.getCurrentContext(); return nglQueryContextNV(ctx.getPeerInfo().getHandle(), ctx.getHandle(), attrib, value, value.position()); }
/** * Returns the available EGLConfigs on the speficied display that satisfy the specified list of attributes. * The number of available EGLConfigs is returned in the num_config parameter. The configs array may be null. * If it is null, a new array will be allocated, with size equal to the result of {@link #eglGetConfigsNum(EGLDisplay)} eglGetConfigsNum}. * If it is not null, no more than {@code configs.length} EGLConfigs will be returned. If the array is bigger * than the number of available EGLConfigs, the remaining array elements will not be affected. * * @param dpy the EGLDisplay * @param attrib_list the attribute list (may be null) * @param configs the EGLConfigs array * @param num_config the number of available EGLConfigs returned * * @return the available EGLConfigs that satisfy the attribute list * * @throws org.lwjgl.LWJGLException if an EGL error occurs */ static EGLConfig[] eglChooseConfig(EGLDisplay dpy, IntBuffer attrib_list, EGLConfig[] configs, IntBuffer num_config) throws LWJGLException { //LWJGLUtil.log("eglChooseConfig"); checkAttribList(attrib_list); BufferChecks.checkBuffer(num_config, 1); int config_size; if ( configs == null ) { if ( !neglChooseConfig(dpy.getPointer(), MemoryUtil.getAddressSafe(attrib_list), 0L, 0, MemoryUtil.getAddress(num_config)) ) throwEGLError("Failed to get number of available EGL configs."); config_size = num_config.get(num_config.position()); } else config_size = configs.length; //LWJGLUtil.log("config_size = " + config_size); PointerBuffer configs_buffer = APIUtil.getBufferPointer(config_size); if ( !neglChooseConfig(dpy.getPointer(), MemoryUtil.getAddressSafe(attrib_list), MemoryUtil.getAddress0(configs_buffer), config_size, MemoryUtil.getAddress(num_config)) ) throwEGLError("Failed to choose EGL config."); // Get the true number of configurations (the first neglChooseConfig call may return more than the second) config_size = num_config.get(num_config.position()); if ( configs == null ) configs = new EGLConfig[config_size]; for ( int i = 0; i < config_size; i++ ) configs[i] = new EGLConfig(dpy, configs_buffer.get(i)); return configs; }
/** * Enumerate the available video output devices. This method is the cross-platform * equivalent of glXEnumerateVideoDevicesNV and wglEnumerateVideoDevicesNV. Since they are * not really compatible, this method works like the WGL version. That is, you first * call it with a null devices buffer, get the number of devices, then call it again * with an appropriately sized buffer. * * @param devices the buffer to store devices in * * @return the number of available video output devices */ public static int glEnumerateVideoDevicesNV(LongBuffer devices) { checkExtension(); if ( devices != null ) BufferChecks.checkBuffer(devices, 1); return nglEnumerateVideoDevicesNV(getPeerInfo(), devices, devices == null ? 0 : devices.position()); }
/** * Binds the video output device specified to one of the context's available video output slots. * This method is the cross-platform equivalent of glXBindVideoDeviceNV and wglBindVideoDeviceNV. * To release a video device without binding another device to the same slot, call it with * video_device set to 0 (will use INVALID_HANDLE_VALUE on WGL). * * @param video_slot the video slot * @param video_device the video device * @param attrib_list the attributes to use * * @return true if the binding was successful */ public static boolean glBindVideoDeviceNV(int video_slot, long video_device, IntBuffer attrib_list) { checkExtension(); if ( attrib_list != null ) BufferChecks.checkNullTerminated(attrib_list); return nglBindVideoDeviceNV(getPeerInfo(), video_slot, video_device, attrib_list, attrib_list == null ? 0 : attrib_list.position()); }
/** * Enumerate the available video capture devices. This method is the cross-platform * equivalent of glXEnumerateVideoCaptureDevicesNV and wglEnumerateVideoCaptureDevicesNV. * Since they are not really compatible, this method works like the WGL version. That is, * you first call it with a null devices buffer, get the number of devices, then call it * again with an appropriately sized buffer. * * @param devices the buffer to store devices in * * @return the number of available video capture devices */ public static int glEnumerateVideoCaptureDevicesNV(LongBuffer devices) { checkExtension(); if ( devices != null ) BufferChecks.checkBuffer(devices, 1); return nglEnumerateVideoCaptureDevicesNV(getPeerInfo(), devices, devices == null ? 0 : devices.position()); }
/** * Use this method to query the unique ID of the physical device backing a * video capture device handle. * * @param device the device * @param attribute the attribute to query * @param value the buffer to store the value in * * @return true if the query was successful */ public static boolean glQueryVideoCaptureDeviceNV(long device, int attribute, IntBuffer value) { checkExtension(); BufferChecks.checkBuffer(value, 1); return nglQueryVideoCaptureDeviceNV(getPeerInfo(), device, attribute, value, value.position()); }
/** * Initializes the specified EGL display. * * @param dpy the EGL display to initialize * @param version the EGL major and minor version will be returned in this buffer. * * @throws org.lwjgl.LWJGLException if an EGL error occurs */ static void eglInitialize(EGLDisplay dpy, IntBuffer version) throws LWJGLException { //LWJGLUtil.log("eglInitialize"); BufferChecks.checkBuffer(version, 2); if ( !neglInitialize(dpy.getPointer(), MemoryUtil.getAddress(version)) ) throwEGLError("Failed to initialize EGL display."); }
/** * Returns the value of the specified EGL surface attribute in the value parameter. * * @param dpy the EGL display * @param surface the EGL surface * @param attribute the surface attribute * @param value the attribute value will be returned here * * @throws org.lwjgl.LWJGLException if an EGL error occurs */ public static void eglQuerySurface(EGLDisplay dpy, EGLSurface surface, int attribute, IntBuffer value) throws LWJGLException { //LWJGLUtil.log("eglQuerySurface"); BufferChecks.checkBuffer(value, 1); if ( !neglQuerySurface(dpy.getPointer(), surface.getPointer(), attribute, MemoryUtil.getAddress(value)) ) throwEGLError("Failed to query surface attribute."); }
/** * Returns the value of the specified EGL context attribute in the value parameter. * * @param dpy the EGL display * @param ctx the EGL context * @param attribute the context attribute * @param value the attribute value will be returned here * * @throws org.lwjgl.LWJGLException if an EGL error occurs */ public static void eglQueryContext(EGLDisplay dpy, EGLContext ctx, int attribute, IntBuffer value) throws LWJGLException { //LWJGLUtil.log("eglQueryContext"); BufferChecks.checkBuffer(value, 1); if ( !neglQueryContext(dpy.getPointer(), ctx.getPointer(), attribute, MemoryUtil.getAddress(value)) ) throwEGLError("Failed to query context attribute."); }