Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raylib 4.5 #6

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 4 additions & 2 deletions Build.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<xml>
<set name="raylib_folder" value="${haxelib:raylib-haxe}/lib/raylib" />
<set name="glfw_folder" value="${haxelib:raylib-haxe}/lib/raylib/external/glfw" />
<set name="raylib_folder" value="${haxelib:raylib-haxe}/lib/raylib/src" />
<set name="glfw_folder" value="${haxelib:raylib-haxe}/lib/raylib/src/external/glfw" />

<echo value="Using raylib from: ${raylib_folder}" />
<echo value="Using glfw from: ${glfw_folder}" />
Expand Down Expand Up @@ -53,6 +53,8 @@
<compilerflag value="-DPLATFORM_DESKTOP" />
<compilerflag value="-D_GLFW_COCOA" />

<file name="${glfw_folder}/src/platform.c" />
<file name="${glfw_folder}/src/posix_module.c" />
<file name="${glfw_folder}/src/cocoa_init.m" />
<file name="${glfw_folder}/src/cocoa_monitor.m" />
<file name="${glfw_folder}/src/cocoa_joystick.m" />
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ To build run `haxe build.hxml` from the project root, this will create a `Main`

Refer to [hello world example](https://github.com/haxeui/raylib-haxe/tree/main/examples/hello-world) for a working example.

## macOS Arm64 (M1+ Processors)

Running `haxe build.hxml` will result in an **Intel** binary. You need to add the correct flag to get the correct **Apple** binary:

```bash
haxe -D HXCPP_ARM64 -D macos build.hxml
```

# Advanced Usage

Expand Down
392 changes: 240 additions & 152 deletions RayLib.hx

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions examples/bunnymark/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p align="center">
<img src="https://raw.githubusercontent.com/haxeui/raylib-haxe/main/examples/textures/screen.png"/>
</p>
10 changes: 10 additions & 0 deletions examples/bunnymark/Run.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@echo off
cd bin
if "%1"=="debug" (
:: run debug
Main-Debug.exe
pause
) else (
:: run release
Main.exe
)
6 changes: 6 additions & 0 deletions examples/bunnymark/build.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-lib raylib-haxe

-cp src

-cpp bin
-main Main
53 changes: 53 additions & 0 deletions examples/bunnymark/bunnymark.hxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<project version="2">
<!-- Output SWF options -->
<output>
<movie outputType="Application" />
<movie input="" />
<movie path="bin" />
<movie fps="0" />
<movie width="0" />
<movie height="0" />
<movie version="0" />
<movie minorVersion="0" />
<movie platform="C++" />
<movie background="#FFFFFF" />
</output>
<!-- Other classes to be compiled into your SWF -->
<classpaths>
<class path="src" />
</classpaths>
<!-- Build options -->
<build>
<option directives="" />
<option flashStrict="False" />
<option noInlineOnDebug="False" />
<option mainClass="Main" />
<option enabledebug="False" />
<option additional="" />
</build>
<!-- haxelib libraries -->
<haxelib>
<library name="raylib-haxe" />
</haxelib>
<!-- Class files to compile (other referenced classes will automatically be included) -->
<compileTargets>
<compile path="src\Main.hx" />
</compileTargets>
<!-- Paths to exclude from the Project Explorer tree -->
<hiddenPaths>
<hidden path="obj" />
</hiddenPaths>
<!-- Executed before build -->
<preBuildCommand />
<!-- Executed after build -->
<postBuildCommand alwaysRun="False" />
<!-- Other project options -->
<options>
<option showHiddenPaths="False" />
<option testMovie="Custom" />
<option testMovieCommand="run.bat $(BuildConfig)" />
</options>
<!-- Plugin storage -->
<storage />
</project>
Binary file added examples/bunnymark/screen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
91 changes: 91 additions & 0 deletions examples/bunnymark/src/Main.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package;

import RayLib.*;
import RayLib.Colors.*;
import RayLib.Image;
import RayLib.Texture;
import RayLib.Vector2;
import RayLib.Vector2Ref;
import RayLib.Color;
import RayLib.ColorRef;
import RayLib.PixelFormat;
import cpp.NativeArray;
import haxe.io.Bytes;

typedef Bunny = {
position:Vector2,
speed:Vector2,
color:Color
};

class Main {
static final MAX_BUNNIES = 100000;
static final MAX_BATCH_ELEMENTS = 8192;

static function main() {
var screenWidth:Int = 800;
var screenHeight:Int = 450;

InitWindow(screenWidth, screenHeight, "RAYLIB HAXE!");

var texBunny = LoadTexture("wabbit_alpha.png");

var bunnies:Array<Bunny> = new Array<Bunny>();

SetTargetFPS(60);

while (!WindowShouldClose()) {
if (IsMouseButtonDown(RayLib.MouseButton.LEFT)) {
for (i in 0...100) {
if (bunnies.length < MAX_BUNNIES) {
var bunny:Bunny = {
position: GetMousePosition(),
speed: cast Vector2.create(GetRandomValue(-250, 250) / 60.0, GetRandomValue(-250, 250) / 60.0),
color: cast Color.create(GetRandomValue(50, 240), GetRandomValue(80, 240), GetRandomValue(100, 240), 255)
};
bunnies.push(bunny);
}
}
}

var halfBunnyWidth:Float = texBunny.width / 2;
var halfBunnyHeight:Float = texBunny.height / 2;

for (bunny in bunnies) {
var newPositionX = bunny.position.x + bunny.speed.x;
var newPositionY = bunny.position.y + bunny.speed.y;

var newSpeedX = bunny.speed.x;
var newSpeedY = bunny.speed.y;

if ((newPositionX + halfBunnyWidth > screenWidth) || (newPositionX - halfBunnyWidth < 0))
newSpeedX *= -1;

if ((newPositionY + halfBunnyHeight > screenHeight) || (newPositionY + halfBunnyHeight - 40 < 0))
newSpeedY *= -1;

bunny.position = cast Vector2.create(newPositionX, newPositionY);
bunny.speed = cast Vector2.create(newSpeedX, newSpeedY);
}


// Draw
BeginDrawing();
ClearBackground(RAYWHITE);


for (bunny in bunnies) {
DrawTexture(texBunny, Std.int(bunny.position.x), Std.int(bunny.position.y), bunny.color);
}

DrawRectangle(0, 0, screenWidth, 40, BLACK);
DrawText(Std.string("bunnies: " + bunnies.length), 120, 10, 20, GREEN);
DrawText(Std.string("batched draw calls: " + (1 + bunnies.length / MAX_BATCH_ELEMENTS)), 320, 10, 20, MAROON);
DrawFPS(10, 10);

EndDrawing();
}

CloseWindow();
}
}
Binary file added examples/bunnymark/wabbit_alpha.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion generator/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Main {
];

static function main() {
var source = "https://raw.githubusercontent.com/raysan5/raylib/master/parser/raylib_api.xml"; // must use xml version so function params are ordered
var source = "https://raw.githubusercontent.com/raysan5/raylib/4.5.0/parser/output/raylib_api.xml"; // must use xml version so function params are ordered
var output = "RayLib.hx";

log('building externs from "${source}"');
Expand Down
8 changes: 8 additions & 0 deletions lib/raylib/.github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# These are supported funding model platforms

github: raysan5
patreon: # raylib
open_collective: # Replace with a single Open Collective username
ko_fi: # raysan
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
custom: # Replace with a single custom sponsorship URL
1 change: 1 addition & 0 deletions lib/raylib/.github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: false
40 changes: 40 additions & 0 deletions lib/raylib/.github/ISSUE_TEMPLATE/new-issue-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
name: new issue template
about: generic template for new issues
title: "[module] Short description of the issue/bug/feature"
labels: ''
assignees: ''

---

**WARNING: Please, read this note carefully before submitting a new issue:**

It is important to realise that **this is NOT A SUPPORT FORUM**, this is for reproducible BUGS with raylib ONLY.

There are lots of generous and helpful people ready to help you out on [raylib Discord forum](https://discord.gg/raylib) or [raylib reddit](https://www.reddit.com/r/raylib/).

Remember that asking for support questions here actively takes developer time away from improving raylib.

---

Please, before submitting a new issue verify and check:

- [ ] I tested it on latest raylib version from master branch
- [ ] I checked there is no similar issue already reported
- [ ] My code has no errors or misuse of raylib

### Issue description

*Briefly describe the issue you are experiencing (or the feature you want to see added to raylib). Tell us what you were trying to do and what happened instead. Remember, this is not the best place to ask questions. For questions, go to [raylib Discord server](https://discord.gg/raylib).*

### Environment

*Provide your Platform, Operating System, OpenGL version, GPU details where you experienced the issue.*

### Issue Screenshot

*If possible, provide a screenshot that illustrates the issue. Usually an image is better than a thousand words.*

### Code Example

*Provide minimal reproduction code to test the issue. Please, format the code properly and try to keep it as simple as possible, just focusing on the experienced issue.*
100 changes: 100 additions & 0 deletions lib/raylib/.github/workflows/android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Android

on:
workflow_dispatch:
push:
paths:
- 'src/**'
- 'examples/**'
- '.github/workflows/android.yml'
pull_request:
paths:
- 'src/**'
- 'examples/**'
- '.github/workflows/android.yml'
release:
types: [published]

permissions:
contents: read

jobs:
build:
permissions:
contents: write # for actions/upload-release-asset to upload release asset
runs-on: windows-latest
strategy:
fail-fast: false
max-parallel: 1
matrix:
ARCH: ["arm64", "x86_64"]

env:
RELEASE_NAME: raylib-dev_android_api29_${{ matrix.ARCH }}

steps:
- name: Checkout
uses: actions/checkout@master

- name: Setup Release Version
run: |
echo "RELEASE_NAME=raylib-${{ github.event.release.tag_name }}_android_api29_${{ matrix.ARCH }}" >> $GITHUB_ENV
shell: bash
if: github.event_name == 'release' && github.event.action == 'published'

- name: Setup Android NDK
id: setup-ndk
uses: nttld/setup-ndk@v1
with:
ndk-version: r25
add-to-path: false
env:
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}

- name: Setup Environment
run: |
mkdir build
cd build
mkdir ${{ env.RELEASE_NAME }}
cd ${{ env.RELEASE_NAME }}
mkdir include
mkdir lib
cd ../..

# Generating static + shared library for 64bit arquitectures and API version 29
- name: Build Library
run: |
cd src
make PLATFORM=PLATFORM_ANDROID ANDROID_ARCH=${{ matrix.ARCH }} ANDROID_API_VERSION=29 ANDROID_NDK=${{ env.ANDROID_NDK_HOME }} RAYLIB_LIBTYPE=STATIC RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib"
make PLATFORM=PLATFORM_ANDROID ANDROID_ARCH=${{ matrix.ARCH }} ANDROID_API_VERSION=29 ANDROID_NDK=${{ env.ANDROID_NDK_HOME }} RAYLIB_LIBTYPE=SHARED RAYLIB_RELEASE_PATH="../build/${{ env.RELEASE_NAME }}/lib" -B
cd ..
shell: cmd

- name: Generate Artifacts
run: |
cp -v ./src/raylib.h ./build/${{ env.RELEASE_NAME }}/include
cp -v ./src/raymath.h ./build/${{ env.RELEASE_NAME }}/include
cp -v ./src/rlgl.h ./build/${{ env.RELEASE_NAME }}/include
cp -v ./CHANGELOG ./build/${{ env.RELEASE_NAME }}/CHANGELOG
cp -v ./README.md ./build/${{ env.RELEASE_NAME }}/README.md
cp -v ./LICENSE ./build/${{ env.RELEASE_NAME }}/LICENSE
cd build
tar -czvf ${{ env.RELEASE_NAME }}.tar.gz ${{ env.RELEASE_NAME }}

- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ env.RELEASE_NAME }}.tar.gz
path: ./build/${{ env.RELEASE_NAME }}.tar.gz

- name: Upload Artifact to Release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./build/${{ env.RELEASE_NAME }}.tar.gz
asset_name: ${{ env.RELEASE_NAME }}.tar.gz
asset_content_type: application/gzip
if: github.event_name == 'release' && github.event.action == 'published'

Loading