00001
00002 #include <stdio.h>
00003
00004 #include <ocean/GLvish/VRenderObject.hpp>
00005 #include <ocean/plankton/VCreator.hpp>
00006 #include <ocean/plankton/VTime.hpp>
00007 #include <ocean/GLvish/BoundingBox.hpp>
00008
00009 #include <stdio.h>
00010
00011 using namespace Wizt;
00012
00013
00032
00033
00034
00035
00036
00037
00038 class TextureObject : public VRenderObject
00039 {
00040 GLubyte ubImage[65536];
00041
00042 virtual void render(VRenderContext&Context) const;
00043
00044 public:
00045 TypedSlot<double> Complexity;
00046
00047 TextureObject(const string&name, int p, const RefPtr<VCreationPreferences>&VP)
00048 : VRenderObject(name, p, VP)
00049 {
00050 int j;
00051 GLubyte *img;
00052 GLsizei imgWidth = 128;
00053
00054
00055 img = ubImage;
00056 for (j = 0; j < 32 * imgWidth; j++) {
00057 *img++ = 0xff;
00058 *img++ = 0x00;
00059 *img++ = 0x00;
00060 *img++ = 0xff;
00061 }
00062 for (j = 0; j < 32 * imgWidth; j++) {
00063 *img++ = 0xff;
00064 *img++ = 0x00;
00065 *img++ = 0xff;
00066 *img++ = 0x00;
00067 }
00068 for (j = 0; j < 32 * imgWidth; j++) {
00069 *img++ = 0xff;
00070 *img++ = 0xff;
00071 *img++ = 0x00;
00072 *img++ = 0x00;
00073 }
00074 for (j = 0; j < 32 * imgWidth; j++) {
00075 *img++ = 0x00;
00076 *img++ = 0xff;
00077 *img++ = 0x00;
00078 *img++ = 0xff;
00079 }
00080 }
00081
00082 ~TextureObject()
00083 {}
00084 };
00085
00086 void TextureObject::render(VRenderContext&Context) const
00087 {
00088 glMatrixMode(GL_PROJECTION);
00089 glLoadIdentity();
00090 gluPerspective(60.0, 1.0, 0.1, 1000.0);
00091 glMatrixMode(GL_MODELVIEW);
00092 glDisable(GL_DITHER);
00093
00094 {
00095 glEnable(GL_TEXTURE_2D);
00096 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
00097 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
00098 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
00099 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
00100
00101 #if GL_EXT_abgr
00102 glTexImage2D(GL_TEXTURE_2D, 0, 3, 128, 128, 0, GL_ABGR_EXT,
00103 GL_UNSIGNED_BYTE, ubImage);
00104
00105 glBegin(GL_POLYGON);
00106 glTexCoord2f(1.0, 1.0);
00107 glVertex3f(-0.2, 0.8, -100.0);
00108 glTexCoord2f(0.0, 1.0);
00109 glVertex3f(-0.8, 0.8, -2.0);
00110 glTexCoord2f(0.0, 0.0);
00111 glVertex3f(-0.8, 0.2, -2.0);
00112 glTexCoord2f(1.0, 0.0);
00113 glVertex3f(-0.2, 0.2, -100.0);
00114 glEnd();
00115 #endif
00116
00117 glTexImage2D(GL_TEXTURE_2D, 0, 3, 128, 128, 0, GL_RGB,
00118 GL_UNSIGNED_BYTE, ubImage);
00119
00120 glBegin(GL_POLYGON);
00121 glTexCoord2f(1.0, 1.0);
00122 glVertex3f(0.8, 0.8, -2.0);
00123 glTexCoord2f(0.0, 1.0);
00124 glVertex3f(0.2, 0.8, -100.0);
00125 glTexCoord2f(0.0, 0.0);
00126 glVertex3f(0.2, 0.2, -100.0);
00127 glTexCoord2f(1.0, 0.0);
00128 glVertex3f(0.8, 0.2, -2.0);
00129 glEnd();
00130
00131 glDisable(GL_TEXTURE_2D);
00132 }
00133
00134
00135 }
00136
00137 static Ref<VCreator<TextureObject> > MyCreator("Tutorial/TextureObject", 0);
00138
00139
00140
00141
00142
00143 VISH_DEFAULT_INIT
00144
00145