void spot_light :: render(GemState *state) { if (!m_light)return; if (m_change) { m_change = 0; if ( !m_on ){ glDisable(m_light); return; } glEnable(m_light); // setGlobal parameter glLightfv(m_light, GL_DIFFUSE, m_color); glLightfv(m_light, GL_SPECULAR, m_color); glLightf(m_light, GL_LINEAR_ATTENUATION, linearAttenuation); } if (m_on) { // Set spot parameters glLightfv(m_light, GL_POSITION, m_position); glLightf(m_light, GL_SPOT_EXPONENT, spotExponent); glLightfv(m_light, GL_SPOT_DIRECTION, spotDirection); glLightf(m_light, GL_SPOT_CUTOFF, spotCutoff); renderDebug(); } }
void renderGameplay(App *app){ SDL_BlitSurface(app->game.board.image, NULL, app->screen, NULL); renderDebug(app); if(app->game.winner){ app->game.winner->grabbing = 0; } if(app->game.head.body.life <= 0){ app->game.allan.body.action = ACTION_DEATH; app->game.indy.body.action = ACTION_DEATH; renderGameOver(app); } if(app->game.winner){ renderWinner(app); } renderLifeBars(app); renderEnemies(app); renderPlayer(app, &app->game.indy); renderPlayer(app, &app->game.allan); renderHead(app); renderHints(app); checkPlayerLife(&app->game.indy, app); checkPlayerLife(&app->game.allan, app); }
void CScenePlay::renderScene() { // レイヤーの描画 mainLayer->Render(); minimapLayer->Render(); // バックバッファにレンダーターゲットを設定 CGraphicsManager::setRenderTargetToBackBuffer(); // レイヤーテクスチャーの貼られた板ポリの描画 mainLayer->board->Render(Camera2D.get()); minimapLayer->board->Render(Camera2D.get()); // UIの描画 renderUI(); #ifdef _DEBUG // デバッグ描画 renderDebug(); #endif renderFPS = renderFPSCount.getFrameRate_(); }
// ================================================ // render // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv void osgParticleHPS::ParticleTrail::render(const osg::Vec3 &xpos, const osg::Vec3 &px, const osg::Vec3 &py ) const { // set the color for the particle glColor4f( current_color_.x(), current_color_.y(), current_color_.z(), current_color_.w() ); //std::cout << "ParticleTrail::render - ratio " << (t0_ - timestampForLastNewPoint_) / timeBetweenPoints_ << std::endl; //std::cout << "ParticleTrail::render - xpos " << xpos << std::endl; //std::cout << "ParticleTrail::render - num points in trail: " << positions_.size() << std::endl; //std::cout << "roll is " << osg::RadiansToDegrees( angle_[0] ) << std::endl; if( !positions_.empty() ) { switch( trailType_ ) { case BUILT_IN_SHAPE: // cast away const-ness (sigh...) ((osgParticleHPS::ParticleTrail*)this)->renderBuiltInShape( px, py ); break; case LINE: renderLine(); break; case RIBBON: renderRibbon(); break; case CROSS_RIBBON: renderCrossRibbon(); break; case DEBUG: renderDebug( current_size_.x() ); break; default: break; } } }
void Screen_GP_Clung::draw() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); m_textureProgram.use(); // Upload texture uniform GLint textureUniform = m_textureProgram.getUniformLocation("mySampler"); glUniform1i(textureUniform, 0); glActiveTexture(GL_TEXTURE0); // Camera matrix glm::mat4 projectionMatrix = m_camera.getCameraMatrix(); GLint pUniform = m_textureProgram.getUniformLocation("P"); glUniformMatrix4fv(pUniform, 1, GL_FALSE, &projectionMatrix[0][0]); m_spriteBatch.begin(); for (Entity_Clung* e : m_entities) { if (m_camera.isBoxInView(e->getPosition() - (e->getDrawDims() / 2.0f), e->getDrawDims())) { e->draw(m_spriteBatch); } } for (Item_Clung* e : m_items) { if (m_camera.isBoxInView(e->getPosition() - (e->getDrawDims() / 2.0f), e->getDrawDims())) { e->draw(m_spriteBatch); } } m_spriteBatch.end(); m_spriteBatch.renderBatch(); m_textureProgram.unuse(); renderGUI(projectionMatrix); if (m_debug) renderDebug(projectionMatrix); }
void UINode::renderTop (int x, int y) const { const int childX = x + getRenderX(); const int childY = y + getRenderY(); if (_renderBorder) { const int w = getRenderWidth(false); const int h = getRenderHeight(false); renderRect(x + getRenderX(false), y + getRenderY(false), w, h, _borderColor); } int textYOffset = 0; for (DelayedTextsConstIter i = _texts.begin(); i != _texts.end(); ++i) { const UINodeDelayedText& t = *i; const int fontX = t.pos.x > 0.00001f ? (t.pos.x * _frontend->getWidth()) : (getRenderCenterX() - t.font->getTextWidth(t.text) / 2.0f); int fontY; if (t.pos.y > 0.00001f) { fontY = t.pos.y * _frontend->getHeight(); } else { const int textHeight = t.font->getTextHeight(t.text); fontY = textYOffset + getRenderCenterY() - textHeight / 2.0f; textYOffset += textHeight; } t.font->print(t.text, colorWhite, fontX, fontY); } const bool debug = Config.isDebugUI(); const bool focus = hasFocus(); if (debug && focus) renderDebug(x, y, y + 20); for (UINodeListConstIter i = _nodes.begin(); i != _nodes.end(); ++i) { const UINode* nodePtr = *i; if (!nodePtr->isVisible()) continue; nodePtr->render(childX, childY); } }
void world_light :: render(GemState *state) { if (!m_light) { return; } if (m_change) { m_change = 0; if ( !m_on ) { glDisable(m_light); return; } glEnable(m_light); glLightfv(m_light, GL_DIFFUSE, m_color); glLightfv(m_light, GL_SPECULAR, m_color); } if (m_on) { glLightfv(m_light, GL_POSITION, m_position); renderDebug(); } }
void SubdividerState::render() { glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /// Draw debug state. renderDebug(); if (shouldDrawLines) glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); else glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); phongProg->glBind(); /// Draw rest ov everything util::MatrixStack MV, P; camera.applyProjectionMatrix(&P); camera.applyViewMatrix(&MV); engine::PointLight light(util::Vec3f(-4, 4, -4), util::Vec3f(1, 1, 1)); phongProg->glSendUniform("uLightPos", MV.applyToPos(light.position)); phongProg->glSendUniform("uLightCol", light.color); engine::PhongMaterial mat; mat.send(*phongProg, "UaColor", "UdColor", "UsColor", "Ushine"); MV.push(); MV.translate(-objectSpacingFromOrigin); MV.scale(objectScales); phongProg->glSendUniform("MV", MV.top()); phongProg->glSendUniform("P", P.top()); baseModel.draw(*phongProg); MV.pop(); engine::SimpleModel * subdivModel = mesh.getModel(); if (subdivModel != NULL) { mat.diffuse = util::Vec3f(1, 0, 0); mat.send(*phongProg, "UaColor", "UdColor", "UsColor", "Ushine"); MV.push(); MV.translate(objectSpacingFromOrigin); MV.scale(objectScales); phongProg->glSendUniform("MV", MV.top()); phongProg->glSendUniform("P", P.top()); subdivModel->draw(*phongProg); MV.pop(); } if (drawHUD) { getFontEngine().renderText(std::string("Mesh: ") + meshFileName + "\n\nM: NextMesh", -0.95, 0.85); getFontEngine().renderText(std::string("C: Capture Cursor") + "\n\nL: Toggle Lines" + "\n\nH: Toggle HUD" + "\n\nL/R Arrows: spacing" + "\n\nU/D Arrows: scaling", -0.95, -0.50); getFontEngine().renderText(std::string("S: Subdivide mesh") + "\n\nN: Next Subdiv Type" + "\n\nR: Reset mesh" + "\n\nSubdiv Type: " + mesh.getTypeString() + "\n\nFPS: " + getFPS(), 0, -0.50); } for (int i = 0; i < (int) postRenderFuncs.size(); i++) postRenderFuncs[i](); postRenderFuncs.clear(); }
void RenderScene() { g_globalCam.Update(); // Clear Depth and color buffers // glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Enabled texturing and depth testing // glEnable(GL_TEXTURE_2D); // Enable Texturing glEnable(GL_DEPTH_TEST); // Enable Depth tests glDepthFunc(GL_LEQUAL); // LESSEQUAL depth test glEnable( GL_CULL_FACE ); glCullFace( GL_BACK ); glFrontFace( GL_CCW ); // Do a depth only pass // int rtColor = (g_bMSAA) ? g_msaaColor : DEFAULT_HANDLE; int rtDepth = (g_bMSAA) ? g_msaaDepth : DEFAULT_HANDLE; g_pTexInterface->BindRenderTarget(&rtColor, 1, rtDepth); glColorMask(0, 0, 0, 0); if(g_bMSAA) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); RenderGeometry( ); int def = DEFAULT_HANDLE; glColorMask(1, 1, 1, 1); // Render the gbuffer to non-msaa targets // RenderSceneGBuffer(); RenderLightBuffer(); rtColor = (g_bMSAA) ? g_msaaColor : DEFAULT_HANDLE; rtDepth = (g_bMSAA) ? g_msaaDepth : DEFAULT_HANDLE; g_pTexInterface->BindRenderTarget(&rtColor, 1, rtDepth); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); rtColor = (g_bMSAA) ? g_normalDepthColor : g_lightBuffer; vec2 viewDims = {(float)GetScreenWidth(), (float)GetScreenHeight()}; g_pShaderInterface->BindShader( g_compositeShader ); g_pShaderInterface->SetFloat( "g_viewDims", viewDims, 2 ); g_pShaderInterface->SetStateMatrix( "g_matWorldViewProj", MATRIX_MODELVIEW | MATRIX_PROJECTION ); g_pShaderInterface->SetTexture( "g_lightBuffer", rtColor ); g_pShaderInterface->SetTexture("g_diffuseTexture", g_groundTexture); int textured = 1; g_pShaderInterface->SetInt( "g_bIsTextured", &textured, 0 ); glDepthFunc(GL_LEQUAL); RenderGeometry(); g_pShaderInterface->UnbindShader(); if(g_bMSAA) { g_pTexInterface->BindTexture(g_lightBuffer); RenderTexturedFullscreenQuad(); // Rebind default backbuffer // g_pTexInterface->ResolveMSAATarget(g_resolveTexture); g_pTexInterface->BindRenderTarget(&def, 1, DEFAULT_HANDLE); glDisable(GL_DEPTH_TEST); g_pTexInterface->BindTexture(g_resolveTexture); // resolve tex RenderTexturedFullscreenQuad(); } g_pTexInterface->EvictTextures(); #ifdef RENDER_DEBUG glDepthFunc(GL_ALWAYS); renderDebug(); glDepthFunc(GL_LEQUAL); #endif glFlush(); }