Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
011ef82
fix(JS port): correct the worker<->host barrier ownership model (#5145)
shai-almog Jun 2, 2026
5d26163
fix(JS port): recover worker<->host response-cross + lost-response pa…
shai-almog Jun 2, 2026
8877282
feat(gpu): portable 3D/shader API skeleton (com.codename1.gpu)
shai-almog Jun 2, 2026
56d5276
feat(gpu): JavaSE simulator backend (software rasterizer)
shai-almog Jun 2, 2026
fe8a87e
test(gpu): 3D screenshot + animation tests in hellocodenameone
shai-almog Jun 2, 2026
26583b0
feat(gpu): Android (GLES2), iOS (Metal), JavaScript (WebGL) backends
shai-almog Jun 2, 2026
4b0337c
docs: developer guide chapter for the 3D graphics and shader API
shai-almog Jun 2, 2026
5ae7507
ci(JS port): upload delivered screenshots so goldens can be seeded fr…
shai-almog Jun 2, 2026
00baf08
fix(gpu): CI fixes - SpotBugs, vale docs, iOS animation-test hang
shai-almog Jun 2, 2026
a2565e9
fix(gpu): PMD + LanguageTool gates; skip 3D tests on time-boxed iOS/J…
shai-almog Jun 2, 2026
9317134
test(JS port #5145): drop obsolete HTML5 chunk-truncation self-skip (…
shai-almog Jun 3, 2026
1a320b1
fix(gpu): capture live 3D GPU scenes in screenshots (Android + JS), u…
shai-almog Jun 3, 2026
5da5b14
test(JS port #5145): seed StickyHeader x3 + StatusBar JS goldens + ra…
shai-almog Jun 3, 2026
bbb648a
test(gpu): multi-stage 3D animation grid; harden static captures vs c…
shai-almog Jun 3, 2026
6a24100
fix(gpu): iOS Metal cube invisible - adapt GL clip space to Metal
shai-almog Jun 3, 2026
82992dd
diag(gpu): temporary iOS Metal 3D draw/frame logging (CN1SS-prefixed)
shai-almog Jun 3, 2026
4e9cc5d
diag(gpu): CN1SS-prefixed iOS draw/frame logging to locate missing cube
shai-almog Jun 3, 2026
5ffdd7a
fix(JS port): serialize screenshot canvas read with a capture-scoped …
shai-almog Jun 3, 2026
c53cb62
diag(gpu): granular iOS draw step logging to locate NPE
shai-almog Jun 3, 2026
5fc4473
test(JS port): reseed TabsTheme_light golden with correct content
shai-almog Jun 3, 2026
a90c891
test(JS port): un-park ChatInput/ChatView screenshot tests
shai-almog Jun 3, 2026
2ecc688
diag(gpu): sub-step logging in iOS getOrCreatePipeline
shai-almog Jun 3, 2026
61b6943
Revert "test(JS port): un-park ChatInput/ChatView screenshot tests"
shai-almog Jun 3, 2026
3b417c5
fix(gpu): iOS Metal pipeline native NPE - add plain-form C symbol
shai-almog Jun 3, 2026
05bdeed
fix(JS port): give DualAppearance tests their full 30s deadline; un-p…
shai-almog Jun 3, 2026
930f743
test(JS port): reseed ChatInput/ChatView/TabsTheme_dark goldens with …
shai-almog Jun 3, 2026
042f4ec
fix(gpu): iOS pipeline native - real impl in plain symbol, _R_ delegates
shai-almog Jun 3, 2026
91d6ee2
test(JS port): reseed ToolbarTheme_dark golden with correct content
shai-almog Jun 3, 2026
119a0ff
fix(gpu): iOS Metal blank 3D - retain pipeline cache; strip diagnostics
shai-almog Jun 3, 2026
caac758
diag(JS port): dump pending host-call symbols + captureGate state on …
shai-almog Jun 3, 2026
850eb82
Merge remote-tracking branch 'origin/master' into feature/gpu-3d-api
shai-almog Jun 3, 2026
df68c54
perf(JS port): cache canvasContentScore per canvas to stop O(700) get…
shai-almog Jun 3, 2026
179bb60
diag(JS port): dump timed-wakeup details on frozen worker (wedge is N…
shai-almog Jun 3, 2026
a15bea8
diag(JS port): only dump frozen-worker state after a SUSTAINED (>=7.5…
shai-almog Jun 3, 2026
b1f9e88
fix(JS port): an uncaught green-thread exception must not halt the wh…
shai-almog Jun 4, 2026
68266e2
test(JS port): un-park Chart{CombinedXY,Transform,Rotated} screenshot…
shai-almog Jun 4, 2026
49211b2
Revert "test(JS port): un-park Chart{CombinedXY,Transform,Rotated} sc…
shai-almog Jun 4, 2026
0e80bb9
Merge remote-tracking branch 'origin/fix-jsport-barrier-model' into f…
shai-almog Jun 4, 2026
bb0745a
feat(JS port): exact 64-bit long arithmetic (Java long == JS BigInt)
shai-almog Jun 4, 2026
732e9e5
fix(JS port): coerce long->Number at scheduler/host boundaries for Bi…
shai-almog Jun 4, 2026
fec55b9
perf(JS port): switch exact longs from BigInt to hi/lo Long objects (…
shai-almog Jun 4, 2026
50f4647
perf(JS port): cut hi/lo Long allocation in hot paths (cmp alloc-free…
shai-almog Jun 4, 2026
f1330bf
Merge remote-tracking branch 'origin/master' into fix-jsport-barrier-…
shai-almog Jun 4, 2026
dabbe2d
Merge branch 'fix-jsport-barrier-model' into js-port-exact-longs
shai-almog Jun 4, 2026
6f3f2cd
fix(gpu): iOS Metal cube rendered inside-out - flip front-facing winding
shai-almog Jun 4, 2026
3c91ae1
Merge remote-tracking branch 'origin/fix-jsport-barrier-model' into f…
shai-almog Jun 4, 2026
163f414
test(JS port): reseed chart goldens fixed by exact 64-bit longs
shai-almog Jun 4, 2026
470bbc2
fix(JS port): self-heal the timed-wakeup timer to recover from a stal…
shai-almog Jun 4, 2026
232109c
JS WebGL 3D backend: real geometry rendering end-to-end
shai-almog Jun 4, 2026
496d574
JS screenshot goldens for the three GPU 3D tests
shai-almog Jun 4, 2026
3d6630c
GPU API cleanup: single GpuImplementation seam, isGpuSupported, impl-…
shai-almog Jun 4, 2026
0308495
glTF mesh-loading API + textured model screenshot test
shai-almog Jun 4, 2026
5f044a5
docs: add 3D Graphics chapter to the developer guide
shai-almog Jun 4, 2026
d8dfb52
test(JS port): un-park Chart{CombinedXY,Transform,Rotated} (exact-lon…
shai-almog Jun 4, 2026
18686a8
test(JS port): re-park ChartCombinedXY (non-terminating); keep Transf…
shai-almog Jun 4, 2026
acd6f57
Use the Khronos BoomBox glTF sample as the 3D model test; load embedd…
shai-almog Jun 4, 2026
42ec72f
Merge remote-tracking branch 'origin/fix-jsport-barrier-model' into f…
shai-almog Jun 4, 2026
9e03ad5
docs: fix Vale style issues in the 3D Graphics chapter
shai-almog Jun 4, 2026
fbd14e6
Use Util.cleanup in GltfLoader; add image callouts to the 3D guide ch…
shai-almog Jun 4, 2026
7aa76af
JavaSE simulator: real OpenGL (JOGL) 3D backend with software fallback
shai-almog Jun 4, 2026
71e3f54
docs: accept Khronos/BoomBox/JOGL in the dev-guide LanguageTool list
shai-almog Jun 4, 2026
7708836
Merge remote-tracking branch 'origin/master' into feature/gpu-3d-api
shai-almog Jun 8, 2026
55e91ba
Win32/D3D: HLSL shader generator (generalize engine-managed shaders t…
shai-almog Jun 8, 2026
d2f3bfa
Win32: Direct3D 11 backend for the portable 3D API
shai-almog Jun 8, 2026
d620add
Win32/D3D: offscreen render test + gl3dCaptureToFile
shai-almog Jun 8, 2026
5cc4319
JS/GL: keep canvas pixel size Java-side (barrier-read lint)
shai-almog Jun 8, 2026
0d16e43
JavaSE/GL: confine JOGL to Maven build, reflective load for Ant
shai-almog Jun 8, 2026
705e027
Win32/D3D: drop C++ STL from cn1_windows_d3d.cpp (clean-target cross-…
shai-almog Jun 8, 2026
c13afd4
gpu: fix SpotBugs violations in GltfLoader
shai-almog Jun 8, 2026
e18b1c1
JavaSE/GL: use JOGL from Maven Central (drop flaky jogamp.org repo)
shai-almog Jun 8, 2026
d838f0c
gpu: preserve cause when rethrowing glTF parse failure (PMD)
shai-almog Jun 8, 2026
c418f24
Android: add GPU 3D screenshot baselines (Gpu3D cube/textured/model/a…
shai-almog Jun 8, 2026
8e8107b
gpu: fix upside-down 3D render on Metal (iOS/Mac) and Direct3D (Windows)
shai-almog Jun 8, 2026
b588e2f
gpu/cn1ss: per-test screenshot tolerance + Mac Native 3D goldens
shai-almog Jun 8, 2026
d20e2b6
iOS Metal: add upright 3D screenshot goldens + tolerance
shai-almog Jun 8, 2026
4eb2227
gpu tests: skip screenshot when GPU 3D is unsupported (iOS GL backend)
shai-almog Jun 8, 2026
abbd815
Merge remote-tracking branch 'origin/master' into feature/gpu-3d-api
shai-almog Jun 8, 2026
bbdd9aa
gpu: fix 3D peer bleeding into later screenshots (JS + Android)
shai-almog Jun 8, 2026
02f26e9
docs: flesh out the 3D graphics guide (Win32 D3D, backends, screenshots)
shai-almog Jun 8, 2026
2b79f6b
gpu(JS): stop stale 3D canvas bleeding into later screenshots (real fix)
shai-almog Jun 8, 2026
44561e9
iOS: regenerate theme goldens for new .res + dispose RenderView in GP…
shai-almog Jun 8, 2026
2cb2818
mac-native: regenerate theme goldens for current build theme metrics
shai-almog Jun 8, 2026
e1c178f
gpu tests: revert cleanup() (broke Windows capture, didn't fix iOS De…
shai-almog Jun 8, 2026
691964c
Merge remote-tracking branch 'origin/master' into feature/gpu-3d-api
shai-almog Jun 8, 2026
fc4a954
Add Windows 3D goldens; run 3D screenshot tests last to keep DesktopM…
shai-almog Jun 8, 2026
2cd01f4
Merge remote-tracking branch 'origin/master' into feature/gpu-3d-api
shai-almog Jun 8, 2026
61768f8
Revert StatusBar theme change (restore device status-bar space); JS s…
shai-almog Jun 8, 2026
aa31389
mac-native: reseed theme goldens to match the reverted StatusBar them…
shai-almog Jun 8, 2026
58b29e0
Move 3D screenshot tests before OrientationLock (fix iOS + JS at once)
shai-almog Jun 8, 2026
757a43e
ci(js): drop JS goldens for the two force-skipped chart/picker tests
shai-almog Jun 9, 2026
b5fa1b9
ci(mac-native): tolerance sidecar for chart-transform Metal AA noise
shai-almog Jun 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
177 changes: 177 additions & 0 deletions CodenameOne/src/com/codename1/gpu/Camera.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
/*
* Copyright (c) 2026, Codename One and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Codename One designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*/
package com.codename1.gpu;

/// A perspective or orthographic camera. The camera builds a view matrix from an
/// eye position, a look-at target and an up vector, and a projection matrix from
/// its lens parameters. Combine the two through `getViewProjection()` which the
/// device multiplies with each model matrix.
public final class Camera {
private boolean perspective = true;
private float fovYRadians = (float) Math.toRadians(60.0);
private float aspect = 1.0f;
private float near = 0.1f;
private float far = 100.0f;
private float orthoHeight = 2.0f;

private float eyeX = 0.0f;
private float eyeY = 0.0f;
private float eyeZ = 5.0f;
private float targetX = 0.0f;
private float targetY = 0.0f;
private float targetZ = 0.0f;
private float upX = 0.0f;
private float upY = 1.0f;
private float upZ = 0.0f;

private final float[] view = Matrix4.identity();
private final float[] projection = Matrix4.identity();
private final float[] viewProjection = Matrix4.identity();
private boolean dirty = true;

/// Configures a perspective projection.
///
/// #### Parameters
///
/// - `fovYDegrees`: the vertical field of view in degrees
///
/// - `near`: the near clip plane distance
///
/// - `far`: the far clip plane distance
///
/// #### Returns
///
/// this camera for chaining
public Camera setPerspective(float fovYDegrees, float near, float far) {
this.perspective = true;
this.fovYRadians = (float) Math.toRadians(fovYDegrees);
this.near = near;
this.far = far;
dirty = true;
return this;
}

/// Configures an orthographic projection.
///
/// #### Parameters
///
/// - `height`: the visible world height; width is derived from the aspect
///
/// - `near`: the near clip plane distance
///
/// - `far`: the far clip plane distance
///
/// #### Returns
///
/// this camera for chaining
public Camera setOrthographic(float height, float near, float far) {
this.perspective = false;
this.orthoHeight = height;
this.near = near;
this.far = far;
dirty = true;
return this;
}

/// Sets the viewport aspect ratio (width / height). The `RenderView`
/// normally calls this from `Renderer.onResize`.
///
/// #### Parameters
///
/// - `aspect`: the width / height ratio
///
/// #### Returns
///
/// this camera for chaining
public Camera setAspect(float aspect) {
this.aspect = aspect;
dirty = true;
return this;
}

/// Sets the eye (camera) world position.
public Camera setPosition(float x, float y, float z) {
this.eyeX = x;
this.eyeY = y;
this.eyeZ = z;
dirty = true;
return this;
}

/// Sets the world space point the camera looks at.
public Camera setTarget(float x, float y, float z) {
this.targetX = x;
this.targetY = y;
this.targetZ = z;
dirty = true;
return this;
}

/// Sets the camera up vector.
public Camera setUp(float x, float y, float z) {
this.upX = x;
this.upY = y;
this.upZ = z;
dirty = true;
return this;
}

/// Returns the eye (camera) world space x coordinate.
public float getEyeX() {
return eyeX;
}

/// Returns the eye (camera) world space y coordinate.
public float getEyeY() {
return eyeY;
}

/// Returns the eye (camera) world space z coordinate.
public float getEyeZ() {
return eyeZ;
}

/// Returns the 16 element column-major view matrix.
public float[] getViewMatrix() {
recompute();
return view;
}

/// Returns the 16 element column-major projection matrix.
public float[] getProjectionMatrix() {
recompute();
return projection;
}

/// Returns the 16 element column-major combined projection * view matrix.
public float[] getViewProjection() {
recompute();
return viewProjection;
}

private void recompute() {
if (!dirty) {
return;
}
float[] v = Matrix4.lookAt(eyeX, eyeY, eyeZ, targetX, targetY, targetZ, upX, upY, upZ);
Matrix4.copy(v, view);
float[] p;
if (perspective) {
p = Matrix4.perspective(fovYRadians, aspect, near, far);
} else {
float halfH = orthoHeight * 0.5f;
float halfW = halfH * aspect;
p = Matrix4.ortho(-halfW, halfW, -halfH, halfH, near, far);
}
Matrix4.copy(p, projection);
Matrix4.multiply(projection, view, viewProjection);
dirty = false;
}
}
Loading
Loading