Skip to content

Commit

Permalink
readme
Browse files Browse the repository at this point in the history
  • Loading branch information
electronstudio committed Jul 3, 2021
1 parent 9985ec1 commit 98327cf
Showing 1 changed file with 16 additions and 24 deletions.
40 changes: 16 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,19 @@ they are auto-generated. See [How To Build](#how-to-build)

## How to use

Download the latest [jaylib.jar](https://github.com/electronstudio/jaylib/releases/download/v3.0.0-rc5/jaylib.jar) from [releases](https://github.com/electronstudio/jaylib/releases)
Download the latest `jaylib.jar` and `jaylib-natives.jar` for your platform(s) from [releases](https://github.com/electronstudio/jaylib/releases)

Write a demo program, e.g. Demo.java

```java
import com.raylib.Jaylib.Vector3;
import com.raylib.Jaylib.Camera;
import com.raylib.Raylib;
import static com.raylib.Jaylib.*;

public class Demo {
public static void main(String args[]) {
InitWindow(800, 450, "Demo");
SetTargetFPS(60);
Camera camera = new Camera(new Vector3(18,16,18),new Vector3(), new Vector3(0,1,0), 45, 0);
Camera camera = new Camera(new Vector3().x(18).y(16).z(18),new Vector3(), new Vector3().x(0).y(1).z(0), 45, 0);
SetCameraMode(camera, CAMERA_ORBITAL);

while(!WindowShouldClose()){
Expand All @@ -50,25 +48,25 @@ public class Demo {

Compile it:

javac -cp jaylib.jar Demo.java
javac -cp jaylib.jar:jaylib-natives.jar Demo.java

Run it:

java -cp jaylib.jar:. Demo
java -cp jaylib.jar:jaylib-natives.jar:. Demo

On MacOS you need this option:

java -XstartOnFirstThread -cp jaylib.jar:. Demo
java -XstartOnFirstThread -cp jaylib.jar:jaylib-natives.jar:. Demo

On weirdy Windows:

java -cp jaylib.jar;. Demo
java -cp jaylib.jar;:jaylib-natives.jar. Demo

## Known issues

### Getters and setters

JavaCPP does not use the 'get' and 'set' names nor does it use public fields. To access a field:
JavaCPP does not use the 'get' and 'set' names in the methods (nor does it expose public fields). To access a field:

var x = vector.x()

Expand All @@ -80,23 +78,11 @@ Remember each time you do either of those you are accessing native memory.

### Constructors

JavaCPP does not generate constructors. There are three ways you can construct objects. The recommended JavaCPP way is like this:
JavaCPP does not generate constructors. The recommended JavaCPP way is like this:

var vec = new Vector3().x(1).y(2).z(3);

I made some sub classes in Jaylib.java. To use those:

import com.raylib.Jaylib.Vector3;
...
var vec = new Vector3(1, 2, 3);

I made some constructor functions in Jaylib.java. To use those:

import static com.raylib.Jaylib.Vector3;

var vec = Vector3(1, 2, 3);

I'm undecided which of these methods is cleanest but I recommend the first because it's autogenerated by JavaCPP.
For discussion of other ways, [see here](https://github.com/electronstudio/jaylib/issues/1#issuecomment-873485303).

### Arrays

Expand All @@ -105,8 +91,14 @@ of which have an arrays of `maps`. To access the second map of the first materi

model.materials().position(1).maps().position(2)

### RLGL and Raymath

These additional libraries are included in the Linux and Mac natives but may not be (or may not work) in the Windows.

## How to build

(See the Github Actions build file for latest more detailed exact platform specific steps.)

Clone this repo including submodules so you get correct version of Raylib. (On Windows, Google for how to enable symlinks
)

Expand All @@ -121,7 +113,7 @@ Edit `build.sh` to set platform variables.
Run:
`./build.sh`

This will build you a jaylib.jar uber-jar.
This will build you a jaylib.jar uber-jar and natives jar and a docs jar.

On Windows the script must be run from inside a Visual C 2019 native x64 command prompt, and needs git-bash to be installed.

Expand Down

0 comments on commit 98327cf

Please sign in to comment.