RenderInterface.hh 8.45 KB
 Jan Möbius committed Sep 06, 2011 1 2 3 /*===========================================================================*\ * * * OpenFlipper *  Martin Schultz committed Jul 16, 2015 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38  * Copyright (c) 2001-2015, RWTH-Aachen University * * Department of Computer Graphics and Multimedia * * All rights reserved. * * www.openflipper.org * * * *---------------------------------------------------------------------------* * This file is part of OpenFlipper. * *---------------------------------------------------------------------------* * * * Redistribution and use in source and binary forms, with or without * * modification, are permitted provided that the following conditions * * are met: * * * * 1. Redistributions of source code must retain the above copyright notice, * * this list of conditions and the following disclaimer. * * * * 2. Redistributions in binary form must reproduce the above copyright * * notice, this list of conditions and the following disclaimer in the * * documentation and/or other materials provided with the distribution. * * * * 3. Neither the name of the copyright holder nor the names of its * * contributors may be used to endorse or promote products derived from * * this software without specific prior written permission. * * * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER * * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *  Jan Möbius committed Sep 06, 2011 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 * * \*===========================================================================*/ /*===========================================================================*\ * * * $Revision$ * * $LastChangedBy$ * * $Date$ * * * \*===========================================================================*/ #ifndef RENDERINTERFACE_HH #define RENDERINTERFACE_HH #include  Jan Möbius committed Sep 09, 2011 55 #include  Jan Möbius committed Sep 06, 2011 56 57 58  /** \file RenderInterface.hh *  Jan Möbius committed Oct 26, 2011 59 * Interface for adding global rendering functions. \ref renderInterfacePage  Jan Möbius committed Sep 06, 2011 60 61 62 63 */ /** \brief Interface to add additional rendering functions from within plugins. *  Jan Möbius committed Oct 26, 2011 64  * \ref renderInterfacePage "Detailed description"  Jan Möbius committed Sep 06, 2011 65 66 67 68 69 70 71 72 73 74 75 76 77 78  * \n * \n * * Interface for adding and controlling rendering functions from a plugin.\n */ class RenderInterface { public: /// Destructor virtual ~RenderInterface() {}; private slots:  Jan Möbius committed Sep 06, 2011 79  /** \brief announce required draw modes  Jan Möbius committed Sep 06, 2011 80  *  Jan Möbius committed Sep 06, 2011 81 82 83 84  * This function is called by the core to get a list of draw modes that are supported * by this renderer. If such a draw mode is set and the currently active * renderer does not support the given mode, the core will switch to * this renderer automatically. If there are multiple renderers capable of rendering  Jan Möbius committed Sep 06, 2011 85  * the drawmode(s), the core will ask the user for its preference.  Jan Möbius committed Sep 06, 2011 86  *  Jan Möbius committed Sep 06, 2011 87  * @param _mode Combined list of drawmodes  Jan Möbius committed Sep 06, 2011 88  */  Jan Möbius committed Sep 09, 2011 89  virtual void supportedDrawModes(ACG::SceneGraph::DrawModes::DrawMode& _mode) = 0;  Jan Möbius committed Sep 06, 2011 90 91 92 93  /** \brief announce name for the rendering function * *  Jan Möbius committed Feb 29, 2012 94  * @return Name displayed for the rendering function  Jan Möbius committed Sep 06, 2011 95  */  Jan Möbius committed Sep 06, 2011 96  virtual QString rendererName() = 0;  Jan Möbius committed Sep 06, 2011 97   Jan Möbius committed Oct 16, 2012 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128  /** \brief Check OpenGL capabilities * * This function has to be implemented and checks, if all required OpenGL extensions are available. * If this is not the case, the plugin will be refused by the core to avoid crashes due to insufficient * OpenGL support. * * You can get the version information in the following way: * * \code * * // Get version and check * QGLFormat::OpenGLVersionFlags flags = QGLFormat::openGLVersionFlags(); * if ( ! flags.testFlag(QGLFormat::OpenGL_Version_2_1) ) * return QString("Insufficient OpenGL Version! OpenGL 2.1 or higher required"); * * //Get OpenGL extensions * QString glExtensions = QString((const char*)glGetString(GL_EXTENSIONS)); * * // Collect missing extension * QString missing = ""; * * if ( !glExtensions.contains("GL_ARB_vertex_program") ) * missing += "Missing Extension GL_ARB_vertex_program\n"; * * return missing; * \endcode * * @return Return an empty string if everything is fine, otherwise return, what features are missing. */ virtual QString checkOpenGL() = 0;  Jan Möbius committed Sep 09, 2011 129  public slots:  Jan Möbius committed Sep 06, 2011 130   Jan Möbius committed Sep 09, 2011 131  /** \brief rendering function  Jan Möbius committed Sep 06, 2011 132  *  Jan Möbius committed Sep 09, 2011 133 134 135 136 137  * Implement this function to render the scene. You have to traverse the * scenegraph in this function. The glContext is made current before this * call. * If you need to initialize something,you can do it within this function. * gl and glew are already setUp here.  Jan Möbius committed Sep 06, 2011 138  */  Jan Möbius committed Sep 09, 2011 139 140 141 142 143 144 145 146 147 148 149  virtual void render(ACG::GLState* _glState, Viewer::ViewerProperties& _properties) {}; /** \brief Return options menu * * If you want an options Menu or menu entry, you can return your action here. * It will be shown on top of the renderer list in the options menu. * * * @return Action for a menu or menu entry */ virtual QAction* optionsAction() { return 0; };  Jan Möbius committed Sep 06, 2011 150   Jan Möbius committed Feb 06, 2013 151 152 153 154 155 156 157 158  /** \brief Return a qstring of the current render objects * * In this function your plugin should return a list of the render objects * (possibly with additional information). It can be used for debugging purposes. * * The IRenderer class already has a function called dumpCurrentRenderObjectsToString() * which can be used to implement this function. *  Jan Möbius committed Feb 08, 2013 159  * @param _outputShaderInfo Output shader code along with the render objects  Jan Möbius committed Feb 06, 2013 160 161  * @return string of render objects */  Jan Möbius committed Feb 08, 2013 162  virtual QString renderObjectsInfo(bool _outputShaderInfo) { return QString("Render object inforation not implemented in this plugin"); };  Jan Möbius committed Feb 06, 2013 163   Christopher Tenter committed Feb 18, 2014 164 165 166 167 168 169  /** \brief Reload any renderer specific shaders * * This function allows the plugin to reload any renderer specific shaders. */ virtual void reloadShaders() { };  Jan Möbius committed Oct 16, 2012 170 171   Jan Möbius committed Sep 06, 2011 172 173 };  Jan Möbius committed Oct 26, 2011 174 /** \page renderInterfacePage Render Interface  Jan Möbius committed Sep 06, 2011 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 \image html RenderInterface.png \n The RenderInterface can be used by plugins to add special rendering functions to OpenFlipper. You can create a dedicated rendering function for a drawmode. E.g. when you need to render 4 passes with different shaders you can do that in your rendering function. Example Code for functions: \code TODO \endcode To use the RenderInterface:
*/ Q_DECLARE_INTERFACE(RenderInterface,"OpenFlipper.RenderInterface/1.0") #endif // RPCINTERFACE_HH