i have bug that only happen when retina flag disabled.

i try draw multiple render texture to achive some multi post effect: so i have 3 render texture,

fbo 1 for final pos effect
fbo 2 for back buffer w/light
fbo 3 for light mask

i apply this using fbo mechanisms of cocos2dx push the fbo1 to screen
push the fbo2 to fbo1
fbo 3 just for sampler texture for render in fbo2 shader

gameplay actor will be drawn on fbo2, after that fbo2 will be rendered to fbo1 ( we can apply some effect here) then fbo1 drawn to screen, then do some gui layering.

the thing is all gp actor drawn into fbo2 , "seems" become scaled down 3 times, so its like the small game screen on left bottom corner, but the light from fbo3 or gui that directly drawn to screen normal positioned and not scaled .

i really dontknow who is scale my fbo2, but i check the matrix its all correct. but seems lot setviewport in rendertexture.h, idont know how its work actualy, so if any one know how viewport work on fbo,

  • no direct open gl acces for my code except attach shader
  • if i dont use fbo2 one, ( using fbo1 directly ), the bug doesnt happen
    ** this doesnt happen on retina true ( scaled 2x ) , this happen on win32 or mac when i disabled retina ,
    ** tracing draw order correcty
    ** log below on command:
    onbegin fbo1
    onbegin fbo2
    onbegin fbo3
    ( i render some sprite to this fbo first ex: alpha gradient mask)
    onend fbo3
    ( i render gp actor here)
    onend fbo2
    ( render attached fbo2 texture with shader carries sampler of attached texture 3)
    onend fbo1
    ( render attached fbo1 texturee)* may caries some shader
    ( render gui part )

1 Answer 1


its fixed now,

onbegin always set the viewport.

because onEnd method the viewport restored to the original screen viewport regardless its return to another fbo. so everytime more than > 1 deep will call viewport with scale of screen, this causing mess because the screen viewport has design ratio. so fix it by ensuring the viewport to original set for each fbo before its.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .