PARP Research Group | Universidad de Murcia |
src/qvgpukltflow.cppGo to the documentation of this file.00001 /* 00002 * Copyright (C) 2011, 2012. PARP Research Group. 00003 * <http://perception.inf.um.es> 00004 * University of Murcia, Spain. 00005 * 00006 * This file is part of the QVision library. 00007 * 00008 * QVision is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License as 00010 * published by the Free Software Foundation, version 3 of the License. 00011 * 00012 * QVision is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with QVision. If not, see <http://www.gnu.org/licenses/>. 00019 */ 00020 00024 00025 #include <qvgpukltflow.h> 00026 00027 //#define _POSIX_SOURCE 00028 #include <stdlib.h> 00029 void initShadersEnvironment() 00030 { 00031 #ifdef V3D_SHADER_PATH 00032 setenv("V3D_SHADER_DIR", V3D_SHADER_PATH, 0); 00033 #else 00034 std::cout << "[initShadersEnvironment] Warking: no V3D_SHADER_PATH variable defined at 'config.pri'." << std::endl; 00035 #endif 00036 } 00037 00038 #include <iostream> 00039 #include <QGLPixelBuffer> 00040 // Function to init GLEW and CG system (called just once): 00041 void InitGLEWCg() 00042 { 00043 // Off-screen buffer (just to use its context isolatedly, in order to be used by the GPU process 00044 // avoiding conflict with the rest of QGLWidgets of the application): 00045 QGLPixelBuffer *pixelbuffer; 00046 00047 // In fact any size is valid for the initial QGLPixelBuffer (the really important thing is 00048 // to call tracker->allocate and tracker->deallocate functions with a correct size afterwards, 00049 // depending on the image input size: 00050 pixelbuffer = new QGLPixelBuffer( QSize(720,576), // GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE 00051 QGLFormat(QGL::DoubleBuffer|QGL::DepthBuffer|QGL::Rgba)); 00052 00053 // With this current buffer we init GLEW and Cg: 00054 pixelbuffer->makeCurrent(); 00055 std::cout << "GLEW initialization:" << std::endl; 00056 GLenum err = glewInit(); 00057 if (GLEW_OK != err) 00058 std::cout << "Error initializing GLEW: " << glewGetErrorString(err) << std::endl; 00059 else 00060 std::cout << "OK initializing GLEW: " << glewGetErrorString(err) << std::endl; 00061 Cg_ProgramBase::initializeCg(); 00062 std::cout << "Done with initialization" << std::endl; 00063 } 00064 |