Having trouble implementing an isometric view

I would like to draw the world from an isometric viewpoint, but am having some major troubles getting anything at all to render when using CameraOrtho.

This is my draw method that works ( Draws a greenish cube near the bottom middle of the screen ):

void MyTestApp::draw( ) {


    ci::CameraPersp cam;
    cam.lookAt( ci::vec3( 3, 4.5, 4.5 ), ci::vec3( 0, 1, 0 ) );
    ci::gl::setMatrices( cam );

    auto lambert = ci::gl::ShaderDef().lambert().color();
    auto shader = ci::gl::getStockShader( lambert );

    ci::gl::pushModelMatrix( );
    ci::gl::color( ci::Color( ci::CM_HSV, 0.2, 1, 1 ) );
    ci::gl::drawCube( ci::vec3( 0 ), ci::vec3( 1 ) );
    ci::gl::popModelMatrix( );

However, I would like to do it with a CameraOrtho, and not have the perspective warping. Changing cam to be a ci::CameraOrtho however renders a black screen. The lookAt function is still setting the eye and direction vectors correctly, but all it renders is a black screen.

In truth, I haven’t been able to get anything at all to render with an orthographic camera, no matter where I put it in the world, or how I set up the lookAt call.

Clearly I do not understand how the Ortho camera works, but finding anything about how it should has proved incredibly difficult. I cannot even find a good opengl example that uses an ortho projection.

The effect I am going for is for a physics simulation. I want to view a 3d graph from a corner of its bounding box, and be able to rotate it around the y axis. I do not want any perspective shifts on this however, it needs to be an isomorphic/ortho view.

Can anyone link me to an example using an ortho camera? Many thanks.


just like you (should) use the CameraPersp::setPerspective() method, so you should use the CameraOrtho::setOrtho() method. Specify the extents of your 3D world with it. For example, if the world is 16 units wide and 9 units high, you could do this:

const float kNear = 0.1f;
const float kFar = 100.0f; 
mCamera.setOrtho( -8, 8, -4.5f, 4.5f, kNear, kFar );

Note that for best results, make sure to respect the window’s aspect ratio. It might be a good idea to do something like:

float aspect = getWindowAspectRatio();
float height = 10.0f;
float width = aspect * height;
mCamera.setOrtho( -0.5f * width, 0.5f * width, -0.5f * height, 0.5f * height, kNear, kFar );


1 Like

Huh. That worked perfectly, thank you. I’m not sure why I was having so much trouble getting that to work.

Ah, I realized part of my problem. I was trying to set the ortho projection as it would be in world space. The ortho cube needs to be in camera space. That clarified quite a lot.