1 | /* |
---|
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: |
---|
12 | main-programmer: Benjamin Grauer |
---|
13 | co-programmer: ... |
---|
14 | |
---|
15 | this file extends the framework file, so it renders what i want. |
---|
16 | */ |
---|
17 | |
---|
18 | #include "framework.h" |
---|
19 | |
---|
20 | #include "light.h" |
---|
21 | |
---|
22 | #include "texture_sequence.h" |
---|
23 | #include "material.h" |
---|
24 | |
---|
25 | #include "objModel.h" |
---|
26 | |
---|
27 | #include "primitive_model.h" |
---|
28 | #include <stdlib.h> |
---|
29 | |
---|
30 | #include "resource_manager.h" |
---|
31 | |
---|
32 | Model* obj; |
---|
33 | TextureSequence* seq; |
---|
34 | Texture* test; |
---|
35 | float counter = 0; |
---|
36 | |
---|
37 | void Framework::moduleInit(int argc, char** argv) |
---|
38 | { |
---|
39 | ResourceManager::getInstance()->addImageDir("./"); |
---|
40 | |
---|
41 | seq = new TextureSequence(); |
---|
42 | for (int i = 1; i < argc; i++) |
---|
43 | { |
---|
44 | seq->addFrame(argv[i]); |
---|
45 | printf("%s\n", argv[i]); |
---|
46 | } |
---|
47 | test = new Texture(argv[1]); |
---|
48 | |
---|
49 | ResourceManager::getInstance()->addImageDir(""); |
---|
50 | |
---|
51 | |
---|
52 | obj = new PrimitiveModel(PRIM_CYLINDER); |
---|
53 | |
---|
54 | ResourceManager::getInstance()->debug(); |
---|
55 | |
---|
56 | LightManager* lightMan = LightManager::getInstance(); |
---|
57 | lightMan->setAmbientColor(.1,.1,.1); |
---|
58 | (new Light())->setAbsCoor(5.0, 10.0, 40.0); |
---|
59 | (new Light())->setAbsCoor(-10, -20, -100); |
---|
60 | } |
---|
61 | |
---|
62 | void Framework::moduleEventHandler(SDL_Event* event) |
---|
63 | { |
---|
64 | switch (event->type) |
---|
65 | { |
---|
66 | case SDL_KEYDOWN: |
---|
67 | switch (event->key.keysym.sym) |
---|
68 | { |
---|
69 | case SDLK_i: |
---|
70 | break; |
---|
71 | } |
---|
72 | } |
---|
73 | } |
---|
74 | |
---|
75 | void Framework::moduleTick(float dt) |
---|
76 | { |
---|
77 | counter+=dt; |
---|
78 | |
---|
79 | seq->gotoFrame((unsigned int)counter); |
---|
80 | if ((unsigned int)counter > seq->getFrameCount()) |
---|
81 | counter = 0; |
---|
82 | } |
---|
83 | |
---|
84 | void Framework::moduleDraw(void) const |
---|
85 | { |
---|
86 | float diffuse[] = {1,1,1,1}; |
---|
87 | float ambient[] = {1,0,0,1}; |
---|
88 | float specular[] = {1,0,1,1}; |
---|
89 | // setting diffuse color |
---|
90 | // glColor3f (diffuse[0], diffuse[1], diffuse[2]); |
---|
91 | glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuse); |
---|
92 | |
---|
93 | // setting ambient color |
---|
94 | glMaterialfv(GL_FRONT, GL_AMBIENT, ambient); |
---|
95 | |
---|
96 | // setting up Sprecular |
---|
97 | glMaterialfv(GL_FRONT, GL_SPECULAR, specular); |
---|
98 | |
---|
99 | // setting up Shininess |
---|
100 | glMaterialf(GL_FRONT, GL_SHININESS, .4); |
---|
101 | glShadeModel(GL_SMOOTH); |
---|
102 | |
---|
103 | glEnable(GL_TEXTURE_2D); |
---|
104 | glBindTexture(GL_TEXTURE_2D, seq->getTexture()); |
---|
105 | // printf("Number = %d\n", seq->getTexture()); |
---|
106 | /* This allows alpha blending of 2D textures with the scene */ |
---|
107 | // if (seq->hasAlpha()) |
---|
108 | // { |
---|
109 | // glEnable(GL_BLEND); |
---|
110 | // glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
---|
111 | // } |
---|
112 | |
---|
113 | obj->draw(); |
---|
114 | |
---|
115 | LightManager::getInstance()->draw(); |
---|
116 | } |
---|
117 | |
---|
118 | |
---|
119 | void Framework::moduleHelp(void) const |
---|
120 | { |
---|
121 | |
---|
122 | } |
---|