Viewport problem

Previous topic - Next topic

FutureCow

I'm having an issue with viewport, I'm hoping someone can help me work out what I'm doing wrong.

From the documentation, "3D graphics will be scaled as if the viewport was the main window."

Here's the two issues I'm having
1) I'm drawing moving water fine on a full 1024x768 screen. I now want to draw 2 copies, scaled to half the screen each. I create a viewport 0,0,512,768 and I was expecting it to squeeze the picture. Instead it crops off the sides. If I create the viewport 0,0,512,384 though it scales it correctly. Why does halving each dimension work, but scaling by halving only the width not work?

2) This isn't in the documentation, but I found I need to create the viewport before calling X_MAKE3D. I thought I would create my 3d environment (X_MAKE3D, camera, lighting) then create a viewport covering half the screen, draw my objects, create the other half of the screen as a viewport and draw the objects again. Is there any way to not have to create cameras/lights etc for each viewport or (I suspect) that's just the way it has to be done. It just seems a waste duplicating that code when I thought it would inherit the current 3D settings.

MrTAToad

I dont know about point 1 - its possibly a bug.

As for point 2, its a problem I've fallen foul of many times - it does seem to be an inefficient way of doing things...

Kitty Hello

Correct. You must first set the viewport, then the camera. It's because... uhm... no idea.
And the viewport for 3D is taken from the diagonal size of the viewport. So, the 512x768 version should be slightly smaller than the 1024x768 version (the diagonal is 923 vs 1280 pixels - not much difference)

FutureCow

Cheers Gernot and MrTAToad. At least I understand what's going on now. Any chance of updating the documentation to that effect?  :whistle: