From b6fa7486a049fce1f7e9bda26f154e739e09abed Mon Sep 17 00:00:00 2001 From: w1z7ard Date: Thu, 16 Aug 2007 01:18:56 +0000 Subject: [PATCH] new custom shape / wave resource handling design implemented, but untested git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/personal/carm/dev-1.0@335 6778bc44-b910-0410-a7a0-be141de4315d --- src/projectM-engine/Parser.cpp | 18 +++-- src/projectM-engine/Preset.cpp | 63 ++++++++------- src/projectM-engine/Preset.hpp | 34 +++------ src/projectM-engine/PresetFrameIO.cpp | 3 +- src/projectM-engine/PresetFrameIO.hpp | 6 +- src/projectM-engine/PresetMerge.cpp | 29 +++---- src/projectM-engine/Renderer.cpp | 106 +++++++++++++------------- 7 files changed, 125 insertions(+), 134 deletions(-) diff --git a/src/projectM-engine/Parser.cpp b/src/projectM-engine/Parser.cpp index e7fafc2ca..b41dad62d 100755 --- a/src/projectM-engine/Parser.cpp +++ b/src/projectM-engine/Parser.cpp @@ -496,7 +496,7 @@ int Parser::parse_line(FILE * fs, Preset * preset) { CustomWave * custom_wave; /* Retrieve custom shape associated with this id */ - if ((custom_wave = Preset::find_custom_object(last_custom_wave_id, true, *preset->customWaves)) == NULL) + if ((custom_wave = Preset::find_custom_object(last_custom_wave_id, preset->customWaves)) == NULL) return PROJECTM_FAILURE; return parse_wave_per_frame_eqn(fs, custom_wave, preset); @@ -511,7 +511,7 @@ int Parser::parse_line(FILE * fs, Preset * preset) { CustomShape * custom_shape; /* Retrieve custom shape associated with this id */ - if ((custom_shape = Preset::find_custom_object(last_custom_shape_id, true, *preset->customShapes)) == NULL) + if ((custom_shape = Preset::find_custom_object(last_custom_shape_id, preset->customShapes)) == NULL) return PROJECTM_FAILURE; return parse_shape_per_frame_eqn(fs, custom_shape, preset); @@ -521,7 +521,7 @@ int Parser::parse_line(FILE * fs, Preset * preset) { CustomShape * custom_shape; /* Retrieve custom shape associated with this id */ - if ((custom_shape = preset->find_custom_object(last_custom_shape_id, true, *preset->customShapes)) == NULL) + if ((custom_shape = preset->find_custom_object(last_custom_shape_id, preset->customShapes)) == NULL) return PROJECTM_FAILURE; return parse_shape_per_frame_init_eqn(fs, custom_shape, preset); @@ -1392,11 +1392,13 @@ int Parser::parse_wavecode(char * token, FILE * fs, Preset * preset) { /* Get id and variable name from token string */ if (parse_wavecode_prefix(token, &id, &var_string) < 0) return PROJECTM_PARSE_ERROR; - + + last_custom_wave_id = id; + //if (PARSE_DEBUG) printf("parse_wavecode: wavecode id = %d, parameter = \"%s\"\n", id, var_string); /* Retrieve custom wave information from preset, allocating new one if necessary */ - if ((custom_wave = Preset::find_custom_object(id, true, *preset->customWaves)) == NULL) { + if ((custom_wave = Preset::find_custom_object(id, preset->customWaves)) == NULL) { std::cerr << "parse_wavecode: failed to load (or create) custom wave (id = " << id << ")!\n" << std::endl; @@ -1480,7 +1482,7 @@ int Parser::parse_shapecode(char * token, FILE * fs, Preset * preset) { /* Retrieve custom shape information from preset. The 3rd argument if true creates a custom shape if one does not exist */ - if ((custom_shape = Preset::find_custom_object(id, true, *preset->customShapes)) == NULL) { + if ((custom_shape = Preset::find_custom_object(id, preset->customShapes)) == NULL) { //if (PARSE_DEBUG) printf("parse_shapecode: failed to load (or create) custom shape (id = %d)!\n", id); return PROJECTM_FAILURE; } @@ -1734,7 +1736,7 @@ int Parser::parse_wave_helper(FILE * fs, Preset * preset, int id, char * eqn_ty InitCond * init_cond; /* Retrieve custom wave associated with this id */ - if ((custom_wave = Preset::find_custom_object(id, true, *preset->customWaves)) == NULL) { + if ((custom_wave = Preset::find_custom_object(id, preset->customWaves)) == NULL) { if (PARSE_DEBUG) printf("parse_wave_helper: custom wave id %d not found!\n", id); return PROJECTM_FAILURE; } @@ -1893,7 +1895,7 @@ int Parser::parse_shape(char * token, FILE * fs, Preset * preset) { } /* Retrieve custom shape associated with this id */ - if ((custom_shape = Preset::find_custom_object(id,true,*preset->customShapes)) == NULL) + if ((custom_shape = Preset::find_custom_object(id,preset->customShapes)) == NULL) return PROJECTM_FAILURE; diff --git a/src/projectM-engine/Preset.cpp b/src/projectM-engine/Preset.cpp index 72433c392..766920b5c 100755 --- a/src/projectM-engine/Preset.cpp +++ b/src/projectM-engine/Preset.cpp @@ -38,14 +38,12 @@ Preset::Preset(const std::string & filename, const PresetInputs & presetInputs, PresetOutputs & presetOutputs): builtinParams(presetInputs, presetOutputs), - customWaves(&presetOutputs.customWaves), - customShapes(&presetOutputs.customShapes), + customWaves(presetOutputs.customWaves), + customShapes(presetOutputs.customShapes), file_path(filename), m_presetOutputs(presetOutputs) { - customWaves->clear(); - customShapes->clear(); clearMeshChecks(); initialize(filename); @@ -65,23 +63,16 @@ Preset::~Preset() Algorithms::traverse >(user_param_tree); - /// @note We do not clear the actual container itself and instead let whoever initializes the preset inputs class to do it - for (PresetOutputs::cwave_container::iterator pos = customWaves->begin(); pos != customWaves->end(); ++pos) + for (PresetOutputs::cwave_container::iterator pos = customWaves.begin(); pos != customWaves.end(); ++pos) { - assert(pos->second); - delete(pos->second); + delete(*pos); } - for (PresetOutputs::cshape_container::iterator pos = customShapes->begin(); pos != customShapes->end(); ++pos) + for (PresetOutputs::cshape_container::iterator pos = customShapes.begin(); pos != customShapes.end(); ++pos) { - assert(pos->second); - delete(pos->second); + delete(*pos); } - /// testing - customWaves->clear(); - customShapes->clear(); - } /* Adds a per pixel equation according to its string name. This @@ -156,9 +147,9 @@ int Preset::add_per_pixel_eqn(char * name, GenExpr * gen_expr) void Preset::evalCustomShapeInitConditions() { - for (PresetOutputs::cshape_container::iterator pos = customShapes->begin(); pos != customShapes->end(); ++pos) { - assert(pos->second); - pos->second->evalInitConds(); + for (PresetOutputs::cshape_container::iterator pos = customShapes.begin(); pos != customShapes.end(); ++pos) { + assert(*pos); + (*pos)->evalInitConds(); } } @@ -166,9 +157,9 @@ void Preset::evalCustomShapeInitConditions() void Preset::evalCustomWaveInitConditions() { - for (PresetOutputs::cwave_container::iterator pos = customWaves->begin(); pos != customWaves->end(); ++pos) { - assert(pos->second); - pos->second->evalInitConds(); + for (PresetOutputs::cwave_container::iterator pos = customWaves.begin(); pos != customWaves.end(); ++pos) { + assert(*pos); + (*pos)->evalInitConds(); } } @@ -176,17 +167,17 @@ void Preset::evalCustomWaveInitConditions() void Preset::evalCustomWavePerFrameEquations() { - for (PresetOutputs::cwave_container::iterator pos = customWaves->begin(); pos != customWaves->end(); ++pos) + for (PresetOutputs::cwave_container::iterator pos = customWaves.begin(); pos != customWaves.end(); ++pos) { - std::map & init_cond_tree = pos->second->init_cond_tree; + std::map & init_cond_tree = (*pos)->init_cond_tree; for (std::map::iterator _pos = init_cond_tree.begin(); _pos != init_cond_tree.end(); ++_pos) { assert(_pos->second); _pos->second->evaluate(); } - std::map & per_frame_eqn_tree = pos->second->per_frame_eqn_tree; + std::map & per_frame_eqn_tree = (*pos)->per_frame_eqn_tree; for (std::map::iterator _pos = per_frame_eqn_tree.begin(); _pos != per_frame_eqn_tree.end(); ++_pos) { assert(_pos->second); @@ -199,16 +190,16 @@ void Preset::evalCustomWavePerFrameEquations() void Preset::evalCustomShapePerFrameEquations() { - for (PresetOutputs::cshape_container::iterator pos = customShapes->begin(); pos != customShapes->end(); ++pos) + for (PresetOutputs::cshape_container::iterator pos = customShapes.begin(); pos != customShapes.end(); ++pos) { - std::map & init_cond_tree = pos->second->init_cond_tree; + std::map & init_cond_tree = (*pos)->init_cond_tree; for (std::map::iterator _pos = init_cond_tree.begin(); _pos != init_cond_tree.end(); ++_pos) { assert(_pos->second); _pos->second->evaluate(); } - std::map & per_frame_eqn_tree = pos->second->per_frame_eqn_tree; + std::map & per_frame_eqn_tree = (*pos)->per_frame_eqn_tree; for (std::map::iterator _pos = per_frame_eqn_tree.begin(); _pos != per_frame_eqn_tree.end(); ++_pos) { assert(_pos->second); @@ -305,10 +296,10 @@ void Preset::loadCustomWaveUnspecInitConds() { - for (PresetOutputs::cwave_container::iterator pos = customWaves->begin(); pos != customWaves->end(); ++pos) + for (PresetOutputs::cwave_container::iterator pos = customWaves.begin(); pos != customWaves.end(); ++pos) { - assert(pos->second); - pos->second->loadUnspecInitConds(); + assert(*pos); + (*pos)->loadUnspecInitConds(); } } @@ -316,10 +307,10 @@ void Preset::loadCustomWaveUnspecInitConds() void Preset::loadCustomShapeUnspecInitConds() { - for (PresetOutputs::cshape_container::iterator pos = customShapes->begin(); pos != customShapes->end(); ++pos) + for (PresetOutputs::cshape_container::iterator pos = customShapes.begin(); pos != customShapes.end(); ++pos) { - assert(pos->second); - pos->second->loadUnspecInitConds(); + assert(*pos); + (*pos)->loadUnspecInitConds(); } } @@ -337,8 +328,14 @@ void Preset::evaluateFrame() evalCustomWavePerFrameEquations(); evalCustomShapePerFrameEquations(); + // Setup pointers of the custom waves and shapes to the preset outputs instance + /// @slow an extra O(N) per frame, could do this during eval + m_presetOutputs.customWaves = PresetOutputs::cwave_container(customWaves); + m_presetOutputs.customShapes = PresetOutputs::cshape_container(customShapes); + } + // Evaluates all per-pixel equations void Preset::evalPerPixelEqns() { diff --git a/src/projectM-engine/Preset.hpp b/src/projectM-engine/Preset.hpp index 6175ef9ba..e93cfdc18 100644 --- a/src/projectM-engine/Preset.hpp +++ b/src/projectM-engine/Preset.hpp @@ -66,9 +66,6 @@ public: /// \param presetOutputs initialized and filled with data parsed from a preset Preset(const std::string & filename, const PresetInputs & presetInputs, PresetOutputs & presetOutputs); - /// A special preset destructor. Very important: the preset destructor is currently responsible - /// for clearing out all heap memory it allocated in presetOutputs. This might change in future. - /// Conclusion: It does NOT necessarily reset or clear any values. It only deallocates. ~Preset(); /// Evaluates the preset for a frame given the current values of preset inputs / outputs @@ -85,7 +82,7 @@ public: /// Used by parser to find/create custom waves and shapes. May be refactored template - static CustomObject * find_custom_object(int id, bool create_flag, std::map & customObjects); + static CustomObject * find_custom_object(int id, std::vector & customObjects); int per_pixel_eqn_string_index; @@ -118,8 +115,8 @@ public: } /// @bug encapsulate - PresetOutputs::cwave_container * customWaves; - PresetOutputs::cshape_container * customShapes; + PresetOutputs::cwave_container customWaves; + PresetOutputs::cshape_container customShapes; /// @bug encapsulate /* Data structures that contain equation and initial condition information */ @@ -157,37 +154,30 @@ private: }; template -CustomObject * Preset::find_custom_object(int id, bool create_flag, std::map & customObjects) +CustomObject * Preset::find_custom_object(int id, std::vector & customObjects) { CustomObject * custom_object = NULL; - typename std::map::iterator pos = customObjects.find(id); + for (typename std::vector::iterator pos = customObjects.begin(); pos != customObjects.end();++pos) { + if ((*pos)->id == id) { + custom_object = *pos; + break; + } + } - if (pos == customObjects.end()) + if (custom_object == NULL) { - if (create_flag == false) - { - return NULL; - } if ((custom_object = new CustomObject(id)) == NULL) { return NULL; } - std::pair::iterator, bool> inserteePair = - customObjects.insert(std::make_pair(custom_object->id, custom_object)); - - assert(inserteePair.second); - - custom_object = inserteePair.first->second; + customObjects.push_back(custom_object); } - else - custom_object = pos->second; - assert(custom_object); return custom_object; diff --git a/src/projectM-engine/PresetFrameIO.cpp b/src/projectM-engine/PresetFrameIO.cpp index eb2c19e08..7861a8111 100644 --- a/src/projectM-engine/PresetFrameIO.cpp +++ b/src/projectM-engine/PresetFrameIO.cpp @@ -13,7 +13,7 @@ void PresetInputs::Initialize ( int gx, int gy ) this->gx =gx; this->gy=gy; - std::cerr << "Allocating x_mesh, gx,gy is " << gx << "," << gy << std::endl; + this->x_mesh= ( float ** ) wipemalloc ( gx * sizeof ( float * ) ); for ( x = 0; x < gx; x++ ) { @@ -186,6 +186,7 @@ PresetInputs::~PresetInputs() this->theta_mesh = NULL; } + void PresetInputs::ResetMesh() { int x,y; diff --git a/src/projectM-engine/PresetFrameIO.hpp b/src/projectM-engine/PresetFrameIO.hpp index 5871641e0..6ec546d5f 100644 --- a/src/projectM-engine/PresetFrameIO.hpp +++ b/src/projectM-engine/PresetFrameIO.hpp @@ -1,6 +1,6 @@ #ifndef PRESET_FRAME_IO_HPP #define PRESET_FRAME_IO_HPP -#include +#include class CustomWave; class CustomShape; @@ -10,8 +10,8 @@ class CustomShape; /// Every preset object needs a reference to one of these. class PresetOutputs { public: - typedef std::map cwave_container; - typedef std::map cshape_container; + typedef std::vector cwave_container; + typedef std::vector cshape_container; cwave_container customWaves; cshape_container customShapes; diff --git a/src/projectM-engine/PresetMerge.cpp b/src/projectM-engine/PresetMerge.cpp index b262369d3..fc9ee47f4 100644 --- a/src/projectM-engine/PresetMerge.cpp +++ b/src/projectM-engine/PresetMerge.cpp @@ -57,39 +57,40 @@ void PresetMerger::MergePresets(PresetOutputs & A, PresetOutputs & B, double rat for (PresetOutputs::cshape_container::iterator pos = A.customShapes.begin(); pos != A.customShapes.end(); ++pos) { - pos->second->a *= invratio; - pos->second->a2 *= invratio; - pos->second->border_a *= invratio; + (*pos)->a *= invratio; + (*pos)->a2 *= invratio; + (*pos)->border_a *= invratio; } for (PresetOutputs::cshape_container::iterator pos = B.customShapes.begin(); pos != B.customShapes.end(); ++pos) { - pos->second->a *= ratio; - pos->second->a2 *= ratio; - pos->second->border_a *= ratio; - A.customShapes[pos->first>>8]=pos->second; + (*pos)->a *= ratio; + (*pos)->a2 *= ratio; + (*pos)->border_a *= ratio; + + A.customShapes.push_back(*pos); } for (PresetOutputs::cwave_container::iterator pos = A.customWaves.begin(); pos != A.customWaves.end(); ++pos) { - pos->second->a *= invratio; - for (int x; x < pos->second->samples; x++) + (*pos)->a *= invratio; + for (int x; x < (*pos)->samples; x++) { - pos->second->a_mesh[x]=pos->second->a_mesh[x]*invratio; + (*pos)->a_mesh[x]= (*pos)->a_mesh[x]*invratio; } } for (PresetOutputs::cwave_container::iterator pos = B.customWaves.begin(); pos != B.customWaves.end(); ++pos) { - pos->second->a *= ratio; - for (int x; x < pos->second->samples; x++) + (*pos)->a *= ratio; + for (int x; x < (*pos)->samples; x++) { - pos->second->a_mesh[x]=pos->second->a_mesh[x]*ratio; + (*pos)->a_mesh[x]= (*pos)->a_mesh[x]*ratio; } - A.customWaves[pos->first>>8]=pos->second; + A.customWaves.push_back(*pos); } diff --git a/src/projectM-engine/Renderer.cpp b/src/projectM-engine/Renderer.cpp index 2d2acf1a4..a8b1a06fe 100644 --- a/src/projectM-engine/Renderer.cpp +++ b/src/projectM-engine/Renderer.cpp @@ -586,46 +586,45 @@ void Renderer::draw_custom_waves(PresetOutputs *presetOutputs) { glPointSize(this->renderTarget->texsize < 512 ? 1 : this->renderTarget->texsize/512); - /// @bug SPERL: this is a starting point at least for (PresetOutputs::cwave_container::const_iterator pos = presetOutputs->customWaves.begin(); pos != presetOutputs->customWaves.end(); ++pos) { - if(pos->second->enabled==1) + if( (*pos)->enabled==1) { - if (pos->second->bAdditive==0) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + if ( (*pos)->bAdditive==0) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); else glBlendFunc(GL_SRC_ALPHA, GL_ONE); - if (pos->second->bDrawThick==1) glLineWidth(this->renderTarget->texsize < 512 ? 1 : 2*this->renderTarget->texsize/512); + if ( (*pos)->bDrawThick==1) glLineWidth(this->renderTarget->texsize < 512 ? 1 : 2*this->renderTarget->texsize/512); - beatDetect->pcm->getPCM(pos->second->value1,pos->second->samples,0,pos->second->bSpectrum,pos->second->smoothing,0); - beatDetect->pcm->getPCM(pos->second->value2,pos->second->samples,1,pos->second->bSpectrum,pos->second->smoothing,0); + beatDetect->pcm->getPCM( (*pos)->value1, (*pos)->samples,0, (*pos)->bSpectrum, (*pos)->smoothing,0); + beatDetect->pcm->getPCM( (*pos)->value2, (*pos)->samples,1, (*pos)->bSpectrum, (*pos)->smoothing,0); // printf("%f\n",pcmL[0]); - float mult=pos->second->scaling*presetOutputs->fWaveScale*(pos->second->bSpectrum ? 0.015f :1.0f); + float mult= (*pos)->scaling*presetOutputs->fWaveScale*( (*pos)->bSpectrum ? 0.015f :1.0f); - for(x=0;xsecond->samples;x++) - {pos->second->value1[x]*=mult;} + for(x=0;x< (*pos)->samples;x++) + { (*pos)->value1[x]*=mult;} - for(x=0;xsecond->samples;x++) - {pos->second->value2[x]*=mult;} + for(x=0;x< (*pos)->samples;x++) + { (*pos)->value2[x]*=mult;} - for(x=0;xsecond->samples;x++) - {pos->second->sample_mesh[x]=((float)x)/((float)(pos->second->samples-1));} + for(x=0;x< (*pos)->samples;x++) + { (*pos)->sample_mesh[x]=((float)x)/((float)( (*pos)->samples-1));} // printf("mid inner loop\n"); - pos->second->evalPerPointEqns(); + (*pos)->evalPerPointEqns(); //put drawing code here - if (pos->second->bUseDots==1) glBegin(GL_POINTS); + if ( (*pos)->bUseDots==1) glBegin(GL_POINTS); else glBegin(GL_LINE_STRIP); - for(x=0;xsecond->samples;x++) + for(x=0;x< (*pos)->samples;x++) { - glColor4f(pos->second->r_mesh[x],pos->second->g_mesh[x],pos->second->b_mesh[x],pos->second->a_mesh[x]); - glVertex3f(pos->second->x_mesh[x],-(pos->second->y_mesh[x]-1),-1); + glColor4f( (*pos)->r_mesh[x], (*pos)->g_mesh[x], (*pos)->b_mesh[x], (*pos)->a_mesh[x]); + glVertex3f( (*pos)->x_mesh[x],-( (*pos)->y_mesh[x]-1),-1); } glEnd(); glPointSize(this->renderTarget->texsize < 512 ? 1 : this->renderTarget->texsize/512); @@ -649,8 +648,9 @@ void Renderer::draw_shapes(PresetOutputs *presetOutputs) { float radius; - float pi = 3.14159265; - float start,inc,xval,yval; +// float pi = 3.14159265; +// float start,inc + float xval,yval; float t; @@ -666,14 +666,14 @@ void Renderer::draw_shapes(PresetOutputs *presetOutputs) { pos != presetOutputs->customShapes.end(); ++pos) { - if(pos->second->enabled==1) + if( (*pos)->enabled==1) { - // printf("drawing shape %f\n",pos->second->ang); - pos->second->y=-((pos->second->y)-1); + // printf("drawing shape %f\n", (*pos)->ang); + (*pos)->y=-(( (*pos)->y)-1); radius=.5; - pos->second->radius=pos->second->radius*(.707*.707*.707*1.04); + (*pos)->radius= (*pos)->radius*(.707*.707*.707*1.04); //Additive Drawing or Overwrite - if (pos->second->additive==0) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + if ( (*pos)->additive==0) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); else glBlendFunc(GL_SRC_ALPHA, GL_ONE); glMatrixMode(GL_MODELVIEW); @@ -687,10 +687,10 @@ void Renderer::draw_shapes(PresetOutputs *presetOutputs) { } */ - xval=pos->second->x; - yval=pos->second->y; + xval= (*pos)->x; + yval= (*pos)->y; - if (pos->second->textured) + if ( (*pos)->textured) { glMatrixMode(GL_TEXTURE); glPushMatrix(); @@ -701,9 +701,9 @@ void Renderer::draw_shapes(PresetOutputs *presetOutputs) { //glTranslatef(.5,.5, 0); //if (this->correction) glScalef(1,this->vw/(float)this->vh,1); - //glRotatef((pos->second->tex_ang*360/6.280), 0, 0, 1); + //glRotatef(( (*pos)->tex_ang*360/6.280), 0, 0, 1); - //glScalef(1/(pos->second->tex_zoom),1/(pos->second->tex_zoom),1); + //glScalef(1/( (*pos)->tex_zoom),1/( (*pos)->tex_zoom),1); // glScalef(1,vh/(float)vw,1); //glTranslatef((-.5) ,(-.5),0); @@ -712,25 +712,25 @@ void Renderer::draw_shapes(PresetOutputs *presetOutputs) { glBegin(GL_TRIANGLE_FAN); - glColor4f(0.0,0.0,0.0,pos->second->a); - //glColor4f(pos->second->r,pos->second->g,pos->second->b,pos->second->a); + glColor4f(0.0,0.0,0.0, (*pos)->a); + //glColor4f( (*pos)->r, (*pos)->g, (*pos)->b, (*pos)->a); glTexCoord2f(.5,.5); glVertex3f(xval,yval,-1); - //glColor4f(pos->second->r2,pos->second->g2,pos->second->b2,pos->second->a2); - glColor4f(0.0,0.0,0.0,pos->second->a2); + //glColor4f( (*pos)->r2, (*pos)->g2, (*pos)->b2, (*pos)->a2); + glColor4f(0.0,0.0,0.0, (*pos)->a2); - for ( i=1;isecond->sides+2;i++) + for ( i=1;i< (*pos)->sides+2;i++) { // theta+=inc; - // glColor4f(pos->second->r2,pos->second->g2,pos->second->b2,pos->second->a2); + // glColor4f( (*pos)->r2, (*pos)->g2, (*pos)->b2, (*pos)->a2); //glTexCoord2f(radius*cos(theta)+.5 ,radius*sin(theta)+.5 ); - //glVertex3f(pos->second->radius*cos(theta)+xval,pos->second->radius*sin(theta)+yval,-1); - t = (i-1)/(float)pos->second->sides; + //glVertex3f( (*pos)->radius*cos(theta)+xval, (*pos)->radius*sin(theta)+yval,-1); + t = (i-1)/(float) (*pos)->sides; - glTexCoord2f( 0.5f + 0.5f*cosf(t*3.1415927f*2 + pos->second->tex_ang + 3.1415927f*0.25f)*(this->correction ? this->aspect : 1.0)/pos->second->tex_zoom, 0.5f + 0.5f*sinf(t*3.1415927f*2 + pos->second->tex_ang + 3.1415927f*0.25f)/pos->second->tex_zoom); - glVertex3f(pos->second->radius*cosf(t*3.1415927f*2 + pos->second->ang + 3.1415927f*0.25f)*(this->correction ? this->aspect : 1.0)+xval, pos->second->radius*sinf(t*3.1415927f*2 + pos->second->ang + 3.1415927f*0.25f)+yval,-1); + glTexCoord2f( 0.5f + 0.5f*cosf(t*3.1415927f*2 + (*pos)->tex_ang + 3.1415927f*0.25f)*(this->correction ? this->aspect : 1.0)/ (*pos)->tex_zoom, 0.5f + 0.5f*sinf(t*3.1415927f*2 + (*pos)->tex_ang + 3.1415927f*0.25f)/ (*pos)->tex_zoom); + glVertex3f( (*pos)->radius*cosf(t*3.1415927f*2 + (*pos)->ang + 3.1415927f*0.25f)*(this->correction ? this->aspect : 1.0)+xval, (*pos)->radius*sinf(t*3.1415927f*2 + (*pos)->ang + 3.1415927f*0.25f)+yval,-1); } glEnd(); @@ -742,26 +742,26 @@ void Renderer::draw_shapes(PresetOutputs *presetOutputs) { glMatrixMode(GL_MODELVIEW); } else{//Untextured (use color values) - //printf("untextured %f %f %f @:%f,%f %f %f\n",pos->second->a2,pos->second->a,pos->second->border_a, pos->second->x,pos->second->y,pos->second->radius,pos->second->ang); + //printf("untextured %f %f %f @:%f,%f %f %f\n", (*pos)->a2, (*pos)->a, (*pos)->border_a, (*pos)->x, (*pos)->y, (*pos)->radius, (*pos)->ang); //draw first n-1 triangular pieces glBegin(GL_TRIANGLE_FAN); - glColor4f(pos->second->r,pos->second->g,pos->second->b,pos->second->a); + glColor4f( (*pos)->r, (*pos)->g, (*pos)->b, (*pos)->a); // glTexCoord2f(.5,.5); glVertex3f(xval,yval,-1); - glColor4f(pos->second->r2,pos->second->g2,pos->second->b2,pos->second->a2); + glColor4f( (*pos)->r2, (*pos)->g2, (*pos)->b2, (*pos)->a2); - for ( i=1;isecond->sides+2;i++) + for ( i=1;i< (*pos)->sides+2;i++) { //theta+=inc; - // glColor4f(pos->second->r2,pos->second->g2,pos->second->b2,pos->second->a2); + // glColor4f( (*pos)->r2, (*pos)->g2, (*pos)->b2, (*pos)->a2); // glTexCoord2f(radius*cos(theta)+.5 ,radius*sin(theta)+.5 ); - //glVertex3f(pos->second->radius*cos(theta)+xval,pos->second->radius*sin(theta)+yval,-1); + //glVertex3f( (*pos)->radius*cos(theta)+xval, (*pos)->radius*sin(theta)+yval,-1); - t = (i-1)/(float)pos->second->sides; - glVertex3f(pos->second->radius*cosf(t*3.1415927f*2 + pos->second->ang + 3.1415927f*0.25f)*(this->correction ? this->aspect : 1.0)+xval, pos->second->radius*sinf(t*3.1415927f*2 + pos->second->ang + 3.1415927f*0.25f)+yval,-1); + t = (i-1)/(float) (*pos)->sides; + glVertex3f( (*pos)->radius*cosf(t*3.1415927f*2 + (*pos)->ang + 3.1415927f*0.25f)*(this->correction ? this->aspect : 1.0)+xval, (*pos)->radius*sinf(t*3.1415927f*2 + (*pos)->ang + 3.1415927f*0.25f)+yval,-1); } glEnd(); @@ -770,15 +770,15 @@ void Renderer::draw_shapes(PresetOutputs *presetOutputs) { } if (presetOutputs->bWaveThick==1) glLineWidth(this->renderTarget->texsize < 512 ? 1 : 2*this->renderTarget->texsize/512); glBegin(GL_LINE_LOOP); - glColor4f(pos->second->border_r,pos->second->border_g,pos->second->border_b,pos->second->border_a); - for ( i=1;isecond->sides+1;i++) + glColor4f( (*pos)->border_r, (*pos)->border_g, (*pos)->border_b, (*pos)->border_a); + for ( i=1;i< (*pos)->sides+1;i++) { - t = (i-1)/(float)pos->second->sides; - glVertex3f(pos->second->radius*cosf(t*3.1415927f*2 + pos->second->ang + 3.1415927f*0.25f)*(this->correction ? this->aspect : 1.0)+xval, pos->second->radius*sinf(t*3.1415927f*2 + pos->second->ang + 3.1415927f*0.25f)+yval,-1); + t = (i-1)/(float) (*pos)->sides; + glVertex3f( (*pos)->radius*cosf(t*3.1415927f*2 + (*pos)->ang + 3.1415927f*0.25f)*(this->correction ? this->aspect : 1.0)+xval, (*pos)->radius*sinf(t*3.1415927f*2 + (*pos)->ang + 3.1415927f*0.25f)+yval,-1); //theta+=inc; - //glVertex3f(pos->second->radius*cos(theta)+xval,pos->second->radius*sin(theta)+yval,-1); + //glVertex3f( (*pos)->radius*cos(theta)+xval, (*pos)->radius*sin(theta)+yval,-1); } glEnd(); if (presetOutputs->bWaveThick==1) glLineWidth(this->renderTarget->texsize < 512 ? 1 : this->renderTarget->texsize/512);