Resizing viewport ( in multiple viewport ) on demand

Hi there,

i have 2 viewport on my scene that are looking on 2 different direction , i want that in a specific action i’m doing the other view port change it size :


cam2 = cam.clone();

cam2.setViewPort(0.7f, 1f, 0.7f, 1f); // <== I’m trying to change this value on demand from my game so i can resize as i want without touching the code

cam.setLocation(new Vector3f(character.getLocalTranslation().x-10f,character.getLocalTranslation().y,character.getLocalTranslation().z-2f));

cam.lookAt(character.getLocalTranslation(), Vector3f.UNIT_Y);

cam2.setLocation(new Vector3f(mob.getLocalTranslation().x-2f,mob.getLocalTranslation().y,mob.getLocalTranslation().z-2f));

cam2.lookAt(mob.getLocalTranslation(), Vector3f.UNIT_Y);

ViewPort view2 = renderManager.createMainView(“Top Right”, cam2);




when i try to do that , i have a magnific :

GRAVE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

Thanks in advance

Whats the exception?

any null checks there, at all ?

Momoko_Fan said:
Whats the exception?

Hi momoko_fan the exception is : java.lang.NullPointerException

Setekh said:
any null checks there, at all ?

well ... i did another test here :
if (name.equals("Test")&& keyPressed){ // By pressing Space Bar i'm trying to change the location of the second camera in viewport
cam2.setLocation(new Vector3f(0,0,0));


and same error

So cam2 is probably null.