Java 类org.lwjgl.system.Platform 实例源码

项目:debug    文件:GLFW.java   
public static long glfwCreateWindow(int width, int height, ByteBuffer title, long monitor, long share) {
    if (Properties.VALIDATE.enabled) {
        RT.checkGlfwMonitor(monitor);
        RT.checkGlfwWindow(share);
        org.lwjgl.glfw.GLFW.glfwWindowHint(org.lwjgl.glfw.GLFW.GLFW_OPENGL_DEBUG_CONTEXT, org.lwjgl.glfw.GLFW.GLFW_TRUE);
        if (Platform.get() == Platform.WINDOWS || Properties.STRICT.enabled) {
            Context ctx = CONTEXTS.get(share);
            if (ctx != null && ctx.currentInThread != null && ctx.currentInThread != Thread.currentThread()) {
                RT.throwISEOrLogError("Context of share window[" + ctx.counter + "] is current in another thread [" + ctx.currentInThread + "]");
            }
        }
    }
    long window = org.lwjgl.glfw.GLFW.glfwCreateWindow(width, height, title, monitor, share);
    createWindow(window, share);
    return window;
}
项目:debug    文件:GLFW.java   
public static long glfwCreateWindow(int width, int height, CharSequence title, long monitor, long share) {
    if (Properties.VALIDATE.enabled) {
        RT.checkGlfwMonitor(monitor);
        RT.checkGlfwWindow(share);
        org.lwjgl.glfw.GLFW.glfwWindowHint(org.lwjgl.glfw.GLFW.GLFW_OPENGL_DEBUG_CONTEXT, org.lwjgl.glfw.GLFW.GLFW_TRUE);
        if (Platform.get() == Platform.WINDOWS || Properties.STRICT.enabled) {
            Context ctx = CONTEXTS.get(share);
            if (ctx != null && ctx.currentInThread != null && ctx.currentInThread != Thread.currentThread()) {
                RT.throwISEOrLogError("Context of share window[" + ctx.counter + "] is current in another thread [" + ctx.currentInThread + "]");
            }
        }
    }
    long window = org.lwjgl.glfw.GLFW.glfwCreateWindow(width, height, title, monitor, share);
    createWindow(window, share);
    return window;
}
项目:Java-GLEngine    文件:LWJGLWindow.java   
@Override
public WindowBuilder setOpenGLContextVersion(OpenGLContextVersion version) {
    if(version.type == OpenGLContext.OPENGL_ES) {
        glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
    } else if(version.type == OpenGLContext.OPENGL_COMPAT) {
        glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_COMPAT_PROFILE);
    } else if(version.type == OpenGLContext.OPENGL_CORE) {
        glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
        if(Platform.get() == Platform.MACOSX)
            glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, 1);
    }

    core = version.type == OpenGLContext.OPENGL_CORE;

    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, version.major);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, version.minor);
    return this;
}
项目:EmergencyLanding    文件:IconLoader.java   
/*************************************************************************
 * Loads an icon in ByteBuffer form.
 * 
 * @param is
 *            The location of the Image to use as an icon.
 * 
 * @return An array of ByteBuffers containing the pixel data for the icon in
 *         varying sizes.
 *************************************************************************/
public static ByteBuffer[] load(InputStream is) {
    BufferedImage image = null;
    try {
        image = ImageIO.read(is);
    } catch (IOException e) {
        e.printStackTrace();
    }
    ByteBuffer[] buffers = null;
    Platform plat = Platform.get();
    System.err.println("Assuming platform " + LUtils.PLATFORM_NAME);
    if (plat == Platform.WINDOWS) {
        buffers = new ByteBuffer[2];
        buffers[0] = loadInstance(image, 16);
        buffers[1] = loadInstance(image, 32);
    } else if (plat == Platform.MACOSX) {
        buffers = new ByteBuffer[1];
        buffers[0] = loadInstance(image, 128);
    } else {
        buffers = new ByteBuffer[1];
        buffers[0] = loadInstance(image, 32);
    }
    return buffers;
}
项目:EmergencyLanding    文件:BufferedTexture.java   
public static BufferedTexture generateTexture(String parentDir, String name) {
    if (parentDir == null) {
        parentDir =
                System.getProperty("user.home", (Platform.get() == Platform.WINDOWS ? "C:" : "") + File.separator);
    }
    if (name == null) {
        throw new IllegalStateException("name cannot be null");
    }
    try {
        return LUtils
                .processPathData(parentDir
                        + ((parentDir.matches(ENDS_WITH_DOUBLE_WINDOWS_SEPEARATOR)
                                || name.matches(STARTS_WITH_DOUBLE_WINDOWS_SEPERATOR)) ? "" : File.separator)
                        + name, BufferedTexture::fromInputStream);
    } catch (IOException e) {
        throw new RuntimeException("Error retriving stream", e);
    }
}
项目:lwjgl3-awt    文件:SimpleDemo.java   
/**
 * Create a Vulkan instance using LWJGL 3.
 * 
 * @return the VkInstance handle
 */
private static VkInstance createInstance() {
    VkApplicationInfo appInfo = VkApplicationInfo.calloc()
            .sType(VK_STRUCTURE_TYPE_APPLICATION_INFO)
            .pApplicationName(memUTF8("AWT Vulkan Demo"))
            .pEngineName(memUTF8(""))
            .apiVersion(VK_MAKE_VERSION(1, 0, 2));
    ByteBuffer VK_KHR_SURFACE_EXTENSION = memUTF8(VK_KHR_SURFACE_EXTENSION_NAME);
    ByteBuffer VK_KHR_OS_SURFACE_EXTENSION;
    if (Platform.get() == Platform.WINDOWS)
        VK_KHR_OS_SURFACE_EXTENSION = memUTF8(VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
    else
        VK_KHR_OS_SURFACE_EXTENSION = memUTF8(VK_KHR_XLIB_SURFACE_EXTENSION_NAME);
    PointerBuffer ppEnabledExtensionNames = memAllocPointer(2);
    ppEnabledExtensionNames.put(VK_KHR_SURFACE_EXTENSION);
    ppEnabledExtensionNames.put(VK_KHR_OS_SURFACE_EXTENSION);
    ppEnabledExtensionNames.flip();
    VkInstanceCreateInfo pCreateInfo = VkInstanceCreateInfo.calloc()
            .sType(VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO)
            .pNext(0L)
            .pApplicationInfo(appInfo);
    if (ppEnabledExtensionNames.remaining() > 0) {
        pCreateInfo.ppEnabledExtensionNames(ppEnabledExtensionNames);
    }
    PointerBuffer pInstance = MemoryUtil.memAllocPointer(1);
    int err = vkCreateInstance(pCreateInfo, null, pInstance);
    if (err != VK_SUCCESS) {
        throw new RuntimeException("Failed to create VkInstance: " + translateVulkanResult(err));
    }
    long instance = pInstance.get(0);
    memFree(pInstance);
    VkInstance ret = new VkInstance(instance, pCreateInfo);
    memFree(ppEnabledExtensionNames);
    memFree(VK_KHR_OS_SURFACE_EXTENSION);
    memFree(VK_KHR_SURFACE_EXTENSION);
    appInfo.free();
    return ret;
}
项目:Null-Engine    文件:NullEngine.java   
private static void initNatives() throws InitializationException {
    Platform platform = Platform.get();
    String path = NATIVE_DIR + "/";
    if (platform == Platform.WINDOWS)
        path += "windows";
    else if (platform == Platform.MACOSX)
        path += "macos";
    else if (platform == Platform.LINUX)
        path += "linux";
    else
        throw new InitializationException("Unsupported platform");
    System.setProperty("org.lwjgl.librarypath", new File(path).getAbsolutePath());
}
项目:lwjgl3-swt    文件:SimpleDemo.java   
/**
 * Create a Vulkan instance using LWJGL 3.
 * 
 * @return the VkInstance handle
 */
private static VkInstance createInstance() {
    VkApplicationInfo appInfo = VkApplicationInfo.calloc()
            .sType(VK_STRUCTURE_TYPE_APPLICATION_INFO)
            .pApplicationName(memUTF8("SWT Vulkan Demo"))
            .pEngineName(memUTF8(""))
            .apiVersion(VK_MAKE_VERSION(1, 0, 2));
    ByteBuffer VK_KHR_SURFACE_EXTENSION = memUTF8(VK_KHR_SURFACE_EXTENSION_NAME);
    ByteBuffer VK_KHR_OS_SURFACE_EXTENSION;
    if (Platform.get() == Platform.WINDOWS)
        VK_KHR_OS_SURFACE_EXTENSION = memUTF8(VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
    else
        VK_KHR_OS_SURFACE_EXTENSION = memUTF8(VK_KHR_XLIB_SURFACE_EXTENSION_NAME);
    PointerBuffer ppEnabledExtensionNames = memAllocPointer(2);
    ppEnabledExtensionNames.put(VK_KHR_SURFACE_EXTENSION);
    ppEnabledExtensionNames.put(VK_KHR_OS_SURFACE_EXTENSION);
    ppEnabledExtensionNames.flip();
    VkInstanceCreateInfo pCreateInfo = VkInstanceCreateInfo.calloc()
            .sType(VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO)
            .pNext(0L)
            .pApplicationInfo(appInfo);
    if (ppEnabledExtensionNames.remaining() > 0) {
        pCreateInfo.ppEnabledExtensionNames(ppEnabledExtensionNames);
    }
    PointerBuffer pInstance = MemoryUtil.memAllocPointer(1);
    int err = vkCreateInstance(pCreateInfo, null, pInstance);
    if (err != VK_SUCCESS) {
        throw new RuntimeException("Failed to create VkInstance: " + translateVulkanResult(err));
    }
    long instance = pInstance.get(0);
    memFree(pInstance);
    VkInstance ret = new VkInstance(instance, pCreateInfo);
    memFree(ppEnabledExtensionNames);
    memFree(VK_KHR_OS_SURFACE_EXTENSION);
    memFree(VK_KHR_SURFACE_EXTENSION);
    appInfo.free();
    return ret;
}
项目:lwjgl3-swt    文件:ClearScreenDemo.java   
/**
 * Create a Vulkan {@link VkInstance} using LWJGL 3.
 * <p>
 * The {@link VkInstance} represents a handle to the Vulkan API and we need that instance for about everything we do.
 * 
 * @return the VkInstance handle
 */
private static VkInstance createInstance() {
    VkApplicationInfo appInfo = VkApplicationInfo.calloc()
            .sType(VK_STRUCTURE_TYPE_APPLICATION_INFO)
            .pApplicationName(memUTF8("SWT Vulkan Demo"))
            .pEngineName(memUTF8(""))
            .apiVersion(VK_MAKE_VERSION(1, 0, 2));
    ByteBuffer VK_KHR_SURFACE_EXTENSION = memUTF8(VK_KHR_SURFACE_EXTENSION_NAME);
    ByteBuffer VK_EXT_DEBUG_REPORT_EXTENSION = memUTF8(VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
    ByteBuffer VK_KHR_OS_SURFACE_EXTENSION;
    if (Platform.get() == Platform.WINDOWS)
        VK_KHR_OS_SURFACE_EXTENSION = memUTF8(VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
    else
        VK_KHR_OS_SURFACE_EXTENSION = memUTF8(VK_KHR_XLIB_SURFACE_EXTENSION_NAME);
    PointerBuffer ppEnabledExtensionNames = memAllocPointer(3)
      .put(VK_KHR_SURFACE_EXTENSION)
      .put(VK_KHR_OS_SURFACE_EXTENSION)
      .put(VK_EXT_DEBUG_REPORT_EXTENSION)
      .flip();
    PointerBuffer ppEnabledLayerNames = memAllocPointer(layers.length);
    for (int i = 0; validation && i < layers.length; i++)
        ppEnabledLayerNames.put(layers[i]);
    ppEnabledLayerNames.flip();
    VkInstanceCreateInfo pCreateInfo = VkInstanceCreateInfo.calloc()
            .sType(VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO)
            .pNext(NULL)
            .pApplicationInfo(appInfo)
            .ppEnabledExtensionNames(ppEnabledExtensionNames)
            .ppEnabledLayerNames(ppEnabledLayerNames);
    PointerBuffer pInstance = memAllocPointer(1);
    int err = vkCreateInstance(pCreateInfo, null, pInstance);
    long instance = pInstance.get(0);
    memFree(pInstance);
    if (err != VK_SUCCESS) {
        throw new AssertionError("Failed to create VkInstance: " + translateVulkanResult(err));
    }
    VkInstance ret = new VkInstance(instance, pCreateInfo);
    pCreateInfo.free();
    memFree(ppEnabledLayerNames);
    memFree(ppEnabledExtensionNames);
    memFree(VK_KHR_OS_SURFACE_EXTENSION);
    memFree(VK_EXT_DEBUG_REPORT_EXTENSION);
    memFree(VK_KHR_SURFACE_EXTENSION);
    appInfo.free();
    return ret;
}
项目:lwjgl3-swt    文件:VKCanvas.java   
/**
 * Create a {@link VKCanvas} widget using the attributes described in the supplied {@link VKData} object.
 *
 * @param parent
 *            a parent composite widget
 * @param style
 *            the bitwise OR'ing of widget styles
 * @param data
 *            the necessary data to create a VKCanvas
 */
public VKCanvas(Composite parent, int style, VKData data) {
    super(parent, platformCanvas.checkStyle(parent, style));
    if (Platform.get() == Platform.WINDOWS) {
        platformCanvas.resetStyle(parent);
    }
    if (data == null)
        SWT.error(SWT.ERROR_NULL_ARGUMENT);
    surface = platformCanvas.create(this, data);
}
项目:lwjgl3-swt    文件:GLCanvas.java   
/**
 * Create a GLCanvas widget using the attributes described in the GLData
 * object provided.
 *
 * @param parent a composite widget
 * @param style the bitwise OR'ing of widget styles
 * @param data the requested attributes of the GLCanvas
 *
 * @exception IllegalArgumentException
 * <ul>
 * <li>ERROR_NULL_ARGUMENT when the data is null
 * <li>ERROR_UNSUPPORTED_DEPTH when the requested attributes cannot be provided
 * </ul>
 */
public GLCanvas(Composite parent, int style, GLData data) {
    super(parent, platformCanvas.checkStyle(parent, style));
    if (Platform.get() == Platform.WINDOWS) {
        platformCanvas.resetStyle(parent);
    }
    if (data == null)
        SWT.error(SWT.ERROR_NULL_ARGUMENT);
    effective = new GLData();
    context = platformCanvas.create(this, data, effective);
}