LoGL.C

Go to the documentation of this file.
00001 /**
00002    \file  Robots/LoBot/util/LoGL.C
00003    \brief Some OpenGL related helpers.
00004 */
00005 
00006 // //////////////////////////////////////////////////////////////////// //
00007 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005   //
00008 // by the University of Southern California (USC) and the iLab at USC.  //
00009 // See http://iLab.usc.edu for information about this project.          //
00010 // //////////////////////////////////////////////////////////////////// //
00011 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00012 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00013 // in Visual Environments, and Applications'' by Christof Koch and      //
00014 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00015 // pending; application number 09/912,225 filed July 23, 2001; see      //
00016 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00017 // //////////////////////////////////////////////////////////////////// //
00018 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00019 //                                                                      //
00020 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00021 // redistribute it and/or modify it under the terms of the GNU General  //
00022 // Public License as published by the Free Software Foundation; either  //
00023 // version 2 of the License, or (at your option) any later version.     //
00024 //                                                                      //
00025 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00026 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00027 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00028 // PURPOSE.  See the GNU General Public License for more details.       //
00029 //                                                                      //
00030 // You should have received a copy of the GNU General Public License    //
00031 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00032 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00033 // Boston, MA 02111-1307 USA.                                           //
00034 // //////////////////////////////////////////////////////////////////// //
00035 //
00036 // Primary maintainer for this file: mviswana usc edu
00037 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Robots/LoBot/util/LoGL.C $
00038 // $Id: LoGL.C 13037 2010-03-23 01:00:53Z mviswana $
00039 //
00040 
00041 //------------------------------ HEADERS --------------------------------
00042 
00043 // lobot headers
00044 #include "Robots/LoBot/util/LoGL.H"
00045 
00046 // OpenGL headers
00047 #ifdef INVT_HAVE_LIBGLUT
00048 #include <GL/glut.h>
00049 #endif
00050 
00051 #ifdef INVT_HAVE_LIBGLU
00052 #include <GL/glu.h>
00053 #endif
00054 
00055 #ifdef INVT_HAVE_LIBGL
00056 #include <GL/gl.h>
00057 #endif
00058 
00059 //----------------------------- NAMESPACE -------------------------------
00060 
00061 namespace lobot {
00062 
00063 //-------------------------- OPENGL HELPERS -----------------------------
00064 
00065 #if defined(INVT_HAVE_LIBGL)  && \
00066     defined(INVT_HAVE_LIBGLU) && \
00067     defined(INVT_HAVE_LIBGLUT)
00068 
00069 // Draw a text label in a GLUT window
00070 void draw_label(float x, float y, const char* label)
00071 {
00072    glRasterPos2f(x, y) ;
00073    for (const char* s = label; *s; ++s)
00074       glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, *s) ;
00075 }
00076 
00077 // Draw a vector from the origin
00078 void draw_vector(const Vector& v)
00079 {
00080    // Draw the vector's "body" with its tail pinned at the origin
00081    glBegin(GL_LINES) ;
00082       glVertex2i(0, 0) ;
00083       glVertex2f(v.i, v.j) ;
00084    glEnd() ;
00085 
00086    // Draw an arrow head at the vector's head
00087    Vector n = normalized(v) ;
00088    Vector p = 0.91f * v ;
00089    Vector q = p + 0.03f * Vector(-n.j,  n.i) ;
00090    Vector r = p + 0.03f * Vector( n.j, -n.i) ;
00091    glBegin(GL_TRIANGLES) ;
00092       glVertex2f(v.i, v.j) ;
00093       glVertex2f(q.i, q.j) ;
00094       glVertex2f(r.i, r.j) ;
00095    glEnd() ;
00096 }
00097 
00098 #else // no OpenGL ==> don't make any GL rendering calls
00099 
00100 void draw_label(float, float, const char*){}
00101 void draw_vector(const Vector&){}
00102 
00103 #endif
00104 
00105 //-----------------------------------------------------------------------
00106 
00107 } // end of namespace encapsulating this file's definitions
00108 
00109 /* So things look consistent in everyone's emacs... */
00110 /* Local Variables: */
00111 /* indent-tabs-mode: nil */
00112 /* End: */
Generated on Sun May 8 08:05:56 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3