diff --git a/.gitmodules b/.gitmodules index 532df8c..845c2e4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "raygui"] path = raygui url = https://github.com/raysan5/raygui.git +[submodule "raylib-cpp"] + path = raylib-cpp + url = https://github.com/RobLoach/raylib-cpp.git diff --git a/build-java.sh b/build-java.sh index c75232c..e60e9d5 100755 --- a/build-java.sh +++ b/build-java.sh @@ -14,7 +14,7 @@ mv src/com/raylib/RaylibConfig.class gen/com/raylib cp *.h gen/com/raylib cd gen echo "STEP 2 - compile Raylib.java" -java -jar ../javacpp.jar -nodelete com/raylib/Raylib.java -Dplatform.compiler.foo='-DPHYSAC_IMPLEMENTATION -DRAYGUI_IMPLEMENTATION -std=c++11' +java -jar ../javacpp.jar -nodelete com/raylib/Raylib.java -Dplatform.compiler.foo='-DPHYSAC_IMPLEMENTATION -DRAYGUI_IMPLEMENTATION -fpermissive -std=c++11' # /Oi /O2 /MD /LD /link /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /NODEFAULTLIB:MSVCRTD' if [ $? -ne '0' ]; then echo "Fix this before trying again" diff --git a/raylib-cpp b/raylib-cpp new file mode 160000 index 0000000..6d9d02c --- /dev/null +++ b/raylib-cpp @@ -0,0 +1 @@ +Subproject commit 6d9d02cd242e8a4f78b6f971afcf992fb7a417dd diff --git a/src/com/raylib/Colors.java b/src/com/raylib/Colors.java index 2413be9..6f74525 100644 --- a/src/com/raylib/Colors.java +++ b/src/com/raylib/Colors.java @@ -29,6 +29,6 @@ public final class Colors { public static final Raylib.Color RAYWHITE = c(245, 245, 245, 255); private static Raylib.Color c(int r, int g, int b, int a) { - return new Raylib.Color().r((byte) r).g((byte) g).b((byte) b).a((byte) a); + return new Raylib.Color(new Raylib.ColorStruct().r((byte) r).g((byte) g).b((byte) b).a((byte) a)); } } diff --git a/src/com/raylib/Helpers.java b/src/com/raylib/Helpers.java deleted file mode 100644 index 5f7b851..0000000 --- a/src/com/raylib/Helpers.java +++ /dev/null @@ -1,131 +0,0 @@ -package com.raylib; - -public final class Helpers { - - public static Raylib.Color newColor(int r, int g, int b, int a) { - return new Raylib.Color() - .r((byte) r) - .g((byte) g) - .b((byte) b) - .a((byte) a); - } - - - public static Raylib.Camera3D newCamera(Raylib.Vector3 position, - Raylib.Vector3 target, - Raylib.Vector3 up, - float fovy, - int projection) { - return new Raylib.Camera3D() - ._position(position) - .target(target) - .up(up) - .fovy(fovy) - .projection(projection); - - } - - public static Raylib.Camera2D newCamera2D(Raylib.Vector2 offset, - Raylib.Vector2 target, - float rotation, - float zoom) { - return new Raylib.Camera2D() - .offset(offset) - .target(target) - .rotation(rotation) - .zoom(zoom); - } - - - public Raylib.Rectangle newRectangle(float x, float y, float width, float height) { - return new Raylib.Rectangle() - .x(x) - .y(y) - .width(width) - .height(height); - } - - public static Raylib.Rectangle newRectangle(Raylib.Rectangle rect) { - return new Raylib.Rectangle() - .x(rect.x()) - .y(rect.y()) - .width(rect.width()) - .height(rect.height()); - } - - - public static Raylib.BoundingBox newBoundingBox(Raylib.Vector3 min, Raylib.Vector3 max) { - return new Raylib.BoundingBox() - .min(min) - .max(max); - } - - public static Raylib.BoundingBox newBoundingBox(Raylib.BoundingBox bb) { - return new Raylib.BoundingBox() - .min(bb.min()) - .max(bb.max()); - } - - - public static Raylib.Ray newRay(Raylib.Vector3 position, Raylib.Vector3 direction) { - return new Raylib.Ray() - ._position(position) - .direction(direction); - } - - public static Raylib.Ray newRay(Raylib.Ray ray) { - return new Raylib.Ray() - ._position(ray._position()) - .direction(ray.direction()); - } - - - public static Raylib.RayCollision newRayCollision(boolean hit, - float distance, - Raylib.Vector3 point, - Raylib.Vector3 normal) { - return new Raylib.RayCollision() - .hit(hit) - .distance(distance) - .point(point) - .normal(normal); - } - - public static Raylib.RayCollision newRayCollision(Raylib.RayCollision rc) { - return new Raylib.RayCollision() - .hit(rc.hit()) - .distance(rc.distance()) - .point(rc.point()) - .normal(rc.normal()); - } - - - public static Raylib.Vector3 newVector3(float x, float y, float z) { - return new Raylib.Vector3() - .x(x) - .y(y) - .z(z); - } - - public static Raylib.Vector3 newVector3(Raylib.Vector3 vector3) { - return new Raylib.Vector3() - .x(vector3.x()) - .y(vector3.y()) - .z(vector3.z()); - } - - - public static Raylib.Vector2 newVector2(float x, float y) { - return new Raylib.Vector2() - .x(x) - .y(y); - } - - public static Raylib.Vector2 newVector2(Raylib.Vector2 vector2) { - return new Raylib.Vector2() - .x(vector2.x()) - .y(vector2.y()); - } - - -} diff --git a/src/com/raylib/RaylibConfig.java b/src/com/raylib/RaylibConfig.java index 2af40c8..5f324f6 100644 --- a/src/com/raylib/RaylibConfig.java +++ b/src/com/raylib/RaylibConfig.java @@ -9,17 +9,68 @@ @Properties( value = { @Platform( - include = {"raylib.h", "rlgl.h", "raymath.h", "physac.h", "raygui.h"}, - compiler = {"!default","foo"} + includepath = {"../raylib-cpp/include/"}, + //cinclude = {"raylib.h", + // "rlgl.h", "raymath.h", "physac.h", "raygui.h" + // }, + include = { + + "Functions.hpp", + "raylib.h", "rlgl.h", "raymath.h", "physac.h", "raygui.h", + "raylib-cpp.hpp", + "raylib-cpp-utils.hpp", + + "AudioDevice.hpp", + "AudioStream.hpp", + "AutomationEventList.hpp", + "BoundingBox.hpp", + "Camera2D.hpp", + "Camera3D.hpp", + "Color.hpp", + "FileData.hpp", + "FileText.hpp", + "Font.hpp", + + "Gamepad.hpp", + "Image.hpp", + "Keyboard.hpp", + //"Material.hpp", + "Matrix.hpp", + "Mesh.hpp", + "MeshUnmanaged.hpp", + "Model.hpp", + //"ModelAnimation.hpp", + "Mouse.hpp", + "Music.hpp", + "Ray.hpp", + "RayCollision.hpp", + //"RaylibException.hpp" , + "Rectangle.hpp", + "RenderTexture.hpp", + "Shader.hpp", + "ShaderUnmanaged.hpp", + "Sound.hpp", + "Text.hpp", + "Texture.hpp", + "TextureUnmanaged.hpp", + "Touch.hpp", + "Vector2.hpp", + "Vector3.hpp", + "Vector4.hpp", + "VrStereoConfig.hpp", + "Wave.hpp", + "Window.hpp" + }, + compiler = {"!default", "foo"} ), @Platform( value = {"windows-x86_64"}, - link = {"winmm", "OpenGL32","user32","shell32","gdi32","raylib"} + link = {"winmm", "OpenGL32", "user32", "shell32", "gdi32", "raylib"} ), @Platform( value = {"windows-x86"}, - link = {"winmm", "OpenGL32","user32","shell32","gdi32","raylib"} - ), + link = {"winmm", "OpenGL32", "user32", "shell32", "gdi32", "raylib"} + ), @Platform( value = {"macosx-x86_64"}, link = {"raylib"} @@ -45,7 +96,6 @@ )}, - target = "com.raylib.Raylib" ) @@ -56,10 +106,12 @@ public void map(InfoMap infoMap) { infoMap.put(new Info("!defined(__cplusplus) && !defined(bool)").define(false)) .put(new Info("!defined(__cplusplus) && !defined(bool) && !defined(RL_BOOL_TYPE)").define(false)) .put(new Info("RLAPI").cppText("#define RLAPI")) + .put((new Info("raylib.h") .linePatterns("// NOTE: Custom raylib color palette for amazing visuals on WHITE background", - "// Structures Definition").skip())) - .put(new Info("MOUSE_LEFT_BUTTON","MOUSE_RIGHT_BUTTON","MOUSE_MIDDLE_BUTTON","FormatText", + "// Structures Definition").skip() + )) + .put(new Info("MOUSE_LEFT_BUTTON", "MOUSE_RIGHT_BUTTON", "MOUSE_MIDDLE_BUTTON", "FormatText", "SubText", "ShowWindow", "LoadText", "SpriteFont", "GetExtension", "GetMouseRay").cppTypes().annotations()) .put(new Info("defined(RLGL_STANDALONE)").define(false)) //.put(new Info("defined(GRAPHICS_API_OPENGL_ES2)").define(false)) @@ -72,7 +124,50 @@ public void map(InfoMap infoMap) { .put(new Info("defined(RAYGUI_STANDALONE)").define(false)) .put(new Info("defined(RAYGUI_IMPLEMENTATION)").define(false)) .put(new Info("RAYGUIAPI").cppText("#define RAYGUIAPI")) - // .put(new Info("GLAD_REALLOC", "GLAD_FREE").cppTypes().annotations()) + .put(new Info("RLCPPAPI").cppText("#define RLCPPAPI")) + + .put(new Info("AudioDevice").pointerTypes("AudioDeviceStruct")) + .put(new Info("AudioStream").pointerTypes("AudioStreamStruct")) + .put(new Info("AutomationEventList").pointerTypes("AutomationEventListStruct")) + .put(new Info("BoundingBox").pointerTypes("BoundingBoxStruct")) + .put(new Info("Camera2D").pointerTypes("Camera2DStruct")) + .put(new Info("Camera3D" ).pointerTypes("Camera3DStruct")) + .put(new Info("Color") .pointerTypes("ColorStruct")) + .put(new Info("FileData" ).pointerTypes("FileDataStruct")) + .put(new Info("FileText" ).pointerTypes("FileTextStruct")) + .put(new Info("Font" ).pointerTypes("FontStruct")) + .put(new Info("Gamepad" ).pointerTypes("GamepadStruct")) + .put(new Info("Image" ).pointerTypes("ImageStruct")) + .put(new Info("Keyboard" ).pointerTypes("KeyboardStruct")) + .put(new Info("Material" ).pointerTypes("MaterialStruct")) + .put(new Info("Matrix" ).pointerTypes("MatrixStruct")) + .put(new Info("Mesh" ).pointerTypes("MeshStruct")) + .put(new Info("Model" ).pointerTypes("ModelStruct")) + .put(new Info("ModelAnimation" ).pointerTypes("ModelAnimationStruct")) + .put(new Info("Mouse" ).pointerTypes("MouseStruct")) + .put(new Info("Music" ).pointerTypes("MusicStruct")) + .put(new Info("Ray" ).pointerTypes("RayStruct")) + .put(new Info("RayCollision" ).pointerTypes("RayCollisionStruct")) + .put(new Info("Rectangle" ).pointerTypes("RectangleStruct")) + .put(new Info("RenderTexture" ).pointerTypes("RenderTextureStruct")) + .put(new Info("Shader" ).pointerTypes("ShaderStruct")) + .put(new Info("Sound" ).pointerTypes("SoundStruct")) + .put(new Info("Text" ).pointerTypes("TextStruct")) + .put(new Info("Texture" ).pointerTypes("TextureStruct")) + .put(new Info("Touch" ).pointerTypes("TouchStruct")) + .put(new Info("Vector2" ).pointerTypes("Vector2Struct")) + .put(new Info("Vector3" ).pointerTypes("Vector3Struct")) + .put(new Info("Vector4" ).pointerTypes("Vector4Struct")) + .put(new Info("VrStereoConfig" ).pointerTypes("VrStereoConfigStruct")) + .put(new Info("Wave" ).pointerTypes("WaveStruct")) + .put(new Info("Window" ).pointerTypes("WindowStruct")) + //.put(new Info("raylib::Camera3D").base("Pointer")) + .put(new Info("raylib::LoadDroppedFiles").skip()) + .put(new Info("raylib::LoadDirectoryFiles").skip()) + .put(new Info("raylib::TextSplit").skip()) + .put(new Info("raylib::Vector4::ToAxisAngle").skip()) + .put(new Info("raylib::Vector4::Color").skip()) + // .put(new Info("GLAD_REALLOC", "GLAD_FREE").cppTypes().annotations()) ; diff --git a/src/com/raylib/Test.java b/src/com/raylib/Test.java index 46ee673..97f8305 100644 --- a/src/com/raylib/Test.java +++ b/src/com/raylib/Test.java @@ -2,7 +2,7 @@ import static com.raylib.Raylib.*; import static com.raylib.Colors.*; -import static com.raylib.Helpers.*; + public class Test { public static void main(String args[]) { @@ -17,20 +17,20 @@ public static void main(String args[]) { // .fovy(45) // .projection(0); - Camera3D camera = newCamera(newVector3(18,16,18), + Camera3D camera = new Camera3D(new Vector3(18,16,18), new Vector3(), new Vector3().x(0).y(1).z(0), 45, 0); - Image image = LoadImage("examples/models/resources/heightmap.png"); - Texture texture = LoadTextureFromImage(image); - Mesh mesh = GenMeshHeightmap(image, new Vector3().x(16).y(8).z(16)); - Model model = LoadModelFromMesh(mesh); + Image image = new Image("heightmap.png"); + TextureUnmanaged texture = new TextureUnmanaged(image); + Mesh mesh = new Mesh(GenMeshHeightmap(image, new Vector3().x(16).y(8).z(16))); + Model model = new Model(mesh); model.materials().maps().position(0).texture(texture); UnloadImage(image); while(!WindowShouldClose()){ - UpdateCamera(camera, CAMERA_ORBITAL); + camera.Update(CAMERA_ORBITAL); BeginDrawing(); ClearBackground(RAYWHITE); BeginMode3D(camera);