Official Codebase of 3DCodeVerse
Python
glsl_shader: an authored main() that calls mainImage() is the entry point — no second main appended
gaoypeng9719a0217552
diff --git a/harness/codeverse3d/languages/glsl_shader/__init__.py b/harness/codeverse3d/languages/glsl_shader/__init__.pyindex d1cf1637..d4545e5b 100644--- a/harness/codeverse3d/languages/glsl_shader/__init__.py+++ b/harness/codeverse3d/languages/glsl_shader/__init__.py@@ -78,11 +78,15 @@ def strip_comments(text: str) -> str:def detect_convention(shader_src: str) -> str:+ """``main`` when the author wrote a ``main()`` (with or without a ``mainImage`` it calls — the usual+ Shadertoy-port pattern), else ``mainImage`` (the harness appends the ``main()`` trailer). Appending+ the trailer to a file that already has ``main()`` redefined it: codex gpt-6-luna wrote both on 4 of+ 4 one-shot shaders (p3x_graphics_v2, 2026-09-23) and every one failed to compile at ``harness:3``."""shader_src = strip_comments(shader_src)- if _MAIN_IMAGE.search(shader_src):- return "mainImage"if _PLAIN_MAIN.search(shader_src):return "main"+ if _MAIN_IMAGE.search(shader_src):+ return "mainImage"return "mainImage" # trailer will surface "mainImage undeclared" at compile time → clear errordiff --git a/harness/tests/graphics/test_wrap_lint.py b/harness/tests/graphics/test_wrap_lint.pyindex 9ad0d6eb..c1e147e4 100644--- a/harness/tests/graphics/test_wrap_lint.py+++ b/harness/tests/graphics/test_wrap_lint.py@@ -30,6 +30,22 @@ def test_plain_main_convention_has_no_trailer_and_comments_ignored():assert compose("void mainImage(out vec4 c, in vec2 f) { c = texture(u_prev, f); }").uses_feedback+def test_an_authored_main_that_calls_main_image_gets_no_second_main():+ """A Shadertoy port often keeps its own main() calling mainImage(); appending the trailer redefined+ main (4/4 gpt-6-luna one-shot shaders, 2026-09-23). The author's main() wins, and it compiles."""+ src = SHADER + "void main() {\n mainImage(fragColor, gl_FragCoord.xy);\n}\n"+ c = compose(src)+ assert c.convention == "main" and c.source.count("void main(") == 1+ import moderngl++ ctx = moderngl.create_standalone_context()+ try:+ ctx.program(vertex_shader="#version 330 core\nin vec2 p; void main(){ gl_Position = vec4(p, 0.0, 1.0); }",+ fragment_shader=c.source)+ finally:+ ctx.release()++def test_parse_glsl_log_dialects_map_to_files():c = compose(SHADER, COMMON)off = HEADER.count("\n") + 1 # common.glsl starts here (1 line) → shader.frag starts at off+1