HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RE_OGLRender.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: RE_OGLRender.h ( RE Library, C++)
7  *
8  * COMMENTS:
9  * Interface class for Open GL. Comamnds are grouped, in this order,
10  * under these tags:
11  *
12  * - RENDERING ENVIRONMENT (gl version, extensions, driver)
13  * - MONITOR SCREEN (monitor setup)
14  * - DISPLAY MODE & WINDOWS (windows, visuals)
15  * - ERROR REPORTING (gl errors)
16  * - FRAMEBUFFER OBJECTS
17  * - BUFFER CONTROL
18  * - FRUSTUM & CLIPPING
19  * - TRANSFORMATION
20  * - COLOR
21  * - LINE & POINT STYLES
22  * - STENCIL, LOGIC & DEPTH
23  * - BLENDING & SMOOTHING
24  * - DISPLAY LISTS
25  * - MATERIALS
26  * - GLSL SHADERS
27  * - TEXTURING
28  * - LIGHTING & SHADING
29  * - PICKING
30  * - RASTER OPERATIONS
31  * - SIMPLE PRIMITIVES (rect, circles, arcs)
32  * - FONT RENDERING
33  * - SURFACES (nurbs)
34  * - OBSOLETE DRAWING METHODS (begin/end stuff, vertex calls)
35  */
36 #ifndef __RE_OGLRender__
37 #define __RE_OGLRender__
38 
39 #include "RE_API.h"
40 
41 #include <SYS/SYS_Floor.h>
42 #include <SYS/SYS_Types.h>
43 
44 #include <UT/UT_Array.h>
45 #include <UT/UT_ArrayMap.h>
46 #include <UT/UT_Assert.h>
47 #include <UT/UT_Color.h>
48 #include <UT/UT_IntArray.h>
49 #include <UT/UT_NonCopyable.h>
50 #include <UT/UT_Pixel.h>
51 #include <UT/UT_Rect.h>
52 #include <UT/UT_SpinLock.h>
53 #include <UT/UT_Thread.h>
55 #include <UT/UT_UniquePtr.h>
56 #include <UT/UT_Vector2.h>
57 #include <UT/UT_VectorTypes.h>
58 
59 #include <PXL/PXL_Common.h>
60 
61 #include "RE_Extension.h"
62 #include "RE_Material.h"
63 #include "RE_OGL.h"
64 #include "RE_OGLErrorChecker.h"
65 #include "RE_OGLExt.h"
66 #include "RE_OGLState.h"
67 #include "RE_RenderFlush.h"
68 #include "RE_Texture.h"
69 #include "RE_TextureTypes.h"
70 #include "RE_Uniform.h"
71 
72 #include <utility>
73 
74 template <typename ITEM_T> class UT_StringMap;
75 class UT_WorkBuffer;
76 class UT_StopWatch;
77 class UT_StringHolder;
78 class IMG_Raster;
79 class TIL_Raster;
80 class PXL_Raster;
81 class PXL_Lookup;
82 
83 class RE_Cursor;
85 class RE_FontBuffers;
86 class RE_Geometry;
87 class RE_OcclusionQuery;
88 class RE_OGLFramebuffer;
89 class RE_OGLTexture;
92 class RE_Render;
93 class RE_Server;
94 class RE_Shader;
95 class RE_ShaderHandle;
96 class RE_Visual;
97 class RE_Window;
98 class RE_WindowDrawable;
99 class RE_WindowList;
100 
101 #define OPEN_GL
102 
103 // These values are the keys in the table returned by getDriverInfoDict().
104 #define RE_DRIVER_INFO_VENDOR "OpenGL Vendor"
105 #define RE_DRIVER_INFO_RENDERER "OpenGL Renderer"
106 #define RE_DRIVER_INFO_VERSION "OpenGL Version"
107 #define RE_DRIVER_INFO_SHADING_LANGUAGE "OpenGL Shading Language"
108 #define RE_DRIVER_INFO_DETECTED "Detected GPU"
109 
110 // --------------------------------------------------------------------------
111 
113 {
114 public:
115  ~RE_OGLRender() override;
116 
117  const char *className() const;
118  int getContextID() const { return myUniqueID; }
119 
120  static void initialize();
121  bool isInitialized() const { return !firstInitialize; }
122 
123  /// Initializes the OpenGL state in the render.
124  /// This method assumes that the render's context is already current.
125  /// If you need to make the render's context current first, then consider
126  /// creating an RE_RenderAutoLock instead.
127  void initGLState();
128 
129  /// Return true if the render's OpenGL state has already been
130  /// initialized and return false otherwise.
131  bool isGLStateInitialized() const { return myIsGLStateInitialized; }
132 
133  // For RE_OGLRender methods to pass an RE_Render * to various objects
135  { return reinterpret_cast<RE_Render*>(this); }
136  const RE_Render *getRender() const
137  { return reinterpret_cast<const RE_Render*>(this); }
138 
139  /// ======================================================================
140  /// For new 2D UI drawing.
141  RE_WindowDrawable * getDrawable() { return myWindowDrawable; }
142  /// ======================================================================
143 
144  // RENDERING ENVIRONMENT ------------------------------------------------
145  // You can use these methods to query support for a specific OpenGL
146  // version on the machine Houdini is running on.
147  static bool hasGL11();
148  static bool hasGL12();
149  static bool hasGL13();
150  static bool hasGL14();
151  static bool hasGL15();
152  static bool hasGL20();
153  static bool hasGL21();
154 
155  static bool hasGL3(int minor);
156  static bool hasGL4(int minor);
157 
158  static int glMajorVersion();
159  static int glMinorVersion();
160 
161  // Determines the version of GLSL. Currently it's either 1.xx or 0.0 (unsup)
162  int glslMajorVersion(); // 1
163  int glslMinorVersion(); // 0, 10, 20, 30, 40 or 50
164  int glslMaxOutputComponents(RE_ShaderType stage);
165  int glslMaxUniformComponents(RE_ShaderType stage);
166 
167  bool hasGLExtension(RE_Extension e) const;
168 
169  /// Writes the OpenGL device UUID. Context requires GL_EXT_memory_object,
170  /// which can be checked for with `hasGLExtension(RE_EXT_EXTERNAL_OBJECTS)`
171  /// If the OpenGL context doesn't support that extension, will return
172  /// false and write nothing into `uuid`
173  bool getDeviceUUID(uint8 (&uuid)[GL_UUID_SIZE_EXT]) const;
174  bool getDriverUUID(uint8 (&uuid)[GL_UUID_SIZE_EXT]) const;
175 
176  // Low-level hardware and driver verisons. Use these only to work
177  // around driver issues. All other features should use the GL version,
178  // or RE_OGLExt.
179 
180  // Returns the hardware doing the rendering.
181  static RE_GraphicsDevice getGraphicsDevice();
182 
183  // By default, we early exit without OpenGL 3.3, use this to disable
184  // for just querying GL info.
185  static void setPerformBadDriverCheck(bool onoff);
186 
187  // The driver version. NVidia uses XX.XX, while ATI uses X.XX.XX
188  static bool hasDriverVersion();
189  static int getDriverMajorVersion();
190  static int getDriverMinorVersion();
191  static int getDriverBuildMajorVersion();
192  static int getDriverBuildMinorVersion();
193  static void getDriverInfo(UT_WorkBuffer &info);
194  static const UT_StringMap<UT_StringHolder> &getDriverInfoDict();
195  static bool getUsingCoreProfile();
196  static void setUsingCoreProfile(bool using_core_profile);
197 
198  // Access to the RE_OGLExt methods. Should not be used outside of RE; use
199  // hasGLExtension() instead.
200  RE_OGLExt *getExt() const;
201 
202  // clear out all VBOs and textures in the graphics cache.
203  static void clearGraphicsCache();
204 
205  // Queries to return the total free memory, and optionally the largest
206  // available chunk of memory on the GPU. Extension RE_EXT_MEMORY_QUERY
207  // is required.
208  int64 getFreeTextureMemoryKB(int64 *largest_chunk = nullptr);
209  int64 getFreeBufferMemoryKB(int64 *largest_chunk = nullptr);
210  int64 getFreeFramebufferMemoryKB(int64 *largest_chunk = nullptr);
211 
212  // Returns the amount of free memory on the GPU when Houdini first started.
213  static int64 getInitialFreeMemoryKB();
214 
215  // Call in the case of a fatal startup error due to insufficient driver
216  // support.
217  static void exitWithBadDriver();
218 
219  // MONITOR SCREEN ---------------------------------------------------------
220 
221  static int resX();
222  static int resY();
223 
224  static void updateScreenSize();
225 
226  // Multi-monitor support. Primary monitor is screen 0.
227  //
228  // returns true if all the screens are the same size
229  static bool areScreensUniform();
230  // returns a work area for the screen(s) occupied by 'area', for use when
231  // multiple screens aren't uniform in size.
232  static UT_DimRect getWorkAreaForScreen(UT_DimRect area);
233 
234  // this method positions rect entirely on one screen, shifting if
235  // required. If screen_hint is not -1, the screen containing that
236  // coord will be used. It returns the screen chosen.
237  //
238  static int positionOnScreen(UT_DimRect &area,
239  int screen_hint=-1);
240 
241  // returns true if the area fits entirely within one of the work areas.
242  static bool positionOkay(const UT_DimRect &area);
243 
244  static int dpi(); // system dpi * UI scale
245  static fpreal uiScale(); // UI scale factor (HOUDINI_UISCALE)
246  static void scaleUI(fpreal scale);
247  static float pixelsToInches(int n);
248  static int inchesToPixels(float i);
249  static int scaledSize(int size);
250  static fpreal scaledSize(fpreal size);
251 
252  // does a quick check to determine if the computer entered a suspend (sleep)
253  // mode, where many GPU computed textures and buffers will need to be
254  // recomputed.
255  void checkForSuspendResume();
256  static void addSuspendResumeCB(void (*cb)(void*), void *data);
257  static void removeSuspendResumeCB(void (*cb)(void*), void *data);
258 
259  // DISPLAY MODE & WINDOWS ----------------------------------------------
260 
261  RE_DisplayMode getMode() const;
262  RE_VisualType getVisualType() const;
263 
264  void enableMultisample(bool enable);
265  bool isMultisampleEnabled() const;
266 
267  void enableAlphaToCoverage(bool enable);
268  bool isAlphaToCoverage() const;
269 
270  void getMaxViewportSize(int &w, int &h) const;
271  int getMaxColorSamples() const;
272  int getMaxDepthSamples() const;
273 
274  static RE_Visual *getVisualForMode(RE_DisplayMode newmode);
275  static RE_Server *getServer();
276  static RE_Cursor *getCursor(const char *name);
277 
278  void setWindow(RE_Window *, bool attach = true);
279 
280  bool makeCurrent(bool ignore_errors = false);
281  static void resetCurrent();
282 
283  /// ======================================================================
284  /// For new 2D UI drawing.
285  bool isCurrentRender() const;
286  bool isDrawableContextValid() const;
287  RE_OGLContext getDrawableContext() const;
288  /// ======================================================================
289 
290  /// ======================================================================
291  /// For OpenGL 2D UI drawing.
292  bool isCurrent() const
293  { return theCurrentRender.get() == this; }
294  bool contextIsValid() const { return (bool)myContext; }
295  RE_OGLContext getContext() const { return myContext; }
296  /// ======================================================================
297 
298  /// ======================================================================
299  /// For new 2D UI drawing.
300  /// When using Pbuffers instead of FBOs, we have to set them up as the
301  /// render target. You cannot push more than 1 buffer at a time.
302  bool pushOffscreenBufferToDrawable(RE_WindowDrawable *type);
303  void popOffscreenBufferFromDrawable();
304  /// ======================================================================
305 
306 
307  /// ======================================================================
308  /// For OpenGL 2D UI drawing.
309  /// When using Pbuffers instead of FBOs, we have to set them up as the
310  /// render target. You cannot push more than 1 buffer at a time.
311  bool pushOffscreenBuffer(OGLDrawable type);
312  void popOffscreenBuffer();
313  /// ======================================================================
314 
315  // This is the context of the main window, which should persist always.
316  void setMainContext(RE_Window *w);
317  static RE_Window *getMainContext();
318 
319  static RE_OGLRender *getCurrentRender();
320  static RE_WindowList *getWindowList();
321  const RE_Window *getCurrentWindow() const;
322  RE_Window *getCurrentWindow();
323 
324  // These methods prepares for another thread to access OpenGL.
325  // They are called from the same thread that will be accessing OpenGL.
326  // If they're called from the main thread, they do nothing.
327  //
328  // These methods work by giving each thread its own OpenGL context.
329  // Because other threads do not know when the main thread changes the
330  // OpenGL context or drawable, they must call the prepare...() method
331  // to explicitly set their context, before they main RE/OGL calls.
332  //
333  // These methods do not provide support for concurrent access to RE
334  // from multiple threads: only one thread at a time may make RE calls.
335  // The main thread must be blocked while the other thread makes the
336  // calls. That other thread must call lock...() while the main thread
337  // is blocked, make its RE calls, call unlock...(), and only then may it
338  // unblock the main thread.
339  //
340  // These methods are called by HOMF_HOMGLAutoLock so HOMF methods can
341  // call code that eventually makes OpenGL calls, even when the Python
342  // interpreter is running in a separate thread.
343  void lockContextForRender();
344  void unlockContextAfterRender();
345  bool tryLockContextForRender();
346  bool isContextLocked() const;
347 
348  /// ======================================================================
349  /// For new 2D UI drawing.
350  /// These methods are similar to lockDrawableContextForRender() and
351  /// unlockDrawableContextAfterRender() but they do not set or unset
352  /// the current / OpenGL context.
353  /// {
354  void lockContext();
355  void unlockContext();
356  /// }
357  /// ======================================================================
358 
359  void bumpRenderCount() { myRenderCount ++; }
360  void resetRenderCount() { myRenderCount = 0; }
361  int64 getRenderCount() const { return myRenderCount; }
362 
363  // ERROR REPORTING --------------------------------------------------
364  int getGLError();
365  int getNextGLError();
366  void clearGLErrors();
367  const char *getGLErrorString( int error );
368  void printGLError(const char *header,
369  bool assert = false );
370  void printAllGLErrors( const char *header,
371  bool assert = false );
372 
373  void dumpNewState(bool show_all = false,
374  bool show_shader_blocks = true);
375  void dumpViewportState(bool show_all = false);
376  void dumpTextureState() const;
377  void dumpVertexAttributes() const;
378  void dumpFragmentTests(bool show_all = false) const;
379  void dumpRasterizeState(bool show_all = false) const;
380  void dumpTextureCacheState(int stack_level =-1) const;
381 
382  void getLimits(UT_WorkBuffer &os);
383 
384  // RE_EXT_DEBUG_OUTPUT2 (GL_KHR_debug) required with env HOUDINI_OGL_DEBUG>0
385  bool isDebugLabelSupported() const;
386 
387  // HOUDINI_OGL_DEBUG > 0 and RE_EXT_DEBUG_OUTPUT2 is supported.
388  bool isDebugging() const;
389 
390  int pushDebug(bool enable);
391  void popDebug(int *nest = nullptr);
392 
393  int pushDebugGroup(const char *name, int id=1987);
394  void popDebugGroup(int *nest = nullptr);
395 
396  void addComment(const char *name,
398  int id =1987);
399 
400 
401  // FRAMEBUFFER OBJECTS -------------------------------------------------
402 
403  // There are two bindings for framebuffers, read and draw. If
404  // RE_EXT_FRAME_BUFFER_OBJECT_ARB is not supported, these will be the same.
405  int pushDrawFramebuffer(); // no change to FBO state
406  int pushDrawFramebuffer(RE_OGLFramebuffer *fb);
407  void setDrawFramebuffer(RE_OGLFramebuffer *fb);
408  RE_OGLFramebuffer *getDrawFramebuffer();
409  void popDrawFramebuffer(int *nest = nullptr);
410 
411  int pushReadFramebuffer(); // no change to FBO state
412  int pushReadFramebuffer(RE_OGLFramebuffer *fb);
413  void setReadFramebuffer(RE_OGLFramebuffer *fb);
414  RE_OGLFramebuffer *getReadFramebuffer();
415  void popReadFramebuffer(int *nest = nullptr);
416 
417  void updateFramebuffer();
418  // Only called by RE_OGLFramebuffer; updates the current FBO state.
419  void updateCurrentFramebuffer(RE_OGLFramebuffer *fb,
420  bool for_draw);
421 
422  void registerFBO(RE_OGLFramebuffer *fb, int fb_id);
423  void unregisterFBO(int id);
424  RE_OGLFramebuffer *getFBO(int id) const;
425 
426  // Sample state
427  void useSampleMask(bool use);
428  bool usingSampleMask() const;
429  int getMaxIntegerSamples() const;
430  int getSampleMask(int mask_number);
431  void setSampleMask(int mask_number, int mask);
432  static int getMatteMaskForSampleCount(int samples);
433 
434  // BUFFER CONTROL -------------------------------------------------------
435 
436  // If possible, call clearCZ() instead of clear() followed by clearZ(),
437  // since a single clearCZ() is much faster on all post-Indy machines.
438  void clearC(float *color = nullptr);
439  void clearZ(float z = 1.0);
440  void clearCZ(float z = 1.0);
441  void clearS();
442 
443  // Using these methods, you can disable updates to the colour and/or depth
444  // bits of the frame buffer. Be careful with these, since the associated
445  // calculations will still be performed (eg. even if color buffer updates
446  // are disabled, useless lighting calculations are still done if
447  // GL_LIGHTING is enabled). Same with GL_DEPTH_TEST. So you can easily
448  // write inefficient code.
449  void enableColorBufferWriting();
450  void disableColorBufferWriting();
451  bool getColorBufferWriting();
452  void updateColorBufferWriting();
453 
454  void setColorMask(bool red, bool green, bool blue, bool alpha);
455  void getColorMask(bool &red, bool &green, bool &blue, bool &alpha);
456 
457  bool swapbuffers();
458 
459  // By default, the buffer is not changed (RE_BUFFER_UNINIT)
460  int pushDrawBuffer( RE_RenderBuf buf = RE_BUFFER_UNINIT);
461  void popDrawBuffer(int *nest = 0);
462  void setDrawBuffer( RE_RenderBuf buf );
463  RE_RenderBuf getDrawBuffer();
464  bool getDrawBufferIsBlendable();
465 
466  int pushReadBuffer( RE_RenderBuf buf = RE_BUFFER_UNINIT);
467  void popReadBuffer(int *nest = 0);
468  void setReadBuffer( RE_RenderBuf buf );
469  RE_RenderBuf getReadBuffer();
470 
471  // set by the current window, UI_Window::setContext(). returns if the
472  // front buffer has been written to since last swap (for marquee drawing)
473  //
474  bool isFrontBufferDirty() const;
475  void setFrontBufferDirty(bool d);
476 
477  void flush(int wait=0);
478 
479  /// Ensure all writes are complete to the specified resource(s).
480  /// GL4.2, RE_EXT_BUFFER_STORE or RE_EXT_SHADER_LOAD_STORE must be
481  /// supported, or this will return false, doing nothing.
482  bool memoryBarrier(RE_MemoryBarrierBitfield barriers);
483 
484  // FRUSTUM & CLIPPING ------------------------------------------------
485 
486  // masked rendering (scissor)
487  void viewport2DI(
488  const UT_DimRect &rect,
489  RE_ViewportCoordSpace coord_space =
491  void screenMask2DI(
492  const UT_DimRect &rect,
493  RE_ViewportCoordSpace coord_space =
495  void screenMask2DI(const UT_DimRect &rect, CacheOnlyTag);
496  void screenMask2DI(
497  const UT_DimRect &rect,
498  RE_ViewportCoordSpace coord_space,
499  CacheOnlyTag);
500  void disableScreenMask();
501  void intersectMask2DI(
502  const UT_DimRect &rect,
503  RE_ViewportCoordSpace coord_space =
505  void intersectMask2DI(
506  const UT_DimRect &rect, CacheOnlyTag);
507  void intersectMask2DI(
508  const UT_DimRect &rect,
509  RE_ViewportCoordSpace coord_space,
510  CacheOnlyTag);
511  UT_DimRect getScreenMask2DI();
512  UT_DimRect getScreenMask2DI(CacheOnlyTag);
513  RE_ViewportCoordSpace getScreenMaskCoordSpace() const;
514  UT_DimRect getRawScreenMask2DI();
515  UT_DimRect getViewport2DI();
516  UT_DimRect getViewport2DI(CacheOnlyTag);
517  RE_ViewportCoordSpace getViewportCoordSpace() const;
518  UT_DimRect getRawViewport2DI();
519  bool getScreenMask();
520  void dirtyViewportAndScreenMask();
521 
522  // Clip distance enables
523  int getOGLMaxClipPlanes();
524  void enableClipDistance(int clip_plane, bool enable);
525  bool clipDistanceEnabled(int clip_plane) const;
526 
527  // Active Occlusion query (only 1 active at a time)
528  void setActiveOcclusionQuery(RE_OcclusionQuery *q);
529  RE_OcclusionQuery *getActiveOcclusionQuery() const;
530 
531  // Backface culling
532  int pushBackfaceCulling();
533  int pushBackfaceCulling(bool backface);
534  void popBackfaceCulling(int *nested = 0);
535 
536  bool isBackface() const;
537  void setBackface(bool removeBackface);
538  bool getReverseWinding();
539  void setReverseWinding(bool reverse_winding);
540  RE_FaceMode getCullFace() const;
541  void setCullFace(RE_FaceMode m);
542 
543  // polygon/line offset
544  bool isPointOffset();
545  bool isLineOffset();
546  bool isPolygonOffset();
547  void pointOffset( bool onoff );
548  void lineOffset( bool onoff );
549  void polygonOffset( bool onoff );
550  void setOffsetAmount( float variable, float constant );
551  void getOffsetAmount(float *variable, float *constant) const;
552 
553 
554 
555  // Start collecting vertex/geometry shader attribute output into buffers.
556  // There must be a shader active, and this shader must have one or more
557  // transform feedback buffers enabled. 'mode' must be one of RE_PRIM_POINTS,
558  // RE_PRIM_LINES, or RE_PRIM_TRIANGLES, and only those types can be
559  // rendered. 'rasterize_too' controls whether primitives continue on to the
560  // fragment shader to be rasterized or stop at the transform feedback stage.
561  // 'stream_bitfield' allows multiple vertex streams to be captured when GL4
562  // is present (bit N = vertex stream N).
563  bool beginTransformFeedback(RE_PrimType mode,
564  bool rasterize_too,
565  int stream_bitfield = 0x1);
566 
567  // only call end if begin returned true.
568  void endTransformFeedback();
569 
570  // returns the number of primitives collected in the transform feedback
571  // buffers. Must be called after endTransformFeedback().
572  int getNumFeedbackPrimitives(int stream = 0);
573 
574  // Returns true if the feedback buffers overflowed. Must be called after
575  // endTransformFeedback()
576  bool hasFeedbackBufferOverflow(int stream = 0);
577 
578  // Transform feedback state queries.
579  bool isTransformFeedbackEnabled() const;
580  RE_PrimType getFeedbackMode() const;
581  bool isRasterizeEnabled() const;
582 
583  // Line & Point sizes
584  int pushLineWidth(float w);
585  void popLineWidth(int *nest = nullptr);
586  float getLineWidth() const;
587  float getMaxSmoothLineWidth();
588 
589  int pushPointSize(float size, bool program_point_size = false);
590  void popPointSize(int *nest = nullptr);
591  void setPointSize(float size);
592 
593  // If enabled, point size is taken from vertex or geometry shader's
594  // gl_PointSize output
595  void setProgramPointSize(bool enable);
596  bool getProgramPointSize() const;
597 
598  // STENCIL, LOGIC & DEPTH ------------------------------------------------
599 
600  // The depth state consists of the depth test bit, depth compare function
601  // depth clamp, and the depth buffer writemask. Note that pushBlendState()
602  // can affect the depth buffer writemask, so it is important that if they
603  // are nested, the order of the pops is reversed from the pushes.
604  int pushDepthState();
605  void popDepthState(int *nest = nullptr);
606 
607  // In order to enable depth buffer writes, a depth buffer must be present
608  // in the current window or framebuffer.
609  void enableDepthBufferWriting();
610  void disableDepthBufferWriting();
611  bool getDepthBufferWriting();
612  void updateDepthBufferWriting();
613 
614  // Depth testing must be enabled for depth buffer writes to have any effect.
615  void enableDepthTest();
616  void disableDepthTest();
617  bool getDepthTest();
618  void updateDepthTest();
619 
620  // The depth function only has an effect if depth testing is enabled.
621  void setZFunction(RE_ZFunction func);
622  RE_ZFunction getZFunction() const;
623  void updateZFunction() const;
624 
625  // Depth clamping causes objects outside of [near,far] to clamp their Z to
626  // near or far. By default it is off.
627  void enableDepthClamp(bool b);
628  bool getDepthClamp();
629  void updateDepthClamp();
630 
631  void setDepthRange(double nr, double fr);
632  void getDepthRange(double &nr, double &fr) const;
633 
634  // Stencil state
635  int pushStencilState();
636  void popStencilState(int *nest = nullptr);
637  bool isStencil();
638  void setStencil(bool enable);
639  void setSClearValue(int clearValue);
640  int getSClearValue() const;
641  void setSWriteMask(int writeMask);
642  int getSWriteMask() const;
643  void setSFunction(RE_SFunction func, int ref, int mask);
644  void getSFunction(RE_SFunction *func, int &ref, int &mask);
645  void setSOperation(RE_SOperation sfail,
648  void getSOperation(RE_SOperation *sfail,
650  RE_SOperation *dppass) const;
651  void updateStencilState();
652  void resetSFunction();
653  void resetSWriteMask();
654  void resetSClearValue();
655  void resetSOperation();
656 
657  // Logic state
658  void enableLogicOp();
659  void disableLogicOp();
660  void invertPixels();
661  void xorPixels();
662  void orPixels();
663 
664  // BLENDING and SMOOTHING -----------------------------------------------
665  int pushBlendState();
666  void popBlendState(int *nesting = 0);
667 
668  bool isBlending() const;
669  void blend(int onoff);
670  void setBlendFunction(RE_BlendSourceFactor sourceFactor,
671  RE_BlendDestFactor destFactor);
672  bool setAlphaBlendFunction(RE_BlendSourceFactor sourceFactor,
673  RE_BlendDestFactor destFactor,
674  bool force = false);
675  void getBlendFunction(RE_BlendSourceFactor* sourceFactor,
676  RE_BlendDestFactor* destFactor);
677  void getAlphaBlendFunction(RE_BlendSourceFactor *sourceFactor,
678  RE_BlendDestFactor *destFactor);
679  void setBlendEquation(RE_BlendEquation eq);
680  RE_BlendEquation getBlendEquation();
681 
682  // blendAlpha uses (Sa, 1-Sa). blendAlphaPremult uses (1, 1-Sa) (assumes
683  // color is premultiplied)
684  void blendAlpha(int onoff = 1);
685  void blendAlphaPremult(bool onoff = true);
686 
687  int pushSmoothLines();
688  void popSmoothLines(int *nesting = 0);
689  void forceSmooth();
690  void smoothBlendLines(RE_SmoothMode mode);
691  void smoothBlendLinesNoFlagChange(bool by_smooth);
692  RE_SmoothMode getSmoothLines();
693 
694  int getBlendSmoothLevel() const;
695 
696  static void allowSmoothLines(int yn);
697  static int allowsSmoothLines();
698 
699  static int getGLBlendSource(RE_BlendSourceFactor sourceFactor);
700  static int getGLBlendDest(RE_BlendDestFactor destFactor);
701  static int getGLBlendEquation(RE_BlendEquation eq);
702 
703  // MATERIALS -------------------------------------------------------------
704 
705  // The layer here is indexed from 0, while the layers in the GU_Details
706  // are indexed from 1.
707  void setMaterial(const RE_MaterialPtr &mat,
708  int layer=0, bool texture=true,
710  RE_Shader *override_mat_shader = nullptr,
711  bool allow_partial_render = false);
712  int pushMaterial(const RE_MaterialPtr &mat,
713  int layer=0, bool texture=true,
715  RE_Shader *override_mat_shader = nullptr,
716  bool allow_partial_render = false);
717  int pushMaterial();
718  void popMaterial(int *nest = nullptr);
719 
720 
721  // material used as a default material
722  const RE_MaterialPtr &getDefaultMaterial();
723 
724  // GLSL SHADERS ---------------------------------------------------------
725 
726  int pushShader(); // no change to state
727  int pushShader(RE_Shader *s);
728  int pushShader(RE_ShaderHandle &sh);
729 
730  void bindShader(RE_Shader *s);
731  void bindShader(RE_ShaderHandle &sh);
732 
733  RE_Shader *getShader();
734  void popShader(int *nest = nullptr);
735 
736  void updateShader(RE_Shader *s); // only called by RE_Shader.
737 
738  int pushShaderTransformFeedback(RE_Shader *sh,
740  bool rasterize = true,
741  int stream_bitfield = 0x1);
742  int pushShaderTransformFeedback(RE_ShaderHandle &sh,
744  bool rasterize = true,
745  int stream_bitfield = 0x1);
746  void popShaderTransformFeedback(int *nest = nullptr);
747 
748  // When on, the GL shader will never be set back to nullptr by popShader();
749  // however, an RE_Geometry::draw() command when the shader should be nullptr
750  // will enter fixed function mode. This is basically a 'lazy pop' mode.
751  // immediate mode begin/end should not be used with this shading mode.
752  void setShaderOnlyMode(bool enable);
753  void requestFixedFunction();
754 
755  /// Set the tesselation default outer level parameters (with no tess control
756  /// shader) for the tesselator. Requires RE_EXT_TESS_SHADER or GL4.
757  void setPatchOuterLevel(const UT_Vector4F &outer);
758 
759  /// Set the tesselation default inner level parameters (with no tess control
760  /// shader) for the tesselator. Requires RE_EXT_TESS_SHADER or GL4.
761  void setPatchInnerLevel(const UT_Vector2F &inner);
762 
763  /// Set the number of vertices per patch for tesselation. Requires
764  /// RE_EXT_TESS_SHADER or GL4.
765  void setPatchVertices(int num_verts);
766 
767  // for multisampled buffers on GL4+ hardware, the fragment shader can be
768  // run to produce more than one color sample. The rate is a fraction between
769  // 0.0 and 1.0, which will guarentee at least ceil(rate*samples) color
770  // samples are produced in multisampled buffers. Note this can degrade
771  // performance substantially for some heavy fragment shaders.
772  // If RE_EXT_SAMPLE_SHADING is unsupported, this has no effect and
773  // setShaderSampleRate() will return false.
774  bool setShaderSampleRate(fpreal rate);
775  fpreal getShaderSampleRate() const;
776 
777  bool isSampleShading() const;
778 
779  // Assign a new uniform value to built-in uniform. If nullptr is passed,
780  // the value is unchanged but the current value copied to the uniform stack.
781  void pushUniform(RE_UniformBuiltIn bindex,
782  RE_Uniform *var = nullptr);
783  // Assign raw values to a built-in uniform. The array must be at least of
784  // size getUniform(builtin_var_type)->getByteSize().
785  void pushUniformData(RE_UniformBuiltIn bindex,
786  const void *data);
787  void pushUniformInt(RE_UniformBuiltIn bindex, int i);
788  void pushUniformColor(RE_UniformBuiltIn bindex,
789  const UT_Color &clr, fpreal32 alpha = 1.0f);
790  void pushUniformSampler(RE_UniformBuiltIn bindex,
791  RE_Texture *tex);
792  void pushUniformMatrix(RE_UniformBuiltIn bindex,
793  const UT_Matrix4D &mat);
794  void assignUniformData(RE_UniformBuiltIn bindex,
795  const void *data);
796  void assignUniformInt(RE_UniformBuiltIn bindex, int i);
797  void assignUniformSampler(RE_UniformBuiltIn bindex,
798  RE_Texture *tex);
799  void assignUniformColor(RE_UniformBuiltIn bindex,
800  const UT_Color &clr, fpreal32 alpha = 1.0f);
801  void assignUniformMatrix(RE_UniformBuiltIn bindex,
802  const UT_Matrix4D &mat);
803  void popUniform(RE_UniformBuiltIn bindex);
805  { popUniform(bindex); }
806 
807  RE_Uniform *getUniform(RE_UniformBuiltIn builtin_var_type) const;
808 
809  // Prints all builtins that have been assigned, or only those which the
810  // current shader has bound (if bound_only is true).
811  void printBuiltInUniforms(bool bound_only);
812 
813  // Print a single builtin's current value.
814  void printBuiltInUniform(RE_UniformBuiltIn b);
815 
816  // Bind all builtin uniforms to the shader. Returns the # of uniforms bound
817  int bindBuiltInUniforms(RE_Shader *s);
818 
819  // Bind the specified uniform to the shader. returns true if a uniform was
820  // present to bind.
821  bool bindBuiltInUniform(RE_Shader *s,
822  RE_UniformBuiltIn uniform);
823 
825  { return myBuiltInUniformSerial; }
826  void bumpBuiltInUniformSerial() { myBuiltInUniformSerial++; }
827 
828  // Assigns a generic uniform, which will be bound to any shaders with this
829  // name. These will override any uniform values when the shader is bound, or
830  // values on the current shader when the uniform is pushed. The name and
831  // uniform type must match exactly for an override to occur.
832  // If more than one uniform of the same name and type is pushed, the last
833  // one pushed takes precedent. Popping it will restore the previous uniform.
834  void pushUniform(RE_Uniform &uniform);
835  void popUniform(RE_Uniform &uniform);
836 
837 
838  // Push the object matrix and update the object and object-view uniforms.
839  // If inverse_too is true, compute and push the inverse object matrix.
840  void pushObjectMatrix(const UT_Matrix4D &obj,
841  bool inverse_too = false);
842  void popObjectMatrix();
843 
844 
845 
846  // Sets a GLSL hint to compute derivatives - fast = false, nice = true
847  void setFragmentDerivativeHint(bool nicest);
848  bool getFragmentDerivativeHint();
849 
850  // Maximum number of vertex attributes supported for vertex shader input
851  int getMaxVertexAttribs() const { return myMaxVertexAttribs; }
852 
853  // Set a vertex attribute at input 'loc' to 'vsize' constant values.
854  // 'vsize' must be between 1 and 4.
855  void setConstAttribF32(int loc, int vsize, const fpreal32 *data);
856 
857  // Set a vertex attribute to constant values. Downcasts to FP32 in GL call.
858  void setConstAttribF32(int loc, int vsize, const fpreal64 *data);
859 
860  // Set a vertex attribute to constant values. Sets as proper FP64.
861  void setConstAttribF64(int loc, int vsize, const fpreal64 *data);
862 
863  // Set a vertex attribute to constant values.
864  void setConstAttribI32(int loc, int vsize, const int32 *data);
865 
866  // Set a vertex attribute to constant values.
867  void setConstAttribU32(int loc, int vsize, const uint32 *data);
868 
869  // Dirty the vertex attribute cache.
870  void dirtyConstAttribs();
871 
872  // Notify the context that 'list' is now the current VAO.
873  bool setCurrentVAO(RE_OGLVertexArrayList *list);
874 
875  // Query the current VAO.
876  RE_OGLVertexArrayList *getCurrentVAO();
877 
878  // Query the default VAO for this context.
879  RE_OGLVertexArrayList *getDefaultVAO() { return myDefaultVAO; }
880 
881  // Don't call this.
882  void setDefaultVAO(RE_OGLVertexArrayList *vao) { myDefaultVAO = vao;}
883 
884  // Notify the context that 'list' is being deleted, and any referenece
885  // should be cleared.
886  void resetCurrentVAO(RE_OGLVertexArrayList *deleted_list);
887 
888  // Returns a list of the currently bound uniform blocks to this context.
889  UT_IntArray &getBoundUniformBlocks() { return myState.myBoundUniformBlocks;}
890 
891  // TEXTURING -------------------------------------------------------------
892 
893  // Bind the given texture to the specified, or active, texture unit. The
894  // texturing mode can be optionally set at the same time (if not set to
895  // UNKNOWN). If texturing for the texture's type is not enabled on the
896  // texturing unit, it is enabled.
897  void bindTexture(const RE_OGLTexture *tex,
898  int unit = RE_ACTIVE_UNIT,
900  void verifyTextureIsNotBound(RE_OGLTexture *texture);
901 
902  // Bind texture buffer 'id' to 'unit' and return the previously bound
903  // texture at 'unit'. This is only used by low-level RE methods.
904  RE_TextureID bindTextureBuffer(int id, int unit);
905 
906  RE_TextureID bindTextureRaw2D(int id, int unit);
907  int bindTextureRaw(int id, int unit);
908 
909  // Bind an array of textures starting at 'first'. Requires
910  // RE_EXT_MULTI_BIND. Returns false if this is not supported.
911  bool bindTextures(int first, const UT_IntArray &tex_ids);
912 
913  // Unbind all instances of texture 'tex'. This can be an expensive call.
914  void unbindTexture(const RE_OGLTexture *tex);
915 
916  // Query & set the active texture units. Note these are 0 based,
917  // not GL_TEXTURE0 based.
918  void setActiveTexture(int textureunit);
919  int getActiveTexture() const;
920 
921  // Save the texture state for the specified texture unit, or all of
922  // them (RE_ALL_UNITS). If the entire state is pushed, the active texture
923  // unit is saved as well. RE_ALL_UNITS is relatively expensive, so use
924  // with care. push returns a nesting index which can be passed to pop to
925  // ensure proper nesting of push/pop calls.
926  int pushTextureState(int textureunit = RE_ALL_UNITS);
927  void popTextureState(int *nest = nullptr);
928 
929  // The type and texture object currently bound to the given,
930  // or current (-1), texture unit
931  RE_TextureDimension getBoundTextureType(int texunit = RE_ACTIVE_UNIT) const;
932  const RE_OGLTexture *getBoundTexture(int texunit = RE_ACTIVE_UNIT) const;
933 
934  // Returns the first texture unit with no bound unit, starting the search
935  // at starting_unit. -1 is returned if no free units are available.
936  int findFirstFreeTextureUnit(int starting_unit = 0) const;
937 
938  // Reads in initial values for all the textures.
939  void updateTextureState() const;
940 
941  // Query the maximum number of texture units we support.
943  { return myMaxTextureShaderUnits; }
945  { return myMaxTextureVertexUnits; }
947  { return myMaxTextureGeometryUnits; }
949  { return myMaxTextureFragmentUnits; }
951  { return myMaxTextureAnisotropy; }
952 
953  // Query the maximum size of a texture that is supported (either width or
954  // height)
955  int getMaxTextureSize() const
956  { return myMaxTextureSize; }
958  { return myMaxTexture3DSize; }
960  { return myMaxTextureRectSize; }
961 
962  // Query the maximum number of frame buffer color attachments.
963  int getMaxColorBuffers() const
964  { return myMaxColorBuffers; }
965  // Query the max number of draw buffers.
966  int getMaxDrawBuffers() const
967  { return myMaxDrawBuffers; }
968 
969  // This will disable for all texture units.
970  void disableAllTextures();
971  void removeTextureRefs(RE_OGLTexture *tex);
972 
973  // Bind a texture as an image (requires RE_EXT_IMAGE_LOAD_STORE or GL4.2)
974  bool bindImageTexture(int image_unit,
975  RE_Texture *image,
976  RE_BufferAccess image_access,
977  bool layered,
978  int layer);
979  void unbindImageTexture(int image_unit);
980 
981  //
982 
983  // These methods ensure that the pixel store options are set so that the
984  //
985  int pushReadAlignment(const void *data, int scansize);
986  void popReadAlignment(int *nest = nullptr);
987  int getReadAlignment() const;
988 
989  int pushWriteAlignment(const void *data, int scansize);
990  void popWriteAlignment(int *nest = nullptr);
991  int getWriteAlignment() const;
992 
993  // Enables seamless cubemap filtering for all cubemaps, if supported.
994  void useSeamlessMaps(bool enable);
995  bool usingSeamlessMaps();
996 
997  // Returns an 8b RGBA 64x64 texture with 0-1 random values in all comps.
998  RE_OGLTexture *getRandomTexture(unsigned int seed, bool interp,
999  int size = 64);
1000 
1001  // Returns an 8b RGBA size^3 3D texture with 0-1 random values
1002  RE_OGLTexture *getRandomTexture3D(unsigned int seed, bool interp,
1003  int size = 32);
1004  // Returns an 8b RGBA size^2 2D texture array of size 'num_layers'
1005  RE_OGLTexture *getRandomTextureArray(unsigned int seed, bool interp,
1006  int num_layers, int size = 64 );
1007 
1008  // returns an int32 single channel texture that returns a random sample
1009  // mask. The texture is size x (nsamples+1) in size, with each row having
1010  // 'N' bits randomly enabled, where N is the row # (0..nsamples). This can
1011  // be used for gl_SampleMask
1012  RE_OGLTexture *getRandomSampleMaskTexture(unsigned int seed, int nsamples,
1013  int size = 64);
1014 
1015  // Texture Image drawing ------------------------------------------------
1016 
1017  // makes a texture out of the raster, and stores the id in the raster.
1018  void convertRasterToTexture(PXL_Raster *raster,
1019  int convert16bit = 0,
1020  bool isinteger = false);
1021 #ifdef KARMA_OUTPUT_GPU_BUFFERS
1022  void convertMaskToTexture(PXL_Raster *raster);
1023 #endif
1024  void convertLUTToTexture(PXL_Lookup *lookup);
1025  bool setupShaderForLUT(RE_Shader *shader,
1026  PXL_Lookup *lookup,
1027  float gamma,
1028  bool add_shader);
1029  bool is3DLUTSupported() const;
1030 
1031  void buildRasterTextureGeometry(
1032  fpreal32 x0, fpreal32 y0, fpreal32 z,
1033  fpreal32 x1, fpreal32 y1,
1034  fpreal32 u0, fpreal32 v0,
1036  int rotation, // Must be in the range [-360, 360] in 90 degree increments
1037  RE_Geometry &geo);
1038  void displayRasterTexture(float x, float y, float z,
1039  const PXL_Raster *raster,
1040  const RE_RasterOpts *opts = 0);
1041  void displayRasterTexture(float x, float y, float z,
1042  float w, float h,
1043  const IMG_Raster *raster,
1044  const RE_RasterOpts *opts = 0);
1045  void displayRasterTexture(float x, float y, float z,
1046  int w, int h,
1047  UT_RGBA *r, int stride,
1048  float zoomx=-1.0f,
1049  float zoomy=-1.0f,
1050  int dither=1,
1051  float alpha_mult=1.0f);
1052 
1053  // The saveRaster method saves the front buffer to a raster. The
1054  // raster should be the same size as the w and h parms. As well,
1055  // currently, we only support 8 bit channels in the raster. A zoom of -1
1056  // uses the current zoom (default).
1057  void saveRaster(int x, int y, int w, int h,
1058  IMG_Raster *r, bool use_backbuf = true);
1059  UT_UniquePtr<TIL_Raster> saveRaster(int x, int y, int w, int h,
1060  PXL_DataFormat format, bool alphatoo,
1061  bool use_backbuf = true);
1062 
1063 
1064  // The following method is used to align text in the viewport where the
1065  // current xform makes attempting to use textMove* impractical for this
1066  // purpose.
1067  // NOTE: Clipping is performed using the actual raster position (set
1068  // through textMove*) and not the offset position.
1069  // NOTE: Only works for bitmap fonts, not texture fonts.
1070  void setViewportFontOffset(int x, int y);
1071  int getViewportFontOffsetX() const;
1072  int getViewportFontOffsetY() const;
1073 
1074  RE_FontBuffers *fetchFontBufferFromPool(int size);
1075  void returnFontBufferToPool(RE_FontBuffers *buf);
1076 
1077  // DRAWING METHODS -------------------------------------------------------
1078 
1079  // Begin a conditional render based on an occlusion query's samples result.
1080  // If the query returns zero samples, all drawing is ignored until
1081  // the conditional render is ended. Otherwise, rendering is done as normal.
1082  // Conditional rendering cannot be nested.
1083  //
1084  // 'render_wait' specifies whether the render should wait for the results
1085  // of the occlusion query, if they are not available.
1086  // 'region_support' allows the conditional render to happen at a fine
1087  // grain level, which is implementation specific.
1088 
1089  // beginConditionalRender() will return false if the the query_object has
1090  // not be run yet, if a conditional render is already in progress, or if
1091  // RE_EXT_CONDITIONAL_RENDER is not supported. Do not call
1092  // endConditionalRender() in this case.
1093  bool beginConditionalRender(RE_OcclusionQuery *query_obj,
1094  bool render_wait,
1095  bool region_support);
1096  void endConditionalRender();
1097 
1098  // enables a primitive restart index, which begins a new primitive when
1099  // using an element buffer.
1100  void enablePrimitiveRestart(bool enable);
1101  void setPrimitiveRestartIndex(unsigned int index);
1102 
1103  // A few higher level functions for simple tasks rendering to the
1104  // viewport. These encapsulate a lot of boilerplate code.
1105  void drawViewportPoint(const fpreal32 p[3],
1106  fpreal32 size);
1107  void preDrawViewportString(UT_Matrix4D &view,
1108  UT_Matrix4D &proj,
1109  UT_DimRect &viewport);
1110  void drawViewportString(const fpreal32 p[3],
1111  const char *str,
1112  const UT_Color *clr = nullptr,
1113  const UT_Matrix4D *view = nullptr,
1114  const UT_Matrix4D *proj = nullptr,
1115  const UT_DimRect *viewport = nullptr);
1116  void postDrawViewportString();
1117 
1118  // Called by various RE classes; do not call directly.
1119  static void destroyShaderObject(unsigned int progid, bool unreg,
1120  bool shader);
1121  static void destroyTextureObject(unsigned int texid, RE_OGLTexture *tex);
1122  static void destroyRenderbufferObject(unsigned int rb);
1123  static void destroyBufferObject(unsigned int buf);
1124  static void destroySync(void *sync);
1125 
1126  static void clearCachedUniformBuffer(int id);
1127 
1128  // Context specific objects
1129  void destroyVertexArrayObject(unsigned int vao);
1130  void destroyQuery(unsigned int query);
1131  void destroyFramebufferObject(unsigned int fbo);
1132 
1133  void fetchDriverInfo(UT_WorkBuffer &info, bool full_info);
1134  void fetchDriverPlatformInfo(UT_WorkBuffer &info, bool for_gl);
1135 
1136  // unbind common objects that might get stomped on by HDK calls:
1137  // shader, VAO, textures
1138  void unbindPipeline();
1139 
1140  // Invalidates all cached state. Useful when GL calls outside of RE are
1141  // used which change the GL state away from the cached state, and it is too
1142  // difficult to track the state, which is often the case with HDK plugins.
1143  void invalidateCachedState();
1144 
1145  // If GL calls outside of RE are used and change the state without restoring
1146  // it, call this method to update RE_OGLRender to the new state. This method
1147  // is somewhat expensive (causing a GPU/CPU sync) and should not be called
1148  // frequently or performance will suffer.
1149  void resync() { updateGLState(); }
1150 
1151  // Optimization to do additional buffer management for small buffers.
1152  // It must be turned on before updating any buffers, and then turned off
1153  // again before drawing those same buffers (enable, update, disable, draw).
1154  void enableSubBufferDrawing(bool enable);
1155  bool subBufferDrawingEnabled() const { return mySubBufferDrawing; }
1156 
1157  static RE_ZFunction oglToREzfunc( int oglZFunc );
1158  static int reToOGLzfunc( RE_ZFunction reZFunc );
1159  static RE_SFunction oglToREsfunc( int oglSFunc );
1160  static int reToOGLsfunc( RE_SFunction reSFunc );
1161  static RE_SOperation oglToREsoperation( int oglSOperation );
1162  static int reToOGLsoperation( RE_SOperation reSOperation );
1163 
1164  // use macros for state change functions. Member variables are in
1165  // RE_OGLState.
1166 #define RE_FLAG_STATE(RE_NAME,GL_FLAG) \
1167  void enable##RE_NAME () { REcheckIsOpenGLPainting(); if( myState.my##RE_NAME##State != 1 ) { ::glEnable( GL_FLAG ); myState.my##RE_NAME##State = 1; } } \
1168  void disable##RE_NAME () { REcheckIsOpenGLPainting(); if( myState.my##RE_NAME##State != 0 ) { ::glDisable( GL_FLAG ); myState.my##RE_NAME##State = 0; } } \
1169  bool get##RE_NAME () { if(myState.my##RE_NAME##State == 3) update##RE_NAME(); return (myState.my##RE_NAME##State ==1); } \
1170  void update##RE_NAME () { myState.my##RE_NAME##State = ::glIsEnabled( GL_FLAG ); } \
1171  void invalidate##RE_NAME() { myState.my##RE_NAME##State = 3; }
1172 
1173  RE_FLAG_STATE(Stencil,GL_STENCIL_TEST);
1174 
1175 // Private methods ----------------------------------------------------------
1176 protected:
1177 
1178  /// Protected constructor to avoid having it created standalone. Strong
1179  /// assumptions are made that RE_OGLRender objects are always an instance
1180  /// of an RE_Render subclass.
1181  RE_OGLRender(int do_foreground, const char *appname = 0);
1182 
1183  RE_FLAG_STATE(Scissor,GL_SCISSOR_TEST);
1184  RE_FLAG_STATE(LineSmoothing,GL_LINE_SMOOTH);
1185 #undef RE_FLAG_STATE
1186 
1187 #define RE_FLAG_11_STATE(RE_NAME,GL_FLAG) \
1188  void enable##RE_NAME () { if( (myState.my##RE_NAME##State) != 1 && hasGL11() ) {::glEnable( GLenum(GL_FLAG) ); myState.my##RE_NAME##State = 1; } } \
1189  void disable##RE_NAME () { if( myState.my##RE_NAME##State && hasGL11() ) { ::glDisable( GLenum(GL_FLAG) ); myState.my##RE_NAME##State = 0; } } \
1190  bool get##RE_NAME () { if(myState.my##RE_NAME##State == 3) update##RE_NAME(); return (myState.my##RE_NAME##State==1) ; } \
1191  void update##RE_NAME () { if( hasGL11() ) { myState.my##RE_NAME##State = ::glIsEnabled( GLenum(GL_FLAG) ); } else { myState.my##RE_NAME##State = 0; } } \
1192  void invalidate##RE_NAME() { if(hasGL11()) myState.my##RE_NAME##State=3; }
1193 
1197 #undef RE_FLAG_11_STATE
1198 
1199  void updateOffsetAmount();
1200 
1201  static bool initGLVersionInfo();
1202  virtual void initGLExtensions();
1203  virtual void updateGLState();// load the following state variables
1204  virtual void updateStacks();
1205  void switchTexture(int textureunit, const RE_OGLTexture *texture);
1206 
1207  static void determineTwinView();
1208  bool switchContextForRender(bool ignore_errors);
1209 
1210 #ifdef WIN32
1211 private:
1212 #endif
1213 
1214  void updateBlendSmoothState();
1215  int privPushBlendSmoothState(bool smooth_too);
1216  void privPopBlendSmoothState(bool smooth_too, int *idx);
1217 
1218  void setupDebugging();
1219 
1220  void freePendingObjects();
1221 
1222  UT_DimRect adjustFramebufferViewport(
1223  const UT_DimRect &rect,
1224  RE_ViewportCoordSpace coord_space,
1225  bool to_fbo);
1226 
1227  void assignPushedUniforms();
1228 
1229  void fetchDriverInfoDict(UT_StringMap<UT_StringHolder> &dict);
1230 
1231 protected:
1232  // get the viewportState from GL
1233  void updateViewport();
1234 
1235  static const char *bufferName(GLint e);
1236  static const char *faceName(GLint e);
1237  static const char *hintName(GLint e);
1238  static const char *cullName(GLint e);
1239 
1240  // ---------------------------------------------------------------------
1241  // Cached OpenGL State
1242 
1244 
1245  // ------------------------------------------------------------------------
1246  // State independent data
1247 
1249 
1254 
1256 
1257  /// ======================================================================
1258  /// For new 2D UI drawing.
1262  /// ======================================================================
1263 
1264  /// ======================================================================
1265  /// For OpenGL 2D UI drawing.
1270  /// ======================================================================
1271 
1274 
1286 
1289 
1295 
1298 
1300 
1301  // Bound built-in uniform list for RE_Uniform.
1304  int myBuiltInStackIndex[RE_UNIFORM_BUILT_IN__count];
1305 
1307 
1308  int myViewportFontOffsetX, myViewportFontOffsetY;
1309 
1311 
1313  bool myMaterialTextureStack[RE_MAX_TEXTURE_STATE_STACK];
1314  int myMaterialLayerStack[RE_MAX_TEXTURE_STATE_STACK];
1317 
1327 
1331 
1335 
1338 
1340 
1346 
1348 
1349  // Static data ----------------------------------------------------------
1350  static int majorGLVersion;
1351  static int minorGLVersion;
1354 
1356  static int theXRes;
1357  static int theYRes;
1358  static int theDotsPerInch;
1361 
1365 
1366  // Card and driver info
1368  static int theDriverMajor;
1369  static int theDriverMinor;
1372  static bool theUsingCoreProfile;
1373 
1374  // These objects are per-context.
1378 
1380 
1382  {
1383  public:
1385  : is_cached(false), type(RE_GPU_FLOAT32), vector_size(4)
1386  { value[0] = 0.0; value[1] = 0.0; value[2] = 0.0; value[3] = 0.0; }
1390  fpreal64 value[4];// This is just a scratch buffer for comparing
1391  };
1392 
1396 
1398 
1399  // Suspend check on Linux
1400  void suspendTestPatternRender();
1401  bool suspendTestPatternCheck();
1402 
1409 
1410 protected:
1413 
1414  // which thread this context was created in.
1415  ut_thread_id_t myNativeThread;
1417 
1418  friend class RE_RenderFlush;
1419 
1420 private:
1421 
1422  /// ======================================================================
1423  /// For new 2D UI drawing.
1424  void lockContextInternal_(bool set_current_context);
1425  void unlockContextInternal_(bool clear_current_context);
1426 
1427  void convertToViewportPixelSpace_(UT_DimRect &r);
1428  void convertToViewportLogicalSpace_(UT_DimRect &r);
1429  /// ======================================================================
1430 };
1431 
1433 {
1434 public:
1436  : myR(r),
1437  myLockedFlag(false)
1438  {
1439  if(!myR->isContextLocked())
1440  {
1441  myR->lockContextForRender();
1442  myLockedFlag = true;
1443  }
1444  }
1445 
1447  {
1448  if(myLockedFlag)
1449  {
1450  myR->unlockContextAfterRender();
1451  }
1452  }
1453 
1455 
1456 private:
1457  RE_OGLRender *myR;
1458  bool myLockedFlag;
1459 };
1460 
1461 
1462 // Inlines ---------------------------------------------------------------
1463 
1464 inline bool
1465 RE_OGLRender::hasGL11() { return ((majorGLVersion > 1) ||
1466  ((majorGLVersion >= 1) &&
1467  (minorGLVersion >= 1))); };
1468 inline bool
1469 RE_OGLRender::hasGL12() { return ((majorGLVersion > 1) ||
1470  ((majorGLVersion >= 1) &&
1471  (minorGLVersion >= 2))); };
1472 inline bool
1473 RE_OGLRender::hasGL13() { return ((majorGLVersion > 1) ||
1474  ((majorGLVersion >= 1) &&
1475  (minorGLVersion >= 3))); };
1476 inline bool
1477 RE_OGLRender::hasGL14() { return ((majorGLVersion > 1) ||
1478  ((majorGLVersion >= 1) &&
1479  (minorGLVersion >= 4))); };
1480 inline bool
1481 RE_OGLRender::hasGL15() { return ((majorGLVersion > 1) ||
1482  ((majorGLVersion >= 1) &&
1483  (minorGLVersion >= 5))); };
1484 inline bool
1485 RE_OGLRender::hasGL20() { return ((majorGLVersion > 2) ||
1486  ((majorGLVersion >= 2) &&
1487  (minorGLVersion >= 0))); };
1488 inline bool
1489 RE_OGLRender::hasGL21() { return ((majorGLVersion > 2) ||
1490  ((majorGLVersion >= 2) &&
1491  (minorGLVersion >= 1))); };
1492 
1493 inline bool
1494 RE_OGLRender::hasGL3(int minor) { return ((majorGLVersion > 3) ||
1495  ((majorGLVersion == 3) &&
1496  (minorGLVersion >= minor))); };
1497 
1498 inline bool
1499 RE_OGLRender::hasGL4(int minor) { return ((majorGLVersion > 4) ||
1500  ((majorGLVersion == 4) &&
1501  (minorGLVersion >= minor))); };
1502 
1503 inline int RE_OGLRender::glMajorVersion() { return majorGLVersion; }
1504 inline int RE_OGLRender::glMinorVersion() { return minorGLVersion; }
1505 
1506 inline int RE_OGLRender::glslMajorVersion() { return majorGLSLVersion; }
1507 inline int RE_OGLRender::glslMinorVersion() { return minorGLSLVersion; }
1508 
1509 inline RE_GraphicsDevice
1510 RE_OGLRender::getGraphicsDevice() { return theDevice; }
1511 
1513 {
1514  return !(theDriverMajor == 0
1515  && theDriverMinor == 0
1516  && theDriverBuildMajor == 0
1517  && theDriverBuildMinor == 0);
1518 }
1519 inline int RE_OGLRender::getDriverMajorVersion() { return theDriverMajor;}
1520 inline int RE_OGLRender::getDriverMinorVersion() { return theDriverMinor;}
1521 inline int RE_OGLRender::getDriverBuildMajorVersion() { return theDriverBuildMajor;}
1522 inline int RE_OGLRender::getDriverBuildMinorVersion() { return theDriverBuildMinor;}
1523 
1524 inline RE_OGLExt *RE_OGLRender::getExt() const { return myExt; }
1526 {
1527  UT_ASSERT_P( myExt );
1528  return myExt->hasExtension( e );
1529 }
1530 
1531 inline int RE_OGLRender::resX() { return theXRes; }
1532 inline int RE_OGLRender::resY() { return theYRes; }
1533 inline int RE_OGLRender::dpi()
1534 {
1535  return SYSrint(theDotsPerInch * uiScale());
1536 }
1537 
1539 {
1540  if(theUIScale <= 0.0)
1541  return 1.0;
1542 
1543  return theUIScale;
1544 }
1545 
1546 inline float
1548 {
1549  return (float)n / dpi();
1550 }
1551 
1552 inline int
1554 {
1555  return (int)SYSrint(i*(float)dpi());
1556 }
1557 
1558 inline int
1560 {
1561  if (size == 0)
1562  return size;
1563 
1564  // Add 0.5 for rounding.
1565  fpreal scaled_size = scaledSize((fpreal)size) + 0.5;
1566 
1567  if (scaled_size < 1.0)
1568  return 1;
1569 
1570  return (int)scaled_size;
1571 }
1572 
1573 inline fpreal
1575 {
1576 #if defined(MBSD)
1577  // Native Qt widgets are automatically scaled by the OS using the display's
1578  // backing scale factor. Scaling again will make native Qt UI look
1579  // comically out-of-place.
1580  return size;
1581 #else
1582  if (size == 0)
1583  return size;
1584 
1585  fpreal ui_scale = uiScale();
1586  if (ui_scale == 1.0)
1587  return size;
1588 
1589  fpreal scaled_size = ui_scale * size;
1590  return scaled_size;
1591 #endif
1592 }
1593 
1594 inline RE_Window *
1595 RE_OGLRender::getMainContext() { return theMainContextWindow; }
1596 
1597 inline RE_OGLRender *
1598 RE_OGLRender::getCurrentRender() { return theCurrentRender.get(); }
1599 
1600 inline RE_WindowList *
1601 RE_OGLRender::getWindowList() { return theWindowList; }
1602 
1603 inline const RE_Window *
1604 RE_OGLRender::getCurrentWindow() const { return currentWindow; }
1605 
1606 inline RE_Window *
1607 RE_OGLRender::getCurrentWindow() { return currentWindow; }
1608 
1609 inline bool
1611 { return myFrontBufferDirty;}
1612 
1613 inline void
1615 { myFrontBufferDirty = d; }
1616 
1617 inline int
1618 RE_OGLRender::getOGLMaxClipPlanes() { return maxClipPlanes; }
1619 
1620 inline bool
1621 RE_OGLRender::isPointOffset() { return getPointOffset(); }
1622 
1623 inline bool
1624 RE_OGLRender::isLineOffset() { return getLineOffset(); }
1625 
1626 inline bool
1627 RE_OGLRender::isPolygonOffset() { return getFillOffset(); }
1628 
1629 inline void
1631 {
1632  if( onoff )
1633  enablePointOffset();
1634  else
1635  disablePointOffset();
1636 }
1637 
1638 inline void
1640 {
1641  if( onoff )
1642  enableLineOffset();
1643  else
1644  disableLineOffset();
1645 }
1646 
1647 inline void
1649 {
1650  if( onoff )
1651  enableFillOffset();
1652  else
1653  disableFillOffset();
1654 }
1655 
1656 inline void
1657 RE_OGLRender::getOffsetAmount(float *variable, float *constant) const
1658 {
1659  *variable = myState._offset_variable;
1660  *constant = myState._offset_constant;
1661 }
1662 
1663 inline bool
1665 {
1666  return myState.myBlendSmoothStack[myState.myBlendSmoothLevel].myBlend==1;
1667 }
1668 inline int
1670 {
1671  return myState.myBlendSmoothLevel;
1672 }
1673 
1674 inline void RE_OGLRender::allowSmoothLines(int yn) { theSmoothLinesAllowed=yn; }
1675 inline int RE_OGLRender::allowsSmoothLines() { return theSmoothLinesAllowed; }
1676 
1677 inline int
1679 { return myViewportFontOffsetX; }
1680 
1681 inline int
1683 { return myViewportFontOffsetY; }
1684 
1685 
1686 inline bool
1688 {
1689  return myTransformFeedbackEnabled;
1690 }
1691 
1692 inline RE_PrimType
1694 {
1695  return myTransformFeedbackType;
1696 }
1697 
1698 inline bool
1700 {
1701  return myRasterizeEnabled;
1702 }
1703 
1704 inline RE_Uniform *
1706 {
1707  return myBuiltInUniforms[builtin_var_type];
1708 }
1709 
1710 inline bool
1712 {
1713  return myDebugLabelSupported;
1714 }
1715 
1716 inline bool
1718 {
1719  return myDebuggingSupported;
1720 }
1721 
1722 #endif
void rasterize(const PointDataTreeOrGridT &points, TransferT &transfer)
Perform potentially complex rasterization from a user defined transfer scheme. See below comments for...
GLuint GLuint stream
Definition: glcorearb.h:1832
int getMaxDrawBuffers() const
Definition: RE_OGLRender.h:966
UT_IntArray myPendingDeleteFBOs
RE_OGLExt * getExt() const
GLenum query
Definition: glad.h:2772
GLint first
Definition: glcorearb.h:405
static int scaledSize(int size)
static int getDriverMajorVersion()
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glcorearb.h:2540
RE_PrimType getFeedbackMode() const
bool isRasterizeEnabled() const
bool myMultisampleEnable
int myDebugGroupStackSize
RV_API RV_VKImagePtr getRandomTextureArray(RV_Render *r, unsigned int seed, bool interp, int num_layers, int size=64)
Returns an 8b RGBA size^2 2D texture array of size 'num_layers'.
bool isInitialized() const
Definition: RE_OGLRender.h:121
int GLint
Definition: cl.hpp:165
UT_Vector2F myLineWidthRange
int int32
Definition: SYS_Types.h:39
bool myIsGLStateInitialized
bool isFrontBufferDirty() const
void setPointSize(fpreal32 size)
OGLDrawable myPushedDrawable
static int inchesToPixels(float i)
#define RE_API
Definition: RE_API.h:10
bool isGLStateInitialized() const
Definition: RE_OGLRender.h:131
bool mySampleShading
#define RE_FLAG_11_STATE(RE_NAME, GL_FLAG)
int myFragmentDerivativeHint
==========================================================================
Definition: RE_Window.h:56
int getMaxTexture3DSize() const
Definition: RE_OGLRender.h:957
static RE_GraphicsDevice theDevice
static int theDriverBuildMinor
RE_FaceMode
Definition: RE_Types.h:471
RE_TextureMode
GLsizei const GLfloat * value
Definition: glcorearb.h:824
RE_OGLFramebuffer * mySuspendTestFBO
RE_PrimType myTransformFeedbackType
RE_GraphicsDevice
Definition: RE_Types.h:648
#define RE_ALL_UNITS
GLdouble GLdouble GLdouble z
Definition: glcorearb.h:848
#define GL_POLYGON_OFFSET_POINT
Definition: glcorearb.h:311
bool myDebugLabelSupported
int64 myBuiltInUniformSerial
RE_WindowDrawable * myWindowDrawable
A collection of vertex arrays defining a geometry object. This class acts as a wrapper around multipl...
Definition: RE_Geometry.h:52
bool isBlending() const
GLdouble s
Definition: glad.h:3009
int getContextID() const
Definition: RE_OGLRender.h:118
static bool hasGL20()
void resetRenderCount()
Definition: RE_OGLRender.h:360
int64 myRenderCount
bool isPolygonOffset()
GLenum sfail
Definition: glcorearb.h:782
RE_Severity
Definition: RE_Types.h:637
RE_WindowDrawable * myPushedWindowDrawable
static UT_Array< std::pair< RE_Visual *, RE_DisplayMode > > theVisuals
GLenum GLenum GLsizei void * image
Definition: glad.h:5132
GLint y
Definition: glcorearb.h:103
static bool hasGL12()
static int allowsSmoothLines()
UT_IntArray myPendingDeleteQueries
void pointOffset(bool onoff)
RE_TextureDimension
GLdouble GLdouble GLdouble q
Definition: glad.h:2445
UT_IntArray myClipDistance
bool subBufferDrawingEnabled() const
int myMaxTextureAnisotropy
UT_RecursiveSpinLock myOpenGLLock
======================================================================
float fpreal32
Definition: SYS_Types.h:200
GLdouble u1
Definition: glad.h:2676
#define GL_STENCIL_TEST
Definition: glcorearb.h:267
GLenum GLenum GLenum dppass
Definition: glcorearb.h:782
int getViewportFontOffsetX() const
bool isPointOffset()
static int glMinorVersion()
static fpreal uiScale()
static RE_GraphicsDevice getGraphicsDevice()
#define GL_POLYGON_OFFSET_FILL
Definition: glcorearb.h:313
void lineOffset(bool onoff)
static int minorGLVersion
int myMaxVertexAttribs
GLenum GLuint GLint GLint layer
Definition: glcorearb.h:1299
int myMaxTextureRectSize
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
< returns > If no error
Definition: snippets.dox:2
static RE_WindowList * theWindowList
int myMaxTexture3DSize
static bool hasGL14()
double fpreal64
Definition: SYS_Types.h:201
unsigned char uint8
Definition: SYS_Types.h:36
RE_ShaderType
Definition: RE_Types.h:235
bool isCurrent() const
======================================================================
Definition: RE_OGLRender.h:292
static bool hasGL13()
vint4 blend(const vint4 &a, const vint4 &b, const vbool4 &mask)
Definition: simd.h:4949
int myMaxDebugGroupStackSize
RE_OGLTexture * mySuspendTestTexture
void getOffsetAmount(float *variable, float *constant) const
GA_API const UT_StringHolder scale
RE_GPUType
Definition: RE_Types.h:52
static fpreal theUIScale
GLdouble n
Definition: glcorearb.h:2008
UT_IntArray myPendingDeleteVertexArrays
int getMaxColorBuffers() const
Definition: RE_OGLRender.h:963
int getOGLMaxClipPlanes()
RE_Window * currentWindow
GLfloat f
Definition: glcorearb.h:1926
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:108
RE_Uniform * getUniform(RE_UniformBuiltIn builtin_var_type) const
bool myDebuggingSupported
static int getDriverMinorVersion()
int myMaxTextureGeometryUnits
int getBlendSmoothLevel() const
UT_IntArray & getBoundUniformBlocks()
Definition: RE_OGLRender.h:889
RE_OcclusionQuery * myActiveQuery
static int theXRes
int getMaxShaderTextureUnits() const
Definition: RE_OGLRender.h:942
#define RE_ACTIVE_UNIT
void pushLineWidth()
int getMaxVertexTextureUnits() const
Definition: RE_OGLRender.h:944
void bumpBuiltInUniformSerial()
Definition: RE_OGLRender.h:826
GLint ref
Definition: glcorearb.h:124
static RE_Window * theMainContextWindow
#define GL_UUID_SIZE_EXT
Definition: glApi.h:796
#define UT_ASSERT_P(ZZ)
Definition: UT_Assert.h:164
static int theDriverMajor
RE_Geometry * mySuspendBox
unsigned int RE_TextureID
GLuint GLint GLboolean layered
Definition: glcorearb.h:2222
UT_StopWatch * mySuspendCheckTimer
GLint GLint GLsizei GLint GLenum format
Definition: glcorearb.h:108
GLfloat green
Definition: glcorearb.h:112
bool contextIsValid() const
Definition: RE_OGLRender.h:294
GLint GLenum GLboolean GLsizei stride
Definition: glcorearb.h:872
GLdouble y1
Definition: glad.h:2349
bool myActiveConditionalRender
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
GLint GLuint mask
Definition: glcorearb.h:124
RE_SmoothMode
Definition: RE_Types.h:465
static RE_Server * theServer
UT_ArrayMap< int, RE_OGLFramebuffer * > myFBOTable
int getViewportFontOffsetY() const
HUSD_API const char * raster()
RE_BlendEquation
Definition: RE_Types.h:539
long long int64
Definition: SYS_Types.h:116
static RE_Window * getMainContext()
static int getDriverBuildMinorVersion()
png_const_structrp png_const_inforp int * unit
Definition: png.h:2161
GLfloat GLfloat GLfloat alpha
Definition: glcorearb.h:112
#define RE_MAX_TEXTURE_STATE_STACK
SIM_API const UT_StringHolder rotation
RE_UniformBuiltIn
Definition: RE_Uniform.h:28
UT_Array< RE_FeedbackPrimitivesWrittenQuery * > myTransformFeedbackWrittenQuery
static int resY()
int myViewportFontOffsetY
int glslMinorVersion()
RE_MemoryBarrierBitfield
Definition: RE_Types.h:556
GLuint const GLchar * name
Definition: glcorearb.h:786
OPENVDB_API void initialize()
Global registration of native Grid, Transform, Metadata and Point attribute types. Also initializes blosc (if enabled).
Definition: logging.h:294
RE_DisplayMode
Definition: RE_Types.h:580
RE_ZFunction
Definition: RE_Types.h:478
PXL_DataFormat
Definition: PXL_Common.h:20
static UT_ThreadSpecificValue< RE_OGLRender * > theCurrentRender
void polygonOffset(bool onoff)
int myMaxTextureFragmentUnits
int myMaxTransformFeedbackComponents
static void allowSmoothLines(int yn)
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
GLint GLenum GLint x
Definition: glcorearb.h:409
short currentDisplayMode
RE_OGLFramebuffer * mySuspendResultFBO
bool myContextInitialized
OGLDrawable myDrawable
int myMaxTextureVertexUnits
#define RE_FLAG_STATE(RE_NAME, GL_FLAG)
RE_ViewportCoordSpace
Definition: RE_Types.h:930
RE_OGLExt * myExt
RE_OGLTexture * mySuspendResultTexture
GLsizei samples
Definition: glcorearb.h:1298
int getMaxTextureSize() const
Definition: RE_OGLRender.h:955
RE_OGLVertexArrayList * getDefaultVAO()
Definition: RE_OGLRender.h:879
bool hasGLExtension(RE_Extension e) const
GLenum mode
Definition: glcorearb.h:99
GLfloat v0
Definition: glcorearb.h:816
int getMaxFragmentTextureUnits() const
Definition: RE_OGLRender.h:948
RE_OGLContext getContext() const
Definition: RE_OGLRender.h:295
bool isDebugging() const
int myVertexMaxStreams
static int theDotsPerInch
void bumpRenderCount()
Definition: RE_OGLRender.h:359
int myShaderOnlyModeCount
*tasks wait()
static int theDriverBuildMajor
RE_OGLState myState
GLenum GLenum dpfail
Definition: glcorearb.h:782
const RE_Render * getRender() const
Definition: RE_OGLRender.h:136
static int getDriverBuildMajorVersion()
static bool theSmoothLinesAllowed
GLsizeiptr size
Definition: glcorearb.h:664
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2002
RE_RenderAutoLock(RE_OGLRender *r)
GLuint shader
Definition: glcorearb.h:785
GLenum func
Definition: glcorearb.h:783
static RE_WindowList * getWindowList()
RE_BufferAccess
Definition: RE_Types.h:321
void pushPointSize(fpreal32 size)
Point options that can change per-point.
bool isTransformFeedbackEnabled() const
int glslMajorVersion()
#define GL_LINE_SMOOTH
Definition: glcorearb.h:253
SIM_API const UT_StringHolder force
RE_Render * getRender()
Definition: RE_OGLRender.h:134
GLuint color
Definition: glcorearb.h:1261
UT_Array< RE_Uniform * > myPushedUniforms
int64 getBuiltInUniformSerial() const
Definition: RE_OGLRender.h:824
static bool hasGL15()
bool myIsAllowingOtherThreads
fpreal64 fpreal
Definition: SYS_Types.h:283
void popLineWidth()
static int theDriverMinor
const RE_Window * getCurrentWindow() const
static bool hasGL4(int minor)
bool isDebugLabelSupported() const
RE_SOperation
Definition: RE_Types.h:502
int myMaxTextureShaderUnits
GLuint index
Definition: glcorearb.h:786
RE_OGLContext myContext
======================================================================
fpreal myShaderSampleRate
RE_VisualType
Definition: RE_Types.h:630
GLfloat GLfloat v1
Definition: glcorearb.h:817
int getTextureAnisotropyLimit() const
Definition: RE_OGLRender.h:950
GLint maxClipPlanes
RE_BlendSourceFactor
Definition: RE_Types.h:514
ut_thread_id_t myNativeThread
int myMaxTransformFeedbackBuffers
static float pixelsToInches(int n)
static int dpi()
unsigned int uint32
Definition: SYS_Types.h:40
static bool hasDriverVersion()
UT_IntArray myDebugStack
bool myMaterialLighting
fpreal32 SYSrint(const fpreal32 val)
Definition: SYS_Floor.h:164
RV_API RV_VKImagePtr getRandomTexture(RV_Render *r, unsigned int seed, bool interp, int size=64)
Returns an 8b RGBA 64x64 texture with 0-1 random values in all comps.
int64 getRenderCount() const
Definition: RE_OGLRender.h:361
GLuint texture
Definition: glcorearb.h:415
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
RE_RenderBuf
Definition: RE_Types.h:437
bool myTransformFeedbackEnabled
int getMaxVertexAttribs() const
Definition: RE_OGLRender.h:851
static bool theUsingCoreProfile
RE_Window * mySavedMainThreadCurrentWindow
static bool hasGL3(int minor)
RE_OGLVertexArrayList * myCurrentVAO
bool myRasterizeEnabled
bool isLineOffset()
GLboolean r
Definition: glcorearb.h:1222
bool mySubBufferDrawing
GLfloat GLfloat blue
Definition: glcorearb.h:112
int getMaxGeometryTextureUnits() const
Definition: RE_OGLRender.h:946
void popUniformData(RE_UniformBuiltIn bindex)
Definition: RE_OGLRender.h:804
void setDefaultVAO(RE_OGLVertexArrayList *vao)
Definition: RE_OGLRender.h:882
RE_ShaderTarget
Definition: RE_Types.h:275
static UT_ThreadSpecificValue< RE_OGLRender * > theLastRender
static int resX()
void popPointSize()
int getMaxTextureRectangleSize()
Definition: RE_OGLRender.h:959
static bool hasGL21()
RE_WindowDrawable * getDrawable()
Definition: RE_OGLRender.h:141
QOpenGLContext * RE_OGLContext
Definition: RE_Types.h:956
#define GL_SCISSOR_TEST
Definition: glcorearb.h:286
void setFrontBufferDirty(bool d)
UT_Array< RE_PrimitivesGeneratedQuery * > myTransformFeedbackPrimitiveQuery
UT_Array< re_ConstVertexAttrib > myConstVertexAttribs
static int theYRes
RE_Shader * myShaderOnlyActiveShader
RE_PrimType
Definition: RE_Types.h:199
RE_SFunction
Definition: RE_Types.h:490
png_structrp int png_fixed_point red
Definition: png.h:1083
RV_API RV_VKImagePtr getRandomTexture3D(RV_Render *r, unsigned int seed, bool interp, int size=32)
Returns an 8b RGBA size^3 3D texture with 0-1 random values.
bool myFrontBufferDirty
#define RE_BUFFER_STACK_SIZE
Definition: RE_Types.h:942
RE_OGLVertexArrayList * myDefaultVAO
RE_Extension
Definition: RE_Extension.h:4
RE_OGLContext pushedGraphicsContext
bool firstInitialize
bool myMultisampleAlphaToCoverage
Definition: RE_Uniform.h:389
Definition: format.h:1821
int myOpenGLContextLockCount
static int majorGLVersion
#define GL_POLYGON_OFFSET_LINE
Definition: glcorearb.h:312
GA_API const UT_StringHolder area
static RE_OGLRender * getCurrentRender()
Simple interface to building a shader from a .prog file.
RE_BlendDestFactor
Definition: RE_Types.h:527
static int glMajorVersion()