本文整理汇总了C++中CBaseGroundDrawer类的典型用法代码示例。如果您正苦于以下问题:C++ CBaseGroundDrawer类的具体用法?C++ CBaseGroundDrawer怎么用?C++ CBaseGroundDrawer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CBaseGroundDrawer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EnableShader
void CGrassDrawer::EnableShader(const GrassShaderProgram type) {
CBaseGroundDrawer* gd = readMap->GetGroundDrawer();
const float3 windSpeed =
wind.GetCurrentDirection() *
wind.GetCurrentStrength() *
mapInfo->grass.bladeWaveScale;
grassShader = grassShaders[type];
grassShader->SetFlag("HAVE_INFOTEX", gd->DrawExtraTex());
grassShader->SetFlag("HAVE_SHADOWS", shadowHandler->shadowsLoaded);
grassShader->Enable();
grassShader->SetUniform("frame", gs->frameNum + globalRendering->timeOffset);
grassShader->SetUniform3v("windSpeed", &windSpeed.x);
grassShader->SetUniform3v("camPos", &camera->GetPos().x);
grassShader->SetUniform3v("camDir", &camera->forward.x);
grassShader->SetUniform3v("camUp", &camera->up.x);
grassShader->SetUniform3v("camRight", &camera->right.x);
grassShader->SetUniform("groundShadowDensity", mapInfo->light.groundShadowDensity);
grassShader->SetUniformMatrix4x4("shadowMatrix", false, &shadowHandler->shadowMatrix.m[0]);
grassShader->SetUniform4v("shadowParams", &shadowHandler->GetShadowParams().x);
grassShader->SetUniform3v("ambientLightColor", &mapInfo->light.unitAmbientColor.x);
grassShader->SetUniform3v("diffuseLightColor", &mapInfo->light.unitSunColor.x);
grassShader->SetUniform3v("specularLightColor", &mapInfo->light.unitSpecularColor.x);
grassShader->SetUniform3v("sunDir", &mapInfo->light.sunDir.x);
}
示例2: glEnable
void CFeatureDrawer::Draw()
{
if(globalRendering->drawFog) {
glEnable(GL_FOG);
glFogfv(GL_FOG_COLOR, mapInfo->atmosphere.fogColor);
}
GML_RECMUTEX_LOCK(feat); // Draw
CBaseGroundDrawer* gd = readmap->GetGroundDrawer();
if (gd->DrawExtraTex()) {
glActiveTextureARB(GL_TEXTURE2_ARB);
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_ADD_SIGNED_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
SetTexGen(1.0f / (gs->pwr2mapx * SQUARE_SIZE), 1.0f / (gs->pwr2mapy * SQUARE_SIZE), 0.0f, 0.0f);
glBindTexture(GL_TEXTURE_2D, gd->infoTex);
glActiveTextureARB(GL_TEXTURE0_ARB);
}
unitDrawer->SetupForUnitDrawing();
GetVisibleFeatures(0, true);
for (int modelType = MODELTYPE_3DO; modelType < MODELTYPE_OTHER; modelType++) {
opaqueModelRenderers[modelType]->PushRenderState();
DrawOpaqueFeatures(modelType);
opaqueModelRenderers[modelType]->PopRenderState();
}
unitDrawer->CleanUpUnitDrawing();
farTextureHandler->Draw();
if (gd->DrawExtraTex()) {
glActiveTextureARB(GL_TEXTURE2_ARB);
glDisable(GL_TEXTURE_2D);
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glActiveTextureARB(GL_TEXTURE0_ARB);
}
glDisable(GL_TEXTURE_2D);
glDisable(GL_FOG);
DrawFeatureStats();
}
示例3: glViewport
void CDynWater::DrawRefraction(CGame* game)
{
drawRefraction=true;
camera->Update(false);
refractRight=camera->right;
refractUp=camera->up;
refractForward=camera->forward;
refractFBO.Bind();
glViewport(0,0,refractSize,refractSize);
glClearColor(mapInfo->atmosphere.fogColor[0],mapInfo->atmosphere.fogColor[1],mapInfo->atmosphere.fogColor[2],1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
float3 oldsun=unitDrawer->unitSunColor;
float3 oldambient=unitDrawer->unitAmbientColor;
unitDrawer->unitSunColor*=float3(0.5f,0.7f,0.9f);
unitDrawer->unitAmbientColor*=float3(0.6f,0.8f,1.0f);
game->SetDrawMode(CGame::refractionDraw);
CBaseGroundDrawer *gd = readmap->GetGroundDrawer();
gd->Draw(false,false,dwGroundRefractVP);
glEnable(GL_CLIP_PLANE2);
double plane[4]={0,-1,0,2};
glClipPlane(GL_CLIP_PLANE2 ,plane);
drawReflection=true;
unitDrawer->Draw(false,true);
featureDrawer->Draw();
unitDrawer->DrawCloakedUnits(true,true);
featureDrawer->DrawFadeFeatures(true,true); // FIXME: Make it fade out correctly without "noAdvShading"
drawReflection=false;
ph->Draw(false,true);
eventHandler.DrawWorldRefraction();
glDisable(GL_CLIP_PLANE2);
game->SetDrawMode(CGame::normalDraw);
drawRefraction=false;
glViewport(gu->viewPosX,0,gu->viewSizeX,gu->viewSizeY);
glClearColor(mapInfo->atmosphere.fogColor[0],mapInfo->atmosphere.fogColor[1],mapInfo->atmosphere.fogColor[2],1);
unitDrawer->unitSunColor=oldsun;
unitDrawer->unitAmbientColor=oldambient;
}
示例4: GML_RECMUTEX_LOCK
void CFeatureDrawer::Draw()
{
ISky::SetupFog();
GML_RECMUTEX_LOCK(feat); // Draw
CBaseGroundDrawer* gd = readMap->GetGroundDrawer();
if (gd->DrawExtraTex()) {
glActiveTextureARB(GL_TEXTURE2_ARB);
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_ADD_SIGNED_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glMultiTexCoord4f(GL_TEXTURE2_ARB, 1.0f,1.0f,1.0f,1.0f); // workaround a nvidia bug with TexGen
SetTexGen(1.0f / (gs->pwr2mapx * SQUARE_SIZE), 1.0f / (gs->pwr2mapy * SQUARE_SIZE), 0.0f, 0.0f);
glBindTexture(GL_TEXTURE_2D, gd->GetActiveInfoTexture());
glActiveTextureARB(GL_TEXTURE0_ARB);
}
unitDrawer->SetupForUnitDrawing(false);
GetVisibleFeatures(0, true);
for (int modelType = MODELTYPE_3DO; modelType < MODELTYPE_OTHER; modelType++) {
opaqueModelRenderers[modelType]->PushRenderState();
DrawOpaqueFeatures(modelType);
opaqueModelRenderers[modelType]->PopRenderState();
}
unitDrawer->CleanUpUnitDrawing(false);
farTextureHandler->Draw();
if (gd->DrawExtraTex()) {
glActiveTextureARB(GL_TEXTURE2_ARB);
glDisable(GL_TEXTURE_2D);
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glActiveTextureARB(GL_TEXTURE0_ARB);
}
glDisable(GL_TEXTURE_2D);
glDisable(GL_FOG);
#ifdef USE_GML
DrawFeatureStats();
#endif
}
示例5: SCOPED_TIMER
void CWorldDrawer::Update()
{
readMap->UpdateDraw();
if (globalRendering->drawGround) {
SCOPED_TIMER("GroundDrawer::Update");
CBaseGroundDrawer* gd = readMap->GetGroundDrawer();
gd->Update();
}
//XXX: do in CGame, cause it needs to get updated even when doDrawWorld==false, cause it updates unitdrawpos which is used for maximized minimap too
//unitDrawer->Update();
//lineDrawer.UpdateLineStipple();
treeDrawer->Update();
featureDrawer->Update();
IWater::ApplyPushedChanges(game);
}
示例6: ResetGlStateNear
void CGrassDrawer::ResetGlStateNear()
{
CBaseGroundDrawer* gd = readMap->GetGroundDrawer();
if (shadowHandler->shadowsLoaded && globalRendering->haveGLSL) {
grassShader->Disable();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
/*glActiveTextureARB(GL_TEXTURE1_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE);
glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_LUMINANCE);
glActiveTextureARB(GL_TEXTURE0_ARB);*/
} else {
glActiveTextureARB(GL_TEXTURE1_ARB);
glDisable(GL_TEXTURE_2D);
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
glActiveTextureARB(GL_TEXTURE2_ARB);
glDisable(GL_TEXTURE_2D);
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 1);
if (gd->DrawExtraTex()) {
glActiveTextureARB(GL_TEXTURE3_ARB);
glDisable(GL_TEXTURE_2D);
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
}
glActiveTextureARB(GL_TEXTURE0_ARB);
}
glDisable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
}
示例7: assert
void CGrassDrawer::SetupGlStateFar()
{
assert(globalRendering->haveGLSL);
CBaseGroundDrawer* gd = readMap->GetGroundDrawer();
//glEnable(GL_ALPHA_TEST);
//glAlphaFunc(GL_GREATER, 0.01f);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDepthMask(GL_FALSE);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glMultMatrixf(camera->GetViewMatrix());
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
EnableShader(GRASS_PROGRAM_DIST);
glActiveTextureARB(GL_TEXTURE0_ARB);
glBindTexture(GL_TEXTURE_2D, farTex);
glActiveTextureARB(GL_TEXTURE1_ARB);
glBindTexture(GL_TEXTURE_2D, readMap->GetGrassShadingTexture());
glActiveTextureARB(GL_TEXTURE2_ARB);
glBindTexture(GL_TEXTURE_2D, readMap->GetShadingTexture());
if (gd->DrawExtraTex()) {
glActiveTextureARB(GL_TEXTURE3_ARB);
glBindTexture(GL_TEXTURE_2D, gd->GetActiveInfoTexture());
}
if (shadowHandler->shadowsLoaded) {
glActiveTextureARB(GL_TEXTURE4_ARB);
glBindTexture(GL_TEXTURE_2D, shadowHandler->shadowTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL);
glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_ALPHA);
}
glActiveTextureARB(GL_TEXTURE0_ARB);
}
示例8: SCOPED_TIMER
void CWorldDrawer::Draw()
{
SCOPED_TIMER("WorldDrawer::Total");
CBaseGroundDrawer* gd = readmap->GetGroundDrawer();
if (globalRendering->drawSky) {
sky->Draw();
}
if (globalRendering->drawGround) {
SCOPED_TIMER("WorldDrawer::Terrain");
gd->Draw(DrawPass::Normal);
smoothHeightMeshDrawer->Draw(1.0f);
treeDrawer->DrawGrass();
gd->DrawTrees();
}
if (globalRendering->drawWater && !mapInfo->map.voidWater) {
SCOPED_TIMER("WorldDrawer::Water");
water->OcclusionQuery();
if (water->IsDrawSolid()) {
water->UpdateWater(game);
water->Draw();
}
}
selectedUnits.Draw();
eventHandler.DrawWorldPreUnit();
{
SCOPED_TIMER("WorldDrawer::Models");
DebugColVolDrawer::Draw();
unitDrawer->Draw(false);
modelDrawer->Draw();
featureDrawer->Draw();
pathDrawer->DrawAll();
}
//! transparent stuff
glEnable(GL_BLEND);
glDepthFunc(GL_LEQUAL);
const bool noAdvShading = shadowHandler->shadowsLoaded;
static const double plane_below[4] = {0.0f, -1.0f, 0.0f, 0.0f};
static const double plane_above[4] = {0.0f, 1.0f, 0.0f, 0.0f};
{
glClipPlane(GL_CLIP_PLANE3, plane_below);
glEnable(GL_CLIP_PLANE3);
//! draw cloaked objects below water surface
unitDrawer->DrawCloakedUnits(noAdvShading);
featureDrawer->DrawFadeFeatures(noAdvShading);
glDisable(GL_CLIP_PLANE3);
}
//! draw water
if (globalRendering->drawWater && !mapInfo->map.voidWater) {
SCOPED_TIMER("WorldDrawer::Water");
if (!water->IsDrawSolid()) {
//! Water rendering will overwrite features, so save them
featureDrawer->SwapFeatures();
water->UpdateWater(game);
water->Draw();
featureDrawer->SwapFeatures();
}
}
{
glClipPlane(GL_CLIP_PLANE3, plane_above);
glEnable(GL_CLIP_PLANE3);
//! draw cloaked objects above water surface
unitDrawer->DrawCloakedUnits(noAdvShading);
featureDrawer->DrawFadeFeatures(noAdvShading);
glDisable(GL_CLIP_PLANE3);
}
{
SCOPED_TIMER("WorldDrawer::Projectiles");
projectileDrawer->Draw(false);
}
if (globalRendering->drawSky) {
sky->DrawSun();
}
eventHandler.DrawWorld();
LuaUnsyncedCtrl::DrawUnitCommandQueues();
if (cmdColors.AlwaysDrawQueue() || guihandler->GetQueueKeystate()) {
selectedUnits.DrawCommands();
}
//.........这里部分代码省略.........
示例9: Draw
void CAdvTreeDrawer::Draw(float treeDistance,bool drawReflection)
{
int activeFarTex=camera->forward.z<0 ? treeGen->farTex[0] : treeGen->farTex[1];
bool drawDetailed=true;
if(treeDistance<4)
drawDetailed=false;
if(drawReflection)
drawDetailed=false;
CBaseGroundDrawer *gd = readmap->GetGroundDrawer ();
glEnable(GL_ALPHA_TEST);
if(gu->drawFog) {
glFogfv(GL_FOG_COLOR, mapInfo->atmosphere.fogColor);
glEnable(GL_FOG);
}
if(shadowHandler->drawShadows && !gd->DrawExtraTex()){
glBindProgramARB( GL_VERTEX_PROGRAM_ARB, treeGen->treeFarVP );
glEnable(GL_VERTEX_PROGRAM_ARB);
glBindTexture(GL_TEXTURE_2D,shadowHandler->shadowTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL);
glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_ALPHA);
if(shadowHandler->useFPShadows){
glBindProgramARB( GL_FRAGMENT_PROGRAM_ARB, treeGen->treeFPShadow );
glEnable( GL_FRAGMENT_PROGRAM_ARB );
glProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB,10, mapInfo->light.groundAmbientColor.x,mapInfo->light.groundAmbientColor.y,mapInfo->light.groundAmbientColor.z,1);
glProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB,11, 0,0,0,1-mapInfo->light.groundShadowDensity*0.5f);
glActiveTextureARB(GL_TEXTURE1_ARB);
glBindTexture(GL_TEXTURE_2D, activeFarTex);
} else {
glEnable(GL_TEXTURE_2D);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FAIL_VALUE_ARB, 1-mapInfo->light.groundShadowDensity*0.5f);
float texConstant[]={mapInfo->light.groundAmbientColor.x,mapInfo->light.groundAmbientColor.y,mapInfo->light.groundAmbientColor.z,0.0f};
glTexEnvfv(GL_TEXTURE_ENV,GL_TEXTURE_ENV_COLOR,texConstant);
glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE0_RGB_ARB,GL_PREVIOUS_ARB);
glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE1_RGB_ARB,GL_CONSTANT);
glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE2_RGB_ARB,GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV,GL_OPERAND2_RGB_ARB,GL_SRC_ALPHA);
glTexEnvi(GL_TEXTURE_ENV,GL_COMBINE_RGB_ARB,GL_INTERPOLATE_ARB);
glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE0_ALPHA_ARB,GL_PREVIOUS_ARB);
glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE1_ALPHA_ARB,GL_CONSTANT);
glTexEnvi(GL_TEXTURE_ENV,GL_COMBINE_ALPHA_ARB,GL_ADD);
glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_COMBINE_ARB);
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, activeFarTex);
}
glActiveTextureARB(GL_TEXTURE0_ARB);
glMatrixMode(GL_MATRIX0_ARB);
glLoadMatrixf(shadowHandler->shadowMatrix.m);
glMatrixMode(GL_MODELVIEW);
} else {
glBindTexture(GL_TEXTURE_2D, activeFarTex);
}
glEnable(GL_TEXTURE_2D);
int cx=(int)(camera->pos.x/(SQUARE_SIZE*TREE_SQUARE_SIZE));
int cy=(int)(camera->pos.z/(SQUARE_SIZE*TREE_SQUARE_SIZE));
CAdvTreeSquareDrawer drawer;
drawer.td = this;
drawer.cx = cx;
drawer.cy = cy;
drawer.treeDistance = treeDistance * SQUARE_SIZE * TREE_SQUARE_SIZE;
drawer.drawDetailed = drawDetailed;
GML_STDMUTEX_LOCK(tree); // Draw
// draw far away trees using the map dependent grid visibility
oldTreeDistance=treeDistance;
readmap->GridVisibility (camera, TREE_SQUARE_SIZE, drawer.treeDistance * 2.0f, &drawer);
if(drawDetailed){
int xstart=std::max(0,cx-2);
int xend=std::min(gs->mapx/TREE_SQUARE_SIZE-1,cx+2);
int ystart=std::max(0,cy-2);
int yend=std::min(gs->mapy/TREE_SQUARE_SIZE-1,cy+2);
if(shadowHandler->drawShadows && !gd->DrawExtraTex()){
glBindProgramARB( GL_VERTEX_PROGRAM_ARB, treeGen->treeVP );
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, treeGen->barkTex);
glActiveTextureARB(GL_TEXTURE0_ARB);
} else {
glBindTexture(GL_TEXTURE_2D, treeGen->barkTex);
//.........这里部分代码省略.........
示例10: Draw
void CAdvTreeDrawer::Draw(float treeDistance, bool drawReflection)
{
const int activeFarTex = (camera->forward.z < 0.0f)? treeGen->farTex[0]: treeGen->farTex[1];
const bool drawDetailed = ((treeDistance >= 4.0f) || drawReflection);
CBaseGroundDrawer* gd = readmap->GetGroundDrawer();
Shader::IProgramObject* treeShader = NULL;
#define L mapInfo->light
glEnable(GL_ALPHA_TEST);
glEnable(GL_TEXTURE_2D);
if (globalRendering->drawFog) {
glFogfv(GL_FOG_COLOR, mapInfo->atmosphere.fogColor);
glEnable(GL_FOG);
}
if (shadowHandler->shadowsLoaded && !gd->DrawExtraTex()) {
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, activeFarTex);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, shadowHandler->shadowTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL);
glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_ALPHA);
treeShader = treeShaders[TREE_PROGRAM_DIST_SHADOW];
treeShader->Enable();
if (globalRendering->haveGLSL) {
treeShader->SetUniformMatrix4fv(7, false, &shadowHandler->shadowMatrix.m[0]);
treeShader->SetUniform4fv(8, &(shadowHandler->GetShadowParams().x));
} else {
treeShader->SetUniformTarget(GL_FRAGMENT_PROGRAM_ARB);
treeShader->SetUniform4f(10, L.groundAmbientColor.x, L.groundAmbientColor.y, L.groundAmbientColor.z, 1.0f);
treeShader->SetUniform4f(11, 0.0f, 0.0f, 0.0f, 1.0f - (sky->GetLight()->GetGroundShadowDensity() * 0.5f));
treeShader->SetUniformTarget(GL_VERTEX_PROGRAM_ARB);
glMatrixMode(GL_MATRIX0_ARB);
glLoadMatrixf(shadowHandler->shadowMatrix.m);
glMatrixMode(GL_MODELVIEW);
}
} else {
glBindTexture(GL_TEXTURE_2D, activeFarTex);
}
const int cx = int(camera->pos.x / (SQUARE_SIZE * TREE_SQUARE_SIZE));
const int cy = int(camera->pos.z / (SQUARE_SIZE * TREE_SQUARE_SIZE));
CAdvTreeSquareDrawer drawer(this, cx, cy, treeDistance * SQUARE_SIZE * TREE_SQUARE_SIZE, drawDetailed);
GML_STDMUTEX_LOCK(tree); // Draw
oldTreeDistance = treeDistance;
// draw far-trees using map-dependent grid-visibility
readmap->GridVisibility(camera, TREE_SQUARE_SIZE, drawer.treeDistance * 2.0f, &drawer);
if (drawDetailed) {
// draw near-trees
const int xstart = std::max( 0, cx - 2);
const int xend = std::min(gs->mapx / TREE_SQUARE_SIZE - 1, cx + 2);
const int ystart = std::max( 0, cy - 2);
const int yend = std::min(gs->mapy / TREE_SQUARE_SIZE - 1, cy + 2);
if (shadowHandler->shadowsLoaded && !gd->DrawExtraTex()) {
treeShader->Disable();
treeShader = treeShaders[TREE_PROGRAM_NEAR_SHADOW];
treeShader->Enable();
if (globalRendering->haveGLSL) {
treeShader->SetUniformMatrix4fv(7, false, &shadowHandler->shadowMatrix.m[0]);
treeShader->SetUniform4fv(8, &(shadowHandler->GetShadowParams().x));
}
glActiveTexture(GL_TEXTURE1);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, treeGen->barkTex);
glActiveTexture(GL_TEXTURE0);
} else {
glBindTexture(GL_TEXTURE_2D, treeGen->barkTex);
treeShader = treeShaders[TREE_PROGRAM_NEAR_BASIC];
treeShader->Enable();
if (!globalRendering->haveGLSL) {
#define MX (gs->pwr2mapx * SQUARE_SIZE)
#define MY (gs->pwr2mapy * SQUARE_SIZE)
treeShader->SetUniformTarget(GL_VERTEX_PROGRAM_ARB);
treeShader->SetUniform4f(15, 1.0f / MX, 1.0f / MY, 1.0f / MX, 1.0f);
#undef MX
#undef MY
}
}
//.........这里部分代码省略.........
示例11: new
void CDynWater::DrawReflection(CGame* game)
{
// CCamera *realCam = camera;
// camera = new CCamera(*realCam);
char realCam[sizeof(CCamera)];
new (realCam) CCamera(*camera); // anti-crash workaround for multithreading
camera->forward.y *= -1.0f;
camera->pos.y *= -1.0f;
camera->pos.y += 0.2f;
camera->Update(false);
reflectRight=camera->right;
reflectUp=camera->up;
reflectForward=camera->forward;
reflectFBO.Bind();
glViewport(0,0,512,512);
glClearColor(0.5f,0.6f,0.8f,0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
game->SetDrawMode(CGame::reflectionDraw);
sky->Draw();
glEnable(GL_CLIP_PLANE2);
double plane2[4]={0,-1,0,1.0f};
glClipPlane(GL_CLIP_PLANE2 ,plane2);
drawReflection=true;
bool drawShadows=shadowHandler->drawShadows;
shadowHandler->drawShadows=false;
CBaseGroundDrawer *gd = readmap->GetGroundDrawer ();
gd->Draw(true,false,dwGroundReflectIVP);
double plane[4]={0,1,0,1.0f};
glClipPlane(GL_CLIP_PLANE2 ,plane);
gd->Draw(true);
shadowHandler->drawShadows=drawShadows;
unitDrawer->Draw(true);
featureDrawer->Draw();
unitDrawer->DrawCloakedUnits(false,true);
featureDrawer->DrawFadeFeatures(false,true);
ph->Draw(true);
eventHandler.DrawWorldReflection();
sky->DrawSun();
game->SetDrawMode(CGame::normalDraw);
drawReflection=false;
glDisable(GL_CLIP_PLANE2);
glViewport(gu->viewPosX,0,gu->viewSizeX,gu->viewSizeY);
glClearColor(mapInfo->atmosphere.fogColor[0],mapInfo->atmosphere.fogColor[1],mapInfo->atmosphere.fogColor[2],1);
// delete camera;
// camera = realCam;
camera->~CCamera();
new (camera) CCamera(*(CCamera *)realCam);
camera->Update(false);
}
示例12: SetupGlStateNear
void CGrassDrawer::SetupGlStateNear()
{
CBaseGroundDrawer* gd = readMap->GetGroundDrawer();
// bind textures
{
glActiveTextureARB(GL_TEXTURE0_ARB);
glBindTexture(GL_TEXTURE_2D, grassBladeTex);
glActiveTextureARB(GL_TEXTURE1_ARB);
glBindTexture(GL_TEXTURE_2D, readMap->GetGrassShadingTexture());
glActiveTextureARB(GL_TEXTURE2_ARB);
glBindTexture(GL_TEXTURE_2D, readMap->GetShadingTexture());
if (gd->DrawExtraTex()) {
glActiveTextureARB(GL_TEXTURE3_ARB);
glBindTexture(GL_TEXTURE_2D, gd->GetActiveInfoTexture());
}
glActiveTextureARB(GL_TEXTURE5_ARB);
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, cubeMapHandler->GetSpecularTextureID());
}
// bind shader
if (globalRendering->haveGLSL) {
EnableShader(GRASS_PROGRAM_NEAR);
if (shadowHandler->shadowsLoaded) {
glActiveTextureARB(GL_TEXTURE4_ARB);
glBindTexture(GL_TEXTURE_2D, shadowHandler->shadowTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL);
glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_ALPHA);
}
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glMultMatrixf(camera->GetViewMatrix());
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
} else {
// FPP enable textures
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glMultiTexCoord4f(GL_TEXTURE1_ARB, 1.0f,1.0f,1.0f,1.0f); // workaround a nvidia bug with TexGen
SetTexGen(1.0f / (gs->mapx * SQUARE_SIZE), 1.0f / (gs->mapy * SQUARE_SIZE), 0.0f, 0.0f);
glActiveTextureARB(GL_TEXTURE2_ARB);
glEnable(GL_TEXTURE_2D);
glMultiTexCoord4f(GL_TEXTURE2_ARB, 1.0f,1.0f,1.0f,1.0f); // workaround a nvidia bug with TexGen
SetTexGen(1.0f / (gs->pwr2mapx * SQUARE_SIZE), 1.0f / (gs->pwr2mapy * SQUARE_SIZE), 0.0f, 0.0f);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2);
if (gd->DrawExtraTex()) {
glActiveTextureARB(GL_TEXTURE3_ARB);
glEnable(GL_TEXTURE_2D);
glMultiTexCoord4f(GL_TEXTURE3_ARB, 1.0f,1.0f,1.0f,1.0f); // workaround a nvidia bug with TexGen
SetTexGen(1.0f / (gs->pwr2mapx * SQUARE_SIZE), 1.0f / (gs->pwr2mapy * SQUARE_SIZE), 0.0f, 0.0f);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_ADD_SIGNED_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PREVIOUS_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_ARB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
}
}
glActiveTextureARB(GL_TEXTURE0_ARB);
glDisable(GL_BLEND);
glDisable(GL_ALPHA_TEST);
glDepthMask(GL_TRUE);
ISky::SetupFog();
}
示例13: glEnable
void CFeatureDrawer::Draw()
{
drawFar.clear();
if(gu->drawFog) {
glEnable(GL_FOG);
glFogfv(GL_FOG_COLOR, mapInfo->atmosphere.fogColor);
}
GML_RECMUTEX_LOCK(feat); // Draw
fadeFeatures.clear();
fadeFeaturesS3O.clear();
CBaseGroundDrawer *gd = readmap->GetGroundDrawer();
if (gd->DrawExtraTex()) {
glActiveTextureARB(GL_TEXTURE2_ARB);
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV,GL_COMBINE_RGB_ARB,GL_ADD_SIGNED_ARB);
glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_COMBINE_ARB);
SetTexGen(1.0f/(gs->pwr2mapx*SQUARE_SIZE),1.0f/(gs->pwr2mapy*SQUARE_SIZE),0,0);
glBindTexture(GL_TEXTURE_2D, gd->infoTex);
glActiveTextureARB(GL_TEXTURE0_ARB);
}
unitDrawer->SetupForUnitDrawing();
unitDrawer->SetupFor3DO();
DrawRaw(0, &drawFar);
unitDrawer->CleanUp3DO();
unitDrawer->DrawQuedS3O();
unitDrawer->CleanUpUnitDrawing();
if (drawFar.size()>0) {
glAlphaFunc(GL_GREATER, 0.5f);
glEnable(GL_ALPHA_TEST);
glBindTexture(GL_TEXTURE_2D, fartextureHandler->GetTextureID());
glColor3f(1.0f, 1.0f, 1.0f);
glNormal3fv((const GLfloat*) &unitDrawer->camNorm.x);
CVertexArray* va = GetVertexArray();
va->Initialize();
va->EnlargeArrays(drawFar.size() * 4, 0, VA_SIZE_T);
for (vector<CFeature*>::iterator it = drawFar.begin(); it != drawFar.end(); ++it) {
fartextureHandler->DrawFarTexture(camera, (*it)->model, (*it)->pos, (*it)->radius, (*it)->heading, va);
}
va->DrawArrayT(GL_QUADS);
glDisable(GL_ALPHA_TEST);
}
if (gd->DrawExtraTex()) {
glActiveTextureARB(GL_TEXTURE2_ARB);
glDisable(GL_TEXTURE_2D);
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);
glActiveTextureARB(GL_TEXTURE0_ARB);
}
glDisable(GL_TEXTURE_2D);
glDisable(GL_FOG);
if(drawStat.size() > 0) {
if(!water->drawReflection) {
for (vector<CFeature *>::iterator fi = drawStat.begin(); fi != drawStat.end(); ++fi)
DrawFeatureStats(*fi);
}
drawStat.clear();
}
}
示例14: assert
void CGrassDrawer::SetupGlStateFar()
{
assert(globalRendering->haveGLSL);
CBaseGroundDrawer* gd = readMap->GetGroundDrawer();
const float3 windSpeed =
wind.GetCurrentDirection() *
wind.GetCurrentStrength() *
mapInfo->grass.bladeWaveScale;
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.01f);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDepthMask(GL_FALSE);
if (shadowHandler->shadowsLoaded) {
grassShader = grassShaders[GRASS_PROGRAM_DIST_SHADOW];
grassShader->SetFlag("HAVE_INFOTEX", gd->DrawExtraTex());
grassShader->Enable();
grassShader->SetUniformMatrix4fv(6, false, &shadowHandler->shadowMatrix.m[0]);
grassShader->SetUniform4fv(7, shadowHandler->GetShadowParams());
grassShader->SetUniform1f(8, gs->frameNum);
grassShader->SetUniform3fv(9, &windSpeed.x);
grassShader->SetUniform3fv(10, &camera->GetPos().x);
glActiveTextureARB(GL_TEXTURE0_ARB);
glBindTexture(GL_TEXTURE_2D, readMap->GetShadingTexture());
glActiveTextureARB(GL_TEXTURE1_ARB);
glBindTexture(GL_TEXTURE_2D, shadowHandler->shadowTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL);
glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_ALPHA);
static const float texConstant[] = {
mapInfo->light.groundAmbientColor.x * 1.24f,
mapInfo->light.groundAmbientColor.y * 1.24f,
mapInfo->light.groundAmbientColor.z * 1.24f,
1.0f
};
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, texConstant);
glActiveTextureARB(GL_TEXTURE2_ARB);
glBindTexture(GL_TEXTURE_2D, readMap->GetGrassShadingTexture());
glActiveTextureARB(GL_TEXTURE3_ARB);
glBindTexture(GL_TEXTURE_2D, farTex);
if (gd->DrawExtraTex()) {
glActiveTextureARB(GL_TEXTURE4_ARB);
glBindTexture(GL_TEXTURE_2D, gd->GetActiveInfoTexture());
}
glActiveTextureARB(GL_TEXTURE0_ARB);
} else {
grassShader = grassShaders[GRASS_PROGRAM_DIST_BASIC];
grassShader->Enable();
grassShader->SetUniform1f(8, gs->frameNum);
grassShader->SetUniform3fv(9, &windSpeed.x);
grassShader->SetUniform3fv(10, &camera->GetPos().x);
glActiveTextureARB(GL_TEXTURE0_ARB);
glBindTexture(GL_TEXTURE_2D, readMap->GetShadingTexture());
//glActiveTextureARB(GL_TEXTURE1_ARB);
glActiveTextureARB(GL_TEXTURE2_ARB);
glBindTexture(GL_TEXTURE_2D, readMap->GetGrassShadingTexture());
glActiveTextureARB(GL_TEXTURE3_ARB);
glBindTexture(GL_TEXTURE_2D, farTex);
if (gd->DrawExtraTex()) {
glActiveTextureARB(GL_TEXTURE4_ARB);
glBindTexture(GL_TEXTURE_2D, gd->GetActiveInfoTexture());
}
glActiveTextureARB(GL_TEXTURE0_ARB);
}
}
示例15: SetupGlStateNear
void CGrassDrawer::SetupGlStateNear()
{
CBaseGroundDrawer* gd = readMap->GetGroundDrawer();
const float3 windSpeed =
wind.GetCurrentDirection() *
wind.GetCurrentStrength() *
mapInfo->grass.bladeWaveScale;
if (shadowHandler->shadowsLoaded && globalRendering->haveGLSL) {
grassShader = grassShaders[GRASS_PROGRAM_NEAR_SHADOW];
grassShader->SetFlag("HAVE_INFOTEX", gd->DrawExtraTex());
grassShader->Enable();
grassShader->SetUniform2f(2, 0.0f, 0.0f);
grassShader->SetUniformMatrix4fv(6, false, shadowHandler->shadowMatrix);
grassShader->SetUniform4fv(7, shadowHandler->GetShadowParams());
grassShader->SetUniform1f(8, gs->frameNum);
grassShader->SetUniform3fv(9, &windSpeed.x);
grassShader->SetUniform3fv(10, &camera->GetPos().x);
glActiveTextureARB(GL_TEXTURE0_ARB);
glBindTexture(GL_TEXTURE_2D, readMap->GetShadingTexture());
glActiveTextureARB(GL_TEXTURE1_ARB);
glBindTexture(GL_TEXTURE_2D, shadowHandler->shadowTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL);
glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_ALPHA);
static const float texConstant[] = {
mapInfo->light.groundAmbientColor.x * 1.24f,
mapInfo->light.groundAmbientColor.y * 1.24f,
mapInfo->light.groundAmbientColor.z * 1.24f,
1.0f
};
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, texConstant);
glActiveTextureARB(GL_TEXTURE2_ARB);
glBindTexture(GL_TEXTURE_2D, readMap->GetGrassShadingTexture());
glActiveTextureARB(GL_TEXTURE3_ARB);
glBindTexture(GL_TEXTURE_2D, grassBladeTex);
if (gd->DrawExtraTex()) {
glActiveTextureARB(GL_TEXTURE4_ARB);
glBindTexture(GL_TEXTURE_2D, gd->GetActiveInfoTexture());
}
glActiveTextureARB(GL_TEXTURE0_ARB);
if (!globalRendering->haveGLSL) {
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glActiveTextureARB(GL_TEXTURE2_ARB);
glEnable(GL_TEXTURE_2D);
glActiveTextureARB(GL_TEXTURE3_ARB);
glEnable(GL_TEXTURE_2D);
if (gd->DrawExtraTex()) {
glActiveTextureARB(GL_TEXTURE4_ARB);
glEnable(GL_TEXTURE_2D);
}
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
}
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glMultMatrixf(camera->GetViewMatrix());
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
} else {
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, grassBladeTex);
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, readMap->GetGrassShadingTexture());
glMultiTexCoord4f(GL_TEXTURE1_ARB, 1.0f,1.0f,1.0f,1.0f); // workaround a nvidia bug with TexGen
SetTexGen(1.0f / (gs->mapx * SQUARE_SIZE), 1.0f / (gs->mapy * SQUARE_SIZE), 0.0f, 0.0f);
glActiveTextureARB(GL_TEXTURE2_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, readMap->GetShadingTexture());
glMultiTexCoord4f(GL_TEXTURE2_ARB, 1.0f,1.0f,1.0f,1.0f); // workaround a nvidia bug with TexGen
SetTexGen(1.0f / (gs->pwr2mapx * SQUARE_SIZE), 1.0f / (gs->pwr2mapy * SQUARE_SIZE), 0.0f, 0.0f);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2);
if (gd->DrawExtraTex()) {
glActiveTextureARB(GL_TEXTURE3_ARB);
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_ADD_SIGNED_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_MODULATE);
//.........这里部分代码省略.........