Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/subprojects/importer/multitex.cc @ 8353

Last change on this file since 8353 was 6532, checked in by bensch, 19 years ago

orxonox/trunk: merged branches/movie_play to the trunk. no conflicts, but a minor virtual function BUG

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:
[6532]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
[6532]26#include "media_container.h"
[4343]27
28Model* obj;
[5866]29Material* testMat;
[6532]30MediaContainer* media_container;
[5866]31
[6532]32int counter = 0;
33float timer = 0;
34float fps;
[4343]35
[5866]36
[4343]37void Framework::moduleInit(int argc, char** argv)
[4333]38{
[6532]39  if( argc <= 1)
[4653]40  {
[6532]41    printf("Wrong arguments try following notations:\n");
42    printf("./multitex [media_file]\n");
43    exit(0);
[4653]44  }
[5865]45
[6532]46  media_container = new MediaContainer(argv[1]);
[4653]47
[6532]48  testMat = new Material;
49  testMat->setDiffuseMap("maps/radialTransparency.png");
50  obj = new PrimitiveModel(PRIM_PLANE, 10.0);
[4653]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);
[6532]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        {
[6532]67        case SDLK_1:
68          obj = new PrimitiveModel(PRIM_CUBE, 10.0);
[4554]69          break;
[6532]70        case SDLK_2:
71          obj = new PrimitiveModel(PRIM_SPHERE, 10.0);
72          break;
73        case SDLK_3:
74          obj = new PrimitiveModel(PRIM_PLANE, 10.0);
75          break;
76        // increase fps
77        case SDLK_9:
78          fps++;
79          PRINTF(0)("fps: %0.2f\n", fps);
80          break;
81        // decrease fps
82        case SDLK_8:
83          if(fps > 0)
84            fps--;
85          PRINTF(0)("fps: %0.2f\n", fps);
86          break;
[4554]87        }
[4334]88    }
[4333]89}
90
91void Framework::moduleTick(float dt)
92{
[6532]93  timer += dt;
[4554]94
[6532]95  if(counter != fps * timer)
96  {
97    counter = fps * timer;
98
99    if (counter >= media_container->getFrameCount())
100    {
101      timer = 0;
102      counter = 0;
103    }
104  }
[4333]105}
106
[4349]107void Framework::moduleDraw(void) const
[4334]108{
[5866]109  testMat->select();
[6532]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.