Java 类com.badlogic.gdx.utils.SharedLibraryLoader 实例源码

项目:cachebox3.0    文件:AndroidLauncherfragment.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    this.setLogLevel(100);

    //initialize platform bitmap factory
    org.oscim.android.canvas.AndroidGraphics.init();

    GdxAssets.init("");
    GLAdapter.init(new AndroidGL());

    AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
    config.stencil = 8;
    config.numSamples = 2;
    new SharedLibraryLoader().load("vtm-jni");

    View view = initializeForView(new CacheboxMain(), config);

    //initialize platform connector
    PlatformConnector.init(new AndroidPlatformConnector(this));

    return view;
}
项目:PixelDungeonTC    文件:DesktopLauncher.java   
public static void main (String[] arg) {
    String version = DesktopLauncher.class.getPackage().getSpecificationVersion();
    if (version == null) {
        version = "1.0";
    }
    LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();

    if (SharedLibraryLoader.isMac) {
        config.preferencesDirectory = "Library/Application Support/Pixel Dungeon/";
    } else if (SharedLibraryLoader.isLinux) {
        config.preferencesDirectory = ".watabou/pixel-dungeon/";
    } else if (SharedLibraryLoader.isWindows) {
        config.preferencesDirectory = "Saved Games/Pixel Dungeon/";
    }
    // FIXME: This is a hack to get access to the preferences before we have an application setup
    com.badlogic.gdx.Preferences prefs = new LwjglPreferences(Preferences.FILE_NAME, config.preferencesDirectory);

    boolean isFullscreen = prefs.getBoolean(Preferences.KEY_WINDOW_FULLSCREEN, false);
    config.fullscreen = isFullscreen;
    if (!isFullscreen) {
        config.width = prefs.getInteger(Preferences.KEY_WINDOW_WIDTH, Preferences.DEFAULT_WINDOW_WIDTH);
        config.height = prefs.getInteger(Preferences.KEY_WINDOW_HEIGHT, Preferences.DEFAULT_WINDOW_HEIGHT);
    }

    config.addIcon( "ic_launcher_128.png", Files.FileType.Internal );
    config.addIcon( "ic_launcher_32.png", Files.FileType.Internal );
    config.addIcon( "ic_launcher_16.png", Files.FileType.Internal );

    // TODO: It have to be pulled from build.gradle, but I don't know how it can be done
    config.title = "Pixel Dungeon";

    new LwjglApplication(new PixelDungeon(
            new DesktopSupport(version, config.preferencesDirectory, new DesktopInputProcessor())
    ), config);
}
项目:warp    文件:PhysicsTask.java   
@Override
protected void onInit() {
    logger.info("initializing physics");
    new SharedLibraryLoader().load("gdx");
    Bullet.init();
    createPhysicsWorld();
    rayTestSolver.setWorld(mainWorld);
}
项目:cachebox3.0    文件:TouchLauncher.java   
public static void initVtm() {
    // load native library
    new SharedLibraryLoader().load("vtm-jni");
    // init globals
    AwtGraphics.init();
    GdxAssets.init("assets/");
    GLAdapter.init(new LwjglGL20());
    GLAdapter.GDX_DESKTOP_QUIRKS = true;
}
项目:gdx-texture-packer-gui    文件:KTXProcessor.java   
@Override
protected File copyToTempFile(String resourcePath) {
    File file = super.copyToTempFile(resourcePath);
    if (file == null) return null;

    if (SharedLibraryLoader.isLinux || SharedLibraryLoader.isMac) {
        try {
            // Change access permission for temp file
            System.out.println("Call \"chmod\" for a temp file");
            Process process = Runtime.getRuntime().exec("chmod +x " + file.getAbsolutePath());

            InputStream is = process.getInputStream();
            BufferedReader br = new BufferedReader(new InputStreamReader(is));
            String line = null;
            while ((line = br.readLine()) != null) {
                System.out.println(line);
            }
            int result = process.waitFor(); // Let the process finish.

            if (result != 0) {
                throw new RuntimeException("\"chmod\" call finished with error");
            }
        } catch (IOException | InterruptedException e) {
            throw new RuntimeException("Error changing file access permission for: " + file.getAbsolutePath(), e);
        }
    }
    return file;
}
项目:gdx-texture-packer-gui    文件:KtxEtc2Processor.java   
@Override
protected File copyToTempFile(String resourcePath) {
    File file = super.copyToTempFile(resourcePath);
    if (file == null) return null;

    if (SharedLibraryLoader.isLinux || SharedLibraryLoader.isMac) {
        try {
            // Change access permission for temp file
            System.out.println("Call \"chmod\" for a temp file");
            Process process = Runtime.getRuntime().exec("chmod +x " + file.getAbsolutePath());

            InputStream is = process.getInputStream();
            BufferedReader br = new BufferedReader(new InputStreamReader(is));
            String line = null;
            while ((line = br.readLine()) != null) {
                System.out.println(line);
            }
            int result = process.waitFor(); // Let the process finish.

            if (result != 0) {
                throw new RuntimeException("\"chmod\" call finished with error");
            }
        } catch (IOException | InterruptedException e) {
            throw new RuntimeException("Error changing file access permission for: " + file.getAbsolutePath(), e);
        }
    }
    return file;
}
项目:gdx-backend-jglfw    文件:JglfwNativesLoader.java   
/** Extracts the LWJGL native libraries from the classpath and sets the "org.lwjgl.librarypath" system property. */
static public synchronized void load(boolean disableOpenAL) {
    if (!load) return;

    SharedLibraryLoader loader = new SharedLibraryLoader();
    File nativesDir = null;
    try {
        if (isWindows) {
            nativesDir = loader.extractFile(is64Bit ? "lwjgl.dll" : "lwjgl32.dll", null).getParentFile();
            if (!disableOpenAL)
                loader.extractFile(is64Bit ? "OpenAL.dll" : "OpenAL32.dll", nativesDir.getName());
            loader.extractFile("libglfw.dll", nativesDir.getName());
        } else if (isMac) {
            nativesDir = loader.extractFile("liblwjgl.dylib", null).getParentFile();
            if (!disableOpenAL) loader.extractFile("libopenal.dylib", nativesDir.getName());
            loader.extractFile("libglfw.dylib", nativesDir.getName());
        } else if (isLinux) {
            nativesDir = loader.extractFile(is64Bit ? "liblwjgl.so" : "liblwjgl32.so", null).getParentFile();
            if (!disableOpenAL)
                loader.extractFile(is64Bit ? "libopenal.so" : "libopenal32.so", nativesDir.getName());
            loader.extractFile("libglfw.so", nativesDir.getName());
        }
    } catch (Throwable ex) {
        throw new RuntimeException("Unable to extract LWJGL natives.", ex);
    }
    System.setProperty("org.lwjgl.librarypath", nativesDir.getAbsolutePath());
    load = false;
}
项目:pixel-dungeon-rebirth    文件:DesktopLauncher.java   
public static void main (String[] arg) {
    String version = DesktopLauncher.class.getPackage().getSpecificationVersion();
    if (version == null) {
        version = "???";
    }
    LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();

    if (SharedLibraryLoader.isMac) {
        config.preferencesDirectory = "Library/Application Support/BravePixel/Pixel Dungeon/";
    } else if (SharedLibraryLoader.isLinux) {
        config.preferencesDirectory = ".bravepixel/pixel-dungeon/";
    } else if (SharedLibraryLoader.isWindows) {
        config.preferencesDirectory = "Saved Games/BravePixel/PixelDungeon";
    }
    // FIXME: This is a hack to get access to the preferences before we have an application setup
    com.badlogic.gdx.Preferences prefs = new LwjglPreferences(Preferences.FILE_NAME, config.preferencesDirectory);

    boolean isFullscreen = prefs.getBoolean(Preferences.KEY_WINDOW_FULLSCREEN, false);
    config.fullscreen = isFullscreen;
    if (!isFullscreen) {
        config.width = prefs.getInteger(Preferences.KEY_WINDOW_WIDTH, Preferences.DEFAULT_WINDOW_WIDTH);
        config.height = prefs.getInteger(Preferences.KEY_WINDOW_HEIGHT, Preferences.DEFAULT_WINDOW_HEIGHT);
    }

    config.addIcon( "ic_launcher_128.png", Files.FileType.Internal );
    config.addIcon( "ic_launcher_32.png", Files.FileType.Internal );
    config.addIcon( "ic_launcher_16.png", Files.FileType.Internal );


    // TODO: It have to be pulled from build.gradle, but I don't know how it can be done
    config.title = "Pixel Dungeon";

    new LwjglApplication(new PixelDungeon(
            new DesktopSupport(version, config.preferencesDirectory, new DesktopInputProcessor())
    ), config);
}
项目:libgdxcn    文件:LwjglNativesLoader.java   
/** Extracts the LWJGL native libraries from the classpath and sets the "org.lwjgl.librarypath" system property. */
static public void load () {
    GdxNativesLoader.load();
    if (GdxNativesLoader.disableNativesLoading) return;
    if (!load) return;

    SharedLibraryLoader loader = new SharedLibraryLoader();
    File nativesDir = null;
    try {
        if (isWindows) {
            nativesDir = loader.extractFile(is64Bit ? "lwjgl64.dll" : "lwjgl.dll", null).getParentFile();
            if (!LwjglApplicationConfiguration.disableAudio)
                loader.extractFile(is64Bit ? "OpenAL64.dll" : "OpenAL32.dll", nativesDir.getName());
        } else if (isMac) {
            File extractedFile = loader.extractFile("liblwjgl.jnilib", null);
            nativesDir = extractedFile.getParentFile();
            new FileHandle(extractedFile).copyTo(new FileHandle(new File(nativesDir, "liblwjgl.dylib")));
            if (!LwjglApplicationConfiguration.disableAudio) loader.extractFile("openal.dylib", nativesDir.getName());
        } else if (isLinux) {
            nativesDir = loader.extractFile(is64Bit ? "liblwjgl64.so" : "liblwjgl.so", null).getParentFile();
            if (!LwjglApplicationConfiguration.disableAudio)
                loader.extractFile(is64Bit ? "libopenal64.so" : "libopenal.so", nativesDir.getName());
        }
    } catch (Throwable ex) {
        throw new GdxRuntimeException("Unable to extract LWJGL natives.", ex);
    }
    System.setProperty("org.lwjgl.librarypath", nativesDir.getAbsolutePath());
    load = false;
}
项目:libgdxcn    文件:JglfwDebugStarter.java   
public static void main (String[] argv) {
    // this is only here for me to debug native code faster
    new SharedLibraryLoader("../../extensions/gdx-audio/libs/gdx-audio-natives.jar").load("gdx-audio");
    new SharedLibraryLoader("../../extensions/gdx-image/libs/gdx-image-natives.jar").load("gdx-image");
    new SharedLibraryLoader("../../extensions/gdx-freetype/libs/gdx-freetype-natives.jar").load("gdx-freetype");
    new SharedLibraryLoader("../../extensions/gdx-controllers/gdx-controllers-desktop/libs/gdx-controllers-desktop-natives.jar")
        .load("gdx-controllers-desktop");
    new SharedLibraryLoader("../../gdx/libs/gdx-natives.jar").load("gdx");

    GdxTest test = new SuperKoalio();
    JglfwApplicationConfiguration config = new JglfwApplicationConfiguration();
    config.vSync = true;
    new JglfwApplication(test, config);
}
项目:vtm    文件:MainActivity.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    AndroidGraphics.init();
    GdxAssets.init("");
    GLAdapter.init(new AndroidGL());
    Tile.SIZE = 400;

    AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();

    new SharedLibraryLoader().load("vtm-jni");

    initialize(new GdxMapAndroid(), cfg);
}
项目:vtm    文件:GdxMapApp.java   
public static void init() {
    // load native library
    new SharedLibraryLoader().load("vtm-jni");
    // init globals
    AwtGraphics.init();
    GdxAssets.init("assets/");
    GLAdapter.init(new GdxGL());
    GLAdapter.GDX_DESKTOP_QUIRKS = true;
}
项目:featurea    文件:MyLwjglCanvas.java   
private void initialize(ApplicationListener listener, LwjglApplicationConfiguration config) {
    LwjglNativesLoader.load();
    this.setApplicationLogger(new LwjglApplicationLogger());
    this.canvas = new Canvas() {
        private final Dimension minSize = new Dimension(1, 1);

        public final void addNotify() {
            super.addNotify();
            if (SharedLibraryLoader.isMac) {
                EventQueue.invokeLater(new Runnable() {
                    public void run() {
                        MyLwjglCanvas.this.create();
                    }
                });
            } else {
                MyLwjglCanvas.this.create();
            }

        }

        public final void removeNotify() {
            MyLwjglCanvas.this.stop();
            super.removeNotify();
        }

        public Dimension getMinimumSize() {
            return this.minSize;
        }
    };
    this.canvas.setSize(1, 1);
    this.canvas.setIgnoreRepaint(true);
    this.graphics = new LwjglGraphics(this.canvas, config) {
        public void setTitle(String title) {
            super.setTitle(title);
            MyLwjglCanvas.this.setTitle(title);
        }

        public boolean setWindowedMode(int width, int height, boolean fullscreen) {
            if (!super.setWindowedMode(width, height)) {
                return false;
            } else {
                if (!fullscreen) {
                    MyLwjglCanvas.this.setDisplayMode(width, height);
                }

                return true;
            }
        }

        public boolean setFullscreenMode(DisplayMode displayMode) {
            if (!super.setFullscreenMode(displayMode)) {
                return false;
            } else {
                MyLwjglCanvas.this.setDisplayMode(displayMode.width, displayMode.height);
                return true;
            }
        }
    };
    this.graphics.setVSync(config.vSyncEnabled);

    this.files = new LwjglFiles();
    this.input = new LwjglInput();
    this.net = new LwjglNet();
    this.listener = listener;
    Gdx.app = this;
    Gdx.graphics = this.graphics;
    Gdx.files = this.files;
    Gdx.input = this.input;
    Gdx.net = this.net;
}
项目:PixelDungeonTC    文件:DesktopLauncher.java   
@Override
public boolean isFullscreenEnabled() {
    //  return Display.getPixelScaleFactor() == 1f;
    return !SharedLibraryLoader.isMac;
}
项目:pixel-dungeon-rebirth    文件:DesktopLauncher.java   
@Override
public boolean isFullscreenEnabled() {
    //  return Display.getPixelScaleFactor() == 1f;
    return !SharedLibraryLoader.isMac;
}
项目:libgdxcn    文件:LwjglCanvas.java   
private void initialize (ApplicationListener listener, LwjglApplicationConfiguration config) {
    LwjglNativesLoader.load();

    canvas = new Canvas() {
        private final Dimension minSize = new Dimension(1, 1);

        public final void addNotify () {
            super.addNotify();
            if (SharedLibraryLoader.isMac) {
                EventQueue.invokeLater(new Runnable() {
                    public void run () {
                        create();
                    }
                });
            } else
                create();
        }

        public final void removeNotify () {
            stop();
            super.removeNotify();
        }

        public Dimension getMinimumSize () {
            return minSize;
        }
    };
    canvas.setSize(1, 1);
    canvas.setIgnoreRepaint(true);

    graphics = new LwjglGraphics(canvas, config) {
        public void setTitle (String title) {
            super.setTitle(title);
            LwjglCanvas.this.setTitle(title);
        }

        public boolean setDisplayMode (int width, int height, boolean fullscreen) {
            if (!super.setDisplayMode(width, height, fullscreen)) return false;
            if (!fullscreen) LwjglCanvas.this.setDisplayMode(width, height);
            return true;
        }

        public boolean setDisplayMode (DisplayMode displayMode) {
            if (!super.setDisplayMode(displayMode)) return false;
            LwjglCanvas.this.setDisplayMode(displayMode.width, displayMode.height);
            return true;
        }
    };
    graphics.setVSync(config.vSyncEnabled);
    if (!LwjglApplicationConfiguration.disableAudio) audio = new OpenALAudio();
    files = new LwjglFiles();
    input = new LwjglInput();
    net = new LwjglNet();
    this.listener = listener;

    Gdx.app = this;
    Gdx.graphics = graphics;
    Gdx.audio = audio;
    Gdx.files = files;
    Gdx.input = input;
    Gdx.net = net;
}
项目:libgdxcn    文件:FreeType.java   
public static Library initFreeType() {
    new SharedLibraryLoader().load("gdx-freetype");
    long address = initFreeTypeJni();
    if(address == 0) throw new GdxRuntimeException("Couldn't initialize FreeType library");
    else return new Library(address);
}
项目:libgdxcn    文件:Box2D.java   
/** Loads the Box2D native library and initializes the gdx-box2d extension. Must be called before any of the box2d
 * classes/methods can be used. Currently with the exception of the {@link World} class, which will also cause the Box2D
 * natives to be loaded. */
public static void init () {
    new SharedLibraryLoader().load("gdx-box2d");
}
项目:libgdxcn    文件:Bullet.java   
/** Loads the native Bullet native library and initializes the gdx-bullet extension.
 * Must be called before any of the bullet classes/methods can be used.
 * @param useRefCounting Whether to use reference counting, causing object to be destroyed when no longer referenced. You must 
 * use {@link BulletBase#obtain()} and {@link BulletBase#release()} when using reference counting.
 * @param logging Whether to log an error on potential errors in the application. */
public static void init (boolean useRefCounting, boolean logging) {
    Bullet.useRefCounting = useRefCounting;
    Bullet.enableLogging = logging;
    new SharedLibraryLoader().load("gdx-bullet");
}
项目:libgdxcn    文件:DesktopControllerManager.java   
public DesktopControllerManager () {
    new SharedLibraryLoader().load("gdx-controllers-desktop");
    new OisControllers(this);
}
项目:gameserver    文件:SoundTouch.java   
/**
 * Creates a new SoundTouch object. Needs to be disposed via {@link #dispose()}.
 */
public SoundTouch() {
    new SharedLibraryLoader().load("gdx-audio");
    addr = newSoundTouchJni();
}
项目:gameserver    文件:KissFFT.java   
/** Creates a new fft instance that can analyse numSamples samples. timeSize must be a power of two.
 * 
 * @param numSamples the number of samples to be analysed. */
public KissFFT (int numSamples) {
    new SharedLibraryLoader().load("gdx-audio");
    addr = create(numSamples);
}
项目:shattered-pixel-dungeon-gdx    文件:DesktopLauncher.java   
public static void main (String[] arg) {
    String version = DesktopLauncher.class.getPackage().getSpecificationVersion();
    if (version == null) {
        version = "0.6.2d";
    }

    int versionCode;
    try {
        versionCode = Integer.parseInt(DesktopLauncher.class.getPackage().getImplementationVersion());
    } catch (NumberFormatException e) {
        versionCode = 228;
    }

    LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();

    if (SharedLibraryLoader.isMac) {
        config.preferencesDirectory = "Library/Application Support/Shattered Pixel Dungeon/";
    } else if (SharedLibraryLoader.isLinux) {
        config.preferencesDirectory = ".shatteredpixel/shattered-pixel-dungeon/";
    } else if (SharedLibraryLoader.isWindows) {
        String winVer = System.getProperties().getProperty("os.name");
        if (winVer.contains("XP")) {
            config.preferencesDirectory = "Application Data/.shatteredpixel/Shattered Pixel Dungeon/";
        } else {
            config.preferencesDirectory = "AppData/Roaming/.shatteredpixel/Shattered Pixel Dungeon/";
        }
    }
    // FIXME: This is a hack to get access to the preferences before we have an application setup
    com.badlogic.gdx.Preferences prefs = new LwjglPreferences(Preferences.FILE_NAME, config.preferencesDirectory);

    boolean isFullscreen = prefs.getBoolean(Preferences.KEY_WINDOW_FULLSCREEN, false);
    //config.fullscreen = isFullscreen;
    if (!isFullscreen) {
        config.width = prefs.getInteger(Preferences.KEY_WINDOW_WIDTH, Preferences.DEFAULT_WINDOW_WIDTH);
        config.height = prefs.getInteger(Preferences.KEY_WINDOW_HEIGHT, Preferences.DEFAULT_WINDOW_HEIGHT);
    }

    config.addIcon( "ic_launcher_128.png", Files.FileType.Internal );
    config.addIcon( "ic_launcher_32.png", Files.FileType.Internal );
    config.addIcon( "ic_launcher_16.png", Files.FileType.Internal );

    // TODO: It have to be pulled from build.gradle, but I don't know how it can be done
    config.title = "Shattered Pixel Dungeon";

    new LwjglApplication(new ShatteredPixelDungeon(
            new DesktopSupport(version, versionCode, config.preferencesDirectory, new DesktopInputProcessor())
    ), config);
}
项目:shattered-pixel-dungeon-gdx    文件:DesktopLauncher.java   
@Override
public boolean isFullscreenEnabled() {
//  return Display.getPixelScaleFactor() == 1f;
    return !SharedLibraryLoader.isMac;
}
项目:mytourbook    文件:Map25App.java   
public static void init() {

        // load native library
        new SharedLibraryLoader().load("vtm-jni"); //$NON-NLS-1$

        // init canvas
        AwtGraphics.init();

        GdxAssets.init("assets/"); //$NON-NLS-1$

        GLAdapter.init(new LwjglGL20());

        GLAdapter.GDX_DESKTOP_QUIRKS = true;
    }