Bork3D Games

Personal tools
From Bork3D
Jump to: navigation, search

Landscape Rendering

By default the Bork3D Game Engine renders in iPhone-native portrait mode. (Because Anytime Golf renders portrait!)

Forcing Landscape

Rendering landscape is a cinch. Before the call to RudeGame::Render() in the Objective-C wrapper code you can set landscape by calling:

RGL.SetLandscape(true);

You'll also need to pass the Render() function a different aspect ratio, since landscape runs 480:320 instead of 320:480:

 float aspect = ((float) backingWidth) / ((float) backingHeight);
	
 if(RGL.GetLandscape())
    aspect = ((float) backingHeight) / ((float) backingWidth);

 gGame->Render(elapsedSeconds, aspect);

Dynamic Landscape/Portrait Switches

The example project takes landscape a step further by exposing landscape as a Tweaker variable and then passing the tweaked variable to SetLandscape(). This is useful if your game dynamically switches between portrait and landscape, or you're trying to validate UI layout in both modes:

bool gRenderLandscape = false;
RUDE_TWEAK(RenderLandscape, kBool, gRenderLandscape);

If you want to support dynamic switching you'll need to be ready to switch the viewport on the fly. From the example project:

 void RBUITitle::Render(float aspect)
 {
    if(RGL.GetLandscape())
      RGL.SetViewport(0, 0, 320, 480);
    else
      RGL.SetViewport(0, 0, 480, 320);
    ...