Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include <iostream>
00012 #include <fstream>
00013
00014 #include "glut-demo/glut-demo.h"
00015 #include "opengl-effects/opengl-effects.h"
00016 #include "perf/perf.h"
00017 #include "wave-glut/texture.h"
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 class Drawer : public glut::DemoHost {
00028 public:
00029 Drawer(IN int size) throw() : m_size(size), m_textureId(0) { }
00030 ~Drawer(void) throw() { }
00031
00032
00033 void onInit(void) {
00034
00035 media::image_t img;
00036 img_color_t color(255, 0, 255);
00037 glut::createSphericalDensityMap(m_size, color, img);
00038 img.dump("test image == spherical density map");
00039
00040
00041 m_textureId = glut::createTextureFromImage(img);
00042 DPRINTF("Texture ID: %d", m_textureId);
00043 }
00044
00045 void display3D(IN const glut::render_context_t& rc,
00046 IN glut::RenderQueue * rq) {
00047 ASSERT(rq, "null");
00048
00049 glutSolidSphere(1.0, 16, 16);
00050
00051
00052 float normal[3] = { 0, 0, 1 };
00053 glEnable(GL_TEXTURE_2D);
00054 glBindTexture(GL_TEXTURE_2D, m_textureId);
00055 glNormal3fv(normal);
00056
00057
00058 glBegin(GL_POLYGON);
00059
00060 glTexCoord2f(0, 0);
00061 glVertex3f(-1, -1, -2);
00062
00063 glTexCoord2f(0, 1);
00064 glVertex3f(-1, +1, -2);
00065
00066 glTexCoord2f(1, 1);
00067 glVertex3f(+1, +1, -2);
00068
00069 glTexCoord2f(1, 0);
00070 glVertex3f(+1, -1, -2);
00071
00072 glEnd();
00073
00074
00075 glDisable(GL_TEXTURE_2D);
00076 }
00077
00078 private:
00079 int m_size;
00080 int m_textureId;
00081 };
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091 int
00092 main
00093 (
00094 IN int argc,
00095 IN const char * argv[]
00096 )
00097 {
00098 ASSERT(2 == argc, "Usage: opengl-effects-test <size>\n");
00099 int size = atoi(argv[1]);
00100 ASSERT(size > 0, "Bad size: %d", size);
00101
00102 try {
00103
00104 std::string title = "OpenGL Effects Test";
00105
00106
00107 smart_ptr<glut::DemoHost> host = new Drawer(size);
00108 ASSERT(host, "out of memory");
00109 glut::startDemo(argc, argv, title.c_str(), host);
00110
00111 } catch (std::exception& e) {
00112 DPRINTF("Exception: %s", e.what());
00113 }
00114
00115
00116 return -1;
00117 }
00118