X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FYoinkApp.cc;h=023b3a30ce51837365e60d22136cc8a2e04cdce3;hp=232c097425b4f3a70803951644e3bdf634d1e203;hb=29e3d45f7bbbf31eadf793c41ff2b3d9c47b7539;hpb=16d1a05b0777e97a45c48e2874aa4e5cc791282e diff --git a/src/YoinkApp.cc b/src/YoinkApp.cc index 232c097..023b3a3 100644 --- a/src/YoinkApp.cc +++ b/src/YoinkApp.cc @@ -50,6 +50,7 @@ static std::string configFiles() std::string files; char* configFile = getenv("YOINKRC"); + char* dataDir = getenv("YOINK_DATADIR"); if (configFile) { @@ -59,8 +60,23 @@ static std::string configFiles() files += ":"; } + // add the colon-delimited paths from configure 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; } @@ -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) { + // look first in the data directory specified by the environment Mf::Resource::addSearchPath(dataDir); } + + // then look in the configured data directory 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_POLYGON_SMOOTH); + //glEnable(GL_POLYGON_SMOOTH); //int texSize; //glGetIntegerv(GL_MAX_TEXTURE_SIZE, &texSize); @@ -138,6 +157,10 @@ void YoinkApp::setupGL() 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); } @@ -155,6 +178,8 @@ void YoinkApp::update(Mf::Scalar t, Mf::Scalar dt) fadeIn.update(dt); + camera.update(t, 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); - glLoadIdentity(); + //glLoadIdentity(); 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); @@ -327,30 +349,43 @@ void YoinkApp::handleEvent(const Mf::Event& event) { 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: @@ -359,11 +394,20 @@ void YoinkApp::handleEvent(const Mf::Event& event) 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; } } +#include int main(int argc, char* argv[]) { @@ -374,6 +418,10 @@ int main(int argc, char* argv[]) int status = 0; + //Mf::Tree myTree; + //Mf::Tree::Ptr prev = myTree.previousSibling(); + //myTree = *prev; + try { YoinkApp app(argc, argv);