void renderLightsToStencil() { if (currentLevel > 1) { GPU_SetDepthTestAndWriteMask(true, GPU_NEVER, 0); GPU_SetStencilTest(true, GPU_NEVER, 1, 0xFF, 0xFF); GPU_SetStencilOp(GPU_STENCIL_REPLACE, GPU_STENCIL_KEEP, GPU_STENCIL_KEEP); GPU_SetAlphaTest(true, GPU_GREATER, 0); if(player.p.activeItem->id == ITEM_LANTERN) renderLight(player.x, player.y, lanternLightBake); else renderLight(player.x, player.y, playerLightBake); int i; for (i = 0; i < eManager.lastSlot[currentLevel]; ++i) { Entity e = eManager.entities[currentLevel][i]; if (e.type != ENTITY_FURNITURE)continue; if (e.entityFurniture.itemID == ITEM_LANTERN && e.x > player.x - 160 && e.y > player.y - 125 && e.x < player.x + 160 && e.y < player.y + 125) renderLight(e.x, e.y, lanternLightBake); } int xo = offsetX >> 4; int yo = offsetY >> 4; int x, y; if(currentLevel == 4){ for (x = xo-2; x <= 13 + xo+2; ++x) { for (y = yo-2; y <= 8 + yo+2; ++y) if(getTile(x, y) == TILE_LAVA) renderLight(x << 4, y << 4, playerLightBake); } } GPU_SetDepthTestAndWriteMask(true, GPU_GEQUAL, GPU_WRITE_ALL); GPU_SetStencilTest(true, GPU_EQUAL, 1, 0xFF, 0x0); GPU_SetAlphaTest(false, GPU_ALWAYS, 0x00); GPU_SetStencilOp(GPU_STENCIL_KEEP, GPU_STENCIL_KEEP, GPU_STENCIL_REPLACE); }
void Simulation::display() { glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); unsigned int i = 0; double timeSinceStart = glutGet(GLUT_ELAPSED_TIME); //cout<<"start"<<timeSinceStart; if (oldTimeSinceStart == 0.0) { oldTimeSinceStart = timeSinceStart; } double deltaTime = timeSinceStart - oldTimeSinceStart; oldTimeSinceStart = timeSinceStart; // update all if (!controlflag){ env->update(deltaTime/1000.0); } //render all Robots for (i = 0; i < robots.size(); i++){ renderRobot(robots[i], count); } //render all Lights for (i = 0; i < lights.size(); i++){ renderLight(lights[i], count); } // debugging messages int err; if ((err = glGetError()) != GL_NO_ERROR) { cerr << "GL is in an error state" << endl; cerr << "(GL error code " << err << ")\n"; assert(0); } // advance glutSwapBuffers(); count++; }
void DeferredSpotLightsPass::render(IViewer* viewer, World& world, const SceneContext& sceneContext, unsigned int lightMapFrameBuffer, const DeferredInitRenderStage& initStage) { GraphicsInterface::beginPerformanceEvent("Spot"); { // Shadow Map std::vector<SpotLight*> spotLights = sceneContext.spotLights(); for (std::vector<SpotLight*>::iterator light = spotLights.begin(); light != spotLights.end(); ++light) { if ((*light)->castsShadows()) { SpotLight* spotLight = (*light); renderShadowMap(spotLight, world); } } } { // Lighting std::vector<SpotLight*> spotLights = sceneContext.spotLights(); for (std::vector<SpotLight*>::iterator light = spotLights.begin(); light != spotLights.end(); ++light) { GraphicsInterface::beginPerformanceEvent("Light"); SpotLight* spotLight = (*light); { // render lighting IEffect* lightEffect = (*light)->castsShadows() ? lightEffectShadow_ : lightEffectNoShadow_; renderLight(spotLight, lightEffect, viewer, initStage.normalViewSpaceMap()); } { // accumulate into lightmap accumulateLight(spotLight, initStage.colorMap(), lightMapFrameBuffer); } GraphicsInterface::endPerformanceEvent(); } } GraphicsInterface::endPerformanceEvent(); }
void CascadedShadowMappingRenderer::render(float deltaTime) { renderLight(); renderCamera(); }
void LightSystem::render() { glUniform3f(AmbientID, ambientColor.x, ambientColor.y, ambientColor.z); if (!lightList.empty()) renderLight(); }
/*********************************************************************** * Map * light ***********************************************************************/ void Map::light() { buildLight(); renderLight(); }