- Timestamp:
- Nov 16, 2006, 1:11:25 PM (18 years ago)
- Location:
- branches/volumetric_fog/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/volumetric_fog/src/lib/graphics/graphics_engine.cc
r9876 r9935 173 173 return this->initVideo(x.getInt(), y.getInt(), 16); 174 174 175 // GraphicsEffect* fe = new FogEffect(NULL);176 // this->loadGraphicsEffect(fe);177 // fe->activate();178 // PRINTF(0)("--------------------------------------------------------------\n");179 180 //LenseFlare* ge = new LenseFlare();181 //this->loadGraphicsEffect(ge);182 183 //ge->addFlare("pictures/lense_flare/sun.png"); //sun184 //ge->addFlare("pictures/lense_flare/lens2.png"); //first halo185 //ge->addFlare("pictures/lense_flare/lens1.png"); //small birst186 //ge->addFlare("pictures/lense_flare/lens3.png"); //second halo187 //ge->addFlare("pictures/lense_flare/lens4.png");188 //ge->addFlare("pictures/lense_flare/lens1.png");189 //ge->addFlare("pictures/lense_flare/lens3.png");190 191 //ge->activate();192 175 } 193 176 -
branches/volumetric_fog/src/world_entities/weather_effects/volfog_effect.cc
r9869 r9935 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 4 Copyright (C) 200 4orx4 Copyright (C) 2006 orx 5 5 6 6 This program is free software; you can redistribute it and/or modify … … 10 10 11 11 ### File Specific: 12 main-programmer: hdavid , amaechler12 main-programmer: hdavid 13 13 */ 14 14 … … 22 22 23 23 #include "glincl.h" 24 //#include "shell_command.h"25 24 #include "debug.h" 26 25 27 26 28 27 #define GLX_GLXEXT_PROTOTYPES 29 //#include <GL/glx.h>30 // #include <GL/glut.h>31 32 //#include <GL/glext.h> //OpenGL Extensions33 //#include <GL/glxext.h> // GLX Extensions34 35 #ifndef GL_EXT_fog_coord36 #define GL_EXT_fog_coord 137 typedef void (APIENTRY * PFNGLFOGCOORDFEXTPROC) (GLfloat coord);38 typedef void (APIENTRY * PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord);39 typedef void (APIENTRY * PFNGLFOGCOORDDEXTPROC) (GLdouble coord);40 typedef void (APIENTRY * PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord);41 typedef void (APIENTRY * PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer);42 #endif43 44 PFNGLFOGCOORDFEXTPROC glFogCoordfEXT = 0;45 PFNGLFOGCOORDFVEXTPROC glFogCoordfvEXT = 0;46 PFNGLFOGCOORDDEXTPROC glFogCoorddEXT = 0;47 PFNGLFOGCOORDDVEXTPROC glFogCoorddvEXT = 0;48 PFNGLFOGCOORDPOINTEREXTPROC glFogCoordPointerEXT = 0;49 50 28 51 29 #include "class_id_DEPRECATED.h" 52 30 ObjectListDefinitionID(VolFogEffect, CL_VOLFOG_EFFECT); 53 31 CREATE_FACTORY(VolFogEffect); 32 33 54 34 55 35 VolFogEffect::VolFogEffect(const TiXmlElement* root) { … … 63 43 64 44 // Activate Effect 65 this->activate(); 45 if(fogActivate) 46 this->activate(); 66 47 } 67 48 … … 76 57 77 58 void VolFogEffect::init() { 78 PRINTF(3)("Initalize VolFogEffect\n"); 59 PRINTF(0)("Initalize VolFogEffect\n"); 60 61 fogActivate = false; 79 62 80 // set fog mode 81 GLenum fogMode = GL_EXP; 82 83 // set fog density 84 float fogDensity = 0.001f; 85 86 // set fog near & far distance 87 float fogStart = 0.0f; 88 float fogEnd = 1000.0f; 89 90 // Set fog color 91 float fogColor[4] = {0.6f,0.58f,0.79f,0.0f}; 92 93 94 /* glFogCoordfEXT = (PFNGLFOGCOORDFEXTPROC)glXGetProcAddressARB((const GLubyte*)"glFogCoordfEXT"); 95 glFogCoordfvEXT = (PFNGLFOGCOORDFVEXTPROC)glXGetProcAddressARB((const GLubyte*)"glFogCoordfvEXT"); 96 glFogCoorddEXT = (PFNGLFOGCOORDDEXTPROC)glXGetProcAddressARB((const GLubyte*)"glFogCoorddEXT"); 97 glFogCoorddvEXT = (PFNGLFOGCOORDDVEXTPROC)glXGetProcAddressARB((const GLubyte*)"glFogCoorddvEXT"); 98 glFogCoordPointerEXT = (PFNGLFOGCOORDPOINTEREXTPROC)glXGetProcAddressARB((const GLubyte*)"glFogCoordPointerEXT"); 99 */ 100 // set the fog attributes 101 glFogf (GL_FOG_START, fogStart); 102 glFogf (GL_FOG_END, fogEnd); 103 glFogfv(GL_FOG_COLOR, fogColor); 104 glFogi (GL_FOG_MODE, fogMode); 105 glFogf (GL_FOG_DENSITY,fogDensity); 106 glFogi (GL_FOG_COORDINATE_SOURCE_EXT,GL_FOG_COORDINATE_EXT); 107 108 // enable the fog 109 glEnable(GL_FOG); 110 111 if (glewInit() == GLEW_OK) 112 PRINTF(4)("glewInit OK\n"); 113 else 114 PRINTF(4)("glewInit failed\n"); 115 116 if (glewGetExtension("GL_EXT_fog_coord")) 117 PRINTF(4)("GL_EXT_fog_coord extension found\n"); 63 118 64 } 119 65 120 66 121 67 void VolFogEffect::activate() { 122 PRINTF( 3)("Activating VolFogEffect\n");68 PRINTF(0)("Activating VolFogEffect\n"); 123 69 } 124 70 125 71 void VolFogEffect::deactivate() { 126 PRINTF(3)("Deactivating VolFogEffect\n"); 127 128 glDisable(GL_FOG); 72 PRINTF(0)("Deactivating VolFogEffect\n"); 129 73 } 130 74 131 75 132 76 /** 133 * draws the effect , if needed77 * draws the effect 134 78 */ 135 79 void VolFogEffect::draw() const { 136 glPushAttrib(GL_ENABLE_BIT);137 glClearColor(fogColor[0],fogColor[1],fogColor[2],0.0f);138 glShadeModel(GL_SMOOTH);139 glEnable(GL_DEPTH_TEST);140 glEnable(GL_CULL_FACE);141 glCullFace(GL_BACK);142 143 /* clear all pixels in colour buffer */144 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);145 146 /* Enable blending */147 //glEnable(GL_BLEND);148 //glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);149 150 int i;151 glLoadIdentity();152 153 154 glBegin( GL_LINES );155 glNormal3f(0,1,0);156 for(i=-20;i<=20;i+=2) {157 float fog_c;158 float diff[3];159 160 diff[0] = State::getCameraNode()->getAbsCoor().x - i;161 diff[2] = State::getCameraNode()->getAbsCoor().z + 20;162 diff[1] = State::getCameraNode()->getAbsCoor().y;163 fog_c = 1.3f*sqrt(diff[0]*diff[0]+diff[1]*diff[1]+diff[2]*diff[2]);164 glFogCoordfEXT(fog_c*2);165 glVertex3f(i,0,-20);166 167 diff[0] = State::getCameraNode()->getAbsCoor().x - i;168 diff[2] = State::getCameraNode()->getAbsCoor().z + 20;169 diff[1] = State::getCameraNode()->getAbsCoor().y;170 fog_c = 1.3f*sqrt(diff[0]*diff[0]+diff[1]*diff[1]+diff[2]*diff[2]);171 glFogCoordfEXT(fog_c*2);172 glVertex3f(i,0,20);173 174 diff[0] = State::getCameraNode()->getAbsCoor().x - i;175 diff[2] = State::getCameraNode()->getAbsCoor().z + 20;176 diff[1] = State::getCameraNode()->getAbsCoor().y;177 fog_c = 1.3f*sqrt(diff[0]*diff[0]+diff[1]*diff[1]+diff[2]*diff[2]);178 glFogCoordfEXT(fog_c*2);179 glVertex3f(-20,0,i);180 181 diff[0] = State::getCameraNode()->getAbsCoor().x - i;182 diff[2] = State::getCameraNode()->getAbsCoor().z + 20;183 diff[1] = State::getCameraNode()->getAbsCoor().y;184 fog_c = 1.3f*sqrt(diff[0]*diff[0]+diff[1]*diff[1]+diff[2]*diff[2]);185 glFogCoordfEXT(fog_c*2);186 glVertex3f(20,0,i);187 }188 glEnd();189 190 glPopAttrib();191 80 192 81 } -
branches/volumetric_fog/src/world_entities/weather_effects/volfog_effect.h
r9869 r9935 30 30 private: 31 31 GLfloat fogColor[4]; 32 bool fogActivate; 32 33 33 34 };
Note: See TracChangeset
for help on using the changeset viewer.