port from perforce
This commit is contained in:
783
evoke-64k/ev10/main.cpp
Normal file
783
evoke-64k/ev10/main.cpp
Normal file
@@ -0,0 +1,783 @@
|
||||
#include "defines.h"
|
||||
|
||||
int c_iScreenSizeX= DEFAULTSCREENX;
|
||||
int c_iScreenSizeY= DEFAULTSCREENY;
|
||||
#ifdef WINDOWED
|
||||
bool bWindowed= true;
|
||||
#else
|
||||
bool bWindowed= false;
|
||||
#endif
|
||||
|
||||
#ifdef LOW_DETAIL
|
||||
bool bLowDetail= true;
|
||||
#else
|
||||
bool bLowDetail= false;
|
||||
#endif
|
||||
|
||||
int c_iRealScreenY= c_iScreenSizeY;
|
||||
|
||||
#ifdef STARTMUSIC
|
||||
#include "v2mplayer.h"
|
||||
#include "libv2.h"
|
||||
#include "music.h"
|
||||
#include "musicdata.h"
|
||||
|
||||
static V2MPlayer player;
|
||||
#endif
|
||||
|
||||
#include "intrin.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <mmsystem.h>
|
||||
#include <d3d9.h>
|
||||
#include <d3dx9math.h>
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
#include "camera.h"
|
||||
|
||||
#include "TargetValue.h"
|
||||
#include "camerahelper.h"
|
||||
|
||||
#include "ShaderFactory.h"
|
||||
#include "Renderpipe.h"
|
||||
#include "textinfo.h"
|
||||
|
||||
|
||||
#undef WINAPI
|
||||
#define WINAPI __declspec(nothrow) __stdcall
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
////
|
||||
// CRT replacement functions
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//extern "C" int _fltused = 1;
|
||||
int __cdecl main(){return 0;};
|
||||
|
||||
|
||||
#undef ZeroMemory
|
||||
|
||||
|
||||
#ifdef EXTRACODE
|
||||
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "StringHelper.h"
|
||||
#include "TextFileReader.h"
|
||||
|
||||
#include "ConfigFiles.h"
|
||||
|
||||
#endif
|
||||
|
||||
#include "mesher.h"
|
||||
#include "camera.h"
|
||||
#include "picstuff.h"
|
||||
#include "bar16to9.h"
|
||||
|
||||
#include "textout.h"
|
||||
#include "flockspline.h"
|
||||
|
||||
void PrepareDemoSetup()
|
||||
{
|
||||
#ifndef DISABLEAUTOSCREEN
|
||||
c_iScreenSizeX = GetSystemMetrics( SM_CXSCREEN );
|
||||
c_iScreenSizeY = GetSystemMetrics( SM_CYSCREEN );
|
||||
#endif
|
||||
/***********************************************************************************/
|
||||
char* pcCommand;
|
||||
pcCommand= GetCommandLine();
|
||||
{
|
||||
int i= 0;
|
||||
int iNumber= 0;
|
||||
int iBool= -1;
|
||||
{
|
||||
while( pcCommand[ i ] != 0 )
|
||||
{
|
||||
if( pcCommand[ i ] == '+' )
|
||||
{
|
||||
iBool= 1;
|
||||
iNumber= 0;
|
||||
}
|
||||
else if( pcCommand[ i ] == '-' )
|
||||
{
|
||||
iBool= 0;
|
||||
iNumber= 0;
|
||||
}
|
||||
else if( pcCommand[ i ] >= '0' && pcCommand[ i ] <= '9' )
|
||||
{
|
||||
iNumber= 10 * iNumber + pcCommand[ i ] - '0';
|
||||
}
|
||||
else if( pcCommand[ i ] == 'w' )
|
||||
{
|
||||
if( iBool != -1 )
|
||||
{
|
||||
bWindowed= iBool == 1;
|
||||
}
|
||||
iBool= -1;
|
||||
iNumber= 0;
|
||||
}
|
||||
else if( pcCommand[ i ] == 'l' )
|
||||
{
|
||||
if( iBool != -1 )
|
||||
{
|
||||
bLowDetail= iBool == 1;
|
||||
}
|
||||
iBool= -1;
|
||||
iNumber= 0;
|
||||
}
|
||||
else if( pcCommand[ i ] == 'x' )
|
||||
{
|
||||
if( iNumber > 0 )
|
||||
{
|
||||
c_iScreenSizeX= iNumber;
|
||||
}
|
||||
iNumber= 0;
|
||||
}
|
||||
else if( pcCommand[ i ] == 'y' )
|
||||
{
|
||||
if( iNumber > 0 )
|
||||
{
|
||||
c_iScreenSizeY= iNumber;
|
||||
}
|
||||
iNumber= 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
iNumber= 0;
|
||||
iBool= -1;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
c_iRealScreenY= c_iScreenSizeX * 9 / 16;
|
||||
if( c_iRealScreenY > c_iScreenSizeY )
|
||||
{
|
||||
c_iRealScreenY= c_iScreenSizeY;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef EXTRACODE
|
||||
LRESULT MessageCallback(HWND ar_Handle, UINT aw_Message, WPARAM aw_Param, LPARAM al_Param)
|
||||
{
|
||||
return DefWindowProc(ar_Handle, aw_Message, aw_Param, al_Param);
|
||||
}
|
||||
#endif
|
||||
|
||||
void CreateWnd()
|
||||
{
|
||||
HWND& hwnd= d3dpp.hDeviceWindow;
|
||||
|
||||
#ifdef EXTRACODE
|
||||
WNDCLASSEX wndclass;
|
||||
wndclass.cbSize = sizeof (wndclass) ;
|
||||
wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
|
||||
wndclass.lpfnWndProc = (WNDPROC)MessageCallback ;
|
||||
wndclass.cbClsExtra = 0 ;
|
||||
wndclass.cbWndExtra = 0 ;
|
||||
wndclass.hInstance = NULL ;
|
||||
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
|
||||
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
|
||||
wndclass.hbrBackground = (HBRUSH) GetStockObject (DKGRAY_BRUSH) ;
|
||||
wndclass.lpszMenuName = NULL;
|
||||
wndclass.lpszClassName = "Window" ;
|
||||
wndclass.hIconSm = LoadIcon (NULL, IDI_APPLICATION) ;
|
||||
|
||||
RegisterClassEx(&wndclass);
|
||||
|
||||
hwnd = CreateWindow(
|
||||
"Window", /* Classname */
|
||||
WindowTitle, /* Title Text */
|
||||
WS_EX_APPWINDOW, /* default window */
|
||||
10, /* Windows decides the position */
|
||||
30, /* where the window ends up on the screen */
|
||||
c_iScreenSizeX, /* The programs width */
|
||||
c_iScreenSizeY, /* and height in pixels */
|
||||
NULL, /* The window is a child-window to desktop */
|
||||
NULL, /* No menu */
|
||||
GetModuleHandle(NULL), //GetModuleHandle(NULL), /* Program Instance handler */
|
||||
NULL /* No Window Creation data */
|
||||
);
|
||||
#else
|
||||
hwnd = CreateWindow(
|
||||
"STATIC", /* Classname */
|
||||
WindowTitle, /* Title Text */
|
||||
WS_POPUP, /* default window */
|
||||
10, /* Windows decides the position */
|
||||
30, /* where the window ends up on the screen */
|
||||
c_iScreenSizeX, /* The programs width */
|
||||
c_iScreenSizeY, /* and height in pixels */
|
||||
NULL, /* The window is a child-window to desktop */
|
||||
NULL, /* No menu */
|
||||
0, //GetModuleHandle(NULL), /* Program Instance handler */
|
||||
NULL /* No Window Creation data */
|
||||
);
|
||||
#endif
|
||||
#ifndef _DEBUG
|
||||
ShowCursor(false);
|
||||
#endif
|
||||
|
||||
#ifdef CAMERATESTER
|
||||
EditorHelp::SetHWND( hwnd );
|
||||
#endif
|
||||
}
|
||||
|
||||
void CreateD3DDevice()
|
||||
{
|
||||
HWND& hwnd= d3dpp.hDeviceWindow;
|
||||
|
||||
g_D3D= Direct3DCreate9( D3D_SDK_VERSION );
|
||||
|
||||
if( bWindowed )
|
||||
{
|
||||
ShowWindow (hwnd , SW_NORMAL );
|
||||
#ifdef EXTRACODE
|
||||
// set exact client size
|
||||
RECT rcClient, rcWindow;
|
||||
POINT ptDiff;
|
||||
GetClientRect(hwnd, &rcClient);
|
||||
GetWindowRect(hwnd, &rcWindow);
|
||||
ptDiff.x = (rcWindow.right - rcWindow.left) - rcClient.right;
|
||||
ptDiff.y = (rcWindow.bottom - rcWindow.top) - rcClient.bottom;
|
||||
MoveWindow(hwnd,rcWindow.left, rcWindow.top, c_iScreenSizeX + ptDiff.x, c_iScreenSizeY + ptDiff.y, TRUE);
|
||||
|
||||
#endif
|
||||
}
|
||||
d3dpp.Windowed = bWindowed;
|
||||
|
||||
d3dpp.BackBufferWidth= c_iScreenSizeX;
|
||||
d3dpp.BackBufferHeight= c_iScreenSizeY;
|
||||
|
||||
if( !bLowDetail )
|
||||
{
|
||||
if( g_d3d_device == NULL )
|
||||
{
|
||||
g_D3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hwnd,D3DCREATE_FPU_PRESERVE|D3DCREATE_HARDWARE_VERTEXPROCESSING,&d3dpp,&g_d3d_device);
|
||||
}
|
||||
|
||||
if( g_d3d_device == NULL )
|
||||
{
|
||||
d3dpp.MultiSampleType= D3DMULTISAMPLE_8_SAMPLES;
|
||||
g_D3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hwnd,D3DCREATE_FPU_PRESERVE|D3DCREATE_HARDWARE_VERTEXPROCESSING,&d3dpp,&g_d3d_device);
|
||||
}
|
||||
if( g_d3d_device == NULL )
|
||||
{
|
||||
d3dpp.MultiSampleType= D3DMULTISAMPLE_4_SAMPLES;
|
||||
g_D3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hwnd,D3DCREATE_FPU_PRESERVE|D3DCREATE_HARDWARE_VERTEXPROCESSING,&d3dpp,&g_d3d_device);
|
||||
}
|
||||
if( g_d3d_device == NULL )
|
||||
{
|
||||
d3dpp.MultiSampleType= D3DMULTISAMPLE_2_SAMPLES;
|
||||
g_D3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hwnd,D3DCREATE_FPU_PRESERVE|D3DCREATE_HARDWARE_VERTEXPROCESSING,&d3dpp,&g_d3d_device);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if( g_d3d_device == NULL )
|
||||
{
|
||||
d3dpp.MultiSampleType= D3DMULTISAMPLE_NONE;
|
||||
g_D3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hwnd,D3DCREATE_FPU_PRESERVE|D3DCREATE_HARDWARE_VERTEXPROCESSING,&d3dpp,&g_d3d_device);
|
||||
}
|
||||
if( g_d3d_device == NULL )
|
||||
{
|
||||
d3dpp.MultiSampleType= D3DMULTISAMPLE_NONE;
|
||||
g_D3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hwnd,D3DCREATE_FPU_PRESERVE|D3DCREATE_SOFTWARE_VERTEXPROCESSING,&d3dpp,&g_d3d_device);
|
||||
}
|
||||
|
||||
if( g_d3d_device == NULL )
|
||||
{
|
||||
MessageBox( NULL,
|
||||
"D3D not initialized!",
|
||||
"fatal Error",
|
||||
MB_OK );
|
||||
ExitProcess( -1 );
|
||||
}
|
||||
}
|
||||
|
||||
void WinEntry(void)
|
||||
{
|
||||
InitGlobals();
|
||||
|
||||
PrepareDemoSetup();
|
||||
|
||||
CreateWnd();
|
||||
CreateD3DDevice();
|
||||
|
||||
#ifdef EXTRACODE
|
||||
StartFileWatch();
|
||||
ReadDataFromDisc();
|
||||
#else
|
||||
PreparePlayCam();
|
||||
#endif
|
||||
|
||||
g_fResolutionFactor = max(d3dpp.BackBufferWidth / 1024.f, d3dpp.BackBufferHeight / 768.f);
|
||||
|
||||
{
|
||||
g_iResolutionFactorExp = 0;
|
||||
float fResFactor = g_fResolutionFactor;
|
||||
while(fResFactor <= .75f) { g_iResolutionFactorExp--; fResFactor *= 2.f; }
|
||||
while(fResFactor >= 1.75f) { g_iResolutionFactorExp++; fResFactor *= 0.5f; }
|
||||
}
|
||||
|
||||
g_nShadowResolution= 2 * max(d3dpp.BackBufferWidth, d3dpp.BackBufferHeight);//config
|
||||
g_nShadowResolution= min( g_nShadowResolution, 4096 );
|
||||
g_nShadowResolution= max( g_nShadowResolution, 1536 );
|
||||
|
||||
Renderpipe::PrepareRenderTargets( d3dpp.BackBufferWidth, d3dpp.BackBufferHeight,
|
||||
g_nShadowResolution, d3dpp.MultiSampleType );
|
||||
|
||||
#ifdef CAMERATESTER
|
||||
ReadCameraAll();
|
||||
HomeCam();
|
||||
EditorHelp::PreparePrint();
|
||||
#endif
|
||||
/***********************************************************************************/
|
||||
//Renderstates
|
||||
|
||||
g_d3d_device->SetMaterial( &d3dMaterial );
|
||||
|
||||
g_d3d_device->SetRenderState( D3DRS_SPECULARENABLE, TRUE );
|
||||
g_d3d_device->SetRenderState( D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_COLOR1 );
|
||||
g_d3d_device->SetRenderState( D3DRS_SPECULARMATERIALSOURCE, D3DMCS_MATERIAL );
|
||||
g_d3d_device->SetRenderState( D3DRS_AMBIENTMATERIALSOURCE, D3DMCS_COLOR1 );
|
||||
g_d3d_device->SetRenderState( D3DRS_NORMALIZENORMALS, TRUE );
|
||||
|
||||
//g_d3d_device->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
|
||||
//g_d3d_device->SetRenderState( D3DRS_FILLMODE, D3DFILL_WIREFRAME );
|
||||
//g_d3d_device->SetRenderState( D3DRS_SHADEMODE, D3DSHADE_FLAT );
|
||||
|
||||
g_d3d_device->SetLight( 0, &d3dLight[ 0 ] );
|
||||
g_d3d_device->SetLight( 1, &d3dLight[ 1 ] );
|
||||
g_d3d_device->SetLight( 1, &d3dLight[ 2 ] );
|
||||
|
||||
g_d3d_device->LightEnable( 0, TRUE );
|
||||
g_d3d_device->LightEnable( 1, TRUE );
|
||||
g_d3d_device->LightEnable( 2, TRUE );
|
||||
|
||||
g_d3d_device->SetRenderState(D3DRS_FOGCOLOR, 0xffe0b0a0 );
|
||||
g_d3d_device->SetRenderState( D3DRS_FOGTABLEMODE, D3DFOG_EXP2);
|
||||
float fDensity= 1.0f / 16.0f;
|
||||
g_d3d_device->SetRenderState( D3DRS_FOGDENSITY, *(DWORD *)(&fDensity) );
|
||||
g_d3d_device->SetRenderState( D3DRS_FOGENABLE, TRUE );
|
||||
|
||||
PrepareText();
|
||||
RenderLoading( 1 );
|
||||
|
||||
PrepareShaders();
|
||||
|
||||
/***********************************************************************************/
|
||||
//generate Demo Zeugs...
|
||||
RenderLoading( 45 );
|
||||
|
||||
RenderLoading( 60 );
|
||||
g_Random.setSeed( 27 );
|
||||
PrepareFlockObjects();
|
||||
|
||||
RenderLoading( 50 );
|
||||
|
||||
RenderLoading( 70 );
|
||||
|
||||
/***********************************************************************************/
|
||||
//prep picture
|
||||
RenderLoading( 80 );
|
||||
|
||||
g_pTextures[ TI_RotMatrix ].Create( 32, 32, 1, 1 );
|
||||
g_pTextures[ TI_RotMatrix ].PrepareRotMatrix();
|
||||
g_pTextures[ TI_Random ].Create( 32, 32, 1, 0 );
|
||||
g_pTextures[ TI_Random ].PrepareRandomTexture();
|
||||
g_pTextures[ TI_RandomCube ].Create( 32, 32, 32, 0 );
|
||||
g_pTextures[ TI_RandomCube ].PrepareRandomTexture();
|
||||
|
||||
RenderLoading( 90 );
|
||||
Texture::Prepare1DTextures();
|
||||
|
||||
g_FullScreenQuad.InitFullScreenQuad();
|
||||
|
||||
g_PSSM.m_iSplitCount = 6; //config
|
||||
g_PSSM.m_fRange = 240.0f;
|
||||
|
||||
g_SkyBox.Create( 24, 36 );
|
||||
g_SkyBox.m_iUsedPreShader= SkyDepth;
|
||||
g_SkyBox.m_iUsedShader[ 0 ]= Sky;
|
||||
g_SkyBox.Lock();
|
||||
g_SkyBox.AddBox(
|
||||
D3DXVECTOR3( 0.0f, 0.0f, 0.0f),
|
||||
D3DXVECTOR3( 1.0f, 1.0f, 1.0f),
|
||||
D3DXVECTOR3( 0.0f, 0.0f, 0.0f ),
|
||||
0xff20b0f0);
|
||||
g_SkyBox.Unlock();
|
||||
|
||||
g_Objects[ 1 ].Create( 127 * 127 * 4, 127 * 127 * 6 );
|
||||
g_Objects[ 1 ].m_iUsedPreShader= PreDepth;
|
||||
g_Objects[ 1 ].m_iUsedShader[ 0 ]= Tarmac;
|
||||
g_Objects[ 1 ].m_iUsedShader[ 1 ]= Grass;
|
||||
g_Objects[ 1 ].m_bAlphaEnable[ 1 ]= true;
|
||||
g_Objects[ 1 ].m_SrcBlend[ 1 ]= D3DBLEND_ONE;
|
||||
g_Objects[ 1 ].m_DestBlend[ 1 ]= D3DBLEND_INVSRCALPHA;
|
||||
g_Objects[ 1 ].m_BlendOp[ 1 ]= D3DBLENDOP_ADD;
|
||||
|
||||
g_Objects[ 1 ].Lock();
|
||||
g_Objects[ 1 ].AddGround(
|
||||
D3DXVECTOR3( 0.0f, -1.0f, 0.0f ),
|
||||
D3DXVECTOR3( 500.0f, 1.0f, 500.0f ),
|
||||
D3DXVECTOR3( 0.0f, 0.0f, 0.0f ),
|
||||
0xFFFFDCB5, // 0x8040ff40
|
||||
80.0f,
|
||||
112.0f,
|
||||
1.0f,
|
||||
48.0f,
|
||||
127,
|
||||
127);
|
||||
|
||||
g_Objects[ 1 ].Unlock();
|
||||
|
||||
RenderLoading( 95 );
|
||||
CreateTextRenderJobs();
|
||||
/***********************************************************************************/
|
||||
// Sound
|
||||
// Sound
|
||||
#ifdef STARTMUSIC
|
||||
player.Init();
|
||||
# ifdef MUSICLOAD
|
||||
|
||||
if( loadMusic() )
|
||||
{
|
||||
player.Open(pLoadSong);
|
||||
}
|
||||
# else
|
||||
player.Open(pSong);
|
||||
# endif
|
||||
|
||||
|
||||
dsInit(player.RenderProxy,&player,GetForegroundWindow());
|
||||
|
||||
# ifdef SCRIPTEDITOR
|
||||
player.Play( g_iSkipTicks * g_iTempo / 1411 );
|
||||
g_iSampleOffset= g_iSampleOffsetGeneral -
|
||||
g_iSkipTicks * g_iTempo / 32;
|
||||
# else
|
||||
player.Play();
|
||||
# endif
|
||||
|
||||
#else
|
||||
g_dwTimeReplaceStart= timeGetTime();
|
||||
#endif
|
||||
|
||||
/***********************************************************************************/
|
||||
//Mainloop
|
||||
int LastCamTick= 0;
|
||||
|
||||
//g_ScriptState.Prepare();
|
||||
|
||||
//STargetValue tvBumping1( 1.0f, 1.0f, 0.0f, 0.05f, 0.85f );
|
||||
|
||||
do
|
||||
{
|
||||
#ifdef EXTRACODE
|
||||
if( CheckFileWatch() )
|
||||
{
|
||||
# ifndef STARTMUSIC
|
||||
g_dwTimeReplaceStart= timeGetTime();
|
||||
# else
|
||||
# ifdef SCRIPTEDITOR
|
||||
player.Play( g_iSkipTicks * g_iTempo / 1411 );
|
||||
g_iSampleOffset= player.GetPlayTick() +
|
||||
g_iSampleOffsetGeneral -
|
||||
g_iSkipTicks * g_iTempo / 32;
|
||||
# else
|
||||
player.Play();
|
||||
g_iSampleOffset= player.GetPlayTick() +
|
||||
g_iSampleOffsetGeneral;
|
||||
# endif
|
||||
# endif
|
||||
//g_ScriptState.Prepare();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef STARTMUSIC
|
||||
g_dwSamplesPassed= (int)player.GetPlayTick() - g_iSampleOffset;
|
||||
#else
|
||||
g_dwSamplesPassed= (timeGetTime() - g_dwTimeReplaceStart ) * 441 / 10;
|
||||
#endif
|
||||
DWORD dwNewSamples= g_dwSamplesPassed - g_dwSamples;
|
||||
g_dwSamples= g_dwSamplesPassed;
|
||||
|
||||
/***********************************************************************************/
|
||||
#ifdef STARTMUSIC
|
||||
float fL, fR;
|
||||
player.GetChannelVU( 3, &fL, &fR );
|
||||
g_vuLightBeat.Set( g_dwSamples / 100 + 88, fL + fR );
|
||||
player.GetChannelVU( 2, &fL, &fR );
|
||||
g_vuOffBeat.Set( g_dwSamples / 100 + 88, fL + fR );
|
||||
#endif
|
||||
|
||||
// Testkamera setzen
|
||||
#ifdef CAMERATESTER
|
||||
// EditCam();
|
||||
EditorHelp::CheckKeys();
|
||||
float fCamTime= (float)dwNewSamples / (float)g_iTempo * (float)g_iCamTickFactor;
|
||||
InterpolateCamGlobal((int)fCamTime, g_Camera);
|
||||
|
||||
# ifdef STARTMUSIC
|
||||
static DWORD LastMusicSetTick= timeGetTime();
|
||||
if( !IsFreeCam() && EditorHelp::m_KeyPressed[ 'M' ] )
|
||||
{
|
||||
if( timeGetTime() > LastMusicSetTick + 1000 )
|
||||
{
|
||||
float fNeededSec= (float)GetRealTime() / (float)g_iCamTickFactor * (float)g_iTempo / 44100.0f;
|
||||
float fMusicSec= (float)player.GetPlayTickOffset() / 44100.0f;
|
||||
float fDiff= abs( fMusicSec - fNeededSec );
|
||||
if( fDiff > 0.1f )
|
||||
{
|
||||
LastMusicSetTick= timeGetTime();
|
||||
player.Play( (int)(fNeededSec * 1000.0f ) );
|
||||
/*g_iSampleOffset= player.GetPlayTick() +
|
||||
g_iSampleOffsetGeneral;*/
|
||||
}
|
||||
}
|
||||
}
|
||||
# endif
|
||||
|
||||
#else
|
||||
float fCamTime= (float)g_dwSamples / (float)g_iTempo * (float)g_iCamTickFactor;
|
||||
int CurCamTick= (int)fCamTime;
|
||||
PlayCam( CurCamTick - LastCamTick, g_Camera);
|
||||
LastCamTick= CurCamTick;
|
||||
#endif
|
||||
|
||||
|
||||
//float fRes= 1.0f - minimum( 1.0f,( g_vuLightBeat.Get( g_dwSamples / 100 ) ) * 0.475f );
|
||||
//d3dMaterial.Power= 1.25f + mypow( fRes, 0.33f ) * 31.0f;
|
||||
|
||||
/***********************************************************************************/
|
||||
//Spline Test
|
||||
{
|
||||
float fSplineTime= (float)g_Camera.m_iDemoTime / (float)g_iCamTickFactor;
|
||||
AddFlockObjectsToScene( fSplineTime );
|
||||
}
|
||||
/***********************************************************************************/
|
||||
// Sonne bewegen
|
||||
{
|
||||
float fPreTime= (float)g_Camera.m_iDemoTime / (float)g_iCamTickFactor;
|
||||
float fTime= fPreTime;
|
||||
float fBaseHeight= 1.1f;
|
||||
if( fTime > 10.0f && fTime < 49.0f )
|
||||
{
|
||||
fBaseHeight= 0.375f;
|
||||
}
|
||||
else if( fTime > 128.0f && fTime < 192.0f )
|
||||
{
|
||||
fBaseHeight= 0.6f;
|
||||
}
|
||||
if( fPreTime > 240.0f )
|
||||
{
|
||||
fTime/= 8.0f;
|
||||
}
|
||||
D3DXMATRIX mSunRotX, mSunRotY, mSunRotZ, mSun;
|
||||
D3DXMatrixRotationX( &mSunRotX, fBaseHeight - 0.4f * sin( 0.08f * fTime ));
|
||||
D3DXMatrixRotationY( &mSunRotY, 0.3f * fTime );
|
||||
D3DXMatrixRotationZ( &mSunRotZ, 0.3f );
|
||||
mSun = mSunRotX * mSunRotY * mSunRotZ;
|
||||
g_LightDir.x = -mSun._21; g_LightDir.y = -mSun._22; g_LightDir.z = -mSun._23;
|
||||
D3DXVec3Normalize(&g_LightDir, &g_LightDir);
|
||||
}
|
||||
{
|
||||
/*int time= timeGetTime();
|
||||
g_fGlow= 1.0f + sin( 0.01f * (float)time );
|
||||
g_fGlow= 0.25f * g_fGlow * g_fGlow;*/
|
||||
g_fGlow= g_vuOffBeat.Get( g_dwSamples / 100 );
|
||||
g_fGlow= 0.5f * g_fGlow * g_fGlow;
|
||||
g_fGlow= min( g_fGlow, 1.5f );
|
||||
g_fGlow= max( g_fGlow, 0.0f );
|
||||
}
|
||||
|
||||
/*{
|
||||
g_fPlasmaGrid= g_vuLightBeat.Get( g_dwSamples / 100 );
|
||||
g_fPlasmaGrid= 1.0f - 0.5f * g_fPlasmaGrid;
|
||||
g_fPlasmaGrid= max( g_fPlasmaGrid, 1.0f / 8.0f );
|
||||
g_fPlasmaGrid= min( g_fPlasmaGrid, 0.5f );
|
||||
}*/
|
||||
|
||||
/*{
|
||||
float fCloudTime= (float)g_dwSamples / (float)g_iTempo;
|
||||
g_fClouds= 0.0f;
|
||||
if( fCloudTime > 66.0f )
|
||||
{
|
||||
g_fClouds= 1.0f;
|
||||
}
|
||||
else if( fCloudTime > 62.0f )
|
||||
{
|
||||
g_fClouds= (fCloudTime - 62.0f ) * 0.25f;
|
||||
}
|
||||
|
||||
g_fClouds= 0.1875f + 0.35f * g_fClouds;
|
||||
}*/
|
||||
|
||||
SetTextPos( (int)(1000.0f * (float)g_Camera.m_iDemoTime / (float)g_iCamTickFactor ) );
|
||||
|
||||
/***********************************************************************************/
|
||||
//begin paint loop
|
||||
g_d3d_device->BeginScene();
|
||||
|
||||
/***********************************************************************************/
|
||||
// normaler Renderdurchlauf
|
||||
|
||||
// Projektion
|
||||
D3DXMATRIX& mat= g_matProjection;
|
||||
|
||||
float zf= 1200.0f;
|
||||
float zn= 0.125f;
|
||||
float xScale = g_Camera.m_fFOV * g_Camera.m_fFOV;
|
||||
float yScale= xScale / (float)c_iScreenSizeY * (float)c_iScreenSizeX;
|
||||
|
||||
mat._11= xScale; mat._12= 0; mat._13= 0; mat._14= 0;
|
||||
mat._21= 0; mat._22= yScale; mat._23= 0; mat._24= 0;
|
||||
mat._31= 0; mat._32= 0; mat._33= zf/(zf-zn); mat._34= 1;
|
||||
mat._41= 0; mat._42= 0; mat._43= -zn*zf/(zf-zn);mat._44= 0;
|
||||
|
||||
FillCameraMatrix( g_Camera.m_vec3Pos, g_Camera.m_vec3Rot, &g_matView );
|
||||
|
||||
// Shadow splits aktualisieren
|
||||
g_PSSM.UpdateSplits(g_LightDir, g_matView, g_matProjection);
|
||||
|
||||
#ifdef ULTRASHOT
|
||||
// Ultra-shot
|
||||
if(GetAsyncKeyState(VK_CONTROL) && GetAsyncKeyState(VK_SHIFT) && GetAsyncKeyState('U'))
|
||||
{
|
||||
const int iTilesX = ULTRASHOT_TILES, iTilesY = ULTRASHOT_TILES;
|
||||
|
||||
D3DXMATRIX matProjectionFull = g_matProjection;
|
||||
LPDIRECT3DSURFACE9 pReadBackTarget = NULL;
|
||||
|
||||
// Allocate read-back buffer
|
||||
g_d3d_device->CreateOffscreenPlainSurface(d3dpp.BackBufferWidth, d3dpp.BackBufferHeight,
|
||||
d3dpp.BackBufferFormat, D3DPOOL_SYSTEMMEM, &pReadBackTarget, NULL);
|
||||
|
||||
float xTileScale = xScale * iTilesX;
|
||||
float yTileScale = yScale * iTilesY;
|
||||
|
||||
for(int x = 0; x < iTilesX; x++)
|
||||
{
|
||||
for(int y = 0; y < iTilesY; y++)
|
||||
{
|
||||
// Projection matrix
|
||||
g_matProjection._11= xTileScale;
|
||||
g_matProjection._22= yTileScale;
|
||||
g_matProjection._31= (float)((iTilesX - 1) - 2 * x);
|
||||
g_matProjection._32= (float)(-(iTilesY - 1) + 2 * y);
|
||||
|
||||
// Render
|
||||
g_d3d_device->SetTransform( D3DTS_PROJECTION, &g_matProjection );
|
||||
g_d3d_device->SetTransform( D3DTS_VIEW, &g_matView );
|
||||
Shader::SetShaderConstants();
|
||||
Renderpipe::RenderPassPostProcessing();
|
||||
|
||||
// Resolve render target
|
||||
g_d3d_device->StretchRect( g_pFullScreenRTS[ RTS_COLOR_MS ], NULL,
|
||||
g_pFullScreenRTS[ RTS_COLOR ], NULL, D3DTEXF_NONE );
|
||||
|
||||
// Read back target data
|
||||
g_d3d_device->GetRenderTargetData( g_pFullScreenRTS[ RTS_COLOR ], pReadBackTarget );
|
||||
|
||||
char acFilename[512];
|
||||
|
||||
// Save to file
|
||||
sprintf( acFilename, "ScreenTile%d_%d_%d.bmp", g_Camera.m_iDemoTime, x, y );
|
||||
D3DXSaveSurfaceToFile( acFilename, D3DXIFF_BMP, pReadBackTarget, NULL, NULL );
|
||||
}
|
||||
}
|
||||
|
||||
// Release read-back buffer
|
||||
pReadBackTarget->Release();
|
||||
|
||||
// Reset projection matrix
|
||||
g_matProjection = matProjectionFull;
|
||||
}
|
||||
#endif
|
||||
|
||||
g_d3d_device->SetTransform( D3DTS_PROJECTION, &g_matProjection );
|
||||
g_d3d_device->SetTransform( D3DTS_VIEW, &g_matView );
|
||||
|
||||
Shader::SetShaderConstants();
|
||||
|
||||
#ifndef DISABLEPOSTPROCESSING
|
||||
Renderpipe::RenderPassPostProcessing();
|
||||
#else
|
||||
Renderpipe::SimpleRenderPass();
|
||||
#endif
|
||||
/***********************************************************************************/
|
||||
// Renderdurchlauf abschliessen
|
||||
|
||||
//Shader aus
|
||||
Shader::Deactivate();
|
||||
|
||||
// Kinobalken
|
||||
RenderBars();
|
||||
|
||||
#ifdef CAMERATESTER
|
||||
DrawCameraDebugOutput();
|
||||
#endif
|
||||
|
||||
g_d3d_device->EndScene();
|
||||
g_d3d_device->Present( NULL, NULL, NULL, NULL );
|
||||
/***********************************************************************************/
|
||||
#ifdef _DEBUG
|
||||
Sleep( 5 );
|
||||
#endif
|
||||
|
||||
/***********************************************************************************/
|
||||
#ifdef EXTRACODE
|
||||
// Allow the window to get focus when clicking in it or at the taskbar icon.
|
||||
MSG msg;
|
||||
if (PeekMessage(&msg, d3dpp.hDeviceWindow, 0, 0, PM_REMOVE))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
#endif
|
||||
#ifdef DISABLEAUTOQUIT
|
||||
bool bEsc= GetAsyncKeyState( VK_ESCAPE ) != 0;
|
||||
bool bCtrl= GetAsyncKeyState( VK_CONTROL ) != 0 || GetAsyncKeyState( VK_SHIFT) != 0;
|
||||
if( bEsc && bCtrl )
|
||||
{
|
||||
break;
|
||||
}
|
||||
} while ( true );
|
||||
#else
|
||||
if( g_dwSamples > 246 * g_iTempo )
|
||||
{
|
||||
break;
|
||||
}
|
||||
} while ( !GetAsyncKeyState( VK_ESCAPE ) );
|
||||
#endif
|
||||
|
||||
/***********************************************************************************/
|
||||
//Shutdown
|
||||
ExitProcess( 0 );
|
||||
}
|
||||
|
||||
#ifdef EXTRACODE
|
||||
|
||||
int WINAPI
|
||||
WinMain (HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPSTR lpCmdLine,
|
||||
int iCmdShow)
|
||||
{
|
||||
WinEntry();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* Declare Windows procedure */
|
||||
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user