1 // OpenCSG - library for image-based CSG rendering for OpenGL 2 // Copyright (C) 2002-2016, Florian Kirsch, 3 // Hasso-Plattner-Institute at the University of Potsdam, Germany 4 // 5 // This library is free software; you can redistribute it and/or 6 // modify it under the terms of the GNU General Public License, 7 // Version 2, as published by the Free Software Foundation. 8 // As a special exception, you have permission to link this library 9 // with the CGAL library and distribute executables. 10 // 11 // This library is distributed in the hope that it will be useful, 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 // GNU General Public License for more details. 15 // 16 // You should have received a copy of the GNU General Public License 17 // along with this program; if not, write to the Free Software Foundation, 18 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 20 // 21 // scissorMemo.h 22 // 23 // handles scissor calculations 24 // 25 26 #ifndef __OpenCSG__scissor_memo_h__ 27 #define __OpenCSG__scissor_memo_h__ 28 29 #include "opencsgConfig.h" 30 #include "area.h" 31 #include "channelManager.h" 32 #include <vector> 33 34 namespace OpenCSG { 35 36 class ScissorMemo { 37 public: 38 /// convenience class for handling scissoring. All areas 39 /// are given in normal device coordinates [-1, 1] x [-1, 1]. 40 ScissorMemo(); 41 42 /// for each channel, the currently set area can be stored 43 void store(Channel); 44 /// restores the area for the channel 45 void recall(Channel); 46 47 /// enables scissoring of area 48 void enableScissor() const; 49 /// disables scissoring 50 void disableScissor() const; 51 52 /// enables depth bounds test of volume (if supported by graphics hardware) 53 void enableDepthBounds() const; 54 /// enables depth bounds test of back of current volume (if supported by graphics hardware) 55 void enableDepthBoundsBack() const; 56 /// disables depth bounds test of volume (if supported by graphics hardware) 57 void disableDepthBounds() const; 58 59 /// sets the maximum area of the intersected CSG-primitives 60 /// by intersecting the bounding boxes of them. 61 void setIntersected(const std::vector<Primitive*>& primitives); 62 63 /// sets the area of primitives whose visilibity is determined next. 64 void setCurrent(const std::vector<Primitive*>& primitives); 65 /// returns the maximum area of the intersected CSG-primitives 66 const NDCVolume& getIntersectedArea() const; 67 /// returns the maximum area of the intersected CSG-primitives 68 /// intersected with the currently used primitives 69 const NDCVolume& getCurrentArea() const; 70 71 protected: 72 /// calculates rendering area by intersecting intersected 73 /// and current. This is invoked implicetely. 74 void calculateArea(); 75 76 private: 77 NDCVolume mIintersection; 78 NDCVolume mCurrent; 79 NDCVolume mArea; 80 std::vector<NDCVolume> mScissor; 81 82 bool mUseDepthBoundsTest; 83 }; 84 85 } // namespace OpenCSG 86 87 #endif // __OpenCSG__scissor_memo_h__ 88 89 90