All pastes #388951 Raw Edit

Someone

public text v1 · immutable
·published 2007-03-10 12:26 UTC
rendered paste body
=== modified file 'phimage.cpp'
--- phimage.cpp 2007-03-09 17:33:26 +0000
+++ phimage.cpp 2007-03-10 12:22:17 +0000
@@ -19,6 +19,7 @@
 #include <gtkmm.h>
 #include <math.h>
 #include <sys/timeb.h>
+//#include <math.h>
 
 #define ESCAPE 27
 
@@ -26,6 +27,7 @@
 
 void keyPressed(unsigned char key, int x, int y);
 void ReSizeGLScene(int Width, int Height);
+void DrawGLScene();
 
 class TextureLoader
 {
@@ -132,8 +134,9 @@
        gint true_window;
        gint tilesize, tilequality, buffersize, blendtime, hangtime;
        uint counter;
-       char *dir, *resolution, *angle, *constraint, *speed, *o_distance, *o_perspective;
-       float distance, perspective, xm, ym, xr, yr, movth, rotth;
+       char *dir, *resolution, *constraint, *speed, *o_distance, *o_perspective, *o_angle;
+       float distance, perspective, xm, ym, xr, yr, movth, rotth; 
+       float theta, thetar, angle;
        gint window;
        GdkInterpType realtilequality;
        vector <Glib::ustring> files;
@@ -155,6 +158,8 @@
 phimage::phimage(int argc, char **argv)
 {
        true_window = 0;
+//     theta = 0.0;
+//     thetar = 0.0;
        this->check_options();
        this->init_options(argc, argv);
        this->get_files();
@@ -220,7 +225,7 @@
        tilesize=512;
        tilequality=1;
        dir=".";
-       angle="5";
+       angle=5.0;
        buffersize=16384;
        blendtime=300;
        hangtime=100;
@@ -333,8 +338,8 @@
                glutEnterGameMode();
        }
 
-//     glutDisplayFunc(self.DrawGLScene)
-//     glutIdleFunc(self.DrawGLScene)
+       glutDisplayFunc(&DrawGLScene);
+       glutIdleFunc(&DrawGLScene);
 
        glutReshapeFunc(&ReSizeGLScene);
        glutKeyboardFunc(&keyPressed);
@@ -373,7 +378,7 @@
   { "tilesize", 't', 0, G_OPTION_ARG_INT, &tilesize, "Tile Size", "N" },
   { "tilequality", 'q', 0, G_OPTION_ARG_INT, &tilequality, "Tile Quality", "M" },
   { "dir", 'd', 0, G_OPTION_ARG_STRING, &dir, "Directory", NULL },
-  { "angle", 'a', 0, G_OPTION_ARG_STRING, &angle, "Angle", NULL },
+  { "angle", 'a', 0, G_OPTION_ARG_STRING, &o_angle, "Angle", NULL },
 
   { "buffersize", 'b', 0, G_OPTION_ARG_INT, &buffersize, "Buffer Size", "N" },
   { "blendtime", 'B', 0, G_OPTION_ARG_INT, &blendtime, "Blend Time", "M" },
@@ -403,6 +408,13 @@
                std::istringstream i(o_perspective);
                i >> perspective;
        }
+
+//     if (o_angle)
+//     {
+//             std::istringstream i(o_angle);
+//             i >> angle;
+//     }
+
        if (o_distance)
        {
                std::istringstream w(o_distance);
@@ -481,7 +493,66 @@
        glLoadIdentity();
 }
 
-
+void DrawGLScene()
+{
+/*
+               float xmov, ymov, xmovr, ymovr;
+               //self.stateChecker()
+               //Trying to imporve performance here
+               glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+               //glClear(GL_COLOR_BUFFER_BIT);
+               glLoadIdentity();
+               glTranslatef(0.0,0.0,-globalObject->distance);
+
+               xmov = sin(globalObject->theta);
+               ymov = cos(globalObject->theta);
+               xmovr = sin(globalObject->thetar);
+               ymovr = cos(globalObject->thetar);
+
+               glTranslatef(xmov*globalObject->xm,ymov*globalObject->ym,0);
+
+               glRotatef (-ymovr*globalObject->yr, 0.0, 1.0, 0.0);
+               glRotatef (xmovr*globalObject->xr, 1.0, 0.0, 0.0);
+               glRotatef(globalObject->angle,0.0,1.0,0.0);
+ 
+               glColor4f(1.0, 1.0, 1.0, 1.0);
+                       //glColor4f(1.0, 1.0, 1.0, self.alpha[0])
+               glBindTexture(GL_TEXTURE_2D, globalObject->textureName[0]);
+               glBegin(GL_QUADS);
+
+               glTexCoord2f(0.0, 1.0); glVertex2f(-1.0, -1.0);
+               glTexCoord2f(1.0, 1.0); glVertex2f( 1.0, -1.0);
+               glTexCoord2f(1.0, 0.0); glVertex2f( 1.0,  1.0);
+               glTexCoord2f(0.0, 0.0); glVertex2f(-1.0,  1.0);
+
+ 
+               glEnd();
+
+               glTranslatef(-2*xmov*globalObject->xm,-2*ymov*globalObject->ym,0);
+               glRotatef(-2*(globalObject->angle),0.0,1.0,0.0);
+
+               //glColor4f(1.0, 1.0, 1.0, self.alpha[1])
+               glBindTexture(GL_TEXTURE_2D,globalObject->textureName[1]);
+               glBegin(GL_QUADS);
+ 
+               glTexCoord2f(0.0, 1.0); glVertex2f(-1.0, -1.0);
+               glTexCoord2f(1.0, 1.0); glVertex2f( 1.0, -1.0);
+               glTexCoord2f(1.0, 0.0); glVertex2f( 1.0,  1.0);
+               glTexCoord2f(0.0, 0.0); glVertex2f(-1.0,  1.0);
+ 
+               glEnd();
+
+
+//             if time.time() - self.d2 >= .0001:
+//                     self.d2 = time.time()
+//                     self.theta = self.theta + self.movth
+//                     self.thetar = self.thetar + self.rotth
+
+               glBlendFunc(GL_SRC_ALPHA,GL_ONE);
+               glFlush();
+               glutSwapBuffers();
+*/
+}
 
 int main(int argc, char *argv[]) {