Java 类com.badlogic.gdx.Application.ApplicationType 实例源码

项目:cocos2d-java    文件:Engine.java   
/**创建一个Card2DEngine实例 */
public static final Engine newEngine(BaseGame card2dAppListener) {
    if(_instance == null){
        if(_engineMode == null) {
            if(Gdx.app.getType() == ApplicationType.Desktop) {
                _engineMode = EngineMode.SingleThread;      //桌面版本经过测试,backend已经实现了渲染线程分离,因此默认使用single模式
            } else {
                _engineMode = EngineMode.DoubleThread;      
            }
        }

        CCLog.engine("Engine", ">>>>>>>>>>>>>>>>>> engine run mode : " + _engineMode);

        _instance = new Engine();
        _instance.game = card2dAppListener;
        _instance.director = Director.getInstance();
        _instance.baseScheduler = BaseScheduler.instance();
    }
    return _instance;
}
项目:Cubes_2    文件:Compatibility.java   
public void startCubes() {
  compatibility = this;

  Thread.setDefaultUncaughtExceptionHandler(UncaughtExceptionHandler.instance);
  Thread.currentThread().setUncaughtExceptionHandler(UncaughtExceptionHandler.instance);

  try {
    if (applicationType == ApplicationType.HeadlessDesktop) {
      run(new ServerAdapter());
    } else {
      run(new ClientAdapter());
    }
  } catch (Exception e) {
    try {
      Log.error("Failed to start", CubesException.get(e));
    } catch (Exception ex) {
      if (ex instanceof CubesException) {
        throw (CubesException) ex;
      } else {
        throw CubesException.get(e);
      }
    }
  }
}
项目:Cubes    文件:Compatibility.java   
public void startCubes() {
  compatibility = this;

  Thread.setDefaultUncaughtExceptionHandler(UncaughtExceptionHandler.instance);
  Thread.currentThread().setUncaughtExceptionHandler(UncaughtExceptionHandler.instance);

  try {
    if (applicationType == ApplicationType.HeadlessDesktop) {
      run(new ServerAdapter());
    } else {
      run(new ClientAdapter());
    }
  } catch (Exception e) {
    try {
      Log.error("Failed to start", CubesException.get(e));
    } catch (Exception ex) {
      if (ex instanceof CubesException) {
        throw (CubesException) ex;
      } else {
        throw CubesException.get(e);
      }
    }
  }
}
项目:QuackHack    文件:QuackHack.java   
@Override
public void create () {     
    // Net Shit
    System.out.println("Good morning!");
       game = this;
    batch = new SpriteBatch();
    if(Gdx.app.getType() == ApplicationType.Desktop) {
        // Run server
        server = new NetServer();
        setScreen(new SplashScreen(game));

    } else {
        // Run client
        client = new NetClient();
        setScreen(new LobbyScreen(game));
    }
}
项目:Space-Bombs    文件:Main.java   
/**
 * Method called once when the application is created.
 */
@Override
public void create() 
{     
    //Load all textures
    TextureManager.load();
    AudioManager.load();

    this.setScreen(new StartScreen(this, client, server));

    if(Constants.TINYWINDOWS)
    {
       Gdx.graphics.setWindowedMode(Constants.SCREENWIDTH / 2, Constants.SCREENHEIGHT/ 2);
    }

    if(Gdx.app.getType().equals(ApplicationType.Android))
    {
        Constants.ISRUNNINGONSMARTPHONE = true;
    }
}
项目:cll1-gdx    文件:AbstractScreen.java   
@Override
public void pause() {
    if (!Gdx.app.getType().equals(ApplicationType.Desktop)) {
        systemPaused = true;
    }
    log("Pause");
    Gdx.input.setInputProcessor(null);
    if (music != null) {
        if (!Gdx.app.getType().equals(ApplicationType.Desktop)) {
            wasMusicPlaying = music.isPlaying();
            music.pause();
        }
    } else {
        wasMusicPlaying = false;
    }
}
项目:Argent    文件:ScreenshotFactory.java   
public static void saveScreenshot(final int w, final int h, final String prefix)
{
    try
    {
        FileHandle fh;
        do
        {
            if (Gdx.app.getType() == ApplicationType.Desktop)
            {
                fh = Gdx.files.local("bin/screenshot_" + prefix + "_" + counter++ + ".png");
            }
            else
            {
                fh = Gdx.files.local("screenshot_" + prefix + "_" + counter++ + ".png");
            }
        }
        while (fh.exists());
        final Pixmap pixmap = getScreenshot(0, 0, w, h, true);
        PixmapIO.writePNG(fh, pixmap);
        pixmap.dispose();
        Gdx.app.log("screenshot", "Screenshot saved to " + fh);
    }
    catch (final Exception e)
    {
    }
}
项目:neblina-libgdx3d    文件:MainMenu.java   
@Override
public void draw (float delta) {
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    viewMatrix.setToOrtho2D(0, 0, 480, 320);
    spriteBatch.setProjectionMatrix(viewMatrix);
    spriteBatch.setTransformMatrix(transformMatrix);
    spriteBatch.begin();
    spriteBatch.disableBlending();
    spriteBatch.setColor(Color.WHITE);
    spriteBatch.draw(background, 0, 0, 480, 320, 0, 0, 512, 512, false, false);
    spriteBatch.enableBlending();
    spriteBatch.draw(logo, 0, 320 - 128, 480, 128, 0, 0, 512, 256, false, false);
    spriteBatch.setBlendFunction(GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_ALPHA);
    glyphLayout.setText(font, "Touch screen to start!");
    font.draw(spriteBatch, glyphLayout, 240 - glyphLayout.width / 2, 128);
    if (Gdx.app.getType() == ApplicationType.WebGL) {
        glyphLayout.setText(font, "Press Enter for Fullscreen Mode");
        font.draw(spriteBatch, glyphLayout, 240 - glyphLayout.width / 2, 128 - font.getLineHeight());
    }
    spriteBatch.end();
}
项目:neblina-libgdx3d    文件:Invaders.java   
@Override
public void create () {
    Array<Controller> controllers = Controllers.getControllers();
    if (controllers.size > 0) {
        controller = controllers.first();
    }
    Controllers.addListener(controllerListener);

    setScreen(new MainMenu(this));
    music = Gdx.audio.newMusic(Gdx.files.getFileHandle("data/8.12.mp3", FileType.Internal));
    music.setLooping(true);
    music.play();
    Gdx.input.setInputProcessor(new InputAdapter() {
        @Override
        public boolean keyUp (int keycode) {
            if (keycode == Keys.ENTER && Gdx.app.getType() == ApplicationType.WebGL) {
                Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode());
            }
            return true;
        }
    });

    fps = new FPSLogger();
}
项目:RavTech    文件:RemoteEditLoadingScreen.java   
@Override
public void show () {
    font = new BitmapFont(Gdx.files.internal("fonts/font.fnt"));
    cache = font.getCache();

    if (Gdx.app.getType() == ApplicationType.Android)
        font.getData().setScale(2);
    polygonBatch = new PolygonSpriteBatch();
    camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

    Pixmap pixMap = new Pixmap(1, 1, Format.RGB565);
    pixMap.setColor(Color.WHITE);
    pixMap.fill();
    emptyTexture = new Texture(pixMap);
    pixMap.dispose();
}
项目:RavTech    文件:ShaderManager.java   
public ShaderManager (String shaderDir, AssetManager am, boolean addProcessors) {
    shaders = new ObjectMap<String, ShaderProgram>();
    shaderPaths = new ObjectMap<String, String>();
    sourcesVert = new ObjectMap<String, String>();
    sourcesFrag = new ObjectMap<String, String>();
    frameBuffers = new ObjectMap<String, FrameBuffer>();
    openedFrameBuffers = new Array<String>(true, MAX_FRAMEBUFFERS);
    screenCamera = new OrthographicCamera(Gdx.graphics.getWidth() + 2, Gdx.graphics.getHeight() + 2);
    createScreenQuad();
    screenCamera.translate(0, -1);
    screenCamera.update();
    setShaderDir(shaderDir);
    setAssetManager(am);
    // add("empty", "empty.vert", "empty.frag");
    // add("default", "default.vert", "default.frag");
    if (addProcessors && (Gdx.app.getType() == ApplicationType.Desktop || Gdx.app.getType() == ApplicationType.Applet
        || Gdx.app.getType() == ApplicationType.WebGL)) {
        /*
         * add("processor", "processor.vert", "processor.frag"); add("processor_blur", "processor.vert", "processor_blur.frag");
         * add("copy", "processor.vert", "copy.frag"); add("processor_draw", "processor.vert", "processor_draw.frag");
         * add("processor_fill", "processor.vert", "processor_fill.frag");
         */
    }
}
项目:gdx-twitter    文件:TwitterSystem.java   
private void tryLoadDesktopTwitterAPI() {
    if (Gdx.app.getType() != ApplicationType.Desktop) {
        Gdx.app.debug(TAG, "Skip loading Twitter API for Desktop. Not running Desktop. \n");
        return;
    }
    try {

        final Class<?> twitterClazz = ClassReflection.forName("de.tomgrill.gdxtwitter.desktop.DesktopTwitterAPI");
        Object twitter = ClassReflection.getConstructor(twitterClazz, TwitterConfig.class).newInstance(config);

        twitterAPI = (TwitterAPI) twitter;

        Gdx.app.debug(TAG, "gdx-twitter for Desktop loaded successfully.");

    } catch (ReflectionException e) {
        Gdx.app.debug(TAG, "Error creating gdx-twitter for Desktop (are the gdx-twitter **.jar files installed?). \n");
        e.printStackTrace();
    }

}
项目:gdx-twitter    文件:TwitterSystem.java   
private void tryLoadHTMLTwitterAPI() {
    if (Gdx.app.getType() != ApplicationType.WebGL) {
        Gdx.app.debug(TAG, "Skip loading gdx-twitter for HTML. Not running HTML. \n");
        return;
    }

    try {

        final Class<?> twitterClazz = ClassReflection.forName("de.tomgrill.gdxtwitter.html.HTMLTwitterAPI");
        Object twitter = ClassReflection.getConstructor(twitterClazz, TwitterConfig.class).newInstance(config);

        twitterAPI = (TwitterAPI) twitter;

        Gdx.app.debug(TAG, "gdx-twitter for HTML loaded successfully.");

    } catch (ReflectionException e) {
        Gdx.app.debug(TAG, "Error creating gdx-twitter for HTML (are the gdx-twitter **.jar files installed?). \n");
        e.printStackTrace();
    }

}
项目:gdx-twitter    文件:TwitterSystem.java   
private void tryLoadIOSTWitterAPI() {

        if (Gdx.app.getType() != ApplicationType.iOS) {
            Gdx.app.debug(TAG, "Skip loading gdx-twitter for iOS. Not running iOS. \n");
            return;
        }
        try {

            // Class<?> activityClazz =
            // ClassReflection.forName("com.badlogic.gdx.backends.iosrobovm.IOSApplication");
            final Class<?> twitterClazz = ClassReflection.forName("de.tomgrill.gdxtwitter.ios.IOSTwitterAPI");

            Object twitter = ClassReflection.getConstructor(twitterClazz, TwitterConfig.class).newInstance(config);

            twitterAPI = (TwitterAPI) twitter;

            Gdx.app.debug(TAG, "gdx-twitter for iOS loaded successfully.");

        } catch (ReflectionException e) {
            Gdx.app.debug(TAG, "Error creating gdx-twitter for iOS (are the gdx-twitter **.jar files installed?). \n");
            e.printStackTrace();
        }

    }
项目:Kroniax    文件:FinishScene.java   
public FinishScene(Application app) {
    setFillParent(true);

    Label label = new Label("You have beaten this level!", app.getGuiSkin());
    add(label);
    row().padTop(175.f);

    Label label1;
    Label label2;

    if (Gdx.app.getType() != ApplicationType.Android) {
        label1 = new Label("Press Space or click left to go to the next level", app.getGuiSkin());
        label2 = new Label("Press Escape to go back to menu", app.getGuiSkin());
    } else {
        label1 = new Label("Touch the screen to go to the next level", app.getGuiSkin());
        label2 = new Label("Press the back button to go back to the menu", app.getGuiSkin());
    }

    add(label1);
    row().padTop(75.f);
    add(label2);

    pack();

    setColor(1, 1, 1, 0);
}
项目:Kroniax    文件:PauseScene.java   
public PauseScene(Application app) {
    setFillParent(true);

    Label label1;
    Label label2;

    if (Gdx.app.getType() != ApplicationType.Android) {
        label1 = new Label("Press Space or press Left to resume the game", app.getGuiSkin());
        label2 = new Label("Press Escape to go back to the menu", app.getGuiSkin());
    } else {
        label1 = new Label("Touch the screen to resume the game", app.getGuiSkin());
        label2 = new Label("Press the back button to go back to the menu", app.getGuiSkin());
    }

    add(new Label("Game paused", app.getGuiSkin()));
    row().padTop(150.f);

    add(label1);
    row().padTop(75.f);
    add(label2);

    pack();

    setColor(1, 1, 1, 0);
}
项目:Kroniax    文件:ModalScene.java   
public ModalScene(Application app) {
    setFillParent(true);

    mText = new Label("No Text set yet", app.getGuiSkin());
    mText.setWrap(true);
    add(mText).width(900);
    row().padTop(175.f);

    Label label1;

    if (Gdx.app.getType() != ApplicationType.Android) {
        label1 = new Label("Press Space or click left to resume the game", app.getGuiSkin());
    } else {
        label1 = new Label("Touch the screen to resume the game", app.getGuiSkin());
    }

    add(label1);

    pack();

    setColor(1, 1, 1, 0);
}
项目:Kroniax    文件:CrashedScene.java   
public CrashedScene(Application app) {
    setFillParent(true);

    Label label1;
    Label label2;

    if (Gdx.app.getType() != ApplicationType.Android) {
        label1 = new Label("Press Space or press Left to start again from the last checkpoint", app.getGuiSkin());
        label2 = new Label("Press Escape to go back to menu", app.getGuiSkin());
    } else {
        label1 = new Label("Touch the screen to start again from the last checkpoint", app.getGuiSkin());
        label2 = new Label("Press the back button to go back to the menu", app.getGuiSkin());
    }

    add(new Label("You crashed into the wall", app.getGuiSkin()));
    row().padTop(150.f);
    add(label1);
    row().padTop(75.f);
    add(label2);

    pack();

    setColor(1, 1, 1, 0);
}
项目:Kroniax    文件:StartScene.java   
public StartScene(Application app) {
    setFillParent(true);

    Label label1;
    Label label2;

    if (Gdx.app.getType() != ApplicationType.Android) {
        label1 = new Label("Press Space or press Left to start the game", app.getGuiSkin());
        label2 = new Label("Press Escape to pause the game", app.getGuiSkin());
    } else {
        label1 = new Label("Touch the screen to start the game", app.getGuiSkin());
        label2 = new Label("Press the back button to pause the game", app.getGuiSkin());
    }

    add(label1);
    row().padTop(150.f);
    add(label2);

    pack();
}
项目:gdx-dialogs    文件:GDXDialogsSystem.java   
private void installDesktopGDXDialogs() {
    if (Gdx.app.getType() != ApplicationType.Desktop) {
        showDebugSkipInstall(ApplicationType.Desktop.name());
        return;
    }
    try {

        final Class<?> dialogManagerClazz = ClassReflection.forName("de.tomgrill.gdxdialogs.desktop.DesktopGDXDialogs");

        Object dialogManager = ClassReflection.getConstructor(dialogManagerClazz).newInstance();

        this.gdxDialogs = (GDXDialogs) dialogManager;

        showDebugInstallSuccessful(ApplicationType.Desktop.name());

    } catch (ReflectionException e) {
        showErrorInstall(ApplicationType.Desktop.name(), "desktop");
        e.printStackTrace();
    }

}
项目:gdx-dialogs    文件:GDXDialogsSystem.java   
private void installHTMLGDXDialogs() {
    if (Gdx.app.getType() != ApplicationType.WebGL) {
        showDebugSkipInstall(ApplicationType.WebGL.name());
        return;
    }

    try {

        final Class<?> dialogManagerClazz = ClassReflection.forName("de.tomgrill.gdxdialogs.html.HTMLGDXDialogs");
        Object dialogManager = ClassReflection.getConstructor(dialogManagerClazz).newInstance();

        this.gdxDialogs = (GDXDialogs) dialogManager;
        showDebugInstallSuccessful(ApplicationType.WebGL.name());

    } catch (ReflectionException e) {
        showErrorInstall(ApplicationType.WebGL.name(), "html");
        e.printStackTrace();
    }

}
项目:umbracraft    文件:Db.java   
public Db() {
    // deserialize all definitions
    definitions = new ObjectMap<>();
    Json json = new Json();
    json.setIgnoreUnknownFields(true);
    for (DefinitionReference reference : DefinitionReference.values()) {
        final String name = reference.id;
        final FileHandle handle = Gdx.files.external("umbracraft/" + name + ".json");
        if (handle.exists() && Gdx.app.getType() == ApplicationType.Desktop) {
            definitions.put(name, json.fromJson(reference.clazz, handle));
        } else {
            final FileHandle internalHandle = Gdx.files.internal("db/" + name + ".json");
            if (internalHandle.exists()) {
                definitions.put(name, json.fromJson(reference.clazz, internalHandle));
            } else {
                try {
                    definitions.put(name, reference.clazz.newInstance());
                } catch (InstantiationException | IllegalAccessException e) {
                    Game.error("Could not instantiate class: " + reference.clazz);
                    e.printStackTrace();
                }
            }
        }
    }
}
项目:GoingUnder    文件:GameManager.java   
public void saveScoreEtc() {
    Preferences prefs = Gdx.app.getPreferences(GameSaves);
    // sum of all scores ever
    totalScoreSum += currentScore;
    prefs.putInteger("total_score_sum", totalScoreSum);
    // games played by player
    ++totalGamesPlayed;
    prefs.putInteger("total_games_played", totalGamesPlayed);
    // save top score
    if (topScore < currentScore) {
        topScore = currentScore;
        // Save top score!!!!
        prefs.putInteger("topscore", topScore);
    }

    // hack / dont want to kill my ssd
    if (Gdx.app.getType() != ApplicationType.Desktop) {
        prefs.flush();
    }
}
项目:practicos    文件:PantallaJuego.java   
@Override
    public void render(float dt) {

    Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

//compara si la aplicacion se ejecuta en escritorio o en android
if(Gdx.app.getType() == ApplicationType.Desktop){
    this.entradaEscritorio(dt);
}else if(Gdx.app.getType() == ApplicationType.Android){
    this.entradaAndroid(dt);
}
//actualizamos 
camara.update();
this.juegoGanado();
batch.setProjectionMatrix(camara.combined);
manejadorDeSprite.update(dt,arcanoid,jugador);

//renderiza el manejadorDeSprite, fondo de pantalla y fuente de jugador
batch.begin();
batch.draw(fondoPantalla, 0, 0,Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
jugador.draw(batch);
batch.end();
manejadorDeSprite.render();
    }
项目:android-screen-recorder    文件:MainMenu.java   
@Override
public void draw (float delta) {
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    viewMatrix.setToOrtho2D(0, 0, 480, 320);
    spriteBatch.setProjectionMatrix(viewMatrix);
    spriteBatch.setTransformMatrix(transformMatrix);
    spriteBatch.begin();
    spriteBatch.disableBlending();
    spriteBatch.setColor(Color.WHITE);
    spriteBatch.draw(background, 0, 0, 480, 320, 0, 0, 512, 512, false, false);
    spriteBatch.enableBlending();
    spriteBatch.draw(logo, 0, 320 - 128, 480, 128, 0, 0, 512, 256, false, false);
    spriteBatch.setBlendFunction(GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_ALPHA);
    String text = "Touch screen to start!";
    float width = font.getBounds(text).width;
    font.draw(spriteBatch, text, 240 - width / 2, 128);
    if (Gdx.app.getType() == ApplicationType.WebGL) {
        text = "Press Enter for Fullscreen Mode";
        width = font.getBounds(text).width;
        font.draw(spriteBatch, "Press Enter for Fullscreen Mode", 240 - width / 2, 128 - font.getLineHeight());
    }
    spriteBatch.end();
}
项目:teavm-libgdx    文件:MainMenu.java   
@Override
public void draw (float delta) {
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    viewMatrix.setToOrtho2D(0, 0, 480, 320);
    spriteBatch.setProjectionMatrix(viewMatrix);
    spriteBatch.setTransformMatrix(transformMatrix);
    spriteBatch.begin();
    spriteBatch.disableBlending();
    spriteBatch.setColor(Color.WHITE);
    spriteBatch.draw(background, 0, 0, 480, 320, 0, 0, 512, 512, false, false);
    spriteBatch.enableBlending();
    spriteBatch.draw(logo, 0, 320 - 128, 480, 128, 0, 0, 512, 256, false, false);
    spriteBatch.setBlendFunction(GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_ALPHA);
    String text = "Touch screen to start!";
    float width = font.getBounds(text).width;
    font.draw(spriteBatch, text, 240 - width / 2, 128);
    if (Gdx.app.getType() == ApplicationType.WebGL) {
        text = "Press Enter for Fullscreen Mode";
        width = font.getBounds(text).width;
        font.draw(spriteBatch, "Press Enter for Fullscreen Mode", 240 - width / 2, 128 - font.getLineHeight());
    }
    spriteBatch.end();
}
项目:teavm-libgdx    文件:Invaders.java   
@Override
public void create () {
    Array<Controller> controllers = Controllers.getControllers();
    if (controllers.size > 0) {
        controller = controllers.first();
    }
    Controllers.addListener(controllerListener);

    setScreen(new MainMenu(this));
    music = Gdx.audio.newMusic(Gdx.files.getFileHandle("data/8.12.mp3", FileType.Internal));
    music.setLooping(true);
    music.play();
    Gdx.input.setInputProcessor(new InputAdapter() {
        @Override
        public boolean keyUp (int keycode) {
            if (keycode == Keys.ENTER && Gdx.app.getType() == ApplicationType.WebGL) {
                if (!Gdx.graphics.isFullscreen()) Gdx.graphics.setDisplayMode(Gdx.graphics.getDisplayModes()[0]);
            }
            return true;
        }
    });

    fps = new FPSLogger();
}
项目:JetFlight    文件:EntityPlayer.java   
public float getInputRotation() {
    float rawRotation = 0f;

    if (Gdx.app.getType() == ApplicationType.Android) {
        float added = Prefs.prefs.getFloat("calibratedX", 0f);
        rawRotation = (Gdx.input.getAccelerometerX() - added) * -0.1f;
    } else if (Gdx.app.getType() == ApplicationType.Desktop) {
        if (Gdx.input.isKeyPressed(Input.Keys.LEFT)) {
            rawRotation = -0.3f;
        } else if (Gdx.input.isKeyPressed(Input.Keys.RIGHT)) {
            rawRotation = 0.3f;
        }
    }

    float rotation = 0f;

    // Don't be too sensitive on the rotation: it only counts if it's above a threshold
    if (rawRotation > rotationThreshold) {
        rotation = rawRotation - rotationThreshold;
    } else if (rawRotation < -rotationThreshold) {
        rotation = rawRotation + rotationThreshold;
    }

    return rotation;
}
项目:libgdxcn    文件:FloatTextureData.java   
@Override
public void consumeCustomData (int target) {
    if (!Gdx.graphics.supportsExtension("texture_float"))
        throw new GdxRuntimeException("Extension OES_TEXTURE_FLOAT not supported!");

    // this is a const from GL 3.0, used only on desktops
    final int GL_RGBA32F = 34836;

    // GLES and WebGL defines texture format by 3rd and 8th argument,
    // so to get a float texture one needs to supply GL_RGBA and GL_FLOAT there.
    if (Gdx.app.getType() == ApplicationType.Android || Gdx.app.getType() == ApplicationType.iOS
        || Gdx.app.getType() == ApplicationType.WebGL) {
        Gdx.gl.glTexImage2D(target, 0, GL20.GL_RGBA, width, height, 0, GL20.GL_RGBA, GL20.GL_FLOAT, buffer);
    } else {
        // in desktop OpenGL the texture format is defined only by the third argument,
        // hence we need to use GL_RGBA32F there (this constant is unavailable in GLES/WebGL)
        Gdx.gl.glTexImage2D(target, 0, GL_RGBA32F, width, height, 0, GL20.GL_RGBA, GL20.GL_FLOAT, buffer);
    }
}
项目:libgdxcn    文件:ParticleShader.java   
public static String createPrefix(final Renderable renderable, final Config config) {
    String prefix = "";
    if(Gdx.app.getType() == ApplicationType.Desktop)
        prefix +="#version 120\n";
    else
        prefix +="#version 100\n";
    if(config.type == ParticleType.Billboard){
        prefix +="#define billboard\n";
        if(config.align == AlignMode.Screen) 
            prefix += "#define screenFacing\n";
        else if(config.align == AlignMode.ViewPoint) 
            prefix += "#define viewPointFacing\n";
        //else if(config.align == AlignMode.ParticleDirection) 
        //  prefix += "#define paticleDirectionFacing\n";
    }
    return prefix;
}
项目:libgdxcn    文件:ShaderCollectionTest.java   
@Override
public Shader getShader (Renderable renderable) {
    try {
        return super.getShader(renderable);
    } catch (Throwable e) {
        if (tempFolder != null && Gdx.app.getType() == ApplicationType.Desktop)
            Gdx.files.absolute(tempFolder).child(name + ".log.txt").writeString(e.getMessage(), false);
        if (!revert()) {
            Gdx.app.error("ShaderCollectionTest", e.getMessage());
            throw new GdxRuntimeException("Error creating shader, cannot revert to default shader", e);
        }
        error = true;
        Gdx.app.error("ShaderTest", "Could not create shader, reverted to default shader.", e);
        return super.getShader(renderable);
    }
}
项目:libgdxcn    文件:ShaderCollectionTest.java   
@Override
public void create () {
    super.create();
    lights = new Environment();
    lights.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.1f, 0.1f, 0.1f, 1.f));
    lights.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -0.5f, -1.0f, -0.8f));

    shaderProvider = new TestShaderProvider();
    shaderBatch = new ModelBatch(shaderProvider);

    cam.position.set(1, 1, 1);
    cam.lookAt(0, 0, 0);
    cam.update();
    showAxes = true;

    onModelClicked("g3d/shapes/teapot.g3dj");

    shaderRoot = (hotLoadFolder != null && Gdx.app.getType() == ApplicationType.Desktop) ? Gdx.files.absolute(hotLoadFolder)
        : Gdx.files.internal("data/g3d/shaders");
}
项目:MathAttack    文件:MAMainMenuEnviroment.java   
/**
 * Sets the up game name.
 *
 * @param menu_screen the new up game name
 */
public void setUpGameName(final MAMainMenuScreen menu_screen) {
    menu_screen.title = new EmptyActorLight(TITLE_W, TITLE_H, true);
    menu_screen.title.setTextureRegion(UIAssets.image_main_title, true);
    menu_screen.title.setOrigin( menu_screen.title.getWidth() / 2, menu_screen.title.getHeight() / 2);
    menu_screen.title.setPosition( AppSettings.SCREEN_W / 2 - menu_screen.title.getWidth() / 2,
            AppSettings.SCREEN_H + menu_screen.title.getHeight());

    if (Gdx.app.getType() == ApplicationType.Android) {
        menu_screen.title.setPosition( AppSettings.SCREEN_W / 2 - menu_screen.title.getWidth() / 2,
                AppSettings.SCREEN_H + menu_screen.title.getHeight() - 50);
    }

    //
    menu_screen.getStage().addActor(menu_screen.title);
}
项目:HAW-SE2-projecthorse    文件:AssetManager.java   
/**
 * Setzen des root-Verzeichnisses. Wird fuer den Zugriff auf Assets
 * benoetigt. Weiterhin werden die Sound, Music und Texture Pfade gesetzt
 */
private static void setApplicationRoot() {
    if (Gdx.app.getType() == ApplicationType.Android) {

        assetDir = "";
    } else if (Gdx.app.getType() == ApplicationType.Desktop) {

        assetDir = System.getProperty("user.dir") + FILESEPARATOR + "bin" + FILESEPARATOR;
    } else {
        Gdx.app.log("AssetManager", "No android or desktop device");
    }

    directorySounds = assetDir + FOLDERNAME_SOUNDS;
    directoryMusic = assetDir + FOLDERNAME_MUSIC;
    directoryPictures = assetDir + FOLDERNAME_PICTURES;
    directoryFonts = assetDir + FOLDERNAME_FONTS;

}
项目:gaiasky    文件:PixelRenderSystem.java   
@Override
protected void initShaderProgram() {
    // Initialise renderer
    if (Gdx.app.getType() == ApplicationType.WebGL)
        shaderProgram = new ShaderProgram(Gdx.files.internal("shader/point.vertex.glsl"), Gdx.files.internal("shader/point.fragment.wgl.glsl"));
    else
        shaderProgram = new ShaderProgram(Gdx.files.internal("shader/point.vertex.glsl"), Gdx.files.internal("shader/point.fragment.glsl"));
    if (!shaderProgram.isCompiled()) {
        Logger.error(this.getClass().getName(), "Pixel shader compilation failed:\n" + shaderProgram.getLog());
    }
    pointAlpha = new float[] { GlobalConf.scene.POINT_ALPHA_MIN, GlobalConf.scene.POINT_ALPHA_MIN + GlobalConf.scene.POINT_ALPHA_MAX };
    shaderProgram.begin();
    shaderProgram.setUniform2fv("u_pointAlpha", pointAlpha, 0, 2);
    shaderProgram.end();

}
项目:bladecoder-adventure-engine    文件:EngineAssetManager.java   
public FileHandle getUserFile(String filename) {
    FileHandle file = null;

    if (Gdx.app.getType() == ApplicationType.Desktop || Gdx.app.getType() == ApplicationType.Applet) {
        String dir = Config.getProperty(Config.TITLE_PROP, DESKTOP_PREFS_DIR);
        dir.replace(" ", "");

        StringBuilder sb = new StringBuilder();
        sb.append(".").append(dir).append("/").append(filename);

        if (System.getProperty("os.name").toLowerCase().contains("mac")
                && System.getenv("HOME").contains("Containers")) {

            file = Gdx.files.absolute(System.getenv("HOME") + "/" + sb.toString());
        } else {

            file = Gdx.files.external(sb.toString());
        }
    } else {
        file = Gdx.files.local(NOT_DESKTOP_PREFS_DIR + filename);
    }

    return file;
}
项目:bladecoder-adventure-engine    文件:EngineAssetManager.java   
public FileHandle getUserFolder() {
    FileHandle file = null;

    if (Gdx.app.getType() == ApplicationType.Desktop || Gdx.app.getType() == ApplicationType.Applet) {
        String dir = Config.getProperty(Config.TITLE_PROP, DESKTOP_PREFS_DIR);
        dir.replace(" ", "");

        StringBuilder sb = new StringBuilder(".");

        if (System.getProperty("os.name").toLowerCase().contains("mac")
                && System.getenv("HOME").contains("Containers")) {

            file = Gdx.files.absolute(System.getenv("HOME") + "/" + sb.append(dir).toString());
        } else {

            file = Gdx.files.external(sb.append(dir).toString());
        }

    } else {
        file = Gdx.files.local(NOT_DESKTOP_PREFS_DIR);
    }

    return file;
}
项目:OneStory_VN_Engine    文件:DefinitionDeterminer.java   
public DefinitionDeterminer(){
    super();

    int w = Gdx.graphics.getWidth();
    int h = Gdx.graphics.getHeight();
    int m = 0;
    if(w>h) m = w;
    else m = h;

    if(Gdx.app.getType() == ApplicationType.Desktop){
        screenType = TextureSize.HIGH;
    }
    else if(m <= 480){
        screenType = TextureSize.LOW;
    }
    else if(m <= 1024){
        screenType = TextureSize.MEDIUM;
    }
    else {
        screenType = TextureSize.HIGH;
    }

    System.out.println("System screen definition : " + screenType.toString());

}
项目:the-erder    文件:GameManager.java   
public static FileHandle[] getFontTxtDir()
{
    if (Gdx.app.getType().equals(ApplicationType.Desktop))
    {
        System.out.println(System.getProperty("user.dir")
                + "\\bin\\fonts\\");

        return Gdx.files.absolute(
                System.getProperty("user.dir") + "\\bin\\fonts\\").list();

    } else if (Gdx.app.getType() == ApplicationType.Android)
    {
        return Gdx.files.internal("fonts/").list();
    }
    return null;
}
项目:libgdx-demo-invaders    文件:MainMenu.java   
@Override
public void draw (float delta) {
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    viewMatrix.setToOrtho2D(0, 0, 480, 320);
    spriteBatch.setProjectionMatrix(viewMatrix);
    spriteBatch.setTransformMatrix(transformMatrix);
    spriteBatch.begin();
    spriteBatch.disableBlending();
    spriteBatch.setColor(Color.WHITE);
    spriteBatch.draw(background, 0, 0, 480, 320, 0, 0, 512, 512, false, false);
    spriteBatch.enableBlending();
    spriteBatch.draw(logo, 0, 320 - 128, 480, 128, 0, 0, 512, 256, false, false);
    spriteBatch.setBlendFunction(GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_ALPHA);
    glyphLayout.setText(font, "Touch screen to start!");
    font.draw(spriteBatch, glyphLayout, 240 - glyphLayout.width / 2, 128);
    if (Gdx.app.getType() == ApplicationType.WebGL) {
        glyphLayout.setText(font, "Press Enter for Fullscreen Mode");
        font.draw(spriteBatch, glyphLayout, 240 - glyphLayout.width / 2, 128 - font.getLineHeight());
    }
    spriteBatch.end();
}