mirror of
https://github.com/glest/glest-source.git
synced 2025-08-29 02:40:17 +02:00
- atempt to squeeze some extra rendering performance
This commit is contained in:
@@ -1359,8 +1359,28 @@ void Renderer::renderObjects(const int renderFps, const int worldFrameCount) {
|
|||||||
const Map *map= world->getMap();
|
const Map *map= world->getMap();
|
||||||
|
|
||||||
assertGl();
|
assertGl();
|
||||||
const Texture2D *fowTex= world->getMinimap()->getFowTexture();
|
|
||||||
Vec3f baseFogColor= world->getTileset()->getFogColor()*computeLightColor(world->getTimeFlow()->getTime());
|
const Texture2D *fowTex= NULL;
|
||||||
|
Vec3f baseFogColor;
|
||||||
|
|
||||||
|
int thisTeamIndex= world->getThisTeamIndex();
|
||||||
|
bool modelRenderStarted = false;
|
||||||
|
|
||||||
|
PosQuadIterator pqi(map, 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);
|
glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_FOG_BIT | GL_LIGHTING_BIT | GL_TEXTURE_BIT);
|
||||||
|
|
||||||
@@ -1380,21 +1400,6 @@ void Renderer::renderObjects(const int renderFps, const int worldFrameCount) {
|
|||||||
glEnable(GL_COLOR_MATERIAL);
|
glEnable(GL_COLOR_MATERIAL);
|
||||||
glAlphaFunc(GL_GREATER, 0.5f);
|
glAlphaFunc(GL_GREATER, 0.5f);
|
||||||
|
|
||||||
int thisTeamIndex= world->getThisTeamIndex();
|
|
||||||
bool modelRenderStarted = false;
|
|
||||||
|
|
||||||
PosQuadIterator pqi(map, 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;
|
|
||||||
modelRenderer->begin(true, true, false);
|
modelRenderer->begin(true, true, false);
|
||||||
}
|
}
|
||||||
//ambient and diffuse color is taken from cell color
|
//ambient and diffuse color is taken from cell color
|
||||||
@@ -1556,13 +1561,24 @@ void Renderer::renderWater(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::renderUnits(const int renderFps, const int worldFrameCount) {
|
void Renderer::renderUnits(const int renderFps, const int worldFrameCount) {
|
||||||
Unit *unit;
|
Unit *unit=NULL;
|
||||||
const World *world= game->getWorld();
|
const World *world= game->getWorld();
|
||||||
MeshCallbackTeamColor meshCallbackTeamColor;
|
MeshCallbackTeamColor meshCallbackTeamColor;
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
assertGl();
|
assertGl();
|
||||||
|
|
||||||
|
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);
|
glPushAttrib(GL_ENABLE_BIT | GL_FOG_BIT | GL_LIGHTING_BIT | GL_TEXTURE_BIT);
|
||||||
glEnable(GL_COLOR_MATERIAL);
|
glEnable(GL_COLOR_MATERIAL);
|
||||||
|
|
||||||
@@ -1579,16 +1595,6 @@ void Renderer::renderUnits(const int renderFps, const int worldFrameCount) {
|
|||||||
}
|
}
|
||||||
glActiveTexture(baseTexUnit);
|
glActiveTexture(baseTexUnit);
|
||||||
|
|
||||||
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;
|
|
||||||
modelRenderer->begin(true, true, true, &meshCallbackTeamColor);
|
modelRenderer->begin(true, true, true, &meshCallbackTeamColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2713,10 +2719,6 @@ void Renderer::renderUnitsFast(){
|
|||||||
|
|
||||||
assertGl();
|
assertGl();
|
||||||
|
|
||||||
glPushAttrib(GL_ENABLE_BIT);
|
|
||||||
glDisable(GL_TEXTURE_2D);
|
|
||||||
glDisable(GL_LIGHTING);
|
|
||||||
|
|
||||||
bool modelRenderStarted = false;
|
bool modelRenderStarted = false;
|
||||||
bool modelRenderFactionStarted = false;
|
bool modelRenderFactionStarted = false;
|
||||||
//modelRenderer->begin(false, false, false);
|
//modelRenderer->begin(false, false, false);
|
||||||
@@ -2729,6 +2731,10 @@ void Renderer::renderUnitsFast(){
|
|||||||
if(world->toRenderUnit(unit, visibleQuad)) {
|
if(world->toRenderUnit(unit, visibleQuad)) {
|
||||||
if(modelRenderStarted == false) {
|
if(modelRenderStarted == false) {
|
||||||
modelRenderStarted = true;
|
modelRenderStarted = true;
|
||||||
|
glPushAttrib(GL_ENABLE_BIT);
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
glDisable(GL_LIGHTING);
|
||||||
|
|
||||||
modelRenderer->begin(false, false, false);
|
modelRenderer->begin(false, false, false);
|
||||||
glInitNames();
|
glInitNames();
|
||||||
}
|
}
|
||||||
@@ -2786,23 +2792,6 @@ void Renderer::renderObjectsFast() {
|
|||||||
|
|
||||||
assertGl();
|
assertGl();
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
int thisTeamIndex= world->getThisTeamIndex();
|
int thisTeamIndex= world->getThisTeamIndex();
|
||||||
bool modelRenderStarted = false;
|
bool modelRenderStarted = false;
|
||||||
|
|
||||||
@@ -2826,6 +2815,23 @@ void Renderer::renderObjectsFast() {
|
|||||||
|
|
||||||
if(modelRenderStarted == false) {
|
if(modelRenderStarted == false) {
|
||||||
modelRenderStarted = true;
|
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);
|
modelRenderer->begin(false, true, false);
|
||||||
}
|
}
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
Reference in New Issue
Block a user