- removed deprecated code from renderer since we have good success with the visible quad cache
This commit is contained in:
parent
a7ca23d18e
commit
c6e809ec97
|
@ -43,7 +43,6 @@ namespace Glest { namespace Game{
|
|||
bool MeshCallbackTeamColor::noTeamColors = false;
|
||||
|
||||
void MeshCallbackTeamColor::execute(const Mesh *mesh) {
|
||||
|
||||
//team color
|
||||
if( mesh->getCustomTexture() && teamTexture != NULL &&
|
||||
MeshCallbackTeamColor::noTeamColors == false) {
|
||||
|
@ -145,7 +144,6 @@ const int MIN_FPS_NORMAL_RENDERING_TOP_THRESHOLD = 25;
|
|||
// ==================== constructor and destructor ====================
|
||||
|
||||
Renderer::Renderer() {
|
||||
this->useQuadCache = true;
|
||||
this->allowRenderUnitTitles = false;
|
||||
this->menu = NULL;
|
||||
this->game = NULL;
|
||||
|
@ -170,7 +168,6 @@ Renderer::Renderer() {
|
|||
FactoryRepository &fr= FactoryRepository::getInstance();
|
||||
Config &config= Config::getInstance();
|
||||
|
||||
this->useQuadCache = config.getBool("UseQuadCache","true");
|
||||
this->no2DMouseRendering = config.getBool("No2DMouseRendering","false");
|
||||
this->maxConsoleLines= config.getInt("ConsoleMaxLines");
|
||||
|
||||
|
@ -190,8 +187,6 @@ Renderer::Renderer() {
|
|||
fontManager[i]= graphicsFactory->newFontManager();
|
||||
}
|
||||
|
||||
//SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
|
||||
|
||||
saveScreenShotThread = new SimpleTaskThread(this,0,25);
|
||||
saveScreenShotThread->setUniqueID(__FILE__);
|
||||
saveScreenShotThread->start();
|
||||
|
@ -278,9 +273,7 @@ void Renderer::reinitAll() {
|
|||
// ==================== init ====================
|
||||
|
||||
void Renderer::init() {
|
||||
|
||||
Config &config= Config::getInstance();
|
||||
|
||||
loadConfig();
|
||||
|
||||
if(config.getBool("CheckGlCaps")){
|
||||
|
@ -339,7 +332,6 @@ void Renderer::initGame(const Game *game){
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
if(shadows == sShadowMapping) {
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
//shadow mapping
|
||||
|
@ -354,7 +346,6 @@ void Renderer::initGame(const Game *game){
|
|||
0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL);
|
||||
}
|
||||
else {
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
//projected
|
||||
|
@ -425,7 +416,6 @@ void Renderer::reset3dMenu(){
|
|||
// ==================== end ====================
|
||||
|
||||
void Renderer::end() {
|
||||
|
||||
//delete resources
|
||||
modelManager[rsGlobal]->end();
|
||||
textureManager[rsGlobal]->end();
|
||||
|
@ -471,6 +461,7 @@ void Renderer::reloadResources(){
|
|||
textureManager[i]->end();
|
||||
fontManager[i]->end();
|
||||
}
|
||||
|
||||
for(int i=0; i<rsCount; ++i) {
|
||||
modelManager[i]->init();
|
||||
textureManager[i]->init();
|
||||
|
@ -478,7 +469,6 @@ void Renderer::reloadResources(){
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// ==================== engine interface ====================
|
||||
|
||||
void Renderer::initTexture(ResourceScope rs, Texture *texture) {
|
||||
|
@ -543,7 +533,6 @@ void Renderer::renderParticleManager(ResourceScope rs){
|
|||
}
|
||||
|
||||
void Renderer::swapBuffers() {
|
||||
|
||||
//glFlush(); // should not be required - http://www.opengl.org/wiki/Common_Mistakes
|
||||
glFlush();
|
||||
|
||||
|
@ -554,7 +543,6 @@ void Renderer::swapBuffers(){
|
|||
|
||||
//places all the opengl lights
|
||||
void Renderer::setupLighting() {
|
||||
|
||||
int lightCount= 0;
|
||||
const World *world= game->getWorld();
|
||||
const GameCamera *gameCamera= game->getGameCamera();
|
||||
|
@ -652,7 +640,7 @@ void Renderer::renderMouse2d(int x, int y, int anim, float fade){
|
|||
if(no2DMouseRendering == true) {
|
||||
return;
|
||||
}
|
||||
float color1, color2;
|
||||
float color1 = 0.0, color2 = 0.0;
|
||||
|
||||
float fadeFactor = fade + 1.f;
|
||||
|
||||
|
@ -705,6 +693,11 @@ void Renderer::renderMouse3d() {
|
|||
const Gui *gui= game->getGui();
|
||||
const Mouse3d *mouse3d= gui->getMouse3d();
|
||||
const Map *map= game->getWorld()->getMap();
|
||||
if(map == NULL) {
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,"In [%s::%s] Line: %d map == NULL",__FILE__,__FUNCTION__,__LINE__);
|
||||
throw runtime_error(szBuf);
|
||||
}
|
||||
|
||||
GLUquadricObj *cilQuadric;
|
||||
Vec4f color;
|
||||
|
@ -723,16 +716,9 @@ void Renderer::renderMouse3d() {
|
|||
|
||||
const Vec2i &pos= gui->getPosObjWorld();
|
||||
|
||||
if(map == NULL) {
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,"In [%s::%s] Line: %d map == NULL",__FILE__,__FUNCTION__,__LINE__);
|
||||
throw runtime_error(szBuf);
|
||||
}
|
||||
|
||||
Vec3f pos3f= Vec3f(pos.x, map->getCell(pos)->getHeight(), pos.y);
|
||||
|
||||
if(gui->isPlacingBuilding()) {
|
||||
|
||||
const UnitType *building= gui->getBuilding();
|
||||
|
||||
//selection building emplacement
|
||||
|
@ -794,7 +780,6 @@ void Renderer::renderMouse3d() {
|
|||
}
|
||||
|
||||
void Renderer::renderBackground(const Texture2D *texture) {
|
||||
|
||||
const Metrics &metrics= Metrics::getInstance();
|
||||
|
||||
assertGl();
|
||||
|
@ -999,7 +984,6 @@ void Renderer::renderChatManager(const ChatManager *chatManager) {
|
|||
}
|
||||
|
||||
void Renderer::renderResourceStatus() {
|
||||
|
||||
const Metrics &metrics= Metrics::getInstance();
|
||||
const World *world= game->getWorld();
|
||||
const Faction *thisFaction= world->getFaction(world->getThisFactionIndex());
|
||||
|
@ -1062,7 +1046,6 @@ void Renderer::renderResourceStatus(){
|
|||
}
|
||||
|
||||
void Renderer::renderSelectionQuad() {
|
||||
|
||||
const Gui *gui= game->getGui();
|
||||
const SelectionQuad *sq= gui->getSelectionQuad();
|
||||
|
||||
|
@ -1716,17 +1699,12 @@ void Renderer::renderSurface(const int renderFps) {
|
|||
glEnable(GL_TEXTURE_2D);
|
||||
glBindTexture(GL_TEXTURE_2D, static_cast<const Texture2DGl*>(fowTex)->getHandle());
|
||||
|
||||
//glCompressedTexSubImage2D(
|
||||
// GL_TEXTURE_2D, 0, 0, 0,
|
||||
// fowTex->getPixmap()->getW(), fowTex->getPixmap()->getH(),
|
||||
// GL_ALPHA, GL_UNSIGNED_BYTE, fowTex->getPixmap()->getPixels());
|
||||
|
||||
glTexSubImage2D(
|
||||
GL_TEXTURE_2D, 0, 0, 0,
|
||||
fowTex->getPixmapConst()->getW(), fowTex->getPixmapConst()->getH(),
|
||||
GL_ALPHA, GL_UNSIGNED_BYTE, fowTex->getPixmapConst()->getPixels());
|
||||
|
||||
if(!shadowsOffDueToMinRender) {
|
||||
if(shadowsOffDueToMinRender == false) {
|
||||
//shadow texture
|
||||
if(shadows==sProjected || shadows==sShadowMapping){
|
||||
glActiveTexture(shadowTexUnit);
|
||||
|
@ -1741,7 +1719,6 @@ void Renderer::renderSurface(const int renderFps) {
|
|||
|
||||
glActiveTexture(baseTexUnit);
|
||||
|
||||
if(useQuadCache == true) {
|
||||
VisibleQuadContainerCache &qCache = getQuadCache();
|
||||
if(qCache.visibleScaledCellList.size() > 0) {
|
||||
for(int visibleIndex = 0;
|
||||
|
@ -1807,73 +1784,6 @@ void Renderer::renderSurface(const int renderFps) {
|
|||
glEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Quad2i scaledQuad= visibleQuad/Map::cellScale;
|
||||
|
||||
PosQuadIterator pqi(scaledQuad);
|
||||
while(pqi.next()) {
|
||||
const Vec2i &pos= pqi.getPos();
|
||||
if(mapBounds.isInside(pos)){
|
||||
|
||||
SurfaceCell *tc00= map->getSurfaceCell(pos.x, pos.y);
|
||||
SurfaceCell *tc10= map->getSurfaceCell(pos.x+1, pos.y);
|
||||
SurfaceCell *tc01= map->getSurfaceCell(pos.x, pos.y+1);
|
||||
SurfaceCell *tc11= map->getSurfaceCell(pos.x+1, pos.y+1);
|
||||
|
||||
if(tc00 == NULL) {
|
||||
throw runtime_error("tc00 == NULL");
|
||||
}
|
||||
if(tc10 == NULL) {
|
||||
throw runtime_error("tc10 == NULL");
|
||||
}
|
||||
if(tc01 == NULL) {
|
||||
throw runtime_error("tc01 == NULL");
|
||||
}
|
||||
if(tc11 == NULL) {
|
||||
throw runtime_error("tc11 == NULL");
|
||||
}
|
||||
|
||||
triangleCount+= 2;
|
||||
pointCount+= 4;
|
||||
|
||||
//set texture
|
||||
currTex= static_cast<const Texture2DGl*>(tc00->getSurfaceTexture())->getHandle();
|
||||
if(currTex!=lastTex){
|
||||
lastTex=currTex;
|
||||
glBindTexture(GL_TEXTURE_2D, lastTex);
|
||||
}
|
||||
|
||||
const Vec2f &surfCoord= tc00->getSurfTexCoord();
|
||||
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
|
||||
//draw quad using immediate mode
|
||||
glMultiTexCoord2fv(fowTexUnit, tc01->getFowTexCoord().ptr());
|
||||
glMultiTexCoord2f(baseTexUnit, surfCoord.x, surfCoord.y + coordStep);
|
||||
glNormal3fv(tc01->getNormal().ptr());
|
||||
glVertex3fv(tc01->getVertex().ptr());
|
||||
|
||||
glMultiTexCoord2fv(fowTexUnit, tc00->getFowTexCoord().ptr());
|
||||
glMultiTexCoord2f(baseTexUnit, surfCoord.x, surfCoord.y);
|
||||
glNormal3fv(tc00->getNormal().ptr());
|
||||
glVertex3fv(tc00->getVertex().ptr());
|
||||
|
||||
glMultiTexCoord2fv(fowTexUnit, tc11->getFowTexCoord().ptr());
|
||||
glMultiTexCoord2f(baseTexUnit, surfCoord.x+coordStep, surfCoord.y+coordStep);
|
||||
glNormal3fv(tc11->getNormal().ptr());
|
||||
glVertex3fv(tc11->getVertex().ptr());
|
||||
|
||||
glMultiTexCoord2fv(fowTexUnit, tc10->getFowTexCoord().ptr());
|
||||
glMultiTexCoord2f(baseTexUnit, surfCoord.x + coordStep, surfCoord.y);
|
||||
glNormal3fv(tc10->getNormal().ptr());
|
||||
glVertex3fv(tc10->getVertex().ptr());
|
||||
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
//glEnd();
|
||||
}
|
||||
|
||||
//Restore
|
||||
static_cast<ModelRendererGl*>(modelRenderer)->setDuplicateTexCoords(false);
|
||||
|
@ -1898,10 +1808,8 @@ void Renderer::renderObjects(const int renderFps) {
|
|||
const Texture2D *fowTex= NULL;
|
||||
Vec3f baseFogColor;
|
||||
|
||||
|
||||
bool modelRenderStarted = false;
|
||||
|
||||
if(useQuadCache == true) {
|
||||
VisibleQuadContainerCache &qCache = getQuadCache();
|
||||
for(int visibleIndex = 0;
|
||||
visibleIndex < qCache.visibleObjectList.size(); ++visibleIndex) {
|
||||
|
@ -1965,79 +1873,6 @@ void Renderer::renderObjects(const int renderFps) {
|
|||
|
||||
//restore
|
||||
static_cast<ModelRendererGl*>(modelRenderer)->setDuplicateTexCoords(true);
|
||||
}
|
||||
else {
|
||||
int thisTeamIndex= world->getThisTeamIndex();
|
||||
bool modelRenderStarted = false;
|
||||
|
||||
PosQuadIterator pqi(visibleQuad, Map::cellScale);
|
||||
while(pqi.next()) {
|
||||
const Vec2i &pos= pqi.getPos();
|
||||
if(map->isInside(pos)){
|
||||
SurfaceCell *sc= map->getSurfaceCell(Map::toSurfCoords(pos));
|
||||
Object *o= sc->getObject();
|
||||
if(sc->isExplored(thisTeamIndex) && o!=NULL){
|
||||
const Model *objModel= sc->getObject()->getModel();
|
||||
const Vec3f &v= o->getConstPos();
|
||||
|
||||
if(modelRenderStarted == false) {
|
||||
modelRenderStarted = true;
|
||||
|
||||
fowTex= world->getMinimap()->getFowTexture();
|
||||
baseFogColor= world->getTileset()->getFogColor()*computeLightColor(world->getTimeFlow()->getTime());
|
||||
|
||||
glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_FOG_BIT | GL_LIGHTING_BIT | GL_TEXTURE_BIT);
|
||||
|
||||
if(!shadowsOffDueToMinRender &&
|
||||
shadows == sShadowMapping) {
|
||||
glActiveTexture(shadowTexUnit);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, shadowMapHandle);
|
||||
|
||||
static_cast<ModelRendererGl*>(modelRenderer)->setDuplicateTexCoords(true);
|
||||
enableProjectiveTexturing();
|
||||
}
|
||||
|
||||
glActiveTexture(baseTexUnit);
|
||||
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
glAlphaFunc(GL_GREATER, 0.5f);
|
||||
|
||||
modelRenderer->begin(true, true, false);
|
||||
}
|
||||
//ambient and diffuse color is taken from cell color
|
||||
|
||||
float fowFactor= fowTex->getPixmapConst()->getPixelf(pos.x / Map::cellScale, pos.y / Map::cellScale);
|
||||
Vec4f color= Vec4f(Vec3f(fowFactor), 1.f);
|
||||
glColor4fv(color.ptr());
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, (color*ambFactor).ptr());
|
||||
glFogfv(GL_FOG_COLOR, (baseFogColor*fowFactor).ptr());
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glTranslatef(v.x, v.y, v.z);
|
||||
glRotatef(o->getRotation(), 0.f, 1.f, 0.f);
|
||||
|
||||
objModel->updateInterpolationData(0.f, true);
|
||||
modelRenderer->render(objModel);
|
||||
|
||||
triangleCount+= objModel->getTriangleCount();
|
||||
pointCount+= objModel->getVertexCount();
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(modelRenderStarted == true) {
|
||||
modelRenderer->end();
|
||||
glPopAttrib();
|
||||
}
|
||||
|
||||
//restore
|
||||
static_cast<ModelRendererGl*>(modelRenderer)->setDuplicateTexCoords(true);
|
||||
}
|
||||
|
||||
assertGl();
|
||||
}
|
||||
|
@ -2188,7 +2023,6 @@ void Renderer::renderUnits(const int renderFps) {
|
|||
|
||||
bool modelRenderStarted = false;
|
||||
|
||||
if(useQuadCache == true) {
|
||||
VisibleQuadContainerCache &qCache = getQuadCache();
|
||||
if(qCache.visibleQuadUnitList.size() > 0) {
|
||||
for(int visibleUnitIndex = 0;
|
||||
|
@ -2270,94 +2104,7 @@ void Renderer::renderUnits(const int renderFps) {
|
|||
|
||||
//restore
|
||||
static_cast<ModelRendererGl*>(modelRenderer)->setDuplicateTexCoords(true);
|
||||
}
|
||||
else {
|
||||
bool modelRenderStarted = false;
|
||||
|
||||
for(int i=0; i<world->getFactionCount(); ++i){
|
||||
meshCallbackTeamColor.setTeamTexture(world->getFaction(i)->getTexture());
|
||||
for(int j=0; j<world->getFaction(i)->getUnitCount(); ++j){
|
||||
unit= world->getFaction(i)->getUnit(j);
|
||||
if(world->toRenderUnit(unit, visibleQuad)) {
|
||||
|
||||
if(modelRenderStarted == false) {
|
||||
modelRenderStarted = true;
|
||||
|
||||
glPushAttrib(GL_ENABLE_BIT | GL_FOG_BIT | GL_LIGHTING_BIT | GL_TEXTURE_BIT);
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
|
||||
if(!shadowsOffDueToMinRender) {
|
||||
if(shadows==sShadowMapping){
|
||||
glActiveTexture(shadowTexUnit);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, shadowMapHandle);
|
||||
|
||||
static_cast<ModelRendererGl*>(modelRenderer)->setDuplicateTexCoords(true);
|
||||
enableProjectiveTexturing();
|
||||
}
|
||||
}
|
||||
glActiveTexture(baseTexUnit);
|
||||
|
||||
modelRenderer->begin(true, true, true, &meshCallbackTeamColor);
|
||||
}
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
|
||||
//translate
|
||||
Vec3f currVec= unit->getCurrVectorFlat();
|
||||
glTranslatef(currVec.x, currVec.y, currVec.z);
|
||||
|
||||
//rotate
|
||||
glRotatef(unit->getRotation(), 0.f, 1.f, 0.f);
|
||||
glRotatef(unit->getVerticalRotation(), 1.f, 0.f, 0.f);
|
||||
|
||||
//dead alpha
|
||||
float alpha= 1.0f;
|
||||
const SkillType *st= unit->getCurrSkill();
|
||||
if(st->getClass()==scDie && static_cast<const DieSkillType*>(st)->getFade()){
|
||||
alpha= 1.0f-unit->getAnimProgress();
|
||||
glDisable(GL_COLOR_MATERIAL);
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, Vec4f(1.0f, 1.0f, 1.0f, alpha).ptr());
|
||||
}
|
||||
else{
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
glAlphaFunc(GL_GREATER, 0.4f);
|
||||
}
|
||||
|
||||
//render
|
||||
const Model *model= unit->getCurrentModel();
|
||||
model->updateInterpolationData(unit->getAnimProgress(), unit->isAlive());
|
||||
|
||||
modelRenderer->render(model);
|
||||
triangleCount+= model->getTriangleCount();
|
||||
pointCount+= model->getVertexCount();
|
||||
|
||||
glPopMatrix();
|
||||
unit->setVisible(true);
|
||||
unit->setScreenPos(computeScreenPosition(unit->getCurrVectorFlat()));
|
||||
visibleFrameUnitList.push_back(unit);
|
||||
|
||||
//if(allowRenderUnitTitles == true) {
|
||||
// Add to the pending render unit title list
|
||||
//renderUnitTitleList.push_back(std::pair<Unit *,Vec3f>(unit,computeScreenPosition(unit->getCurrVectorFlat())) );
|
||||
//}
|
||||
}
|
||||
else
|
||||
{
|
||||
unit->setVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(modelRenderStarted == true) {
|
||||
modelRenderer->end();
|
||||
glPopAttrib();
|
||||
}
|
||||
|
||||
//restore
|
||||
static_cast<ModelRendererGl*>(modelRenderer)->setDuplicateTexCoords(true);
|
||||
}
|
||||
// reset alpha
|
||||
glAlphaFunc(GL_GREATER, 0.0f);
|
||||
//assert
|
||||
|
@ -2654,7 +2401,6 @@ void Renderer::renderMinimap(){
|
|||
glDisable(GL_BLEND);
|
||||
|
||||
//draw units
|
||||
if(useQuadCache == true) {
|
||||
VisibleQuadContainerCache &qCache = getQuadCache();
|
||||
if(qCache.visibleUnitList.size() > 0) {
|
||||
for(int visibleIndex = 0;
|
||||
|
@ -2679,29 +2425,6 @@ void Renderer::renderMinimap(){
|
|||
glEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
glBegin(GL_QUADS);
|
||||
for(int i=0; i<world->getFactionCount(); ++i){
|
||||
for(int j=0; j<world->getFaction(i)->getUnitCount(); ++j){
|
||||
Unit *unit= world->getFaction(i)->getUnit(j);
|
||||
if(world->toRenderUnit(unit)){
|
||||
if (!unit->isAlive()) {
|
||||
continue;
|
||||
}
|
||||
Vec2i pos= unit->getPos()/Map::cellScale;
|
||||
int size= unit->getType()->getSize();
|
||||
Vec3f color= world->getFaction(i)->getTexture()->getPixmapConst()->getPixel3f(0, 0);
|
||||
glColor3fv(color.ptr());
|
||||
glVertex2f(mx + pos.x*zoom.x, my + mh - (pos.y*zoom.y));
|
||||
glVertex2f(mx + (pos.x+1)*zoom.x+size, my + mh - (pos.y*zoom.y));
|
||||
glVertex2f(mx + (pos.x+1)*zoom.x+size, my + mh - ((pos.y+size)*zoom.y));
|
||||
glVertex2f(mx + pos.x*zoom.x, my + mh - ((pos.y+size)*zoom.y));
|
||||
}
|
||||
}
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
//draw camera
|
||||
float wRatio= static_cast<float>(metrics.getMinimapW()) / world->getMap()->getW();
|
||||
|
@ -3514,9 +3237,6 @@ void Renderer::renderUnitsFast(bool renderingShadows) {
|
|||
assertGl();
|
||||
|
||||
bool modelRenderStarted = false;
|
||||
//bool modelRenderFactionStarted = false;
|
||||
|
||||
if(useQuadCache == true) {
|
||||
VisibleQuadContainerCache &qCache = getQuadCache();
|
||||
if(qCache.visibleQuadUnitList.size() > 0) {
|
||||
for(int visibleUnitIndex = 0;
|
||||
|
@ -3527,10 +3247,11 @@ void Renderer::renderUnitsFast(bool renderingShadows) {
|
|||
modelRenderStarted = true;
|
||||
//glPushAttrib(GL_ENABLE_BIT| GL_TEXTURE_BIT);
|
||||
glDisable(GL_LIGHTING);
|
||||
if (!renderingShadows) {
|
||||
if (renderingShadows == false) {
|
||||
glPushAttrib(GL_ENABLE_BIT);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
glPushAttrib(GL_ENABLE_BIT| GL_TEXTURE_BIT);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glAlphaFunc(GL_GREATER, 0.4f);
|
||||
|
@ -3571,88 +3292,9 @@ void Renderer::renderUnitsFast(bool renderingShadows) {
|
|||
modelRenderer->render(model);
|
||||
|
||||
glPopMatrix();
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] calling glPopName() for unit->getId() = %d\n",__FILE__,__FUNCTION__,__LINE__,unit->getId());
|
||||
glPopName();
|
||||
}
|
||||
|
||||
//if(modelRenderFactionStarted == true) {
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] calling glPopName() for lastFactionIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,lastFactionIndex);
|
||||
//glPopName();
|
||||
//}
|
||||
|
||||
if(modelRenderStarted == true) {
|
||||
modelRenderer->end();
|
||||
glPopAttrib();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
bool modelRenderStarted = false;
|
||||
bool modelRenderFactionStarted = false;
|
||||
for(int i=0; i<world->getFactionCount(); ++i){
|
||||
modelRenderFactionStarted = false;
|
||||
for(int j=0; j<world->getFaction(i)->getUnitCount(); ++j){
|
||||
Unit *unit= world->getFaction(i)->getUnit(j);
|
||||
if(world->toRenderUnit(unit, visibleQuad)) {
|
||||
if(modelRenderStarted == false) {
|
||||
modelRenderStarted = true;
|
||||
glPushAttrib(GL_ENABLE_BIT| GL_TEXTURE_BIT);
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
if (!renderingShadows) {
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
} else {
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glAlphaFunc(GL_GREATER, 0.4f);
|
||||
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
||||
|
||||
//set color to the texture alpha
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PRIMARY_COLOR);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
|
||||
|
||||
//set alpha to the texture alpha
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
|
||||
}
|
||||
|
||||
modelRenderer->begin(false, renderingShadows, false);
|
||||
|
||||
glInitNames();
|
||||
}
|
||||
if(modelRenderFactionStarted == false) {
|
||||
modelRenderFactionStarted = true;
|
||||
glPushName(i);
|
||||
}
|
||||
glPushName(j);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
//debuxar modelo
|
||||
glPushMatrix();
|
||||
|
||||
//translate
|
||||
Vec3f currVec= unit->getCurrVectorFlat();
|
||||
glTranslatef(currVec.x, currVec.y, currVec.z);
|
||||
|
||||
//rotate
|
||||
glRotatef(unit->getRotation(), 0.f, 1.f, 0.f);
|
||||
|
||||
//render
|
||||
const Model *model= unit->getCurrentModel();
|
||||
model->updateInterpolationVertices(unit->getAnimProgress(), unit->isAlive());
|
||||
modelRenderer->render(model);
|
||||
|
||||
glPopMatrix();
|
||||
glPopName();
|
||||
}
|
||||
}
|
||||
if(modelRenderFactionStarted == true) {
|
||||
glPopName();
|
||||
}
|
||||
}
|
||||
if(modelRenderStarted == true) {
|
||||
modelRenderer->end();
|
||||
glPopAttrib();
|
||||
|
@ -3671,7 +3313,6 @@ void Renderer::renderObjectsFast() {
|
|||
|
||||
bool modelRenderStarted = false;
|
||||
|
||||
if(useQuadCache == true) {
|
||||
VisibleQuadContainerCache &qCache = getQuadCache();
|
||||
if(qCache.visibleObjectList.size() > 0) {
|
||||
for(int visibleIndex = 0;
|
||||
|
@ -3718,68 +3359,6 @@ void Renderer::renderObjectsFast() {
|
|||
glPopAttrib();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
int thisTeamIndex= world->getThisTeamIndex();
|
||||
bool modelRenderStarted = false;
|
||||
|
||||
PosQuadIterator pqi(visibleQuad, Map::cellScale);
|
||||
while(pqi.next()) {
|
||||
const Vec2i &pos= pqi.getPos();
|
||||
if(map->isInside(pos)){
|
||||
const Vec2i &mapPos = Map::toSurfCoords(pos);
|
||||
SurfaceCell *sc= map->getSurfaceCell(mapPos);
|
||||
Object *o= sc->getObject();
|
||||
bool isExplored = (sc->isExplored(thisTeamIndex) && o!=NULL);
|
||||
//bool isVisible = (sc->isVisible(thisTeamIndex) && o!=NULL);
|
||||
bool isVisible = true;
|
||||
|
||||
if(isExplored == true && isVisible == true) {
|
||||
const Model *objModel= sc->getObject()->getModel();
|
||||
const Vec3f &v= o->getConstPos();
|
||||
|
||||
if(modelRenderStarted == false) {
|
||||
modelRenderStarted = true;
|
||||
glPushAttrib(GL_ENABLE_BIT| GL_TEXTURE_BIT);
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
glAlphaFunc(GL_GREATER, 0.5f);
|
||||
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
||||
|
||||
//set color to the texture alpha
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PRIMARY_COLOR);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
|
||||
|
||||
//set alpha to the texture alpha
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
|
||||
|
||||
modelRenderer->begin(false, true, false);
|
||||
}
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glTranslatef(v.x, v.y, v.z);
|
||||
glRotatef(o->getRotation(), 0.f, 1.f, 0.f);
|
||||
|
||||
modelRenderer->render(objModel);
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
// vctEntity.push_back(RenderEntity(o,mapPos));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// modelRenderer->begin(false, true, false);
|
||||
// renderObjectFastList(vctEntity);
|
||||
if(modelRenderStarted == true) {
|
||||
modelRenderer->end();
|
||||
glPopAttrib();
|
||||
}
|
||||
}
|
||||
|
||||
assertGl();
|
||||
}
|
||||
|
@ -3787,7 +3366,6 @@ void Renderer::renderObjectsFast() {
|
|||
// ==================== gl caps ====================
|
||||
|
||||
void Renderer::checkGlCaps() {
|
||||
|
||||
//opengl 1.3
|
||||
if(!isGlVersionSupported(1, 3, 0)) {
|
||||
string message;
|
||||
|
@ -3946,7 +3524,6 @@ void Renderer::init3dList() {
|
|||
}
|
||||
|
||||
void Renderer::init2dList() {
|
||||
|
||||
const Metrics &metrics= Metrics::getInstance();
|
||||
|
||||
//this list sets the state for the 2d rendering
|
||||
|
|
|
@ -242,8 +242,6 @@ private:
|
|||
float smoothedRenderFps;
|
||||
bool shadowsOffDueToMinRender;
|
||||
|
||||
bool useQuadCache;
|
||||
|
||||
SimpleTaskThread *saveScreenShotThread;
|
||||
Mutex saveScreenShotThreadAccessor;
|
||||
std::list<std::pair<string,Pixmap2D *> > saveScreenQueue;
|
||||
|
|
Loading…
Reference in New Issue
Block a user