Skip to content

JFixby/libgdx-snippets

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

libGDX lazy snippets

A collection of code snippets for the lazy libGDX user.

Outline

  • Aimed for desktop projects, so the code won't run on HTML5 and mobile.
  • Written/compiled with JDK 8, and uses Java 1.8 language features. Be advised you may encounter heavy (ab)use of lambdas.
  • Invades the com.badlogic.gdx.* namespace.
  • Embeds a small native library for some utility functions.
  • (Almost) no external dependencies besides libGDX.

Highlights

  • AnnotatedJson: custom JSON serializer, based on libGDX' Json classes, which allows annotation-driven serialization of object hierarchies.
  • AutoDisposer: annotation-driven, semi-automatic disposal of disposable object hierarchies.
  • GL33Ext: native interface to flextGL to expose desktop OpenGL functions not made available by libGDX/LWJGL.
  • GLSLOptimizer: Native interface to glsl-optimizer.
  • MultiTargetFrameBuffer: custom GLFrameBuffer implementation for creating multi-render targets, e.g. usable for deferred rendering (G-buffers).

Usage

To use the native interfaces, you just need to add a call to GdxSnippetsNativesLoader.load(), for example in your create() function.

public class MyGdxGameAdapter extends ApplicationAdapter {
    @Override
    public void create() {
        GdxSnippetsNativesLoader.load();
    }
}

Building from source

Java package

This is a Maven project. Just use mvn package or mvn install to create a snapshot.

Native libraries

This library uses the fips cmake build wrapper to compile the native source code. Please read the list of requirements to run fips (in short: Python 2.7.9, cmake 2.8.11+, and an appropriate C++ compiler environment). In addition, Maven and Java are required for the fips-jni module.

The steps below should work on every target system. You only need to specify a different build target.

The root folder for the native code is located in [libgdx-snippets]/src/main/native/jni/.

# navigate to the native source folder
> cd [libgdx-snippets]/src/main/native/jni/

To install fips plus dependencies (one-time):

# this will install fips
> ./fips

# fetch dependencies
> ./fips fetch

# setup fips-jni
> ./fips jni setup

To select the build target (one-time):

# [optional] list all configs known to fips
> ./fips list configs

# e.g. for Windows 64 bit, using VS2013
> ./fips set config win64-vs2013-release

# or, for OS X, using XCode
> ./fips set config osx-xcode-release

To compile the native library:

# [optional] clean output
> ./fips clean all

# generate JNI code and build the library
> ./fips build

Note: fips-jni uses gdx-jnigen to generate native code from C++ embedded in Java source files. Gdx-jnigen parses both .java and .class files. This means that, to compile the native library successfully, it is required to compile the Java code first, e.g. via mvn compile from the root folder, or from inside your favourite IDE.

To copy the compiled runtime library:

# e.g. for Windows 64 bit
> mvn install -Pwin64-vs2013

# or, for OS X
> mvn install -Posx-xcode

Note: this copies the compiled runtime library to [libgdx-snippets]/src/main/resources.

About

A collection of code snippets for use with libGDX.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 67.5%
  • Java 31.1%
  • C++ 0.7%
  • CMake 0.4%
  • Python 0.3%
  • Shell 0.0%