forked from LWJGL/lwjgl3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(par): add par_octasphere.h bindings
- Loading branch information
Showing
17 changed files
with
1,913 additions
and
125 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
37 changes: 37 additions & 0 deletions
37
modules/lwjgl/par/src/generated/c/org_lwjgl_util_par_ParOctasphere.c
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,37 @@ | ||
/* | ||
* Copyright LWJGL. All rights reserved. | ||
* License terms: https://www.lwjgl.org/license | ||
* MACHINE GENERATED FILE, DO NOT EDIT | ||
*/ | ||
#include "common_tools.h" | ||
#define PAR_OCTASPHERE_IMPLEMENTATION | ||
#include "par_octasphere.h" | ||
|
||
EXTERN_C_ENTER | ||
|
||
JNIEXPORT void JNICALL Java_org_lwjgl_util_par_ParOctasphere_npar_1octasphere_1get_1counts__JJJ(JNIEnv *__env, jclass clazz, jlong configAddress, jlong num_indicesAddress, jlong num_verticesAddress) { | ||
par_octasphere_config const *config = (par_octasphere_config const *)(intptr_t)configAddress; | ||
uint32_t *num_indices = (uint32_t *)(intptr_t)num_indicesAddress; | ||
uint32_t *num_vertices = (uint32_t *)(intptr_t)num_verticesAddress; | ||
UNUSED_PARAMS(__env, clazz) | ||
par_octasphere_get_counts(config, num_indices, num_vertices); | ||
} | ||
|
||
JNIEXPORT void JNICALL Java_org_lwjgl_util_par_ParOctasphere_npar_1octasphere_1populate(JNIEnv *__env, jclass clazz, jlong configAddress, jlong meshAddress) { | ||
par_octasphere_config const *config = (par_octasphere_config const *)(intptr_t)configAddress; | ||
par_octasphere_mesh *mesh = (par_octasphere_mesh *)(intptr_t)meshAddress; | ||
UNUSED_PARAMS(__env, clazz) | ||
par_octasphere_populate(config, mesh); | ||
} | ||
|
||
JNIEXPORT void JNICALL Java_org_lwjgl_util_par_ParOctasphere_npar_1octasphere_1get_1counts__J_3I_3I(JNIEnv *__env, jclass clazz, jlong configAddress, jintArray num_indicesAddress, jintArray num_verticesAddress) { | ||
par_octasphere_config const *config = (par_octasphere_config const *)(intptr_t)configAddress; | ||
jint *num_indices = (*__env)->GetIntArrayElements(__env, num_indicesAddress, NULL); | ||
jint *num_vertices = (*__env)->GetIntArrayElements(__env, num_verticesAddress, NULL); | ||
UNUSED_PARAMS(__env, clazz) | ||
par_octasphere_get_counts(config, (uint32_t *)num_indices, (uint32_t *)num_vertices); | ||
(*__env)->ReleaseIntArrayElements(__env, num_verticesAddress, num_vertices, 0); | ||
(*__env)->ReleaseIntArrayElements(__env, num_indicesAddress, num_indices, 0); | ||
} | ||
|
||
EXTERN_C_EXIT |
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
99 changes: 99 additions & 0 deletions
99
modules/lwjgl/par/src/generated/java/org/lwjgl/util/par/ParOctasphere.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,99 @@ | ||
/* | ||
* Copyright LWJGL. All rights reserved. | ||
* License terms: https://www.lwjgl.org/license | ||
* MACHINE GENERATED FILE, DO NOT EDIT | ||
*/ | ||
package org.lwjgl.util.par; | ||
|
||
import java.nio.*; | ||
|
||
import org.lwjgl.system.*; | ||
|
||
import static org.lwjgl.system.Checks.*; | ||
import static org.lwjgl.system.MemoryUtil.*; | ||
|
||
/** | ||
* Bindings to <a target="_blank" href="https://prideout.net/blog/octasphere">par_octasphere.h</a>, a tiny malloc-free library that generates triangle meshes for spheres, | ||
* rounded boxes, and capsules. | ||
* | ||
* <p>Usage example:</p> | ||
* | ||
* <pre><code> | ||
* // Specify a 100x100x20 rounded box. | ||
* const par_octasphere_config cfg = { | ||
* .corner_radius = 5, | ||
* .width = 100, | ||
* .height = 100, | ||
* .depth = 20, | ||
* .num_subdivisions = 3, | ||
* }; | ||
* | ||
* // Allocate memory for the mesh and opt-out of normals. | ||
* uint32_t num_indices; | ||
* uint32_t num_vertices; | ||
* par_octasphere_get_counts(&cfg, &num_indices, &num_vertices); | ||
* par_octasphere_mesh mesh = { | ||
* .positions = malloc(sizeof(float) * 3 * num_vertices), | ||
* .normals = NULL, | ||
* .texcoords = malloc(sizeof(float) * 2 * num_vertices), | ||
* .indices = malloc(sizeof(uint16_t) * num_indices), | ||
* }; | ||
* | ||
* // Generate vertex coordinates, UV's, and triangle indices. | ||
* par_octasphere_populate(&cfg, &mesh);</code></pre> | ||
* | ||
* <p>To generate a sphere: set width, height, and depth to 0 in your configuration. To generate a capsule shape: set only two of these dimensions to 0.</p> | ||
*/ | ||
public class ParOctasphere { | ||
|
||
public static final int par_octasphere_PAR_OCTASPHERE_MAX_SUBDIVISIONS = 5; | ||
|
||
/** {@code par_octasphere_uv_mode} */ | ||
public static final int par_octasphere_UV_LATLONG = 0; | ||
|
||
/** {@code par_octasphere_normals_mode} */ | ||
public static final int par_octasphere_NORMALS_SMOOTH = 0; | ||
|
||
static { LibPar.initialize(); } | ||
|
||
protected ParOctasphere() { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
// --- [ par_octasphere_get_counts ] --- | ||
|
||
/** Unsafe version of: {@link #par_octasphere_get_counts get_counts} */ | ||
public static native void npar_octasphere_get_counts(long config, long num_indices, long num_vertices); | ||
|
||
/** Computes the maximum possible number of indices and vertices for the given octasphere config. */ | ||
public static void par_octasphere_get_counts(@NativeType("par_octasphere_config const *") ParOctasphereConfig config, @NativeType("uint32_t *") IntBuffer num_indices, @NativeType("uint32_t *") IntBuffer num_vertices) { | ||
if (CHECKS) { | ||
check(num_indices, 1); | ||
check(num_vertices, 1); | ||
} | ||
npar_octasphere_get_counts(config.address(), memAddress(num_indices), memAddress(num_vertices)); | ||
} | ||
|
||
// --- [ par_octasphere_populate ] --- | ||
|
||
/** Unsafe version of: {@link #par_octasphere_populate populate} */ | ||
public static native void npar_octasphere_populate(long config, long mesh); | ||
|
||
/** Populates a pre-allocated mesh structure with indices and vertices. */ | ||
public static void par_octasphere_populate(@NativeType("par_octasphere_config const *") ParOctasphereConfig config, @NativeType("par_octasphere_mesh *") ParOctasphereMesh mesh) { | ||
npar_octasphere_populate(config.address(), mesh.address()); | ||
} | ||
|
||
/** Array version of: {@link #npar_octasphere_get_counts} */ | ||
public static native void npar_octasphere_get_counts(long config, int[] num_indices, int[] num_vertices); | ||
|
||
/** Array version of: {@link #par_octasphere_get_counts get_counts} */ | ||
public static void par_octasphere_get_counts(@NativeType("par_octasphere_config const *") ParOctasphereConfig config, @NativeType("uint32_t *") int[] num_indices, @NativeType("uint32_t *") int[] num_vertices) { | ||
if (CHECKS) { | ||
check(num_indices, 1); | ||
check(num_vertices, 1); | ||
} | ||
npar_octasphere_get_counts(config.address(), num_indices, num_vertices); | ||
} | ||
|
||
} |
Oops, something went wrong.