HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RE_Render.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_Render.h ( RE Library, C++)
7  */
8 
9 #ifndef __RE_Render__
10 #define __RE_Render__
11 
12 /*****************************************************************************
13 
14 DESCRIPTION:
15 
16 RE_Render is a switcher for platform-dependent renderers. Code using
17 RE_Render should therefore be platform-independent.
18 
19 *****************************************************************************/
20 
21 #include "RE_API.h"
22 #include <SYS/SYS_Floor.h>
23 #include <SYS/SYS_Math.h>
24 #include <UT/UT_Unicode.h>
25 #include "RE_OGLRender.h"
26 
27 class QWidget;
28 
29 #if defined(EXPERIMENTAL_GL_DRAWABLE_FEEL)
30 class RE_GLDrawable;
31 #endif
32 
33 #if defined(EXPERIMENTAL_VULKAN)
34 class RV_Instance;
35 #endif
36 
38 {
39 public:
40  RE_Render(int do_foreground, const char *appname = 0);
41  ~RE_Render() override;
42 
43  static void setMainRender(RE_Render * main);
44  static RE_Render * getMainRender();
45  static bool isMainRenderInitialized();
46 
47  // The list of OpenGL render contexts that are currently available
48  static int getNumRenderContexts();
49  static RE_Render *getRenderContext(int index);
50 
51  static RE_Render *findRenderWithID(int id);
52  static RE_Render *findRenderWithContext(RE_OGLContext context);
53 
54 
55  // Control whether or not to allow adaptive subdivision in the viewport.
56  static bool getAllowAdaptiveSubd();
57  static void setAllowAdaptiveSubd(bool allow);
58 
59  // High DPI mode upscales some elements.
60  static bool isHighDPIMode();
61 
62  // Creates a new OpenGL context using the same drawable as this context.
63  RE_Render *createNewRenderContext();
64 
65 #if !defined(EXPERIMENTAL_GL_DRAWABLE_FEEL)
66  // Creates a new OpenGL context using a new offscreen window. Delete the
67  // created window to free the render when finished.
68  static RE_Render *createNewOffscreenContext(RE_Window *&win);
69 #else
70  // Creates a new OpenGL context using a new offscreen drawable. Delete the
71  // created drawable to free the render when finished.
72  static RE_Render *createNewOffscreenContext(RE_GLDrawable *&drawable);
73 #endif
74 
75 #if defined(EXPERIMENTAL_VULKAN)
76  static void setVulkanInst(RV_Instance* newVkInst)
77  { theVulkanInstance = newVkInst; }
78 
79  static RV_Instance* getVulkanInst()
80  { return theVulkanInstance; }
81 #endif
82 
83 private:
84  static RE_Render * theMainRender;
85 #if defined(EXPERIMENTAL_VULKAN)
86  static RV_Instance* theVulkanInstance;
87 #endif
88 };
89 
90 
91 RE_API extern RE_Render *REgetRender();
94 
95 // Inches are an arbitrary unit that get translated into pixels based on the
96 // current DPI setting of the server (which in turn is modified by the
97 // HOUDINI_UISCALE env variable). Inches scale with the DPI.
98 
99 inline int REtoPixels(fpreal inches)
100 {
101  return RE_OGLRender::inchesToPixels(inches);
102 }
103 
105 {
106  return RE_OGLRender::pixelsToInches(pixels);
107 }
108 
109 // When using pixels, absolute pixel values do not scale with the DPI, they
110 // always assume a DPI of 85. These methds will scale a pixel length using the
111 // current DPI to 85dpi ratio.
112 
113 inline int REtoScaledPixels(int pixels)
114 {
115  if(pixels != 0)
116  {
117  return SYSmax(1, (int) SYSrint(pixels *
119  }
120  return 0;
121 }
122 inline int REfromScaledPixels(int pixels)
123 {
124  return (int) SYSrint(pixels * (RE_DEFAULT_DPI/RE_OGLRender::dpi()));
125 }
126 
127 RE_API extern fpreal REgetScreenToDeviceScale(int screen=-1);
128 
129 #endif // __RE_Render__
#define SYSmax(a, b)
Definition: SYS_Math.h:1513
RE_Render * REgetMainRender()
Definition: RE_Render.h:92
static int inchesToPixels(float i)
#define RE_API
Definition: RE_API.h:10
int REtoPixels(fpreal inches)
Definition: RE_Render.h:99
int REtoScaledPixels(int pixels)
Definition: RE_Render.h:113
fpreal REtoInches(int pixels)
Definition: RE_Render.h:104
#define RE_DEFAULT_DPI
Definition: RE_Types.h:402
int main(int argc, char *argv[])
Definition: cvexsample.C:147
RE_API fpreal REgetScreenToDeviceScale(int screen=-1)
fpreal32 SYSrint(fpreal32 val)
Definition: SYS_Floor.h:163
static bool isMainRenderInitialized()
fpreal64 fpreal
Definition: SYS_Types.h:277
RE_API RE_Render * REgetRender()
GLuint index
Definition: glcorearb.h:786
int REfromScaledPixels(int pixels)
Definition: RE_Render.h:122
static float pixelsToInches(int n)
static int dpi()
bool REisMainRenderInitialized()
Definition: RE_Render.h:93
QOpenGLContext * RE_OGLContext
Definition: RE_Types.h:921
GLint GLint GLsizei GLint GLenum GLenum const void * pixels
Definition: glcorearb.h:108
static RE_Render * getMainRender()