00001 #include <ocean/plankton/VCreator.hpp> 00002 #include <ocean/GLvish/VRenderObject.hpp> 00003 #include <ocean/plankton/VTime.hpp> 00004 00005 00006 using namespace Wizt; 00007 00013 00014 class DefaultBackground : public VRenderObject 00015 { 00016 override void render(VRenderContext&Context) const 00017 { 00018 GLclampf red=1, green=1, blue=1, alpha=1; 00019 int r=100, g=100, b=100; 00020 getParameterValue(r, "red", Context); 00021 red = r/100.; 00022 getParameterValue(g, "green", Context); 00023 green = g/100.; 00024 //puts("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"); 00025 if (!getParameterValue(b, "blue", Context) ) 00026 puts("COULD NOT GET BLUE!"); 00027 #if 0 00028 printf("Background: BLUE is %d\n", b); 00029 00030 VParameterReference*VPR = getParameterReference("blue"); 00031 if (!VPR) puts("NO blue parameter"); 00032 else VPR->p.speak( VPR->member.c_str() ); 00033 00034 printf("Parameter has type %s\n", 00035 Typename( VPR->p->getType( VPR->member ) ).c_str() 00036 ); 00037 fflush(stdout); 00038 #endif 00039 00040 00041 blue = b/100.; 00042 00043 glClearColor( red, 00044 green, 00045 blue, 00046 alpha ); 00047 00048 glClear(GL_COLOR_BUFFER_BIT); 00049 } 00050 00051 public: 00052 const std::type_info&getType() const 00053 { 00054 return typeid( DefaultBackground ); 00055 } 00056 00057 DefaultBackground(const string&name, int p, const RefPtr<VCreationPreferences>&VP) 00058 : VRenderObject(name, BACKGROUND_OBJECT+p, VP) 00059 { 00060 addParam("blue" , 53, new VCreationPreferences("local") ); 00061 addParam("green", 65, new VCreationPreferences("local") ); 00062 addParam("red" , 65, new VCreationPreferences("local") ); 00063 } 00064 }; 00065 00066 00067 /* 00068 An OpenGL background which uses a background color depending 00069 on a time parameter. 00070 */ 00071 class DynamicBackground : public VRenderObject 00072 { 00073 override void render(VRenderContext&Context) const 00074 { 00075 VTime t; 00076 getParameterValue(t, "time", Context); 00077 00078 GLclampf red=1, green=1, blue=1, alpha=1; 00079 00080 int r=100, g=100, b=100; 00081 getParameterValue(r, "red", Context); 00082 red = r/100. - t(); 00083 getParameterValue(g, "green", Context); 00084 green = g/100. + t(); 00085 getParameterValue(b, "blue", Context); 00086 blue = b/100.; 00087 00088 glClearColor( red, 00089 green, 00090 blue, 00091 alpha ); 00092 00093 glClear(GL_COLOR_BUFFER_BIT); 00094 } 00095 00096 public: 00097 const std::type_info&getType() const 00098 { 00099 return typeid( DynamicBackground ); 00100 } 00101 00102 DynamicBackground (const string&name, int p, const RefPtr<VCreationPreferences>&VP) 00103 : VRenderObject(name, BACKGROUND_OBJECT+p, VP) 00104 { 00105 addParam("time", VTime(0) );//->LocalizeVariable(); 00106 00107 addParam("blue" , 53, new VCreationPreferences("local") ); 00108 addParam("green", 65, new VCreationPreferences("local") ); 00109 addParam("red" , 65, new VCreationPreferences("local") ); 00110 } 00111 }; 00112 00113 00114 static VCreator<DefaultBackground> myBackground("Background"); 00115 00116 static VCreator<DynamicBackground> myDynamicBackground("DynamicBackground"); 00117