32 #if defined (G4VIS_BUILD_OPENGL_DRIVER) || defined (G4VIS_USE_OPENGL)
34 #ifndef G4OPENGLVIEWER_HH
35 #define G4OPENGLVIEWER_HH
39 #ifdef G4OPENGL_VERSION_2
43 class G4OpenGLSceneHandler;
47 class G4OpenGLViewerPickMap {
53 inline void setHitNumber(
G4int n) {
57 inline void setSubHitNumber(
G4int n) {
60 inline void setPickName(
G4int n) {
64 inline void addAttributes(
G4String att) {
65 fAttributes.push_back(att);
72 inline G4int getHitNumber() {
76 inline G4int getSubHitNumber() {
80 inline G4int getPickName() {
84 inline std::vector <G4String > getAttributes() {
95 std::vector <G4String > fAttributes;
100 class G4OpenGLViewer:
virtual public G4VViewer {
102 friend class G4OpenGLSceneHandler;
103 friend class G4OpenGLImmediateSceneHandler;
104 friend class G4OpenGLStoredSceneHandler;
105 friend class G4OpenGLFileSceneHandler;
110 void ClearViewWithoutFlush ();
113 virtual bool exportImage(std::string
name=
"",
int width=-1,
int height=-1);
115 bool setExportImageFormat(std::string format,
bool quiet =
false);
119 #ifdef G4OPENGL_VERSION_2
120 inline G4OpenGLVboDrawer* getWtDrawer() {
return fVboDrawer;}
123 void setVboDrawer(G4OpenGLVboDrawer* drawer);
124 G4OpenGLVboDrawer* fVboDrawer;
127 return fGlViewInitialized;
132 G4OpenGLViewer (G4OpenGLSceneHandler& scene);
133 virtual ~G4OpenGLViewer ();
136 G4OpenGLViewer(
const G4OpenGLViewer&);
137 G4OpenGLViewer& operator= (
const G4OpenGLViewer&);
143 virtual void DrawText(
const G4Text&);
144 void ChangePointSize(
G4double size);
145 void ChangeLineWidth(
G4double width);
146 void HaloingFirstPass ();
147 void HaloingSecondPass ();
148 void HLRFirstPass ();
149 void HLRSecondPass ();
150 void HLRThirdPass ();
151 void InitializeGLView ();
153 void ResizeWindow(
unsigned int,
unsigned int);
154 virtual G4String Pick(GLdouble
x, GLdouble
y);
155 const std::vector < G4OpenGLViewerPickMap* > & GetPickDetails(GLdouble
x, GLdouble
y);
156 virtual void CreateFontLists () {}
171 std::string getRealPrintFilename();
172 unsigned int getWinWidth()
const;
173 unsigned int getWinHeight()
const;
176 GLdouble getSceneNearWidth();
177 GLdouble getSceneFarWidth();
178 GLdouble getSceneDepth();
179 void addExportImageFormat(std::string format);
182 G4bool isFramebufferReady();
184 void g4GluPickMatrix(GLdouble
x, GLdouble
y, GLdouble width, GLdouble height,
188 void g4GluLookAt( GLdouble eyex, GLdouble eyey, GLdouble eyez,
189 GLdouble centerx, GLdouble centery, GLdouble
191 GLdouble upx, GLdouble upy, GLdouble upz );
193 void g4GlOrtho (GLdouble
left, GLdouble
right,
194 GLdouble bottom, GLdouble top,
195 GLdouble near, GLdouble far);
197 void g4GlFrustum (GLdouble
left, GLdouble
right,
198 GLdouble bottom, GLdouble top,
199 GLdouble near, GLdouble far);
205 G4OpenGLSceneHandler& fOpenGLSceneHandler;
208 transparency_enabled,
209 antialiasing_enabled,
215 unsigned int fWinSize_x;
216 unsigned int fWinSize_y;
217 std::vector < std::string > fExportImageFormatVector;
218 std::string fDefaultExportImageFormat;
219 std::string fExportImageFormat;
220 int fExportFilenameIndex;
230 int fGl2psDefaultLineWith;
231 int fGl2psDefaultPointSize;
232 bool fGlViewInitialized;
238 G4int getRealExportWidth();
239 G4int getRealExportHeight();
240 GLubyte* grabPixels (
int inColor,
242 unsigned int height);
243 bool printNonVectoredEPS ();
246 bool printVectoredEPS();
249 bool fIsGettingPickInfos;
252 #ifdef G4OPENGL_VERSION_2
254 #if defined (G4VIS_BUILD_OPENGLWT_DRIVER) || defined (G4VIS_USE_OPENGLWT)
255 inline Wt::WGLWidget::Program getShaderProgram() {
256 return fShaderProgram;
258 inline Wt::WGLWidget::UniformLocation getShaderProjectionMatrix() {
259 return fpMatrixUniform;
261 inline Wt::WGLWidget::UniformLocation getShaderTransformMatrix() {
262 return ftMatrixUniform;
265 inline GLuint getShaderProgram() {
266 return fShaderProgram;
268 inline GLuint getShaderProjectionMatrix() {
269 return fpMatrixUniform;
271 inline GLuint getShaderTransformMatrix() {
272 return ftMatrixUniform;
274 inline GLuint getShaderViewModelMatrix() {
275 return fmvMatrixUniform;
277 #endif // G4VIS_BUILD_OPENGLWT_DRIVER
282 #if defined (G4VIS_BUILD_OPENGLWT_DRIVER) || defined (G4VIS_USE_OPENGLWT)
283 #define Shader Wt::WGLWidget::Shader
285 #define Shader GLuint
286 #endif // G4VIS_BUILD_OPENGLWT_DRIVER
289 #if defined (G4VIS_BUILD_OPENGLWT_DRIVER) || defined (G4VIS_USE_OPENGLWT)
290 Wt::WGLWidget::Program fShaderProgram;
293 Wt::WGLWidget::AttribLocation fVertexPositionAttribute;
294 Wt::WGLWidget::AttribLocation fVertexNormalAttribute;
295 Wt::WGLWidget::UniformLocation fpMatrixUniform;
296 Wt::WGLWidget::UniformLocation fcMatrixUniform;
297 Wt::WGLWidget::UniformLocation fmvMatrixUniform;
298 Wt::WGLWidget::UniformLocation fnMatrixUniform;
299 Wt::WGLWidget::UniformLocation ftMatrixUniform;
301 GLuint fShaderProgram;
304 GLuint fVertexPositionAttribute;
305 GLuint fVertexNormalAttribute;
306 GLuint fpMatrixUniform;
307 GLuint fcMatrixUniform;
308 GLuint fmvMatrixUniform;
309 GLuint fnMatrixUniform;
310 GLuint ftMatrixUniform;
311 #endif // G4VIS_BUILD_OPENGLWT_DRIVER