Skip to content

Commit bb36f33

Browse files
authored
renderer: refactor to address the stencil buffer issues (#92)
- Introduce new `ContextGLHost`/`ContextGLApp` classes and rename storage methods (`on*`) to replace legacy context storage. - Add `iterateContentRenderers` API and extend inspector with a `/json/statistics` endpoint. - Add framebuffer‐attachment helpers, update debug output (including stencil state), and adjust project build/configuration files.
1 parent aaf35fa commit bb36f33

27 files changed

+1727
-886
lines changed

.vscode/c_cpp_properties.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,34 @@
1212
"cppStandard": "c++20",
1313
"intelliSenseMode": "macos-clang-arm64",
1414
"configurationProvider": "ms-vscode.cmake-tools"
15+
},
16+
{
17+
"name": "Android",
18+
"defines": [
19+
"ANDROID",
20+
"__ANDROID__",
21+
"__ANDROID_API__=26"
22+
],
23+
"compilerPath": "${env:ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android26-clang++",
24+
"compileCommands": "${workspaceFolder}/build/targets/android/compile_commands.json",
25+
"cStandard": "c17",
26+
"cppStandard": "c++20",
27+
"intelliSenseMode": "linux-gcc-arm64",
28+
"includePath": [
29+
"${env:ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include",
30+
"${env:ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/aarch64-linux-android",
31+
"${env:ANDROID_NDK_HOME}/sources/cxx-stl/llvm-libc++/include",
32+
"${env:ANDROID_NDK_HOME}/sources/android/support/include"
33+
],
34+
"browse": {
35+
"path": [
36+
"${workspaceFolder}",
37+
"${env:ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include",
38+
"${env:ANDROID_NDK_HOME}/sources/cxx-stl/llvm-libc++/include"
39+
],
40+
"limitSymbolsToIncludedHeaders": true
41+
},
42+
"configurationProvider": "ms-vscode.cmake-tools"
1543
}
1644
],
1745
"version": 4

build/configure.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ CMAKE_CMD=(
234234
-S "$SOURCE_DIR"
235235
-B "$BUILD_DIR"
236236
-DCMAKE_BUILD_TYPE="$BUILD_TYPE"
237+
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
237238
)
238239

239240
# Add platform-specific parameters
@@ -249,7 +250,6 @@ elif [[ $TARGET == "darwin" ]]; then
249250
-G "$GENERATOR"
250251
-DCMAKE_CXX_COMPILER="$CXX_COMPILER"
251252
-DCMAKE_OSX_DEPLOYMENT_TARGET="$OSX_DEPLOYMENT_TARGET"
252-
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
253253
)
254254
fi
255255

makefile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ CRATES_FORCE_REBUILD ?= no
2424
# Define the INSPECTOR flag (default is no) that will build the inspector
2525
INSPECTOR ?= no
2626

27-
# Update the flags if RELEASE is set to yes
28-
ifeq ($(RELEASE), yes)
29-
CLEAN := yes
30-
endif
31-
3227
# This makefile defines a function `build_crates` to build Rust crates using Cargo.
3328
#
3429
# Usage:

src/client/builtin_scene/texture_altas.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,12 @@ namespace builtin_scene
4242
}
4343

4444
// Initialize the texture atlas with the default values.
45-
glContext->texImage3D(WebGLTexture3DTarget::kTexture2DArray,
46-
0,
47-
WEBGL2_RGBA8,
48-
width,
49-
height,
50-
kMaxLayerCount,
51-
0,
52-
WebGLTextureFormat::kRGBA,
53-
WebGLPixelType::kUnsignedByte,
54-
nullptr);
45+
glContext->texStorage3D(WebGLTexture3DTarget::kTexture2DArray,
46+
1,
47+
WEBGL2_RGBA8,
48+
width,
49+
height,
50+
kMaxLayerCount);
5551
glContext->generateMipmap(WebGLTextureTarget::kTexture2DArray);
5652
}
5753
glContext->bindTexture(WebGLTextureTarget::kTexture2DArray, nullptr);

src/common/classes.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ class TrContentRuntime;
77
class TrSoundSource;
88
class TrMediaManager;
99

10+
// Inspector classes
11+
class TrInspector;
12+
1013
namespace renderer
1114
{
1215
class TrRenderer;

src/common/debug.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ IUnityLog *GET_UNITY_LOG_HANDLE();
5353
#define LOG_TAG_CLIENT_CANVAS "jsar.client.canvas"
5454
#endif
5555

56+
/**
57+
* Enable the performance counter for the runtime statistics.
58+
*/
59+
#define TR_ENABLE_PERF_COUNTER 1
60+
// Uncomment the following line to enable performance counter for the runtime statistics.
61+
#undef TR_ENABLE_PERF_COUNTER
62+
5663
/**
5764
* Print a debug message to the console.
5865
*/

src/examples/desktop_opengl.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,12 @@ namespace jsar::example
161161
}
162162
}
163163

164-
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
165-
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
166-
glfwWindowHint(GLFW_SAMPLES, samples);
164+
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
165+
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
167166
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
167+
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
168+
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
169+
glfwWindowHint(GLFW_SAMPLES, samples);
168170

169171
if (width == -1 || height == -1)
170172
{
@@ -229,7 +231,11 @@ namespace jsar::example
229231

230232
// Make the context available before starting the embedder
231233
glfwMakeContextCurrent(windowCtx_->window);
234+
glfwSwapInterval(1);
232235
{
236+
auto version = glGetString(GL_VERSION);
237+
fprintf(stdout, "OpenGL version: %s\n", version);
238+
233239
// Get environment variables for OpenGL context
234240
const char *str = getenv("JSAR_DISABLE_MULTISAMPLE");
235241
if (str != NULL && strcmp(str, "1") == 0)

0 commit comments

Comments
 (0)