void MenuState::addMenuItem(MenuItem & item) { /* EntityFactory fact(getEngines()); Entity * guyEnt = fact.create< SingleVisualEntity>("bullet", item.MarkerPos); getEngines().entityEngine().addEntity(guyEnt, &getManagedEntityList()); */ // add text Vector2 textPos(item.MarkerPos.x() + 0.9f, item.MarkerPos.y() - 0.5f); TexturePtr textTex = getEngines().resourceEngine().loadImage("textChars"); auto textV = std14::make_unique<TextVisual>( getEngines().renderEngine().getScreenTransform(), textTex, textPos, item.Text); textV->setSizeScale(0.7f); item.TextVis = textV.get(); getEngines().renderEngine().addTextVisual(std::move(textV)); if (m_currentItem < 0) m_currentItem = 0; m_menuItems.push_back(item); }
/******************************************************************************* PointSprites *******************************************************************************/ void PSSprites::render(){ mTexture->bind(); int count = 0; int bad = 0; //Set GL state glEnable(GL_TEXTURE_2D); glDepthMask(GL_FALSE); glEnable(GL_BLEND); //glBlendFunc(GL_SRC_ALPHA,GL_ONE); glBlendFunc(GL_ONE, GL_ONE); //glEnableClientState(GL_VERTEX_ARRAY); #ifdef DISABLE_SIZE glPointSize(5.0f); glBegin(GL_POINTS); #endif //Scaling float scale = setSizeScale(); map<float, ParticleCollection *>::const_iterator itr; //Go through each of the particle collections for(itr = mParticleCollections.begin(); itr != mParticleCollections.end(); ++itr){ ParticleCollection *collection = itr->second; //This may be hidden by colour or size if(!collection->bShown){ continue; } vector<Particle *> *list = &collection->mParticles; //Make sure we've got at least one particle if(list->size() == 0) { continue; } collection->mColor.bind(); //Set the state for this collection #ifndef DISABLE_SIZE glPointSize(collection->fSize * scale); glBegin(GL_POINTS); #endif bad++; //Count the number of state changes count += list->size(); //Count the number of particles //Now render all the particles in this list //TODO: Use glDrawArrays! for(int i=0;i<(int)list->size();i++){ Particle *p = (*list)[i]; glVertex3f(p->x, p->y, p->z); } #ifndef DISABLE_SIZE glEnd(); #endif } #ifdef DISABLE_SIZE glEnd(); #endif //And clean up glDisable(GL_BLEND); glDepthMask(GL_TRUE); //glDisableClientState(GL_VERTEX_ARRAY); iNumActive = count; }
/********************************************* Render using standard drawing **********************************************/ void PSClassic::render(){ mTexture->bind(); int count = 0; int bad = 0; //Set GL state glEnable(GL_TEXTURE_2D); glDepthMask(GL_FALSE); glEnable(GL_BLEND); //glBlendFunc(GL_SRC_ALPHA,GL_ONE); glBlendFunc(GL_ONE, GL_ONE); //Scaling float scale = setSizeScale(); map<float, ParticleCollection *>::const_iterator itr; //Go through each of the particle collections for(itr = mParticleCollections.begin(); itr != mParticleCollections.end(); ++itr){ ParticleCollection *collection = itr->second; //This may be hidden by colour or size if(!collection->bShown){ continue; } vector<Particle *> *list = &collection->mParticles; //Make sure we've got at least one particle if(list->size() == 0) { continue; } //Set the state for this collection float s = collection->fSize * scale / 20.0f; collection->mColor.bind(); bad++; //Count the number of state changes count += list->size(); //Count the number of particles for(int i=0;i<(int)list->size();i++){ Particle *p = (*list)[i]; float x = p->x; float y = p->y; float z = p->z; glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(1,1); glVertex3f(x+s, y+s, z); // Top Right glTexCoord2f(0,1); glVertex3f(x-s, y+s, z); // Top Left glTexCoord2f(1,0); glVertex3f(x+s, y-s, z); // Bottom Right glTexCoord2f(0,0); glVertex3f(x-s, y-s, z); // Bottom Left glEnd(); } } //And clean up glDisable(GL_BLEND); glDepthMask(GL_TRUE); iNumActive = count; }