Skip to content

v0.3.2 — Fix GLSL CC_MVPMatrix redeclaration

Choose a tag to compare

@UniqueName54321 UniqueName54321 released this 20 Aug 03:55
· 14 commits to main since this release

The shader was failing to compile at all

CCGLProgram injects CC_MVPMatrix (and other built-ins) before every shader source. Our vertex shader was declaring it again, which is a GLSL redeclaration error — the GPU was seeing the same uniform declared twice.

What changed

1. Removed uniform mat4 CC_MVPMatrix; from vertex shader
The shader still uses CC_MVPMatrix — it just doesn't declare it. Cocos pre-declares it, same as its own built-in position-texture-color shader does.

2. Added GLES precision qualifiers to varyings
Vertex shader: varying mediump vec2 v_texCoord / varying lowp vec4 v_fragmentColor
Fragment shader: matching varying mediump / varying lowp
This matches Cocos's own convention and prevents mobile link failures.

3. Shader log output on failure
Instead of just "init failed," we now dump vertexShaderLog(), fragmentShaderLog(), and programLog() so the next GLSL error is actually debuggable.

The chain we fixed

```
v0.3.0: shader broken → overlay created anyway → CCSprite::draw() → 💥
v0.3.1: shader broken → log error, don't create overlay → GD survives
v0.3.2: shader compiles correctly → ??? → (hopefully) VHS effect works
```

Previous release (v0.3.1) context

v0.3.1 added null-shader crash guards and a diagnostic CCSprite hook. The crash was downstream of the real problem — the shader never compiled. v0.3.2 fixes the root cause.

Full Changelog: v0.3.1...v0.3.2