TestWinGlut.cpp
Go to the documentation of this file.
00001 
00002 //      File:           TestWinGlut.cpp
00003 //      Author:         Changchang Wu
00004 //      Description : Implementation of TestWinGlut Class
00005 //
00006 //
00007 //
00008 //      Copyright (c) 2007 University of North Carolina at Chapel Hill
00009 //      All Rights Reserved
00010 //
00011 //      Permission to use, copy, modify and distribute this software and its
00012 //      documentation for educational, research and non-profit purposes, without
00013 //      fee, and without a written agreement is hereby granted, provided that the
00014 //      above copyright notice and the following paragraph appear in all copies.
00015 //      
00016 //      The University of North Carolina at Chapel Hill make no representations
00017 //      about the suitability of this software for any purpose. It is provided
00018 //      'as is' without express or implied warranty. 
00019 //
00020 //      Please send BUG REPORTS to ccwu@cs.unc.edu
00021 //
00023 
00024 #include <stdlib.h>
00025 #ifdef __APPLE__
00026         #include "GLUT/glut.h"
00027 #else
00028         #include "GL/glut.h"
00029 #endif
00030 #include "BasicTestWin.h"
00031 #include "TestWinGlut.h"
00032 
00034 
00035 int main(int argc, char**argv)
00036 {
00037         //
00039         glutInit(&argc, argv);
00040 
00041 
00042         //create the glut window
00043         TestWinGlut twg(argc, argv);
00044 //      TestWinGlut twg2(0, NULL);
00045 
00046 
00047         //run the glut main loop to display all the TestWinGlut Windows
00048         TestWinGlut::Run();
00049 
00050         return 0;
00051 }
00052 
00054 // TestWinGlut Class
00056 
00057 
00058 
00062 TestWinGlut* TestWinGlut::_win[TestWinGlut::MAX_TEST_WIN_GLUT];
00063 
00065 // Construction/Destruction
00067 
00068 
00069 
00070 TestWinGlut::TestWinGlut(int argc, char**argv)
00071 
00072 {
00073         //enable console output
00074         SetVerbose();
00075         ParseSiftParam(argc, argv);
00076 
00077         //create glut window
00078         CreateGLUT();
00079 
00080         //parse parameters and run sift 
00081         RunSiftGPU();
00082 
00083 
00084 }
00085 
00086 TestWinGlut::~TestWinGlut()
00087 {
00088 
00089 }
00090 
00091 
00092 
00093 void TestWinGlut::CreateGLUT()
00094 {
00095         int id;
00096         glutInitDisplayMode (GLUT_RGBA | GLUT_DOUBLE);
00097         glutInitWindowSize (600,450);
00098     if(_win_x != -1) glutInitWindowPosition(_win_x, _win_y);
00099         id = glutCreateWindow ("SIFT_GPU");
00100         if(id>0)
00101         {
00102                 if(id >=MAX_TEST_WIN_GLUT) exit(0);//should not happen...
00103                 
00104                 //
00105                 glutDisplayFunc (display);
00106                 glutKeyboardFunc(keyboard);
00107                 glutReshapeFunc (reshape);
00108                 glutIdleFunc(idle);
00109                 glutMotionFunc(motion);
00110                 glutMouseFunc(button);
00111                 //save a pointer to the stucture
00112                 _win[id] = this;
00113         }
00114 
00115 }
00116 
00117 void TestWinGlut::idle() 
00118 {
00119         int id = glutGetWindow();
00120         _win[id]->OnIdle();
00121 }
00122 
00123 void TestWinGlut::keyboard(unsigned char key, int x, int y)
00124 {
00125         int id = glutGetWindow();
00126 
00127         _win[id]->KeyInput(key);
00128           glutPostRedisplay();
00129 }
00130 void TestWinGlut::reshape(int w, int h)
00131 {
00132         int id = glutGetWindow();
00133         _win[id]->ReShape(w, h); 
00134         glutPostRedisplay();
00135 }
00136 void TestWinGlut::display()
00137 {
00138         static int firstcall=1;
00139         int id = glutGetWindow();
00140         _win[id]->Display();
00141         glutSwapBuffers();
00142         if(firstcall ==0)
00143         {
00144         }else
00145         {
00146                 //if it is the first display call, redraw
00147                 firstcall = 0;
00148                 glutPostRedisplay();
00149         }
00150 }
00151 
00152 void TestWinGlut::Run()
00153 {
00154         glutMainLoop();
00155 }
00156 
00157 void TestWinGlut::motion(int x, int y)
00158 {
00159         int id = glutGetWindow();
00160         _win[id]->MoveMouse(x, y);
00161 }
00162 
00163 void TestWinGlut::SetWindowTitle(char *title)
00164 {
00165         glutSetWindowTitle(title);
00166 }
00167 
00168 void TestWinGlut::button(int button, int state,int x, int y)
00169 {
00170         int id = glutGetWindow();
00171         if (button ==  GLUT_LEFT_BUTTON)
00172         {
00173                 if(state == GLUT_DOWN)
00174                         _win[id]->StartMotion(x, y);
00175                 else if (state == GLUT_UP)
00176                         _win[id]->EndMotion();
00177         }
00178 }
00179 
00180 void TestWinGlut::UpdateDisplay()
00181 {
00182         glutPostRedisplay();
00183 }
00184 
00185 void TestWinGlut::SetDisplaySize(int w, int h)
00186 {
00187         glutReshapeWindow(w, h);
00188 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


rgbd_registration
Author(s): Ross Kidson
autogenerated on Thu May 23 2013 15:36:53