Hi all,
I was wondering if you could help me figure out how to implement a magnifying glass effect?
Basically, I want be able to zoom in on certain parts of the scene though a magnifying glass, but I want everything outside of the magnifying glass to appear at normal size.
This example shows the effect I’m trying to get https://github.com/RocMax/MagnifyingGlassEffect, but that example only works with single sprites. I want to be able to zoom in on a scene that has multiple moving sprites.
In SMFL I used to create a second view to acheive this kind of result, but I don’t know where to start with Cocos2D-X!
Any help would be greatly appreciated 
Thanks!
Off top of my head I would probably render the game to one frame buffer and then apply magnify glass shader which should be possibly without any additional sprites. However, you could also use the masked sprite in your example with the RenderTexture sprite along with the same mask sprite, but I think applying a direct shader might be more performant?
Using a RenderTexture I would try adding the game’s root node to it instead of to the scene, then add the RenderTexture to the scene as its only child and apply the magnify shader to it (or the RT’s internal sprite).
You could also use the camera to attach a 2nd frame buffer instead which would be similar, but would leave the game code alone and instead you’d write some more code in the app/scene setup.
Shader uniforms might include: render texture, magnify center {x,y}, and magnify radius, maybe a drop off value.
I’m sure ShaderToy or google has a shader solution.
Look at cpp-test for RenderTexture test(s) and for setGLProgramState in test(s) if you need to understand more how they work.
Maybe others have better or more concrete advice.
Thank you very much @stevetranby!! 
Sorry for the late reply, but I wanted to thank you for your excellent answer and detailed answer
You definitely helped point me in the right direction.
I currently have the magnifying glass effect working via the RenderTexture method. I did try to get a shader working first, but I didn’t have much luck (I’m not very good and this programming stuff ;-))
When I get some more time, I’ll look at the shader method again, but for now the RenderTexture method is working great 
Thanks again! I really appreciate it 
1 Like
Hi. Can you please show me an example how can I render the game to one frame buffer if I use lot of cameras (I have about 5 cameras if this is important). Thank you so much.
What do you mean by render to one frame buffer? By default they all render into the same default screen frame buffer. Are you trying to render 5 cameras into a separate frame buffer so you can do some full-screen effects pass(es)?
Thank you. I understood now.