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