main.cpp
Go to the documentation of this file.
00001 #include <iostream>
00002 #include <pangolin/pangolin.h>
00003 
00004 using namespace pangolin;
00005 using namespace std;
00006 
00007 void setImageData(float * imageArray, int width, int height){
00008   for(int i = 0 ; i < width*height;i++) {
00009     imageArray[i] = (float)rand()/RAND_MAX;
00010   }
00011 }
00012 
00013 int main( int /*argc*/, char* argv[] )
00014 {
00015   // Create OpenGL window in single line thanks to GLUT
00016   pangolin::CreateGlutWindowAndBind("Main",640,480);
00017   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
00018 
00019   // Issue specific OpenGl we might need
00020   glEnable (GL_BLEND);
00021   glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00022 
00023   // Define Camera Render Object (for view / scene browsing)
00024   pangolin::OpenGlMatrix proj = ProjectionMatrix(640,480,420,420,320,240,0.1,1000);
00025   pangolin::OpenGlRenderState s_cam(proj);
00026   pangolin::OpenGlRenderState s_cam2(proj);
00027 
00028   // Add named OpenGL viewport to window and provide 3D Handler
00029   View& d_cam1 = pangolin::Display("cam1")
00030     .SetAspect(640.0f/480.0f)
00031     .SetHandler(new Handler3D(s_cam));
00032 
00033   View& d_cam2 = pangolin::Display("cam2")
00034     .SetAspect(640.0f/480.0f)
00035     .SetHandler(new Handler3D(s_cam2));
00036 
00037   View& d_cam3 = pangolin::Display("cam3")
00038     .SetAspect(640.0f/480.0f)
00039     .SetHandler(new Handler3D(s_cam));
00040 
00041   View& d_cam4 = pangolin::Display("cam4")
00042     .SetAspect(640.0f/480.0f)
00043     .SetHandler(new Handler3D(s_cam2));
00044 
00045   View& d_img1 = pangolin::Display("img1")
00046     .SetAspect(640.0f/480.0f);
00047 
00048   View& d_img2 = pangolin::Display("img2")
00049     .SetAspect(640.0f/480.0f);
00050 
00051   // LayoutEqual is an EXPERIMENTAL feature - it requires that all sub-displays
00052   // share the same aspect ratio, placing them in a raster fasion in the
00053   // viewport so as to maximise display size.
00054   pangolin::Display("multi")
00055       .SetBounds(1.0, 0.0, 0.0, 1.0)
00056       .SetLayout(LayoutEqual)
00057       .AddDisplay(d_cam1)
00058       .AddDisplay(d_img1)
00059       .AddDisplay(d_cam2)
00060       .AddDisplay(d_img2)
00061       .AddDisplay(d_cam3)
00062       .AddDisplay(d_cam4);
00063 
00064   const int width =  64;
00065   const int height = 48;
00066   float * imageArray = new float[width*height];
00067   GlTexture imageTexture(width,height,GL_LUMINANCE32F_ARB);
00068   imageTexture.SetNearestNeighbour();
00069 
00070   // Default hooks for exiting (Esc) and fullscreen (tab).
00071   while( !pangolin::ShouldQuit() )
00072   {
00073     if(HasResized())
00074       DisplayBase().ActivateScissorAndClear();
00075 
00076     // Generate random image and place in texture memory for display
00077     setImageData(imageArray,width,height);
00078     imageTexture.Upload(imageArray,GL_LUMINANCE,GL_FLOAT);
00079 
00080     // (3D Handler requires depth testing to be enabled)
00081     glEnable(GL_DEPTH_TEST);
00082     glColor3f(1.0,1.0,1.0);
00083 
00084     d_cam1.ActivateScissorAndClear(s_cam);
00085     glutWireTeapot(1.0);
00086 
00087     d_cam2.ActivateScissorAndClear(s_cam2);
00088     glutWireTeapot(1.0);
00089 
00090     d_cam3.ActivateScissorAndClear(s_cam);
00091     glutWireTeapot(1.0);
00092 
00093     d_cam4.ActivateScissorAndClear(s_cam2);
00094     glutWireTeapot(1.0);
00095 
00096     d_img1.ActivateScissorAndClear();
00097     imageTexture.RenderToViewport();
00098 
00099     d_img2.ActivateScissorAndClear();
00100     imageTexture.RenderToViewport();
00101 
00102     // Swap frames and Process Events
00103     pangolin::FinishGlutFrame();
00104   }
00105 
00106   delete imageArray;
00107 
00108   return 0;
00109 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


pangolin_wrapper
Author(s): Todor Stoyanov
autogenerated on Wed Feb 13 2013 14:03:25