コード例 #1
0
ファイル: SMFGroundDrawer.cpp プロジェクト: Arkazon/spring
CSMFGroundDrawer::CSMFGroundDrawer(CSMFReadMap* rm)
	: smfMap(rm)
	, meshDrawer(NULL)
{
	groundTextures = new CSMFGroundTextures(smfMap);
	meshDrawer = SwitchMeshDrawer((!!configHandler->GetInt("ROAM")) ? SMF_MESHDRAWER_ROAM : SMF_MESHDRAWER_LEGACY);

	smfRenderStateSSP = ISMFRenderState::GetInstance(globalRendering->haveARB, globalRendering->haveGLSL);
	smfRenderStateFFP = ISMFRenderState::GetInstance(                   false,                     false);

	// set in ::Draw, but UpdateSunDir can be called first if DynamicSun is enabled
	smfRenderState = smfRenderStateFFP;

	// LH must be initialized before LoadMapShaders is called
	lightHandler.Init(2U, configHandler->GetInt("MaxDynamicMapLights"));

	groundDetail = configHandler->GetInt("GroundDetail");
	advShading = LoadMapShaders();

	waterPlaneCamInDispList  = 0;
	waterPlaneCamOutDispList = 0;

	if (mapInfo->water.hasWaterPlane) {
		waterPlaneCamInDispList = glGenLists(1);
		glNewList(waterPlaneCamInDispList, GL_COMPILE);
		CreateWaterPlanes(false);
		glEndList();

		waterPlaneCamOutDispList = glGenLists(1);
		glNewList(waterPlaneCamOutDispList, GL_COMPILE);
		CreateWaterPlanes(true);
		glEndList();
	}
}
コード例 #2
0
ファイル: SMFGroundDrawer.cpp プロジェクト: sprunk/spring
CSMFGroundDrawer::CSMFGroundDrawer(CSMFReadMap* rm)
	: smfMap(rm)
	, meshDrawer(nullptr)
{
	drawerMode = (configHandler->GetInt("ROAM") != 0)? SMF_MESHDRAWER_ROAM: SMF_MESHDRAWER_BASIC;
	groundDetail = configHandler->GetInt("GroundDetail");

	groundTextures = new CSMFGroundTextures(smfMap);
	meshDrawer = SwitchMeshDrawer(drawerMode);

	smfRenderStates.resize(RENDER_STATE_CNT, nullptr);
	smfRenderStates[RENDER_STATE_NOP] = ISMFRenderState::GetInstance( true, false);
	smfRenderStates[RENDER_STATE_SSP] = ISMFRenderState::GetInstance(false, false);
	smfRenderStates[RENDER_STATE_LUA] = ISMFRenderState::GetInstance(false,  true);

	// LH must be initialized before render-state is initialized
	lightHandler.Init(configHandler->GetInt("MaxDynamicMapLights"));
	geomBuffer.SetName("GROUNDDRAWER-GBUFFER");

	drawForward = true;
	drawDeferred = geomBuffer.Valid();
	drawMapEdges = configHandler->GetBool("MapBorder");
	drawWaterPlane = false && waterRendering->hasWaterPlane;

	smfRenderStates[RENDER_STATE_SSP]->Init(this);
	smfRenderStates[RENDER_STATE_SSP]->Update(this, nullptr);

	// always initialize this state; defer Update (allows re-use)
	smfRenderStates[RENDER_STATE_LUA]->Init(this);

	// note: state must be pre-selected before the first drawn frame
	// Sun*Changed can be called first, e.g. if DynamicSun is enabled
	smfRenderStates[RENDER_STATE_SEL] = SelectRenderState(DrawPass::Normal);



	if (drawWaterPlane) {
		CreateWaterPlanes( true);
		CreateWaterPlanes(false);
	}
	if (drawMapEdges)
		CreateBorderShader();

	if (drawDeferred) {
		drawDeferred &= UpdateGeometryBuffer(true);
	}
}