Skip to content

Add GLSL code formatting step after preprocessing in demo#20

Draft
Copilot wants to merge 2 commits intodevfrom
copilot/preprocess-and-format-code
Draft

Add GLSL code formatting step after preprocessing in demo#20
Copilot wants to merge 2 commits intodevfrom
copilot/preprocess-and-format-code

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 7, 2026

The demo displayed preprocessed shader output as a raw, unformatted string. This adds a formatting pass after compiler.preprocess() so the output is human-readable.

Changes

  • lib/glslFormatter.js — New UMD-compatible GLSL tokenizer + formatter. Handles:

    • Block indentation tracking via {}/}
    • Statement-per-line via ;
    • Preprocessor directives unindented at column 0
    • Line and block comments re-indented correctly
    • Collapsing of consecutive blank lines
  • demo/app.ts — Declares formatGLSL global; pipes preprocessed result through it before display

  • demo/index.html — Loads glslFormatter.js before app.bundle.js

  • demo/app.bundle.js — Updated compiled bundle to reflect the app.ts change

Example

Input (after preprocessing):

void main(){vec3 pos=a_position;pos.z*=2.0;gl_Position=u_mvp*vec4(pos,1.0);}

Output (after formatting):

void main() {
    vec3 pos=a_position;
    pos.z*=2.0;
    gl_Position=u_mvp*vec4(pos,1.0);
}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • registry.npmmirror.com
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install --frozen-lockfile (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: 06wj <800043+06wj@users.noreply.github.com>
Copilot AI changed the title [WIP] Preprocess and format code in demo/index.html Add GLSL code formatting step after preprocessing in demo Mar 7, 2026
Copilot finished work on behalf of 06wj March 7, 2026 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants