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