Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
// Surface anlegen tbDirect3D::GetDevice()->CreateOffscreenPlainSurface( tbDirect3D::GetScreenSize().x, tbDirect3D::GetScreenSize().y, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &m_pBackgroundS, 0); // Surface anlegen tbDirect3D::GetDevice()->CreateOffscreenPlainSurface( tbDirect3D::GetScreenSize().x, tbDirect3D::GetScreenSize().y, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &m_pTemp, 0); |
Quellcode |
|
1 2 3 4 5 |
// Bildpuffer abfragen und in Datei speichern tbDirect3D::GetDevice()->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &m_pTemp); // Bildpuffer auf die Textur schreiben m_pBackgroundT->GetSurfaceLevel(0, &m_pBackgroundS); tbDirect3D::GetDevice()->UpdateSurface(m_pTemp, NULL, m_pBackgroundS, NULL); |
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
// Surface anlegen tbDirect3D::GetDevice()->CreateOffscreenPlainSurface( tbDirect3D::GetScreenSize().x, tbDirect3D::GetScreenSize().y, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &m_pBackgroundS, 0); // Surface anlegen tbDirect3D::GetDevice()->CreateOffscreenPlainSurface( tbDirect3D::GetScreenSize().x, tbDirect3D::GetScreenSize().y, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &m_pTemp, 0); int iWidth, iHeight; // Unterstützt das Gerät Texturen, deren Breite und Höhe keine 2er-Potenzen sind? if(tbDirect3D::GetCaps().TextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL) { // Ja! iWidth = tbDirect3D::GetScreenSize().x; iHeight = tbDirect3D::GetScreenSize().y; } else { // Breite und Höhe müssen 2er-Potenzen sein. Wir suchen jeweils die nächste. if(tbDirect3D::GetScreenSize().y > 4096) iWidth = 4096; if(tbDirect3D::GetScreenSize().y < 4096) iWidth = 4096; if(tbDirect3D::GetScreenSize().y < 2048) iWidth = 2048; if(tbDirect3D::GetScreenSize().y < 1024) iWidth = 1024; if(tbDirect3D::GetScreenSize().y < 512) iWidth = 512; if(tbDirect3D::GetScreenSize().y < 256) iWidth = 256; if(tbDirect3D::GetScreenSize().y < 128) iWidth = 128; if(tbDirect3D::GetScreenSize().y < 64) iWidth = 64; if(tbDirect3D::GetScreenSize().y < 32) iWidth = 32; if(tbDirect3D::GetScreenSize().y < 16) iWidth = 16; if(tbDirect3D::GetScreenSize().y < 8) iWidth = 8; if(tbDirect3D::GetScreenSize().y < 4) iWidth = 4; if(tbDirect3D::GetScreenSize().x > 4096) iHeight = 4096; if(tbDirect3D::GetScreenSize().x < 4096) iHeight = 4096; if(tbDirect3D::GetScreenSize().x < 2048) iHeight = 2048; if(tbDirect3D::GetScreenSize().x < 1024) iHeight = 1024; if(tbDirect3D::GetScreenSize().x < 512) iHeight = 512; if(tbDirect3D::GetScreenSize().x < 256) iHeight = 256; if(tbDirect3D::GetScreenSize().x < 128) iHeight = 128; if(tbDirect3D::GetScreenSize().x < 64) iHeight = 64; if(tbDirect3D::GetScreenSize().x < 32) iHeight = 32; if(tbDirect3D::GetScreenSize().x < 16) iHeight = 16; if(tbDirect3D::GetScreenSize().x < 8) iHeight = 8; if(tbDirect3D::GetScreenSize().x < 4) iHeight = 4; } // Hintergrundtextur erstellen (nicht füllen) tbDirect3D::GetDevice()->CreateTexture( iWidth, iHeight, 0, 0, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &m_pBackgroundT, NULL); |
Quellcode |
|
1 2 3 4 |
// Bildpuffer abfragen und speichern und kopieren tbDirect3D::GetDevice()->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &m_pBackgroundS); // Bildpuffer auf die Textur schreiben m_pBackgroundT->GetSurfaceLevel(0, &m_pBackgroundS); |
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
int iWidth, iHeight; // Unterstützt das Gerät Texturen, deren Breite und Höhe keine 2er-Potenzen sind? if(tbDirect3D::GetCaps().TextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL) { // Ja! Dann setzen wir Breite und Höhe auf die Dimensionen des Videos. iWidth = tbDirect3D::GetScreenSize().x; iHeight = tbDirect3D::GetScreenSize().y; } else { // Breite und Höhe müssen 2er-Potenzen sein. Wir suchen jeweils die nächste. if(tbDirect3D::GetScreenSize().x > 4096) iWidth = 4096; if(tbDirect3D::GetScreenSize().x < 4096) iWidth = 4096; if(tbDirect3D::GetScreenSize().x < 2048) iWidth = 2048; if(tbDirect3D::GetScreenSize().x < 1024) iWidth = 1024; if(tbDirect3D::GetScreenSize().x < 512) iWidth = 512; if(tbDirect3D::GetScreenSize().x < 256) iWidth = 256; if(tbDirect3D::GetScreenSize().x < 128) iWidth = 128; if(tbDirect3D::GetScreenSize().x < 64) iWidth = 64; if(tbDirect3D::GetScreenSize().x < 32) iWidth = 32; if(tbDirect3D::GetScreenSize().x < 16) iWidth = 16; if(tbDirect3D::GetScreenSize().x < 8) iWidth = 8; if(tbDirect3D::GetScreenSize().x < 4) iWidth = 4; if(tbDirect3D::GetScreenSize().y > 4096) iHeight = 4096; if(tbDirect3D::GetScreenSize().y < 4096) iHeight = 4096; if(tbDirect3D::GetScreenSize().y < 2048) iHeight = 2048; if(tbDirect3D::GetScreenSize().y < 1024) iHeight = 1024; if(tbDirect3D::GetScreenSize().y < 512) iHeight = 512; if(tbDirect3D::GetScreenSize().y < 256) iHeight = 256; if(tbDirect3D::GetScreenSize().y < 128) iHeight = 128; if(tbDirect3D::GetScreenSize().y < 64) iHeight = 64; if(tbDirect3D::GetScreenSize().y < 32) iHeight = 32; if(tbDirect3D::GetScreenSize().y < 16) iHeight = 16; if(tbDirect3D::GetScreenSize().y < 8) iHeight = 8; if(tbDirect3D::GetScreenSize().y < 4) iHeight = 4; } // Hintergrundbild laden tbDirect3D::GetDevice()->CreateTexture(iWidth, iHeight, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &m_pBackground, NULL); tbDirect3D::GetDevice()->CreateOffscreenPlainSurface(tbDirect3D::GetScreenSize().y, tbDirect3D::GetScreenSize().x, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &m_pTemp, NULL); |
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
// ------------------------------------ IDirect3DSurface9* pOldBackBuffer; IDirect3DSurface9* pOldZBuffer; tbDirect3D::GetDevice()->GetRenderTarget(0, &pOldBackBuffer); tbDirect3D::GetDevice()->GetDepthStencilSurface(&pOldZBuffer); m_pBackground->GetSurfaceLevel(0,&m_pTemp); tbDirect3D::GetDevice()->SetRenderTarget(0,m_pTemp); tbDirect3D::BeginScene(); g_pMissile->m_pFont1->Begin(); tbDirect3D::GetDevice()->ColorFill(m_pTemp, NULL, tbColor(0.0f,0.0f,0.0f,1.0f)); g_pMissile->m_pFont1->DrawText(tbVector2(0.5f, 0.5f), "TEST", TB_FF_ALIGN_HCENTER | TB_FF_ALIGN_VCENTER | TB_FF_RELATIVE | TB_FF_RELATIVESCALING, -1, tbColor(1.0f,1.0f,0.0f,1.0f)), tbVector2(2.0f, 4.0f); g_pMissile->m_pFont1->End(); g_pMissile->m_pFont1->Begin(); g_pMissile->m_pFont1->DrawText(tbVector2(0.1f, 0.1f), "TEST", TB_FF_ALIGN_HCENTER | TB_FF_ALIGN_VCENTER | TB_FF_RELATIVE | TB_FF_RELATIVESCALING, -1, tbColor(1.0f,1.0f,0.0f,1.0f)), tbVector2(2.0f, 4.0f); g_pMissile->m_pFont1->End(); tbDirect3D::EndScene(); tbDirect3D::GetDevice()->SetRenderTarget(0, pOldBackBuffer); tbDirect3D::GetDevice()->SetDepthStencilSurface(pOldZBuffer); if(NULL != pOldZBuffer) { pOldZBuffer->Release(); pOldZBuffer = NULL; } if(NULL != pOldBackBuffer) { pOldBackBuffer->Release(); pOldBackBuffer = NULL; } // ------------------------------------ // Puffer leeren und Szene beginnen tbDirect3D::Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, tbColor(0.7f, 0.7f, 0.7f), 1.0f, 0); tbDirect3D::BeginScene(); // ... tbDirect3D::SetTexture(0, m_pBackground); |
Werbeanzeige