]> Dogcows Code - chaz/yoink/blobdiff - src/YoinkApp.cc
scene drawing correctly implemented; new classes
[chaz/yoink] / src / YoinkApp.cc
index 232c097425b4f3a70803951644e3bdf634d1e203..023b3a30ce51837365e60d22136cc8a2e04cdce3 100644 (file)
@@ -50,6 +50,7 @@ static std::string configFiles()
        std::string files;
 
        char* configFile = getenv("YOINKRC");
        std::string files;
 
        char* configFile = getenv("YOINKRC");
+       char* dataDir = getenv("YOINK_DATADIR");
 
        if (configFile)
        {
 
        if (configFile)
        {
@@ -59,8 +60,23 @@ static std::string configFiles()
                files += ":";
        }
 
                files += ":";
        }
 
+       // add the colon-delimited paths from configure
        files += YOINK_CONFIGFILES;
 
        files += YOINK_CONFIGFILES;
 
+       if (dataDir)
+       {
+               // if another data directory is set in the environment, look for a
+               // config file there
+               files += ":";
+               files += dataDir;
+               files += "/yoinkrc";
+       }
+
+       // look in the configured data directory last of all
+       files += ":";
+       files += (dataDir ? dataDir : YOINK_DATADIR);
+       files += "/yoinkrc";
+
        return files;
 }
 
        return files;
 }
 
@@ -71,8 +87,11 @@ static std::string iconFile()
        // first set up the search paths so we can find the icon and other resources
        if (dataDir)
        {
        // first set up the search paths so we can find the icon and other resources
        if (dataDir)
        {
+               // look first in the data directory specified by the environment
                Mf::Resource::addSearchPath(dataDir);
        }
                Mf::Resource::addSearchPath(dataDir);
        }
+
+       // then look in the configured data directory
        Mf::Resource::addSearchPath(YOINK_DATADIR);
 
        return Mf::Resource::getPathToResource("yoink.png");
        Mf::Resource::addSearchPath(YOINK_DATADIR);
 
        return Mf::Resource::getPathToResource("yoink.png");
@@ -125,7 +144,7 @@ void YoinkApp::setupGL()
        glEnable(GL_DEPTH_TEST);
 
        glShadeModel(GL_SMOOTH);
        glEnable(GL_DEPTH_TEST);
 
        glShadeModel(GL_SMOOTH);
-       glEnable(GL_POLYGON_SMOOTH);
+       //glEnable(GL_POLYGON_SMOOTH);
 
        //int texSize;
        //glGetIntegerv(GL_MAX_TEXTURE_SIZE, &texSize);
 
        //int texSize;
        //glGetIntegerv(GL_MAX_TEXTURE_SIZE, &texSize);
@@ -138,6 +157,10 @@ void YoinkApp::setupGL()
 
        glClearColor(1.0, 0.0, 0.0, 1.0);
 
 
        glClearColor(1.0, 0.0, 0.0, 1.0);
 
+       glMatrixMode(GL_PROJECTION);
+       glLoadIdentity();
+       gluPerspective(60.0, 1.33333, 1.0, 2500.0);
+       
        //glLineWidth(10.0f);
 }
 
        //glLineWidth(10.0f);
 }
 
@@ -155,6 +178,8 @@ void YoinkApp::update(Mf::Scalar t, Mf::Scalar dt)
        
        fadeIn.update(dt);
 
        
        fadeIn.update(dt);
 
+       camera.update(t, dt);
+
        someChar->getAnimation().update(t, dt);
        interp.update(dt);
 
        someChar->getAnimation().update(t, dt);
        interp.update(dt);
 
@@ -177,16 +202,13 @@ void YoinkApp::draw(Mf::Scalar alpha)
        
 
 
        
 
 
-       glMatrixMode(GL_PROJECTION);
-       glLoadIdentity();
-       gluPerspective(60.0, 1.33333, 1.0, 2000.0);
-       
        glMatrixMode(GL_MODELVIEW);
        glMatrixMode(GL_MODELVIEW);
-       glLoadIdentity();
+       //glLoadIdentity();
 
        glBindTexture(GL_TEXTURE_2D, 0);
        //glRotatef(drawstate*15.0f, 0.0, 1.0, 0.0);
 
        glBindTexture(GL_TEXTURE_2D, 0);
        //glRotatef(drawstate*15.0f, 0.0, 1.0, 0.0);
-       glTranslatef(x, y, z);
+       //glTranslatef(x, y, z);
+       glLoadMatrix(camera.getTransformation().data());
 
        // DRAW THE SCENE
        testScene->draw(alpha);
 
        // DRAW THE SCENE
        testScene->draw(alpha);
@@ -327,30 +349,43 @@ void YoinkApp::handleEvent(const Mf::Event& event)
                        {
                                someChar->getAnimation().startSequence("Punch");
                        }
                        {
                                someChar->getAnimation().startSequence("Punch");
                        }
-                       else if (event.key.keysym.sym == SDLK_RIGHT)
-                       {
-                               x -= 50.0;
-                       }
-                       else if (event.key.keysym.sym == SDLK_LEFT)
-                       {
-                               x += 50.0;
-                       }
-                       else if (event.key.keysym.sym == SDLK_UP)
-                       {
-                               y -= 50.0;
-                       }
-                       else if (event.key.keysym.sym == SDLK_DOWN)
+                       else if (event.key.keysym.sym == SDLK_r)
                        {
                        {
-                               y += 50.0;
+                               testScene->refresh();
                        }
                        }
-                       else if (event.key.keysym.sym == SDLK_PAGEUP)
+                       else if (event.key.keysym.sym == SDLK_l)
                        {
                        {
-                               z += 50.0;
-                       }
-                       else if (event.key.keysym.sym == SDLK_PAGEDOWN)
-                       {
-                               z -= 50.0;
+                               getVideo().toggleCursorGrab();
+                               getVideo().toggleCursorVisible();
                        }
                        }
+                       //else if (event.key.keysym.sym == SDLK_RIGHT)
+                       //{
+                               //x -= 50.0;
+                       //}
+                       //else if (event.key.keysym.sym == SDLK_LEFT)
+                       //{
+                               //x += 50.0;
+                       //}
+                       //else if (event.key.keysym.sym == SDLK_UP)
+                       //{
+                               //y -= 50.0;
+                       //}
+                       //else if (event.key.keysym.sym == SDLK_DOWN)
+                       //{
+                               //y += 50.0;
+                       //}
+                       //else if (event.key.keysym.sym == SDLK_PAGEUP)
+                       //{
+                               //z += 50.0;
+                       //}
+                       //else if (event.key.keysym.sym == SDLK_PAGEDOWN)
+                       //{
+                               //z -= 50.0;
+                       //}
+
+               case SDL_MOUSEMOTION:
+               case SDL_MOUSEBUTTONDOWN:
+                       camera.adjustFromInput(event);
                        break;
 
                case SDL_QUIT:
                        break;
 
                case SDL_QUIT:
@@ -359,11 +394,20 @@ void YoinkApp::handleEvent(const Mf::Event& event)
 
                case SDL_VIDEORESIZE:
                        glViewport(0, 0, event.resize.w, event.resize.h);
 
                case SDL_VIDEORESIZE:
                        glViewport(0, 0, event.resize.w, event.resize.h);
+
+                       glMatrixMode(GL_PROJECTION);
+                       glLoadIdentity();
+
+
+                       gluPerspective(60.0, double(event.resize.w / event.resize.h), 1.0, 2500.0);
+
+                       glMatrixMode(GL_MODELVIEW);
                        break;
        }
 }
 
 
                        break;
        }
 }
 
 
+#include <Moof/Tree.hh>
 
 int main(int argc, char* argv[])
 {
 
 int main(int argc, char* argv[])
 {
@@ -374,6 +418,10 @@ int main(int argc, char* argv[])
 
        int status = 0;
 
 
        int status = 0;
 
+       //Mf::Tree<Mf::Drawable> myTree;
+       //Mf::Tree<Mf::Drawable>::Ptr prev = myTree.previousSibling();
+       //myTree = *prev;
+
        try
        {
                YoinkApp app(argc, argv);
        try
        {
                YoinkApp app(argc, argv);
This page took 0.022803 seconds and 4 git commands to generate.