usata-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Usata-commits] Changes to usata2/src/objects/test_object.cpp


From: David Lau
Subject: [Usata-commits] Changes to usata2/src/objects/test_object.cpp
Date: Sat, 15 Jan 2005 14:17:35 -0500

Index: usata2/src/objects/test_object.cpp
diff -u usata2/src/objects/test_object.cpp:1.9 
usata2/src/objects/test_object.cpp:1.10
--- usata2/src/objects/test_object.cpp:1.9      Mon Jan 10 20:10:21 2005
+++ usata2/src/objects/test_object.cpp  Sat Jan 15 19:17:35 2005
@@ -10,27 +10,32 @@
 // included in the software distribution, or visit
 // http://www.fsf.org/licenses/gpl.html.
 //
-// $Id: test_object.cpp,v 1.9 2005/01/10 20:10:21 skunix Exp $
+// $Id: test_object.cpp,v 1.10 2005/01/15 19:17:35 skunix Exp $
 
 #include "../object.hpp"
 #include "../object-registry.hpp"
 #include "../scene-manager.hpp"
+#include "../texture.hpp"
 #include <boost/format.hpp>
 #include <GL/glew.h>
 
+#include <iostream>
+
 namespace
 {
        using namespace usata;
        
        class Something : public Object, public GCInterface
        {
+               Texture_sp t;
+               int spin;
                public:
                
                        virtual void    realize(Usata&, const Object_sp& );
                        Something();
                        virtual ResourceList 
                                                        construct(const 
ObjectProperties&){return ResourceList();}
-                       virtual void    update(void){};
+                       virtual void    update(void);
                        virtual void    draw (void);
                        virtual                 ~Something(){};
        };
@@ -41,19 +46,37 @@
 
        }
 
-       
+       void    
+       Something::update(void)
+       {
+               //std::cout << "up" << std::endl;
+               spin++;
+               while (spin >360) spin -= 360;
+       }
        void
        Something::draw()
        {
+               glPushMatrix();
+               glEnable(GL_TEXTURE_2D);
+               glBindTexture(GL_TEXTURE_2D, t->get_tex());
+               
+               glTranslatef(0,0,-1.0);
+               glRotatef(spin, 0, 1,0);
+
                glBegin(GL_TRIANGLES);
-               glVertex3f(1.0, 0.0, -1.0);
-               glVertex3f(1.0, -0.2, -1.0);
-               glVertex3f(0, -0.5 ,-1.0);
+               glTexCoord2f(0,0);
+               glVertex3f(-.5, 0.0, .0);
+               glTexCoord2f(1,1);
+               glVertex3f(0.5, -0.5, .0);
+               glTexCoord2f(0,1);
+               glVertex3f(-0.5, -0.5 ,.0);
                glEnd();
+               glPopMatrix();
        }
        void
        Something::realize(Usata& game, const Object_sp& self)
        {
+               t = game.textures().get("atex");        
                game.scene().add(self, "gui");
        }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]