1 /******************************************************************************** 2 * * 3 * V i s u a l C l a s s * 4 * * 5 ********************************************************************************* 6 * Copyright (C) 1999,2021 by Jeroen van der Zijp. All Rights Reserved. * 7 ********************************************************************************* 8 * This library is free software; you can redistribute it and/or modify * 9 * it under the terms of the GNU Lesser General Public License as published by * 10 * the Free Software Foundation; either version 3 of the License, or * 11 * (at your option) any later version. * 12 * * 13 * This library is distributed in the hope that it will be useful, * 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 16 * GNU Lesser General Public License for more details. * 17 * * 18 * You should have received a copy of the GNU Lesser General Public License * 19 * along with this program. If not, see <http://www.gnu.org/licenses/> * 20 ********************************************************************************/ 21 #ifndef FXGLVISUAL_H 22 #define FXGLVISUAL_H 23 24 #ifndef FXVISUAL_H 25 #include "FXVisual.h" 26 #endif 27 28 namespace FX { 29 30 31 class FXFont; 32 class FXWindow; 33 class FXImage; 34 class FXIcon; 35 class FXBitmap; 36 class FXDCWindow; 37 38 39 /// Visual describes pixel format of a drawable 40 class FXAPI FXGLVisual : public FXVisual { 41 FXDECLARE(FXGLVisual) 42 friend class FXWindow; 43 friend class FXImage; 44 friend class FXIcon; 45 friend class FXBitmap; 46 friend class FXDCWindow; 47 protected: 48 struct FXGLSpecs; 49 protected: 50 FXuchar redSize; // Red bits 51 FXuchar greenSize; // Green depth 52 FXuchar blueSize; // Blue bits 53 FXuchar alphaSize; // Alpha bits 54 FXuchar depthSize; // Depth bits 55 FXuchar stencilSize; // Stencil bits 56 FXuchar multiSamples; // Multi-sampling 57 FXuchar accumRedSize; // Red accu buffer bits 58 FXuchar accumGreenSize; // Green accu buffer bits 59 FXuchar accumBlueSize; // Blue accu buffer bits 60 FXuchar accumAlphaSize; // Alpha accu buffer bits 61 FXuchar actualRedSize; // Actual Red bits 62 FXuchar actualGreenSize; // Actual Green depth 63 FXuchar actualBlueSize; // Actual Blue bits 64 FXuchar actualAlphaSize; // Actual Alpha bits 65 FXuchar actualDepthSize; // Actual Depth bits 66 FXuchar actualStencilSize; // Actual Stencil bits 67 FXuchar actualMultiSamples; // Actual multi-sampling 68 FXuchar actualAccumRedSize; // Actual Red accu buffer bits 69 FXuchar actualAccumGreenSize; // Actual Green accu buffer bits 70 FXuchar actualAccumBlueSize; // Actual Blue accu buffer bits 71 FXuchar actualAccumAlphaSize; // Actual Alpha accu buffer bits 72 FXbool doubleBuffer; 73 FXbool stereoBuffer; 74 FXbool accelerated; 75 FXbool copying; 76 protected: 77 FXGLVisual(); 78 private: 79 FXGLVisual(const FXGLVisual&); 80 FXGLVisual &operator=(const FXGLVisual&); 81 FXint matchSpecs(const FXGLSpecs& s); 82 public: 83 84 /// Construct default visual 85 FXGLVisual(FXApp* a,FXuint flgs=VISUAL_DOUBLE_BUFFER); 86 87 /// Create visual 88 virtual void create(); 89 90 /// Detach visual 91 virtual void detach(); 92 93 /// Destroy visual 94 virtual void destroy(); 95 96 /// Get sizes for bit-planes getRedSize()97 FXint getRedSize() const { return redSize; } getGreenSize()98 FXint getGreenSize() const { return greenSize; } getBlueSize()99 FXint getBlueSize() const { return blueSize; } getAlphaSize()100 FXint getAlphaSize() const { return alphaSize; } getDepthSize()101 FXint getDepthSize() const { return depthSize; } getStencilSize()102 FXint getStencilSize() const { return stencilSize; } getMultiSamples()103 FXint getMultiSamples() const { return multiSamples; } getAccumRedSize()104 FXint getAccumRedSize() const { return accumRedSize; } getAccumGreenSize()105 FXint getAccumGreenSize() const { return accumGreenSize; } getAccumBlueSize()106 FXint getAccumBlueSize() const { return accumBlueSize; } getAccumAlphaSize()107 FXint getAccumAlphaSize() const { return accumAlphaSize; } 108 109 /// Set sizes for bit-planes setRedSize(FXint rs)110 void setRedSize(FXint rs){ redSize=rs; } setGreenSize(FXint gs)111 void setGreenSize(FXint gs){ greenSize=gs; } setBlueSize(FXint bs)112 void setBlueSize(FXint bs){ blueSize=bs; } setAlphaSize(FXint as)113 void setAlphaSize(FXint as){ alphaSize=as; } setDepthSize(FXint ds)114 void setDepthSize(FXint ds){ depthSize=ds; } setStencilSize(FXint ss)115 void setStencilSize(FXint ss){ stencilSize=ss; } setMultiSamples(FXint ms)116 void setMultiSamples(FXint ms){ multiSamples=ms; } setAccumRedSize(FXint rs)117 void setAccumRedSize(FXint rs){ accumRedSize=rs; } setAccumGreenSize(FXint gs)118 void setAccumGreenSize(FXint gs){ accumGreenSize=gs; } setAccumBlueSize(FXint bs)119 void setAccumBlueSize(FXint bs){ accumBlueSize=bs; } setAccumAlphaSize(FXint as)120 void setAccumAlphaSize(FXint as){ accumAlphaSize=as; } 121 122 /// Get ACTUAL sizes for bit-planes getActualRedSize()123 FXint getActualRedSize() const { return actualRedSize; } getActualGreenSize()124 FXint getActualGreenSize() const { return actualGreenSize; } getActualBlueSize()125 FXint getActualBlueSize() const { return actualBlueSize; } getActualAlphaSize()126 FXint getActualAlphaSize() const { return actualAlphaSize; } getActualDepthSize()127 FXint getActualDepthSize() const { return actualDepthSize; } getActualStencilSize()128 FXint getActualStencilSize() const { return actualStencilSize; } getActualMultiSamples()129 FXint getActualMultiSamples() const { return actualMultiSamples; } getActualAccumRedSize()130 FXint getActualAccumRedSize() const { return actualAccumRedSize; } getActualAccumGreenSize()131 FXint getActualAccumGreenSize() const { return actualAccumGreenSize; } getActualAccumBlueSize()132 FXint getActualAccumBlueSize() const { return actualAccumBlueSize; } getActualAccumAlphaSize()133 FXint getActualAccumAlphaSize() const { return actualAccumAlphaSize; } 134 135 /// Is it double buffered? isDoubleBuffer()136 FXbool isDoubleBuffer() const { return doubleBuffer; } 137 138 /// Is it stereo? isStereo()139 FXbool isStereo() const { return stereoBuffer; } 140 141 /// Is it hardware-accelerated? isAccelerated()142 FXbool isAccelerated() const { return accelerated; } 143 144 /// Does it swap by copying instead of flipping buffers isBufferSwapCopy()145 FXbool isBufferSwapCopy() const { return copying; } 146 147 /// Test if if OpenGL is supported. 148 static FXbool hasOpenGL(FXApp* application); 149 150 /// Save visual info to a stream 151 virtual void save(FXStream& store) const; 152 153 /// Load visual info to a stream 154 virtual void load(FXStream& store); 155 156 /// Destructor 157 virtual ~FXGLVisual(); 158 }; 159 160 } 161 162 #endif 163