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 void putString(const char *string); 00041 void putChar(char c); 00042 00043 int getNumLinesInString(const char *string) const; 00044 void putMultiLineString(const char *string); 00045 00046 void setFont(RE_Font *f); 00047 00048 static void setMainRender(RE_Render * main); 00049 static RE_Render * getMainRender(); 00050 static bool isMainRenderInitialized(); 00051 00052 // The list of OpenGL render contexts that are currently available 00053 static int getNumRenderContexts(); 00054 static RE_Render *getRenderContext(int index); 00055 00056 private: 00057 // Nobody should ever call this. It is useful only as an implementation 00058 // helper. Use UIgetDefaultFont() instead. 00059 RE_Font *getDefaultFont(); 00060 00061 RE_Font *myFont; 00062 RE_Font *myDefaultFont; 00063 00064 static RE_Render * theMainRender; 00065 }; 00066 00067 00068 RE_API extern RE_Render *REgetRender(); 00069 inline RE_Render *REgetMainRender() { return RE_Render::getMainRender(); } 00070 inline bool REisMainRenderInitialized() { return RE_Render::isMainRenderInitialized(); } 00071 00072 // Inches are an arbitrary unit that get translated into pixels based on the 00073 // current DPI setting of the server (which in turn is modified by the 00074 // HOUDINI_UISCALE env variable). Inches scale with the DPI. 00075 00076 inline int REtoPixels(fpreal inches) 00077 { 00078 return RE_OGLRender::inchesToPixels(inches); 00079 } 00080 00081 inline fpreal REtoInches(int pixels) 00082 { 00083 return RE_OGLRender::pixelsToInches(pixels); 00084 } 00085 00086 // When using pixels, absolute pixel values do not scale with the DPI, they 00087 // always assume a DPI of 85. These methds will scale a pixel length using the 00088 // current DPI to 85dpi ratio. 00089 00090 inline int REtoScaledPixels(int pixels) 00091 { 00092 if(pixels != 0) 00093 { 00094 return SYSmax(1, (int) SYSrint(pixels * 00095 (RE_OGLRender::dpi()/RE_DEFAULT_DPI))); 00096 } 00097 return 0; 00098 } 00099 inline int REfromScaledPixels(int pixels) 00100 { 00101 return (int) SYSrint(pixels * (RE_DEFAULT_DPI/RE_OGLRender::dpi())); 00102 } 00103 00104 #endif // __RE_Render__
1.5.9