void SceneResult::Render() const { if ( PlayerManager::GetInstance()->GetWin() ) { RenderSprite( SPRITE_RESULT_WIN, m_Position ); } else { RenderSprite( SPRITE_RESULT_LOSE, m_Position ); } TextManager::GetInstance()->DrawTexts(); }
void CBLSprite::RenderSprite( TBLImageVector inXOff, TBLImageVector inYOff, CBLCanvas &inCanvas) { RenderSprite(inXOff,inYOff,&inCanvas.GetABCRec()); }
bool DirectGraphicsSprite::RenderSprite(float x, float y, int Anim, D3DCOLOR Color) { // Ausschnitt einstellen Anim %= 255; itsRect = itsPreCalcedRects [Anim]; // Und Sprite rendern RenderSprite(x, y, Color); return true; }
//================================================================================================// void SpriteEffect::Draw(const float interp) { if(!bGlow) UTIL_GL::SetBlend(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); else UTIL_GL::SetBlend(GL_ONE,GL_ONE); // glColor4f(1,1,1,1); Vec2 p; if(mpTarget == NULL) p = UTIL_Misc::Interpolate(mPos,oPos,interp); else p = UTIL_Misc::Interpolate(*mpTarget+mPos,oPos,interp); if(bAlignCenter) RenderSprite(pSpr,(int)frame,p.x-(mSize.x*0.5f),p.y-(mSize.y*0.5f),mSize.x,mSize.y); else RenderSprite(pSpr,(int)frame,p.x,p.y,mSize.x,mSize.y); }
//================================================================================================// void SuperTurret::Draw(const float interp) { UTIL_GL::SetBlend(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); if(iTakeDamageTicks>0) { glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD); glColor4f(1,1,0,1); } else glColor4f(1,1,1,1); if(bDirection) RenderSprite(gpEngine->sprSuperTurret,(int)frame,Pos.x,Pos.y,64,32); else RenderSprite(gpEngine->sprSuperTurret,(int)frame,Pos.x,Pos.y+32,64,-32); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); /* glDisable(GL_TEXTURE_2D); glColor4f(1,1,0,1); GeoDraw2D::DrawSphere(mSphere, 5);//*/ }
void GameEngine::RenderObject() { for (std::map<int, GameObjectPtr>::iterator iter = _objects.begin(); iter != _objects.end(); ++iter ) { if (iter->second->IsEnabled()) { iter->second->Render(); } } // for layer reason RenderSprite(); }
void SpriteBatch::Impl::RenderBatch(std::shared_ptr<Texture> texture, SpriteInfo const* const* sprites, size_t count) { // Activate batch texture pixelShader->SetTexture(0, texture); while (count > 0) { size_t batchSize = count; size_t remainingSpace = MaxBatchSize - m_vertexBufferOffset; if (batchSize > remainingSpace) { if (remainingSpace < MinBatchSize) { m_vertexBufferOffset = 0; batchSize = std::min(count, MaxBatchSize); } else { batchSize = remainingSpace; } } VertexPositionColorTexture* vertices = nullptr; vertexBuffer->Map(m_vertexBufferOffset == 0 ? BufferMapType::Discard : BufferMapType::NoOverwrite, (void**) &vertices); vertices += m_vertexBufferOffset * VerticesPerSprite; for (size_t i = 0; i < batchSize; ++i) { float2 textureSize((float)texture->GetWidth(), (float)texture->GetHeight()); float2 inverseTextureSize(1.0f / textureSize.x, 1.0f / textureSize.y); RenderSprite(sprites[i], vertices, textureSize, inverseTextureSize); vertices += VerticesPerSprite; } vertexBuffer->Unmap(); // Draw indexed sprites! u32 startIndex = m_vertexBufferOffset * IndicesPerSprite; u32 indexCount = batchSize * IndicesPerSprite; device->DrawIndexed(indexCount, startIndex, 0); // Advance buffer position m_vertexBufferOffset += batchSize; sprites += batchSize; count -= batchSize; } }
bool DirectGraphicsSprite::RenderSprite(float x, float y, int Anim, D3DCOLOR Color, bool mirrored) { // Ausschnitt einstellen Anim %= 255; itsRect = itsPreCalcedRects [Anim]; // Und Sprite rendern if (mirrored == false) RenderSprite(x, y, Color); else RenderMirroredSprite(x, y, Color); return true; }
/** * Prepares the sprite in the set of type aSpriteType to be displayed at * aSpritePos with size aSpriteSize. The sprite will be resized as necessary under the * restriction of aSpriteResizeMode. */ EXPORT_C void CSpriteSet::PrepareSpriteForDisplayL(TInt aSpriteType, const TPoint& aSpritePos, const TSize& aSpriteSize, TSpriteResizeMode aSpriteResizeMode) { __ASSERT_DEBUG((aSpriteType >= 0) && (aSpriteType < iSourceMembers.Count()),Panic(EEgulPanicInvalidSpriteIndex)); __ASSERT_DEBUG((aSpriteSize.iWidth >= 0) && (aSpriteSize.iHeight >= 0),Panic(EEgulPanicNegativeSpriteSize)); iSpritePosition = aSpritePos; iMainFbsBitGc->SetOrigin(TPoint(0,0)); TSize spriteSize(aSpriteSize); const TSize sourceSize(iSourceMembers[aSpriteType]->Bitmap()->SizeInPixels()); AdjustSpriteSizeAccordingToResizeMode(spriteSize, sourceSize, aSpriteResizeMode); User::LeaveIfError(iMainBmpDevice->Resize(spriteSize)); User::LeaveIfError(iMaskBmpDevice->Resize(spriteSize)); iMainFbsBitGc->Resized(); iMaskFbsBitGc->Resized(); iMaskFbsBitGc->SetBrushColor(KRgbBlack); iMaskFbsBitGc->Clear(); const TRect translatedClipRect(iClippingRect.iTl - aSpritePos, iClippingRect.Size()); if(!translatedClipRect.IsEmpty()) iMaskFbsBitGc->SetClippingRect(translatedClipRect); TInternalSpriteResizeMode resizeMode = EHSameVSame; ComputeInternalResizeMode(resizeMode,aSpriteResizeMode,sourceSize,spriteSize); RenderSprite(aSpriteType,resizeMode,sourceSize,spriteSize); iMaskFbsBitGc->CancelClippingRect(); iMainFbsBitGc->SetOrigin(-aSpritePos); }
//-- Render ------------------------------------------------------------------- // //----------------------------------------------------------------------------- void ShadeWorm_c::Render() { static State_e state = STATE_NEWCOL; static int fadeCol = 0; IDirect3DSurface8* oldSurface; IDirect3DSurface8* newSurface; m_device->GetRenderTarget(&oldSurface); oldSurface->Release(); m_bufferTexture->GetSurfaceLevel(0, &newSurface); m_device->SetRenderTarget(newSurface, NULL); newSurface->Release(); if (state == STATE_NEWCOL) { if (m_randomColMap) { int newCol = rand() % m_numColMaps; if (newCol == m_colMap) m_colMap = (m_colMap+1) % m_numColMaps; else m_colMap = newCol; } else { m_colMap = (m_colMap+1) % m_numColMaps; } CreateColMap(m_colMap); m_device->Clear( 0L, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER|D3DCLEAR_STENCIL, D3DCOLOR_XRGB(0,0,0), 1.0f, 0L ); float x = 256.0f + (100 - (rand() % 200)); float y = 256.0f + (100 - (rand() % 200)); for (int i = 0; i < m_numWorms; i++) { m_worms[i].vx = 0; m_worms[i].vy = 0; m_worms[i].x = x; m_worms[i].y = y; } state = STATE_FADEUP; m_timer = 60 * m_drawTime; } d3dSetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); d3dSetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); d3dSetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); d3dSetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); d3dSetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); d3dSetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ); d3dSetRenderState(D3DRS_ALPHABLENDENABLE, true); d3dSetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD); d3dSetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); d3dSetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE); d3dSetTextureStageState(0, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP); d3dSetTextureStageState(0, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP); d3dSetTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); d3dSetTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_LINEAR); if (state == STATE_FADEDOWN || state == STATE_DRAWING) { for (int i = 0; i < m_numWorms; i++) { m_worms[i].vx += GetRand(); Clamp(-1, 1, m_worms[i].vx); m_worms[i].vy += GetRand(); Clamp(-1, 1, m_worms[i].vy); m_worms[i].x += m_worms[i].vx; Clamp(0, 512, m_worms[i].x); m_worms[i].y += m_worms[i].vy; Clamp(0, 512, m_worms[i].y); } m_device->SetTexture(0, m_spriteTexture); for (int i = 0; i < m_numWorms; i++) RenderSprite(m_worms[i].x , m_worms[i].y, 5, 5, 0x05ffffff); } if (state == STATE_FADEUP) { fadeCol += 0x08; if (fadeCol >= 0xff) { fadeCol = 0xff; state = STATE_DRAWING; } } else if (state == STATE_FADEDOWN) { fadeCol -= 0x08; if (fadeCol <= 0) { fadeCol = 0; state = STATE_NEWCOL; } } else if (state == STATE_DRAWING) { m_timer--; if (m_timer <= 0) state = STATE_FADEDOWN; } d3dSetRenderState(D3DRS_ALPHABLENDENABLE, false); m_device->SetRenderTarget(oldSurface, NULL); m_device->SetTexture(0, m_bufferTexture); m_device->SetTexture(1, m_colMapTexture); d3dSetTextureStageState(1, D3DTSS_MAGFILTER, D3DTEXF_POINT); d3dSetTextureStageState(1, D3DTSS_MINFILTER, D3DTEXF_POINT); d3dSetTextureStageState(1, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP); d3dSetTextureStageState(1, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP); m_device->SetPixelShader(m_pShader); float size = fadeCol / 255.0f; RenderSprite(m_width/2.0f, m_height/2.0f, m_width/(2.0f * size), m_height/(2.0f * size), fadeCol << 24); m_device->SetPixelShader(0); m_device->SetTexture(0, NULL); m_device->SetTexture(1, NULL); } // Render
//================================================================================================// void BreakScenery::Draw(const float interp) { if(iTakeDamageTicks>0) { glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD); glColor4f(1,1,0,1); } else glColor4f(1,1,1,1); Vec2 p = UTIL_Misc::Interpolate(Pos,oPos,interp); UTIL_GL::SetBlend(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); if(frame!=3) { switch(iRotation) { case 0://noraml RenderSprite(spr,(int)frame,p.x,p.y,(float)spr.GetWindowScale().first,(float)spr.GetWindowScale().second); break; case 1://flipped horizontally RenderSprite(spr,(int)frame,p.x+(float)spr.GetWindowScale().first,p.y,-(float)spr.GetWindowScale().first,(float)spr.GetWindowScale().second); break; case 2://flipped vertically RenderSprite(spr,(int)frame,p.x,p.y+(float)spr.GetWindowScale().second,(float)spr.GetWindowScale().first,-(float)spr.GetWindowScale().second); break; case 3://flipped vertically & horizontally RenderSprite(spr,(int)frame,p.x+(float)spr.GetWindowScale().first,p.y+(float)spr.GetWindowScale().second,-(float)spr.GetWindowScale().first,-(float)spr.GetWindowScale().second); break; } } else { switch(iRotation) { case 0://noraml RenderRotatedSprite(gpEngine->sprThruster,(int)internalFrame,mSphere.p.x,mSphere.p.y,34,34,135); break; case 1://flipped horizontally RenderRotatedSprite(gpEngine->sprThruster,(int)internalFrame,mSphere.p.x,mSphere.p.y,34,34,45); break; case 2://flipped vertically RenderRotatedSprite(gpEngine->sprThruster,(int)internalFrame,mSphere.p.x,mSphere.p.y,34,34,-135); break; case 3://flipped vertically & horizontally RenderRotatedSprite(gpEngine->sprThruster,(int)internalFrame,mSphere.p.x,mSphere.p.y,34,34,-45); break; } } glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); /* if(frame!=3) { glDisable(GL_TEXTURE_2D); glColor4f(1,1,0,1); GeoDraw2D::DrawBox(Box((float)spr.GetWindowScale().first,(float)spr.GetWindowScale().second,Pos+Vec2((float)(spr.GetWindowScale().first*0.5f),(float)(spr.GetWindowScale().second*0.5f)))); GeoDraw2D::DrawSphere(mSphere, 15); }//*/ /* if(frame==3) { glDisable(GL_TEXTURE_2D); glColor4f(1,1,0,1); GeoDraw2D::DrawSphere(mSphere, 15); }//*/ }
void BaseApp::RenderFrame() { m_fpsCounter.MarkFrameStart(); POINT mousePos; GetCursorPos(&mousePos); m_mouseX = mousePos.x - m_winPosX; m_mouseY = mousePos.y - m_winPosY; if(lockMouse) { m_camera.SetViewByMouse( float(m_mouseLockedX - m_mouseX) * 0.2f , float(m_mouseLockedY - m_mouseY) * 0.2f); CenterMouse(); } float height = g_heightMap->GetInterpolatedHeight(m_camera.m_vEye.x, m_camera.m_vEye.z); //if( m_camera.m_vEye.y <= height + 2.0f ) { float oldY = m_camera.m_vEye.y; m_camera.m_vEye.y = height + 12.0f; float newY = m_camera.m_vEye.y; m_camera.m_vCenter.y += newY - oldY; } glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, g_frameBuffer); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, g_texFP16.GetID(), 0); glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, g_renderBuffer[0]); glClearColor(0.8f, 1.0f, 0.8f, 1.0f); glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); m_camera.BuildViewMatrix(&modelViewMat); glLoadMatrixf(modelViewMat); if(!m_freezeFrustum) frustum.ComputeFrustum(projMat, modelViewMat); glPushMatrix(); glTranslatef(m_camera.m_vEye.x, m_camera.m_vEye.y, m_camera.m_vEye.z); glDepthMask(GL_FALSE); m_shdSky->enable(); m_shdSky->sendUniform3f("color1", 2.0f, 2.0f, 2.0f); m_shdSky->sendUniform3f("color2", 0.5f, 0.7f, 2.0f); m_skydome.Render(); m_shdSky->disable(); //glDepthMask(GL_TRUE); glPopMatrix(); Vec3 sunPos = m_sunPos * 500.0f; glPopMatrix(); glPushMatrix(); glTranslatef(m_camera.m_vEye.x + sunPos.x, m_camera.m_vEye.y + sunPos.y, m_camera.m_vEye.z + sunPos.z); m_texSun.Activate(0); m_shdSimpleColor->enable(); m_shdSimpleColor->sendUniform3f("color", 4.0f, 4.0f, 2.0f); glEnable(GL_BLEND ); glBlendFunc(GL_SRC_COLOR, GL_ONE); RenderSprite(2000, &m_camera.m_vEye, modelViewMat); glDisable(GL_BLEND ); m_shdSimpleColor->disable(); m_texSun.Deactivate(); glDepthMask(GL_TRUE); glPopMatrix(); g_quadtree->Render(frustum, m_camera.m_vEye); /* glAlphaFunc(GL_GREATER,0.5f); glEnable(GL_ALPHA_TEST); Mat4 tmp; tmp.Identity(); tmp.Translate(Vec3(0.0f, g_heightMap->GetInterpolatedHeight(0.0f, 0.0f), 0.0f)); model.render(tmp, &frustum); tmp.Identity(); tmp.Translate(Vec3(50.0f, g_heightMap->GetInterpolatedHeight(50.0f, 0.0f), 0.0f)); model.render(tmp, &frustum); tmp.Identity(); tmp.Translate(Vec3(0.0f, g_heightMap->GetInterpolatedHeight(0.0f, 100.0f), 100.0f)); model.render(tmp, &frustum); tmp.Identity(); tmp.Translate(Vec3(-50.0f, g_heightMap->GetInterpolatedHeight(-50.0f, -200.0f), -200.0f)); model.render(tmp, &frustum); glDisable(GL_ALPHA_TEST); */ RenderWaterReflection(); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, g_texFP16.GetID(), 0); glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, g_renderBuffer[0]); g_texFP162.Bind(0); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0,0, 0, m_width, m_height); RenderWater(); RenderWaterSpecular(); RenderUnderwaterNormalMap(); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); // No wireframe glPushAttrib(GL_POLYGON_BIT); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); if(m_camera.m_vEye.y < 0) { m_shdUnderwater->enable(); m_shdUnderwater->sendUniform1i("g_texViewport", 0); m_shdUnderwater->sendUniform1i("g_texNormalMap", 1); LARGE_INTEGER time; QueryPerformanceCounter(&time); m_shdUnderwater->sendUniform1f("g_waterTranslation", float(time.QuadPart) * 0.000000008f); g_texWaterReflect.Bind(1); } g_texFP16.Activate(0); RenderScreenCoveringQuad(); g_texFP16.Deactivate(); /* g_texWaterReflect.Activate(0); RenderScreenCoveringQuad(); g_texWaterReflect.Deactivate(); */ if(m_camera.m_vEye.y < 0) { m_shdUnderwater->disable(); } BlurHDR(); glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE); g_texVBluredHDR.Activate(0); RenderScreenCoveringQuad(); g_texVBluredHDR.Deactivate(); glDisable(GL_BLEND); m_pGui->SetViewportDim(m_width, m_height); m_pGui->Render(m_mouseX, m_mouseY, this->m_mouseButton); m_pFont->Enable(m_width, m_height); m_pFont->SetAlignment(FONT_HORIZ_ALIGN_RIGHT, FONT_VERT_ALIGN_TOP); m_pFont->Print(m_width - 10, 10, "FPS: %d", (int)m_fpsCounter.GetFPS() ); m_pFont->Print(m_width - 10, 30, "Camera eye: %f, %f, %f", m_camera.m_vEye.x, m_camera.m_vEye.y, m_camera.m_vEye.z); m_pFont->Print(m_width - 10, 50, "Camera center: %f, %f, %f", m_camera.m_vCenter.x, m_camera.m_vCenter.y, m_camera.m_vCenter.z); m_pFont->Print(m_width - 10, 70, "Triangles rendered: %d", g_quadtree->GetNumTrisLastRendered()); m_pFont->Print(m_width - 10, 90, "VBOs data size: %d bytes", g_quadtree->m_vboDataSize); //m_pFont->Print(m_width - 10, 110, "Mouse coords: (%d, %d)", m_mouseX, m_mouseY); m_pFont->Disable(); /* RenderTexDebug(3, 3, 2, g_texVBluredHDR.GetID(), "Blured HDR"); RenderTexDebug(2, 3, 2, g_texHDR.GetID(), "HDR"); RenderTexDebug(1, 3, 2, g_texFP16.GetID(), "Water refraction"); RenderTexDebug(0, 3, 2, g_texWaterReflect.GetID(), "Water reflection"); */ glPopAttrib(); SwapBuffers(m_hDC); m_fpsCounter.MarkFrameEnd(); }
void CComponent_Items::OnRender() { if(Client()->State() < IClient::STATE_ONLINE) return; int Num = Client()->SnapNumItems(IClient::SNAP_CURRENT); for(int i = 0; i < Num; i++) { IClient::CSnapItem Item; const void *pData = Client()->SnapGetItem(IClient::SNAP_CURRENT, i, &Item); switch(Item.m_Type) { case NETOBJTYPE_TU_SPRITE: { const void *pPrev = Client()->SnapFindItem(IClient::SNAP_PREV, Item.m_Type, Item.m_ID); if(pPrev) RenderSprite((const CNetObj_TU_Sprite *)pPrev, (const CNetObj_TU_Sprite *)pData); } break; case NETOBJTYPE_TU_SPRITECHARACTER: { const void *pPrev = Client()->SnapFindItem(IClient::SNAP_PREV, Item.m_Type, Item.m_ID); if(pPrev) RenderSpriteCharacter((const CNetObj_TU_SpriteCharacter *)pPrev, (const CNetObj_TU_SpriteCharacter *)pData); } break; case NETOBJTYPE_TU_TEXT: { const void *pPrev = Client()->SnapFindItem(IClient::SNAP_PREV, Item.m_Type, Item.m_ID); if(pPrev) RenderText((const CNetObj_TU_Text *)pPrev, (const CNetObj_TU_Text *)pData); } break; case NETOBJTYPE_TU_TEXTCHARACTER: { const void *pPrev = Client()->SnapFindItem(IClient::SNAP_PREV, Item.m_Type, Item.m_ID); if(pPrev) RenderTextCharacter((const CNetObj_TU_TextCharacter *)pPrev, (const CNetObj_TU_TextCharacter *)pData); } break; } } int64 CurrentTime = time_get(); int64 DeltaTime = CurrentTime - m_LastTime; m_LastTime = CurrentTime; if(Client()->State() == IClient::STATE_DEMOPLAYBACK) { const IDemoPlayer::CInfo *pInfo = DemoPlayer()->BaseInfo(); if(!pInfo->m_Paused) UpdateEvents((float)((DeltaTime)/(double)time_freq())*pInfo->m_Speed); } else { if(m_pClient->m_Snap.m_pGameData && !(m_pClient->m_Snap.m_pGameData->m_GameStateFlags&GAMESTATEFLAG_PAUSED)) UpdateEvents((float)((DeltaTime)/(double)time_freq())); } }