[529] | 1 | // |
---|
| 2 | // ******************************************************************** |
---|
| 3 | // * License and Disclaimer * |
---|
| 4 | // * * |
---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
| 7 | // * conditions of the Geant4 Software License, included in the file * |
---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
| 9 | // * include a list of copyright holders. * |
---|
| 10 | // * * |
---|
| 11 | // * Neither the authors of this software system, nor their employing * |
---|
| 12 | // * institutes,nor the agencies providing financial support for this * |
---|
| 13 | // * work make any representation or warranty, express or implied, * |
---|
| 14 | // * regarding this software system or assume any liability for its * |
---|
| 15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
| 16 | // * for the full disclaimer and the limitation of liability. * |
---|
| 17 | // * * |
---|
| 18 | // * This code implementation is the result of the scientific and * |
---|
| 19 | // * technical work of the GEANT4 collaboration. * |
---|
| 20 | // * By using, copying, modifying or distributing the software (or * |
---|
| 21 | // * any work based on the software) you agree to acknowledge its * |
---|
| 22 | // * use in resulting scientific publications, and indicate your * |
---|
| 23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
| 24 | // ******************************************************************** |
---|
| 25 | // |
---|
| 26 | // |
---|
| 27 | // $Id: G4OpenGLXViewer.hh,v 1.26 2006/11/01 11:22:27 allison Exp $ |
---|
| 28 | // GEANT4 tag $Name: geant4-08-02-patch-01 $ |
---|
| 29 | // |
---|
| 30 | // |
---|
| 31 | // Andrew Walkden 7th February 1997 |
---|
| 32 | // G4OpenGLXViewer : Class to provide XWindows specific |
---|
| 33 | // functionality for OpenGL in GEANT4 |
---|
| 34 | |
---|
| 35 | #ifdef G4VIS_BUILD_OPENGLX_DRIVER |
---|
| 36 | |
---|
| 37 | #ifndef G4OPENGLXVIEWER_HH |
---|
| 38 | #define G4OPENGLXVIEWER_HH |
---|
| 39 | |
---|
| 40 | #include "G4VViewer.hh" |
---|
| 41 | #include "G4OpenGLSceneHandler.hh" |
---|
| 42 | #include "globals.hh" |
---|
| 43 | |
---|
| 44 | #include <X11/Xlib.h> |
---|
| 45 | #include <X11/Intrinsic.h> |
---|
| 46 | #include <X11/Xmu/StdCmap.h> |
---|
| 47 | |
---|
| 48 | #include <GL/glx.h> |
---|
| 49 | |
---|
| 50 | class G4OpenGLSceneHandler; |
---|
| 51 | |
---|
| 52 | class G4OpenGLXViewer: virtual public G4OpenGLViewer { |
---|
| 53 | |
---|
| 54 | friend class G4OpenGLXViewerMessenger; |
---|
| 55 | |
---|
| 56 | public: |
---|
| 57 | G4OpenGLXViewer (G4OpenGLSceneHandler& scene); |
---|
| 58 | virtual ~G4OpenGLXViewer (); |
---|
| 59 | void SetView (); |
---|
| 60 | void ShowView (); |
---|
| 61 | void print(); |
---|
| 62 | |
---|
| 63 | protected: |
---|
| 64 | void GetXConnection (); |
---|
| 65 | void CreateGLXContext (XVisualInfo* vi); |
---|
| 66 | virtual void CreateMainWindow (); |
---|
| 67 | virtual void CreateFontLists (); |
---|
| 68 | |
---|
| 69 | static int snglBuf_RGBA[12]; |
---|
| 70 | static int dblBuf_RGBA[13]; |
---|
| 71 | |
---|
| 72 | char print_string[50]; |
---|
| 73 | G4bool print_colour, |
---|
| 74 | vectored_ps; |
---|
| 75 | |
---|
| 76 | //////////////////////////////Vectored PostScript production functions////////////////////////////// |
---|
| 77 | void printBuffer(GLint, GLfloat*); |
---|
| 78 | GLfloat* spewPrimitiveEPS (FILE*, GLfloat*); |
---|
| 79 | void spewSortedFeedback (FILE*, GLint, GLfloat*); |
---|
| 80 | void spewWireframeEPS (FILE*, GLint, GLfloat*, const char*); |
---|
| 81 | void print3DcolorVertex(GLint, GLint*, GLfloat*); |
---|
| 82 | G4float pointSize; |
---|
| 83 | |
---|
| 84 | |
---|
| 85 | //////////////////////////////Pixmap (screen dump) production functions////////////////////////////// |
---|
| 86 | GLubyte* grabPixels (int inColor, |
---|
| 87 | unsigned int width, |
---|
| 88 | unsigned int height); |
---|
| 89 | int generateEPS (char* filnam, |
---|
| 90 | int inColour, |
---|
| 91 | unsigned int width, |
---|
| 92 | unsigned int height); |
---|
| 93 | GLXContext create_GL_print_context (XVisualInfo*& pvi); |
---|
| 94 | |
---|
| 95 | XWindowAttributes xwa; |
---|
| 96 | Display *dpy; |
---|
| 97 | static XVisualInfo *vi_single_buffer; |
---|
| 98 | static XVisualInfo *vi_double_buffer; |
---|
| 99 | XVisualInfo *vi_immediate, |
---|
| 100 | *vi_stored, |
---|
| 101 | *vi; |
---|
| 102 | Colormap cmap; |
---|
| 103 | XSetWindowAttributes swa; |
---|
| 104 | GLXDrawable win; |
---|
| 105 | GLXContext cx; |
---|
| 106 | XEvent event; |
---|
| 107 | G4int *attributeList, |
---|
| 108 | errorBase, |
---|
| 109 | eventBase, |
---|
| 110 | major, |
---|
| 111 | minor, |
---|
| 112 | x_origin, |
---|
| 113 | y_origin; |
---|
| 114 | XSizeHints *norm_hints; |
---|
| 115 | XWMHints *wm_hints; |
---|
| 116 | XClassHint *class_hints; |
---|
| 117 | Pixmap icon_pixmap; |
---|
| 118 | XSizeHints *size_hints; |
---|
| 119 | unsigned int WinSize_x, |
---|
| 120 | WinSize_y; |
---|
| 121 | Atom Xatom; |
---|
| 122 | XTextProperty windowName, |
---|
| 123 | iconName; |
---|
| 124 | char charViewName [100]; |
---|
| 125 | |
---|
| 126 | private: |
---|
| 127 | G4OpenGLXViewer (const G4OpenGLXViewer&); |
---|
| 128 | G4OpenGLXViewer& operator = (const G4OpenGLXViewer&); |
---|
| 129 | }; |
---|
| 130 | |
---|
| 131 | typedef struct G4OpenGLXViewerFeedback3Dcolor { |
---|
| 132 | GLfloat x; |
---|
| 133 | GLfloat y; |
---|
| 134 | GLfloat z; |
---|
| 135 | GLfloat red; |
---|
| 136 | GLfloat green; |
---|
| 137 | GLfloat blue; |
---|
| 138 | GLfloat alpha; |
---|
| 139 | } Feedback3Dcolor; |
---|
| 140 | |
---|
| 141 | #endif |
---|
| 142 | |
---|
| 143 | #endif |
---|