00001 #ifndef __RE_Render__ 00002 #define __RE_Render__ 00003 00004 #include "RE_API.h" 00005 /***************************************************************************** 00006 00007 DESCRIPTION: 00008 00009 RE_Render is a switcher for platform-dependent renderers. Code using 00010 RE_Render should therefore be platform-independent. 00011 00012 *****************************************************************************/ 00013 00014 00015 /***************************************************************************** 00016 00017 RE_Render switcher 00018 00019 *****************************************************************************/ 00020 00021 // Find out what platform we're compiling for from RE_Platform.h 00022 #include "RE_Platform.h" 00023 00024 #ifdef PLATFORM_OPEN_GL 00025 00026 #include "RE_OGLRender.h" 00027 00028 #include <SYS/SYS_Floor.h> 00029 #include <SYS/SYS_Math.h> 00030 00031 class RE_API RE_Render : public RE_OGLRender 00032 00033 #endif 00034 00035 { 00036 public: 00037 RE_Render(int do_foreground, const char *appname = 0); 00038 virtual ~RE_Render(); 00039 00040 virtual RE_Render *getRender() { return this; } 00041 00042 void putString(const char *string); 00043 void putChar(char c); 00044 00045 int getNumLinesInString(const char *string) const; 00046 void putMultiLineString(const char *string); 00047 00048 void setFont(RE_Font *f); 00049 00050 static void setMainRender(RE_Render * main); 00051 static RE_Render * getMainRender(); 00052 static bool isMainRenderInitialized(); 00053 00054 // The list of OpenGL render contexts that are currently available 00055 static int getNumRenderContexts(); 00056 static RE_Render *getRenderContext(int index); 00057 00058 // Creates a new OpenGL context using the same drawable as this context. 00059 RE_Render *createNewRenderContext(); 00060 00061 private: 00062 // Nobody should ever call this. It is useful only as an implementation 00063 // helper. Use UIgetDefaultFont() instead. 00064 RE_Font *getDefaultFont(); 00065 00066 RE_Font *myFont; 00067 RE_Font *myDefaultFont; 00068 00069 static RE_Render * theMainRender; 00070 }; 00071 00072 00073 RE_API extern RE_Render *REgetRender(); 00074 inline RE_Render *REgetMainRender() { return RE_Render::getMainRender(); } 00075 inline bool REisMainRenderInitialized() { return RE_Render::isMainRenderInitialized(); } 00076 00077 // Inches are an arbitrary unit that get translated into pixels based on the 00078 // current DPI setting of the server (which in turn is modified by the 00079 // HOUDINI_UISCALE env variable). Inches scale with the DPI. 00080 00081 inline int REtoPixels(fpreal inches) 00082 { 00083 return RE_OGLRender::inchesToPixels(inches); 00084 } 00085 00086 inline fpreal REtoInches(int pixels) 00087 { 00088 return RE_OGLRender::pixelsToInches(pixels); 00089 } 00090 00091 // When using pixels, absolute pixel values do not scale with the DPI, they 00092 // always assume a DPI of 85. These methds will scale a pixel length using the 00093 // current DPI to 85dpi ratio. 00094 00095 inline int REtoScaledPixels(int pixels) 00096 { 00097 if(pixels != 0) 00098 { 00099 return SYSmax(1, (int) SYSrint(pixels * 00100 (RE_OGLRender::dpi()/RE_DEFAULT_DPI))); 00101 } 00102 return 0; 00103 } 00104 inline int REfromScaledPixels(int pixels) 00105 { 00106 return (int) SYSrint(pixels * (RE_DEFAULT_DPI/RE_OGLRender::dpi())); 00107 } 00108 00109 #endif // __RE_Render__
1.5.9