-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 91532be
Showing
11 changed files
with
531 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Example Maven project for Jaylib | ||
|
||
You can import this project into IntelliJ or Eclipse. | ||
|
||
## Use it to run the included examples in IntelliJ | ||
|
||
Right-click on the example and select `run`. | ||
|
||
## Use it to run the included examples from the command line | ||
|
||
mvn compile exec:java -Dmain.class="examples.HeightMap" | ||
mvn compile exec:java -Dmain.class="examples.CubicMap" | ||
|
||
## Use it as the basis of your own game. | ||
|
||
Edit `Main.java` with your own code. (You can delete the examples.) Then | ||
|
||
To run: | ||
|
||
mvn compile exec:java |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.example</groupId> | ||
<artifactId>jaylib-maven-example-project</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<properties> | ||
<maven.compiler.source>17</maven.compiler.source> | ||
<maven.compiler.target>17</maven.compiler.target> | ||
<main.class>Main</main.class> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>exec-maven-plugin</artifactId> | ||
<version>3.0.0</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>exec</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<mainClass>${main.class}</mainClass> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<repositories> | ||
<repository> | ||
<id>electron-studio-jaylib</id> | ||
<url>https://dl.cloudsmith.io/public/electron-studio/jaylib/maven/</url> | ||
<releases> | ||
<enabled>true</enabled> | ||
<updatePolicy>always</updatePolicy> | ||
</releases> | ||
<snapshots> | ||
<enabled>true</enabled> | ||
<updatePolicy>always</updatePolicy> | ||
</snapshots> | ||
</repository> | ||
</repositories> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>uk.co.electronstudio.jaylib</groupId> | ||
<artifactId>jaylib</artifactId> | ||
<version>3.7.0</version> | ||
</dependency> | ||
|
||
|
||
<dependency> | ||
<groupId>uk.co.electronstudio.jaylib</groupId> | ||
<artifactId>jaylib-natives-windows-x86_64</artifactId> | ||
<version>3.7.0</version> | ||
</dependency> | ||
|
||
|
||
<dependency> | ||
<groupId>uk.co.electronstudio.jaylib</groupId> | ||
<artifactId>jaylib-natives-macosx-x86_64</artifactId> | ||
<version>3.7.0</version> | ||
</dependency> | ||
|
||
|
||
<dependency> | ||
<groupId>uk.co.electronstudio.jaylib</groupId> | ||
<artifactId>jaylib-natives-linux-x86_64</artifactId> | ||
<version>3.7.0</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
|
||
</project> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import static com.raylib.Jaylib.RAYWHITE; | ||
import static com.raylib.Jaylib.VIOLET; | ||
import static com.raylib.Raylib.*; | ||
|
||
public class Main { | ||
public static void main(String args[]) { | ||
InitWindow(800, 450, "Demo"); | ||
SetTargetFPS(60); | ||
Camera3D camera = new Camera3D() | ||
._position(new Vector3().x(18).y(16).z(18)) | ||
.target(new Vector3()) | ||
.up(new Vector3().x(0).y(1).z(0)) | ||
.fovy(45).projection(CAMERA_PERSPECTIVE); | ||
SetCameraMode(camera, CAMERA_ORBITAL); | ||
|
||
while (!WindowShouldClose()) { | ||
UpdateCamera(camera); | ||
BeginDrawing(); | ||
ClearBackground(RAYWHITE); | ||
BeginMode3D(camera); | ||
DrawGrid(20, 1.0f); | ||
EndMode3D(); | ||
DrawText("Hello world", 190, 200, 20, VIOLET); | ||
DrawFPS(20, 20); | ||
EndDrawing(); | ||
} | ||
CloseWindow(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package examples; /******************************************************************************************* | ||
* | ||
* raylib [models] example - Cubicmap loading and drawing | ||
* | ||
* This example has been created using raylib 1.8 (www.raylib.com) | ||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | ||
* | ||
* Copyright (c) 2015 Ramon Santamaria (@raysan5) | ||
* | ||
********************************************************************************************/ | ||
|
||
|
||
import static com.raylib.Jaylib.*; | ||
import static com.raylib.Raylib.Vector2; | ||
import static com.raylib.Raylib.Vector3; | ||
import static com.raylib.Raylib.*; | ||
|
||
public class CubicMap { | ||
|
||
public static void main(String []args){ | ||
// Initialization | ||
//-------------------------------------------------------------------------------------- | ||
final int screenWidth = 800; | ||
final int screenHeight = 450; | ||
|
||
InitWindow(screenWidth, screenHeight, "raylib [models] example - cubesmap loading and drawing"); | ||
|
||
// Define the camera to look into our 3d world | ||
//Camera3D camera = new Camera(new Vector3(16.0f, 14.0f, 16.0f), new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 1.0f, 0.0f), 45.0f, 0); | ||
Camera3D camera = new Camera3D() | ||
._position(new Vector3().x(18).y(16).z(18)) | ||
.target(new Vector3()) | ||
.up(new Vector3().x(0).y(1).z(0)) | ||
.fovy(45).projection(CAMERA_PERSPECTIVE); | ||
|
||
Image image = LoadImage("resources/cubicmap.png"); // Load cubicmap image (RAM) | ||
Texture cubicmap = LoadTextureFromImage(image); // Convert image to texture to display (VRAM) | ||
|
||
Mesh mesh = GenMeshCubicmap(image, new Vector3().x(1.0f).y(1.0f).z(1.0f)); | ||
Model model = LoadModelFromMesh(mesh); | ||
|
||
// NOTE: By default each cube is mapped to one part of texture atlas | ||
Texture texture = LoadTexture("resources/cubicmap_atlas.png"); // Load map texture | ||
model.materials().maps().texture(texture); // Set map diffuse texture | ||
|
||
Vector3 mapPosition = new Vector3().x(-16.0f).y(0.0f).z(-8.0f); // Set model position | ||
|
||
UnloadImage(image); // Unload cubesmap image from RAM, already uploaded to VRAM | ||
|
||
SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode | ||
|
||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second | ||
//-------------------------------------------------------------------------------------- | ||
|
||
// Main game loop | ||
while (!WindowShouldClose()) // Detect window close button or ESC key | ||
{ | ||
// Update | ||
//---------------------------------------------------------------------------------- | ||
UpdateCamera(camera); // Update camera | ||
//---------------------------------------------------------------------------------- | ||
|
||
// Draw | ||
//---------------------------------------------------------------------------------- | ||
BeginDrawing(); | ||
|
||
ClearBackground(RAYWHITE); | ||
|
||
BeginMode3D(camera); | ||
|
||
DrawModel(model, mapPosition, 1.0f, WHITE); | ||
|
||
EndMode3D(); | ||
|
||
DrawTextureEx(cubicmap, new Vector2().x(screenWidth - cubicmap.width() * 4 - 20).y( 20), 0.0f, 4.0f, WHITE); | ||
DrawRectangleLines(screenWidth - cubicmap.width() * 4 - 20, 20, cubicmap.width() * 4, cubicmap.height() * 4, GREEN); | ||
|
||
DrawText("cubicmap image used to", 658, 90, 10, GRAY); | ||
DrawText("generate map 3d model", 658, 104, 10, GRAY); | ||
|
||
DrawFPS(10, 10); | ||
|
||
EndDrawing(); | ||
//---------------------------------------------------------------------------------- | ||
} | ||
|
||
// De-Initialization | ||
//-------------------------------------------------------------------------------------- | ||
UnloadTexture(cubicmap); // Unload cubicmap texture | ||
UnloadTexture(texture); // Unload map texture | ||
UnloadModel(model); // Unload map model | ||
|
||
CloseWindow(); // Close window and OpenGL context | ||
//-------------------------------------------------------------------------------------- | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package examples; | ||
|
||
|
||
import static com.raylib.Jaylib.*; | ||
import static com.raylib.Raylib.Vector3; | ||
import static com.raylib.Raylib.*; | ||
|
||
|
||
public class HeightMap { | ||
public static void main(String args[]) { | ||
InitWindow(800, 450, "Raylib static texture test"); | ||
SetTargetFPS(60); | ||
Camera3D camera = new Camera3D() | ||
._position(new Vector3().x(18).y(16).z(18)) | ||
.target(new Vector3()) | ||
.up(new Vector3().x(0).y(1).z(0)) | ||
.fovy(45).projection(CAMERA_PERSPECTIVE); | ||
|
||
Image image = LoadImage("resources/heightmap.png"); | ||
Texture texture = LoadTextureFromImage(image); | ||
Mesh mesh = GenMeshHeightmap(image, new Vector3().x(16).y(8).z(16)); | ||
Model model = LoadModelFromMesh(mesh); | ||
model.materials().maps().position(0).texture(texture); | ||
|
||
|
||
UnloadImage(image); | ||
SetCameraMode(camera, CAMERA_ORBITAL); | ||
|
||
while(!WindowShouldClose()){ | ||
UpdateCamera(camera); | ||
BeginDrawing(); | ||
ClearBackground(RAYWHITE); | ||
BeginMode3D(camera); | ||
DrawModel(model, new Vector3().x(-8).y(0).z(-8), 1, RED); | ||
DrawGrid(20, 1.0f); | ||
EndMode3D(); | ||
DrawText("This mesh should be textured", 190, 200, 20, VIOLET); | ||
DrawFPS(20, 20); | ||
EndDrawing(); | ||
} | ||
CloseWindow(); | ||
} | ||
} |
Oops, something went wrong.