Skip to content

Commit f2c82bc

Browse files
committed
Added simple ortho projection functionality
1 parent a749d42 commit f2c82bc

File tree

4 files changed

+37
-4
lines changed

4 files changed

+37
-4
lines changed

example/example.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ int main(int argc, char **argv)
309309

310310
#if (ISAAC_STEREO == 0)
311311
isaac::DefaultController,
312+
//isaac::OrthoController,
312313
isaac::DefaultCompositor
313314
#else
314315
isaac::StereoController,

lib/isaac/isaac_compositors.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ namespace isaac
2121
struct DefaultCompositor
2222
{
2323
DefaultCompositor( isaac_size2 framebuffer_size ) {}
24-
~DefaultCompositor() {}
2524
static inline isaac_size2 getCompositedbufferSize( isaac_size2 framebuffer_size )
2625
{
2726
return framebuffer_size;

lib/isaac/isaac_controllers.hpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ namespace isaac
2121
struct DefaultController
2222
{
2323
static const int pass_count = 1;
24-
DefaultController() {}
25-
~DefaultController() {}
2624
inline bool updateProjection( IceTDouble * const projection, const isaac_size2 & framebuffer_size, json_t * const message, const bool first = false)
2725
{
2826
if (first)
@@ -32,14 +30,25 @@ struct DefaultController
3230
inline void sendFeedback( json_t * const json_root, bool force = false ) {}
3331
};
3432

33+
struct OrthoController
34+
{
35+
static const int pass_count = 1;
36+
inline bool updateProjection( IceTDouble * const projection, const isaac_size2 & framebuffer_size, json_t * const message, const bool first = false)
37+
{
38+
if (first)
39+
setOrthographic( projection, (isaac_float)framebuffer_size.x/(isaac_float)framebuffer_size.y*isaac_float(2), isaac_float(2), ISAAC_Z_NEAR, ISAAC_Z_FAR);
40+
return false;
41+
}
42+
inline void sendFeedback( json_t * const json_root, bool force = false ) {}
43+
};
44+
3545
struct StereoController
3646
{
3747
static const int pass_count = 2;
3848
StereoController() :
3949
eye_distance(0.06f),
4050
send_stereo(true)
4151
{}
42-
~StereoController() {}
4352
inline bool updateProjection( IceTDouble * const projection, const isaac_size2 & framebuffer_size, json_t * const message, const bool first = false)
4453
{
4554
if ( json_t* js = json_object_get(message, "eye distance") )

lib/isaac/isaac_helper.hpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ void setFrustum(IceTDouble * const projection, const isaac_float left,const isaa
276276
projection[14] = ( -znear2 * zfar ) / -zRange;
277277
projection[15] = isaac_float( 0);
278278
}
279+
279280
void setPerspective(IceTDouble * const projection, const isaac_float fovyInDegrees,const isaac_float aspectRatio,const isaac_float znear,const isaac_float zfar )
280281
{
281282
isaac_float ymax = znear * tan( fovyInDegrees * M_PI / isaac_float(360) );
@@ -294,6 +295,29 @@ void spSetPerspectiveStereoscopic( IceTDouble * const projection, const isaac_fl
294295
projection[12] += distance;
295296
}
296297

298+
299+
void setOrthographic(IceTDouble * const projection, const isaac_float right,const isaac_float top,const isaac_float znear,const isaac_float zfar )
300+
{
301+
projection[ 0] = 1.0 / right;
302+
projection[ 1] = isaac_float( 0);
303+
projection[ 2] = isaac_float( 0);
304+
projection[ 3] = isaac_float( 0);
305+
projection[ 4] = isaac_float( 0);
306+
projection[ 5] = 1.0 / top;
307+
projection[ 6] = isaac_float( 0);
308+
projection[ 7] = isaac_float( 0);
309+
projection[ 8] = isaac_float( 0);
310+
projection[ 9] = isaac_float( 0);
311+
projection[10] = -2.0 / (zfar-znear);
312+
projection[11] = isaac_float( 0);
313+
projection[12] = isaac_float( 0);
314+
projection[13] = isaac_float( 0);
315+
projection[14] = - (zfar+znear) / (zfar-znear);
316+
projection[15] = isaac_float( 1);
317+
}
318+
319+
320+
297321
#if ISAAC_VALGRIND_TWEAKS == 1
298322
static void *extra_malloc(size_t size)
299323
{

0 commit comments

Comments
 (0)