# Mat4::Ortho() example

**URL:** <https://forums.imgtec.com/t/mat4-ortho-example/628>\
**Category:** PowerVR Insider\
**Created:** [March 12, 2010, 4:53pm UTC](https://forums.imgtec.com/t/mat4-ortho-example/628 "2010-03-12T16:53:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnf](https://avatars.discourse-cdn.com/v4/letter/j/848f3c/32.png) [@johnf](https://forums.imgtec.com/u/johnf)\
**Post date:** [March 12, 2010, 4:53pm UTC](https://forums.imgtec.com/t/mat4-ortho-example/628/1 "2010-03-12T16:53:53Z")

</div>

Hello,  
I’m using the 3\_00\_00\_06 SDK from TI for OMAP3530.&nbsp; I have a simple gles2 app with a shader which works fine using a projection matrix.&nbsp; I can rotate my model 45 degrees and get expected results.&nbsp; When I use a PVRT::Mat4::Ortho() I end up with an unsatisfying blank screen.&nbsp; In other words,  
  
// this works:  
float aspect = screenWidth/screenHeight;  
bool bRotate = false;  
PVRT::Mat4::PerspectiveFovFloatDepthRH(PI/6.0, aspect, 1.0, PVRT::Mat4::OGL, bRotate);  
  
// this doesn’t work:  
float NEAR\_CLIP=10.0;  
float FAR\_CLIP=-10.0;  
PVRT::Mat4::Ortho(screenWidth/-2.0, screenHeight/2.0, screenWidth/2.0, screenHeight/-2.0, NEAR\_CLIP, FAR\_CLIP, PVRT::Mat4::OGL, bRotate);  
  
Is there an example app which uses an orthographic projection?&nbsp; A grep in the SDK sources didn’t turn up anything.  
  
Another data point: when I just use a rotation matrix of .001 degrees around the Y axis, (no additional perspective or ortho matrix) I get a thin vertical block of pixels suggesting depth clipping is against me.&nbsp; I assume this will go away once proper near/far planes are set.  
  
Thanks!

---

<div class="post-metadata">

**Author:** ![michax-2](https://avatars.discourse-cdn.com/v4/letter/m/b38774/32.png) [@michax-2](https://forums.imgtec.com/u/michax-2)\
**Post date:** [August 27, 2010, 1:58am UTC](https://forums.imgtec.com/t/mat4-ortho-example/628/2 "2010-08-27T01:58:14Z")

</div>

Perspective has another “scale” factory. So if you have small triangle created with size around 1.0f it will be as 1px in screen in Ortho mode.  
  
  
  
  
  
Try to use -1, 1, 1, -1 for left, top, right, bottom, and you will get similar result to Perspective ( considering scale ).  
  
  
  
  
  
But if you want Ortho for creating HUD, you will need to scale up your objects.  
  
  
  
  
  
You asked also for exmaple, Ortho is used in Water Demo.

---

<div class="post-metadata">

**Author:** ![johnf](https://avatars.discourse-cdn.com/v4/letter/j/848f3c/32.png) [@johnf](https://forums.imgtec.com/u/johnf)\
**Post date:** [September 10, 2010, 9:26pm UTC](https://forums.imgtec.com/t/mat4-ortho-example/628/3 "2010-09-10T21:26:36Z")

</div>

Hi michax.&nbsp; Thanks for your reply.  
  
I was not able to find source for the water or sailboat demo in the SDK nor elsewhere, but I had another look at using PVRTMatrixOrthoRHF() and it seems to be doing what I need.&nbsp; I started with the 02\_HelloTriangle example in the GLES2 training, passed the matrix generated by&nbsp; PVRTMatrixOrthoRHF() to glUniformMatrix4fv() instead of the identity matrix and got expected results.

---

<div class="post-metadata">

**Author:** ![GordonMaclachlan](https://avatars.discourse-cdn.com/v4/letter/g/c68b51/32.png) [@GordonMaclachlan](https://forums.imgtec.com/u/GordonMaclachlan)\
**Post date:** [September 17, 2010, 9:31am UTC](https://forums.imgtec.com/t/mat4-ortho-example/628/4 "2010-09-17T09:31:42Z")

</div>

Please post further if you encounter any difficulties. Incidentally, the Water demo should be here, in the SDK:  
  
SDKPackageDemosWater

---

<div class="post-metadata">

**Author:** ![StuartNeilson](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/stuartneilson/32/2_2.png) [@StuartNeilson](https://forums.imgtec.com/u/StuartNeilson)\
**Post date:** [October 12, 2010, 3:52am UTC](https://forums.imgtec.com/t/mat4-ortho-example/628/5 "2010-10-12T03:52:25Z")

</div>

Thanks you for your sharing ! It need for me to understand about ortho  
&nbsp;I’m studying about it  
  
 ![Wink]()

#
