Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/avi_play/src/subprojects/importer/multitex.cc @ 6339

Last change on this file since 6339 was 6339, checked in by hdavid, 18 years ago

branches\avi_play: some copy, pasta & delete

File size: 2.4 KB
RevLine 
[4554]1/*
[4333]2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific:
[6286]12   main-programmer: David Hasenfratz
[4333]13   co-programmer: ...
14
15   this file extends the framework file, so it renders what i want.
16*/
17
18#include "framework.h"
19
[4343]20#include "light.h"
[4333]21
[5865]22#include "material.h"
[4343]23#include "primitive_model.h"
24#include <stdlib.h>
[4333]25
[6094]26#include "media_container.h"
[4343]27
28Model* obj;
[5866]29Material* testMat;
[6339]30MediaContainer* media_container;
[5866]31
[6168]32int counter = 0;
33float timer = 0;
34float fps;
[4343]35
[5866]36
[4343]37void Framework::moduleInit(int argc, char** argv)
[4333]38{
[6339]39  if( argc <= 1)
[6168]40  {
41    printf("Wrong arguments try following notations:\n");
[6339]42    printf("./multitex [media_file]\n");
[6168]43    exit(0);
44  }
[6094]45
[6339]46  media_container = new MediaContainer(argv[1]);
[6163]47
[5866]48  testMat = new Material;
[6163]49  testMat->setDiffuseMap("maps/radialTransparency.png");
[6003]50  obj = new PrimitiveModel(PRIM_PLANE, 10.0);
[4333]51
[4343]52  LightManager* lightMan = LightManager::getInstance();
53  lightMan->setAmbientColor(.1,.1,.1);
[4741]54  (new Light())->setAbsCoor(5.0, 10.0, 40.0);
55  (new Light())->setAbsCoor(-10, -20, -100);
[6339]56
57  fps = media_container->getFPS();
[4333]58}
59
[4334]60void Framework::moduleEventHandler(SDL_Event* event)
61{
62  switch (event->type)
63    {
64    case SDL_KEYDOWN:
65      switch (event->key.keysym.sym)
[4554]66        {
[6003]67        case SDLK_1:
[6013]68          obj = new PrimitiveModel(PRIM_CUBE, 10.0);
[4554]69          break;
[6068]70        case SDLK_2:
[6013]71          obj = new PrimitiveModel(PRIM_SPHERE, 10.0);
[6003]72          break;
[6013]73        case SDLK_3:
74          obj = new PrimitiveModel(PRIM_PLANE, 10.0);
[6003]75          break;
[6168]76        // increase fps
77        case SDLK_9:
78          fps++;
[6339]79          PRINTF(0)("fps: %0.2f\n", fps);
[6168]80          break;
81        // decrease fps
82        case SDLK_8:
83          if(fps > 0)
84            fps--;
[6339]85          PRINTF(0)("fps: %0.2f\n", fps);
[6168]86          break;
[4554]87        }
[4334]88    }
[4333]89}
90
91void Framework::moduleTick(float dt)
92{
[6168]93  timer += dt;
[4554]94
[6168]95  if(counter != fps * timer)
96  {
97    counter = fps * timer;
[6254]98
[6339]99    if (counter >= media_container->getFrameCount())
[6168]100    {
101      timer = 0;
102      counter = 0;
103    }
[6254]104  }
[4333]105}
106
[4349]107void Framework::moduleDraw(void) const
[4334]108{
[5866]109  testMat->select();
[6339]110  glBindTexture(GL_TEXTURE_2D, media_container->getFrameTexture(counter));
[4343]111  obj->draw();
112
113  LightManager::getInstance()->draw();
[4334]114}
[4333]115
116void Framework::moduleHelp(void) const
117{
[4554]118
[4333]119}
Note: See TracBrowser for help on using the repository browser.