00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00033 #ifndef OPENGLRENDERER_H
00034 #define OPENGLRENDERER_H
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 #include "DisplayDevice.h"
00045 #include "Scene.h"
00046 #include "OpenGLExtensions.h"
00047 #include "OpenGLCache.h"
00048
00049 #if defined(VMDUSEOPENGLSHADER)
00050 #include "OpenGLShader.h"
00051 #endif
00052
00053 #if defined(_MSC_VER)
00054 #include <windows.h>
00055 #endif
00056
00057
00058
00059
00060
00061 #define GL_GLEXT_PROTOTYPES 1
00062
00063 #if defined(__APPLE__) && !defined (VMDMESA)
00064 #include <OpenGL/gl.h>
00065 #else
00066 #include <GL/gl.h>
00067 #endif
00068
00069
00070 #if defined(VMDUSELIBGLU)
00071 #if defined(__APPLE__) && !defined (VMDMESA)
00072 #include <OpenGL/glu.h>
00073 #else
00074 #include <GL/glu.h>
00075 #endif
00076 #endif
00077
00078
00079
00080
00081 #if (defined(__linux) || defined(_MSC_VER)) && !defined(VMDMESA)
00082 #include <GL/glext.h>
00083 #endif
00084 #if defined(__APPLE__) && !defined (VMDMESA)
00085 #include <OpenGL/glext.h>
00086 #endif
00087
00088
00089 #ifndef APIENTRY
00090 #define APIENTRY
00091 #endif
00092 #ifndef GLAPI
00093 #define GLAPI extern
00094 #endif
00095
00096
00097 #define OPENGL_STEREO_OFF 0
00098 #define OPENGL_STEREO_QUADBUFFER 1
00099 #define OPENGL_STEREO_HDTVSIDE 2
00100 #define OPENGL_STEREO_STENCIL_CHECKERBOARD 3
00101 #define OPENGL_STEREO_STENCIL_COLUMNS 4
00102 #define OPENGL_STEREO_STENCIL_ROWS 5
00103 #define OPENGL_STEREO_ANAGLYPH 6
00104 #define OPENGL_STEREO_SIDE 7
00105 #define OPENGL_STEREO_ABOVEBELOW 8
00106 #define OPENGL_STEREO_LEFT 9
00107 #define OPENGL_STEREO_RIGHT 10
00108 #define OPENGL_STEREO_MODES 11
00109
00110
00111 #define OPENGL_RENDER_NORMAL 0
00112 #define OPENGL_RENDER_GLSL 1
00113 #if defined(VMDOPTIXRTRT)
00114 #define OPENGL_RENDER_RTXRTRT 2
00115 #define OPENGL_RENDER_ACROBAT3D 3
00116 #define OPENGL_RENDER_MODES 4
00117 #else
00118 #define OPENGL_RENDER_ACROBAT3D 2
00119 #define OPENGL_RENDER_MODES 3
00120 #endif
00121
00122
00123 #define OPENGL_CACHE_OFF 0
00124 #define OPENGL_CACHE_ON 1
00125 #define OPENGL_CACHE_MODES 2
00126
00127 class OpenGLRenderer;
00128 class VMDDisplayList;
00129 #if defined(VMDOPTIXRTRT)
00130 class OptiXRenderer;
00131 #endif
00132
00137 class OpenGLRenderer : public DisplayDevice {
00138 #if defined(VMD_NANOHUB)
00139 protected:
00140 GLuint _finalFbo, _finalColorTex, _finalDepthRb;
00141 bool init_offscreen_framebuffer(int width, int height);
00142 #endif
00143
00144 public:
00145 void setup_initial_opengl_state(void);
00146
00147 protected:
00149
00150 #if defined(VMDUSELIBGLU)
00151 GLUquadricObj *pointsQuadric;
00152 GLUquadricObj *objQuadric;
00153 #endif
00154
00156 ResizeArray<GLuint> solidSphereLists;
00157 ResizeArray<GLuint> pointSphereLists;
00158
00160 GLuint SphereList;
00162
00163
00165
00166
00167 OpenGLCache displaylistcache;
00168 OpenGLCache texturecache;
00169 int oglmaterialindex;
00170 float oglopacity;
00171 float oglambient;
00172 float oglspecular;
00173 float ogldiffuse;
00174 float oglshininess;
00175 float ogloutline;
00176 float ogloutlinewidth;
00177 int ogltransmode;
00178 GLfloat ogl_pmatrix[16];
00179 GLfloat ogl_mvmatrix[16];
00180 Matrix4 ogl_textMat;
00181 GLint ogl_viewport[4];
00182 GLint ogl_fogmode;
00183 int ogl_lightingenabled;
00184 int ogl_useblendedtrans;
00185 int ogl_useglslshader;
00186 int ogl_glslserial;
00187 int ogl_glsltoggle;
00188 int ogl_glslmaterialindex;
00189 int ogl_glslprojectionmode;
00190 int ogl_glsltexturemode;
00191 int ogl_transpass;
00192 int ogl_rendstateserial;
00193 int ogl_clipmode[VMD_MAX_CLIP_PLANE];
00194 int ogl_lightstate[DISP_LIGHTS];
00195 GLfloat ogl_lightcolor[DISP_LIGHTS][4];
00196 GLfloat ogl_lightpos[DISP_LIGHTS][4];
00197 GLfloat ogl_backcolor[4];
00198 GLfloat ogl_backgradient[2][4];
00199 int ogl_acrobat3dcapture;
00201
00202 #if defined(VMDOPTIXRTRT)
00203
00204 OptiXRenderer * ort;
00205 int ogl_optix_rtrt_passthrough;
00206 #endif
00207
00209 int ogl_cacheenabled;
00210 int ogl_cachedebug;
00211 GLint ogl_cachelistbase;
00212
00213 int dpl_initialized;
00214
00215 protected:
00217 GLuint font1pxListBase;
00218 GLuint fontNpxListBase;
00219
00220 OpenGLExtensions *ext;
00221
00222 #if defined(VMDUSEOPENGLSHADER)
00223 OpenGLShader *mainshader;
00224 OpenGLShader *sphereshader;
00225 OpenGLShader *spherespriteshader;
00226 #endif
00227
00228 int simplegraphics;
00229 int wiregl;
00230 int intelswr;
00231 int immersadeskflip;
00232 int shearstereo;
00233
00235
00236 int hastex2d;
00237 GLint max2DtexX;
00238 GLint max2DtexY;
00239 GLint max2DtexSize;
00241
00243
00244 int hastex3d;
00245 GLint max3DtexX;
00246 GLint max3DtexY;
00247 GLint max3DtexZ;
00248 GLint max3DtexSize;
00250
00251
00252
00253
00255
00256 void update_shader_uniforms(void *, int forceupdate);
00257
00259
00260 void set_line_width(int);
00261 void set_line_style(int);
00262 void set_sphere_res(int);
00263 void set_sphere_mode(int);
00264 void cylinder(float *, float *, int, float, float);
00265 void require_volume_texture(unsigned long ID,
00266 unsigned xsize, unsigned ysize, unsigned zsize, unsigned char *texmap);
00267 int build3Dmipmaps(int, int, int, unsigned char *tx);
00268 void draw_background_gradient(void);
00270
00271
00273
00274 virtual int do_define_light(int n, float *color, float *position);
00275 virtual int do_activate_light(int n, int turnon);
00277
00278 public:
00280 OpenGLRenderer(const char *);
00281 virtual ~OpenGLRenderer(void);
00282
00283
00284
00285 virtual int supports_gui() { return TRUE; }
00286
00288
00289 virtual void loadmatrix(const Matrix4&);
00290 virtual void multmatrix(const Matrix4&);
00292
00293
00294
00295
00296
00297
00299
00300 virtual void abs_screen_loc_3D(float *, float *);
00302 virtual void abs_screen_loc_2D(float *, float *);
00304
00305
00306
00307
00308 virtual void find_3D_from_2D(const float *A3D, const float *B2D, float *B3D);
00309
00311
00312 virtual void aa_on(void);
00313 virtual void aa_off(void);
00314 virtual void cueing_on(void);
00315 virtual void cueing_off(void);
00316 virtual void culling_on(void);
00317 virtual void culling_off(void);
00319
00320
00321 virtual void set_background(const float *);
00322 virtual void set_backgradient(const float *, const float *);
00323
00324
00325 virtual void enable_stencil_stereo(int newMode);
00326 virtual void disable_stencil_stereo(void);
00327 virtual void left(void);
00328 virtual void right(void);
00329 virtual void normal(void);
00330 virtual void set_persp(DisplayEye = NOSTEREO);
00331 virtual int prepare3D(int do_clear = TRUE);
00332 virtual int prepareOpaque();
00333 virtual int prepareTrans();
00334 virtual void clear(void);
00335 virtual void render(const VMDDisplayList *);
00336 virtual void render_done();
00337 void free_opengl_ctx();
00338
00340 virtual int forced_stereo_draws(void) { return ext->stereodrawforced; }
00341
00342 virtual void set_stereo_mode(int = 0);
00343 virtual void set_cache_mode(int);
00344 virtual void set_render_mode(int);
00345 virtual void set_window_title(char *) {};
00346 };
00347
00348 #endif
00349