Imagination PowerVR SDK Blog

How to handle 3D view resizing?


#1
I want to support dynamic resizing of my application's 3D view.

As far as I understand, the canvas size is to be stored in PVRShell's prefWidth and prefHeight variables. 
In the documentation of `PVRShellSet` it says: 
"This function is used to pass preferences to the PVRShell.

If used, it must be called from InitApplication()."

But how can I handle 3D view resizing at runtime? Apparently I cannot set prefWidth/prefHeight when my view frame changes.


#2

Hi Dan.

What exactly do you mean by 3D view resizing? Is your application running on a device, or on a windowed desktop system using our emulation libraries? PVRShell’s prefWidth and prefHeight are generally used to determine the size of a device’s screen, for example.

#3

Hi Arron, 

I am actually targeting both. 

On iOS (or Android, when I come to porting the app), the OpenGL view does not take up all the screen size but sits inside a tabBar tab. I also want to handle device rotation as a resizing operation of the view (that’s basically what it is) instead of rotating the camera OpenGL.

On the desktop (currently MacOS) I want to do just the same. I have a resizable window containing the OpenGL view.

I have used this pattern before with objective-c implementations an it works very well. On view resizing I just start my render loop and set the new viewport size accordingly.

As I understand the PVRShell’s default pattern would be to assume the app is displayed full screen.

Which would be the most suitable way to support dynamic view resizing?


#4

Hello


my first guess will be to use and extension of  GLSurfaceView  and complete the implementation of the GLSurfaceView.EGLContextFactory as describe in the doc .LIke that we can have a specific view to render and enabling the usage to the gui builder as a bonus.


david

 


#5

Hi Dan.

Unfortunately without modification PVRShell will not be suitable for your requirements, as you’ve described. PVRShell is primarily intended to be used full-screen on devices in which the screen size does not change, and rotation is handled via a view matrix.

In order to support dynamic resizing you will unfortunately need to add this code yourself. However, it should not be too difficult to add, OS depending.