Changeset 6772 in orxonox.OLD for trunk/src/lib/graphics
- Timestamp:
- Jan 26, 2006, 2:44:26 PM (19 years ago)
- Location:
- trunk/src/lib/graphics
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/effects/fog_effect.cc
r6752 r6772 22 22 #include "factory.h" 23 23 24 #include "glincl.h" 25 26 24 27 25 28 using namespace std; 26 29 27 CREATE_FACTORY(FogEffect, CL_ LIGHT);30 CREATE_FACTORY(FogEffect, CL_FOG_EFFECT); 28 31 29 32 … … 35 38 FogEffect::FogEffect(const TiXmlElement* root) 36 39 { 40 41 this->fogMode = GL_EXP2; 42 this->fogDensity = 0.001f; 43 this->fogStart = 10.0f; 44 this->fogEnd = 1000.0f; 45 37 46 38 47 if (root != NULL) … … 55 64 GraphicsEffect::loadParams(root); 56 65 57 // LoadParam(root, "diffuse-color", this, FogEffect, setDiffuseColor) 58 // .describe("sets the diffuse color of the FogEffect (red [0-1], green [0-1], blue [0-1])"); 66 LoadParam(root, "fog-effect", this, FogEffect, setFogMode) 67 .describe("sets the the fog mode {GL_LINEAR, GL_EXP, GL_EXP2}"); 68 69 LoadParam(root, "fog-density", this, FogEffect, setFogDensity) 70 .describe("sets the the fog density of the exponentionl functions"); 71 72 LoadParam(root, "fog-range", this, FogEffect, setFogRange) 73 .describe("sets the the range of the linear functions"); 59 74 } 60 75 … … 72 87 bool FogEffect::activate() 73 88 { 74 /* glEnable(GL_FOG); 89 PRINTF(4)( "Enabling Fog Effect, mode: %i, density: %f, start: %f, end: %f\n", this->fogMode, this->fogDensity, 90 this->fogStart, this->fogEnd); 91 92 glEnable(GL_FOG); 75 93 { 76 GLfloat fogColor[4] = {0.5, 0.5, 1.0};94 GLfloat fogColor[4] = {0.5, 0.5, 0.5, 1.0}; 77 95 78 GLint fogMode = GL_EXP; 79 glFogi(GL_FOG_MODE, fogMode); 96 glFogi(GL_FOG_MODE, this->fogMode); 80 97 glFogfv(GL_FOG_COLOR, fogColor); 81 gfFogf(GL_FOG_DENSITY, 0.35f); 98 glFogf(GL_FOG_DENSITY, this->fogDensity); 99 glHint(GL_FOG_HINT, GL_DONT_CARE); 100 glFogf(GL_FOG_START, this->fogStart); 101 glFogf(GL_FOG_END, this->fogEnd); 82 102 83 84 }*/ 103 //glFogi(GL_FOG_COORDINATE_SOURCE, GL_FOG_COORDINATE); 104 } 105 glClearColor(0.5, 0.5, 0.5, 1.0); 85 106 } 86 107 … … 90 111 */ 91 112 bool FogEffect::deactivate() 92 {} 113 { 114 glDisable(GL_FOG); 115 } 116 117 118 /** 119 * converts a gl mode char to a GLint 120 * @param mode the mode character 121 */ 122 GLint FogEffect::charToFogMode(const char* mode) 123 { 124 if( !strcmp( "GL_LINEAR", mode)) 125 return GL_LINEAR; 126 else if( !strcmp("GL_EXP", mode)) 127 return GL_EXP; 128 else if(!strcmp("GL_EXP2", mode) ) 129 return GL_EXP2; 130 else 131 return -1; 132 } 133 -
trunk/src/lib/graphics/effects/fog_effect.h
r6741 r6772 24 24 virtual bool activate(); 25 25 virtual bool deactivate(); 26 27 void setFogMode(const char* mode) { this->fogMode = this->charToFogMode(mode); } 28 void setFogDensity(float density) { this->fogDensity = density; } 29 void setFogRange(float start, float end) { this->fogStart = start; this->fogEnd = end; } 30 31 32 private: 33 GLint charToFogMode(const char* mode); 34 35 36 private: 37 GLint fogMode; 38 GLfloat fogDensity; 39 GLfloat fogStart; 40 GLfloat fogEnd; 26 41 }; 27 42 -
trunk/src/lib/graphics/effects/graphics_effect.cc
r6741 r6772 13 13 ### File Specific: 14 14 main-programmer: Patrick Boenzli 15 co-programmer: ...16 15 */ 17 16 … … 21 20 #include "graphics_effect.h" 22 21 22 #include "graphics_engine.h" 23 23 #include "load_param.h" 24 24 … … 35 35 GraphicsEffect::GraphicsEffect(const TiXmlElement* root) 36 36 { 37 this->bActivated = false; 38 39 this->bActivated = GraphicsEngine::getInstance()->loadGraphicsEffect(this); 37 40 38 41 if (root != NULL) … … 45 48 */ 46 49 GraphicsEffect::~GraphicsEffect() 47 {} 50 { 51 if( this->bActivated) 52 GraphicsEngine::getInstance()->unloadGraphicsEffect(this); 53 } 48 54 49 55 -
trunk/src/lib/graphics/effects/graphics_effect.h
r6741 r6772 24 24 virtual bool activate() = 0; 25 25 virtual bool deactivate() = 0; 26 27 inline bool isActivated() { return this->bActivated; } 28 29 30 protected: 31 bool bActivated; 26 32 }; 27 33 -
trunk/src/lib/graphics/graphics_engine.cc
r6753 r6772 37 37 38 38 #include "effects/graphics_effect.h" 39 #include "effects/fog_effect.h" 39 40 40 41 #include "shell_command.h" … … 148 149 149 150 this->initVideo(atoi(resolution.getString(0)), atoi(resolution.getString(1)), 16); 151 152 GraphicsEffect* fe = new FogEffect(NULL); 153 this->loadGraphicsEffect(fe); 154 fe->activate(); 155 PRINTF(0)("--------------------------------------------------------------\n"); 150 156 } 151 157
Note: See TracChangeset
for help on using the changeset viewer.