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 
34 {
35 public:
36  RE_Render(int do_foreground, const char *appname = 0);
37  virtual ~RE_Render();
38 
39  static void setMainRender(RE_Render * main);
40  static RE_Render * getMainRender();
41  static bool isMainRenderInitialized();
42 
43  // The list of OpenGL render contexts that are currently available
44  static int getNumRenderContexts();
45  static RE_Render *getRenderContext(int index);
46 
47  static RE_Render *findRenderWithID(int id);
48  static RE_Render *findRenderWithContext(RE_OGLContext context);
49 
50 
51  // Control whether or not to allow adaptive subdivision in the viewport.
52  static bool getAllowAdaptiveSubd();
53  static void setAllowAdaptiveSubd(bool allow);
54 
55  // High DPI mode upscales some elements.
56  static bool isHighDPIMode();
57 
58  // Creates a new OpenGL context using the same drawable as this context.
59  RE_Render *createNewRenderContext();
60 
61 #if !defined(EXPERIMENTAL_GL_DRAWABLE_FEEL)
62  // Creates a new OpenGL context using a new offscreen window. Delete the
63  // created window to free the render when finished.
64  static RE_Render *createNewOffscreenContext(RE_Window *&win);
65 #else
66  // Creates a new OpenGL context using a new offscreen drawable. Delete the
67  // created drawable to free the render when finished.
68  static RE_Render *createNewOffscreenContext(RE_GLDrawable *&drawable);
69 #endif
70 
71 private:
72  static RE_Render * theMainRender;
73 };
74 
75 
76 RE_API extern RE_Render *REgetRender();
79 
80 // Inches are an arbitrary unit that get translated into pixels based on the
81 // current DPI setting of the server (which in turn is modified by the
82 // HOUDINI_UISCALE env variable). Inches scale with the DPI.
83 
84 inline int REtoPixels(fpreal inches)
85 {
86  return RE_OGLRender::inchesToPixels(inches);
87 }
88 
90 {
91  return RE_OGLRender::pixelsToInches(pixels);
92 }
93 
94 // When using pixels, absolute pixel values do not scale with the DPI, they
95 // always assume a DPI of 85. These methds will scale a pixel length using the
96 // current DPI to 85dpi ratio.
97 
98 inline int REtoScaledPixels(int pixels)
99 {
100  if(pixels != 0)
101  {
102  return SYSmax(1, (int) SYSrint(pixels *
104  }
105  return 0;
106 }
107 inline int REfromScaledPixels(int pixels)
108 {
109  return (int) SYSrint(pixels * (RE_DEFAULT_DPI/RE_OGLRender::dpi()));
110 }
111 
112 RE_API extern fpreal REgetScreenToDeviceScale(int screen=-1);
113 
114 #endif // __RE_Render__
#define SYSmax(a, b)
Definition: SYS_Math.h:1447
RE_Render * REgetMainRender()
Definition: RE_Render.h:77
static int inchesToPixels(float i)
#define RE_API
Definition: RE_API.h:10
int REtoPixels(fpreal inches)
Definition: RE_Render.h:84
GLuint index
Definition: glew.h:1814
int REtoScaledPixels(int pixels)
Definition: RE_Render.h:98
fpreal REtoInches(int pixels)
Definition: RE_Render.h:89
#define RE_DEFAULT_DPI
Definition: RE_Types.h:393
int main(int argc, char *argv[])
Definition: cvexsample.C:147
RE_API fpreal REgetScreenToDeviceScale(int screen=-1)
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const void * pixels
Definition: glew.h:1254
fpreal32 SYSrint(fpreal32 val)
Definition: SYS_Floor.h:163
double fpreal
Definition: SYS_Types.h:276
static bool isMainRenderInitialized()
RE_API RE_Render * REgetRender()
int REfromScaledPixels(int pixels)
Definition: RE_Render.h:107
static float pixelsToInches(int n)
static int dpi()
bool REisMainRenderInitialized()
Definition: RE_Render.h:78
QOpenGLContext * RE_OGLContext
Definition: RE_Types.h:891
static RE_Render * getMainRender()