1 | /* |
---|
2 | orxonox - the future of 3D-vertical-scrollers |
---|
3 | |
---|
4 | Copyright (C) 2006 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: hdavid |
---|
13 | */ |
---|
14 | |
---|
15 | #include "volfog_effect.h" |
---|
16 | |
---|
17 | #include "util/loading/load_param.h" |
---|
18 | #include "util/loading/factory.h" |
---|
19 | |
---|
20 | #include "p_node.h" |
---|
21 | #include "state.h" |
---|
22 | #include "shell_command.h" |
---|
23 | |
---|
24 | #include "glincl.h" |
---|
25 | #include "debug.h" |
---|
26 | |
---|
27 | #define GLX_GLXEXT_PROTOTYPES |
---|
28 | |
---|
29 | #include "class_id_DEPRECATED.h" |
---|
30 | ObjectListDefinitionID(VolFogEffect, CL_VOLFOG_EFFECT); |
---|
31 | CREATE_FACTORY(VolFogEffect); |
---|
32 | |
---|
33 | SHELL_COMMAND(activate, VolFogEffect, activateFog); |
---|
34 | SHELL_COMMAND(deactivate, VolFogEffect, deactivateFog); |
---|
35 | |
---|
36 | |
---|
37 | typedef void (APIENTRY * PFNGLFOGCOORDFEXTPROC) (GLfloat coord); // Declare Function Prototype |
---|
38 | PFNGLFOGCOORDFEXTPROC glFogCoordfEXT = NULL; // Our glFogCoordfEXT Function |
---|
39 | |
---|
40 | |
---|
41 | VolFogEffect::VolFogEffect(const TiXmlElement* root) { |
---|
42 | this->registerObject(this, VolFogEffect::_objectList); |
---|
43 | |
---|
44 | if (root != NULL) |
---|
45 | this->loadParams(root); |
---|
46 | |
---|
47 | // Initialize Effect |
---|
48 | this->init(); |
---|
49 | |
---|
50 | // Activate Effect |
---|
51 | if(fogActivate) |
---|
52 | this->activate(); |
---|
53 | } |
---|
54 | |
---|
55 | |
---|
56 | VolFogEffect::~VolFogEffect() { |
---|
57 | if(fogActivate) |
---|
58 | this->deactivate(); |
---|
59 | } |
---|
60 | |
---|
61 | void VolFogEffect::loadParams(const TiXmlElement* root) { |
---|
62 | WeatherEffect::loadParams(root); |
---|
63 | } |
---|
64 | |
---|
65 | void VolFogEffect::init() { |
---|
66 | PRINTF(0)("Initalize VolFogEffect\n"); |
---|
67 | |
---|
68 | fogColor[0] = 0.6f; |
---|
69 | fogColor[1] = 0.3f; |
---|
70 | fogColor[2] = 0.0f; |
---|
71 | fogColor[3] = 1.0f; |
---|
72 | |
---|
73 | fogActivate = false; |
---|
74 | } |
---|
75 | |
---|
76 | |
---|
77 | void VolFogEffect::activate() { |
---|
78 | PRINTF(0)("Activating VolFogEffect\n"); |
---|
79 | |
---|
80 | // Test whether the extension exists |
---|
81 | if (!glewIsSupported("GL_EXT_fog_coord")) |
---|
82 | { |
---|
83 | PRINTF(0)("Can't activate volumetric fog, GL_EXT_fog_coord extension is misssing\n"); |
---|
84 | return; |
---|
85 | } |
---|
86 | |
---|
87 | fogActivate = true; |
---|
88 | } |
---|
89 | |
---|
90 | void VolFogEffect::deactivate() { |
---|
91 | PRINTF(0)("Deactivating VolFogEffect\n"); |
---|
92 | |
---|
93 | fogActivate = false; |
---|
94 | } |
---|
95 | |
---|
96 | |
---|
97 | /** |
---|
98 | * draws the effect |
---|
99 | */ |
---|
100 | void VolFogEffect::draw() const { |
---|
101 | |
---|
102 | if(!fogActivate) |
---|
103 | return; |
---|
104 | } |
---|
105 | |
---|
106 | |
---|
107 | /** |
---|
108 | * ticks the effect if there is any time dependancy |
---|
109 | */ |
---|
110 | void VolFogEffect::tick(float dt) {} |
---|