home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2006 July & August
/
PCWorld_2006-07-08_cd.bin
/
temacd
/
planearcade
/
planearcade.exe
/
Tank3.bmp
/
offscreen.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
2004-10-03
|
3KB
|
131 lines
#include "main.h"
//------------------------------------------------------------------
// Name: OFFSCREEN()
// Desc: konstruktor
//------------------------------------------------------------------
OFFSCREEN::OFFSCREEN()
{
RenderToSurface = NULL ;
DynamicTexture = NULL;
TextureSurface = NULL;
Width = 256;
Height = 256;
}
//------------------------------------------------------------------
// Name: ~OFFSCREEN()
// Desc: destruktor
//------------------------------------------------------------------
OFFSCREEN::~OFFSCREEN()
{
if( RenderToSurface != NULL )
RenderToSurface->Release();
if( DynamicTexture != NULL )
DynamicTexture->Release();
if( TextureSurface != NULL )
TextureSurface->Release();
}
//------------------------------------------------------------------
// Name: Initialize()
// Desc: inicializacia textur a povrchov
//------------------------------------------------------------------
void OFFSCREEN::Initialize()
{
LogPrint("Inicializujem Texturu pre rendering");
//
// Create our dynamic texture for use by the "render to" surface...
//
if (FAILED(D3DXCreateTexture( g_pd3dDevice,
Width,
Height,
1,
D3DUSAGE_RENDERTARGET,
D3DFMT_A8R8G8B8,
Engine.TextureCreatingFlag,
&DynamicTexture )))
{
LogPrint(" Nepodarilo sa vytvorit dynamicku texturu");
}
else
{
LogPrint(" Dynamicka textura vytvorena");
}
//
// Create an off-screen "render to" surface...
//
D3DSURFACE_DESC desc;
DynamicTexture->GetSurfaceLevel( 0, &TextureSurface );
TextureSurface->GetDesc( &desc );
if (FAILED(D3DXCreateRenderToSurface( g_pd3dDevice,
desc.Width,
desc.Height,
desc.Format,
TRUE,
D3DFMT_D16,
&RenderToSurface )))
{
LogPrint(" Nepodarilo sa vytvorit povrch");
}
else
{
LogPrint(" Povrch vytvoreny");
}
//
//Vytvorenie projekcnej matice
//
D3DXMatrixPerspectiveFovLH( &Projection, 45.0f,
(float)Width / (float)Height,
0.1f, 100.0f );
}
//------------------------------------------------------------------
// Name: BeginRender()
// Desc: zaciatok render-> vycistenie bufferu
//------------------------------------------------------------------
void OFFSCREEN::BeginRender()
{
RenderToSurface->BeginScene( TextureSurface, NULL );
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
D3DCOLOR_COLORVALUE(0.0f,0.0f,0.0f,1.0f), 1.0f, 0);
}
//------------------------------------------------------------------
// Name: EndRender()
// Desc: koniec renderu -> prezentacia dßt
//------------------------------------------------------------------
void OFFSCREEN::EndRender()
{
RenderToSurface->EndScene( 0 );
}
//------------------------------------------------------------------
// Name: GetTexture()
// Desc: vrati texturu do ktorej sa renderovalo
//------------------------------------------------------------------
LPDIRECT3DTEXTURE9 OFFSCREEN::GetTexture()
{
return DynamicTexture;
}