Initial commit: ROW Client source code
Game client codebase including: - CharacterActionControl: Character and creature management - GlobalScript: Network, items, skills, quests, utilities - RYLClient: Main client application with GUI and event handlers - Engine: 3D rendering engine (RYLGL) - MemoryManager: Custom memory allocation - Library: Third-party dependencies (DirectX, boost, etc.) - Tools: Development utilities 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
10
Engine/Zalla3D Base Class/3DMath.h
Normal file
10
Engine/Zalla3D Base Class/3DMath.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
#ifndef _3DMATH_H
|
||||
#define _3DMATH_H
|
||||
#include "vector.h"
|
||||
#include "matrix.h"
|
||||
#include "color.h"
|
||||
#include "quaternion.h"
|
||||
#include "Intersection.h"
|
||||
#include "FastMath.h"
|
||||
#endif
|
||||
681
Engine/Zalla3D Base Class/BaseGraphicsLayer.cpp
Normal file
681
Engine/Zalla3D Base Class/BaseGraphicsLayer.cpp
Normal file
@@ -0,0 +1,681 @@
|
||||
// BaseGraphic.cpp: implementation of the BaseGraphic class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "BaseGraphicsLayer.h"
|
||||
#include <d3d8.h>
|
||||
#include <d3dx8.h>
|
||||
#include "Vertex.h"
|
||||
#include "FastMath.h"
|
||||
#include "dxutil.h"
|
||||
#include "NTexture.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CViewCamera BaseGraphicsLayer::m_ViewCamera;
|
||||
|
||||
LPDIRECT3DDEVICE8 BaseGraphicsLayer::m_pd3dDevice;
|
||||
LPDIRECT3D8 BaseGraphicsLayer:: m_pD3D;
|
||||
D3DPRESENT_PARAMETERS BaseGraphicsLayer::m_d3dpp;
|
||||
|
||||
long BaseGraphicsLayer::m_lScreenSx;
|
||||
long BaseGraphicsLayer::m_lScreenSy;
|
||||
color BaseGraphicsLayer::m_ClearColor;
|
||||
|
||||
HWND BaseGraphicsLayer::m_hWnd;
|
||||
|
||||
bool BaseGraphicsLayer::m_VoodooOption=false;
|
||||
int BaseGraphicsLayer::m_iGraphicCards = 0;
|
||||
|
||||
char BaseGraphicsLayer::m_aszCustomMsg[10][300];
|
||||
CD3DFont* BaseGraphicsLayer::m_pFont = NULL;
|
||||
|
||||
|
||||
BaseGraphicsLayer::BaseGraphicsLayer()
|
||||
{
|
||||
m_hWnd=NULL;
|
||||
m_pd3dDevice=NULL;
|
||||
m_pD3D=NULL;
|
||||
m_fFov=m_fNear=m_fFar=0.0f;
|
||||
m_ClearColor.c=0x0;
|
||||
m_bEditorMode=false;
|
||||
m_iGraphicCards = 0;
|
||||
|
||||
memset(m_aszCustomMsg, 0, sizeof(m_aszCustomMsg));
|
||||
}
|
||||
|
||||
BaseGraphicsLayer::~BaseGraphicsLayer()
|
||||
{
|
||||
CROSSM::CNTexture::Close();
|
||||
CTexture::Close();
|
||||
|
||||
if(m_pd3dDevice) {
|
||||
m_pd3dDevice->Release();
|
||||
m_pd3dDevice = NULL;
|
||||
}
|
||||
if(m_pD3D) {
|
||||
m_pD3D->Release();
|
||||
m_pD3D = NULL;
|
||||
}
|
||||
if(m_pFont) {
|
||||
delete m_pFont;
|
||||
m_pFont = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void BaseGraphicsLayer::Create(HWND hWnd, bool bWindowed,bool Editor, long screenx, long screeny, long screenwidth, long screenheight)
|
||||
{
|
||||
//LogMessage("BaseGraphicsLayer Create Start");
|
||||
m_hWnd=hWnd;
|
||||
m_bWindowed=bWindowed;
|
||||
m_bEditorMode=Editor;
|
||||
GetWindowRect( m_hWnd, &m_rcWindowBounds );
|
||||
GetClientRect( m_hWnd, &m_rcWindowClient );
|
||||
|
||||
if(NULL == (m_pD3D=Direct3DCreate8(D3D_SDK_VERSION)))
|
||||
{
|
||||
throw CGraphicLayerError("BaseGraphicsLayer:Create,GetDirect3D Interface getting fail");
|
||||
}
|
||||
//LogMessage("Direct3D 8.0 Create");
|
||||
/*
|
||||
D3DAdapterInfo* pAdapterInfo = &CEnumD3D::m_Adapters[CEnumD3D::m_dwAdapter];
|
||||
D3DDeviceInfo* pDeviceInfo = &pAdapterInfo->devices[pAdapterInfo->dwCurrentDevice];
|
||||
D3DModeInfo* pModeInfo = &pDeviceInfo->modes[pDeviceInfo->dwCurrentMode];
|
||||
*/
|
||||
|
||||
D3DAdapterInfo* pAdapterInfo = &CEnumD3D::m_Adapters[CEnumD3D::m_nAdapter];
|
||||
D3DDeviceInfo* pDeviceInfo = &pAdapterInfo->devices[CEnumD3D::m_nDevice];
|
||||
D3DModeInfo* pModeInfo = &pDeviceInfo->modes[CEnumD3D::m_nMode];
|
||||
|
||||
if(strstr(pAdapterInfo->d3dAdapterIdentifier.Description,"Voodoo"))
|
||||
{
|
||||
m_VoodooOption=true;
|
||||
m_iGraphicCards = 0;
|
||||
//MessageBox(NULL,"Voodoo",0,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_VoodooOption=false;
|
||||
if(strstr(pAdapterInfo->d3dAdapterIdentifier.Description,"TNT")) {
|
||||
m_iGraphicCards = 1;
|
||||
}
|
||||
else if(strstr(pAdapterInfo->d3dAdapterIdentifier.Description,"GeForce2")) {
|
||||
m_iGraphicCards = 2;
|
||||
}
|
||||
else if(strstr(pAdapterInfo->d3dAdapterIdentifier.Description,"GeForce3")) {
|
||||
m_iGraphicCards = 3;
|
||||
}
|
||||
else if(strstr(pAdapterInfo->d3dAdapterIdentifier.Description,"GeForce4")) {
|
||||
m_iGraphicCards = 4;
|
||||
|
||||
}
|
||||
else {
|
||||
m_iGraphicCards = 5;
|
||||
}
|
||||
}
|
||||
|
||||
// Set up the presentation parameters
|
||||
ZeroMemory( &m_d3dpp, sizeof(m_d3dpp) );
|
||||
m_d3dpp.Windowed = bWindowed;
|
||||
m_d3dpp.BackBufferCount = 1;
|
||||
m_d3dpp.MultiSampleType = pDeviceInfo->MultiSampleType;
|
||||
//m_d3dpp.SwapEffect = D3DSWAPEFFECT_COPY ;
|
||||
m_d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD ;
|
||||
m_d3dpp.Flags=D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
|
||||
|
||||
m_d3dpp.hDeviceWindow=m_hWnd;
|
||||
m_d3dpp.EnableAutoDepthStencil=TRUE;
|
||||
|
||||
m_d3dpp.AutoDepthStencilFormat = pModeInfo->DepthStencilFormat;
|
||||
m_d3dpp.Flags=D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
|
||||
|
||||
if(bWindowed)
|
||||
{
|
||||
m_lScreenSx=m_d3dpp.BackBufferWidth = screenwidth ; //m_rcWindowClient.right - m_rcWindowClient.left;
|
||||
m_lScreenSy=m_d3dpp.BackBufferHeight = screenheight ;//m_rcWindowClient.bottom - m_rcWindowClient.top;
|
||||
|
||||
if(pAdapterInfo->d3ddmDesktop.Format==D3DFMT_X8R8G8B8)
|
||||
{
|
||||
m_d3dpp.BackBufferFormat=D3DFMT_A8R8G8B8;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_d3dpp.BackBufferFormat=pAdapterInfo->d3ddmDesktop.Format;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
m_lScreenSx=m_d3dpp.BackBufferWidth = screenwidth ; //pModeInfo->Width;
|
||||
m_lScreenSy=m_d3dpp.BackBufferHeight = screenheight ; //pModeInfo->Height;
|
||||
m_d3dpp.BackBufferFormat = pModeInfo->Format;
|
||||
m_d3dpp.FullScreen_PresentationInterval=D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||
}
|
||||
if(Editor)
|
||||
{
|
||||
if(FAILED(m_pD3D->CreateDevice( CEnumD3D::m_dwAdapter, pDeviceInfo->DeviceType,
|
||||
m_hWnd,
|
||||
//D3DCREATE_SOFTWARE_VERTEXPROCESSING,
|
||||
//D3DCREATE_MIXED_VERTEXPROCESSING,
|
||||
pModeInfo->dwBehavior,
|
||||
&m_d3dpp,
|
||||
&m_pd3dDevice )))
|
||||
{
|
||||
throw CGraphicLayerError("BaseGraphicsLayer:Create, CreateDevice is failed");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(FAILED(m_pD3D->CreateDevice( CEnumD3D::m_dwAdapter, pDeviceInfo->DeviceType,
|
||||
m_hWnd,
|
||||
//D3DCREATE_SOFTWARE_VERTEXPROCESSING,
|
||||
//D3DCREATE_MIXED_VERTEXPROCESSING,
|
||||
pModeInfo->dwBehavior,
|
||||
&m_d3dpp,
|
||||
&m_pd3dDevice )))
|
||||
{
|
||||
throw CGraphicLayerError("BaseGraphicsLayer:Create, CreateDevice is failed");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
D3DVIEWPORT8 d3dViewport ;
|
||||
d3dViewport.Width = screenwidth ;
|
||||
d3dViewport.Height = screenheight ;
|
||||
d3dViewport.X = screenx ;
|
||||
d3dViewport.Y = screeny ;
|
||||
d3dViewport.MaxZ = 1.0f ;
|
||||
d3dViewport.MinZ = 0.0f ;
|
||||
|
||||
m_pd3dDevice->SetViewport( &d3dViewport ) ;
|
||||
*/
|
||||
m_dwStartRemainTextureMemory=m_pd3dDevice->GetAvailableTextureMem();
|
||||
|
||||
//LogMessage("Direct3D Device Create");
|
||||
//LogMessage("Direct3D 7.0 Create");
|
||||
// Follow code is to Initial RenderState( light ,matrix,material);
|
||||
CTexture::Init(m_pd3dDevice);
|
||||
matrix matProj;
|
||||
float fAspect=(float)m_d3dpp.BackBufferWidth/(float)m_d3dpp.BackBufferHeight;
|
||||
fAspect=1.0f/fAspect;
|
||||
//fAspect=1.0f;
|
||||
|
||||
// edith <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>.
|
||||
matProj.MakeProjection(3.1415f/3.0f,fAspect,50.0f, 320000.0f);
|
||||
m_pd3dDevice->SetTransform(D3DTS_PROJECTION,(D3DMATRIX*)&matProj);
|
||||
matrix matView;
|
||||
matView.MakeIdent();
|
||||
m_pd3dDevice->SetTransform(D3DTS_VIEW,(D3DMATRIX*)&matView);
|
||||
matrix matWorld;
|
||||
matWorld.MakeIdent();
|
||||
m_pd3dDevice->SetTransform(D3DTS_WORLD,(D3DMATRIX*)&matWorld);
|
||||
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
|
||||
m_pd3dDevice->SetRenderState(D3DRS_LOCALVIEWER,FALSE);
|
||||
m_pd3dDevice->SetRenderState(D3DRS_CLIPPING,TRUE);
|
||||
|
||||
m_pd3dDevice->SetTextureStageState(0,D3DTSS_MAGFILTER,D3DTEXF_LINEAR);
|
||||
m_pd3dDevice->SetTextureStageState(0,D3DTSS_MINFILTER,D3DTEXF_LINEAR);
|
||||
m_pd3dDevice->SetTextureStageState(0,D3DTSS_MIPFILTER,D3DTEXF_LINEAR);
|
||||
|
||||
m_pd3dDevice->SetTextureStageState(1,D3DTSS_MAGFILTER,D3DTEXF_LINEAR);
|
||||
m_pd3dDevice->SetTextureStageState(1,D3DTSS_MINFILTER,D3DTEXF_LINEAR);
|
||||
m_pd3dDevice->SetTextureStageState(1,D3DTSS_MIPFILTER,D3DTEXF_LINEAR);
|
||||
|
||||
m_pd3dDevice->SetTextureStageState(2,D3DTSS_MAGFILTER,D3DTEXF_LINEAR);
|
||||
m_pd3dDevice->SetTextureStageState(2,D3DTSS_MINFILTER,D3DTEXF_LINEAR);
|
||||
m_pd3dDevice->SetTextureStageState(2,D3DTSS_MIPFILTER,D3DTEXF_LINEAR);
|
||||
|
||||
m_pd3dDevice->SetTextureStageState(3,D3DTSS_MAGFILTER,D3DTEXF_LINEAR);
|
||||
m_pd3dDevice->SetTextureStageState(3,D3DTSS_MINFILTER,D3DTEXF_LINEAR);
|
||||
m_pd3dDevice->SetTextureStageState(3,D3DTSS_MIPFILTER,D3DTEXF_LINEAR);
|
||||
|
||||
CROSSM::CNTexture::Init(m_pd3dDevice);
|
||||
|
||||
//m_pd3dDevice->SetRenderState(D3DRS_CLIPPING,FALSE);
|
||||
|
||||
|
||||
D3DLIGHT8 light;
|
||||
|
||||
ZeroMemory( &light, sizeof(D3DLIGHT8) );
|
||||
light.Type = D3DLIGHT_DIRECTIONAL;
|
||||
light.Diffuse.r = 1.0f;
|
||||
light.Diffuse.g = 1.0f;
|
||||
light.Diffuse.b = 1.0f;
|
||||
light.Position.x = light.Direction.x = 0.0f;
|
||||
light.Position.y = light.Direction.y = -1.0f;
|
||||
light.Position.z = light.Direction.z = 0.0f;
|
||||
light.Direction.x = 0.0f;
|
||||
light.Range = 1000.0f;
|
||||
m_pd3dDevice->SetLight( 0,&light );
|
||||
m_pd3dDevice->LightEnable( 0,TRUE);
|
||||
m_pd3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_AMBIENT,0xffffffff);
|
||||
|
||||
|
||||
D3DMATERIAL8 mtrl;
|
||||
ZeroMemory( &mtrl, sizeof(D3DMATERIAL8) );
|
||||
mtrl.Diffuse.r = mtrl.Ambient.r = 1.0f;
|
||||
mtrl.Diffuse.g = mtrl.Ambient.g = 1.0f;
|
||||
mtrl.Diffuse.b = mtrl.Ambient.b = 1.0f;
|
||||
mtrl.Diffuse.a = mtrl.Ambient.a = 1.0f;
|
||||
m_pd3dDevice->SetMaterial( &mtrl );
|
||||
|
||||
|
||||
if(m_bEditorMode)
|
||||
{
|
||||
m_pFont= new CD3DFont( _T("Arial"), 10, 0 );
|
||||
m_pFont->InitDeviceObjects( m_pd3dDevice );
|
||||
m_pFont->RestoreDeviceObjects();
|
||||
}
|
||||
else
|
||||
m_pFont = NULL;
|
||||
|
||||
// For Init View Frustum //
|
||||
m_ViewCamera.BuildFrustum(fAspect,3.1415f/3.0f,40.0f,1300000.0f);
|
||||
//LogMessage("Setting Default Device RenderState");
|
||||
|
||||
CFastMath::Init();
|
||||
|
||||
m_pd3dDevice->SetRenderState(D3DRS_RANGEFOGENABLE,TRUE);
|
||||
|
||||
//float fMipLodBias=-2.0f;
|
||||
//m_pd3dDevice->SetTextureStageState(0,D3DTSS_MIPMAPLODBIAS,*((LPDWORD)(&fMipLodBias)));
|
||||
//LogMessage("FastMath Class Init");
|
||||
}
|
||||
void BaseGraphicsLayer::GetPickPoint(long lScreenX, long lScreenY, float &fsX, float &fsY, float &fsZ)
|
||||
{
|
||||
RECT rect;
|
||||
rect.left=lScreenX;
|
||||
rect.right=lScreenX+1;
|
||||
rect.top=lScreenY;
|
||||
rect.bottom=lScreenY+1;
|
||||
POINT p;
|
||||
p.x=0;
|
||||
p.y=0;
|
||||
D3DLOCKED_RECT d3dlocked_rect;
|
||||
|
||||
LPDIRECT3DSURFACE8 pBackBuffer;
|
||||
m_pd3dDevice->GetBackBuffer(0,D3DBACKBUFFER_TYPE_MONO,&pBackBuffer);
|
||||
pBackBuffer->LockRect(&d3dlocked_rect,NULL,D3DLOCK_READONLY|D3DLOCK_NO_DIRTY_UPDATE );
|
||||
DWORD *e=(DWORD*)d3dlocked_rect.pBits;
|
||||
pBackBuffer->UnlockRect();
|
||||
pBackBuffer->Release();
|
||||
|
||||
|
||||
LPDIRECT3DSURFACE8 pZBuffer;
|
||||
m_pd3dDevice->GetDepthStencilSurface( &pZBuffer );
|
||||
pZBuffer->LockRect(&d3dlocked_rect,&rect,D3DLOCK_NO_DIRTY_UPDATE|D3DLOCK_READONLY);
|
||||
|
||||
if(d3dlocked_rect.pBits==NULL)
|
||||
return;
|
||||
BYTE *pb=(BYTE*)d3dlocked_rect.pBits;
|
||||
WORD wLen=0;
|
||||
wLen|=*(pb+1)<<8;
|
||||
wLen|=*(pb);
|
||||
pZBuffer->UnlockRect();
|
||||
pZBuffer->Release();
|
||||
|
||||
matrix matView,matProj;
|
||||
m_pd3dDevice->GetTransform(D3DTS_VIEW,(D3DMATRIX*)&matView);
|
||||
m_pd3dDevice->GetTransform(D3DTS_PROJECTION,(D3DMATRIX*)&matProj);
|
||||
|
||||
matrix matSet=matView*matProj;
|
||||
|
||||
matrix matInv;
|
||||
|
||||
//matInv.Inverse(matSet);
|
||||
float d;
|
||||
D3DXMatrixInverse((D3DXMATRIX*)&matInv,&d,(D3DXMATRIX*)&matSet);
|
||||
|
||||
float fX,fY,fZ;
|
||||
fX=2.0/m_d3dpp.BackBufferWidth;
|
||||
fY=2.0/m_d3dpp.BackBufferHeight;
|
||||
|
||||
fZ=(float)wLen/(float)0xffff;
|
||||
fX=lScreenX*(fX)-1.0f;
|
||||
fY=1.0f-(lScreenY)*(fY);
|
||||
|
||||
float fXp=matInv._11*fX + matInv._21*fY + matInv._31*fZ + matInv._41;
|
||||
float fYp=matInv._12*fX + matInv._22*fY + matInv._32*fZ + matInv._42;
|
||||
float fZp=matInv._13*fX + matInv._23*fY + matInv._33*fZ + matInv._43;
|
||||
float fWp=matInv._14*fX + matInv._24*fY + matInv._34*fZ + matInv._44;
|
||||
|
||||
fsX=fXp/fWp;
|
||||
fsY=fYp/fWp;
|
||||
fsZ=fZp/fWp;
|
||||
}
|
||||
|
||||
void BaseGraphicsLayer::Flip()
|
||||
{
|
||||
//RECT rect={100,100,800,600};
|
||||
m_pd3dDevice->Present(NULL,NULL,m_hWnd,NULL);
|
||||
//m_pd3dDevice->Present(&rect,&rect,NULL,NULL);
|
||||
|
||||
/*
|
||||
LPDIRECT3DSURFACE8 pddsFrontBuffer,pddsBackBuffer;
|
||||
m_pd3dDevice->GetBackBuffer(0,D3DBACKBUFFER_TYPE_MONO,&pddsBackBuffer);
|
||||
m_pd3dDevice->GetFrontBuffer(&pddsFrontBuffer);
|
||||
RECT rect={0,0,800,600};
|
||||
POINT pt={0,0};
|
||||
m_pd3dDevice->CopyRects(pddsBackBuffer,&rect,0,pddsFrontBuffer,&pt);
|
||||
pddsFrontBuffer->Release();
|
||||
pddsBackBuffer->Release();
|
||||
*/
|
||||
}
|
||||
|
||||
void BaseGraphicsLayer::PrefareRender()
|
||||
{
|
||||
m_pd3dDevice->SetTransform(D3DTS_VIEW,m_ViewCamera.GetMatView());
|
||||
m_pd3dDevice->Clear( 0, NULL, D3DCLEAR_ZBUFFER|D3DCLEAR_TARGET, m_ClearColor.c, 1.0f, 0 );
|
||||
}
|
||||
|
||||
void BaseGraphicsLayer::ShowState()
|
||||
{
|
||||
m_pd3dDevice->SetRenderState( D3DRS_LIGHTING,FALSE);
|
||||
m_pd3dDevice->SetRenderState( D3DRS_FOGENABLE,FALSE);
|
||||
/*
|
||||
TLVertex NSVertex[4];
|
||||
float fZvalue=0.01f;
|
||||
float fProjectedPositionW=0.01f;
|
||||
|
||||
NSVertex[0].v=vector3(0.0f,100.0f,fZvalue);
|
||||
NSVertex[0].tu=0.0f;
|
||||
NSVertex[0].tv=1.0f;
|
||||
NSVertex[1].v=vector3(0.0f,0.0f,fZvalue);
|
||||
NSVertex[1].tu=0.0f;
|
||||
NSVertex[1].tv=0.0f;
|
||||
NSVertex[2].v=vector3(100.0f,100.0f,fZvalue);
|
||||
NSVertex[2].tu=1.0f;
|
||||
NSVertex[2].tv=1.0f;
|
||||
NSVertex[3].v=vector3(100.0f,0.0f,fZvalue);
|
||||
NSVertex[3].tu=1.0f;
|
||||
NSVertex[3].tv=0.0f;
|
||||
|
||||
NSVertex[0].v=vector3(100.0f,100.0f,fZvalue);
|
||||
NSVertex[1].v=vector3(100.0f,100.0f,fZvalue);
|
||||
NSVertex[2].v=vector3(100.0f,100.0f,fZvalue);
|
||||
NSVertex[3].v=vector3(100.0f,100.0f,fZvalue);
|
||||
|
||||
float fNsSize=100.0f;
|
||||
|
||||
NSVertex[0].v.x+=fNsSize*cosf(0.0f + 3.14159f*(0.75f) - m_ViewCamera.GetRotationY() );
|
||||
NSVertex[0].v.y+=fNsSize*sinf(0.0f + 3.14159f*(0.75f) - m_ViewCamera.GetRotationY() );
|
||||
|
||||
NSVertex[1].v.x+=fNsSize*cosf(3.1415f*0.5f+ 3.14159f*(0.75f) - m_ViewCamera.GetRotationY() );
|
||||
NSVertex[1].v.y+=fNsSize*sinf(3.1415f*0.5f+ 3.14159f*(0.75f) - m_ViewCamera.GetRotationY() );
|
||||
|
||||
NSVertex[2].v.x+=fNsSize*cosf(3.1415f*1.5f+ 3.14159f*(0.75f) - m_ViewCamera.GetRotationY() );
|
||||
NSVertex[2].v.y+=fNsSize*sinf(3.1415f*1.5f+ 3.14159f*(0.75f) - m_ViewCamera.GetRotationY() );
|
||||
|
||||
NSVertex[3].v.x+=fNsSize*cosf(3.1415f+ 3.14159f*(0.75f) - m_ViewCamera.GetRotationY() );
|
||||
NSVertex[3].v.y+=fNsSize*sinf(3.1415f+ 3.14159f*(0.75f) - m_ViewCamera.GetRotationY() );
|
||||
|
||||
|
||||
NSVertex[0].w=fProjectedPositionW;
|
||||
NSVertex[1].w=fProjectedPositionW;
|
||||
NSVertex[2].w=fProjectedPositionW;
|
||||
NSVertex[3].w=fProjectedPositionW;
|
||||
|
||||
NSVertex[0].Diffuse.c=0xff000000;
|
||||
NSVertex[1].Diffuse.c=0xff000000;
|
||||
NSVertex[2].Diffuse.c=0xff000000;
|
||||
NSVertex[3].Diffuse.c=0xff000000;
|
||||
NSVertex[0].Specular.c=0x0;
|
||||
NSVertex[1].Specular.c=0x0;
|
||||
NSVertex[2].Specular.c=0x0;
|
||||
NSVertex[3].Specular.c=0x0;
|
||||
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
|
||||
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
||||
|
||||
m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE,TRUE);
|
||||
m_pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
m_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
|
||||
|
||||
|
||||
m_pd3dDevice->SetVertexShader(TLVERTEXFVF);
|
||||
m_pd3dDevice->SetTexture(0,m_NsTexture.GetTexture());
|
||||
m_pd3dDevice->SetTexture(1,NULL);
|
||||
m_pd3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,NSVertex,sizeof(TLVertex));
|
||||
m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE,FALSE);
|
||||
//*/
|
||||
|
||||
static FLOAT fLastTime = 0.0f;
|
||||
static DWORD dwFrames = 0L;
|
||||
|
||||
static char strFrameStats[256];
|
||||
FLOAT fTime = DXUtil_Timer( TIMER_GETABSOLUTETIME );
|
||||
++dwFrames;
|
||||
|
||||
// Update the scene stats once per second
|
||||
if( fTime - fLastTime > 1.0f )
|
||||
{
|
||||
float fFPS = dwFrames / (fTime - fLastTime);
|
||||
fLastTime = fTime;
|
||||
dwFrames = 0L;
|
||||
sprintf( strFrameStats, "%.02f fps", fFPS);
|
||||
}
|
||||
|
||||
// edith 2008.01.18 ShowState
|
||||
if(m_bEditorMode)
|
||||
{
|
||||
m_pFont->DrawText( 2, 40, D3DCOLOR_ARGB(255,255,0,0),strFrameStats);
|
||||
|
||||
static char strSectorPos[256];
|
||||
|
||||
matrix *matPos=m_ViewCamera.GetMatPosition();
|
||||
sprintf(strSectorPos,"sSector-X = %d , Sector-Y = %d",(int)(matPos->_41/(63.0f*500.0f)),(int)(matPos->_43/(63.0f*500.0f)));
|
||||
m_pFont->DrawText( 2, 60, D3DCOLOR_ARGB(255,255,0,0),strSectorPos);
|
||||
|
||||
sprintf(strSectorPos,"Viewer Position x=%.2f y=%.2f z=%.2f",matPos->_41,matPos->_42,matPos->_43);
|
||||
m_pFont->DrawText( 2, 80, D3DCOLOR_ARGB(255,255,0,0),strSectorPos);
|
||||
|
||||
m_dwAbleTextureMemory=m_pd3dDevice->GetAvailableTextureMem();
|
||||
|
||||
sprintf(strSectorPos,"Total used texture memory %d ",m_dwStartRemainTextureMemory-m_dwAbleTextureMemory);
|
||||
m_pFont->DrawText( 2, 100, D3DCOLOR_ARGB(255,255,0,0),strSectorPos);
|
||||
|
||||
sprintf(strSectorPos,"Remain Texture memory %d ",m_dwAbleTextureMemory);
|
||||
m_pFont->DrawText( 2, 120, D3DCOLOR_ARGB(255,255,0,0),strSectorPos);
|
||||
|
||||
for (size_t i = 0; i < 10; ++i)
|
||||
{
|
||||
if(strlen(m_aszCustomMsg[i]) == 0)
|
||||
continue;
|
||||
|
||||
m_pFont->DrawText( 2, 155 + i*20, D3DCOLOR_ARGB(255,255,0,0),m_aszCustomMsg[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
bool BaseGraphicsLayer::TransformVector(vector3 &t,vector3 &vecResult,float &w)
|
||||
{
|
||||
DWORD dwClipWidth;
|
||||
DWORD dwClipHeight;
|
||||
|
||||
|
||||
dwClipWidth=m_d3dpp.BackBufferWidth/2;
|
||||
dwClipHeight=m_d3dpp.BackBufferHeight/2;
|
||||
|
||||
//dwClipWidth=256/2.0f;
|
||||
//dwClipHeight=256/2.0f;
|
||||
|
||||
|
||||
|
||||
matrix matWorld,matView,matProj;
|
||||
m_pd3dDevice->GetTransform(D3DTS_WORLD,(D3DMATRIX*)&matWorld);
|
||||
m_pd3dDevice->GetTransform(D3DTS_VIEW,(D3DMATRIX*)&matView);
|
||||
m_pd3dDevice->GetTransform(D3DTS_PROJECTION,(D3DMATRIX*)&matProj);
|
||||
//matrix matSet=matProj*matView;
|
||||
matrix matSet=matView*matProj;
|
||||
|
||||
float x,y,z;
|
||||
x=t.x;
|
||||
y=t.y;
|
||||
z=t.z;
|
||||
|
||||
float xp = matSet._11*x + matSet._21*y + matSet._31*z + matSet._41;
|
||||
float yp = matSet._12*x + matSet._22*y + matSet._32*z + matSet._42;
|
||||
float zp = matSet._13*x + matSet._23*y + matSet._33*z + matSet._43;
|
||||
float wp = matSet._14*x + matSet._24*y + matSet._34*z + matSet._44;
|
||||
vector3 vecTansform;
|
||||
vecTansform.x= ( 1.0f + (xp/wp) ) * dwClipWidth;
|
||||
vecTansform.y= ( 1.0f - (yp/wp) ) * dwClipHeight;
|
||||
vecTansform.z= zp / wp;
|
||||
w = wp;
|
||||
|
||||
vecResult=vecTansform;
|
||||
if( 0.0f < vecTansform.x &&
|
||||
vecTansform.x < m_d3dpp.BackBufferWidth &&
|
||||
0.0f < vecTansform.y &&
|
||||
vecTansform.y < m_d3dpp.BackBufferHeight)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool BaseGraphicsLayer::TransformVector(const vector3 &vSource, const matrix& mTransform, vector3 &vResult,float &w)
|
||||
{
|
||||
DWORD dwClipWidth;
|
||||
DWORD dwClipHeight;
|
||||
|
||||
dwClipWidth=m_d3dpp.BackBufferWidth/2;
|
||||
dwClipHeight=m_d3dpp.BackBufferHeight/2;
|
||||
|
||||
float x,y,z;
|
||||
x=vSource.x;
|
||||
y=vSource.y;
|
||||
z=vSource.z;
|
||||
|
||||
float xp = mTransform._11*x + mTransform._21*y + mTransform._31*z + mTransform._41;
|
||||
float yp = mTransform._12*x + mTransform._22*y + mTransform._32*z + mTransform._42;
|
||||
float zp = mTransform._13*x + mTransform._23*y + mTransform._33*z + mTransform._43;
|
||||
float wp = mTransform._14*x + mTransform._24*y + mTransform._34*z + mTransform._44;
|
||||
vector3 vecTansform;
|
||||
vecTansform.x= ( 1.0f + (xp/wp) ) * dwClipWidth;
|
||||
vecTansform.y= ( 1.0f - (yp/wp) ) * dwClipHeight;
|
||||
vecTansform.z= zp / wp;
|
||||
w = wp;
|
||||
|
||||
vResult=vecTansform;
|
||||
if( 0.0f < vecTansform.x &&
|
||||
vecTansform.x < m_d3dpp.BackBufferWidth &&
|
||||
0.0f < vecTansform.y &&
|
||||
vecTansform.y < m_d3dpp.BackBufferHeight)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void BaseGraphicsLayer::ManyTransformVector(vector3 *t, vector3 *result, float *w)
|
||||
{
|
||||
/*
|
||||
DWORD dwClipWidth=m_d3dpp.BackBufferWidth/2;
|
||||
DWORD dwClipHeight=m_d3dpp.BackBufferHeight/2;
|
||||
|
||||
matrix matView,matProj;
|
||||
m_pd3dDevice->GetTransform(D3DTS_VIEW,(D3DMATRIX*)&matView);
|
||||
m_pd3dDevice->GetTransform(D3DTS_PROJECTION,(D3DMATRIX*)&matProj);
|
||||
//matrix matSet=matProj*matView;
|
||||
matrix matSet=matView*matProj;
|
||||
|
||||
float x,y,z;
|
||||
x=t.x;
|
||||
y=t.y;
|
||||
z=t.z;
|
||||
|
||||
float xp = matSet._11*x + matSet._21*y + matSet._31*z + matSet._41;
|
||||
float yp = matSet._12*x + matSet._22*y + matSet._32*z + matSet._42;
|
||||
float zp = matSet._13*x + matSet._23*y + matSet._33*z + matSet._43;
|
||||
float wp = matSet._14*x + matSet._24*y + matSet._34*z + matSet._44;
|
||||
vector3 vecTansform;
|
||||
vecTansform.x= ( 1.0f + (xp/wp) ) * dwClipWidth;
|
||||
vecTansform.y= ( 1.0f - (yp/wp) ) * dwClipHeight;
|
||||
vecTansform.z= zp / wp;
|
||||
w = wp;
|
||||
|
||||
vecResult=vecTansform;
|
||||
if( 0.0f < vecTansform.x &&
|
||||
vecTansform.x < m_d3dpp.BackBufferWidth &&
|
||||
0.0f < vecTansform.y &&
|
||||
vecTansform.y < m_d3dpp.BackBufferHeight)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
*/
|
||||
}
|
||||
|
||||
void BaseGraphicsLayer::RectFlip(std::vector<RECT> &RectList)
|
||||
{
|
||||
for(int i=0;i<(int)RectList.size();i++)
|
||||
{
|
||||
m_pd3dDevice->Present(&RectList[i],&RectList[i],NULL,NULL);
|
||||
}
|
||||
}
|
||||
|
||||
bool BaseGraphicsLayer::ProjectiveTextureMapping(vector3 vecPoint, float &fTu, float &fTv)
|
||||
{
|
||||
vector3 vecFrontPlaneNormal=(m_ViewCamera.m_vecFrustumNear[1]-m_ViewCamera.m_vecFrustumNear[0])^(m_ViewCamera.m_vecFrustumNear[2]-m_ViewCamera.m_vecFrustumNear[1]);
|
||||
vecFrontPlaneNormal.Normalize();
|
||||
//vecFrontPlaneNormal=-vecFrontPlaneNormal;
|
||||
|
||||
vector3 vecPos=m_ViewCamera.GetMatPosition()->GetLoc();
|
||||
|
||||
float fInter=CIntersection::PointFromPlane(vecFrontPlaneNormal,vecPos,vecPoint);
|
||||
|
||||
// TU
|
||||
float fUInter=CIntersection::PointFromPlane(m_ViewCamera.m_vecCenterAxis[0],vecPos,vecPoint);
|
||||
|
||||
// TV
|
||||
float fVInter=CIntersection::PointFromPlane(m_ViewCamera.m_vecCenterAxis[1],vecPos,vecPoint);
|
||||
|
||||
float fNormalSize=tanf(3.14159f/6.0f)*fInter;
|
||||
|
||||
fTu=fUInter/fNormalSize;
|
||||
fTu=fTu*0.5f+0.5f;
|
||||
|
||||
float fAspect=(float)m_lScreenSx/(float)m_lScreenSy;
|
||||
|
||||
fNormalSize=tanf((3.14159f/6.0f))*fInter*fAspect;
|
||||
fTv=fVInter/fNormalSize;
|
||||
fTv=fTv*0.5f+0.5f;
|
||||
|
||||
vecFrontPlaneNormal^vector3(0.0f,1.0f,0.0f);
|
||||
|
||||
return false;
|
||||
|
||||
/*
|
||||
if(fInter>=0.0f)
|
||||
return true;
|
||||
return false;
|
||||
*/
|
||||
}
|
||||
|
||||
void BaseGraphicsLayer::SetCustomMsg(size_t index, const char* sz)
|
||||
{
|
||||
if (index >= 10)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
strncpy(m_aszCustomMsg[index], sz, 299);
|
||||
m_aszCustomMsg[index][299] = '\0';
|
||||
}
|
||||
|
||||
void BaseGraphicsLayer::DrawText(float x, float y, DWORD dwColor, char*szText)
|
||||
{
|
||||
if (NULL == m_pFont)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_pFont->DrawText(x, y, dwColor, szText);
|
||||
}
|
||||
78
Engine/Zalla3D Base Class/BaseGraphicsLayer.h
Normal file
78
Engine/Zalla3D Base Class/BaseGraphicsLayer.h
Normal file
@@ -0,0 +1,78 @@
|
||||
// BaseGraphic.h: interface for the BaseGraphic class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_BASEGRAPHIC_H__D2B16AD2_C324_44D0_A581_93528EA232C2__INCLUDED_)
|
||||
#define AFX_BASEGRAPHIC_H__D2B16AD2_C324_44D0_A581_93528EA232C2__INCLUDED_
|
||||
|
||||
#include "VECTOR.h" // Added by ClassView
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include <d3d8.h>
|
||||
|
||||
#include "ViewCamera.h"
|
||||
#include "list.h"
|
||||
//#include <Utility/Exception.h>
|
||||
#include "Texture.h"
|
||||
#include "EnumD3D.h"
|
||||
#include "D3DFont.h"
|
||||
#include "StateLog.h"
|
||||
|
||||
class BaseGraphicsLayer
|
||||
{
|
||||
static HWND m_hWnd;
|
||||
static LPDIRECT3DDEVICE8 m_pd3dDevice;
|
||||
static LPDIRECT3D8 m_pD3D;
|
||||
bool m_bWindowed;
|
||||
bool m_bEditorMode;
|
||||
//Projection Parameter//
|
||||
float m_fFov,m_fNear,m_fFar;
|
||||
//NS//
|
||||
CTexture m_NsTexture;
|
||||
DWORD m_dwStartRemainTextureMemory;
|
||||
DWORD m_dwAbleTextureMemory;
|
||||
|
||||
public :
|
||||
static int m_iGraphicCards;
|
||||
|
||||
public:
|
||||
static bool ProjectiveTextureMapping(vector3 vecPoint,float &fTu,float &fTv);
|
||||
void RectFlip(std::vector<RECT> &RectList);
|
||||
static long m_lScreenSx,m_lScreenSy;
|
||||
static CD3DFont* m_pFont; // Font for drawing text
|
||||
static D3DPRESENT_PARAMETERS m_d3dpp;
|
||||
RECT m_rcWindowBounds;
|
||||
RECT m_rcWindowClient;
|
||||
static bool m_VoodooOption;
|
||||
|
||||
static HWND GethWnd(){return m_hWnd;};
|
||||
|
||||
|
||||
void ManyTransformVector(vector3 *t,vector3 *result,float *w);
|
||||
static bool TransformVector(vector3 &t,vector3 &vecResult,float &w);
|
||||
static bool TransformVector(const vector3 &vSource, const matrix& mTransform, vector3 &vResult,float &w);
|
||||
void ShowState();
|
||||
void PrefareRender();
|
||||
void Flip();
|
||||
void GetPickPoint(long lScreenX,long lScreenY,float &fsX,float &fsY,float &fsZ);
|
||||
|
||||
static void DrawText(float x, float y, DWORD dwColor, char*szText);
|
||||
static CViewCamera m_ViewCamera;
|
||||
static color m_ClearColor;
|
||||
|
||||
|
||||
void Create(HWND hWnd,bool bWindowed,bool Editor,long screenx,long screeny, long screenwidth, long screenheight);
|
||||
BaseGraphicsLayer();
|
||||
virtual ~BaseGraphicsLayer();
|
||||
static LPDIRECT3DDEVICE8 GetDevice(){return m_pd3dDevice;};
|
||||
static int GetGraphicCard() { return m_iGraphicCards;}
|
||||
|
||||
static void SetCustomMsg(size_t index, const char* sz);
|
||||
|
||||
|
||||
static char m_aszCustomMsg[10][300];
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_BASEGRAPHIC_H__D2B16AD2_C324_44D0_A581_93528EA232C2__INCLUDED_)
|
||||
55
Engine/Zalla3D Base Class/Bitset.h
Normal file
55
Engine/Zalla3D Base Class/Bitset.h
Normal file
@@ -0,0 +1,55 @@
|
||||
#pragma once
|
||||
|
||||
class CBitset
|
||||
{
|
||||
protected:
|
||||
unsigned int *m_pBits; // Bit Set ptr
|
||||
int m_iBitSize; // Bit Set Size
|
||||
|
||||
public:
|
||||
CBitset()
|
||||
{
|
||||
m_pBits = NULL;
|
||||
m_iBitSize = 0;
|
||||
}
|
||||
~CBitset()
|
||||
{
|
||||
if(m_pBits)
|
||||
{
|
||||
delete[] m_pBits;
|
||||
m_pBits = NULL;
|
||||
}
|
||||
}
|
||||
void ResizeBits(int iNewCount)
|
||||
{
|
||||
|
||||
m_iBitSize = iNewCount / 32 + 1; // Get Inteager Size
|
||||
if(m_pBits)
|
||||
{
|
||||
delete[] m_pBits;
|
||||
m_pBits = NULL;
|
||||
}
|
||||
m_pBits = new unsigned int[m_iBitSize]; // Allocate Bits
|
||||
ClearBits();
|
||||
|
||||
}
|
||||
void ClearBits()
|
||||
{ // Clear All Bits
|
||||
memset(m_pBits,0,sizeof(unsigned int) * m_iBitSize);
|
||||
}
|
||||
|
||||
void ClearOneBit(int index)
|
||||
{
|
||||
m_pBits[ index >> 5 ] &= ~( 1 << ( index & 31 ) );
|
||||
}
|
||||
|
||||
void SetBit(int index) { // Set Bit
|
||||
m_pBits[ index >> 5 ] |= ( 1 << ( index & 31 ) );
|
||||
|
||||
}
|
||||
bool GetBit(int index) { // Return Bit's Setting : return true or false
|
||||
|
||||
return (m_pBits[ index >> 5 ] & ( 1 << (index & 31 ) )) ? true : false;
|
||||
|
||||
}
|
||||
};
|
||||
BIN
Engine/Zalla3D Base Class/Boost/Boost-old.zip
Normal file
BIN
Engine/Zalla3D Base Class/Boost/Boost-old.zip
Normal file
Binary file not shown.
70
Engine/Zalla3D Base Class/Boost/config.hpp
Normal file
70
Engine/Zalla3D Base Class/Boost/config.hpp
Normal file
@@ -0,0 +1,70 @@
|
||||
// Boost config.hpp configuration header file ------------------------------//
|
||||
|
||||
// (C) Copyright John Maddock 2002.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/libs/config for most recent version.
|
||||
|
||||
// Boost config.hpp policy and rationale documentation has been moved to
|
||||
// http://www.boost.org/libs/config
|
||||
//
|
||||
// CAUTION: This file is intended to be completely stable -
|
||||
// DO NOT MODIFY THIS FILE!
|
||||
//
|
||||
|
||||
#ifndef BOOST_CONFIG_HPP
|
||||
#define BOOST_CONFIG_HPP
|
||||
|
||||
// if we don't have a user config, then use the default location:
|
||||
#if !defined(BOOST_USER_CONFIG) && !defined(BOOST_NO_USER_CONFIG)
|
||||
# define BOOST_USER_CONFIG <boost/config/user.hpp>
|
||||
#endif
|
||||
// include it first:
|
||||
#ifdef BOOST_USER_CONFIG
|
||||
# include BOOST_USER_CONFIG
|
||||
#endif
|
||||
|
||||
// if we don't have a compiler config set, try and find one:
|
||||
#if !defined(BOOST_COMPILER_CONFIG) && !defined(BOOST_NO_COMPILER_CONFIG) && !defined(BOOST_NO_CONFIG)
|
||||
# include <boost/config/select_compiler_config.hpp>
|
||||
#endif
|
||||
// if we have a compiler config, include it now:
|
||||
#ifdef BOOST_COMPILER_CONFIG
|
||||
# include BOOST_COMPILER_CONFIG
|
||||
#endif
|
||||
|
||||
// if we don't have a std library config set, try and find one:
|
||||
#if !defined(BOOST_STDLIB_CONFIG) && !defined(BOOST_NO_STDLIB_CONFIG) && !defined(BOOST_NO_CONFIG)
|
||||
# include <boost/config/select_stdlib_config.hpp>
|
||||
#endif
|
||||
// if we have a std library config, include it now:
|
||||
#ifdef BOOST_STDLIB_CONFIG
|
||||
# include BOOST_STDLIB_CONFIG
|
||||
#endif
|
||||
|
||||
// if we don't have a platform config set, try and find one:
|
||||
#if !defined(BOOST_PLATFORM_CONFIG) && !defined(BOOST_NO_PLATFORM_CONFIG) && !defined(BOOST_NO_CONFIG)
|
||||
# include <boost/config/select_platform_config.hpp>
|
||||
#endif
|
||||
// if we have a platform config, include it now:
|
||||
#ifdef BOOST_PLATFORM_CONFIG
|
||||
# include BOOST_PLATFORM_CONFIG
|
||||
#endif
|
||||
|
||||
// get config suffix code:
|
||||
#include <boost/config/suffix.hpp>
|
||||
|
||||
#endif // BOOST_CONFIG_HPP
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
170
Engine/Zalla3D Base Class/Boost/config/compiler/visualc.hpp
Normal file
170
Engine/Zalla3D Base Class/Boost/config/compiler/visualc.hpp
Normal file
@@ -0,0 +1,170 @@
|
||||
// (C) Copyright John Maddock 2001 - 2003.
|
||||
// (C) Copyright Darin Adler 2001 - 2002.
|
||||
// (C) Copyright Peter Dimov 2001.
|
||||
// (C) Copyright Aleksey Gurtovoy 2002.
|
||||
// (C) Copyright David Abrahams 2002 - 2003.
|
||||
// (C) Copyright Beman Dawes 2002 - 2003.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for most recent version.
|
||||
|
||||
// Microsoft Visual C++ compiler setup:
|
||||
|
||||
#define BOOST_MSVC _MSC_VER
|
||||
|
||||
// turn off the warnings before we #include anything
|
||||
#pragma warning( disable : 4503 ) // warning: decorated name length exceeded
|
||||
|
||||
#if _MSC_VER < 1300 // 1200 == VC++ 6.0, 1200-1202 == eVC++4
|
||||
# pragma warning( disable : 4786 ) // ident trunc to '255' chars in debug info
|
||||
# define BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS
|
||||
# define BOOST_NO_VOID_RETURNS
|
||||
# define BOOST_NO_EXCEPTION_STD_NAMESPACE
|
||||
// disable min/max macro defines on vc6:
|
||||
//
|
||||
#endif
|
||||
|
||||
#if (_MSC_VER <= 1300) // 1300 == VC++ 7.0
|
||||
|
||||
# if !defined(_MSC_EXTENSIONS) && !defined(BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS) // VC7 bug with /Za
|
||||
# define BOOST_NO_DEPENDENT_TYPES_IN_TEMPLATE_VALUE_PARAMETERS
|
||||
# endif
|
||||
|
||||
# define BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS
|
||||
# define BOOST_NO_INCLASS_MEMBER_INITIALIZATION
|
||||
# define BOOST_NO_PRIVATE_IN_AGGREGATE
|
||||
# define BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
|
||||
# define BOOST_NO_INTEGRAL_INT64_T
|
||||
# define BOOST_NO_DEDUCED_TYPENAME
|
||||
# define BOOST_NO_USING_DECLARATION_OVERLOADS_FROM_TYPENAME_BASE
|
||||
|
||||
// VC++ 6/7 has member templates but they have numerous problems including
|
||||
// cases of silent failure, so for safety we define:
|
||||
# define BOOST_NO_MEMBER_TEMPLATES
|
||||
// For VC++ experts wishing to attempt workarounds, we define:
|
||||
# define BOOST_MSVC6_MEMBER_TEMPLATES
|
||||
|
||||
# define BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
# define BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
# define BOOST_NO_CV_VOID_SPECIALIZATIONS
|
||||
# define BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
# define BOOST_NO_USING_TEMPLATE
|
||||
# define BOOST_NO_SWPRINTF
|
||||
# define BOOST_NO_TEMPLATE_TEMPLATES
|
||||
# define BOOST_NO_SFINAE
|
||||
# define BOOST_NO_POINTER_TO_MEMBER_TEMPLATE_PARAMETERS
|
||||
# define BOOST_NO_IS_ABSTRACT
|
||||
// TODO: what version is meant here? Have there really been any fixes in cl 12.01 (as e.g. shipped with eVC4)?
|
||||
# if (_MSC_VER > 1200)
|
||||
# define BOOST_NO_MEMBER_FUNCTION_SPECIALIZATIONS
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
#if _MSC_VER < 1400
|
||||
// although a conforming signature for swprint exists in VC7.1
|
||||
// it appears not to actually work:
|
||||
# define BOOST_NO_SWPRINTF
|
||||
#endif
|
||||
|
||||
#if _MSC_VER <= 1400 // 1400 == VC++ 8.0
|
||||
# define BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
#endif
|
||||
|
||||
#ifndef _NATIVE_WCHAR_T_DEFINED
|
||||
# define BOOST_NO_INTRINSIC_WCHAR_T
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
# define BOOST_NO_THREADEX
|
||||
# define BOOST_NO_GETSYSTEMTIMEASFILETIME
|
||||
#endif
|
||||
|
||||
//
|
||||
// check for exception handling support:
|
||||
#ifndef _CPPUNWIND
|
||||
# define BOOST_NO_EXCEPTIONS
|
||||
#endif
|
||||
|
||||
//
|
||||
// __int64 support:
|
||||
//
|
||||
#if (_MSC_VER >= 1200)
|
||||
# define BOOST_HAS_MS_INT64
|
||||
#endif
|
||||
#if (_MSC_VER >= 1310) && defined(_MSC_EXTENSIONS)
|
||||
# define BOOST_HAS_LONG_LONG
|
||||
#endif
|
||||
#if (_MSC_VER >= 1400) && !defined(_DEBUG)
|
||||
# define BOOST_HAS_NRVO
|
||||
#endif
|
||||
//
|
||||
// disable Win32 API's if compiler extentions are
|
||||
// turned off:
|
||||
//
|
||||
#ifndef _MSC_EXTENSIONS
|
||||
# define BOOST_DISABLE_WIN32
|
||||
#endif
|
||||
|
||||
//
|
||||
// all versions support __declspec:
|
||||
//
|
||||
#define BOOST_HAS_DECLSPEC
|
||||
//
|
||||
// prefix and suffix headers:
|
||||
//
|
||||
#ifndef BOOST_ABI_PREFIX
|
||||
# define BOOST_ABI_PREFIX "boost/config/abi/msvc_prefix.hpp"
|
||||
#endif
|
||||
#ifndef BOOST_ABI_SUFFIX
|
||||
# define BOOST_ABI_SUFFIX "boost/config/abi/msvc_suffix.hpp"
|
||||
#endif
|
||||
|
||||
// TODO:
|
||||
// these things are mostly bogus. 1200 means version 12.0 of the compiler. The
|
||||
// artificial versions assigned to them only refer to the versions of some IDE
|
||||
// these compilers have been shipped with, and even that is not all of it. Some
|
||||
// were shipped with freely downloadable SDKs, others as crosscompilers in eVC.
|
||||
// IOW, you can't use these 'versions' in any sensible way. Sorry.
|
||||
# if defined(UNDER_CE)
|
||||
# if _MSC_VER < 1200
|
||||
// Note: these are so far off, they are not really supported
|
||||
# elif _MSC_VER < 1300 // eVC++ 4 comes with 1200-1202
|
||||
# define BOOST_COMPILER_VERSION evc4.0
|
||||
# elif _MSC_VER == 1400
|
||||
# define BOOST_COMPILER_VERSION evc8
|
||||
# else
|
||||
# if defined(BOOST_ASSERT_CONFIG)
|
||||
# error "Unknown EVC++ compiler version - please run the configure tests and report the results"
|
||||
# else
|
||||
# pragma message("Unknown EVC++ compiler version - please run the configure tests and report the results")
|
||||
# endif
|
||||
# endif
|
||||
# else
|
||||
# if _MSC_VER < 1200
|
||||
// Note: these are so far off, they are not really supported
|
||||
# define BOOST_COMPILER_VERSION 5.0
|
||||
# elif _MSC_VER < 1300
|
||||
# define BOOST_COMPILER_VERSION 6.0
|
||||
# elif _MSC_VER == 1300
|
||||
# define BOOST_COMPILER_VERSION 7.0
|
||||
# elif _MSC_VER == 1310
|
||||
# define BOOST_COMPILER_VERSION 7.1
|
||||
# elif _MSC_VER == 1400
|
||||
# define BOOST_COMPILER_VERSION 8.0
|
||||
# else
|
||||
# define BOOST_COMPILER_VERSION _MSC_VER
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#define BOOST_COMPILER "Microsoft Visual C++ version " BOOST_STRINGIZE(BOOST_COMPILER_VERSION)
|
||||
|
||||
//
|
||||
// versions check:
|
||||
// we don't support Visual C++ prior to version 6:
|
||||
#if _MSC_VER < 1200
|
||||
#error "Compiler not supported or configured - please reconfigure"
|
||||
#endif
|
||||
//
|
||||
28
Engine/Zalla3D Base Class/Boost/config/no_tr1/utility.hpp
Normal file
28
Engine/Zalla3D Base Class/Boost/config/no_tr1/utility.hpp
Normal file
@@ -0,0 +1,28 @@
|
||||
// (C) Copyright John Maddock 2005.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// The aim of this header is just to include <utility> but to do
|
||||
// so in a way that does not result in recursive inclusion of
|
||||
// the Boost TR1 components if boost/tr1/tr1/utility is in the
|
||||
// include search path. We have to do this to avoid circular
|
||||
// dependencies:
|
||||
//
|
||||
|
||||
#ifndef BOOST_CONFIG_UTILITY
|
||||
# define BOOST_CONFIG_UTILITY
|
||||
|
||||
# ifndef BOOST_TR1_NO_RECURSION
|
||||
# define BOOST_TR1_NO_RECURSION
|
||||
# define BOOST_CONFIG_NO_UTILITY_RECURSION
|
||||
# endif
|
||||
|
||||
# include <utility>
|
||||
|
||||
# ifdef BOOST_CONFIG_NO_UTILITY_RECURSION
|
||||
# undef BOOST_TR1_NO_RECURSION
|
||||
# undef BOOST_CONFIG_NO_UTILITY_RECURSION
|
||||
# endif
|
||||
|
||||
#endif
|
||||
58
Engine/Zalla3D Base Class/Boost/config/platform/win32.hpp
Normal file
58
Engine/Zalla3D Base Class/Boost/config/platform/win32.hpp
Normal file
@@ -0,0 +1,58 @@
|
||||
// (C) Copyright John Maddock 2001 - 2003.
|
||||
// (C) Copyright Bill Kempf 2001.
|
||||
// (C) Copyright Aleksey Gurtovoy 2003.
|
||||
// (C) Copyright Rene Rivera 2005.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for most recent version.
|
||||
|
||||
// Win32 specific config options:
|
||||
|
||||
#define BOOST_PLATFORM "Win32"
|
||||
|
||||
// Get the information about the MinGW runtime, i.e. __MINGW32_*VERSION.
|
||||
#if defined(__MINGW32__)
|
||||
# include <_mingw.h>
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && !defined(BOOST_NO_SWPRINTF)
|
||||
# define BOOST_NO_SWPRINTF
|
||||
#endif
|
||||
|
||||
#if !defined(__GNUC__) && !defined(BOOST_HAS_DECLSPEC)
|
||||
# define BOOST_HAS_DECLSPEC
|
||||
#endif
|
||||
|
||||
#if defined(__MINGW32__) && ((__MINGW32_MAJOR_VERSION > 2) || ((__MINGW32_MAJOR_VERSION == 2) && (__MINGW32_MINOR_VERSION >= 0)))
|
||||
# define BOOST_HAS_STDINT_H
|
||||
# define __STDC_LIMIT_MACROS
|
||||
# define BOOST_HAS_DIRENT_H
|
||||
# define BOOST_HAS_UNISTD_H
|
||||
#endif
|
||||
|
||||
//
|
||||
// Win32 will normally be using native Win32 threads,
|
||||
// but there is a pthread library avaliable as an option,
|
||||
// we used to disable this when BOOST_DISABLE_WIN32 was
|
||||
// defined but no longer - this should allow some
|
||||
// files to be compiled in strict mode - while maintaining
|
||||
// a consistent setting of BOOST_HAS_THREADS across
|
||||
// all translation units (needed for shared_ptr etc).
|
||||
//
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
# define BOOST_NO_ANSI_APIS
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_HAS_PTHREADS
|
||||
# define BOOST_HAS_WINTHREADS
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_DISABLE_WIN32
|
||||
// WEK: Added
|
||||
#define BOOST_HAS_FTIME
|
||||
#define BOOST_WINDOWS 1
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,87 @@
|
||||
// Boost compiler configuration selection header file
|
||||
|
||||
// (C) Copyright John Maddock 2001 - 2003.
|
||||
// (C) Copyright Martin Wille 2003.
|
||||
// (C) Copyright Guillaume Melquiond 2003.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for most recent version.
|
||||
|
||||
// locate which compiler we are using and define
|
||||
// BOOST_COMPILER_CONFIG as needed:
|
||||
|
||||
#if defined(__GCCXML__)
|
||||
// GCC-XML emulates other compilers, it has to appear first here!
|
||||
# define BOOST_COMPILER_CONFIG "boost/config/compiler/gcc_xml.hpp"
|
||||
|
||||
#elif defined __COMO__
|
||||
// Comeau C++
|
||||
# define BOOST_COMPILER_CONFIG "boost/config/compiler/comeau.hpp"
|
||||
|
||||
#elif defined __DMC__
|
||||
// Digital Mars C++
|
||||
# define BOOST_COMPILER_CONFIG "boost/config/compiler/digitalmars.hpp"
|
||||
|
||||
#elif defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)
|
||||
// Intel
|
||||
# define BOOST_COMPILER_CONFIG "boost/config/compiler/intel.hpp"
|
||||
|
||||
# elif defined __GNUC__
|
||||
// GNU C++:
|
||||
# define BOOST_COMPILER_CONFIG "boost/config/compiler/gcc.hpp"
|
||||
|
||||
#elif defined __KCC
|
||||
// Kai C++
|
||||
# define BOOST_COMPILER_CONFIG "boost/config/compiler/kai.hpp"
|
||||
|
||||
#elif defined __sgi
|
||||
// SGI MIPSpro C++
|
||||
# define BOOST_COMPILER_CONFIG "boost/config/compiler/sgi_mipspro.hpp"
|
||||
|
||||
#elif defined __DECCXX
|
||||
// Compaq Tru64 Unix cxx
|
||||
# define BOOST_COMPILER_CONFIG "boost/config/compiler/compaq_cxx.hpp"
|
||||
|
||||
#elif defined __ghs
|
||||
// Greenhills C++
|
||||
# define BOOST_COMPILER_CONFIG "boost/config/compiler/greenhills.hpp"
|
||||
|
||||
#elif defined __BORLANDC__
|
||||
// Borland
|
||||
# define BOOST_COMPILER_CONFIG "boost/config/compiler/borland.hpp"
|
||||
|
||||
#elif defined __MWERKS__
|
||||
// Metrowerks CodeWarrior
|
||||
# define BOOST_COMPILER_CONFIG "boost/config/compiler/metrowerks.hpp"
|
||||
|
||||
#elif defined __SUNPRO_CC
|
||||
// Sun Workshop Compiler C++
|
||||
# define BOOST_COMPILER_CONFIG "boost/config/compiler/sunpro_cc.hpp"
|
||||
|
||||
#elif defined __HP_aCC
|
||||
// HP aCC
|
||||
# define BOOST_COMPILER_CONFIG "boost/config/compiler/hp_acc.hpp"
|
||||
|
||||
#elif defined(__MRC__) || defined(__SC__)
|
||||
// MPW MrCpp or SCpp
|
||||
# define BOOST_COMPILER_CONFIG "boost/config/compiler/mpw.hpp"
|
||||
|
||||
#elif defined(__IBMCPP__)
|
||||
// IBM Visual Age
|
||||
# define BOOST_COMPILER_CONFIG "boost/config/compiler/vacpp.hpp"
|
||||
|
||||
#elif defined _MSC_VER
|
||||
// Microsoft Visual C++
|
||||
//
|
||||
// Must remain the last #elif since some other vendors (Metrowerks, for
|
||||
// example) also #define _MSC_VER
|
||||
# define BOOST_COMPILER_CONFIG "boost/config/compiler/visualc.hpp"
|
||||
|
||||
#elif defined (BOOST_ASSERT_CONFIG)
|
||||
// this must come last - generate an error if we don't
|
||||
// recognise the compiler:
|
||||
# error "Unknown compiler - please configure (http://www.boost.org/libs/config/config.htm#configuring) and report the results to the main boost mailing list (http://www.boost.org/more/mailing_lists.htm#main)"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,90 @@
|
||||
// Boost compiler configuration selection header file
|
||||
|
||||
// (C) Copyright John Maddock 2001 - 2002.
|
||||
// (C) Copyright Jens Maurer 2001.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for most recent version.
|
||||
|
||||
// locate which platform we are on and define BOOST_PLATFORM_CONFIG as needed.
|
||||
// Note that we define the headers to include using "header_name" not
|
||||
// <header_name> in order to prevent macro expansion within the header
|
||||
// name (for example "linux" is a macro on linux systems).
|
||||
|
||||
#if defined(linux) || defined(__linux) || defined(__linux__)
|
||||
// linux:
|
||||
# define BOOST_PLATFORM_CONFIG "boost/config/platform/linux.hpp"
|
||||
|
||||
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
|
||||
// BSD:
|
||||
# define BOOST_PLATFORM_CONFIG "boost/config/platform/bsd.hpp"
|
||||
|
||||
#elif defined(sun) || defined(__sun)
|
||||
// solaris:
|
||||
# define BOOST_PLATFORM_CONFIG "boost/config/platform/solaris.hpp"
|
||||
|
||||
#elif defined(__sgi)
|
||||
// SGI Irix:
|
||||
# define BOOST_PLATFORM_CONFIG "boost/config/platform/irix.hpp"
|
||||
|
||||
#elif defined(__hpux)
|
||||
// hp unix:
|
||||
# define BOOST_PLATFORM_CONFIG "boost/config/platform/hpux.hpp"
|
||||
|
||||
#elif defined(__CYGWIN__)
|
||||
// cygwin is not win32:
|
||||
# define BOOST_PLATFORM_CONFIG "boost/config/platform/cygwin.hpp"
|
||||
|
||||
#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
|
||||
// win32:
|
||||
# define BOOST_PLATFORM_CONFIG "boost/config/platform/win32.hpp"
|
||||
|
||||
#elif defined(__BEOS__)
|
||||
// BeOS
|
||||
# define BOOST_PLATFORM_CONFIG "boost/config/platform/beos.hpp"
|
||||
|
||||
#elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
|
||||
// MacOS
|
||||
# define BOOST_PLATFORM_CONFIG "boost/config/platform/macos.hpp"
|
||||
|
||||
#elif defined(__IBMCPP__) || defined(_AIX)
|
||||
// IBM
|
||||
# define BOOST_PLATFORM_CONFIG "boost/config/platform/aix.hpp"
|
||||
|
||||
#elif defined(__amigaos__)
|
||||
// AmigaOS
|
||||
# define BOOST_PLATFORM_CONFIG "boost/config/platform/amigaos.hpp"
|
||||
|
||||
#elif defined(__QNXNTO__)
|
||||
// QNX:
|
||||
# define BOOST_PLATFORM_CONFIG "boost/config/platform/qnxnto.hpp"
|
||||
|
||||
#else
|
||||
|
||||
# if defined(unix) \
|
||||
|| defined(__unix) \
|
||||
|| defined(_XOPEN_SOURCE) \
|
||||
|| defined(_POSIX_SOURCE)
|
||||
|
||||
// generic unix platform:
|
||||
|
||||
# ifndef BOOST_HAS_UNISTD_H
|
||||
# define BOOST_HAS_UNISTD_H
|
||||
# endif
|
||||
|
||||
# include <boost/config/posix_features.hpp>
|
||||
|
||||
# endif
|
||||
|
||||
# if defined (BOOST_ASSERT_CONFIG)
|
||||
// this must come last - generate an error if we don't
|
||||
// recognise the platform:
|
||||
# error "Unknown platform - please configure and report the results to boost.org"
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
// Boost compiler configuration selection header file
|
||||
|
||||
// (C) Copyright John Maddock 2001 - 2003.
|
||||
// (C) Copyright Jens Maurer 2001 - 2002.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
|
||||
// See http://www.boost.org for most recent version.
|
||||
|
||||
// locate which std lib we are using and define BOOST_STDLIB_CONFIG as needed:
|
||||
|
||||
// we need to include a std lib header here in order to detect which
|
||||
// library is in use, use <utility> as it's about the smallest
|
||||
// of the std lib headers - do not rely on this header being included -
|
||||
// users can short-circuit this header if they know whose std lib
|
||||
// they are using.
|
||||
|
||||
#include <boost/config/no_tr1/utility.hpp>
|
||||
|
||||
#if defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)
|
||||
// STLPort library; this _must_ come first, otherwise since
|
||||
// STLport typically sits on top of some other library, we
|
||||
// can end up detecting that first rather than STLport:
|
||||
# define BOOST_STDLIB_CONFIG "boost/config/stdlib/stlport.hpp"
|
||||
|
||||
#elif defined(__LIBCOMO__)
|
||||
// Comeau STL:
|
||||
#define BOOST_STDLIB_CONFIG "boost/config/stdlib/libcomo.hpp"
|
||||
|
||||
#elif defined(__STD_RWCOMPILER_H__) || defined(_RWSTD_VER)
|
||||
// Rogue Wave library:
|
||||
# define BOOST_STDLIB_CONFIG "boost/config/stdlib/roguewave.hpp"
|
||||
|
||||
#elif defined(__GLIBCPP__) || defined(__GLIBCXX__)
|
||||
// GNU libstdc++ 3
|
||||
# define BOOST_STDLIB_CONFIG "boost/config/stdlib/libstdcpp3.hpp"
|
||||
|
||||
#elif defined(__STL_CONFIG_H)
|
||||
// generic SGI STL
|
||||
# define BOOST_STDLIB_CONFIG "boost/config/stdlib/sgi.hpp"
|
||||
|
||||
#elif defined(__MSL_CPP__)
|
||||
// MSL standard lib:
|
||||
# define BOOST_STDLIB_CONFIG "boost/config/stdlib/msl.hpp"
|
||||
|
||||
#elif defined(__IBMCPP__)
|
||||
// take the default VACPP std lib
|
||||
# define BOOST_STDLIB_CONFIG "boost/config/stdlib/vacpp.hpp"
|
||||
|
||||
#elif defined(MSIPL_COMPILE_H)
|
||||
// Modena C++ standard library
|
||||
# define BOOST_STDLIB_CONFIG "boost/config/stdlib/modena.hpp"
|
||||
|
||||
#elif (defined(_YVALS) && !defined(__IBMCPP__)) || defined(_CPPLIB_VER)
|
||||
// Dinkumware Library (this has to appear after any possible replacement libraries):
|
||||
# define BOOST_STDLIB_CONFIG "boost/config/stdlib/dinkumware.hpp"
|
||||
|
||||
#elif defined (BOOST_ASSERT_CONFIG)
|
||||
// this must come last - generate an error if we don't
|
||||
// recognise the library:
|
||||
# error "Unknown standard library - please configure and report the results to boost.org"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
106
Engine/Zalla3D Base Class/Boost/config/stdlib/dinkumware.hpp
Normal file
106
Engine/Zalla3D Base Class/Boost/config/stdlib/dinkumware.hpp
Normal file
@@ -0,0 +1,106 @@
|
||||
// (C) Copyright John Maddock 2001 - 2003.
|
||||
// (C) Copyright Jens Maurer 2001.
|
||||
// (C) Copyright Peter Dimov 2001.
|
||||
// (C) Copyright David Abrahams 2002.
|
||||
// (C) Copyright Guillaume Melquiond 2003.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for most recent version.
|
||||
|
||||
// Dinkumware standard library config:
|
||||
|
||||
#if !defined(_YVALS) && !defined(_CPPLIB_VER)
|
||||
#include <boost/config/no_tr1/utility.hpp>
|
||||
#if !defined(_YVALS) && !defined(_CPPLIB_VER)
|
||||
#error This is not the Dinkumware lib!
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(_CPPLIB_VER) && (_CPPLIB_VER >= 306)
|
||||
// full dinkumware 3.06 and above
|
||||
// fully conforming provided the compiler supports it:
|
||||
# if !(defined(_GLOBAL_USING) && (_GLOBAL_USING+0 > 0)) && !defined(__BORLANDC__) && !defined(_STD) && !(defined(__ICC) && (__ICC >= 700)) // can be defined in yvals.h
|
||||
# define BOOST_NO_STDC_NAMESPACE
|
||||
# endif
|
||||
# if !(defined(_HAS_MEMBER_TEMPLATES_REBIND) && (_HAS_MEMBER_TEMPLATES_REBIND+0 > 0)) && !(defined(_MSC_VER) && (_MSC_VER > 1300)) && defined(BOOST_MSVC)
|
||||
# define BOOST_NO_STD_ALLOCATOR
|
||||
# endif
|
||||
# define BOOST_HAS_PARTIAL_STD_ALLOCATOR
|
||||
# if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
|
||||
// if this lib version is set up for vc6 then there is no std::use_facet:
|
||||
# define BOOST_NO_STD_USE_FACET
|
||||
# define BOOST_HAS_TWO_ARG_USE_FACET
|
||||
// C lib functions aren't in namespace std either:
|
||||
# define BOOST_NO_STDC_NAMESPACE
|
||||
// and nor is <exception>
|
||||
# define BOOST_NO_EXCEPTION_STD_NAMESPACE
|
||||
# endif
|
||||
// There's no numeric_limits<long long> support unless _LONGLONG is defined:
|
||||
# if !defined(_LONGLONG) && (_CPPLIB_VER <= 310)
|
||||
# define BOOST_NO_MS_INT64_NUMERIC_LIMITS
|
||||
# endif
|
||||
// 3.06 appears to have (non-sgi versions of) <hash_set> & <hash_map>,
|
||||
// and no <slist> at all
|
||||
#else
|
||||
# define BOOST_MSVC_STD_ITERATOR 1
|
||||
# define BOOST_NO_STD_ITERATOR
|
||||
# define BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS
|
||||
# define BOOST_NO_STD_ALLOCATOR
|
||||
# define BOOST_NO_STDC_NAMESPACE
|
||||
# define BOOST_NO_STD_USE_FACET
|
||||
# define BOOST_NO_STD_OUTPUT_ITERATOR_ASSIGN
|
||||
# define BOOST_HAS_MACRO_USE_FACET
|
||||
# ifndef _CPPLIB_VER
|
||||
// Updated Dinkum library defines this, and provides
|
||||
// its own min and max definitions.
|
||||
# define BOOST_NO_STD_MIN_MAX
|
||||
# define BOOST_NO_MS_INT64_NUMERIC_LIMITS
|
||||
# endif
|
||||
#endif
|
||||
|
||||
//
|
||||
// std extension namespace is stdext for vc7.1 and later,
|
||||
// the same applies to other compilers that sit on top
|
||||
// of vc7.1 (Intel and Comeau):
|
||||
//
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1310) && !defined(__BORLANDC__)
|
||||
# define BOOST_STD_EXTENSION_NAMESPACE stdext
|
||||
#endif
|
||||
|
||||
|
||||
#if (defined(_MSC_VER) && (_MSC_VER <= 1300) && !defined(__BORLANDC__)) || !defined(_CPPLIB_VER) || (_CPPLIB_VER < 306)
|
||||
// if we're using a dinkum lib that's
|
||||
// been configured for VC6/7 then there is
|
||||
// no iterator traits (true even for icl)
|
||||
# define BOOST_NO_STD_ITERATOR_TRAITS
|
||||
#endif
|
||||
|
||||
#if defined(__ICL) && (__ICL < 800) && defined(_CPPLIB_VER) && (_CPPLIB_VER <= 310)
|
||||
// Intel C++ chokes over any non-trivial use of <locale>
|
||||
// this may be an overly restrictive define, but regex fails without it:
|
||||
# define BOOST_NO_STD_LOCALE
|
||||
#endif
|
||||
|
||||
#ifdef _CPPLIB_VER
|
||||
# define BOOST_DINKUMWARE_STDLIB _CPPLIB_VER
|
||||
#else
|
||||
# define BOOST_DINKUMWARE_STDLIB 1
|
||||
#endif
|
||||
|
||||
#ifdef _CPPLIB_VER
|
||||
# define BOOST_STDLIB "Dinkumware standard library version " BOOST_STRINGIZE(_CPPLIB_VER)
|
||||
#else
|
||||
# define BOOST_STDLIB "Dinkumware standard library version 1.x"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
569
Engine/Zalla3D Base Class/Boost/config/suffix.hpp
Normal file
569
Engine/Zalla3D Base Class/Boost/config/suffix.hpp
Normal file
@@ -0,0 +1,569 @@
|
||||
// Boost config.hpp configuration header file ------------------------------//
|
||||
|
||||
// (C) Copyright John Maddock 2001 - 2003.
|
||||
// (C) Copyright Darin Adler 2001.
|
||||
// (C) Copyright Peter Dimov 2001.
|
||||
// (C) Copyright Bill Kempf 2002.
|
||||
// (C) Copyright Jens Maurer 2002.
|
||||
// (C) Copyright David Abrahams 2002 - 2003.
|
||||
// (C) Copyright Gennaro Prota 2003.
|
||||
// (C) Copyright Eric Friedman 2003.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org for most recent version.
|
||||
|
||||
// Boost config.hpp policy and rationale documentation has been moved to
|
||||
// http://www.boost.org/libs/config
|
||||
//
|
||||
// This file is intended to be stable, and relatively unchanging.
|
||||
// It should contain boilerplate code only - no compiler specific
|
||||
// code unless it is unavoidable - no changes unless unavoidable.
|
||||
|
||||
#ifndef BOOST_CONFIG_SUFFIX_HPP
|
||||
#define BOOST_CONFIG_SUFFIX_HPP
|
||||
|
||||
//
|
||||
// look for long long by looking for the appropriate macros in <limits.h>.
|
||||
// Note that we use limits.h rather than climits for maximal portability,
|
||||
// remember that since these just declare a bunch of macros, there should be
|
||||
// no namespace issues from this.
|
||||
//
|
||||
#if !defined(BOOST_HAS_LONG_LONG) \
|
||||
&& !defined(BOOST_MSVC) && !defined(__BORLANDC__)
|
||||
# include <limits.h>
|
||||
# if (defined(ULLONG_MAX) || defined(ULONG_LONG_MAX) || defined(ULONGLONG_MAX))
|
||||
# define BOOST_HAS_LONG_LONG
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// GCC 3.x will clean up all of those nasty macro definitions that
|
||||
// BOOST_NO_CTYPE_FUNCTIONS is intended to help work around, so undefine
|
||||
// it under GCC 3.x.
|
||||
#if defined(__GNUC__) && (__GNUC__ >= 3) && defined(BOOST_NO_CTYPE_FUNCTIONS)
|
||||
# undef BOOST_NO_CTYPE_FUNCTIONS
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// Assume any extensions are in namespace std:: unless stated otherwise:
|
||||
//
|
||||
# ifndef BOOST_STD_EXTENSION_NAMESPACE
|
||||
# define BOOST_STD_EXTENSION_NAMESPACE std
|
||||
# endif
|
||||
|
||||
//
|
||||
// If cv-qualified specializations are not allowed, then neither are cv-void ones:
|
||||
//
|
||||
# if defined(BOOST_NO_CV_SPECIALIZATIONS) \
|
||||
&& !defined(BOOST_NO_CV_VOID_SPECIALIZATIONS)
|
||||
# define BOOST_NO_CV_VOID_SPECIALIZATIONS
|
||||
# endif
|
||||
|
||||
//
|
||||
// If there is no numeric_limits template, then it can't have any compile time
|
||||
// constants either!
|
||||
//
|
||||
# if defined(BOOST_NO_LIMITS) \
|
||||
&& !defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS)
|
||||
# define BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
|
||||
# define BOOST_NO_MS_INT64_NUMERIC_LIMITS
|
||||
# define BOOST_NO_LONG_LONG_NUMERIC_LIMITS
|
||||
# endif
|
||||
|
||||
//
|
||||
// if there is no long long then there is no specialisation
|
||||
// for numeric_limits<long long> either:
|
||||
//
|
||||
#if !defined(BOOST_HAS_LONG_LONG) && !defined(BOOST_NO_LONG_LONG_NUMERIC_LIMITS)
|
||||
# define BOOST_NO_LONG_LONG_NUMERIC_LIMITS
|
||||
#endif
|
||||
|
||||
//
|
||||
// if there is no __int64 then there is no specialisation
|
||||
// for numeric_limits<__int64> either:
|
||||
//
|
||||
#if !defined(BOOST_HAS_MS_INT64) && !defined(BOOST_NO_MS_INT64_NUMERIC_LIMITS)
|
||||
# define BOOST_NO_MS_INT64_NUMERIC_LIMITS
|
||||
#endif
|
||||
|
||||
//
|
||||
// if member templates are supported then so is the
|
||||
// VC6 subset of member templates:
|
||||
//
|
||||
# if !defined(BOOST_NO_MEMBER_TEMPLATES) \
|
||||
&& !defined(BOOST_MSVC6_MEMBER_TEMPLATES)
|
||||
# define BOOST_MSVC6_MEMBER_TEMPLATES
|
||||
# endif
|
||||
|
||||
//
|
||||
// Without partial specialization, can't test for partial specialisation bugs:
|
||||
//
|
||||
# if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
|
||||
&& !defined(BOOST_BCB_PARTIAL_SPECIALIZATION_BUG)
|
||||
# define BOOST_BCB_PARTIAL_SPECIALIZATION_BUG
|
||||
# endif
|
||||
|
||||
//
|
||||
// Without partial specialization, we can't have array-type partial specialisations:
|
||||
//
|
||||
# if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
|
||||
&& !defined(BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS)
|
||||
# define BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS
|
||||
# endif
|
||||
|
||||
//
|
||||
// Without partial specialization, std::iterator_traits can't work:
|
||||
//
|
||||
# if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
|
||||
&& !defined(BOOST_NO_STD_ITERATOR_TRAITS)
|
||||
# define BOOST_NO_STD_ITERATOR_TRAITS
|
||||
# endif
|
||||
|
||||
//
|
||||
// Without member template support, we can't have template constructors
|
||||
// in the standard library either:
|
||||
//
|
||||
# if defined(BOOST_NO_MEMBER_TEMPLATES) \
|
||||
&& !defined(BOOST_MSVC6_MEMBER_TEMPLATES) \
|
||||
&& !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)
|
||||
# define BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS
|
||||
# endif
|
||||
|
||||
//
|
||||
// Without member template support, we can't have a conforming
|
||||
// std::allocator template either:
|
||||
//
|
||||
# if defined(BOOST_NO_MEMBER_TEMPLATES) \
|
||||
&& !defined(BOOST_MSVC6_MEMBER_TEMPLATES) \
|
||||
&& !defined(BOOST_NO_STD_ALLOCATOR)
|
||||
# define BOOST_NO_STD_ALLOCATOR
|
||||
# endif
|
||||
|
||||
//
|
||||
// without ADL support then using declarations will break ADL as well:
|
||||
//
|
||||
#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) && !defined(BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL)
|
||||
# define BOOST_FUNCTION_SCOPE_USING_DECLARATION_BREAKS_ADL
|
||||
#endif
|
||||
|
||||
//
|
||||
// If we have a standard allocator, then we have a partial one as well:
|
||||
//
|
||||
#if !defined(BOOST_NO_STD_ALLOCATOR)
|
||||
# define BOOST_HAS_PARTIAL_STD_ALLOCATOR
|
||||
#endif
|
||||
|
||||
//
|
||||
// We can't have a working std::use_facet if there is no std::locale:
|
||||
//
|
||||
# if defined(BOOST_NO_STD_LOCALE) && !defined(BOOST_NO_STD_USE_FACET)
|
||||
# define BOOST_NO_STD_USE_FACET
|
||||
# endif
|
||||
|
||||
//
|
||||
// We can't have a std::messages facet if there is no std::locale:
|
||||
//
|
||||
# if defined(BOOST_NO_STD_LOCALE) && !defined(BOOST_NO_STD_MESSAGES)
|
||||
# define BOOST_NO_STD_MESSAGES
|
||||
# endif
|
||||
|
||||
//
|
||||
// We can't have a working std::wstreambuf if there is no std::locale:
|
||||
//
|
||||
# if defined(BOOST_NO_STD_LOCALE) && !defined(BOOST_NO_STD_WSTREAMBUF)
|
||||
# define BOOST_NO_STD_WSTREAMBUF
|
||||
# endif
|
||||
|
||||
//
|
||||
// We can't have a <cwctype> if there is no <cwchar>:
|
||||
//
|
||||
# if defined(BOOST_NO_CWCHAR) && !defined(BOOST_NO_CWCTYPE)
|
||||
# define BOOST_NO_CWCTYPE
|
||||
# endif
|
||||
|
||||
//
|
||||
// We can't have a swprintf if there is no <cwchar>:
|
||||
//
|
||||
# if defined(BOOST_NO_CWCHAR) && !defined(BOOST_NO_SWPRINTF)
|
||||
# define BOOST_NO_SWPRINTF
|
||||
# endif
|
||||
|
||||
//
|
||||
// If Win32 support is turned off, then we must turn off
|
||||
// threading support also, unless there is some other
|
||||
// thread API enabled:
|
||||
//
|
||||
#if defined(BOOST_DISABLE_WIN32) && defined(_WIN32) \
|
||||
&& !defined(BOOST_DISABLE_THREADS) && !defined(BOOST_HAS_PTHREADS)
|
||||
# define BOOST_DISABLE_THREADS
|
||||
#endif
|
||||
|
||||
//
|
||||
// Turn on threading support if the compiler thinks that it's in
|
||||
// multithreaded mode. We put this here because there are only a
|
||||
// limited number of macros that identify this (if there's any missing
|
||||
// from here then add to the appropriate compiler section):
|
||||
//
|
||||
#if (defined(__MT__) || defined(_MT) || defined(_REENTRANT) \
|
||||
|| defined(_PTHREADS)) && !defined(BOOST_HAS_THREADS)
|
||||
# define BOOST_HAS_THREADS
|
||||
#endif
|
||||
|
||||
//
|
||||
// Turn threading support off if BOOST_DISABLE_THREADS is defined:
|
||||
//
|
||||
#if defined(BOOST_DISABLE_THREADS) && defined(BOOST_HAS_THREADS)
|
||||
# undef BOOST_HAS_THREADS
|
||||
#endif
|
||||
|
||||
//
|
||||
// Turn threading support off if we don't recognise the threading API:
|
||||
//
|
||||
#if defined(BOOST_HAS_THREADS) && !defined(BOOST_HAS_PTHREADS)\
|
||||
&& !defined(BOOST_HAS_WINTHREADS) && !defined(BOOST_HAS_BETHREADS)\
|
||||
&& !defined(BOOST_HAS_MPTASKS)
|
||||
# undef BOOST_HAS_THREADS
|
||||
#endif
|
||||
|
||||
//
|
||||
// Turn threading detail macros off if we don't (want to) use threading
|
||||
//
|
||||
#ifndef BOOST_HAS_THREADS
|
||||
# undef BOOST_HAS_PTHREADS
|
||||
# undef BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE
|
||||
# undef BOOST_HAS_WINTHREADS
|
||||
# undef BOOST_HAS_BETHREADS
|
||||
# undef BOOST_HAS_MPTASKS
|
||||
#endif
|
||||
|
||||
//
|
||||
// If the compiler claims to be C99 conformant, then it had better
|
||||
// have a <stdint.h>:
|
||||
//
|
||||
# if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)
|
||||
# define BOOST_HAS_STDINT_H
|
||||
# ifndef BOOST_HAS_LOG1P
|
||||
# define BOOST_HAS_LOG1P
|
||||
# endif
|
||||
# ifndef BOOST_HAS_EXPM1
|
||||
# define BOOST_HAS_EXPM1
|
||||
# endif
|
||||
# endif
|
||||
|
||||
//
|
||||
// Define BOOST_NO_SLIST and BOOST_NO_HASH if required.
|
||||
// Note that this is for backwards compatibility only.
|
||||
//
|
||||
# ifndef BOOST_HAS_SLIST
|
||||
# define BOOST_NO_SLIST
|
||||
# endif
|
||||
|
||||
# ifndef BOOST_HAS_HASH
|
||||
# define BOOST_NO_HASH
|
||||
# endif
|
||||
|
||||
//
|
||||
// Set BOOST_SLIST_HEADER if not set already:
|
||||
//
|
||||
#if defined(BOOST_HAS_SLIST) && !defined(BOOST_SLIST_HEADER)
|
||||
# define BOOST_SLIST_HEADER <slist>
|
||||
#endif
|
||||
|
||||
//
|
||||
// Set BOOST_HASH_SET_HEADER if not set already:
|
||||
//
|
||||
#if defined(BOOST_HAS_HASH) && !defined(BOOST_HASH_SET_HEADER)
|
||||
# define BOOST_HASH_SET_HEADER <hash_set>
|
||||
#endif
|
||||
|
||||
//
|
||||
// Set BOOST_HASH_MAP_HEADER if not set already:
|
||||
//
|
||||
#if defined(BOOST_HAS_HASH) && !defined(BOOST_HASH_MAP_HEADER)
|
||||
# define BOOST_HASH_MAP_HEADER <hash_map>
|
||||
#endif
|
||||
|
||||
// BOOST_HAS_ABI_HEADERS
|
||||
// This macro gets set if we have headers that fix the ABI,
|
||||
// and prevent ODR violations when linking to external libraries:
|
||||
#if defined(BOOST_ABI_PREFIX) && defined(BOOST_ABI_SUFFIX) && !defined(BOOST_HAS_ABI_HEADERS)
|
||||
# define BOOST_HAS_ABI_HEADERS
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_ABI_HEADERS) && defined(BOOST_DISABLE_ABI_HEADERS)
|
||||
# undef BOOST_HAS_ABI_HEADERS
|
||||
#endif
|
||||
|
||||
// BOOST_NO_STDC_NAMESPACE workaround --------------------------------------//
|
||||
// Because std::size_t usage is so common, even in boost headers which do not
|
||||
// otherwise use the C library, the <cstddef> workaround is included here so
|
||||
// that ugly workaround code need not appear in many other boost headers.
|
||||
// NOTE WELL: This is a workaround for non-conforming compilers; <cstddef>
|
||||
// must still be #included in the usual places so that <cstddef> inclusion
|
||||
// works as expected with standard conforming compilers. The resulting
|
||||
// double inclusion of <cstddef> is harmless.
|
||||
|
||||
# ifdef BOOST_NO_STDC_NAMESPACE
|
||||
# include <cstddef>
|
||||
namespace std { using ::ptrdiff_t; using ::size_t; }
|
||||
# endif
|
||||
|
||||
// Workaround for the unfortunate min/max macros defined by some platform headers
|
||||
|
||||
#define BOOST_PREVENT_MACRO_SUBSTITUTION
|
||||
|
||||
#ifndef BOOST_USING_STD_MIN
|
||||
# define BOOST_USING_STD_MIN() using std::min
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_USING_STD_MAX
|
||||
# define BOOST_USING_STD_MAX() using std::max
|
||||
#endif
|
||||
|
||||
// BOOST_NO_STD_MIN_MAX workaround -----------------------------------------//
|
||||
|
||||
# ifdef BOOST_NO_STD_MIN_MAX
|
||||
|
||||
namespace std {
|
||||
template <class _Tp>
|
||||
inline const _Tp& min BOOST_PREVENT_MACRO_SUBSTITUTION (const _Tp& __a, const _Tp& __b) {
|
||||
return __b < __a ? __b : __a;
|
||||
}
|
||||
template <class _Tp>
|
||||
inline const _Tp& max BOOST_PREVENT_MACRO_SUBSTITUTION (const _Tp& __a, const _Tp& __b) {
|
||||
return __a < __b ? __b : __a;
|
||||
}
|
||||
}
|
||||
|
||||
# endif
|
||||
|
||||
// BOOST_STATIC_CONSTANT workaround --------------------------------------- //
|
||||
// On compilers which don't allow in-class initialization of static integral
|
||||
// constant members, we must use enums as a workaround if we want the constants
|
||||
// to be available at compile-time. This macro gives us a convenient way to
|
||||
// declare such constants.
|
||||
|
||||
# ifdef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
|
||||
# define BOOST_STATIC_CONSTANT(type, assignment) enum { assignment }
|
||||
# else
|
||||
# define BOOST_STATIC_CONSTANT(type, assignment) static const type assignment
|
||||
# endif
|
||||
|
||||
// BOOST_USE_FACET / HAS_FACET workaround ----------------------------------//
|
||||
// When the standard library does not have a conforming std::use_facet there
|
||||
// are various workarounds available, but they differ from library to library.
|
||||
// The same problem occurs with has_facet.
|
||||
// These macros provide a consistent way to access a locale's facets.
|
||||
// Usage:
|
||||
// replace
|
||||
// std::use_facet<Type>(loc);
|
||||
// with
|
||||
// BOOST_USE_FACET(Type, loc);
|
||||
// Note do not add a std:: prefix to the front of BOOST_USE_FACET!
|
||||
// Use for BOOST_HAS_FACET is analagous.
|
||||
|
||||
#if defined(BOOST_NO_STD_USE_FACET)
|
||||
# ifdef BOOST_HAS_TWO_ARG_USE_FACET
|
||||
# define BOOST_USE_FACET(Type, loc) std::use_facet(loc, static_cast<Type*>(0))
|
||||
# define BOOST_HAS_FACET(Type, loc) std::has_facet(loc, static_cast<Type*>(0))
|
||||
# elif defined(BOOST_HAS_MACRO_USE_FACET)
|
||||
# define BOOST_USE_FACET(Type, loc) std::_USE(loc, Type)
|
||||
# define BOOST_HAS_FACET(Type, loc) std::_HAS(loc, Type)
|
||||
# elif defined(BOOST_HAS_STLP_USE_FACET)
|
||||
# define BOOST_USE_FACET(Type, loc) (*std::_Use_facet<Type >(loc))
|
||||
# define BOOST_HAS_FACET(Type, loc) std::has_facet< Type >(loc)
|
||||
# endif
|
||||
#else
|
||||
# define BOOST_USE_FACET(Type, loc) std::use_facet< Type >(loc)
|
||||
# define BOOST_HAS_FACET(Type, loc) std::has_facet< Type >(loc)
|
||||
#endif
|
||||
|
||||
// BOOST_NESTED_TEMPLATE workaround ------------------------------------------//
|
||||
// Member templates are supported by some compilers even though they can't use
|
||||
// the A::template member<U> syntax, as a workaround replace:
|
||||
//
|
||||
// typedef typename A::template rebind<U> binder;
|
||||
//
|
||||
// with:
|
||||
//
|
||||
// typedef typename A::BOOST_NESTED_TEMPLATE rebind<U> binder;
|
||||
|
||||
#ifndef BOOST_NO_MEMBER_TEMPLATE_KEYWORD
|
||||
# define BOOST_NESTED_TEMPLATE template
|
||||
#else
|
||||
# define BOOST_NESTED_TEMPLATE
|
||||
#endif
|
||||
|
||||
// BOOST_UNREACHABLE_RETURN(x) workaround -------------------------------------//
|
||||
// Normally evaluates to nothing, unless BOOST_NO_UNREACHABLE_RETURN_DETECTION
|
||||
// is defined, in which case it evaluates to return x; Use when you have a return
|
||||
// statement that can never be reached.
|
||||
|
||||
#ifdef BOOST_NO_UNREACHABLE_RETURN_DETECTION
|
||||
# define BOOST_UNREACHABLE_RETURN(x) return x;
|
||||
#else
|
||||
# define BOOST_UNREACHABLE_RETURN(x)
|
||||
#endif
|
||||
|
||||
// BOOST_DEDUCED_TYPENAME workaround ------------------------------------------//
|
||||
//
|
||||
// Some compilers don't support the use of `typename' for dependent
|
||||
// types in deduced contexts, e.g.
|
||||
//
|
||||
// template <class T> void f(T, typename T::type);
|
||||
// ^^^^^^^^
|
||||
// Replace these declarations with:
|
||||
//
|
||||
// template <class T> void f(T, BOOST_DEDUCED_TYPENAME T::type);
|
||||
|
||||
#ifndef BOOST_NO_DEDUCED_TYPENAME
|
||||
# define BOOST_DEDUCED_TYPENAME typename
|
||||
#else
|
||||
# define BOOST_DEDUCED_TYPENAME
|
||||
#endif
|
||||
|
||||
// long long workaround ------------------------------------------//
|
||||
// On gcc (and maybe other compilers?) long long is alway supported
|
||||
// but it's use may generate either warnings (with -ansi), or errors
|
||||
// (with -pedantic -ansi) unless it's use is prefixed by __extension__
|
||||
//
|
||||
#if defined(BOOST_HAS_LONG_LONG)
|
||||
namespace boost{
|
||||
# ifdef __GNUC__
|
||||
__extension__ typedef long long long_long_type;
|
||||
__extension__ typedef unsigned long long ulong_long_type;
|
||||
# else
|
||||
typedef long long long_long_type;
|
||||
typedef unsigned long long ulong_long_type;
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
||||
// BOOST_[APPEND_]EXPLICIT_TEMPLATE_[NON_]TYPE macros --------------------------//
|
||||
//
|
||||
// Some compilers have problems with function templates whose
|
||||
// template parameters don't appear in the function parameter
|
||||
// list (basically they just link one instantiation of the
|
||||
// template in the final executable). These macros provide a
|
||||
// uniform way to cope with the problem with no effects on the
|
||||
// calling syntax.
|
||||
|
||||
// Example:
|
||||
//
|
||||
// #include <iostream>
|
||||
// #include <ostream>
|
||||
// #include <typeinfo>
|
||||
//
|
||||
// template <int n>
|
||||
// void f() { std::cout << n << ' '; }
|
||||
//
|
||||
// template <typename T>
|
||||
// void g() { std::cout << typeid(T).name() << ' '; }
|
||||
//
|
||||
// int main() {
|
||||
// f<1>();
|
||||
// f<2>();
|
||||
//
|
||||
// g<int>();
|
||||
// g<double>();
|
||||
// }
|
||||
//
|
||||
// With VC++ 6.0 the output is:
|
||||
//
|
||||
// 2 2 double double
|
||||
//
|
||||
// To fix it, write
|
||||
//
|
||||
// template <int n>
|
||||
// void f(BOOST_EXPLICIT_TEMPLATE_NON_TYPE(int, n)) { ... }
|
||||
//
|
||||
// template <typename T>
|
||||
// void g(BOOST_EXPLICIT_TEMPLATE_TYPE(T)) { ... }
|
||||
//
|
||||
|
||||
|
||||
#if defined BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS
|
||||
|
||||
# include "boost/type.hpp"
|
||||
# include "boost/non_type.hpp"
|
||||
|
||||
# define BOOST_EXPLICIT_TEMPLATE_TYPE(t) boost::type<t>* = 0
|
||||
# define BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(t) boost::type<t>*
|
||||
# define BOOST_EXPLICIT_TEMPLATE_NON_TYPE(t, v) boost::non_type<t, v>* = 0
|
||||
# define BOOST_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v) boost::non_type<t, v>*
|
||||
|
||||
# define BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(t) \
|
||||
, BOOST_EXPLICIT_TEMPLATE_TYPE(t)
|
||||
# define BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(t) \
|
||||
, BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(t)
|
||||
# define BOOST_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(t, v) \
|
||||
, BOOST_EXPLICIT_TEMPLATE_NON_TYPE(t, v)
|
||||
# define BOOST_APPEND_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v) \
|
||||
, BOOST_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v)
|
||||
|
||||
#else
|
||||
|
||||
// no workaround needed: expand to nothing
|
||||
|
||||
# define BOOST_EXPLICIT_TEMPLATE_TYPE(t)
|
||||
# define BOOST_EXPLICIT_TEMPLATE_TYPE_SPEC(t)
|
||||
# define BOOST_EXPLICIT_TEMPLATE_NON_TYPE(t, v)
|
||||
# define BOOST_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v)
|
||||
|
||||
# define BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(t)
|
||||
# define BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(t)
|
||||
# define BOOST_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(t, v)
|
||||
# define BOOST_APPEND_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v)
|
||||
|
||||
|
||||
#endif // defined BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------//
|
||||
|
||||
//
|
||||
// Helper macro BOOST_STRINGIZE:
|
||||
// Converts the parameter X to a string after macro replacement
|
||||
// on X has been performed.
|
||||
//
|
||||
#define BOOST_STRINGIZE(X) BOOST_DO_STRINGIZE(X)
|
||||
#define BOOST_DO_STRINGIZE(X) #X
|
||||
|
||||
//
|
||||
// Helper macro BOOST_JOIN:
|
||||
// The following piece of macro magic joins the two
|
||||
// arguments together, even when one of the arguments is
|
||||
// itself a macro (see 16.3.1 in C++ standard). The key
|
||||
// is that macro expansion of macro arguments does not
|
||||
// occur in BOOST_DO_JOIN2 but does in BOOST_DO_JOIN.
|
||||
//
|
||||
#define BOOST_JOIN( X, Y ) BOOST_DO_JOIN( X, Y )
|
||||
#define BOOST_DO_JOIN( X, Y ) BOOST_DO_JOIN2(X,Y)
|
||||
#define BOOST_DO_JOIN2( X, Y ) X##Y
|
||||
|
||||
//
|
||||
// Set some default values for compiler/library/platform names.
|
||||
// These are for debugging config setup only:
|
||||
//
|
||||
# ifndef BOOST_COMPILER
|
||||
# define BOOST_COMPILER "Unknown ISO C++ Compiler"
|
||||
# endif
|
||||
# ifndef BOOST_STDLIB
|
||||
# define BOOST_STDLIB "Unknown ISO standard library"
|
||||
# endif
|
||||
# ifndef BOOST_PLATFORM
|
||||
# if defined(unix) || defined(__unix) || defined(_XOPEN_SOURCE) \
|
||||
|| defined(_POSIX_SOURCE)
|
||||
# define BOOST_PLATFORM "Generic Unix"
|
||||
# else
|
||||
# define BOOST_PLATFORM "Unknown"
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
124
Engine/Zalla3D Base Class/Boost/config/user.hpp
Normal file
124
Engine/Zalla3D Base Class/Boost/config/user.hpp
Normal file
@@ -0,0 +1,124 @@
|
||||
// boost/config/user.hpp ---------------------------------------------------//
|
||||
|
||||
// (C) Copyright John Maddock 2001.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// Do not check in modified versions of this file,
|
||||
// This file may be customized by the end user, but not by boost.
|
||||
|
||||
//
|
||||
// Use this file to define a site and compiler specific
|
||||
// configuration policy:
|
||||
//
|
||||
|
||||
// define this to locate a compiler config file:
|
||||
// #define BOOST_COMPILER_CONFIG <myheader>
|
||||
|
||||
// define this to locate a stdlib config file:
|
||||
// #define BOOST_STDLIB_CONFIG <myheader>
|
||||
|
||||
// define this to locate a platform config file:
|
||||
// #define BOOST_PLATFORM_CONFIG <myheader>
|
||||
|
||||
// define this to disable compiler config,
|
||||
// use if your compiler config has nothing to set:
|
||||
// #define BOOST_NO_COMPILER_CONFIG
|
||||
|
||||
// define this to disable stdlib config,
|
||||
// use if your stdlib config has nothing to set:
|
||||
// #define BOOST_NO_STDLIB_CONFIG
|
||||
|
||||
// define this to disable platform config,
|
||||
// use if your platform config has nothing to set:
|
||||
// #define BOOST_NO_PLATFORM_CONFIG
|
||||
|
||||
// define this to disable all config options,
|
||||
// excluding the user config. Use if your
|
||||
// setup is fully ISO compliant, and has no
|
||||
// useful extensions, or for autoconf generated
|
||||
// setups:
|
||||
// #define BOOST_NO_CONFIG
|
||||
|
||||
// define this to make the config "optimistic"
|
||||
// about unknown compiler versions. Normally
|
||||
// unknown compiler versions are assumed to have
|
||||
// all the defects of the last known version, however
|
||||
// setting this flag, causes the config to assume
|
||||
// that unknown compiler versions are fully conformant
|
||||
// with the standard:
|
||||
// #define BOOST_STRICT_CONFIG
|
||||
|
||||
// define this to cause the config to halt compilation
|
||||
// with an #error if it encounters anything unknown --
|
||||
// either an unknown compiler version or an unknown
|
||||
// compiler/platform/library:
|
||||
// #define BOOST_ASSERT_CONFIG
|
||||
|
||||
|
||||
// define if you want to disable threading support, even
|
||||
// when available:
|
||||
// #define BOOST_DISABLE_THREADS
|
||||
|
||||
// define when you want to disable Win32 specific features
|
||||
// even when available:
|
||||
// #define BOOST_DISABLE_WIN32
|
||||
|
||||
// BOOST_DISABLE_ABI_HEADERS: Stops boost headers from including any
|
||||
// prefix/suffix headers that normally control things like struct
|
||||
// packing and alignment.
|
||||
// #define BOOST_DISABLE_ABI_HEADERS
|
||||
|
||||
// BOOST_ABI_PREFIX: A prefix header to include in place of whatever
|
||||
// boost.config would normally select, any replacement should set up
|
||||
// struct packing and alignment options as required.
|
||||
// #define BOOST_ABI_PREFIX my-header-name
|
||||
|
||||
// BOOST_ABI_SUFFIX: A suffix header to include in place of whatever
|
||||
// boost.config would normally select, any replacement should undo
|
||||
// the effects of the prefix header.
|
||||
// #define BOOST_ABI_SUFFIX my-header-name
|
||||
|
||||
// BOOST_ALL_DYN_LINK: Forces all libraries that have separate source,
|
||||
// to be linked as dll's rather than static libraries on Microsoft Windows
|
||||
// (this macro is used to turn on __declspec(dllimport) modifiers, so that
|
||||
// the compiler knows which symbols to look for in a dll rather than in a
|
||||
// static library). Note that there may be some libraries that can only
|
||||
// be statically linked (Boost.Test for example) and others which may only
|
||||
// be dynamically linked (Boost.Threads for example), in these cases this
|
||||
// macro has no effect.
|
||||
// #define BOOST_ALL_DYN_LINK
|
||||
|
||||
// BOOST_WHATEVER_DYN_LINK: Forces library "whatever" to be linked as a dll
|
||||
// rather than a static library on Microsoft Windows: replace the WHATEVER
|
||||
// part of the macro name with the name of the library that you want to
|
||||
// dynamically link to, for example use BOOST_DATE_TIME_DYN_LINK or
|
||||
// BOOST_REGEX_DYN_LINK etc (this macro is used to turn on __declspec(dllimport)
|
||||
// modifiers, so that the compiler knows which symbols to look for in a dll
|
||||
// rather than in a static library).
|
||||
// Note that there may be some libraries that can only be statically linked
|
||||
// (Boost.Test for example) and others which may only be dynamically linked
|
||||
// (Boost.Threads for example), in these cases this macro is unsupported.
|
||||
// #define BOOST_WHATEVER_DYN_LINK
|
||||
|
||||
// BOOST_ALL_NO_LIB: Tells the config system not to automatically select
|
||||
// which libraries to link against.
|
||||
// Normally if a compiler supports #pragma lib, then the correct library
|
||||
// build variant will be automatically selected and linked against,
|
||||
// simply by the act of including one of that library's headers.
|
||||
// This macro turns that feature off.
|
||||
// #define BOOST_ALL_NO_LIB
|
||||
|
||||
// BOOST_WHATEVER_NO_LIB: Tells the config system not to automatically
|
||||
// select which library to link against for library "whatever",
|
||||
// replace WHATEVER in the macro name with the name of the library;
|
||||
// for example BOOST_DATE_TIME_NO_LIB or BOOST_REGEX_NO_LIB.
|
||||
// Normally if a compiler supports #pragma lib, then the correct library
|
||||
// build variant will be automatically selected and linked against, simply
|
||||
// by the act of including one of that library's headers. This macro turns
|
||||
// that feature off.
|
||||
// #define BOOST_WHATEVER_NO_LIB
|
||||
|
||||
|
||||
|
||||
449
Engine/Zalla3D Base Class/Boost/detail/limits.hpp
Normal file
449
Engine/Zalla3D Base Class/Boost/detail/limits.hpp
Normal file
@@ -0,0 +1,449 @@
|
||||
// Copyright 2001 John Maddock
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompany-
|
||||
// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute and sell this software
|
||||
* and its documentation for any purpose is hereby granted without fee,
|
||||
* provided that the above copyright notice appear in all copies and
|
||||
* that both that copyright notice and this permission notice appear
|
||||
* in supporting documentation. Silicon Graphics makes no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied warranty.
|
||||
*/
|
||||
|
||||
/* NOTE: This is not portable code. Parts of numeric_limits<> are
|
||||
* inherently machine-dependent, and this file is written for the MIPS
|
||||
* architecture and the SGI MIPSpro C++ compiler. Parts of it (in
|
||||
* particular, some of the characteristics of floating-point types)
|
||||
* are almost certainly incorrect for any other platform.
|
||||
*/
|
||||
|
||||
/* The above comment is almost certainly out of date. This file works
|
||||
* on systems other than SGI MIPSpro C++ now.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Revision history:
|
||||
* 21 Sep 2001:
|
||||
* Only include <cwchar> if BOOST_NO_CWCHAR is defined. (Darin Adler)
|
||||
* 10 Aug 2001:
|
||||
* Added MIPS (big endian) to the big endian family. (Jens Maurer)
|
||||
* 13 Apr 2001:
|
||||
* Added powerpc to the big endian family. (Jeremy Siek)
|
||||
* 5 Apr 2001:
|
||||
* Added sparc (big endian) processor support (John Maddock).
|
||||
* Initial sub:
|
||||
* Modified by Jens Maurer for gcc 2.95 on x86.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_SGI_CPP_LIMITS
|
||||
#define BOOST_SGI_CPP_LIMITS
|
||||
|
||||
#include <climits>
|
||||
#include <cfloat>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/endian.hpp>
|
||||
|
||||
#ifndef BOOST_NO_CWCHAR
|
||||
#include <cwchar> // for WCHAR_MIN and WCHAR_MAX
|
||||
#endif
|
||||
|
||||
namespace std {
|
||||
|
||||
enum float_round_style {
|
||||
round_indeterminate = -1,
|
||||
round_toward_zero = 0,
|
||||
round_to_nearest = 1,
|
||||
round_toward_infinity = 2,
|
||||
round_toward_neg_infinity = 3
|
||||
};
|
||||
|
||||
enum float_denorm_style {
|
||||
denorm_indeterminate = -1,
|
||||
denorm_absent = 0,
|
||||
denorm_present = 1
|
||||
};
|
||||
|
||||
// The C++ standard (section 18.2.1) requires that some of the members of
|
||||
// numeric_limits be static const data members that are given constant-
|
||||
// initializers within the class declaration. On compilers where the
|
||||
// BOOST_NO_INCLASS_MEMBER_INITIALIZATION macro is defined, it is impossible to write
|
||||
// a standard-conforming numeric_limits class.
|
||||
//
|
||||
// There are two possible workarounds: either initialize the data
|
||||
// members outside the class, or change them from data members to
|
||||
// enums. Neither workaround is satisfactory: the former makes it
|
||||
// impossible to use the data members in constant-expressions, and the
|
||||
// latter means they have the wrong type and that it is impossible to
|
||||
// take their addresses. We choose the former workaround.
|
||||
|
||||
#ifdef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
|
||||
# define BOOST_STL_DECLARE_LIMITS_MEMBER(__mem_type, __mem_name, __mem_value) \
|
||||
enum { __mem_name = __mem_value }
|
||||
#else /* BOOST_NO_INCLASS_MEMBER_INITIALIZATION */
|
||||
# define BOOST_STL_DECLARE_LIMITS_MEMBER(__mem_type, __mem_name, __mem_value) \
|
||||
static const __mem_type __mem_name = __mem_value
|
||||
#endif /* BOOST_NO_INCLASS_MEMBER_INITIALIZATION */
|
||||
|
||||
// Base class for all specializations of numeric_limits.
|
||||
template <class __number>
|
||||
class _Numeric_limits_base {
|
||||
public:
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_specialized, false);
|
||||
|
||||
static __number min BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return __number(); }
|
||||
static __number max BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return __number(); }
|
||||
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(int, digits, 0);
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(int, digits10, 0);
|
||||
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_signed, false);
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_integer, false);
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_exact, false);
|
||||
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(int, radix, 0);
|
||||
|
||||
static __number epsilon() throw() { return __number(); }
|
||||
static __number round_error() throw() { return __number(); }
|
||||
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(int, min_exponent, 0);
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(int, min_exponent10, 0);
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(int, max_exponent, 0);
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(int, max_exponent10, 0);
|
||||
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, has_infinity, false);
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, has_quiet_NaN, false);
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, has_signaling_NaN, false);
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(float_denorm_style,
|
||||
has_denorm,
|
||||
denorm_absent);
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, has_denorm_loss, false);
|
||||
|
||||
static __number infinity() throw() { return __number(); }
|
||||
static __number quiet_NaN() throw() { return __number(); }
|
||||
static __number signaling_NaN() throw() { return __number(); }
|
||||
static __number denorm_min() throw() { return __number(); }
|
||||
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_iec559, false);
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_bounded, false);
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_modulo, false);
|
||||
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, traps, false);
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, tinyness_before, false);
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(float_round_style,
|
||||
round_style,
|
||||
round_toward_zero);
|
||||
};
|
||||
|
||||
// Base class for integers.
|
||||
|
||||
template <class _Int,
|
||||
_Int __imin,
|
||||
_Int __imax,
|
||||
int __idigits = -1>
|
||||
class _Integer_limits : public _Numeric_limits_base<_Int>
|
||||
{
|
||||
public:
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_specialized, true);
|
||||
|
||||
static _Int min BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return __imin; }
|
||||
static _Int max BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return __imax; }
|
||||
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(int,
|
||||
digits,
|
||||
(__idigits < 0) ? (int)(sizeof(_Int) * CHAR_BIT)
|
||||
- (__imin == 0 ? 0 : 1)
|
||||
: __idigits);
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(int, digits10, (digits * 301) / 1000);
|
||||
// log 2 = 0.301029995664...
|
||||
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_signed, __imin != 0);
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_integer, true);
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_exact, true);
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(int, radix, 2);
|
||||
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_bounded, true);
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_modulo, true);
|
||||
};
|
||||
|
||||
#if defined(BOOST_BIG_ENDIAN)
|
||||
|
||||
template<class Number, unsigned int Word>
|
||||
struct float_helper{
|
||||
static Number get_word() throw() {
|
||||
// sizeof(long double) == 16
|
||||
const unsigned int _S_word[4] = { Word, 0, 0, 0 };
|
||||
return *reinterpret_cast<const Number*>(&_S_word);
|
||||
}
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
template<class Number, unsigned int Word>
|
||||
struct float_helper{
|
||||
static Number get_word() throw() {
|
||||
// sizeof(long double) == 12, but only 10 bytes significant
|
||||
const unsigned int _S_word[4] = { 0, 0, 0, Word };
|
||||
return *reinterpret_cast<const Number*>(
|
||||
reinterpret_cast<const char *>(&_S_word)+16-
|
||||
(sizeof(Number) == 12 ? 10 : sizeof(Number)));
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
// Base class for floating-point numbers.
|
||||
template <class __number,
|
||||
int __Digits, int __Digits10,
|
||||
int __MinExp, int __MaxExp,
|
||||
int __MinExp10, int __MaxExp10,
|
||||
unsigned int __InfinityWord,
|
||||
unsigned int __QNaNWord, unsigned int __SNaNWord,
|
||||
bool __IsIEC559,
|
||||
float_round_style __RoundStyle>
|
||||
class _Floating_limits : public _Numeric_limits_base<__number>
|
||||
{
|
||||
public:
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_specialized, true);
|
||||
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(int, digits, __Digits);
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(int, digits10, __Digits10);
|
||||
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_signed, true);
|
||||
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(int, radix, 2);
|
||||
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(int, min_exponent, __MinExp);
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(int, max_exponent, __MaxExp);
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(int, min_exponent10, __MinExp10);
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(int, max_exponent10, __MaxExp10);
|
||||
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, has_infinity, true);
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, has_quiet_NaN, true);
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, has_signaling_NaN, true);
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(float_denorm_style,
|
||||
has_denorm,
|
||||
denorm_indeterminate);
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, has_denorm_loss, false);
|
||||
|
||||
|
||||
static __number infinity() throw() {
|
||||
return float_helper<__number, __InfinityWord>::get_word();
|
||||
}
|
||||
static __number quiet_NaN() throw() {
|
||||
return float_helper<__number,__QNaNWord>::get_word();
|
||||
}
|
||||
static __number signaling_NaN() throw() {
|
||||
return float_helper<__number,__SNaNWord>::get_word();
|
||||
}
|
||||
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_iec559, __IsIEC559);
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_bounded, true);
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, traps, false /* was: true */ );
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, tinyness_before, false);
|
||||
|
||||
BOOST_STL_DECLARE_LIMITS_MEMBER(float_round_style, round_style, __RoundStyle);
|
||||
};
|
||||
|
||||
// Class numeric_limits
|
||||
|
||||
// The unspecialized class.
|
||||
|
||||
template<class T>
|
||||
class numeric_limits : public _Numeric_limits_base<T> {};
|
||||
|
||||
// Specializations for all built-in integral types.
|
||||
|
||||
template<>
|
||||
class numeric_limits<bool>
|
||||
: public _Integer_limits<bool, false, true, 0>
|
||||
{};
|
||||
|
||||
template<>
|
||||
class numeric_limits<char>
|
||||
: public _Integer_limits<char, CHAR_MIN, CHAR_MAX>
|
||||
{};
|
||||
|
||||
template<>
|
||||
class numeric_limits<signed char>
|
||||
: public _Integer_limits<signed char, SCHAR_MIN, SCHAR_MAX>
|
||||
{};
|
||||
|
||||
template<>
|
||||
class numeric_limits<unsigned char>
|
||||
: public _Integer_limits<unsigned char, 0, UCHAR_MAX>
|
||||
{};
|
||||
|
||||
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
|
||||
template<>
|
||||
class numeric_limits<wchar_t>
|
||||
#if !defined(WCHAR_MAX) || !defined(WCHAR_MIN)
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
: public _Integer_limits<wchar_t, 0, USHRT_MAX>
|
||||
#elif defined(__hppa)
|
||||
// wchar_t has "unsigned int" as the underlying type
|
||||
: public _Integer_limits<wchar_t, 0, UINT_MAX>
|
||||
#else
|
||||
// assume that wchar_t has "int" as the underlying type
|
||||
: public _Integer_limits<wchar_t, INT_MIN, INT_MAX>
|
||||
#endif
|
||||
#else
|
||||
// we have WCHAR_MIN and WCHAR_MAX defined, so use it
|
||||
: public _Integer_limits<wchar_t, WCHAR_MIN, WCHAR_MAX>
|
||||
#endif
|
||||
{};
|
||||
#endif
|
||||
|
||||
template<>
|
||||
class numeric_limits<short>
|
||||
: public _Integer_limits<short, SHRT_MIN, SHRT_MAX>
|
||||
{};
|
||||
|
||||
template<>
|
||||
class numeric_limits<unsigned short>
|
||||
: public _Integer_limits<unsigned short, 0, USHRT_MAX>
|
||||
{};
|
||||
|
||||
template<>
|
||||
class numeric_limits<int>
|
||||
: public _Integer_limits<int, INT_MIN, INT_MAX>
|
||||
{};
|
||||
|
||||
template<>
|
||||
class numeric_limits<unsigned int>
|
||||
: public _Integer_limits<unsigned int, 0, UINT_MAX>
|
||||
{};
|
||||
|
||||
template<>
|
||||
class numeric_limits<long>
|
||||
: public _Integer_limits<long, LONG_MIN, LONG_MAX>
|
||||
{};
|
||||
|
||||
template<>
|
||||
class numeric_limits<unsigned long>
|
||||
: public _Integer_limits<unsigned long, 0, ULONG_MAX>
|
||||
{};
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
||||
// Some compilers have long long, but don't define the
|
||||
// LONGLONG_MIN and LONGLONG_MAX macros in limits.h. This
|
||||
// assumes that long long is 64 bits.
|
||||
#if !defined(LONGLONG_MAX) && !defined(ULONGLONG_MAX)
|
||||
|
||||
# define ULONGLONG_MAX 0xffffffffffffffffLLU
|
||||
# define LONGLONG_MAX 0x7fffffffffffffffLL
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(LONGLONG_MIN)
|
||||
# define LONGLONG_MIN (-LONGLONG_MAX - 1)
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(ULONGLONG_MIN)
|
||||
# define ULONGLONG_MIN 0
|
||||
#endif
|
||||
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
// Specializations for all built-in floating-point type.
|
||||
|
||||
template<> class numeric_limits<float>
|
||||
: public _Floating_limits<float,
|
||||
FLT_MANT_DIG, // Binary digits of precision
|
||||
FLT_DIG, // Decimal digits of precision
|
||||
FLT_MIN_EXP, // Minimum exponent
|
||||
FLT_MAX_EXP, // Maximum exponent
|
||||
FLT_MIN_10_EXP, // Minimum base 10 exponent
|
||||
FLT_MAX_10_EXP, // Maximum base 10 exponent
|
||||
#if defined(BOOST_BIG_ENDIAN)
|
||||
0x7f80 << (sizeof(int)*CHAR_BIT-16), // Last word of +infinity
|
||||
0x7f81 << (sizeof(int)*CHAR_BIT-16), // Last word of quiet NaN
|
||||
0x7fc1 << (sizeof(int)*CHAR_BIT-16), // Last word of signaling NaN
|
||||
#else
|
||||
0x7f800000u, // Last word of +infinity
|
||||
0x7f810000u, // Last word of quiet NaN
|
||||
0x7fc10000u, // Last word of signaling NaN
|
||||
#endif
|
||||
true, // conforms to iec559
|
||||
round_to_nearest>
|
||||
{
|
||||
public:
|
||||
static float min BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return FLT_MIN; }
|
||||
static float denorm_min() throw() { return FLT_MIN; }
|
||||
static float max BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return FLT_MAX; }
|
||||
static float epsilon() throw() { return FLT_EPSILON; }
|
||||
static float round_error() throw() { return 0.5f; } // Units: ulps.
|
||||
};
|
||||
|
||||
template<> class numeric_limits<double>
|
||||
: public _Floating_limits<double,
|
||||
DBL_MANT_DIG, // Binary digits of precision
|
||||
DBL_DIG, // Decimal digits of precision
|
||||
DBL_MIN_EXP, // Minimum exponent
|
||||
DBL_MAX_EXP, // Maximum exponent
|
||||
DBL_MIN_10_EXP, // Minimum base 10 exponent
|
||||
DBL_MAX_10_EXP, // Maximum base 10 exponent
|
||||
#if defined(BOOST_BIG_ENDIAN)
|
||||
0x7ff0 << (sizeof(int)*CHAR_BIT-16), // Last word of +infinity
|
||||
0x7ff1 << (sizeof(int)*CHAR_BIT-16), // Last word of quiet NaN
|
||||
0x7ff9 << (sizeof(int)*CHAR_BIT-16), // Last word of signaling NaN
|
||||
#else
|
||||
0x7ff00000u, // Last word of +infinity
|
||||
0x7ff10000u, // Last word of quiet NaN
|
||||
0x7ff90000u, // Last word of signaling NaN
|
||||
#endif
|
||||
true, // conforms to iec559
|
||||
round_to_nearest>
|
||||
{
|
||||
public:
|
||||
static double min BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return DBL_MIN; }
|
||||
static double denorm_min() throw() { return DBL_MIN; }
|
||||
static double max BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return DBL_MAX; }
|
||||
static double epsilon() throw() { return DBL_EPSILON; }
|
||||
static double round_error() throw() { return 0.5; } // Units: ulps.
|
||||
};
|
||||
|
||||
template<> class numeric_limits<long double>
|
||||
: public _Floating_limits<long double,
|
||||
LDBL_MANT_DIG, // Binary digits of precision
|
||||
LDBL_DIG, // Decimal digits of precision
|
||||
LDBL_MIN_EXP, // Minimum exponent
|
||||
LDBL_MAX_EXP, // Maximum exponent
|
||||
LDBL_MIN_10_EXP,// Minimum base 10 exponent
|
||||
LDBL_MAX_10_EXP,// Maximum base 10 exponent
|
||||
#if defined(BOOST_BIG_ENDIAN)
|
||||
0x7ff0 << (sizeof(int)*CHAR_BIT-16), // Last word of +infinity
|
||||
0x7ff1 << (sizeof(int)*CHAR_BIT-16), // Last word of quiet NaN
|
||||
0x7ff9 << (sizeof(int)*CHAR_BIT-16), // Last word of signaling NaN
|
||||
#else
|
||||
0x7fff8000u, // Last word of +infinity
|
||||
0x7fffc000u, // Last word of quiet NaN
|
||||
0x7fff9000u, // Last word of signaling NaN
|
||||
#endif
|
||||
false, // Doesn't conform to iec559
|
||||
round_to_nearest>
|
||||
{
|
||||
public:
|
||||
static long double min BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return LDBL_MIN; }
|
||||
static long double denorm_min() throw() { return LDBL_MIN; }
|
||||
static long double max BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return LDBL_MAX; }
|
||||
static long double epsilon() throw() { return LDBL_EPSILON; }
|
||||
static long double round_error() throw() { return 4; } // Units: ulps.
|
||||
};
|
||||
|
||||
} // namespace std
|
||||
|
||||
#endif /* BOOST_SGI_CPP_LIMITS */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
|
||||
|
||||
|
||||
74
Engine/Zalla3D Base Class/Boost/detail/workaround.hpp
Normal file
74
Engine/Zalla3D Base Class/Boost/detail/workaround.hpp
Normal file
@@ -0,0 +1,74 @@
|
||||
// Copyright David Abrahams 2002.
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
#ifndef WORKAROUND_DWA2002126_HPP
|
||||
# define WORKAROUND_DWA2002126_HPP
|
||||
|
||||
// Compiler/library version workaround macro
|
||||
//
|
||||
// Usage:
|
||||
//
|
||||
// #if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
// // workaround for eVC4 and VC6
|
||||
// ... // workaround code here
|
||||
// #endif
|
||||
//
|
||||
// When BOOST_STRICT_CONFIG is defined, expands to 0. Otherwise, the
|
||||
// first argument must be undefined or expand to a numeric
|
||||
// value. The above expands to:
|
||||
//
|
||||
// (BOOST_MSVC) != 0 && (BOOST_MSVC) < 1300
|
||||
//
|
||||
// When used for workarounds that apply to the latest known version
|
||||
// and all earlier versions of a compiler, the following convention
|
||||
// should be observed:
|
||||
//
|
||||
// #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1301))
|
||||
//
|
||||
// The version number in this case corresponds to the last version in
|
||||
// which the workaround was known to have been required. When
|
||||
// BOOST_DETECT_OUTDATED_WORKAROUNDS is not the defined, the macro
|
||||
// BOOST_TESTED_AT(x) expands to "!= 0", which effectively activates
|
||||
// the workaround for any version of the compiler. When
|
||||
// BOOST_DETECT_OUTDATED_WORKAROUNDS is defined, a compiler warning or
|
||||
// error will be issued if the compiler version exceeds the argument
|
||||
// to BOOST_TESTED_AT(). This can be used to locate workarounds which
|
||||
// may be obsoleted by newer versions.
|
||||
|
||||
# ifndef BOOST_STRICT_CONFIG
|
||||
|
||||
# define BOOST_WORKAROUND(symbol, test) \
|
||||
((symbol != 0) && (1 % (( (symbol test) ) + 1)))
|
||||
// ^ ^ ^ ^
|
||||
// The extra level of parenthesis nesting above, along with the
|
||||
// BOOST_OPEN_PAREN indirection below, is required to satisfy the
|
||||
// broken preprocessor in MWCW 8.3 and earlier.
|
||||
//
|
||||
// The basic mechanism works as follows:
|
||||
// (symbol test) + 1 => if (symbol test) then 2 else 1
|
||||
// 1 % ((symbol test) + 1) => if (symbol test) then 1 else 0
|
||||
//
|
||||
// The complication with % is for cooperation with BOOST_TESTED_AT().
|
||||
// When "test" is BOOST_TESTED_AT(x) and
|
||||
// BOOST_DETECT_OUTDATED_WORKAROUNDS is #defined,
|
||||
//
|
||||
// symbol test => if (symbol <= x) then 1 else -1
|
||||
// (symbol test) + 1 => if (symbol <= x) then 2 else 0
|
||||
// 1 % ((symbol test) + 1) => if (symbol <= x) then 1 else divide-by-zero
|
||||
//
|
||||
|
||||
# ifdef BOOST_DETECT_OUTDATED_WORKAROUNDS
|
||||
# define BOOST_OPEN_PAREN (
|
||||
# define BOOST_TESTED_AT(value) > value) ?(-1): BOOST_OPEN_PAREN 1
|
||||
# else
|
||||
# define BOOST_TESTED_AT(value) != ((value)-(value))
|
||||
# endif
|
||||
|
||||
# else
|
||||
|
||||
# define BOOST_WORKAROUND(symbol, test) 0
|
||||
|
||||
# endif
|
||||
|
||||
#endif // WORKAROUND_DWA2002126_HPP
|
||||
144
Engine/Zalla3D Base Class/Boost/limits.hpp
Normal file
144
Engine/Zalla3D Base Class/Boost/limits.hpp
Normal file
@@ -0,0 +1,144 @@
|
||||
|
||||
// (C) Copyright John maddock 1999.
|
||||
// (C) David Abrahams 2002. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// use this header as a workaround for missing <limits>
|
||||
|
||||
// See http://www.boost.org/libs/utility/limits.html for documentation.
|
||||
|
||||
#ifndef BOOST_LIMITS
|
||||
#define BOOST_LIMITS
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#ifdef BOOST_NO_LIMITS
|
||||
# include <boost/detail/limits.hpp>
|
||||
#else
|
||||
# include <limits>
|
||||
#endif
|
||||
|
||||
#if (defined(BOOST_HAS_LONG_LONG) && defined(BOOST_NO_LONG_LONG_NUMERIC_LIMITS)) \
|
||||
|| (defined(BOOST_HAS_MS_INT64) && defined(BOOST_NO_MS_INT64_NUMERIC_LIMITS))
|
||||
// Add missing specializations for numeric_limits:
|
||||
#ifdef BOOST_HAS_MS_INT64
|
||||
# define BOOST_LLT __int64
|
||||
# define BOOST_ULLT unsigned __int64
|
||||
#else
|
||||
# define BOOST_LLT ::boost::long_long_type
|
||||
# define BOOST_ULLT ::boost::ulong_long_type
|
||||
#endif
|
||||
|
||||
namespace std
|
||||
{
|
||||
template<>
|
||||
class numeric_limits<BOOST_LLT>
|
||||
{
|
||||
public:
|
||||
|
||||
BOOST_STATIC_CONSTANT(bool, is_specialized = true);
|
||||
#ifdef BOOST_HAS_MS_INT64
|
||||
static BOOST_LLT min BOOST_PREVENT_MACRO_SUBSTITUTION (){ return 0x8000000000000000i64; }
|
||||
static BOOST_LLT max BOOST_PREVENT_MACRO_SUBSTITUTION (){ return 0x7FFFFFFFFFFFFFFFi64; }
|
||||
#elif defined(LLONG_MAX)
|
||||
static BOOST_LLT min BOOST_PREVENT_MACRO_SUBSTITUTION (){ return LLONG_MIN; }
|
||||
static BOOST_LLT max BOOST_PREVENT_MACRO_SUBSTITUTION (){ return LLONG_MAX; }
|
||||
#elif defined(LONGLONG_MAX)
|
||||
static BOOST_LLT min BOOST_PREVENT_MACRO_SUBSTITUTION (){ return LONGLONG_MIN; }
|
||||
static BOOST_LLT max BOOST_PREVENT_MACRO_SUBSTITUTION (){ return LONGLONG_MAX; }
|
||||
#else
|
||||
static BOOST_LLT min BOOST_PREVENT_MACRO_SUBSTITUTION (){ return 1LL << (sizeof(BOOST_LLT) * CHAR_BIT - 1); }
|
||||
static BOOST_LLT max BOOST_PREVENT_MACRO_SUBSTITUTION (){ return ~(min)(); }
|
||||
#endif
|
||||
BOOST_STATIC_CONSTANT(int, digits = sizeof(BOOST_LLT) * CHAR_BIT -1);
|
||||
BOOST_STATIC_CONSTANT(int, digits10 = (CHAR_BIT * sizeof (BOOST_LLT) - 1) * 301L / 1000);
|
||||
BOOST_STATIC_CONSTANT(bool, is_signed = true);
|
||||
BOOST_STATIC_CONSTANT(bool, is_integer = true);
|
||||
BOOST_STATIC_CONSTANT(bool, is_exact = true);
|
||||
BOOST_STATIC_CONSTANT(int, radix = 2);
|
||||
static BOOST_LLT epsilon() throw() { return 0; };
|
||||
static BOOST_LLT round_error() throw() { return 0; };
|
||||
|
||||
BOOST_STATIC_CONSTANT(int, min_exponent = 0);
|
||||
BOOST_STATIC_CONSTANT(int, min_exponent10 = 0);
|
||||
BOOST_STATIC_CONSTANT(int, max_exponent = 0);
|
||||
BOOST_STATIC_CONSTANT(int, max_exponent10 = 0);
|
||||
|
||||
BOOST_STATIC_CONSTANT(bool, has_infinity = false);
|
||||
BOOST_STATIC_CONSTANT(bool, has_quiet_NaN = false);
|
||||
BOOST_STATIC_CONSTANT(bool, has_signaling_NaN = false);
|
||||
BOOST_STATIC_CONSTANT(bool, has_denorm = false);
|
||||
BOOST_STATIC_CONSTANT(bool, has_denorm_loss = false);
|
||||
static BOOST_LLT infinity() throw() { return 0; };
|
||||
static BOOST_LLT quiet_NaN() throw() { return 0; };
|
||||
static BOOST_LLT signaling_NaN() throw() { return 0; };
|
||||
static BOOST_LLT denorm_min() throw() { return 0; };
|
||||
|
||||
BOOST_STATIC_CONSTANT(bool, is_iec559 = false);
|
||||
BOOST_STATIC_CONSTANT(bool, is_bounded = true);
|
||||
BOOST_STATIC_CONSTANT(bool, is_modulo = true);
|
||||
|
||||
BOOST_STATIC_CONSTANT(bool, traps = false);
|
||||
BOOST_STATIC_CONSTANT(bool, tinyness_before = false);
|
||||
BOOST_STATIC_CONSTANT(float_round_style, round_style = round_toward_zero);
|
||||
|
||||
};
|
||||
|
||||
template<>
|
||||
class numeric_limits<BOOST_ULLT>
|
||||
{
|
||||
public:
|
||||
|
||||
BOOST_STATIC_CONSTANT(bool, is_specialized = true);
|
||||
#ifdef BOOST_HAS_MS_INT64
|
||||
static BOOST_ULLT min BOOST_PREVENT_MACRO_SUBSTITUTION (){ return 0ui64; }
|
||||
static BOOST_ULLT max BOOST_PREVENT_MACRO_SUBSTITUTION (){ return 0xFFFFFFFFFFFFFFFFui64; }
|
||||
#elif defined(ULLONG_MAX) && defined(ULLONG_MIN)
|
||||
static BOOST_ULLT min BOOST_PREVENT_MACRO_SUBSTITUTION (){ return ULLONG_MIN; }
|
||||
static BOOST_ULLT max BOOST_PREVENT_MACRO_SUBSTITUTION (){ return ULLONG_MAX; }
|
||||
#elif defined(ULONGLONG_MAX) && defined(ULONGLONG_MIN)
|
||||
static BOOST_ULLT min BOOST_PREVENT_MACRO_SUBSTITUTION (){ return ULONGLONG_MIN; }
|
||||
static BOOST_ULLT max BOOST_PREVENT_MACRO_SUBSTITUTION (){ return ULONGLONG_MAX; }
|
||||
#else
|
||||
static BOOST_ULLT min BOOST_PREVENT_MACRO_SUBSTITUTION (){ return 0uLL; }
|
||||
static BOOST_ULLT max BOOST_PREVENT_MACRO_SUBSTITUTION (){ return ~0uLL; }
|
||||
#endif
|
||||
BOOST_STATIC_CONSTANT(int, digits = sizeof(BOOST_LLT) * CHAR_BIT);
|
||||
BOOST_STATIC_CONSTANT(int, digits10 = (CHAR_BIT * sizeof (BOOST_LLT)) * 301L / 1000);
|
||||
BOOST_STATIC_CONSTANT(bool, is_signed = false);
|
||||
BOOST_STATIC_CONSTANT(bool, is_integer = true);
|
||||
BOOST_STATIC_CONSTANT(bool, is_exact = true);
|
||||
BOOST_STATIC_CONSTANT(int, radix = 2);
|
||||
static BOOST_ULLT epsilon() throw() { return 0; };
|
||||
static BOOST_ULLT round_error() throw() { return 0; };
|
||||
|
||||
BOOST_STATIC_CONSTANT(int, min_exponent = 0);
|
||||
BOOST_STATIC_CONSTANT(int, min_exponent10 = 0);
|
||||
BOOST_STATIC_CONSTANT(int, max_exponent = 0);
|
||||
BOOST_STATIC_CONSTANT(int, max_exponent10 = 0);
|
||||
|
||||
BOOST_STATIC_CONSTANT(bool, has_infinity = false);
|
||||
BOOST_STATIC_CONSTANT(bool, has_quiet_NaN = false);
|
||||
BOOST_STATIC_CONSTANT(bool, has_signaling_NaN = false);
|
||||
BOOST_STATIC_CONSTANT(bool, has_denorm = false);
|
||||
BOOST_STATIC_CONSTANT(bool, has_denorm_loss = false);
|
||||
static BOOST_ULLT infinity() throw() { return 0; };
|
||||
static BOOST_ULLT quiet_NaN() throw() { return 0; };
|
||||
static BOOST_ULLT signaling_NaN() throw() { return 0; };
|
||||
static BOOST_ULLT denorm_min() throw() { return 0; };
|
||||
|
||||
BOOST_STATIC_CONSTANT(bool, is_iec559 = false);
|
||||
BOOST_STATIC_CONSTANT(bool, is_bounded = true);
|
||||
BOOST_STATIC_CONSTANT(bool, is_modulo = true);
|
||||
|
||||
BOOST_STATIC_CONSTANT(bool, traps = false);
|
||||
BOOST_STATIC_CONSTANT(bool, tinyness_before = false);
|
||||
BOOST_STATIC_CONSTANT(float_round_style, round_style = round_toward_zero);
|
||||
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
104
Engine/Zalla3D Base Class/Boost/pool/detail/ct_gcd_lcm.hpp
Normal file
104
Engine/Zalla3D Base Class/Boost/pool/detail/ct_gcd_lcm.hpp
Normal file
@@ -0,0 +1,104 @@
|
||||
// Copyright (C) 2000 Stephen Cleary
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_POOL_CT_GCD_LCM_HPP
|
||||
#define BOOST_POOL_CT_GCD_LCM_HPP
|
||||
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type_traits/ice.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace details {
|
||||
namespace pool {
|
||||
|
||||
// Compile-time calculation of greatest common divisor and least common multiple
|
||||
|
||||
//
|
||||
// ct_gcd is a compile-time algorithm that calculates the greatest common
|
||||
// divisor of two unsigned integers, using Euclid's algorithm.
|
||||
//
|
||||
// assumes: A != 0 && B != 0
|
||||
//
|
||||
|
||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
namespace details {
|
||||
template <unsigned A, unsigned B, bool Bis0>
|
||||
struct ct_gcd_helper;
|
||||
template <unsigned A, unsigned B>
|
||||
struct ct_gcd_helper<A, B, false>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(unsigned, A_mod_B_ = A % B);
|
||||
BOOST_STATIC_CONSTANT(unsigned, value =
|
||||
(::boost::details::pool::details::ct_gcd_helper<
|
||||
B, static_cast<unsigned>(A_mod_B_),
|
||||
::boost::type_traits::ice_eq<A_mod_B_, 0>::value
|
||||
>::value) );
|
||||
};
|
||||
template <unsigned A, unsigned B>
|
||||
struct ct_gcd_helper<A, B, true>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(unsigned, value = A);
|
||||
};
|
||||
} // namespace details
|
||||
|
||||
template <unsigned A, unsigned B>
|
||||
struct ct_gcd
|
||||
{
|
||||
BOOST_STATIC_ASSERT(A != 0 && B != 0);
|
||||
BOOST_STATIC_CONSTANT(unsigned, value =
|
||||
(::boost::details::pool::details::ct_gcd_helper<A, B, false>::value) );
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
// Thanks to Peter Dimov for providing this workaround!
|
||||
namespace details {
|
||||
template<unsigned A> struct ct_gcd2
|
||||
{
|
||||
template<unsigned B>
|
||||
struct helper
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(unsigned, value = ct_gcd2<B>::helper<A % B>::value);
|
||||
};
|
||||
template<>
|
||||
struct helper<0>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(unsigned, value = A);
|
||||
};
|
||||
};
|
||||
} // namespace details
|
||||
|
||||
template<unsigned A, unsigned B> struct ct_gcd
|
||||
{
|
||||
BOOST_STATIC_ASSERT(A != 0 && B != 0);
|
||||
enum { value = details::ct_gcd2<A>::helper<B>::value };
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// ct_lcm is a compile-time algorithm that calculates the least common
|
||||
// multiple of two unsigned integers.
|
||||
//
|
||||
// assumes: A != 0 && B != 0
|
||||
//
|
||||
template <unsigned A, unsigned B>
|
||||
struct ct_lcm
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(unsigned, value =
|
||||
(A / ::boost::details::pool::ct_gcd<A, B>::value * B) );
|
||||
};
|
||||
|
||||
} // namespace pool
|
||||
} // namespace details
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
107
Engine/Zalla3D Base Class/Boost/pool/detail/for.m4
Normal file
107
Engine/Zalla3D Base Class/Boost/pool/detail/for.m4
Normal file
@@ -0,0 +1,107 @@
|
||||
m4_dnl
|
||||
m4_dnl Copyright (C) 2000 Stephen Cleary
|
||||
m4_dnl
|
||||
m4_dnl Distributed under the Boost Software License, Version 1.0. (See accompany-
|
||||
m4_dnl ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
m4_dnl
|
||||
m4_dnl See http://www.boost.org for updates, documentation, and revision history.
|
||||
m4_dnl
|
||||
m4_dnl
|
||||
m4_dnl
|
||||
m4_dnl BOOST_M4_FOR: repeat a given text for a range of values
|
||||
m4_dnl $1 - variable to hold the current value.
|
||||
m4_dnl $2 - the starting value.
|
||||
m4_dnl $3 - the ending value (text is _not_ repeated for this value).
|
||||
m4_dnl $4 - the text to repeat.
|
||||
m4_dnl $5 - the delimeter text (optional).
|
||||
m4_dnl
|
||||
m4_dnl If the starting value is < ending value:
|
||||
m4_dnl Will repeat $4, binding $1 to the values in the range [$2, $3).
|
||||
m4_dnl Else (that is, starting value >= ending value):
|
||||
m4_dnl Will do nothing
|
||||
m4_dnl Repeats $5 in-between each occurrence of $4
|
||||
m4_dnl
|
||||
m4_dnl Logic:
|
||||
m4_dnl Set $1 to $2 and call BOOST_M4_FOR_LIST_HELPER:
|
||||
m4_dnl If $1 >= $3, do nothing
|
||||
m4_dnl Else
|
||||
m4_dnl output $4,
|
||||
m4_dnl set $1 to itself incremented,
|
||||
m4_dnl If $1 != $3, output $5,
|
||||
m4_dnl and use recursion
|
||||
m4_dnl
|
||||
m4_define(`BOOST_M4_FOR',
|
||||
`m4_ifelse(m4_eval($# < 4 || $# > 5), 1,
|
||||
`m4_errprint(m4___file__:m4___line__: `Boost m4 script: BOOST_M4_FOR: Wrong number of arguments ($#)')',
|
||||
`m4_pushdef(`$1', `$2')BOOST_M4_FOR_HELPER($@)m4_popdef(`$1')')')m4_dnl
|
||||
m4_define(`BOOST_M4_FOR_HELPER',
|
||||
`m4_ifelse(m4_eval($1 >= $3), 1, ,
|
||||
`$4`'m4_define(`$1', m4_incr($1))m4_ifelse(m4_eval($1 != $3), 1, `$5')`'BOOST_M4_FOR_HELPER($@)')')m4_dnl
|
||||
m4_dnl
|
||||
m4_dnl Testing/Examples:
|
||||
m4_dnl
|
||||
m4_dnl The following line will output:
|
||||
m4_dnl "repeat.m4:42: Boost m4 script: BOOST_M4_FOR: Wrong number of arguments (3)"
|
||||
m4_dnl BOOST_M4_FOR(i, 1, 3)
|
||||
m4_dnl
|
||||
m4_dnl The following line will output:
|
||||
m4_dnl "repeat.m4:46: Boost m4 script: BOOST_M4_FOR: Wrong number of arguments (6)"
|
||||
m4_dnl BOOST_M4_FOR(i, 1, 3, i, ` ', 13)
|
||||
m4_dnl
|
||||
m4_dnl The following line will output (nothing):
|
||||
m4_dnl ""
|
||||
m4_dnl BOOST_M4_FOR(i, 7, 0, i )
|
||||
m4_dnl
|
||||
m4_dnl The following line will output (nothing):
|
||||
m4_dnl ""
|
||||
m4_dnl BOOST_M4_FOR(i, 0, 0, i )
|
||||
m4_dnl
|
||||
m4_dnl The following line will output:
|
||||
m4_dnl "0 1 2 3 4 5 6 "
|
||||
m4_dnl BOOST_M4_FOR(i, 0, 7, i )
|
||||
m4_dnl
|
||||
m4_dnl The following line will output:
|
||||
m4_dnl "-13 -12 -11 "
|
||||
m4_dnl BOOST_M4_FOR(i, -13, -10, i )
|
||||
m4_dnl
|
||||
m4_dnl The following two lines will output:
|
||||
m4_dnl "(0, 0) (0, 1) (0, 2) (0, 3) "
|
||||
m4_dnl "(1, 0) (1, 1) (1, 2) (1, 3) "
|
||||
m4_dnl "(2, 0) (2, 1) (2, 2) (2, 3) "
|
||||
m4_dnl "(3, 0) (3, 1) (3, 2) (3, 3) "
|
||||
m4_dnl "(4, 0) (4, 1) (4, 2) (4, 3) "
|
||||
m4_dnl "(5, 0) (5, 1) (5, 2) (5, 3) "
|
||||
m4_dnl "(6, 0) (6, 1) (6, 2) (6, 3) "
|
||||
m4_dnl "(7, 0) (7, 1) (7, 2) (7, 3) "
|
||||
m4_dnl ""
|
||||
m4_dnl BOOST_M4_FOR(i, 0, 8, BOOST_M4_FOR(j, 0, 4, (i, j) )
|
||||
m4_dnl )
|
||||
m4_dnl
|
||||
m4_dnl The following line will output (nothing):
|
||||
m4_dnl ""
|
||||
m4_dnl BOOST_M4_FOR(i, 7, 0, i, |)
|
||||
m4_dnl
|
||||
m4_dnl The following line will output (nothing):
|
||||
m4_dnl ""
|
||||
m4_dnl BOOST_M4_FOR(i, 0, 0, i, |)
|
||||
m4_dnl
|
||||
m4_dnl The following line will output:
|
||||
m4_dnl "0|1|2|3|4|5|6"
|
||||
m4_dnl BOOST_M4_FOR(i, 0, 7, i, |)
|
||||
m4_dnl
|
||||
m4_dnl The following line will output:
|
||||
m4_dnl "-13, -12, -11"
|
||||
m4_dnl BOOST_M4_FOR(i, -13, -10, i, `, ')
|
||||
m4_dnl
|
||||
m4_dnl The following two lines will output:
|
||||
m4_dnl "[(0, 0), (0, 1), (0, 2), (0, 3)],"
|
||||
m4_dnl "[(1, 0), (1, 1), (1, 2), (1, 3)],"
|
||||
m4_dnl "[(2, 0), (2, 1), (2, 2), (2, 3)],"
|
||||
m4_dnl "[(3, 0), (3, 1), (3, 2), (3, 3)],"
|
||||
m4_dnl "[(4, 0), (4, 1), (4, 2), (4, 3)],"
|
||||
m4_dnl "[(5, 0), (5, 1), (5, 2), (5, 3)],"
|
||||
m4_dnl "[(6, 0), (6, 1), (6, 2), (6, 3)],"
|
||||
m4_dnl "[(7, 0), (7, 1), (7, 2), (7, 3)]"
|
||||
m4_dnl BOOST_M4_FOR(i, 0, 8, `[BOOST_M4_FOR(j, 0, 4, (i, j), `, ')]', `,
|
||||
m4_dnl ')
|
||||
m4_dnl
|
||||
58
Engine/Zalla3D Base Class/Boost/pool/detail/gcd_lcm.hpp
Normal file
58
Engine/Zalla3D Base Class/Boost/pool/detail/gcd_lcm.hpp
Normal file
@@ -0,0 +1,58 @@
|
||||
// Copyright (C) 2000 Stephen Cleary
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_POOL_GCD_LCM_HPP
|
||||
#define BOOST_POOL_GCD_LCM_HPP
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace details {
|
||||
namespace pool {
|
||||
|
||||
// Greatest common divisor and least common multiple
|
||||
|
||||
//
|
||||
// gcd is an algorithm that calculates the greatest common divisor of two
|
||||
// integers, using Euclid's algorithm.
|
||||
//
|
||||
// Pre: A > 0 && B > 0
|
||||
// Recommended: A > B
|
||||
template <typename Integer>
|
||||
Integer gcd(Integer A, Integer B)
|
||||
{
|
||||
do
|
||||
{
|
||||
const Integer tmp(B);
|
||||
B = A % B;
|
||||
A = tmp;
|
||||
} while (B != 0);
|
||||
|
||||
return A;
|
||||
}
|
||||
|
||||
//
|
||||
// lcm is an algorithm that calculates the least common multiple of two
|
||||
// integers.
|
||||
//
|
||||
// Pre: A > 0 && B > 0
|
||||
// Recommended: A > B
|
||||
template <typename Integer>
|
||||
Integer lcm(const Integer & A, const Integer & B)
|
||||
{
|
||||
Integer ret = A;
|
||||
ret /= gcd(A, B);
|
||||
ret *= B;
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace pool
|
||||
} // namespace details
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
40
Engine/Zalla3D Base Class/Boost/pool/detail/guard.hpp
Normal file
40
Engine/Zalla3D Base Class/Boost/pool/detail/guard.hpp
Normal file
@@ -0,0 +1,40 @@
|
||||
// Copyright (C) 2000 Stephen Cleary
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_POOL_GUARD_HPP
|
||||
#define BOOST_POOL_GUARD_HPP
|
||||
|
||||
// Extremely Light-Weight guard glass
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace details {
|
||||
namespace pool {
|
||||
|
||||
template <typename Mutex>
|
||||
class guard
|
||||
{
|
||||
private:
|
||||
Mutex & mtx;
|
||||
|
||||
guard(const guard &);
|
||||
void operator=(const guard &);
|
||||
|
||||
public:
|
||||
explicit guard(Mutex & nmtx)
|
||||
:mtx(nmtx) { mtx.lock(); }
|
||||
|
||||
~guard() { mtx.unlock(); }
|
||||
};
|
||||
|
||||
} // namespace pool
|
||||
} // namespace details
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
145
Engine/Zalla3D Base Class/Boost/pool/detail/mutex.hpp
Normal file
145
Engine/Zalla3D Base Class/Boost/pool/detail/mutex.hpp
Normal file
@@ -0,0 +1,145 @@
|
||||
// Copyright (C) 2000 Stephen Cleary
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_POOL_MUTEX_HPP
|
||||
#define BOOST_POOL_MUTEX_HPP
|
||||
|
||||
#include <boost/config.hpp> // for workarounds
|
||||
|
||||
// Extremely Light-Weight wrapper classes for OS thread synchronization
|
||||
|
||||
// Configuration: for now, we just choose between pthread or Win32 mutexes or none
|
||||
|
||||
#define BOOST_MUTEX_HELPER_NONE 0
|
||||
#define BOOST_MUTEX_HELPER_WIN32 1
|
||||
#define BOOST_MUTEX_HELPER_PTHREAD 2
|
||||
|
||||
#if !defined(BOOST_HAS_THREADS) && !defined(BOOST_NO_MT)
|
||||
# define BOOST_NO_MT
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_NO_MT
|
||||
// No multithreading -> make locks into no-ops
|
||||
#define BOOST_MUTEX_HELPER BOOST_MUTEX_HELPER_NONE
|
||||
#else
|
||||
#ifdef BOOST_WINDOWS
|
||||
#define BOOST_MUTEX_HELPER BOOST_MUTEX_HELPER_WIN32
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#ifdef _POSIX_THREADS
|
||||
#define BOOST_MUTEX_HELPER BOOST_MUTEX_HELPER_PTHREAD
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_MUTEX_HELPER
|
||||
#error Unable to determine platform mutex type; define BOOST_NO_MT to assume single-threaded
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_MT
|
||||
# ifdef BOOST_WINDOWS
|
||||
# include <windows.h>
|
||||
# endif
|
||||
# ifdef _POSIX_THREADS
|
||||
# include <pthread.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace details {
|
||||
namespace pool {
|
||||
|
||||
#ifndef BOOST_NO_MT
|
||||
|
||||
#ifdef BOOST_WINDOWS
|
||||
|
||||
class win32_mutex
|
||||
{
|
||||
private:
|
||||
CRITICAL_SECTION mtx;
|
||||
|
||||
win32_mutex(const win32_mutex &);
|
||||
void operator=(const win32_mutex &);
|
||||
|
||||
public:
|
||||
win32_mutex()
|
||||
{ InitializeCriticalSection(&mtx); }
|
||||
|
||||
~win32_mutex()
|
||||
{ DeleteCriticalSection(&mtx); }
|
||||
|
||||
void lock()
|
||||
{ EnterCriticalSection(&mtx); }
|
||||
|
||||
void unlock()
|
||||
{ LeaveCriticalSection(&mtx); }
|
||||
};
|
||||
|
||||
#endif // defined(BOOST_WINDOWS)
|
||||
|
||||
#ifdef _POSIX_THREADS
|
||||
|
||||
class pthread_mutex
|
||||
{
|
||||
private:
|
||||
pthread_mutex_t mtx;
|
||||
|
||||
pthread_mutex(const pthread_mutex &);
|
||||
void operator=(const pthread_mutex &);
|
||||
|
||||
public:
|
||||
pthread_mutex()
|
||||
{ pthread_mutex_init(&mtx, 0); }
|
||||
|
||||
~pthread_mutex()
|
||||
{ pthread_mutex_destroy(&mtx); }
|
||||
|
||||
void lock()
|
||||
{ pthread_mutex_lock(&mtx); }
|
||||
|
||||
void unlock()
|
||||
{ pthread_mutex_unlock(&mtx); }
|
||||
};
|
||||
|
||||
#endif // defined(_POSIX_THREADS)
|
||||
|
||||
#endif // !defined(BOOST_NO_MT)
|
||||
|
||||
class null_mutex
|
||||
{
|
||||
private:
|
||||
null_mutex(const null_mutex &);
|
||||
void operator=(const null_mutex &);
|
||||
|
||||
public:
|
||||
null_mutex() { }
|
||||
|
||||
static void lock() { }
|
||||
static void unlock() { }
|
||||
};
|
||||
|
||||
#if BOOST_MUTEX_HELPER == BOOST_MUTEX_HELPER_NONE
|
||||
typedef null_mutex default_mutex;
|
||||
#elif BOOST_MUTEX_HELPER == BOOST_MUTEX_HELPER_WIN32
|
||||
typedef win32_mutex default_mutex;
|
||||
#elif BOOST_MUTEX_HELPER == BOOST_MUTEX_HELPER_PTHREAD
|
||||
typedef pthread_mutex default_mutex;
|
||||
#endif
|
||||
|
||||
} // namespace pool
|
||||
} // namespace details
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#undef BOOST_MUTEX_HELPER_WIN32
|
||||
#undef BOOST_MUTEX_HELPER_PTHREAD
|
||||
#undef BOOST_MUTEX_HELPER_NONE
|
||||
#undef BOOST_MUTEX_HELPER
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,24 @@
|
||||
@echo off
|
||||
rem
|
||||
rem Copyright (C) 2000, 2001 Stephen Cleary
|
||||
rem
|
||||
rem Distributed under the Boost Software License, Version 1.0. (See accompany-
|
||||
rem ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
|
||||
|
||||
rem Check for Windows NT
|
||||
if %OS%==Windows_NT goto NT
|
||||
|
||||
rem Not NT - run m4 as normal, then exit
|
||||
m4 -P -E -DNumberOfArguments=%1 pool_construct.m4 > pool_construct.inc
|
||||
goto end
|
||||
|
||||
rem DJGPP programs (including m4) running on Windows/NT do NOT support long
|
||||
rem file names (see the DJGPP v2 FAQ, question 8.1)
|
||||
rem Note that the output doesn't have to be a short name because it's an
|
||||
rem argument to the command shell, not m4.
|
||||
:NT
|
||||
m4 -P -E -DNumberOfArguments=%1 < pool_construct.m4 > pool_construct.inc
|
||||
|
||||
:end
|
||||
853
Engine/Zalla3D Base Class/Boost/pool/detail/pool_construct.inc
Normal file
853
Engine/Zalla3D Base Class/Boost/pool/detail/pool_construct.inc
Normal file
@@ -0,0 +1,853 @@
|
||||
// Copyright (C) 2000 Stephen Cleary
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
// This file was AUTOMATICALLY GENERATED from "pool_c~1.m4"
|
||||
// Do NOT include directly!
|
||||
// Do NOT edit!
|
||||
|
||||
template <typename T0>
|
||||
element_type * construct(T0 & a0)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0>
|
||||
element_type * construct(const T0 & a0)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0>
|
||||
element_type * construct(volatile T0 & a0)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0>
|
||||
element_type * construct(const volatile T0 & a0)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1>
|
||||
element_type * construct(T0 & a0, T1 & a1)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1>
|
||||
element_type * construct(const T0 & a0, T1 & a1)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1>
|
||||
element_type * construct(volatile T0 & a0, T1 & a1)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1>
|
||||
element_type * construct(const volatile T0 & a0, T1 & a1)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1>
|
||||
element_type * construct(T0 & a0, const T1 & a1)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1>
|
||||
element_type * construct(const T0 & a0, const T1 & a1)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1>
|
||||
element_type * construct(volatile T0 & a0, const T1 & a1)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1>
|
||||
element_type * construct(const volatile T0 & a0, const T1 & a1)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1>
|
||||
element_type * construct(T0 & a0, volatile T1 & a1)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1>
|
||||
element_type * construct(const T0 & a0, volatile T1 & a1)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1>
|
||||
element_type * construct(volatile T0 & a0, volatile T1 & a1)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1>
|
||||
element_type * construct(const volatile T0 & a0, volatile T1 & a1)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1>
|
||||
element_type * construct(T0 & a0, const volatile T1 & a1)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1>
|
||||
element_type * construct(const T0 & a0, const volatile T1 & a1)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1>
|
||||
element_type * construct(volatile T0 & a0, const volatile T1 & a1)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1>
|
||||
element_type * construct(const volatile T0 & a0, const volatile T1 & a1)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(T0 & a0, T1 & a1, T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(const T0 & a0, T1 & a1, T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(volatile T0 & a0, T1 & a1, T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(const volatile T0 & a0, T1 & a1, T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(T0 & a0, const T1 & a1, T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(const T0 & a0, const T1 & a1, T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(volatile T0 & a0, const T1 & a1, T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(const volatile T0 & a0, const T1 & a1, T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(T0 & a0, volatile T1 & a1, T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(const T0 & a0, volatile T1 & a1, T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(volatile T0 & a0, volatile T1 & a1, T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(const volatile T0 & a0, volatile T1 & a1, T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(T0 & a0, const volatile T1 & a1, T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(const T0 & a0, const volatile T1 & a1, T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(volatile T0 & a0, const volatile T1 & a1, T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(const volatile T0 & a0, const volatile T1 & a1, T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(T0 & a0, T1 & a1, const T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(const T0 & a0, T1 & a1, const T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(volatile T0 & a0, T1 & a1, const T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(const volatile T0 & a0, T1 & a1, const T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(T0 & a0, const T1 & a1, const T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(const T0 & a0, const T1 & a1, const T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(volatile T0 & a0, const T1 & a1, const T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(const volatile T0 & a0, const T1 & a1, const T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(T0 & a0, volatile T1 & a1, const T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(const T0 & a0, volatile T1 & a1, const T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(volatile T0 & a0, volatile T1 & a1, const T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(const volatile T0 & a0, volatile T1 & a1, const T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(T0 & a0, const volatile T1 & a1, const T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(const T0 & a0, const volatile T1 & a1, const T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(volatile T0 & a0, const volatile T1 & a1, const T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(const volatile T0 & a0, const volatile T1 & a1, const T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(T0 & a0, T1 & a1, volatile T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(const T0 & a0, T1 & a1, volatile T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(volatile T0 & a0, T1 & a1, volatile T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(const volatile T0 & a0, T1 & a1, volatile T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(T0 & a0, const T1 & a1, volatile T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(const T0 & a0, const T1 & a1, volatile T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(volatile T0 & a0, const T1 & a1, volatile T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(const volatile T0 & a0, const T1 & a1, volatile T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(T0 & a0, volatile T1 & a1, volatile T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(const T0 & a0, volatile T1 & a1, volatile T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(volatile T0 & a0, volatile T1 & a1, volatile T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(const volatile T0 & a0, volatile T1 & a1, volatile T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(T0 & a0, const volatile T1 & a1, volatile T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(const T0 & a0, const volatile T1 & a1, volatile T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(volatile T0 & a0, const volatile T1 & a1, volatile T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(const volatile T0 & a0, const volatile T1 & a1, volatile T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(T0 & a0, T1 & a1, const volatile T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(const T0 & a0, T1 & a1, const volatile T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(volatile T0 & a0, T1 & a1, const volatile T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(const volatile T0 & a0, T1 & a1, const volatile T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(T0 & a0, const T1 & a1, const volatile T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(const T0 & a0, const T1 & a1, const volatile T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(volatile T0 & a0, const T1 & a1, const volatile T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(const volatile T0 & a0, const T1 & a1, const volatile T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(T0 & a0, volatile T1 & a1, const volatile T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(const T0 & a0, volatile T1 & a1, const volatile T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(volatile T0 & a0, volatile T1 & a1, const volatile T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(const volatile T0 & a0, volatile T1 & a1, const volatile T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(T0 & a0, const volatile T1 & a1, const volatile T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(const T0 & a0, const volatile T1 & a1, const volatile T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(volatile T0 & a0, const volatile T1 & a1, const volatile T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(const volatile T0 & a0, const volatile T1 & a1, const volatile T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
m4_dnl
|
||||
m4_dnl Copyright (C) 2000 Stephen Cleary
|
||||
m4_dnl
|
||||
m4_dnl Distributed under the Boost Software License, Version 1.0. (See accompany-
|
||||
m4_dnl ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
m4_dnl
|
||||
m4_dnl See http://www.boost.org for updates, documentation, and revision history.
|
||||
m4_dnl
|
||||
m4_dnl
|
||||
m4_dnl
|
||||
m4_dnl Avoid the use of any m4_* identifiers in this header file,
|
||||
m4_dnl as that may cause incompatibility problems with future
|
||||
m4_dnl versions of m4.
|
||||
m4_dnl
|
||||
m4_dnl This is a normal header file, except that lines starting
|
||||
m4_dnl with `m4_dnl' will be stripped, TBA_FOR
|
||||
m4_dnl macros will be replaced with repeated text, and text in
|
||||
m4_dnl single quotes (`...') will have their single quotes
|
||||
m4_dnl stripped.
|
||||
m4_dnl
|
||||
m4_dnl
|
||||
m4_dnl Check to make sure NumberOfArguments was defined. If it's not defined,
|
||||
m4_dnl default to 3
|
||||
m4_dnl
|
||||
m4_ifdef(`NumberOfArguments', , `m4_errprint(m4___file__:m4___line__`: NumberOfArguments is not defined; defaulting to 3
|
||||
')m4_define(`NumberOfArguments', 3)')m4_dnl
|
||||
m4_ifelse(NumberOfArguments, , `m4_errprint(m4___file__:m4___line__`: NumberOfArguments is defined to be empty; defaulting to 3
|
||||
')m4_define(`NumberOfArguments', 3)')m4_dnl
|
||||
m4_dnl
|
||||
m4_dnl Check to make sure NumberOfArguments >= 1. If it's not, then fatal error.
|
||||
m4_dnl
|
||||
m4_ifelse(m4_eval(NumberOfArguments < 1), 1, `m4_errprint(m4___file__:m4___line__`: NumberOfArguments ('NumberOfArguments`) is less than 1
|
||||
')m4_m4exit(1)')m4_dnl
|
||||
m4_dnl
|
||||
m4_dnl Include the BOOST_M4_FOR macro definition
|
||||
m4_dnl
|
||||
m4_include(`for.m4')`'m4_dnl
|
||||
m4_dnl
|
||||
m4_dnl Begin the generated file.
|
||||
m4_dnl
|
||||
// Copyright (C) 2000 Stephen Cleary
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompany-
|
||||
// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
m4_dnl These warnings apply to the file generated from this file.
|
||||
m4_dnl Of course, you may freely edit this file.
|
||||
// This file was AUTOMATICALLY GENERATED from "m4___file__"
|
||||
// Do NOT include directly!
|
||||
// Do NOT edit!
|
||||
|
||||
m4_dnl
|
||||
m4_dnl First we define a simple 'cv_qual' macro which takes a number, either
|
||||
m4_dnl 0, 1, 2, or 3, and determines cv-qualification.
|
||||
m4_dnl
|
||||
m4_define(`cv_qual',
|
||||
`m4_ifelse($1, 0, `',
|
||||
`m4_ifelse($1, 1, `const ',
|
||||
`m4_ifelse($1, 2, `volatile ',
|
||||
`m4_ifelse($1, 3, `const volatile ',
|
||||
`m4_errprint(m4___file__:m4___line__: `Boost m4 script: cv-determiner: Not 0, 1, 2, or 3 (was '$1`)')'
|
||||
)')')')')m4_dnl
|
||||
m4_dnl
|
||||
m4_dnl Next we go through the actual loop. For each number of arguments from
|
||||
m4_dnl 1 to NumberOfArguments, we create a template function that takes that
|
||||
m4_dnl many template arguments, and also generate all cv-qualified permutations
|
||||
m4_dnl of that function.
|
||||
m4_dnl
|
||||
BOOST_M4_FOR(N, 1, NumberOfArguments + 1,
|
||||
`BOOST_M4_FOR(cv, 0, m4_eval(4 ** N),
|
||||
`template <BOOST_M4_FOR(i, 0, N, `typename T`'i', `, ')>
|
||||
element_type * construct(BOOST_M4_FOR(i, 0, N,
|
||||
`cv_qual(m4_eval((cv >> (i * 2)) % 4))T`'i & a`'i', `, '))
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(BOOST_M4_FOR(i, 0, N, `a`'i', `, ')); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
')')
|
||||
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2000 Stephen Cleary
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0. (See accompany-
|
||||
# ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
#
|
||||
# See http://www.boost.org for updates, documentation, and revision history.
|
||||
#
|
||||
|
||||
m4 -P -E -DNumberOfArguments=$1 pool_construct.m4 > pool_construct.inc
|
||||
@@ -0,0 +1,25 @@
|
||||
@echo off
|
||||
rem
|
||||
rem Copyright (C) 2001 Stephen Cleary
|
||||
rem
|
||||
rem Distributed under the Boost Software License, Version 1.0. (See accompany-
|
||||
rem ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
rem
|
||||
rem See http://www.boost.org for updates, documentation, and revision history.
|
||||
rem
|
||||
|
||||
rem Check for Windows NT
|
||||
if %OS%==Windows_NT goto NT
|
||||
|
||||
rem Not NT - run m4 as normal, then exit
|
||||
m4 -P -E -DNumberOfArguments=%1 pool_construct_simple.m4 > pool_construct_simple.inc
|
||||
goto end
|
||||
|
||||
rem DJGPP programs (including m4) running on Windows/NT do NOT support long
|
||||
rem file names (see the DJGPP v2 FAQ, question 8.1)
|
||||
rem Note that the output doesn't have to be a short name because it's an
|
||||
rem argument to the command shell, not m4.
|
||||
:NT
|
||||
m4 -P -E -DNumberOfArguments=%1 < pool_construct_simple.m4 > pool_construct_simple.inc
|
||||
|
||||
:end
|
||||
@@ -0,0 +1,43 @@
|
||||
// Copyright (C) 2000 Stephen Cleary
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
// This file was AUTOMATICALLY GENERATED from "stdin"
|
||||
// Do NOT include directly!
|
||||
// Do NOT edit!
|
||||
|
||||
template <typename T0>
|
||||
element_type * construct(const T0 & a0)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1>
|
||||
element_type * construct(const T0 & a0, const T1 & a1)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
template <typename T0, typename T1, typename T2>
|
||||
element_type * construct(const T0 & a0, const T1 & a1, const T2 & a2)
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(a0, a1, a2); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
m4_dnl
|
||||
m4_dnl Copyright (C) 2001 Stephen Cleary
|
||||
m4_dnl
|
||||
m4_dnl Distributed under the Boost Software License, Version 1.0. (See accompany-
|
||||
m4_dnl ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
m4_dnl
|
||||
m4_dnl See http://www.boost.org for updates, documentation, and revision history.
|
||||
m4_dnl
|
||||
m4_dnl
|
||||
m4_dnl
|
||||
m4_dnl Avoid the use of any m4_* identifiers in this header file,
|
||||
m4_dnl as that may cause incompatibility problems with future
|
||||
m4_dnl versions of m4.
|
||||
m4_dnl
|
||||
m4_dnl This is a normal header file, except that lines starting
|
||||
m4_dnl with `m4_dnl' will be stripped, TBA_FOR
|
||||
m4_dnl macros will be replaced with repeated text, and text in
|
||||
m4_dnl single quotes (`...') will have their single quotes
|
||||
m4_dnl stripped.
|
||||
m4_dnl
|
||||
m4_dnl
|
||||
m4_dnl Check to make sure NumberOfArguments was defined. If it's not defined,
|
||||
m4_dnl default to 3
|
||||
m4_dnl
|
||||
m4_ifdef(`NumberOfArguments', , `m4_errprint(m4___file__:m4___line__`: NumberOfArguments is not defined; defaulting to 3
|
||||
')m4_define(`NumberOfArguments', 3)')m4_dnl
|
||||
m4_ifelse(NumberOfArguments, , `m4_errprint(m4___file__:m4___line__`: NumberOfArguments is defined to be empty; defaulting to 3
|
||||
')m4_define(`NumberOfArguments', 3)')m4_dnl
|
||||
m4_dnl
|
||||
m4_dnl Check to make sure NumberOfArguments >= 1. If it's not, then fatal error.
|
||||
m4_dnl
|
||||
m4_ifelse(m4_eval(NumberOfArguments < 1), 1, `m4_errprint(m4___file__:m4___line__`: NumberOfArguments ('NumberOfArguments`) is less than 1
|
||||
')m4_m4exit(1)')m4_dnl
|
||||
m4_dnl
|
||||
m4_dnl Include the BOOST_M4_FOR macro definition
|
||||
m4_dnl
|
||||
m4_include(`for.m4')`'m4_dnl
|
||||
m4_dnl
|
||||
m4_dnl Begin the generated file.
|
||||
m4_dnl
|
||||
// Copyright (C) 2000 Stephen Cleary
|
||||
//
|
||||
// This file can be redistributed and/or modified under the terms found
|
||||
// in "copyright.html"
|
||||
// This software and its documentation is provided "as is" without express or
|
||||
// implied warranty, and with no claim as to its suitability for any purpose.
|
||||
//
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
m4_dnl These warnings apply to the file generated from this file.
|
||||
m4_dnl Of course, you may freely edit this file.
|
||||
// This file was AUTOMATICALLY GENERATED from "m4___file__"
|
||||
// Do NOT include directly!
|
||||
// Do NOT edit!
|
||||
|
||||
m4_dnl
|
||||
m4_dnl Here we go through the actual loop. For each number of arguments from
|
||||
m4_dnl 1 to NumberOfArguments, we create a template function that takes that
|
||||
m4_dnl many template arguments.
|
||||
m4_dnl
|
||||
BOOST_M4_FOR(N, 1, NumberOfArguments + 1,
|
||||
`template <BOOST_M4_FOR(i, 0, N, `typename T`'i', `, ')>
|
||||
element_type * construct(BOOST_M4_FOR(i, 0, N,
|
||||
`const T`'i & a`'i', `, '))
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(BOOST_M4_FOR(i, 0, N, `a`'i', `, ')); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
')
|
||||
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2001 Stephen Cleary
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0. (See accompany-
|
||||
# ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
#
|
||||
# See http://www.boost.org for updates, documentation, and revision history.
|
||||
#
|
||||
|
||||
m4 -P -E -DNumberOfArguments=$1 pool_construct_simple.m4 > pool_construct_simple.inc
|
||||
107
Engine/Zalla3D Base Class/Boost/pool/detail/singleton.hpp
Normal file
107
Engine/Zalla3D Base Class/Boost/pool/detail/singleton.hpp
Normal file
@@ -0,0 +1,107 @@
|
||||
// Copyright (C) 2000 Stephen Cleary
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_POOL_SINGLETON_HPP
|
||||
#define BOOST_POOL_SINGLETON_HPP
|
||||
|
||||
// The following code might be put into some Boost.Config header in a later revision
|
||||
#ifdef __BORLANDC__
|
||||
# pragma option push -w-inl
|
||||
#endif
|
||||
|
||||
//
|
||||
// The following helper classes are placeholders for a generic "singleton"
|
||||
// class. The classes below support usage of singletons, including use in
|
||||
// program startup/shutdown code, AS LONG AS there is only one thread
|
||||
// running before main() begins, and only one thread running after main()
|
||||
// exits.
|
||||
//
|
||||
// This class is also limited in that it can only provide singleton usage for
|
||||
// classes with default constructors.
|
||||
//
|
||||
|
||||
// The design of this class is somewhat twisted, but can be followed by the
|
||||
// calling inheritance. Let us assume that there is some user code that
|
||||
// calls "singleton_default<T>::instance()". The following (convoluted)
|
||||
// sequence ensures that the same function will be called before main():
|
||||
// instance() contains a call to create_object.do_nothing()
|
||||
// Thus, object_creator is implicitly instantiated, and create_object
|
||||
// must exist.
|
||||
// Since create_object is a static member, its constructor must be
|
||||
// called before main().
|
||||
// The constructor contains a call to instance(), thus ensuring that
|
||||
// instance() will be called before main().
|
||||
// The first time instance() is called (i.e., before main()) is the
|
||||
// latest point in program execution where the object of type T
|
||||
// can be created.
|
||||
// Thus, any call to instance() will auto-magically result in a call to
|
||||
// instance() before main(), unless already present.
|
||||
// Furthermore, since the instance() function contains the object, instead
|
||||
// of the singleton_default class containing a static instance of the
|
||||
// object, that object is guaranteed to be constructed (at the latest) in
|
||||
// the first call to instance(). This permits calls to instance() from
|
||||
// static code, even if that code is called before the file-scope objects
|
||||
// in this file have been initialized.
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace details {
|
||||
namespace pool {
|
||||
|
||||
// T must be: no-throw default constructible and no-throw destructible
|
||||
template <typename T>
|
||||
struct singleton_default
|
||||
{
|
||||
private:
|
||||
struct object_creator
|
||||
{
|
||||
// This constructor does nothing more than ensure that instance()
|
||||
// is called before main() begins, thus creating the static
|
||||
// T object before multithreading race issues can come up.
|
||||
object_creator() { singleton_default<T>::instance(); }
|
||||
inline void do_nothing() const { }
|
||||
};
|
||||
static object_creator create_object;
|
||||
|
||||
singleton_default();
|
||||
|
||||
public:
|
||||
typedef T object_type;
|
||||
|
||||
// If, at any point (in user code), singleton_default<T>::instance()
|
||||
// is called, then the following function is instantiated.
|
||||
static object_type & instance()
|
||||
{
|
||||
// This is the object that we return a reference to.
|
||||
// It is guaranteed to be created before main() begins because of
|
||||
// the next line.
|
||||
static object_type obj;
|
||||
|
||||
// The following line does nothing else than force the instantiation
|
||||
// of singleton_default<T>::create_object, whose constructor is
|
||||
// called before main() begins.
|
||||
create_object.do_nothing();
|
||||
|
||||
return obj;
|
||||
}
|
||||
};
|
||||
template <typename T>
|
||||
typename singleton_default<T>::object_creator
|
||||
singleton_default<T>::create_object;
|
||||
|
||||
} // namespace pool
|
||||
} // namespace details
|
||||
|
||||
} // namespace boost
|
||||
|
||||
// The following code might be put into some Boost.Config header in a later revision
|
||||
#ifdef __BORLANDC__
|
||||
# pragma option pop
|
||||
#endif
|
||||
|
||||
#endif
|
||||
157
Engine/Zalla3D Base Class/Boost/pool/object_pool.hpp
Normal file
157
Engine/Zalla3D Base Class/Boost/pool/object_pool.hpp
Normal file
@@ -0,0 +1,157 @@
|
||||
// Copyright (C) 2000, 2001 Stephen Cleary
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_OBJECT_POOL_HPP
|
||||
#define BOOST_OBJECT_POOL_HPP
|
||||
|
||||
#include <boost/pool/poolfwd.hpp>
|
||||
|
||||
// boost::pool
|
||||
#include <boost/pool/pool.hpp>
|
||||
|
||||
// The following code will be put into Boost.Config in a later revision
|
||||
#if defined(BOOST_MSVC) || defined(__KCC)
|
||||
# define BOOST_NO_TEMPLATE_CV_REF_OVERLOADS
|
||||
#endif
|
||||
|
||||
// The following code might be put into some Boost.Config header in a later revision
|
||||
#ifdef __BORLANDC__
|
||||
# pragma option push -w-inl
|
||||
#endif
|
||||
|
||||
// There are a few places in this file where the expression "this->m" is used.
|
||||
// This expression is used to force instantiation-time name lookup, which I am
|
||||
// informed is required for strict Standard compliance. It's only necessary
|
||||
// if "m" is a member of a base class that is dependent on a template
|
||||
// parameter.
|
||||
// Thanks to Jens Maurer for pointing this out!
|
||||
|
||||
namespace boost {
|
||||
|
||||
// T must have a non-throwing destructor
|
||||
template <typename T, typename UserAllocator>
|
||||
class object_pool: protected pool<UserAllocator>
|
||||
{
|
||||
public:
|
||||
typedef T element_type;
|
||||
typedef UserAllocator user_allocator;
|
||||
typedef typename pool<UserAllocator>::size_type size_type;
|
||||
typedef typename pool<UserAllocator>::difference_type difference_type;
|
||||
|
||||
protected:
|
||||
pool<UserAllocator> & store() { return *this; }
|
||||
const pool<UserAllocator> & store() const { return *this; }
|
||||
|
||||
// for the sake of code readability :)
|
||||
static void * & nextof(void * const ptr)
|
||||
{ return *(static_cast<void **>(ptr)); }
|
||||
|
||||
public:
|
||||
// This constructor parameter is an extension!
|
||||
explicit object_pool(const size_type next_size = 32)
|
||||
:pool<UserAllocator>(sizeof(T), next_size) { }
|
||||
|
||||
~object_pool();
|
||||
|
||||
// Returns 0 if out-of-memory
|
||||
element_type * malloc()
|
||||
{ return static_cast<element_type *>(store().ordered_malloc()); }
|
||||
void free(element_type * const chunk)
|
||||
{ store().ordered_free(chunk); }
|
||||
bool is_from(element_type * const chunk) const
|
||||
{ return store().is_from(chunk); }
|
||||
|
||||
element_type * construct()
|
||||
{
|
||||
element_type * const ret = malloc();
|
||||
if (ret == 0)
|
||||
return ret;
|
||||
try { new (ret) element_type(); }
|
||||
catch (...) { free(ret); throw; }
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Include automatically-generated file for family of template construct()
|
||||
// functions
|
||||
#ifndef BOOST_NO_TEMPLATE_CV_REF_OVERLOADS
|
||||
# include <boost/pool/detail/pool_construct.inc>
|
||||
#else
|
||||
# include <boost/pool/detail/pool_construct_simple.inc>
|
||||
#endif
|
||||
|
||||
void destroy(element_type * const chunk)
|
||||
{
|
||||
chunk->~T();
|
||||
free(chunk);
|
||||
}
|
||||
|
||||
// These functions are extensions!
|
||||
size_type get_next_size() const { return store().get_next_size(); }
|
||||
void set_next_size(const size_type x) { store().set_next_size(x); }
|
||||
};
|
||||
|
||||
template <typename T, typename UserAllocator>
|
||||
object_pool<T, UserAllocator>::~object_pool()
|
||||
{
|
||||
// handle trivial case
|
||||
if (!this->list.valid())
|
||||
return;
|
||||
|
||||
details::PODptr<size_type> iter = this->list;
|
||||
details::PODptr<size_type> next = iter;
|
||||
|
||||
// Start 'freed_iter' at beginning of free list
|
||||
void * freed_iter = this->first;
|
||||
|
||||
const size_type partition_size = this->alloc_size();
|
||||
|
||||
do
|
||||
{
|
||||
// increment next
|
||||
next = next.next();
|
||||
|
||||
// delete all contained objects that aren't freed
|
||||
|
||||
// Iterate 'i' through all chunks in the memory block
|
||||
for (char * i = iter.begin(); i != iter.end(); i += partition_size)
|
||||
{
|
||||
// If this chunk is free
|
||||
if (i == freed_iter)
|
||||
{
|
||||
// Increment freed_iter to point to next in free list
|
||||
freed_iter = nextof(freed_iter);
|
||||
|
||||
// Continue searching chunks in the memory block
|
||||
continue;
|
||||
}
|
||||
|
||||
// This chunk is not free (allocated), so call its destructor
|
||||
static_cast<T *>(static_cast<void *>(i))->~T();
|
||||
// and continue searching chunks in the memory block
|
||||
}
|
||||
|
||||
// free storage
|
||||
UserAllocator::free(iter.begin());
|
||||
|
||||
// increment iter
|
||||
iter = next;
|
||||
} while (iter.valid());
|
||||
|
||||
// Make the block list empty so that the inherited destructor doesn't try to
|
||||
// free it again.
|
||||
this->list.invalidate();
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
// The following code might be put into some Boost.Config header in a later revision
|
||||
#ifdef __BORLANDC__
|
||||
# pragma option pop
|
||||
#endif
|
||||
|
||||
#endif
|
||||
580
Engine/Zalla3D Base Class/Boost/pool/pool.hpp
Normal file
580
Engine/Zalla3D Base Class/Boost/pool/pool.hpp
Normal file
@@ -0,0 +1,580 @@
|
||||
// Copyright (C) 2000, 2001 Stephen Cleary
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_POOL_HPP
|
||||
#define BOOST_POOL_HPP
|
||||
|
||||
#include <boost/config.hpp> // for workarounds
|
||||
|
||||
// std::less, std::less_equal, std::greater
|
||||
#include <functional>
|
||||
// new[], delete[], std::nothrow
|
||||
#include <new>
|
||||
// std::size_t, std::ptrdiff_t
|
||||
#include <cstddef>
|
||||
// std::malloc, std::free
|
||||
#include <cstdlib>
|
||||
// std::invalid_argument
|
||||
#include <exception>
|
||||
// std::max
|
||||
#include <algorithm>
|
||||
|
||||
#include <boost/pool/poolfwd.hpp>
|
||||
|
||||
// boost::details::pool::ct_lcm
|
||||
#include <boost/pool/detail/ct_gcd_lcm.hpp>
|
||||
// boost::details::pool::lcm
|
||||
#include <boost/pool/detail/gcd_lcm.hpp>
|
||||
// boost::simple_segregated_storage
|
||||
#include <boost/pool/simple_segregated_storage.hpp>
|
||||
|
||||
#ifdef BOOST_NO_STDC_NAMESPACE
|
||||
namespace std { using ::malloc; using ::free; }
|
||||
#endif
|
||||
|
||||
// There are a few places in this file where the expression "this->m" is used.
|
||||
// This expression is used to force instantiation-time name lookup, which I am
|
||||
// informed is required for strict Standard compliance. It's only necessary
|
||||
// if "m" is a member of a base class that is dependent on a template
|
||||
// parameter.
|
||||
// Thanks to Jens Maurer for pointing this out!
|
||||
|
||||
namespace boost {
|
||||
|
||||
struct default_user_allocator_new_delete
|
||||
{
|
||||
typedef std::size_t size_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
|
||||
static char * malloc(const size_type bytes)
|
||||
{ return new (std::nothrow) char[bytes]; }
|
||||
static void free(char * const block)
|
||||
{ delete [] block; }
|
||||
};
|
||||
|
||||
struct default_user_allocator_malloc_free
|
||||
{
|
||||
typedef std::size_t size_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
|
||||
static char * malloc(const size_type bytes)
|
||||
{ return reinterpret_cast<char *>(std::malloc(bytes)); }
|
||||
static void free(char * const block)
|
||||
{ std::free(block); }
|
||||
};
|
||||
|
||||
namespace details {
|
||||
|
||||
// PODptr is a class that pretends to be a "pointer" to different class types
|
||||
// that don't really exist. It provides member functions to access the "data"
|
||||
// of the "object" it points to. Since these "class" types are of variable
|
||||
// size, and contains some information at the *end* of its memory (for
|
||||
// alignment reasons), PODptr must contain the size of this "class" as well as
|
||||
// the pointer to this "object".
|
||||
template <typename SizeType>
|
||||
class PODptr
|
||||
{
|
||||
public:
|
||||
typedef SizeType size_type;
|
||||
|
||||
private:
|
||||
char * ptr;
|
||||
size_type sz;
|
||||
|
||||
char * ptr_next_size() const
|
||||
{ return (ptr + sz - sizeof(size_type)); }
|
||||
char * ptr_next_ptr() const
|
||||
{
|
||||
return (ptr_next_size() -
|
||||
pool::ct_lcm<sizeof(size_type), sizeof(void *)>::value);
|
||||
}
|
||||
|
||||
public:
|
||||
PODptr(char * const nptr, const size_type nsize)
|
||||
:ptr(nptr), sz(nsize) { }
|
||||
PODptr()
|
||||
:ptr(0), sz(0) { }
|
||||
|
||||
bool valid() const { return (begin() != 0); }
|
||||
void invalidate() { begin() = 0; }
|
||||
char * & begin() { return ptr; }
|
||||
char * begin() const { return ptr; }
|
||||
char * end() const { return ptr_next_ptr(); }
|
||||
size_type total_size() const { return sz; }
|
||||
size_type element_size() const
|
||||
{
|
||||
return (sz - sizeof(size_type) -
|
||||
pool::ct_lcm<sizeof(size_type), sizeof(void *)>::value);
|
||||
}
|
||||
|
||||
size_type & next_size() const
|
||||
{ return *(reinterpret_cast<size_type *>(ptr_next_size())); }
|
||||
char * & next_ptr() const
|
||||
{ return *(reinterpret_cast<char **>(ptr_next_ptr())); }
|
||||
|
||||
PODptr next() const
|
||||
{ return PODptr<size_type>(next_ptr(), next_size()); }
|
||||
void next(const PODptr & arg) const
|
||||
{
|
||||
next_ptr() = arg.begin();
|
||||
next_size() = arg.total_size();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace details
|
||||
|
||||
template <typename UserAllocator>
|
||||
class pool: protected simple_segregated_storage<
|
||||
typename UserAllocator::size_type>
|
||||
{
|
||||
public:
|
||||
typedef UserAllocator user_allocator;
|
||||
typedef typename UserAllocator::size_type size_type;
|
||||
typedef typename UserAllocator::difference_type difference_type;
|
||||
|
||||
private:
|
||||
BOOST_STATIC_CONSTANT(unsigned, min_alloc_size =
|
||||
(::boost::details::pool::ct_lcm<sizeof(void *), sizeof(size_type)>::value) );
|
||||
|
||||
// Returns 0 if out-of-memory
|
||||
// Called if malloc/ordered_malloc needs to resize the free list
|
||||
void * malloc_need_resize();
|
||||
void * ordered_malloc_need_resize();
|
||||
|
||||
protected:
|
||||
details::PODptr<size_type> list;
|
||||
|
||||
simple_segregated_storage<size_type> & store() { return *this; }
|
||||
const simple_segregated_storage<size_type> & store() const { return *this; }
|
||||
const size_type requested_size;
|
||||
size_type next_size;
|
||||
|
||||
// finds which POD in the list 'chunk' was allocated from
|
||||
details::PODptr<size_type> find_POD(void * const chunk) const;
|
||||
|
||||
// is_from() tests a chunk to determine if it belongs in a block
|
||||
static bool is_from(void * const chunk, char * const i,
|
||||
const size_type sizeof_i)
|
||||
{
|
||||
// We use std::less_equal and std::less to test 'chunk'
|
||||
// against the array bounds because standard operators
|
||||
// may return unspecified results.
|
||||
// This is to ensure portability. The operators < <= > >= are only
|
||||
// defined for pointers to objects that are 1) in the same array, or
|
||||
// 2) subobjects of the same object [5.9/2].
|
||||
// The functor objects guarantee a total order for any pointer [20.3.3/8]
|
||||
//WAS:
|
||||
// return (std::less_equal<void *>()(static_cast<void *>(i), chunk)
|
||||
// && std::less<void *>()(chunk,
|
||||
// static_cast<void *>(i + sizeof_i)));
|
||||
std::less_equal<void *> lt_eq;
|
||||
std::less<void *> lt;
|
||||
return (lt_eq(i, chunk) && lt(chunk, i + sizeof_i));
|
||||
}
|
||||
|
||||
size_type alloc_size() const
|
||||
{
|
||||
const unsigned min_size = min_alloc_size;
|
||||
return details::pool::lcm<size_type>(requested_size, min_size);
|
||||
}
|
||||
|
||||
// for the sake of code readability :)
|
||||
static void * & nextof(void * const ptr)
|
||||
{ return *(static_cast<void **>(ptr)); }
|
||||
|
||||
public:
|
||||
// The second parameter here is an extension!
|
||||
// pre: npartition_size != 0 && nnext_size != 0
|
||||
explicit pool(const size_type nrequested_size,
|
||||
const size_type nnext_size = 32)
|
||||
:list(0, 0), requested_size(nrequested_size), next_size(nnext_size)
|
||||
{ }
|
||||
|
||||
~pool() { purge_memory(); }
|
||||
|
||||
// Releases memory blocks that don't have chunks allocated
|
||||
// pre: lists are ordered
|
||||
// Returns true if memory was actually deallocated
|
||||
bool release_memory();
|
||||
|
||||
// Releases *all* memory blocks, even if chunks are still allocated
|
||||
// Returns true if memory was actually deallocated
|
||||
bool purge_memory();
|
||||
|
||||
// These functions are extensions!
|
||||
size_type get_next_size() const { return next_size; }
|
||||
void set_next_size(const size_type nnext_size) { next_size = nnext_size; }
|
||||
|
||||
// Both malloc and ordered_malloc do a quick inlined check first for any
|
||||
// free chunks. Only if we need to get another memory block do we call
|
||||
// the non-inlined *_need_resize() functions.
|
||||
// Returns 0 if out-of-memory
|
||||
void * malloc()
|
||||
{
|
||||
// Look for a non-empty storage
|
||||
if (!store().empty())
|
||||
return store().malloc();
|
||||
return malloc_need_resize();
|
||||
}
|
||||
|
||||
void * ordered_malloc()
|
||||
{
|
||||
// Look for a non-empty storage
|
||||
if (!store().empty())
|
||||
return store().malloc();
|
||||
return ordered_malloc_need_resize();
|
||||
}
|
||||
|
||||
// Returns 0 if out-of-memory
|
||||
// Allocate a contiguous section of n chunks
|
||||
void * ordered_malloc(size_type n);
|
||||
|
||||
// pre: 'chunk' must have been previously
|
||||
// returned by *this.malloc().
|
||||
void free(void * const chunk)
|
||||
{ store().free(chunk); }
|
||||
|
||||
// pre: 'chunk' must have been previously
|
||||
// returned by *this.malloc().
|
||||
void ordered_free(void * const chunk)
|
||||
{ store().ordered_free(chunk); }
|
||||
|
||||
// pre: 'chunk' must have been previously
|
||||
// returned by *this.malloc(n).
|
||||
void free(void * const chunks, const size_type n)
|
||||
{
|
||||
const size_type partition_size = alloc_size();
|
||||
const size_type total_req_size = n * requested_size;
|
||||
const size_type num_chunks = total_req_size / partition_size +
|
||||
((total_req_size % partition_size) ? true : false);
|
||||
|
||||
store().free_n(chunks, num_chunks, partition_size);
|
||||
}
|
||||
|
||||
// pre: 'chunk' must have been previously
|
||||
// returned by *this.malloc(n).
|
||||
void ordered_free(void * const chunks, const size_type n)
|
||||
{
|
||||
const size_type partition_size = alloc_size();
|
||||
const size_type total_req_size = n * requested_size;
|
||||
const size_type num_chunks = total_req_size / partition_size +
|
||||
((total_req_size % partition_size) ? true : false);
|
||||
|
||||
store().ordered_free_n(chunks, num_chunks, partition_size);
|
||||
}
|
||||
|
||||
// is_from() tests a chunk to determine if it was allocated from *this
|
||||
bool is_from(void * const chunk) const
|
||||
{
|
||||
return (find_POD(chunk).valid());
|
||||
}
|
||||
};
|
||||
|
||||
template <typename UserAllocator>
|
||||
bool pool<UserAllocator>::release_memory()
|
||||
{
|
||||
// This is the return value: it will be set to true when we actually call
|
||||
// UserAllocator::free(..)
|
||||
bool ret = false;
|
||||
|
||||
// This is a current & previous iterator pair over the memory block list
|
||||
details::PODptr<size_type> ptr = list;
|
||||
details::PODptr<size_type> prev;
|
||||
|
||||
// This is a current & previous iterator pair over the free memory chunk list
|
||||
// Note that "prev_free" in this case does NOT point to the previous memory
|
||||
// chunk in the free list, but rather the last free memory chunk before the
|
||||
// current block.
|
||||
void * free = this->first;
|
||||
void * prev_free = 0;
|
||||
|
||||
const size_type partition_size = alloc_size();
|
||||
|
||||
// Search through all the all the allocated memory blocks
|
||||
while (ptr.valid())
|
||||
{
|
||||
// At this point:
|
||||
// ptr points to a valid memory block
|
||||
// free points to either:
|
||||
// 0 if there are no more free chunks
|
||||
// the first free chunk in this or some next memory block
|
||||
// prev_free points to either:
|
||||
// the last free chunk in some previous memory block
|
||||
// 0 if there is no such free chunk
|
||||
// prev is either:
|
||||
// the PODptr whose next() is ptr
|
||||
// !valid() if there is no such PODptr
|
||||
|
||||
// If there are no more free memory chunks, then every remaining
|
||||
// block is allocated out to its fullest capacity, and we can't
|
||||
// release any more memory
|
||||
if (free == 0)
|
||||
return ret;
|
||||
|
||||
// We have to check all the chunks. If they are *all* free (i.e., present
|
||||
// in the free list), then we can free the block.
|
||||
bool all_chunks_free = true;
|
||||
|
||||
// Iterate 'i' through all chunks in the memory block
|
||||
// if free starts in the memory block, be careful to keep it there
|
||||
void * saved_free = free;
|
||||
for (char * i = ptr.begin(); i != ptr.end(); i += partition_size)
|
||||
{
|
||||
// If this chunk is not free
|
||||
if (i != free)
|
||||
{
|
||||
// We won't be able to free this block
|
||||
all_chunks_free = false;
|
||||
|
||||
// free might have travelled outside ptr
|
||||
free = saved_free;
|
||||
// Abort searching the chunks; we won't be able to free this
|
||||
// block because a chunk is not free.
|
||||
break;
|
||||
}
|
||||
|
||||
// We do not increment prev_free because we are in the same block
|
||||
free = nextof(free);
|
||||
}
|
||||
|
||||
// post: if the memory block has any chunks, free points to one of them
|
||||
// otherwise, our assertions above are still valid
|
||||
|
||||
const details::PODptr<size_type> next = ptr.next();
|
||||
|
||||
if (!all_chunks_free)
|
||||
{
|
||||
if (is_from(free, ptr.begin(), ptr.element_size()))
|
||||
{
|
||||
std::less<void *> lt;
|
||||
void * const end = ptr.end();
|
||||
do
|
||||
{
|
||||
prev_free = free;
|
||||
free = nextof(free);
|
||||
} while (free && lt(free, end));
|
||||
}
|
||||
// This invariant is now restored:
|
||||
// free points to the first free chunk in some next memory block, or
|
||||
// 0 if there is no such chunk.
|
||||
// prev_free points to the last free chunk in this memory block.
|
||||
|
||||
// We are just about to advance ptr. Maintain the invariant:
|
||||
// prev is the PODptr whose next() is ptr, or !valid()
|
||||
// if there is no such PODptr
|
||||
prev = ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
// All chunks from this block are free
|
||||
|
||||
// Remove block from list
|
||||
if (prev.valid())
|
||||
prev.next(next);
|
||||
else
|
||||
list = next;
|
||||
|
||||
// Remove all entries in the free list from this block
|
||||
if (prev_free != 0)
|
||||
nextof(prev_free) = free;
|
||||
else
|
||||
this->first = free;
|
||||
|
||||
// And release memory
|
||||
UserAllocator::free(ptr.begin());
|
||||
ret = true;
|
||||
}
|
||||
|
||||
// Increment ptr
|
||||
ptr = next;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <typename UserAllocator>
|
||||
bool pool<UserAllocator>::purge_memory()
|
||||
{
|
||||
details::PODptr<size_type> iter = list;
|
||||
|
||||
if (!iter.valid())
|
||||
return false;
|
||||
|
||||
do
|
||||
{
|
||||
// hold "next" pointer
|
||||
const details::PODptr<size_type> next = iter.next();
|
||||
|
||||
// delete the storage
|
||||
UserAllocator::free(iter.begin());
|
||||
|
||||
// increment iter
|
||||
iter = next;
|
||||
} while (iter.valid());
|
||||
|
||||
list.invalidate();
|
||||
this->first = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename UserAllocator>
|
||||
void * pool<UserAllocator>::malloc_need_resize()
|
||||
{
|
||||
// No memory in any of our storages; make a new storage,
|
||||
const size_type partition_size = alloc_size();
|
||||
const size_type POD_size = next_size * partition_size +
|
||||
details::pool::ct_lcm<sizeof(size_type), sizeof(void *)>::value + sizeof(size_type);
|
||||
char * const ptr = UserAllocator::malloc(POD_size);
|
||||
if (ptr == 0)
|
||||
return 0;
|
||||
const details::PODptr<size_type> node(ptr, POD_size);
|
||||
next_size <<= 1;
|
||||
|
||||
// initialize it,
|
||||
store().add_block(node.begin(), node.element_size(), partition_size);
|
||||
|
||||
// insert it into the list,
|
||||
node.next(list);
|
||||
list = node;
|
||||
|
||||
// and return a chunk from it.
|
||||
return store().malloc();
|
||||
}
|
||||
|
||||
template <typename UserAllocator>
|
||||
void * pool<UserAllocator>::ordered_malloc_need_resize()
|
||||
{
|
||||
// No memory in any of our storages; make a new storage,
|
||||
const size_type partition_size = alloc_size();
|
||||
const size_type POD_size = next_size * partition_size +
|
||||
details::pool::ct_lcm<sizeof(size_type), sizeof(void *)>::value + sizeof(size_type);
|
||||
char * const ptr = UserAllocator::malloc(POD_size);
|
||||
if (ptr == 0)
|
||||
return 0;
|
||||
const details::PODptr<size_type> node(ptr, POD_size);
|
||||
next_size <<= 1;
|
||||
|
||||
// initialize it,
|
||||
// (we can use "add_block" here because we know that
|
||||
// the free list is empty, so we don't have to use
|
||||
// the slower ordered version)
|
||||
store().add_block(node.begin(), node.element_size(), partition_size);
|
||||
|
||||
// insert it into the list,
|
||||
// handle border case
|
||||
if (!list.valid() || std::greater<void *>()(list.begin(), node.begin()))
|
||||
{
|
||||
node.next(list);
|
||||
list = node;
|
||||
}
|
||||
else
|
||||
{
|
||||
details::PODptr<size_type> prev = list;
|
||||
|
||||
while (true)
|
||||
{
|
||||
// if we're about to hit the end or
|
||||
// if we've found where "node" goes
|
||||
if (prev.next_ptr() == 0
|
||||
|| std::greater<void *>()(prev.next_ptr(), node.begin()))
|
||||
break;
|
||||
|
||||
prev = prev.next();
|
||||
}
|
||||
|
||||
node.next(prev.next());
|
||||
prev.next(node);
|
||||
}
|
||||
|
||||
// and return a chunk from it.
|
||||
return store().malloc();
|
||||
}
|
||||
|
||||
template <typename UserAllocator>
|
||||
void * pool<UserAllocator>::ordered_malloc(const size_type n)
|
||||
{
|
||||
const size_type partition_size = alloc_size();
|
||||
const size_type total_req_size = n * requested_size;
|
||||
const size_type num_chunks = total_req_size / partition_size +
|
||||
((total_req_size % partition_size) ? true : false);
|
||||
|
||||
void * ret = store().malloc_n(num_chunks, partition_size);
|
||||
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
// Not enougn memory in our storages; make a new storage,
|
||||
BOOST_USING_STD_MAX();
|
||||
next_size = max BOOST_PREVENT_MACRO_SUBSTITUTION(next_size, num_chunks);
|
||||
const size_type POD_size = next_size * partition_size +
|
||||
details::pool::ct_lcm<sizeof(size_type), sizeof(void *)>::value + sizeof(size_type);
|
||||
char * const ptr = UserAllocator::malloc(POD_size);
|
||||
if (ptr == 0)
|
||||
return 0;
|
||||
const details::PODptr<size_type> node(ptr, POD_size);
|
||||
|
||||
// Split up block so we can use what wasn't requested
|
||||
// (we can use "add_block" here because we know that
|
||||
// the free list is empty, so we don't have to use
|
||||
// the slower ordered version)
|
||||
if (next_size > num_chunks)
|
||||
store().add_block(node.begin() + num_chunks * partition_size,
|
||||
node.element_size() - num_chunks * partition_size, partition_size);
|
||||
|
||||
next_size <<= 1;
|
||||
|
||||
// insert it into the list,
|
||||
// handle border case
|
||||
if (!list.valid() || std::greater<void *>()(list.begin(), node.begin()))
|
||||
{
|
||||
node.next(list);
|
||||
list = node;
|
||||
}
|
||||
else
|
||||
{
|
||||
details::PODptr<size_type> prev = list;
|
||||
|
||||
while (true)
|
||||
{
|
||||
// if we're about to hit the end or
|
||||
// if we've found where "node" goes
|
||||
if (prev.next_ptr() == 0
|
||||
|| std::greater<void *>()(prev.next_ptr(), node.begin()))
|
||||
break;
|
||||
|
||||
prev = prev.next();
|
||||
}
|
||||
|
||||
node.next(prev.next());
|
||||
prev.next(node);
|
||||
}
|
||||
|
||||
// and return it.
|
||||
return node.begin();
|
||||
}
|
||||
|
||||
template <typename UserAllocator>
|
||||
details::PODptr<typename pool<UserAllocator>::size_type>
|
||||
pool<UserAllocator>::find_POD(void * const chunk) const
|
||||
{
|
||||
// We have to find which storage this chunk is from.
|
||||
details::PODptr<size_type> iter = list;
|
||||
while (iter.valid())
|
||||
{
|
||||
if (is_from(chunk, iter.begin(), iter.element_size()))
|
||||
return iter;
|
||||
iter = iter.next();
|
||||
}
|
||||
|
||||
return iter;
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
221
Engine/Zalla3D Base Class/Boost/pool/pool_alloc.hpp
Normal file
221
Engine/Zalla3D Base Class/Boost/pool/pool_alloc.hpp
Normal file
@@ -0,0 +1,221 @@
|
||||
// Copyright (C) 2000, 2001 Stephen Cleary
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_POOL_ALLOC_HPP
|
||||
#define BOOST_POOL_ALLOC_HPP
|
||||
|
||||
// std::numeric_limits
|
||||
#include <boost/limits.hpp>
|
||||
// new, std::bad_alloc
|
||||
#include <new>
|
||||
|
||||
#include <boost/pool/poolfwd.hpp>
|
||||
|
||||
// boost::singleton_pool
|
||||
#include <boost/pool/singleton_pool.hpp>
|
||||
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
// The following code will be put into Boost.Config in a later revision
|
||||
#if defined(_RWSTD_VER) || defined(__SGI_STL_PORT) || \
|
||||
BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
|
||||
#define BOOST_NO_PROPER_STL_DEALLOCATE
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
struct pool_allocator_tag { };
|
||||
|
||||
template <typename T,
|
||||
typename UserAllocator,
|
||||
typename Mutex,
|
||||
unsigned NextSize>
|
||||
class pool_allocator
|
||||
{
|
||||
public:
|
||||
typedef T value_type;
|
||||
typedef UserAllocator user_allocator;
|
||||
typedef Mutex mutex;
|
||||
BOOST_STATIC_CONSTANT(unsigned, next_size = NextSize);
|
||||
|
||||
typedef value_type * pointer;
|
||||
typedef const value_type * const_pointer;
|
||||
typedef value_type & reference;
|
||||
typedef const value_type & const_reference;
|
||||
typedef typename pool<UserAllocator>::size_type size_type;
|
||||
typedef typename pool<UserAllocator>::difference_type difference_type;
|
||||
|
||||
template <typename U>
|
||||
struct rebind
|
||||
{
|
||||
typedef pool_allocator<U, UserAllocator, Mutex, NextSize> other;
|
||||
};
|
||||
|
||||
public:
|
||||
pool_allocator() { }
|
||||
|
||||
// default copy constructor
|
||||
|
||||
// default assignment operator
|
||||
|
||||
// not explicit, mimicking std::allocator [20.4.1]
|
||||
template <typename U>
|
||||
pool_allocator(const pool_allocator<U, UserAllocator, Mutex, NextSize> &)
|
||||
{ }
|
||||
|
||||
// default destructor
|
||||
|
||||
static pointer address(reference r)
|
||||
{ return &r; }
|
||||
static const_pointer address(const_reference s)
|
||||
{ return &s; }
|
||||
static size_type max_size()
|
||||
{ return (std::numeric_limits<size_type>::max)(); }
|
||||
static void construct(const pointer ptr, const value_type & t)
|
||||
{ new (ptr) T(t); }
|
||||
static void destroy(const pointer ptr)
|
||||
{
|
||||
ptr->~T();
|
||||
(void) ptr; // avoid unused variable warning
|
||||
}
|
||||
|
||||
bool operator==(const pool_allocator &) const
|
||||
{ return true; }
|
||||
bool operator!=(const pool_allocator &) const
|
||||
{ return false; }
|
||||
|
||||
static pointer allocate(const size_type n)
|
||||
{
|
||||
const pointer ret = static_cast<pointer>(
|
||||
singleton_pool<pool_allocator_tag, sizeof(T), UserAllocator, Mutex,
|
||||
NextSize>::ordered_malloc(n) );
|
||||
if (ret == 0)
|
||||
throw std::bad_alloc();
|
||||
return ret;
|
||||
}
|
||||
static pointer allocate(const size_type n, const void * const)
|
||||
{ return allocate(n); }
|
||||
static void deallocate(const pointer ptr, const size_type n)
|
||||
{
|
||||
#ifdef BOOST_NO_PROPER_STL_DEALLOCATE
|
||||
if (ptr == 0 || n == 0)
|
||||
return;
|
||||
#endif
|
||||
singleton_pool<pool_allocator_tag, sizeof(T), UserAllocator, Mutex,
|
||||
NextSize>::ordered_free(ptr, n);
|
||||
}
|
||||
};
|
||||
|
||||
struct fast_pool_allocator_tag { };
|
||||
|
||||
template <typename T,
|
||||
typename UserAllocator,
|
||||
typename Mutex,
|
||||
unsigned NextSize>
|
||||
class fast_pool_allocator
|
||||
{
|
||||
public:
|
||||
typedef T value_type;
|
||||
typedef UserAllocator user_allocator;
|
||||
typedef Mutex mutex;
|
||||
BOOST_STATIC_CONSTANT(unsigned, next_size = NextSize);
|
||||
|
||||
typedef value_type * pointer;
|
||||
typedef const value_type * const_pointer;
|
||||
typedef value_type & reference;
|
||||
typedef const value_type & const_reference;
|
||||
typedef typename pool<UserAllocator>::size_type size_type;
|
||||
typedef typename pool<UserAllocator>::difference_type difference_type;
|
||||
|
||||
template <typename U>
|
||||
struct rebind
|
||||
{
|
||||
typedef fast_pool_allocator<U, UserAllocator, Mutex, NextSize> other;
|
||||
};
|
||||
|
||||
public:
|
||||
fast_pool_allocator() { }
|
||||
|
||||
// default copy constructor
|
||||
|
||||
// default assignment operator
|
||||
|
||||
// not explicit, mimicking std::allocator [20.4.1]
|
||||
template <typename U>
|
||||
fast_pool_allocator(
|
||||
const fast_pool_allocator<U, UserAllocator, Mutex, NextSize> &)
|
||||
{ }
|
||||
|
||||
// default destructor
|
||||
|
||||
static pointer address(reference r)
|
||||
{ return &r; }
|
||||
static const_pointer address(const_reference s)
|
||||
{ return &s; }
|
||||
static size_type max_size()
|
||||
{ return (std::numeric_limits<size_type>::max)(); }
|
||||
void construct(const pointer ptr, const value_type & t)
|
||||
{ new (ptr) T(t); }
|
||||
void destroy(const pointer ptr)
|
||||
{
|
||||
ptr->~T();
|
||||
(void) ptr; // avoid unused variable warning
|
||||
}
|
||||
|
||||
bool operator==(const fast_pool_allocator &) const
|
||||
{ return true; }
|
||||
bool operator!=(const fast_pool_allocator &) const
|
||||
{ return false; }
|
||||
|
||||
static pointer allocate(const size_type n)
|
||||
{
|
||||
const pointer ret = (n == 1) ?
|
||||
static_cast<pointer>(
|
||||
singleton_pool<fast_pool_allocator_tag, sizeof(T),
|
||||
UserAllocator, Mutex, NextSize>::malloc() ) :
|
||||
static_cast<pointer>(
|
||||
singleton_pool<fast_pool_allocator_tag, sizeof(T),
|
||||
UserAllocator, Mutex, NextSize>::ordered_malloc(n) );
|
||||
if (ret == 0)
|
||||
throw std::bad_alloc();
|
||||
return ret;
|
||||
}
|
||||
static pointer allocate(const size_type n, const void * const)
|
||||
{ return allocate(n); }
|
||||
static pointer allocate()
|
||||
{
|
||||
const pointer ret = static_cast<pointer>(
|
||||
singleton_pool<fast_pool_allocator_tag, sizeof(T),
|
||||
UserAllocator, Mutex, NextSize>::malloc() );
|
||||
if (ret == 0)
|
||||
throw std::bad_alloc();
|
||||
return ret;
|
||||
}
|
||||
static void deallocate(const pointer ptr, const size_type n)
|
||||
{
|
||||
#ifdef BOOST_NO_PROPER_STL_DEALLOCATE
|
||||
if (ptr == 0 || n == 0)
|
||||
return;
|
||||
#endif
|
||||
if (n == 1)
|
||||
singleton_pool<fast_pool_allocator_tag, sizeof(T),
|
||||
UserAllocator, Mutex, NextSize>::free(ptr);
|
||||
else
|
||||
singleton_pool<fast_pool_allocator_tag, sizeof(T),
|
||||
UserAllocator, Mutex, NextSize>::free(ptr, n);
|
||||
}
|
||||
static void deallocate(const pointer ptr)
|
||||
{
|
||||
singleton_pool<fast_pool_allocator_tag, sizeof(T),
|
||||
UserAllocator, Mutex, NextSize>::free(ptr);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
73
Engine/Zalla3D Base Class/Boost/pool/poolfwd.hpp
Normal file
73
Engine/Zalla3D Base Class/Boost/pool/poolfwd.hpp
Normal file
@@ -0,0 +1,73 @@
|
||||
// Copyright (C) 2000, 2001 Stephen Cleary
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_POOLFWD_HPP
|
||||
#define BOOST_POOLFWD_HPP
|
||||
|
||||
#include <boost/config.hpp> // for workarounds
|
||||
|
||||
// std::size_t
|
||||
#include <cstddef>
|
||||
|
||||
// boost::details::pool::default_mutex
|
||||
#include <boost/pool/detail/mutex.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
//
|
||||
// Location: <boost/pool/simple_segregated_storage.hpp>
|
||||
//
|
||||
template <typename SizeType = std::size_t>
|
||||
class simple_segregated_storage;
|
||||
|
||||
//
|
||||
// Location: <boost/pool/pool.hpp>
|
||||
//
|
||||
struct default_user_allocator_new_delete;
|
||||
struct default_user_allocator_malloc_free;
|
||||
|
||||
template <typename UserAllocator = default_user_allocator_new_delete>
|
||||
class pool;
|
||||
|
||||
//
|
||||
// Location: <boost/pool/object_pool.hpp>
|
||||
//
|
||||
template <typename T, typename UserAllocator = default_user_allocator_new_delete>
|
||||
class object_pool;
|
||||
|
||||
//
|
||||
// Location: <boost/pool/singleton_pool.hpp>
|
||||
//
|
||||
template <typename Tag, unsigned RequestedSize,
|
||||
typename UserAllocator = default_user_allocator_new_delete,
|
||||
typename Mutex = details::pool::default_mutex,
|
||||
unsigned NextSize = 32>
|
||||
struct singleton_pool;
|
||||
|
||||
//
|
||||
// Location: <boost/pool/pool_alloc.hpp>
|
||||
//
|
||||
struct pool_allocator_tag;
|
||||
|
||||
template <typename T,
|
||||
typename UserAllocator = default_user_allocator_new_delete,
|
||||
typename Mutex = details::pool::default_mutex,
|
||||
unsigned NextSize = 32>
|
||||
class pool_allocator;
|
||||
|
||||
struct fast_pool_allocator_tag;
|
||||
|
||||
template <typename T,
|
||||
typename UserAllocator = default_user_allocator_new_delete,
|
||||
typename Mutex = details::pool::default_mutex,
|
||||
unsigned NextSize = 32>
|
||||
class fast_pool_allocator;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,265 @@
|
||||
// Copyright (C) 2000, 2001 Stephen Cleary
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_SIMPLE_SEGREGATED_STORAGE_HPP
|
||||
#define BOOST_SIMPLE_SEGREGATED_STORAGE_HPP
|
||||
|
||||
// std::greater
|
||||
#include <functional>
|
||||
|
||||
#include <boost/pool/poolfwd.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
template <typename SizeType>
|
||||
class simple_segregated_storage
|
||||
{
|
||||
public:
|
||||
typedef SizeType size_type;
|
||||
|
||||
private:
|
||||
simple_segregated_storage(const simple_segregated_storage &);
|
||||
void operator=(const simple_segregated_storage &);
|
||||
|
||||
// pre: (n > 0), (start != 0), (nextof(start) != 0)
|
||||
// post: (start != 0)
|
||||
static void * try_malloc_n(void * & start, size_type n,
|
||||
size_type partition_size);
|
||||
|
||||
protected:
|
||||
void * first;
|
||||
|
||||
// Traverses the free list referred to by "first",
|
||||
// and returns the iterator previous to where
|
||||
// "ptr" would go if it was in the free list.
|
||||
// Returns 0 if "ptr" would go at the beginning
|
||||
// of the free list (i.e., before "first")
|
||||
void * find_prev(void * ptr);
|
||||
|
||||
// for the sake of code readability :)
|
||||
static void * & nextof(void * const ptr)
|
||||
{ return *(static_cast<void **>(ptr)); }
|
||||
|
||||
public:
|
||||
// Post: empty()
|
||||
simple_segregated_storage()
|
||||
:first(0) { }
|
||||
|
||||
// pre: npartition_sz >= sizeof(void *)
|
||||
// npartition_sz = sizeof(void *) * i, for some integer i
|
||||
// nsz >= npartition_sz
|
||||
// block is properly aligned for an array of object of
|
||||
// size npartition_sz and array of void *
|
||||
// The requirements above guarantee that any pointer to a chunk
|
||||
// (which is a pointer to an element in an array of npartition_sz)
|
||||
// may be cast to void **.
|
||||
static void * segregate(void * block,
|
||||
size_type nsz, size_type npartition_sz,
|
||||
void * end = 0);
|
||||
|
||||
// Same preconditions as 'segregate'
|
||||
// Post: !empty()
|
||||
void add_block(void * const block,
|
||||
const size_type nsz, const size_type npartition_sz)
|
||||
{
|
||||
// Segregate this block and merge its free list into the
|
||||
// free list referred to by "first"
|
||||
first = segregate(block, nsz, npartition_sz, first);
|
||||
}
|
||||
|
||||
// Same preconditions as 'segregate'
|
||||
// Post: !empty()
|
||||
void add_ordered_block(void * const block,
|
||||
const size_type nsz, const size_type npartition_sz)
|
||||
{
|
||||
// This (slower) version of add_block segregates the
|
||||
// block and merges its free list into our free list
|
||||
// in the proper order
|
||||
|
||||
// Find where "block" would go in the free list
|
||||
void * const loc = find_prev(block);
|
||||
|
||||
// Place either at beginning or in middle/end
|
||||
if (loc == 0)
|
||||
add_block(block, nsz, npartition_sz);
|
||||
else
|
||||
nextof(loc) = segregate(block, nsz, npartition_sz, nextof(loc));
|
||||
}
|
||||
|
||||
// default destructor
|
||||
|
||||
bool empty() const { return (first == 0); }
|
||||
|
||||
// pre: !empty()
|
||||
void * malloc()
|
||||
{
|
||||
void * const ret = first;
|
||||
|
||||
// Increment the "first" pointer to point to the next chunk
|
||||
first = nextof(first);
|
||||
return ret;
|
||||
}
|
||||
|
||||
// pre: chunk was previously returned from a malloc() referring to the
|
||||
// same free list
|
||||
// post: !empty()
|
||||
void free(void * const chunk)
|
||||
{
|
||||
nextof(chunk) = first;
|
||||
first = chunk;
|
||||
}
|
||||
|
||||
// pre: chunk was previously returned from a malloc() referring to the
|
||||
// same free list
|
||||
// post: !empty()
|
||||
void ordered_free(void * const chunk)
|
||||
{
|
||||
// This (slower) implementation of 'free' places the memory
|
||||
// back in the list in its proper order.
|
||||
|
||||
// Find where "chunk" goes in the free list
|
||||
void * const loc = find_prev(chunk);
|
||||
|
||||
// Place either at beginning or in middle/end
|
||||
if (loc == 0)
|
||||
free(chunk);
|
||||
else
|
||||
{
|
||||
nextof(chunk) = nextof(loc);
|
||||
nextof(loc) = chunk;
|
||||
}
|
||||
}
|
||||
|
||||
// Note: if you're allocating/deallocating n a lot, you should
|
||||
// be using an ordered pool.
|
||||
void * malloc_n(size_type n, size_type partition_size);
|
||||
|
||||
// pre: chunks was previously allocated from *this with the same
|
||||
// values for n and partition_size
|
||||
// post: !empty()
|
||||
// Note: if you're allocating/deallocating n a lot, you should
|
||||
// be using an ordered pool.
|
||||
void free_n(void * const chunks, const size_type n,
|
||||
const size_type partition_size)
|
||||
{
|
||||
add_block(chunks, n * partition_size, partition_size);
|
||||
}
|
||||
|
||||
// pre: chunks was previously allocated from *this with the same
|
||||
// values for n and partition_size
|
||||
// post: !empty()
|
||||
void ordered_free_n(void * const chunks, const size_type n,
|
||||
const size_type partition_size)
|
||||
{
|
||||
add_ordered_block(chunks, n * partition_size, partition_size);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename SizeType>
|
||||
void * simple_segregated_storage<SizeType>::find_prev(void * const ptr)
|
||||
{
|
||||
// Handle border case
|
||||
if (first == 0 || std::greater<void *>()(first, ptr))
|
||||
return 0;
|
||||
|
||||
void * iter = first;
|
||||
while (true)
|
||||
{
|
||||
// if we're about to hit the end or
|
||||
// if we've found where "ptr" goes
|
||||
if (nextof(iter) == 0 || std::greater<void *>()(nextof(iter), ptr))
|
||||
return iter;
|
||||
|
||||
iter = nextof(iter);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename SizeType>
|
||||
void * simple_segregated_storage<SizeType>::segregate(
|
||||
void * const block,
|
||||
const size_type sz,
|
||||
const size_type partition_sz,
|
||||
void * const end)
|
||||
{
|
||||
// Get pointer to last valid chunk, preventing overflow on size calculations
|
||||
// The division followed by the multiplication just makes sure that
|
||||
// old == block + partition_sz * i, for some integer i, even if the
|
||||
// block size (sz) is not a multiple of the partition size.
|
||||
char * old = static_cast<char *>(block)
|
||||
+ ((sz - partition_sz) / partition_sz) * partition_sz;
|
||||
|
||||
// Set it to point to the end
|
||||
nextof(old) = end;
|
||||
|
||||
// Handle border case where sz == partition_sz (i.e., we're handling an array
|
||||
// of 1 element)
|
||||
if (old == block)
|
||||
return block;
|
||||
|
||||
// Iterate backwards, building a singly-linked list of pointers
|
||||
for (char * iter = old - partition_sz; iter != block;
|
||||
old = iter, iter -= partition_sz)
|
||||
nextof(iter) = old;
|
||||
|
||||
// Point the first pointer, too
|
||||
nextof(block) = old;
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
// The following function attempts to find n contiguous chunks
|
||||
// of size partition_size in the free list, starting at start.
|
||||
// If it succeds, it returns the last chunk in that contiguous
|
||||
// sequence, so that the sequence is known by [start, {retval}]
|
||||
// If it fails, it does do either because it's at the end of the
|
||||
// free list or hits a non-contiguous chunk. In either case,
|
||||
// it will return 0, and set start to the last considered
|
||||
// chunk. You are at the end of the free list if
|
||||
// nextof(start) == 0. Otherwise, start points to the last
|
||||
// chunk in the contiguous sequence, and nextof(start) points
|
||||
// to the first chunk in the next contiguous sequence (assuming
|
||||
// an ordered free list)
|
||||
template <typename SizeType>
|
||||
void * simple_segregated_storage<SizeType>::try_malloc_n(
|
||||
void * & start, size_type n, const size_type partition_size)
|
||||
{
|
||||
void * iter = nextof(start);
|
||||
while (--n != 0)
|
||||
{
|
||||
void * next = nextof(iter);
|
||||
if (next != static_cast<char *>(iter) + partition_size)
|
||||
{
|
||||
// next == 0 (end-of-list) or non-contiguous chunk found
|
||||
start = iter;
|
||||
return 0;
|
||||
}
|
||||
iter = next;
|
||||
}
|
||||
return iter;
|
||||
}
|
||||
|
||||
template <typename SizeType>
|
||||
void * simple_segregated_storage<SizeType>::malloc_n(const size_type n,
|
||||
const size_type partition_size)
|
||||
{
|
||||
void * start = &first;
|
||||
void * iter;
|
||||
do
|
||||
{
|
||||
if (nextof(start) == 0)
|
||||
return 0;
|
||||
iter = try_malloc_n(start, n, partition_size);
|
||||
} while (iter == 0);
|
||||
void * const ret = nextof(start);
|
||||
nextof(start) = nextof(iter);
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
119
Engine/Zalla3D Base Class/Boost/pool/singleton_pool.hpp
Normal file
119
Engine/Zalla3D Base Class/Boost/pool/singleton_pool.hpp
Normal file
@@ -0,0 +1,119 @@
|
||||
// Copyright (C) 2000, 2001 Stephen Cleary
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See http://www.boost.org for updates, documentation, and revision history.
|
||||
|
||||
#ifndef BOOST_SINGLETON_POOL_HPP
|
||||
#define BOOST_SINGLETON_POOL_HPP
|
||||
|
||||
#include <boost/pool/poolfwd.hpp>
|
||||
|
||||
// boost::pool
|
||||
#include <boost/pool/pool.hpp>
|
||||
// boost::details::pool::singleton_default
|
||||
#include <boost/pool/detail/singleton.hpp>
|
||||
// boost::details::pool::guard
|
||||
#include <boost/pool/detail/guard.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
//
|
||||
// The singleton_pool class allows other pool interfaces for types of the same
|
||||
// size to share the same pool
|
||||
//
|
||||
template <typename Tag, unsigned RequestedSize,
|
||||
typename UserAllocator,
|
||||
typename Mutex,
|
||||
unsigned NextSize>
|
||||
struct singleton_pool
|
||||
{
|
||||
public:
|
||||
typedef Tag tag;
|
||||
typedef Mutex mutex;
|
||||
typedef UserAllocator user_allocator;
|
||||
typedef typename pool<UserAllocator>::size_type size_type;
|
||||
typedef typename pool<UserAllocator>::difference_type difference_type;
|
||||
|
||||
BOOST_STATIC_CONSTANT(unsigned, requested_size = RequestedSize);
|
||||
BOOST_STATIC_CONSTANT(unsigned, next_size = NextSize);
|
||||
|
||||
private:
|
||||
struct pool_type: Mutex
|
||||
{
|
||||
pool<UserAllocator> p;
|
||||
pool_type():p(RequestedSize, NextSize) { }
|
||||
};
|
||||
|
||||
typedef details::pool::singleton_default<pool_type> singleton;
|
||||
|
||||
singleton_pool();
|
||||
|
||||
public:
|
||||
static void * malloc()
|
||||
{
|
||||
pool_type & p = singleton::instance();
|
||||
details::pool::guard<Mutex> g(p);
|
||||
return p.p.malloc();
|
||||
}
|
||||
static void * ordered_malloc()
|
||||
{
|
||||
pool_type & p = singleton::instance();
|
||||
details::pool::guard<Mutex> g(p);
|
||||
return p.p.ordered_malloc();
|
||||
}
|
||||
static void * ordered_malloc(const size_type n)
|
||||
{
|
||||
pool_type & p = singleton::instance();
|
||||
details::pool::guard<Mutex> g(p);
|
||||
return p.p.ordered_malloc(n);
|
||||
}
|
||||
static bool is_from(void * const ptr)
|
||||
{
|
||||
pool_type & p = singleton::instance();
|
||||
details::pool::guard<Mutex> g(p);
|
||||
return p.p.is_from(ptr);
|
||||
}
|
||||
static void free(void * const ptr)
|
||||
{
|
||||
pool_type & p = singleton::instance();
|
||||
details::pool::guard<Mutex> g(p);
|
||||
p.p.free(ptr);
|
||||
}
|
||||
static void ordered_free(void * const ptr)
|
||||
{
|
||||
pool_type & p = singleton::instance();
|
||||
details::pool::guard<Mutex> g(p);
|
||||
p.p.ordered_free(ptr);
|
||||
}
|
||||
static void free(void * const ptr, const size_type n)
|
||||
{
|
||||
pool_type & p = singleton::instance();
|
||||
details::pool::guard<Mutex> g(p);
|
||||
p.p.free(ptr, n);
|
||||
}
|
||||
static void ordered_free(void * const ptr, const size_type n)
|
||||
{
|
||||
pool_type & p = singleton::instance();
|
||||
details::pool::guard<Mutex> g(p);
|
||||
p.p.ordered_free(ptr, n);
|
||||
}
|
||||
static bool release_memory()
|
||||
{
|
||||
pool_type & p = singleton::instance();
|
||||
details::pool::guard<Mutex> g(p);
|
||||
return p.p.release_memory();
|
||||
}
|
||||
static bool purge_memory()
|
||||
{
|
||||
pool_type & p = singleton::instance();
|
||||
details::pool::guard<Mutex> g(p);
|
||||
return p.p.purge_memory();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
118
Engine/Zalla3D Base Class/Boost/static_assert.hpp
Normal file
118
Engine/Zalla3D Base Class/Boost/static_assert.hpp
Normal file
@@ -0,0 +1,118 @@
|
||||
// (C) Copyright John Maddock 2000.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/libs/static_assert for documentation.
|
||||
|
||||
/*
|
||||
Revision history:
|
||||
02 August 2000
|
||||
Initial version.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_STATIC_ASSERT_HPP
|
||||
#define BOOST_STATIC_ASSERT_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
//
|
||||
// workaround for buggy integral-constant expression support:
|
||||
#define BOOST_BUGGY_INTEGRAL_CONSTANT_EXPRESSIONS
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ == 3) && ((__GNUC_MINOR__ == 3) || (__GNUC_MINOR__ == 4))
|
||||
// gcc 3.3 and 3.4 don't produce good error messages with the default version:
|
||||
# define BOOST_SA_GCC_WORKAROUND
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
|
||||
// HP aCC cannot deal with missing names for template value parameters
|
||||
template <bool x> struct STATIC_ASSERTION_FAILURE;
|
||||
|
||||
template <> struct STATIC_ASSERTION_FAILURE<true> { enum { value = 1 }; };
|
||||
|
||||
// HP aCC cannot deal with missing names for template value parameters
|
||||
template<int x> struct static_assert_test{};
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Implicit instantiation requires that all member declarations be
|
||||
// instantiated, but that the definitions are *not* instantiated.
|
||||
//
|
||||
// It's not particularly clear how this applies to enum's or typedefs;
|
||||
// both are described as declarations [7.1.3] and [7.2] in the standard,
|
||||
// however some compilers use "delayed evaluation" of one or more of
|
||||
// these when implicitly instantiating templates. We use typedef declarations
|
||||
// by default, but try defining BOOST_USE_ENUM_STATIC_ASSERT if the enum
|
||||
// version gets better results from your compiler...
|
||||
//
|
||||
// Implementation:
|
||||
// Both of these versions rely on sizeof(incomplete_type) generating an error
|
||||
// message containing the name of the incomplete type. We use
|
||||
// "STATIC_ASSERTION_FAILURE" as the type name here to generate
|
||||
// an eye catching error message. The result of the sizeof expression is either
|
||||
// used as an enum initialiser, or as a template argument depending which version
|
||||
// is in use...
|
||||
// Note that the argument to the assert is explicitly cast to bool using old-
|
||||
// style casts: too many compilers currently have problems with static_cast
|
||||
// when used inside integral constant expressions.
|
||||
//
|
||||
#if !defined(BOOST_BUGGY_INTEGRAL_CONSTANT_EXPRESSIONS)
|
||||
|
||||
#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
|
||||
// __LINE__ macro broken when -ZI is used see Q199057
|
||||
// fortunately MSVC ignores duplicate typedef's.
|
||||
#define BOOST_STATIC_ASSERT( B ) \
|
||||
typedef ::boost::static_assert_test<\
|
||||
sizeof(::boost::STATIC_ASSERTION_FAILURE< (bool)( B ) >)\
|
||||
> boost_static_assert_typedef_
|
||||
#elif defined(BOOST_MSVC)
|
||||
#define BOOST_STATIC_ASSERT( B ) \
|
||||
typedef ::boost::static_assert_test<\
|
||||
sizeof(::boost::STATIC_ASSERTION_FAILURE< (bool)( B ) >)>\
|
||||
BOOST_JOIN(boost_static_assert_typedef_, __COUNTER__)
|
||||
#elif defined(BOOST_INTEL_CXX_VERSION) || defined(BOOST_SA_GCC_WORKAROUND)
|
||||
// agurt 15/sep/02: a special care is needed to force Intel C++ issue an error
|
||||
// instead of warning in case of failure
|
||||
# define BOOST_STATIC_ASSERT( B ) \
|
||||
typedef char BOOST_JOIN(boost_static_assert_typedef_, __LINE__) \
|
||||
[ ::boost::STATIC_ASSERTION_FAILURE< (bool)( B ) >::value ]
|
||||
#elif defined(__sgi)
|
||||
// special version for SGI MIPSpro compiler
|
||||
#define BOOST_STATIC_ASSERT( B ) \
|
||||
BOOST_STATIC_CONSTANT(bool, \
|
||||
BOOST_JOIN(boost_static_assert_test_, __LINE__) = ( B )); \
|
||||
typedef ::boost::static_assert_test<\
|
||||
sizeof(::boost::STATIC_ASSERTION_FAILURE< \
|
||||
BOOST_JOIN(boost_static_assert_test_, __LINE__) >)>\
|
||||
BOOST_JOIN(boost_static_assert_typedef_, __LINE__)
|
||||
#elif BOOST_WORKAROUND(__MWERKS__, <= 0x3003)
|
||||
// special version for CodeWarrior <= 8.x
|
||||
#define BOOST_STATIC_ASSERT( B ) \
|
||||
BOOST_STATIC_CONSTANT(int, \
|
||||
BOOST_JOIN(boost_static_assert_test_, __LINE__) = \
|
||||
sizeof(::boost::STATIC_ASSERTION_FAILURE< (bool)( B ) >) )
|
||||
#else
|
||||
// generic version
|
||||
#define BOOST_STATIC_ASSERT( B ) \
|
||||
typedef ::boost::static_assert_test<\
|
||||
sizeof(::boost::STATIC_ASSERTION_FAILURE< (bool)( B ) >)>\
|
||||
BOOST_JOIN(boost_static_assert_typedef_, __LINE__)
|
||||
#endif
|
||||
|
||||
#else
|
||||
// alternative enum based implementation:
|
||||
#define BOOST_STATIC_ASSERT( B ) \
|
||||
enum { BOOST_JOIN(boost_static_assert_enum_, __LINE__) \
|
||||
= sizeof(::boost::STATIC_ASSERTION_FAILURE< (bool)( B ) >) }
|
||||
#endif
|
||||
|
||||
|
||||
#endif // BOOST_STATIC_ASSERT_HPP
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
// (C) Copyright John Maddock and Steve Cleary 2000.
|
||||
//
|
||||
// Use, modification and distribution are subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt).
|
||||
//
|
||||
// See http://www.boost.org/libs/type_traits for most recent version including documentation.
|
||||
|
||||
#ifndef BOOST_TT_DETAIL_ICE_AND_HPP_INCLUDED
|
||||
#define BOOST_TT_DETAIL_ICE_AND_HPP_INCLUDED
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace type_traits {
|
||||
|
||||
template <bool b1, bool b2, bool b3 = true, bool b4 = true, bool b5 = true, bool b6 = true, bool b7 = true>
|
||||
struct ice_and;
|
||||
|
||||
template <bool b1, bool b2, bool b3, bool b4, bool b5, bool b6, bool b7>
|
||||
struct ice_and
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, value = false);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ice_and<true, true, true, true, true, true, true>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, value = true);
|
||||
};
|
||||
|
||||
} // namespace type_traits
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_TT_DETAIL_ICE_AND_HPP_INCLUDED
|
||||
@@ -0,0 +1,36 @@
|
||||
// (C) Copyright John Maddock and Steve Cleary 2000.
|
||||
// Use, modification and distribution are subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt).
|
||||
//
|
||||
// See http://www.boost.org/libs/type_traits for most recent version including documentation.
|
||||
|
||||
#ifndef BOOST_TT_DETAIL_ICE_EQ_HPP_INCLUDED
|
||||
#define BOOST_TT_DETAIL_ICE_EQ_HPP_INCLUDED
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace type_traits {
|
||||
|
||||
template <int b1, int b2>
|
||||
struct ice_eq
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, value = (b1 == b2));
|
||||
};
|
||||
|
||||
template <int b1, int b2>
|
||||
struct ice_ne
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, value = (b1 != b2));
|
||||
};
|
||||
|
||||
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
|
||||
template <int b1, int b2> bool const ice_eq<b1,b2>::value;
|
||||
template <int b1, int b2> bool const ice_ne<b1,b2>::value;
|
||||
#endif
|
||||
|
||||
} // namespace type_traits
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_TT_DETAIL_ICE_EQ_HPP_INCLUDED
|
||||
@@ -0,0 +1,31 @@
|
||||
// (C) Copyright John Maddock and Steve Cleary 2000.
|
||||
// Use, modification and distribution are subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt).
|
||||
//
|
||||
// See http://www.boost.org/libs/type_traits for most recent version including documentation.
|
||||
|
||||
#ifndef BOOST_TT_DETAIL_ICE_NOT_HPP_INCLUDED
|
||||
#define BOOST_TT_DETAIL_ICE_NOT_HPP_INCLUDED
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace type_traits {
|
||||
|
||||
template <bool b>
|
||||
struct ice_not
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, value = true);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ice_not<true>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, value = false);
|
||||
};
|
||||
|
||||
} // namespace type_traits
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_TT_DETAIL_ICE_NOT_HPP_INCLUDED
|
||||
@@ -0,0 +1,34 @@
|
||||
// (C) Copyright John Maddock and Steve Cleary 2000.
|
||||
// Use, modification and distribution are subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt).
|
||||
//
|
||||
// See http://www.boost.org/libs/type_traits for most recent version including documentation.
|
||||
|
||||
#ifndef BOOST_TT_DETAIL_ICE_OR_HPP_INCLUDED
|
||||
#define BOOST_TT_DETAIL_ICE_OR_HPP_INCLUDED
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace type_traits {
|
||||
|
||||
template <bool b1, bool b2, bool b3 = false, bool b4 = false, bool b5 = false, bool b6 = false, bool b7 = false>
|
||||
struct ice_or;
|
||||
|
||||
template <bool b1, bool b2, bool b3, bool b4, bool b5, bool b6, bool b7>
|
||||
struct ice_or
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, value = true);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ice_or<false, false, false, false, false, false, false>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, value = false);
|
||||
};
|
||||
|
||||
} // namespace type_traits
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_TT_DETAIL_ICE_OR_HPP_INCLUDED
|
||||
@@ -0,0 +1,26 @@
|
||||
|
||||
// (C) Copyright John Maddock and Steve Cleary 2000.
|
||||
// Use, modification and distribution are subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt).
|
||||
//
|
||||
// See http://www.boost.org/libs/type_traits for most recent version including documentation.
|
||||
//
|
||||
// macros and helpers for working with integral-constant-expressions.
|
||||
|
||||
#ifndef BOOST_TT_DETAIL_YES_NO_TYPE_HPP_INCLUDED
|
||||
#define BOOST_TT_DETAIL_YES_NO_TYPE_HPP_INCLUDED
|
||||
|
||||
namespace boost {
|
||||
namespace type_traits {
|
||||
|
||||
typedef char yes_type;
|
||||
struct no_type
|
||||
{
|
||||
char padding[8];
|
||||
};
|
||||
|
||||
} // namespace type_traits
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_TT_DETAIL_YES_NO_TYPE_HPP_INCLUDED
|
||||
20
Engine/Zalla3D Base Class/Boost/type_traits/ice.hpp
Normal file
20
Engine/Zalla3D Base Class/Boost/type_traits/ice.hpp
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
// (C) Copyright John Maddock and Steve Cleary 2000.
|
||||
// Use, modification and distribution are subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt).
|
||||
//
|
||||
// See http://www.boost.org/libs/type_traits for most recent version including documentation.
|
||||
//
|
||||
// macros and helpers for working with integral-constant-expressions.
|
||||
|
||||
#ifndef BOOST_TT_ICE_HPP_INCLUDED
|
||||
#define BOOST_TT_ICE_HPP_INCLUDED
|
||||
|
||||
#include <boost/type_traits/detail/yes_no_type.hpp>
|
||||
#include <boost/type_traits/detail/ice_or.hpp>
|
||||
#include <boost/type_traits/detail/ice_and.hpp>
|
||||
#include <boost/type_traits/detail/ice_not.hpp>
|
||||
#include <boost/type_traits/detail/ice_eq.hpp>
|
||||
|
||||
#endif // BOOST_TT_ICE_HPP_INCLUDED
|
||||
136
Engine/Zalla3D Base Class/ByteDataObj.cpp
Normal file
136
Engine/Zalla3D Base Class/ByteDataObj.cpp
Normal file
@@ -0,0 +1,136 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include "./ByteDataObj.h"
|
||||
|
||||
namespace CROSSM {
|
||||
|
||||
const long UINT_SIZE = (long)sizeof(unsigned char);
|
||||
|
||||
CByteDataObj::CByteDataObj(void)
|
||||
{
|
||||
m_pBytes = NULL;
|
||||
m_lSize = 0;
|
||||
m_lReadPos = 0;
|
||||
|
||||
}
|
||||
|
||||
CByteDataObj::~CByteDataObj(void)
|
||||
{
|
||||
if(m_pBytes)
|
||||
{
|
||||
delete[] m_pBytes;
|
||||
m_pBytes = NULL;
|
||||
m_lSize = 0;
|
||||
m_lReadPos = 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
unsigned char *CByteDataObj::GetReadPtr()
|
||||
{
|
||||
if((m_lReadPos >= m_lSize) || (m_pBytes == NULL))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &(m_pBytes[m_lReadPos]);
|
||||
|
||||
}
|
||||
bool CByteDataObj::SaveByte(const char *strFileName,long lOffset )
|
||||
{
|
||||
FILE *fp = fopen(strFileName,"wb+");
|
||||
if(!fp)
|
||||
{
|
||||
//CLogMgr::_LogError("CByteDataObj::SaveByte fopen Failed.");
|
||||
return false;
|
||||
}
|
||||
if(lOffset > 0)
|
||||
{
|
||||
fseek(fp,lOffset,SEEK_SET);
|
||||
}
|
||||
if(fwrite((void *)m_pBytes,sizeof(unsigned char) * m_lSize,1,fp) != m_lSize)
|
||||
{
|
||||
//CLogMgr::_LogError("CByteDataObj::SaveByte fwrite Failed.");
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
fclose(fp);
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
bool CByteDataObj::LoadByte(const char *strFileName,long lOffset)
|
||||
{
|
||||
FILE *fp = fopen(strFileName,"rb");
|
||||
long lFileSize = 0;
|
||||
|
||||
if(fp == NULL)
|
||||
{
|
||||
//CLogMgr::_LogError("CByteDataObj::LoadByte() : %s file not exist\n",strFileName);
|
||||
return false;
|
||||
|
||||
}
|
||||
fseek(fp,0,SEEK_END);
|
||||
m_lSize = ftell(fp);
|
||||
if(m_lSize <= 0)
|
||||
{
|
||||
//CLogMgr::_LogError("CByteDataObj::LoadByte() : %s file size Wrong\n",strFileName);
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
// Offset <20><><EFBFBD><EFBFBD>
|
||||
if(m_lSize > lOffset)
|
||||
m_lSize -= lOffset;
|
||||
else
|
||||
{
|
||||
//CLogMgr::_LogError("CByteDataObj::LoadByte() : %s File Offset<65><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ѱ踦 <20>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD>ϴ<EFBFBD>.\n",strFileName);
|
||||
fclose(fp);
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
m_pBytes = new unsigned char[m_lSize];
|
||||
if(m_pBytes == NULL)
|
||||
{
|
||||
//CLogMgr::_LogError("CByteDataObj::LoadByte() : File Load Buffer's New Fail.\n");
|
||||
fclose(fp);
|
||||
return false;
|
||||
|
||||
}
|
||||
fseek(fp,lOffset,SEEK_SET);
|
||||
if(fread((unsigned char *)m_pBytes,sizeof(unsigned char),m_lSize,fp) != m_lSize)
|
||||
{
|
||||
//CLogMgr::_LogError("CByteDataObj::LoadByte() : Load File Fail.\n");
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
fclose(fp);
|
||||
return true;
|
||||
|
||||
}
|
||||
long CByteDataObj::Write(void *ptr,size_t UnitSize,int iNum)
|
||||
{
|
||||
if(ptr == NULL)
|
||||
return -1;
|
||||
return 0;
|
||||
|
||||
}
|
||||
long CByteDataObj::Read(void *ptr,size_t UnitSize,int iNum)
|
||||
{
|
||||
if(ptr == NULL)
|
||||
return -1;
|
||||
long lCurrentReaded = ((long)(UnitSize) * iNum) / UINT_SIZE;
|
||||
if(m_lSize >= lCurrentReaded + m_lReadPos)
|
||||
{
|
||||
memcpy(ptr,&(m_pBytes[m_lReadPos]), (size_t)(UINT_SIZE * lCurrentReaded));
|
||||
m_lReadPos += lCurrentReaded;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
|
||||
}
|
||||
return m_lReadPos;
|
||||
|
||||
}
|
||||
};
|
||||
34
Engine/Zalla3D Base Class/ByteDataObj.h
Normal file
34
Engine/Zalla3D Base Class/ByteDataObj.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include "CrossMHeader.h"
|
||||
|
||||
namespace CROSSM {
|
||||
|
||||
class CByteDataObj
|
||||
{
|
||||
public:
|
||||
CByteDataObj(void);
|
||||
~CByteDataObj(void);
|
||||
|
||||
bool LoadByte(const char *strFileName,long lOffset = 0 );
|
||||
bool SaveByte(const char *strFileName,long lOffset = 0 );
|
||||
|
||||
long GetByteSize() { return m_lSize; }
|
||||
|
||||
long GetReadPos() { return m_lReadPos;}
|
||||
void SetReadPos(long lPos) { m_lReadPos = lPos;}
|
||||
|
||||
unsigned char *GetReadPtr();
|
||||
|
||||
long Read(void *ptr,size_t UnitSize,int iNum);
|
||||
long Write(void *ptr,size_t UnitSize,int iNum);
|
||||
|
||||
protected:
|
||||
|
||||
unsigned char *m_pBytes;
|
||||
long m_lSize;
|
||||
long m_lReadPos;
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
379
Engine/Zalla3D Base Class/ConvertTexture.cpp
Normal file
379
Engine/Zalla3D Base Class/ConvertTexture.cpp
Normal file
@@ -0,0 +1,379 @@
|
||||
// ConvertTexture.cpp: implementation of the CConvertTexture class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <d3dx8.h>
|
||||
#include "ConvertTexture.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CConvertTexture::CConvertTexture()
|
||||
{
|
||||
m_pddNewTexture=NULL;
|
||||
}
|
||||
|
||||
CConvertTexture::~CConvertTexture()
|
||||
{
|
||||
if(m_pddNewTexture)
|
||||
m_pddNewTexture->Release();
|
||||
}
|
||||
|
||||
void CConvertTexture::Compress(D3DFORMAT fmtTo)
|
||||
{
|
||||
if(m_pddNewTexture)
|
||||
{
|
||||
m_pddNewTexture->Release();
|
||||
m_pddNewTexture=NULL;
|
||||
}
|
||||
|
||||
int nMips=m_pddTexture->GetLevelCount();
|
||||
//ms_pd3dDevice->CreateTexture(m_dwWidth,m_dwHeight,0,0,fmtTo,D3DPOOL_MANAGED,&m_pddNewTexture);
|
||||
ms_pd3dDevice->CreateTexture(m_dwWidth,m_dwHeight,nMips,0,fmtTo,D3DPOOL_MANAGED,&m_pddNewTexture);
|
||||
//int nMips=m_pddNewTexture->GetLevelCount();
|
||||
|
||||
LPDIRECT3DSURFACE8 pSurfaceSrc,pSurfaceDest;
|
||||
|
||||
for(int cLevel=0;cLevel<nMips;cLevel++)
|
||||
{
|
||||
HRESULT r;
|
||||
r=((LPDIRECT3DTEXTURE8)m_pddTexture)->GetSurfaceLevel(cLevel,&pSurfaceSrc);
|
||||
r=m_pddNewTexture->GetSurfaceLevel(cLevel,&pSurfaceDest);
|
||||
r=D3DXLoadSurfaceFromSurface(pSurfaceDest,NULL,NULL,pSurfaceSrc,NULL,NULL,D3DX_FILTER_TRIANGLE,0);
|
||||
pSurfaceSrc->Release();
|
||||
pSurfaceDest->Release();
|
||||
}
|
||||
}
|
||||
|
||||
void CConvertTexture::GenerateMipMaps(bool bGenMipmap)
|
||||
{
|
||||
//m_pddNewTexture<72>̳ѿ<CCB3> <20>Ӹ<EFBFBD><D3B8><EFBFBD> <20><> <20>ؽ<EFBFBD><D8BD>İ<EFBFBD> <20><><EFBFBD>
|
||||
|
||||
|
||||
D3DFORMAT fmt;
|
||||
D3DSURFACE_DESC sd;
|
||||
((LPDIRECT3DTEXTURE8)m_pddTexture)->GetLevelDesc(0, &sd);
|
||||
fmt = sd.Format;
|
||||
if(bGenMipmap)
|
||||
ms_pd3dDevice->CreateTexture(m_dwWidth,m_dwHeight,0,0,fmt,D3DPOOL_MANAGED,&m_pddNewTexture);
|
||||
else
|
||||
ms_pd3dDevice->CreateTexture(m_dwWidth,m_dwHeight,1,0,fmt,D3DPOOL_MANAGED,&m_pddNewTexture);
|
||||
|
||||
LPDIRECT3DSURFACE8 pSurfaceSrc,pSurfaceDest;
|
||||
((LPDIRECT3DTEXTURE8)m_pddNewTexture)->GetSurfaceLevel(0,&pSurfaceDest);
|
||||
((LPDIRECT3DTEXTURE8)m_pddTexture)->GetSurfaceLevel(0,&pSurfaceSrc);
|
||||
|
||||
D3DXLoadSurfaceFromSurface(pSurfaceDest, NULL, NULL, pSurfaceSrc, NULL, NULL, D3DX_FILTER_TRIANGLE, 0);
|
||||
pSurfaceSrc->Release();
|
||||
pSurfaceDest->Release();
|
||||
if(bGenMipmap)
|
||||
D3DXFilterTexture(m_pddNewTexture, NULL, 0, D3DX_FILTER_TRIANGLE);
|
||||
|
||||
/*
|
||||
|
||||
D3DXFilterTexture(pmiptexNew, NULL, 0, D3DX_FILTER_TRIANGLE);
|
||||
D3DXFilterTexture(m_pddNewTexture, NULL, 0, D3DX_FILTER_TRIANGLE);
|
||||
|
||||
m_ptexOrig = pmiptexNew;
|
||||
|
||||
if (m_ptexNew != NULL)
|
||||
{
|
||||
D3DSURFACE_DESC sd;
|
||||
((LPDIRECT3DCUBETEXTURE8)m_ptexNew)->GetLevelDesc(0, &sd);
|
||||
fmt = sd.Format;
|
||||
Compress(fmt);
|
||||
}
|
||||
return;
|
||||
*/
|
||||
}
|
||||
|
||||
void CConvertTexture::SaveDDS(char *strFilename)
|
||||
{
|
||||
FILE *fp=fopen(strFilename,"wb");
|
||||
DWORD dwMagic;
|
||||
dwMagic=MAKEFOURCC('D','D','S',' ');
|
||||
//dwMagic=0xffffffff;
|
||||
fwrite(&dwMagic,sizeof(dwMagic),1,fp);
|
||||
|
||||
DDS_HEADER ddsh={sizeof(DDS_HEADER),};
|
||||
ddsh.dwHeaderFlags=DDS_HEADER_FLAGS_TEXTURE;
|
||||
ddsh.dwWidth=m_dwWidth;
|
||||
ddsh.dwHeight=m_dwHeight;
|
||||
ddsh.dwSurfaceFlags=DDS_SURFACE_FLAGS_TEXTURE;
|
||||
|
||||
int nMips=m_pddNewTexture->GetLevelCount();
|
||||
|
||||
if(nMips>1)
|
||||
{
|
||||
ddsh.dwHeaderFlags|=DDS_HEADER_FLAGS_MIPMAP;
|
||||
ddsh.dwSurfaceFlags|=DDS_SURFACE_FLAGS_MIPMAP;
|
||||
ddsh.dwMipMapCount=nMips;
|
||||
}
|
||||
|
||||
D3DSURFACE_DESC sd;
|
||||
D3DFORMAT fmt;
|
||||
DWORD dwSize;
|
||||
DWORD dwPitch = 0;
|
||||
D3DLOCKED_RECT lr;
|
||||
|
||||
m_pddNewTexture->GetLevelDesc(0,&sd);
|
||||
fmt=sd.Format;
|
||||
dwSize=sd.Size;
|
||||
|
||||
m_pddNewTexture->LockRect(0,&lr,NULL,D3DLOCK_READONLY);
|
||||
dwPitch=lr.Pitch;
|
||||
m_pddNewTexture->UnlockRect(NULL);
|
||||
switch (fmt)
|
||||
{
|
||||
case D3DFMT_DXT1:
|
||||
ddsh.ddspf = DDSPF_DXT1;
|
||||
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_LINEARSIZE;
|
||||
ddsh.dwPitchOrLinearSize = dwSize;
|
||||
break;
|
||||
case D3DFMT_DXT2:
|
||||
ddsh.ddspf = DDSPF_DXT2;
|
||||
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_LINEARSIZE;
|
||||
ddsh.dwPitchOrLinearSize = dwSize;
|
||||
break;
|
||||
case D3DFMT_DXT3:
|
||||
ddsh.ddspf = DDSPF_DXT3;
|
||||
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_LINEARSIZE;
|
||||
ddsh.dwPitchOrLinearSize = dwSize;
|
||||
break;
|
||||
case D3DFMT_DXT4:
|
||||
ddsh.ddspf = DDSPF_DXT4;
|
||||
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_LINEARSIZE;
|
||||
ddsh.dwPitchOrLinearSize = dwSize;
|
||||
break;
|
||||
case D3DFMT_DXT5:
|
||||
ddsh.ddspf = DDSPF_DXT5;
|
||||
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_LINEARSIZE;
|
||||
ddsh.dwPitchOrLinearSize = dwSize;
|
||||
break;
|
||||
case D3DFMT_A8R8G8B8:
|
||||
ddsh.ddspf = DDSPF_A8R8G8B8;
|
||||
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_PITCH;
|
||||
ddsh.dwPitchOrLinearSize = dwPitch;
|
||||
break;
|
||||
case D3DFMT_A1R5G5B5:
|
||||
ddsh.ddspf = DDSPF_A1R5G5B5;
|
||||
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_PITCH;
|
||||
ddsh.dwPitchOrLinearSize = dwPitch;
|
||||
break;
|
||||
case D3DFMT_A4R4G4B4:
|
||||
ddsh.ddspf = DDSPF_A4R4G4B4;
|
||||
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_PITCH;
|
||||
ddsh.dwPitchOrLinearSize = dwPitch;
|
||||
break;
|
||||
case D3DFMT_R8G8B8:
|
||||
ddsh.ddspf = DDSPF_R8G8B8;
|
||||
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_PITCH;
|
||||
ddsh.dwPitchOrLinearSize = dwPitch;
|
||||
break;
|
||||
case D3DFMT_R5G6B5:
|
||||
ddsh.ddspf = DDSPF_R5G6B5;
|
||||
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_PITCH;
|
||||
ddsh.dwPitchOrLinearSize = dwPitch;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
fwrite(&ddsh,sizeof(ddsh),1,fp);
|
||||
|
||||
LPDIRECT3DSURFACE8 pSurface;
|
||||
|
||||
|
||||
|
||||
for(int cLevel=0;cLevel<nMips;cLevel++)
|
||||
{
|
||||
if(FAILED(m_pddNewTexture->GetSurfaceLevel(cLevel,&pSurface)))
|
||||
{
|
||||
break;
|
||||
}
|
||||
pSurface->GetDesc(&sd);
|
||||
pSurface->Release();
|
||||
if(FAILED(m_pddNewTexture->LockRect(cLevel,&lr,NULL,0)))
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (sd.Format == D3DFMT_DXT1 ||
|
||||
sd.Format == D3DFMT_DXT2 ||
|
||||
sd.Format == D3DFMT_DXT3 ||
|
||||
sd.Format == D3DFMT_DXT4 ||
|
||||
sd.Format == D3DFMT_DXT5)
|
||||
{
|
||||
fwrite(lr.pBits,sd.Size,1,fp);
|
||||
}
|
||||
else
|
||||
{
|
||||
WORD yp;
|
||||
BYTE *pbDest=(BYTE*)lr.pBits;
|
||||
LONG dataBytesPerRow=0;
|
||||
|
||||
if(sd.Format==D3DFMT_A8R8G8B8)
|
||||
dataBytesPerRow=4*sd.Width;
|
||||
else if(sd.Format==D3DFMT_R8G8B8)
|
||||
dataBytesPerRow=3*sd.Width;
|
||||
else
|
||||
dataBytesPerRow=2*sd.Width;
|
||||
for(yp=0;yp<sd.Height;yp++)
|
||||
{
|
||||
fwrite(pbDest,dataBytesPerRow,1,fp);
|
||||
pbDest+=lr.Pitch;
|
||||
}
|
||||
}
|
||||
m_pddNewTexture->UnlockRect(cLevel);
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
void CConvertTexture::SaveDDS(char *strFilename, int LowerSave,int MaxTextureSize)
|
||||
{
|
||||
FILE *fp=fopen(strFilename,"wb");
|
||||
DWORD dwMagic;
|
||||
dwMagic=MAKEFOURCC('D','D','S',' ');
|
||||
fwrite(&dwMagic,sizeof(dwMagic),1,fp);
|
||||
|
||||
DDS_HEADER ddsh={sizeof(DDS_HEADER),};
|
||||
ddsh.dwHeaderFlags=DDS_HEADER_FLAGS_TEXTURE;
|
||||
|
||||
ddsh.dwWidth=m_dwWidth/(int)pow((double)2,LowerSave);
|
||||
ddsh.dwHeight=m_dwHeight/(int)pow((double)2,LowerSave);
|
||||
|
||||
long NowTextureSize=ddsh.dwWidth>=ddsh.dwHeight ? ddsh.dwWidth:ddsh.dwHeight;
|
||||
while(NowTextureSize > MaxTextureSize)
|
||||
{
|
||||
LowerSave++;
|
||||
ddsh.dwWidth=m_dwWidth/(int)pow((double)2,LowerSave);
|
||||
ddsh.dwHeight=m_dwHeight/(int)pow((double)2,LowerSave);
|
||||
NowTextureSize=ddsh.dwWidth>=ddsh.dwHeight ? ddsh.dwWidth:ddsh.dwHeight;
|
||||
}
|
||||
ddsh.dwSurfaceFlags=DDS_SURFACE_FLAGS_TEXTURE;
|
||||
|
||||
|
||||
int nMips=m_pddNewTexture->GetLevelCount();
|
||||
nMips-=LowerSave;
|
||||
|
||||
if(nMips>1)
|
||||
{
|
||||
ddsh.dwHeaderFlags|=DDS_HEADER_FLAGS_MIPMAP;
|
||||
ddsh.dwSurfaceFlags|=DDS_SURFACE_FLAGS_MIPMAP;
|
||||
ddsh.dwMipMapCount=nMips;
|
||||
}
|
||||
|
||||
D3DSURFACE_DESC sd;
|
||||
D3DFORMAT fmt;
|
||||
DWORD dwSize;
|
||||
DWORD dwPitch = 0;
|
||||
D3DLOCKED_RECT lr;
|
||||
|
||||
m_pddNewTexture->GetLevelDesc(LowerSave,&sd);
|
||||
fmt=sd.Format;
|
||||
dwSize=sd.Size;
|
||||
|
||||
m_pddNewTexture->LockRect(LowerSave,&lr,NULL,D3DLOCK_READONLY);
|
||||
dwPitch=lr.Pitch;
|
||||
m_pddNewTexture->UnlockRect(LowerSave);
|
||||
switch (fmt)
|
||||
{
|
||||
case D3DFMT_DXT1:
|
||||
ddsh.ddspf = DDSPF_DXT1;
|
||||
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_LINEARSIZE;
|
||||
ddsh.dwPitchOrLinearSize = dwSize;
|
||||
break;
|
||||
case D3DFMT_DXT2:
|
||||
ddsh.ddspf = DDSPF_DXT2;
|
||||
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_LINEARSIZE;
|
||||
ddsh.dwPitchOrLinearSize = dwSize;
|
||||
break;
|
||||
case D3DFMT_DXT3:
|
||||
ddsh.ddspf = DDSPF_DXT3;
|
||||
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_LINEARSIZE;
|
||||
ddsh.dwPitchOrLinearSize = dwSize;
|
||||
break;
|
||||
case D3DFMT_DXT4:
|
||||
ddsh.ddspf = DDSPF_DXT4;
|
||||
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_LINEARSIZE;
|
||||
ddsh.dwPitchOrLinearSize = dwSize;
|
||||
break;
|
||||
case D3DFMT_DXT5:
|
||||
ddsh.ddspf = DDSPF_DXT5;
|
||||
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_LINEARSIZE;
|
||||
ddsh.dwPitchOrLinearSize = dwSize;
|
||||
break;
|
||||
case D3DFMT_A8R8G8B8:
|
||||
ddsh.ddspf = DDSPF_A8R8G8B8;
|
||||
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_PITCH;
|
||||
ddsh.dwPitchOrLinearSize = dwPitch;
|
||||
break;
|
||||
case D3DFMT_A1R5G5B5:
|
||||
ddsh.ddspf = DDSPF_A1R5G5B5;
|
||||
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_PITCH;
|
||||
ddsh.dwPitchOrLinearSize = dwPitch;
|
||||
break;
|
||||
case D3DFMT_A4R4G4B4:
|
||||
ddsh.ddspf = DDSPF_A4R4G4B4;
|
||||
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_PITCH;
|
||||
ddsh.dwPitchOrLinearSize = dwPitch;
|
||||
break;
|
||||
case D3DFMT_R8G8B8:
|
||||
ddsh.ddspf = DDSPF_R8G8B8;
|
||||
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_PITCH;
|
||||
ddsh.dwPitchOrLinearSize = dwPitch;
|
||||
break;
|
||||
case D3DFMT_R5G6B5:
|
||||
ddsh.ddspf = DDSPF_R5G6B5;
|
||||
ddsh.dwHeaderFlags |= DDS_HEADER_FLAGS_PITCH;
|
||||
ddsh.dwPitchOrLinearSize = dwPitch;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
fwrite(&ddsh,sizeof(ddsh),1,fp);
|
||||
|
||||
LPDIRECT3DSURFACE8 pSurface;
|
||||
|
||||
for(int cLevel=0;cLevel<nMips;cLevel++)
|
||||
{
|
||||
if(FAILED(m_pddNewTexture->GetSurfaceLevel(cLevel+LowerSave,&pSurface)))
|
||||
{
|
||||
break;
|
||||
}
|
||||
pSurface->GetDesc(&sd);
|
||||
pSurface->Release();
|
||||
if(FAILED(m_pddNewTexture->LockRect(cLevel+LowerSave,&lr,NULL,0)))
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (sd.Format == D3DFMT_DXT1 ||
|
||||
sd.Format == D3DFMT_DXT2 ||
|
||||
sd.Format == D3DFMT_DXT3 ||
|
||||
sd.Format == D3DFMT_DXT4 ||
|
||||
sd.Format == D3DFMT_DXT5)
|
||||
{
|
||||
fwrite(lr.pBits,sd.Size,1,fp);
|
||||
}
|
||||
else
|
||||
{
|
||||
WORD yp;
|
||||
BYTE *pbDest=(BYTE*)lr.pBits;
|
||||
LONG dataBytesPerRow=0;
|
||||
|
||||
if(sd.Format==D3DFMT_A8R8G8B8)
|
||||
dataBytesPerRow=4*sd.Width;
|
||||
else if(sd.Format==D3DFMT_R8G8B8)
|
||||
dataBytesPerRow=3*sd.Width;
|
||||
else
|
||||
dataBytesPerRow=2*sd.Width;
|
||||
for(yp=0;yp<sd.Height;yp++)
|
||||
{
|
||||
fwrite(pbDest,dataBytesPerRow,1,fp);
|
||||
pbDest+=lr.Pitch;
|
||||
}
|
||||
}
|
||||
m_pddNewTexture->UnlockRect(cLevel+LowerSave);
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
30
Engine/Zalla3D Base Class/ConvertTexture.h
Normal file
30
Engine/Zalla3D Base Class/ConvertTexture.h
Normal file
@@ -0,0 +1,30 @@
|
||||
// ConvertTexture.h: interface for the CConvertTexture class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_CONVERTTEXTURE_H__CA884184_2931_4713_89E5_356F999EF196__INCLUDED_)
|
||||
#define AFX_CONVERTTEXTURE_H__CA884184_2931_4713_89E5_356F999EF196__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "Texture.h"
|
||||
|
||||
class CConvertTexture : public CTexture
|
||||
{
|
||||
public:
|
||||
void SaveDDS(char *strFilename,int LowerSave,int MaxTextureSize);
|
||||
LPDIRECT3DTEXTURE8 m_pddNewTexture;
|
||||
void SaveDDS(char *strFilename);
|
||||
void GenerateMipMaps(bool bGenMipmap);
|
||||
void Compress(D3DFORMAT fmtTo);
|
||||
|
||||
int GetMipmapCount(){return m_pddTexture->GetLevelCount();};
|
||||
CConvertTexture();
|
||||
virtual ~CConvertTexture();
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_CONVERTTEXTURE_H__CA884184_2931_4713_89E5_356F999EF196__INCLUDED_)
|
||||
97
Engine/Zalla3D Base Class/CrossMHeader.h
Normal file
97
Engine/Zalla3D Base Class/CrossMHeader.h
Normal file
@@ -0,0 +1,97 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef __CROSSM_HEADER_H__
|
||||
|
||||
#define __CROSSM_HEADER_H__
|
||||
|
||||
#pragma warning(disable:4786)
|
||||
#pragma warning(disable:4251)
|
||||
#pragma warning(disable:4503)
|
||||
|
||||
#include <windows.h>
|
||||
#include <algorithm>
|
||||
#include <tchar.h>
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <math.h>
|
||||
#include <process.h>
|
||||
#include <mmsystem.h>
|
||||
#include <time.h>
|
||||
|
||||
|
||||
namespace CROSSM {
|
||||
// template function <20><><EFBFBD><EFBFBD>
|
||||
template<class _T>
|
||||
inline void SafeDelete( _T ptr )
|
||||
{
|
||||
if( NULL != ptr )
|
||||
{
|
||||
delete (ptr);
|
||||
ptr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
template<class _T>
|
||||
inline void SafeDeleteA( _T ptr )
|
||||
{
|
||||
if( NULL != ptr )
|
||||
{
|
||||
delete[] (ptr);
|
||||
ptr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class _T>
|
||||
inline void SafeRelease( _T ptr )
|
||||
{
|
||||
if( NULL != ptr )
|
||||
{
|
||||
ptr->Release();
|
||||
ptr = NULL;
|
||||
}
|
||||
}
|
||||
inline unsigned long GetHashID(const char *strFileName)
|
||||
{
|
||||
unsigned long ulHashId = 0;
|
||||
|
||||
int iLength = (int)strlen(strFileName);
|
||||
|
||||
for(int i=0;i < iLength; i++) {
|
||||
ulHashId += (( i + 1) * strFileName[i]);
|
||||
}
|
||||
return ulHashId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
enum CROSSM_OBJ_TYPE {
|
||||
OBJ_POOL = 0,
|
||||
OBJ_RESOURCE,
|
||||
OBJ_TYPENUMS
|
||||
};
|
||||
enum CROSSM_POOLRESOURCE_TYPE{
|
||||
// Pool <20><>ü
|
||||
POOL_MESSAGEOBJ = 0, // CSGMessage <20><>ü.
|
||||
// POOL_BYTEDATAOBJ, // CByteDataObj
|
||||
// POOL_RESOURCEMGROBJ, // CResourceMgrObj
|
||||
// POOL_DELRESOURCEINFOOBJ, // CDelResourceInfoObj
|
||||
// POOL_HOUSEOBJSCENE, // HouseObjectScene.
|
||||
// POOL_HOUSEOBJ, // HouseObj,
|
||||
// POOL_OBJECTSCENE, // Object Scene
|
||||
// POOL_OCTREEOBJ, // Octree Obj
|
||||
// POOL_POLYNODE, // Poly Node
|
||||
// Resource <20><>ü
|
||||
RESOURCE_TEXTURE, // Texture
|
||||
RESOURCE_MESH, // Mesh
|
||||
RESOURCE_OCTREESCENE, // Octree
|
||||
|
||||
POOLRESOURCE_TYPENUMS,
|
||||
};
|
||||
}
|
||||
#endif
|
||||
0
Engine/Zalla3D Base Class/DebugClass.h
Normal file
0
Engine/Zalla3D Base Class/DebugClass.h
Normal file
246
Engine/Zalla3D Base Class/DeviceInput.cpp
Normal file
246
Engine/Zalla3D Base Class/DeviceInput.cpp
Normal file
@@ -0,0 +1,246 @@
|
||||
// DeviceInput.cpp: implementation of the CDeviceInput class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "DeviceInput.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
LPDIRECTINPUT8 CDeviceInput::m_pDI;
|
||||
LPDIRECTINPUTDEVICE8 CDeviceInput::m_pMouse;
|
||||
LPDIRECTINPUTDEVICE8 CDeviceInput::m_pKeyboard;
|
||||
|
||||
bool CDeviceInput::m_MouseButton[3];
|
||||
POINT CDeviceInput::m_MousePos;
|
||||
bool CDeviceInput::m_isMouseMove;
|
||||
POINT CDeviceInput::m_MouseMovePos;
|
||||
bool CDeviceInput::m_isLeftMouseClick;
|
||||
bool CDeviceInput::m_isRightMouseClick;
|
||||
|
||||
bool CDeviceInput::m_isLeftMouseDown;
|
||||
bool CDeviceInput::m_isRightMouseDown;
|
||||
|
||||
bool CDeviceInput::m_isLeftMousePress;
|
||||
bool CDeviceInput::m_isRightMousePress;
|
||||
|
||||
bool CDeviceInput::m_isRightMouseUp;
|
||||
bool CDeviceInput::m_isMidMousePress;
|
||||
|
||||
float CDeviceInput::m_MouseSpeed;
|
||||
int CDeviceInput::m_MouseZPos;
|
||||
RECT CDeviceInput::m_rcMouseMove;
|
||||
|
||||
char CDeviceInput::m_aryKeyState[256];
|
||||
char CDeviceInput::m_aryKeyOldState[256];
|
||||
|
||||
|
||||
CDeviceInput::CDeviceInput()
|
||||
{
|
||||
m_pDI=NULL;
|
||||
m_pMouse=NULL;
|
||||
m_pKeyboard = NULL;
|
||||
m_MouseButton[0]=false;
|
||||
m_MouseButton[1]=false;
|
||||
m_MouseButton[2]=false;
|
||||
|
||||
m_MousePos.x=0;
|
||||
m_MousePos.y=0;
|
||||
m_MouseZPos=0;
|
||||
|
||||
m_MouseMovePos.x=0;
|
||||
m_MouseMovePos.y=0;
|
||||
m_isLeftMouseClick=m_isRightMouseClick=false;
|
||||
m_isLeftMouseDown=m_isRightMouseDown=false;
|
||||
m_isLeftMousePress=m_isRightMousePress=false;
|
||||
m_isRightMouseUp=false;
|
||||
m_isMouseMove=false;
|
||||
m_MouseSpeed=2.0f;
|
||||
|
||||
SetRect(&m_rcMouseMove,0,0,800-16,600-16);
|
||||
|
||||
memset(m_aryKeyState, 0, 256);
|
||||
memset(m_aryKeyOldState, 0, 256);
|
||||
}
|
||||
|
||||
CDeviceInput::~CDeviceInput()
|
||||
{
|
||||
if(m_pKeyboard)
|
||||
m_pKeyboard->Release();
|
||||
if(m_pMouse)
|
||||
m_pMouse->Release();
|
||||
if(m_pDI)
|
||||
m_pDI->Release();
|
||||
}
|
||||
|
||||
void CDeviceInput::Create(HWND hWnd)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
if( FAILED(DirectInput8Create( GetModuleHandle(NULL), DIRECTINPUT_VERSION,
|
||||
IID_IDirectInput8, (VOID**)&m_pDI, NULL ) ) )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Obtain an interface to the system keyboard device.
|
||||
if( FAILED(m_pDI->CreateDevice( GUID_SysKeyboard, &m_pKeyboard, NULL ) ) )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if( FAILED( hr = m_pKeyboard->SetDataFormat( &c_dfDIKeyboard ) ) )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if(FAILED(m_pKeyboard->SetCooperativeLevel( hWnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND )))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
m_pKeyboard->Acquire();
|
||||
|
||||
|
||||
// Obtain an interface to the system mouse device.
|
||||
if( FAILED(m_pDI->CreateDevice( GUID_SysMouse, &m_pMouse, NULL ) ) )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if( FAILED( hr = m_pMouse->SetDataFormat( &c_dfDIMouse2 ) ) )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
m_pMouse->SetCooperativeLevel(hWnd, DISCL_EXCLUSIVE | DISCL_FOREGROUND);
|
||||
m_pMouse->Acquire();
|
||||
|
||||
|
||||
/*
|
||||
if(FAILED(DirectInputCreate( (HINSTANCE)GetWindowLong( hWnd, GWL_HINSTANCE ),
|
||||
DIRECTINPUT_VERSION, &m_pDI, NULL )))
|
||||
{
|
||||
throw CDeviceInputError("CDeviceInput:Create , Create DirectInput Error");
|
||||
}
|
||||
|
||||
if(FAILED(m_pDI->CreateDevice( GUID_SysKeyboard, &m_pKeyboard, NULL )))
|
||||
{
|
||||
throw CDeviceInputError("CDeviceInput:Create , cannot Get a KeyboardDevice");
|
||||
}
|
||||
if(FAILED(m_pKeyboard->SetDataFormat( &c_dfDIKeyboard )))
|
||||
{
|
||||
throw CDeviceInputError("CDeviceInput:Create , Setting DataFormat failed");
|
||||
}
|
||||
if(FAILED(m_pKeyboard->SetCooperativeLevel( hWnd,DISCL_EXCLUSIVE | DISCL_FOREGROUND )))
|
||||
{
|
||||
throw CDeviceInputError("CDeviceInput:Create ,SetCooperativeLevel is failed");
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
void CDeviceInput::Acquire()
|
||||
{
|
||||
if(m_pKeyboard)
|
||||
m_pKeyboard->Acquire();
|
||||
if(m_pMouse)
|
||||
m_pMouse->Acquire();
|
||||
}
|
||||
|
||||
void CDeviceInput::UnAcquire()
|
||||
{
|
||||
}
|
||||
void CDeviceInput::UpdateInput()
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
memcpy(m_aryKeyOldState, m_aryKeyState, 256);
|
||||
hr = m_pKeyboard->GetDeviceState(256, (void *)&m_aryKeyState);
|
||||
if(FAILED(hr))
|
||||
{
|
||||
memcpy(m_aryKeyState, m_aryKeyOldState, 256);
|
||||
return;
|
||||
}
|
||||
|
||||
DIMOUSESTATE2 dims2; // DirectInput mouse state structure
|
||||
ZeroMemory( &dims2, sizeof(dims2) );
|
||||
hr = m_pMouse->GetDeviceState( sizeof(DIMOUSESTATE2), &dims2 );
|
||||
|
||||
if( FAILED(hr) )
|
||||
{
|
||||
m_MouseMovePos.x=0;
|
||||
m_MouseMovePos.y=0;
|
||||
m_MouseZPos=0;
|
||||
m_MouseButton[0]=false;
|
||||
m_MouseButton[1]=false;
|
||||
m_MouseButton[2]=false;
|
||||
return;
|
||||
}
|
||||
|
||||
m_MouseMovePos.x=dims2.lX;
|
||||
m_MouseMovePos.y=dims2.lY;
|
||||
m_MouseZPos=dims2.lZ;
|
||||
bool oldMouseButton[3];
|
||||
oldMouseButton[0]=m_MouseButton[0];
|
||||
oldMouseButton[1]=m_MouseButton[1];
|
||||
oldMouseButton[2]=m_MouseButton[2];
|
||||
m_MouseButton[0]=(dims2.rgbButtons[0] & 0x80) ? true : false;
|
||||
m_MouseButton[1]=(dims2.rgbButtons[1] & 0x80) ? true : false;
|
||||
m_MouseButton[2]=(dims2.rgbButtons[2] & 0x80) ? true : false;
|
||||
if(m_isMouseMove)
|
||||
{
|
||||
m_MousePos.x+=(int)(m_MouseMovePos.x*m_MouseSpeed);
|
||||
m_MousePos.y+=(int)(m_MouseMovePos.y*m_MouseSpeed);
|
||||
|
||||
if(m_MousePos.x<=m_rcMouseMove.left)
|
||||
m_MousePos.x=m_rcMouseMove.left;
|
||||
|
||||
if(m_MousePos.y<=m_rcMouseMove.top)
|
||||
m_MousePos.y=m_rcMouseMove.top;
|
||||
|
||||
if(m_MousePos.x>=m_rcMouseMove.right)
|
||||
m_MousePos.x=m_rcMouseMove.right;
|
||||
if(m_MousePos.y>=m_rcMouseMove.bottom)
|
||||
m_MousePos.y=m_rcMouseMove.bottom;
|
||||
}
|
||||
if(oldMouseButton[0]==true && m_MouseButton[0]==false)
|
||||
m_isLeftMouseClick=true;
|
||||
else
|
||||
m_isLeftMouseClick=false;
|
||||
|
||||
if(oldMouseButton[1]==true && m_MouseButton[1]==false)
|
||||
m_isRightMouseClick=true;
|
||||
else
|
||||
m_isRightMouseClick=false;
|
||||
|
||||
if(oldMouseButton[0]==false && m_MouseButton[0]==true)
|
||||
m_isLeftMouseDown=true;
|
||||
else
|
||||
m_isLeftMouseDown=false;
|
||||
if(oldMouseButton[1]==false && m_MouseButton[1]==true)
|
||||
m_isRightMouseDown=true;
|
||||
else
|
||||
m_isRightMouseDown=false;
|
||||
|
||||
if(oldMouseButton[1]==true && m_MouseButton[1]==false)
|
||||
m_isRightMouseUp=true;
|
||||
else
|
||||
m_isRightMouseUp=false;
|
||||
|
||||
if(m_MouseButton[0]==true)
|
||||
m_isLeftMousePress=true;
|
||||
else
|
||||
m_isLeftMousePress=false;
|
||||
if(m_MouseButton[1]==true)
|
||||
m_isRightMousePress=true;
|
||||
else
|
||||
m_isRightMousePress=false;
|
||||
|
||||
if(m_MouseButton[2]==true)
|
||||
m_isMidMousePress=true;
|
||||
else
|
||||
m_isMidMousePress=false;
|
||||
}
|
||||
75
Engine/Zalla3D Base Class/DeviceInput.h
Normal file
75
Engine/Zalla3D Base Class/DeviceInput.h
Normal file
@@ -0,0 +1,75 @@
|
||||
// DeviceInput.h: interface for the CDeviceInput class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_DEVICEINPUT_H__70A5C6C2_40AB_4919_9E57_25A08751068F__INCLUDED_)
|
||||
#define AFX_DEVICEINPUT_H__70A5C6C2_40AB_4919_9E57_25A08751068F__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#define DIRECTINPUT_VERSION 0x800
|
||||
|
||||
#include <dinput.h>
|
||||
#include "Exception.h"
|
||||
|
||||
|
||||
class CDeviceInput
|
||||
{
|
||||
static LPDIRECTINPUT8 m_pDI;
|
||||
static LPDIRECTINPUTDEVICE8 m_pMouse;
|
||||
static LPDIRECTINPUTDEVICE8 m_pKeyboard;
|
||||
|
||||
static bool m_MouseButton[3];
|
||||
static POINT m_MousePos;
|
||||
static int m_MouseZPos;
|
||||
static bool m_isMouseMove;
|
||||
|
||||
static POINT m_MouseMovePos;
|
||||
static bool m_isLeftMouseClick,m_isRightMouseClick;
|
||||
static bool m_isLeftMouseDown,m_isRightMouseDown;
|
||||
static bool m_isLeftMousePress,m_isRightMousePress;
|
||||
static bool m_isRightMouseUp;
|
||||
static bool m_isMidMousePress;
|
||||
static float m_MouseSpeed;
|
||||
static RECT m_rcMouseMove;
|
||||
|
||||
static char m_aryKeyState[256];
|
||||
static char m_aryKeyOldState[256];
|
||||
|
||||
public:
|
||||
void UpdateInput();
|
||||
static bool GetIsMousePos(){return m_isMouseMove;};
|
||||
static void SetIsMousePos(bool isMouseMove){m_isMouseMove=isMouseMove;};
|
||||
static bool GetIsLeftMouseClick(){return m_isLeftMouseClick;};
|
||||
static bool GetIsRightMouseClick(){return m_isRightMouseClick;};
|
||||
static bool GetIsLeftMouseDown(){return m_isLeftMouseDown;};
|
||||
static bool GetIsRightMouseDown(){return m_isRightMouseDown;};
|
||||
static bool GetIsLeftMousePress(){return m_isLeftMousePress;};
|
||||
static bool GetIsRightMousePress(){return m_isRightMousePress;};
|
||||
static bool GetIsMidMousePress(){return m_isMidMousePress;};
|
||||
static bool GetIsRightMouseUp(){return m_isRightMouseUp;};
|
||||
|
||||
static void Fake_LeftMouseDown(){ m_isLeftMouseDown=true; };
|
||||
|
||||
static POINT GetMousePosition(){return m_MousePos;};
|
||||
|
||||
static void SetMousePosition(POINT pt){m_MousePos=pt;};
|
||||
static POINT GetMouseMove(){return m_MouseMovePos;};
|
||||
static int GetMouseZMove(){return m_MouseZPos;};
|
||||
|
||||
static BOOL KeyDown(int KeyCode) { if((m_aryKeyState[KeyCode] & 0x80) && !(m_aryKeyOldState[KeyCode] & 0x80)) return TRUE; else return FALSE; }
|
||||
static BOOL KeyHold(int KeyCode) { if(m_aryKeyState[KeyCode] & 0x80) return TRUE; else return FALSE; }
|
||||
static BOOL KeyUp(int KeyCode) { if(!(m_aryKeyState[KeyCode] & 0x80) && (m_aryKeyOldState[KeyCode] & 0x80)) return TRUE; else return FALSE; }
|
||||
|
||||
static void InitKey(int KeyCode) { m_aryKeyState[KeyCode] = 0; m_aryKeyOldState[KeyCode] = 0; }
|
||||
|
||||
static void UnAcquire();
|
||||
static void Acquire();
|
||||
static void Create(HWND hWnd);
|
||||
CDeviceInput();
|
||||
virtual ~CDeviceInput();
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_DEVICEINPUT_H__70A5C6C2_40AB_4919_9E57_25A08751068F__INCLUDED_)
|
||||
20
Engine/Zalla3D Base Class/DeviceInputError.cpp
Normal file
20
Engine/Zalla3D Base Class/DeviceInputError.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
// DeviceInputError.cpp: implementation of the CDeviceInputError class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "DeviceInputError.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CDeviceInputError::CDeviceInputError()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CDeviceInputError::~CDeviceInputError()
|
||||
{
|
||||
|
||||
}
|
||||
35
Engine/Zalla3D Base Class/DeviceInputError.h
Normal file
35
Engine/Zalla3D Base Class/DeviceInputError.h
Normal file
@@ -0,0 +1,35 @@
|
||||
// DeviceInputError.h: interface for the CDeviceInputError class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_DEVICEINPUTERROR_H__1F661071_76D1_4712_8943_137EA762B1DD__INCLUDED_)
|
||||
#define AFX_DEVICEINPUTERROR_H__1F661071_76D1_4712_8943_137EA762B1DD__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "Error.h"
|
||||
|
||||
|
||||
class CDeviceInputError : public CError
|
||||
{
|
||||
public:
|
||||
CDeviceInputError();
|
||||
CDeviceInputError(char *msg)
|
||||
{
|
||||
SetErrorMsg(msg);
|
||||
}
|
||||
char *GetErrorMsg()
|
||||
{
|
||||
char msgtemp[MAX_ERRORBUFFER];
|
||||
strcpy(msgtemp,"Device Input Error:");
|
||||
strcat(msgtemp,m_strErrormsg);
|
||||
strcpy(m_strErrormsg,msgtemp);
|
||||
return m_strErrormsg;
|
||||
};
|
||||
virtual ~CDeviceInputError();
|
||||
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_DEVICEINPUTERROR_H__1F661071_76D1_4712_8943_137EA762B1DD__INCLUDED_)
|
||||
187
Engine/Zalla3D Base Class/DxDiag.h
Normal file
187
Engine/Zalla3D Base Class/DxDiag.h
Normal file
@@ -0,0 +1,187 @@
|
||||
/*==========================================================================;
|
||||
*
|
||||
* Copyright (C) Microsoft Corporation. All Rights Reserved.
|
||||
*
|
||||
* File: dxdiag.h
|
||||
* Content: DirectX Diagnostic Tool include file
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _DXDIAG_H_
|
||||
#define _DXDIAG_H_
|
||||
|
||||
#include <ole2.h> // for DECLARE_INTERFACE_ and HRESULT
|
||||
|
||||
// This identifier is passed to IDxDiagProvider::Initialize in order to ensure that an
|
||||
// application was built against the correct header files. This number is
|
||||
// incremented whenever a header (or other) change would require applications
|
||||
// to be rebuilt. If the version doesn't match, IDxDiagProvider::Initialize will fail.
|
||||
// (The number itself has no meaning.)
|
||||
#define DXDIAG_DX9_SDK_VERSION 111
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* DxDiag Errors
|
||||
*
|
||||
****************************************************************************/
|
||||
#define DXDIAG_E_INSUFFICIENT_BUFFER ((HRESULT)0x8007007AL) // HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER)
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* DxDiag CLSIDs
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
// {A65B8071-3BFE-4213-9A5B-491DA4461CA7}
|
||||
DEFINE_GUID(CLSID_DxDiagProvider,
|
||||
0xA65B8071, 0x3BFE, 0x4213, 0x9A, 0x5B, 0x49, 0x1D, 0xA4, 0x46, 0x1C, 0xA7);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* DxDiag Interface IIDs
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
// {9C6B4CB0-23F8-49CC-A3ED-45A55000A6D2}
|
||||
DEFINE_GUID(IID_IDxDiagProvider,
|
||||
0x9C6B4CB0, 0x23F8, 0x49CC, 0xA3, 0xED, 0x45, 0xA5, 0x50, 0x00, 0xA6, 0xD2);
|
||||
|
||||
// {0x7D0F462F-0x4064-0x4862-BC7F-933E5058C10F}
|
||||
DEFINE_GUID(IID_IDxDiagContainer,
|
||||
0x7D0F462F, 0x4064, 0x4862, 0xBC, 0x7F, 0x93, 0x3E, 0x50, 0x58, 0xC1, 0x0F);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* DxDiag Interface Pointer definitions
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
typedef struct IDxDiagProvider *LPDXDIAGPROVIDER, *PDXDIAGPROVIDER;
|
||||
|
||||
typedef struct IDxDiagContainer *LPDXDIAGCONTAINER, *PDXDIAGCONTAINER;
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* DxDiag Structures
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
typedef struct _DXDIAG_INIT_PARAMS
|
||||
{
|
||||
DWORD dwSize; // Size of this structure.
|
||||
DWORD dwDxDiagHeaderVersion; // Pass in DXDIAG_DX9_SDK_VERSION. This verifies
|
||||
// the header and dll are correctly matched.
|
||||
BOOL bAllowWHQLChecks; // If true, allow dxdiag to check if drivers are
|
||||
// digital signed as logo'd by WHQL which may
|
||||
// connect via internet to update WHQL certificates.
|
||||
VOID* pReserved; // Reserved. Must be NULL.
|
||||
} DXDIAG_INIT_PARAMS;
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* DxDiag Application Interfaces
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
//
|
||||
// COM definition for IDxDiagProvider
|
||||
//
|
||||
#undef INTERFACE // External COM Implementation
|
||||
#define INTERFACE IDxDiagProvider
|
||||
DECLARE_INTERFACE_(IDxDiagProvider,IUnknown)
|
||||
{
|
||||
/*** IUnknown methods ***/
|
||||
STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID *ppvObj) PURE;
|
||||
STDMETHOD_(ULONG,AddRef) (THIS) PURE;
|
||||
STDMETHOD_(ULONG,Release) (THIS) PURE;
|
||||
|
||||
/*** IDxDiagProvider methods ***/
|
||||
STDMETHOD(Initialize) (THIS_ DXDIAG_INIT_PARAMS* pParams) PURE;
|
||||
STDMETHOD(GetRootContainer) (THIS_ IDxDiagContainer **ppInstance) PURE;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// COM definition for IDxDiagContainer
|
||||
//
|
||||
#undef INTERFACE // External COM Implementation
|
||||
#define INTERFACE IDxDiagContainer
|
||||
DECLARE_INTERFACE_(IDxDiagContainer,IUnknown)
|
||||
{
|
||||
/*** IUnknown methods ***/
|
||||
STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID *ppvObj) PURE;
|
||||
STDMETHOD_(ULONG,AddRef) (THIS) PURE;
|
||||
STDMETHOD_(ULONG,Release) (THIS) PURE;
|
||||
|
||||
/*** IDxDiagContainer methods ***/
|
||||
STDMETHOD(GetNumberOfChildContainers) (THIS_ DWORD *pdwCount) PURE;
|
||||
STDMETHOD(EnumChildContainerNames) (THIS_ DWORD dwIndex, LPWSTR pwszContainer, DWORD cchContainer) PURE;
|
||||
STDMETHOD(GetChildContainer) (THIS_ LPCWSTR pwszContainer, IDxDiagContainer **ppInstance) PURE;
|
||||
STDMETHOD(GetNumberOfProps) (THIS_ DWORD *pdwCount) PURE;
|
||||
STDMETHOD(EnumPropNames) (THIS_ DWORD dwIndex, LPWSTR pwszPropName, DWORD cchPropName) PURE;
|
||||
STDMETHOD(GetProp) (THIS_ LPCWSTR pwszPropName, VARIANT *pvarProp) PURE;
|
||||
};
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* DxDiag application interface macros
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if !defined(__cplusplus) || defined(CINTERFACE)
|
||||
|
||||
#define IDxDiagProvider_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
|
||||
#define IDxDiagProvider_AddRef(p) (p)->lpVtbl->AddRef(p)
|
||||
#define IDxDiagProvider_Release(p) (p)->lpVtbl->Release(p)
|
||||
#define IDxDiagProvider_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b)
|
||||
#define IDxDiagProvider_GetRootContainer(p,a) (p)->lpVtbl->GetRootContainer(p,a)
|
||||
|
||||
#define IDxDiagContainer_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
|
||||
#define IDxDiagContainer_AddRef(p) (p)->lpVtbl->AddRef(p)
|
||||
#define IDxDiagContainer_Release(p) (p)->lpVtbl->Release(p)
|
||||
#define IDxDiagContainer_GetNumberOfChildContainers(p,a) (p)->lpVtbl->GetNumberOfChildContainers(p,a)
|
||||
#define IDxDiagContainer_EnumChildContainerNames(p,a,b,c) (p)->lpVtbl->EnumChildContainerNames(p,a,b,c)
|
||||
#define IDxDiagContainer_GetChildContainer(p,a,b) (p)->lpVtbl->GetChildContainer(p,a,b)
|
||||
#define IDxDiagContainer_GetNumberOfProps(p,a) (p)->lpVtbl->GetNumberOfProps(p,a)
|
||||
#define IDxDiagContainer_EnumProps(p,a,b) (p)->lpVtbl->EnumProps(p,a,b,c)
|
||||
#define IDxDiagContainer_GetProp(p,a,b) (p)->lpVtbl->GetProp(p,a,b)
|
||||
|
||||
#else /* C++ */
|
||||
|
||||
#define IDxDiagProvider_QueryInterface(p,a,b) (p)->QueryInterface(p,a,b)
|
||||
#define IDxDiagProvider_AddRef(p) (p)->AddRef(p)
|
||||
#define IDxDiagProvider_Release(p) (p)->Release(p)
|
||||
#define IDxDiagProvider_Initialize(p,a,b) (p)->Initialize(p,a,b)
|
||||
#define IDxDiagProvider_GetRootContainer(p,a) (p)->GetRootContainer(p,a)
|
||||
|
||||
#define IDxDiagContainer_QueryInterface(p,a,b) (p)->QueryInterface(p,a,b)
|
||||
#define IDxDiagContainer_AddRef(p) (p)->AddRef(p)
|
||||
#define IDxDiagContainer_Release(p) (p)->Release(p)
|
||||
#define IDxDiagContainer_GetNumberOfChildContainers(p,a) (p)->GetNumberOfChildContainers(p,a)
|
||||
#define IDxDiagContainer_EnumChildContainerNames(p,a,b,c) (p)->EnumChildContainerNames(p,a,b,c)
|
||||
#define IDxDiagContainer_GetChildContainer(p,a,b) (p)->GetChildContainer(p,a,b)
|
||||
#define IDxDiagContainer_GetNumberOfProps(p,a) (p)->GetNumberOfProps(p,a)
|
||||
#define IDxDiagContainer_EnumProps(p,a,b) (p)->EnumProps(p,a,b,c)
|
||||
#define IDxDiagContainer_GetProp(p,a,b) (p)->GetProp(p,a,b)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _DXDIAG_H_ */
|
||||
|
||||
|
||||
489
Engine/Zalla3D Base Class/EnumD3D.cpp
Normal file
489
Engine/Zalla3D Base Class/EnumD3D.cpp
Normal file
@@ -0,0 +1,489 @@
|
||||
// EnumD3D.cpp: implementation of the CEnumD3D class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "EnumD3D.h"
|
||||
#include <dsound.h>
|
||||
#include "GMMemory.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
D3DAdapterInfo CEnumD3D::m_Adapters[10];
|
||||
DWORD CEnumD3D::m_dwNumAdapters;
|
||||
DWORD CEnumD3D::m_dwAdapter;
|
||||
BOOL CEnumD3D::m_bWindowed;
|
||||
LPDIRECT3D8 CEnumD3D::m_pD3D;
|
||||
BOOL CEnumD3D::m_bUseDepthBuffer;
|
||||
long CEnumD3D::m_dwMinDepthBits;
|
||||
long CEnumD3D::m_dwMinStencilBits;
|
||||
|
||||
long CEnumD3D::m_nAdapter;
|
||||
long CEnumD3D::m_nDevice;
|
||||
long CEnumD3D::m_nMode;
|
||||
|
||||
TCHAR CEnumD3D::m_strSoundCard[64];
|
||||
TCHAR CEnumD3D::m_strSoundCardDrv[64];
|
||||
|
||||
|
||||
int SortModesCallback( const VOID* arg1, const VOID* arg2 )
|
||||
{
|
||||
D3DDISPLAYMODE* p1 = (D3DDISPLAYMODE*)arg1;
|
||||
D3DDISPLAYMODE* p2 = (D3DDISPLAYMODE*)arg2;
|
||||
|
||||
if( p1->Format > p2->Format ) return -1;
|
||||
if( p1->Format < p2->Format ) return +1;
|
||||
if( p1->Width < p2->Width ) return -1;
|
||||
if( p1->Width > p2->Width ) return +1;
|
||||
if( p1->Height < p2->Height ) return -1;
|
||||
if( p1->Height > p2->Height ) return +1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
VOID EnumSound();
|
||||
BOOL CALLBACK
|
||||
DSoundEnumProc(LPGUID lpGUID,
|
||||
LPCTSTR lpszDesc,
|
||||
LPCTSTR lpszDrvName,
|
||||
LPVOID lpContext );
|
||||
|
||||
CEnumD3D::CEnumD3D()
|
||||
{
|
||||
m_bUseDepthBuffer=true;
|
||||
m_nAdapter=m_nDevice=m_nMode=0;
|
||||
}
|
||||
|
||||
CEnumD3D::~CEnumD3D()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
HRESULT CEnumD3D::Enum()
|
||||
{
|
||||
m_pD3D=Direct3DCreate8(D3D_SDK_VERSION);
|
||||
const DWORD dwNumDeviceTypes = 2;
|
||||
const TCHAR* strDeviceDescs[] = { "HAL", "REF" };
|
||||
const D3DDEVTYPE DeviceTypes[] = { D3DDEVTYPE_HAL, D3DDEVTYPE_REF };
|
||||
|
||||
BOOL bHALExists = FALSE;
|
||||
BOOL bHALIsWindowedCompatible = FALSE;
|
||||
BOOL bHALIsDesktopCompatible = FALSE;
|
||||
BOOL bHALIsSampleCompatible = FALSE;
|
||||
|
||||
// Loop through all the adapters on the system (usually, there's just one
|
||||
// unless more than one graphics card is present).
|
||||
m_dwNumAdapters=0;
|
||||
for( UINT iAdapter = 0; iAdapter < m_pD3D->GetAdapterCount(); iAdapter++ )
|
||||
{
|
||||
// Fill in adapter info
|
||||
D3DAdapterInfo* pAdapter = &m_Adapters[m_dwNumAdapters];
|
||||
m_pD3D->GetAdapterIdentifier( iAdapter, 0, &pAdapter->d3dAdapterIdentifier );
|
||||
m_pD3D->GetAdapterDisplayMode( iAdapter, &pAdapter->d3ddmDesktop );
|
||||
pAdapter->dwNumDevices = 0;
|
||||
pAdapter->dwCurrentDevice = 0;
|
||||
|
||||
// Enumerate all display modes on this adapter
|
||||
CD3DDISPLAYMODE modes[100];
|
||||
D3DFORMAT formats[20];
|
||||
DWORD dwNumFormats = 0;
|
||||
DWORD dwNumModes = 0;
|
||||
DWORD dwNumAdapterModes = m_pD3D->GetAdapterModeCount( iAdapter );
|
||||
|
||||
// Add the adapter's current desktop format to the list of formats
|
||||
formats[dwNumFormats++] = pAdapter->d3ddmDesktop.Format;
|
||||
|
||||
DWORD dwRefreshCount = 0;
|
||||
ZeroMemory(&modes[0].RefreshRate, sizeof(modes[0].RefreshRate));
|
||||
for( UINT iMode = 0; iMode < dwNumAdapterModes; iMode++ )
|
||||
{
|
||||
// Get the display mode attributes
|
||||
D3DDISPLAYMODE DisplayMode;
|
||||
m_pD3D->EnumAdapterModes( iAdapter, iMode, &DisplayMode );
|
||||
|
||||
// Filter out low-resolution modes
|
||||
if( DisplayMode.Width < 640 || DisplayMode.Height < 400 )
|
||||
continue;
|
||||
|
||||
// Check if the mode already exists (to filter out refresh rates)
|
||||
DWORD m=0L;
|
||||
for( ; m<dwNumModes; m++ )
|
||||
{
|
||||
if( ( modes[m].Width == DisplayMode.Width ) &&
|
||||
( modes[m].Height == DisplayMode.Height ) &&
|
||||
( modes[m].Format == DisplayMode.Format ) )
|
||||
break;
|
||||
}
|
||||
|
||||
// If we found a new mode, add it to the list of modes
|
||||
if( m == dwNumModes )
|
||||
{
|
||||
dwRefreshCount = 0;
|
||||
ZeroMemory(&modes[dwNumModes].RefreshRate, sizeof(modes[dwNumModes].RefreshRate));
|
||||
modes[dwNumModes].RefreshRate[dwRefreshCount++] = DisplayMode.RefreshRate;
|
||||
modes[dwNumModes].Width = DisplayMode.Width;
|
||||
modes[dwNumModes].Height = DisplayMode.Height;
|
||||
modes[dwNumModes].Format = DisplayMode.Format;
|
||||
dwNumModes++;
|
||||
|
||||
// Check if the mode's format already exists
|
||||
DWORD f=0;
|
||||
for( ; f<dwNumFormats; f++ )
|
||||
{
|
||||
if( DisplayMode.Format == formats[f] )
|
||||
break;
|
||||
}
|
||||
|
||||
// If the format is new, add it to the list
|
||||
if( f== dwNumFormats )
|
||||
formats[dwNumFormats++] = DisplayMode.Format;
|
||||
} else
|
||||
{
|
||||
modes[m].RefreshRate[dwRefreshCount++] = DisplayMode.RefreshRate;
|
||||
}
|
||||
}
|
||||
|
||||
// Sort the list of display modes (by format, then width, then height)
|
||||
// qsort( modes, dwNumModes, sizeof(CD3DDISPLAYMODE), SortModesCallback );
|
||||
|
||||
// Add devices to adapter
|
||||
for( UINT iDevice = 0; iDevice < dwNumDeviceTypes; iDevice++ )
|
||||
{
|
||||
// Fill in device info
|
||||
D3DDeviceInfo* pDevice;
|
||||
pDevice = &pAdapter->devices[pAdapter->dwNumDevices];
|
||||
pDevice->DeviceType = DeviceTypes[iDevice];
|
||||
m_pD3D->GetDeviceCaps( iAdapter, DeviceTypes[iDevice], &pDevice->d3dCaps );
|
||||
pDevice->strDesc = strDeviceDescs[iDevice];
|
||||
pDevice->dwNumModes = 0;
|
||||
pDevice->dwCurrentMode = 0;
|
||||
pDevice->bCanDoWindowed = FALSE;
|
||||
pDevice->bWindowed = FALSE;
|
||||
pDevice->MultiSampleType = D3DMULTISAMPLE_NONE;
|
||||
|
||||
// Examine each format supported by the adapter to see if it will
|
||||
// work with this device and meets the needs of the application.
|
||||
BOOL bFormatConfirmed[20];
|
||||
DWORD dwBehavior[20];
|
||||
D3DFORMAT fmtDepthStencil[20];
|
||||
|
||||
for( DWORD f=0; f<dwNumFormats; f++ )
|
||||
{
|
||||
bFormatConfirmed[f] = FALSE;
|
||||
fmtDepthStencil[f] = D3DFMT_UNKNOWN;
|
||||
|
||||
// Skip formats that cannot be used as render targets on this device
|
||||
if( FAILED( m_pD3D->CheckDeviceType( iAdapter, pDevice->DeviceType,
|
||||
formats[f], formats[f], FALSE ) ) )
|
||||
continue;
|
||||
|
||||
if( pDevice->DeviceType == D3DDEVTYPE_HAL )
|
||||
{
|
||||
// This system has a HAL device
|
||||
bHALExists = TRUE;
|
||||
|
||||
if( pDevice->d3dCaps.Caps2 & D3DCAPS2_CANRENDERWINDOWED )
|
||||
{
|
||||
// HAL can run in a window for some mode
|
||||
bHALIsWindowedCompatible = TRUE;
|
||||
|
||||
if( f == 0 )
|
||||
{
|
||||
// HAL can run in a window for the current desktop mode
|
||||
bHALIsDesktopCompatible = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Confirm the device/format for HW vertex processing
|
||||
if( pDevice->d3dCaps.DevCaps&D3DDEVCAPS_HWTRANSFORMANDLIGHT )
|
||||
{
|
||||
if( pDevice->d3dCaps.DevCaps&D3DDEVCAPS_PUREDEVICE )
|
||||
{
|
||||
/*
|
||||
dwBehavior[f] = D3DCREATE_HARDWARE_VERTEXPROCESSING |
|
||||
D3DCREATE_PUREDEVICE;
|
||||
*/
|
||||
dwBehavior[f] = D3DCREATE_HARDWARE_VERTEXPROCESSING;
|
||||
|
||||
if( SUCCEEDED( ConfirmDevice( &pDevice->d3dCaps, dwBehavior[f],
|
||||
formats[f] ) ) )
|
||||
bFormatConfirmed[f] = FALSE;
|
||||
}
|
||||
|
||||
if ( FALSE == bFormatConfirmed[f] )
|
||||
{
|
||||
dwBehavior[f] = D3DCREATE_HARDWARE_VERTEXPROCESSING;
|
||||
|
||||
if( SUCCEEDED( ConfirmDevice( &pDevice->d3dCaps, dwBehavior[f],
|
||||
formats[f] ) ) )
|
||||
bFormatConfirmed[f] = TRUE;
|
||||
}
|
||||
|
||||
if ( FALSE == bFormatConfirmed[f] )
|
||||
{
|
||||
dwBehavior[f] = D3DCREATE_MIXED_VERTEXPROCESSING;
|
||||
|
||||
if( SUCCEEDED( ConfirmDevice( &pDevice->d3dCaps, dwBehavior[f],
|
||||
formats[f] ) ) )
|
||||
bFormatConfirmed[f] = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// Confirm the device/format for SW vertex processing
|
||||
if( FALSE == bFormatConfirmed[f] )
|
||||
{
|
||||
dwBehavior[f] = D3DCREATE_SOFTWARE_VERTEXPROCESSING;
|
||||
|
||||
if( SUCCEEDED( ConfirmDevice( &pDevice->d3dCaps, dwBehavior[f],
|
||||
formats[f] ) ) )
|
||||
bFormatConfirmed[f] = TRUE;
|
||||
}
|
||||
|
||||
// Find a suitable depth/stencil buffer format for this device/format
|
||||
if( bFormatConfirmed[f])
|
||||
{
|
||||
if( !FindDepthStencilFormat( iAdapter, pDevice->DeviceType,
|
||||
formats[f], &fmtDepthStencil[f] ) )
|
||||
{
|
||||
bFormatConfirmed[f] = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add all enumerated display modes with confirmed formats to the
|
||||
// device's list of valid modes
|
||||
DWORD m=0L;
|
||||
for( ; m<dwNumModes; m++ )
|
||||
{
|
||||
for( DWORD f=0; f<dwNumFormats; f++ )
|
||||
{
|
||||
if( modes[m].Format == formats[f] )
|
||||
{
|
||||
if( bFormatConfirmed[f] == TRUE )
|
||||
{
|
||||
// Add this mode to the device's list of valid modes
|
||||
pDevice->modes[pDevice->dwNumModes].Width = modes[m].Width;
|
||||
pDevice->modes[pDevice->dwNumModes].Height = modes[m].Height;
|
||||
pDevice->modes[pDevice->dwNumModes].Format = modes[m].Format;
|
||||
pDevice->modes[pDevice->dwNumModes].dwBehavior = dwBehavior[f];
|
||||
pDevice->modes[pDevice->dwNumModes].DepthStencilFormat = fmtDepthStencil[f];
|
||||
|
||||
for( DWORD r = 0; r < 50; ++r )
|
||||
{
|
||||
pDevice->modes[pDevice->dwNumModes].dwRefresh[r] = modes[m].RefreshRate[r];
|
||||
}
|
||||
|
||||
pDevice->dwNumModes++;
|
||||
|
||||
if( pDevice->DeviceType == D3DDEVTYPE_HAL )
|
||||
bHALIsSampleCompatible = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Select any 640x480 mode for default (but prefer a 16-bit mode)
|
||||
for( m=0; m<pDevice->dwNumModes; m++ )
|
||||
{
|
||||
if( pDevice->modes[m].Width==640 && pDevice->modes[m].Height==480 )
|
||||
{
|
||||
pDevice->dwCurrentMode = m;
|
||||
if( pDevice->modes[m].Format == D3DFMT_R5G6B5 ||
|
||||
pDevice->modes[m].Format == D3DFMT_X1R5G5B5 ||
|
||||
pDevice->modes[m].Format == D3DFMT_A1R5G5B5 )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the device is compatible with the desktop display mode
|
||||
// (which was added initially as formats[0])
|
||||
if( bFormatConfirmed[0] && (pDevice->d3dCaps.Caps2 & D3DCAPS2_CANRENDERWINDOWED) )
|
||||
{
|
||||
pDevice->bCanDoWindowed = TRUE;
|
||||
pDevice->bWindowed = TRUE;
|
||||
}
|
||||
|
||||
// If valid modes were found, keep this device
|
||||
if( pDevice->dwNumModes > 0 )
|
||||
pAdapter->dwNumDevices++;
|
||||
}
|
||||
|
||||
// If valid devices were found, keep this adapter
|
||||
if( pAdapter->dwNumDevices > 0 )
|
||||
m_dwNumAdapters++;
|
||||
}
|
||||
|
||||
// Return an error if no compatible devices were found
|
||||
if( 0L == m_dwNumAdapters )
|
||||
return S_OK;
|
||||
|
||||
// Pick a default device that can render into a window
|
||||
// (This code assumes that the HAL device comes before the REF
|
||||
// device in the device array).
|
||||
m_pD3D->Release();
|
||||
EnumSound();
|
||||
|
||||
for( DWORD a=0; a<m_dwNumAdapters; a++ )
|
||||
{
|
||||
for( DWORD d=0; d < m_Adapters[a].dwNumDevices; d++ )
|
||||
{
|
||||
if( m_Adapters[a].devices[d].bWindowed )
|
||||
{
|
||||
m_Adapters[a].dwCurrentDevice = d;
|
||||
m_dwAdapter = a;
|
||||
m_bWindowed = TRUE;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
BOOL CEnumD3D::FindDepthStencilFormat(UINT iAdapter, D3DDEVTYPE DeviceType, D3DFORMAT TargetFormat, D3DFORMAT *pDepthStencilFormat)
|
||||
{
|
||||
if( m_dwMinDepthBits <= 16 && m_dwMinStencilBits == 0 )
|
||||
{
|
||||
if( SUCCEEDED( m_pD3D->CheckDeviceFormat( iAdapter, DeviceType,
|
||||
TargetFormat, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D16 ) ) )
|
||||
{
|
||||
if( SUCCEEDED( m_pD3D->CheckDepthStencilMatch( iAdapter, DeviceType,
|
||||
TargetFormat, TargetFormat, D3DFMT_D16 ) ) )
|
||||
{
|
||||
*pDepthStencilFormat = D3DFMT_D16;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( m_dwMinDepthBits <= 15 && m_dwMinStencilBits <= 1 )
|
||||
{
|
||||
if( SUCCEEDED( m_pD3D->CheckDeviceFormat( iAdapter, DeviceType,
|
||||
TargetFormat, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D15S1 ) ) )
|
||||
{
|
||||
if( SUCCEEDED( m_pD3D->CheckDepthStencilMatch( iAdapter, DeviceType,
|
||||
TargetFormat, TargetFormat, D3DFMT_D15S1 ) ) )
|
||||
{
|
||||
*pDepthStencilFormat = D3DFMT_D15S1;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( m_dwMinDepthBits <= 24 && m_dwMinStencilBits == 0 )
|
||||
{
|
||||
if( SUCCEEDED( m_pD3D->CheckDeviceFormat( iAdapter, DeviceType,
|
||||
TargetFormat, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D24X8 ) ) )
|
||||
{
|
||||
if( SUCCEEDED( m_pD3D->CheckDepthStencilMatch( iAdapter, DeviceType,
|
||||
TargetFormat, TargetFormat, D3DFMT_D24X8 ) ) )
|
||||
{
|
||||
*pDepthStencilFormat = D3DFMT_D24X8;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( m_dwMinDepthBits <= 24 && m_dwMinStencilBits <= 8 )
|
||||
{
|
||||
if( SUCCEEDED( m_pD3D->CheckDeviceFormat( iAdapter, DeviceType,
|
||||
TargetFormat, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D24S8 ) ) )
|
||||
{
|
||||
if( SUCCEEDED( m_pD3D->CheckDepthStencilMatch( iAdapter, DeviceType,
|
||||
TargetFormat, TargetFormat, D3DFMT_D24S8 ) ) )
|
||||
{
|
||||
*pDepthStencilFormat = D3DFMT_D24S8;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( m_dwMinDepthBits <= 24 && m_dwMinStencilBits <= 4 )
|
||||
{
|
||||
if( SUCCEEDED( m_pD3D->CheckDeviceFormat( iAdapter, DeviceType,
|
||||
TargetFormat, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D24X4S4 ) ) )
|
||||
{
|
||||
if( SUCCEEDED( m_pD3D->CheckDepthStencilMatch( iAdapter, DeviceType,
|
||||
TargetFormat, TargetFormat, D3DFMT_D24X4S4 ) ) )
|
||||
{
|
||||
*pDepthStencilFormat = D3DFMT_D24X4S4;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( m_dwMinDepthBits <= 32 && m_dwMinStencilBits == 0 )
|
||||
{
|
||||
if( SUCCEEDED( m_pD3D->CheckDeviceFormat( iAdapter, DeviceType,
|
||||
TargetFormat, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D32 ) ) )
|
||||
{
|
||||
if( SUCCEEDED( m_pD3D->CheckDepthStencilMatch( iAdapter, DeviceType,
|
||||
TargetFormat, TargetFormat, D3DFMT_D32 ) ) )
|
||||
{
|
||||
*pDepthStencilFormat = D3DFMT_D32;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
HRESULT CEnumD3D::ConfirmDevice(D3DCAPS8 *, DWORD, D3DFORMAT)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
VOID EnumSound()
|
||||
{
|
||||
|
||||
LPDIRECTSOUND8 pDS;
|
||||
if( FAILED(DirectSoundCreate8(NULL, &pDS, NULL)) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (FAILED(DirectSoundEnumerate((LPDSENUMCALLBACK)DSoundEnumProc,
|
||||
NULL)))
|
||||
{
|
||||
if( pDS )
|
||||
{
|
||||
pDS->Release();
|
||||
pDS = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if( pDS )
|
||||
{
|
||||
pDS->Release();
|
||||
pDS = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BOOL CALLBACK DSoundEnumProc(LPGUID lpGUID,
|
||||
LPCTSTR lpszDesc,
|
||||
LPCTSTR lpszDrvName,
|
||||
LPVOID lpContext )
|
||||
{
|
||||
HWND hCombo = (HWND)lpContext;
|
||||
LPGUID lpTemp = NULL;
|
||||
|
||||
|
||||
if (lpGUID != NULL) // NULL only for "Primary Sound Driver".
|
||||
{
|
||||
strcpy( CEnumD3D::m_strSoundCard, lpszDesc );
|
||||
strcpy( CEnumD3D::m_strSoundCardDrv, lpszDrvName );
|
||||
}
|
||||
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
107
Engine/Zalla3D Base Class/EnumD3D.h
Normal file
107
Engine/Zalla3D Base Class/EnumD3D.h
Normal file
@@ -0,0 +1,107 @@
|
||||
// EnumD3D.h: interface for the CEnumD3D class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_ENUMD3D_H__9D5F8359_25F1_49DD_8C6A_CADE38529740__INCLUDED_)
|
||||
#define AFX_ENUMD3D_H__9D5F8359_25F1_49DD_8C6A_CADE38529740__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
#include <d3d8.h>
|
||||
#include <vector>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: struct D3DModeInfo
|
||||
// Desc: Structure for holding information about a display mode
|
||||
//-----------------------------------------------------------------------------
|
||||
struct D3DModeInfo
|
||||
{
|
||||
DWORD Width; // Screen width in this mode
|
||||
DWORD Height; // Screen height in this mode
|
||||
D3DFORMAT Format; // Pixel format in this mode
|
||||
DWORD dwBehavior; // Hardware / Software / Mixed vertex processing
|
||||
DWORD dwRefresh[50];
|
||||
D3DFORMAT DepthStencilFormat; // Which depth/stencil format to use with this mode
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: struct D3DDeviceInfo
|
||||
// Desc: Structure for holding information about a Direct3D device, including
|
||||
// a list of modes compatible with this device
|
||||
//-----------------------------------------------------------------------------
|
||||
struct D3DDeviceInfo
|
||||
{
|
||||
// Device data
|
||||
D3DDEVTYPE DeviceType; // Reference, HAL, etc.
|
||||
D3DCAPS8 d3dCaps; // Capabilities of this device
|
||||
const TCHAR* strDesc; // Name of this device
|
||||
BOOL bCanDoWindowed; // Whether this device can work in windowed mode
|
||||
|
||||
// Modes for this device
|
||||
DWORD dwNumModes;
|
||||
D3DModeInfo modes[150];
|
||||
|
||||
// Current state
|
||||
DWORD dwCurrentMode;
|
||||
BOOL bWindowed;
|
||||
D3DMULTISAMPLE_TYPE MultiSampleType;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: struct D3DAdapterInfo
|
||||
// Desc: Structure for holding information about an adapter, including a list
|
||||
// of devices available on this adapter
|
||||
//-----------------------------------------------------------------------------
|
||||
struct D3DAdapterInfo
|
||||
{
|
||||
// Adapter data
|
||||
D3DADAPTER_IDENTIFIER8 d3dAdapterIdentifier;
|
||||
D3DDISPLAYMODE d3ddmDesktop; // Desktop display mode for this adapter
|
||||
|
||||
// Devices for this adapter
|
||||
DWORD dwNumDevices;
|
||||
D3DDeviceInfo devices[5];
|
||||
|
||||
// Current state
|
||||
DWORD dwCurrentDevice;
|
||||
};
|
||||
|
||||
/* Display Modes */
|
||||
typedef struct _CD3DDISPLAYMODE
|
||||
{
|
||||
UINT Width;
|
||||
UINT Height;
|
||||
UINT RefreshRate[50];
|
||||
D3DFORMAT Format;
|
||||
} CD3DDISPLAYMODE;
|
||||
|
||||
class CEnumD3D
|
||||
{
|
||||
static BOOL m_bWindowed;
|
||||
static long m_dwMinDepthBits;
|
||||
static long m_dwMinStencilBits;
|
||||
public:
|
||||
static long m_nAdapter,m_nDevice,m_nMode;
|
||||
static LPDIRECT3D8 m_pD3D;
|
||||
static DWORD m_dwNumAdapters;
|
||||
static BOOL m_bUseDepthBuffer;
|
||||
static DWORD m_dwAdapter;
|
||||
static D3DAdapterInfo m_Adapters[10];
|
||||
static TCHAR m_strSoundCard[64];
|
||||
static TCHAR m_strSoundCardDrv[64];
|
||||
|
||||
static HRESULT ConfirmDevice(D3DCAPS8*,DWORD,D3DFORMAT);
|
||||
static BOOL FindDepthStencilFormat(UINT iAdapter, D3DDEVTYPE DeviceType, D3DFORMAT TargetFormat, D3DFORMAT *pDepthStencilFormat);
|
||||
static HRESULT Enum();
|
||||
CEnumD3D();
|
||||
virtual ~CEnumD3D();
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_ENUMD3D_H__9D5F8359_25F1_49DD_8C6A_CADE38529740__INCLUDED_)
|
||||
20
Engine/Zalla3D Base Class/Error.cpp
Normal file
20
Engine/Zalla3D Base Class/Error.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
// Error.cpp: implementation of the CError class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Error.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CError::CError()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CError::~CError()
|
||||
{
|
||||
|
||||
}
|
||||
41
Engine/Zalla3D Base Class/Error.h
Normal file
41
Engine/Zalla3D Base Class/Error.h
Normal file
@@ -0,0 +1,41 @@
|
||||
// Error.h: interface for the CError class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_ERROR_H__0F1AE97A_A373_4DE7_B36A_23BE292D42B2__INCLUDED_)
|
||||
#define AFX_ERROR_H__0F1AE97A_A373_4DE7_B36A_23BE292D42B2__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
#include <string>
|
||||
|
||||
const long MAX_ERRORBUFFER=256;
|
||||
|
||||
|
||||
class CError
|
||||
{
|
||||
protected:
|
||||
char m_strErrormsg[MAX_ERRORBUFFER];
|
||||
public:
|
||||
CError();
|
||||
virtual ~CError();
|
||||
void SetErrorMsg(char *msg)
|
||||
{
|
||||
strcpy(m_strErrormsg,msg);
|
||||
}
|
||||
virtual char *GetErrorMsg()
|
||||
{
|
||||
char msgtemp[MAX_ERRORBUFFER];
|
||||
strcpy(msgtemp,"General Error:");
|
||||
strcat(msgtemp,m_strErrormsg);
|
||||
strcpy(m_strErrormsg,msgtemp);
|
||||
return m_strErrormsg;
|
||||
}
|
||||
CError(char *msg)
|
||||
{
|
||||
SetErrorMsg(msg);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_ERROR_H__0F1AE97A_A373_4DE7_B36A_23BE292D42B2__INCLUDED_)
|
||||
10
Engine/Zalla3D Base Class/Exception.h
Normal file
10
Engine/Zalla3D Base Class/Exception.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef _EXCEPTION_H
|
||||
#define _EXCEPTION_H
|
||||
|
||||
#pragma once
|
||||
|
||||
//#include <Utility/Exception.h>
|
||||
#include "Error.h"
|
||||
#include "GraphicLayerError.h"
|
||||
#include "DeviceInputError.h"
|
||||
#endif
|
||||
521
Engine/Zalla3D Base Class/FastMath.cpp
Normal file
521
Engine/Zalla3D Base Class/FastMath.cpp
Normal file
@@ -0,0 +1,521 @@
|
||||
// FastMath.cpp: implementation of the CFastMath class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <tchar.h>
|
||||
#include "FastMath.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
// This table only works on Little Endian(Byte Order) machine.
|
||||
unsigned short CFastMath::m_FastHeToBi[0x100] = {
|
||||
0x3030, 0x3130, 0x3230, 0x3330, 0x3430, 0x3530, 0x3630, 0x3730,
|
||||
0x3830, 0x3930, 0x4130, 0x4230, 0x4330, 0x4430, 0x4530, 0x4630,
|
||||
0x3031, 0x3131, 0x3231, 0x3331, 0x3431, 0x3531, 0x3631, 0x3731,
|
||||
0x3831, 0x3931, 0x4131, 0x4231, 0x4331, 0x4431, 0x4531, 0x4631,
|
||||
0x3032, 0x3132, 0x3232, 0x3332, 0x3432, 0x3532, 0x3632, 0x3732,
|
||||
0x3832, 0x3932, 0x4132, 0x4232, 0x4332, 0x4432, 0x4532, 0x4632,
|
||||
0x3033, 0x3133, 0x3233, 0x3333, 0x3433, 0x3533, 0x3633, 0x3733,
|
||||
0x3833, 0x3933, 0x4133, 0x4233, 0x4333, 0x4433, 0x4533, 0x4633,
|
||||
0x3034, 0x3134, 0x3234, 0x3334, 0x3434, 0x3534, 0x3634, 0x3734,
|
||||
0x3834, 0x3934, 0x4134, 0x4234, 0x4334, 0x4434, 0x4534, 0x4634,
|
||||
0x3035, 0x3135, 0x3235, 0x3335, 0x3435, 0x3535, 0x3635, 0x3735,
|
||||
0x3835, 0x3935, 0x4135, 0x4235, 0x4335, 0x4435, 0x4535, 0x4635,
|
||||
0x3036, 0x3136, 0x3236, 0x3336, 0x3436, 0x3536, 0x3636, 0x3736,
|
||||
0x3836, 0x3936, 0x4136, 0x4236, 0x4336, 0x4436, 0x4536, 0x4636,
|
||||
0x3037, 0x3137, 0x3237, 0x3337, 0x3437, 0x3537, 0x3637, 0x3737,
|
||||
0x3837, 0x3937, 0x4137, 0x4237, 0x4337, 0x4437, 0x4537, 0x4637,
|
||||
0x3038, 0x3138, 0x3238, 0x3338, 0x3438, 0x3538, 0x3638, 0x3738,
|
||||
0x3838, 0x3938, 0x4138, 0x4238, 0x4338, 0x4438, 0x4538, 0x4638,
|
||||
0x3039, 0x3139, 0x3239, 0x3339, 0x3439, 0x3539, 0x3639, 0x3739,
|
||||
0x3839, 0x3939, 0x4139, 0x4239, 0x4339, 0x4439, 0x4539, 0x4639,
|
||||
0x3041, 0x3141, 0x3241, 0x3341, 0x3441, 0x3541, 0x3641, 0x3741,
|
||||
0x3841, 0x3941, 0x4141, 0x4241, 0x4341, 0x4441, 0x4541, 0x4641,
|
||||
0x3042, 0x3142, 0x3242, 0x3342, 0x3442, 0x3542, 0x3642, 0x3742,
|
||||
0x3842, 0x3942, 0x4142, 0x4242, 0x4342, 0x4442, 0x4542, 0x4642,
|
||||
0x3043, 0x3143, 0x3243, 0x3343, 0x3443, 0x3543, 0x3643, 0x3743,
|
||||
0x3843, 0x3943, 0x4143, 0x4243, 0x4343, 0x4443, 0x4543, 0x4643,
|
||||
0x3044, 0x3144, 0x3244, 0x3344, 0x3444, 0x3544, 0x3644, 0x3744,
|
||||
0x3844, 0x3944, 0x4144, 0x4244, 0x4344, 0x4444, 0x4544, 0x4644,
|
||||
0x3045, 0x3145, 0x3245, 0x3345, 0x3445, 0x3545, 0x3645, 0x3745,
|
||||
0x3845, 0x3945, 0x4145, 0x4245, 0x4345, 0x4445, 0x4545, 0x4645,
|
||||
0x3046, 0x3146, 0x3246, 0x3346, 0x3446, 0x3546, 0x3646, 0x3746,
|
||||
0x3846, 0x3946, 0x4146, 0x4246, 0x4346, 0x4446, 0x4546, 0x4646,
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
unsigned int CFastMath::m_FastSqrtTable[0x10000];
|
||||
long CFastMath::m_HoldRand = 1L;
|
||||
CFastMath::CFastMath()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CFastMath::~CFastMath()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CFastMath::Init()
|
||||
{
|
||||
unsigned int i;
|
||||
FastSqrtUnion s;
|
||||
for (i=0;i<=0x7FFF;i++)
|
||||
{
|
||||
s.i = (i << 8) | (0x7F << 23);
|
||||
s.f = (float)sqrt(s.f);
|
||||
m_FastSqrtTable[i+0x8000]=(s.i&0x7FFFFF);
|
||||
s.i = (i << 8) | (0x80 << 23);
|
||||
s.f = (float)sqrt(s.f);
|
||||
m_FastSqrtTable[i]=(s.i&0x7FFFFF);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// this function returns the equivalent binary value for an individual character specified in the ascii format
|
||||
UCHAR CFastMath::BiToHe( char cBin )
|
||||
{
|
||||
if( (cBin >= '0') && (cBin <= '9') ) {
|
||||
return ( cBin - '0' );
|
||||
} else if( (cBin >= 'A') && (cBin <= 'F') ) {
|
||||
return ( cBin - 'A' + 0xA );
|
||||
} if( (cBin >= 'a') && (cBin <= 'f') ) {
|
||||
return ( cBin -'a' + 0xA );
|
||||
}
|
||||
return cBin;
|
||||
}
|
||||
|
||||
void CFastMath::AcToHe(char *szDst, char *szSrc, int iCount)
|
||||
{
|
||||
while( iCount-- ) {
|
||||
*szDst = BiToHe(*szSrc) << 4;
|
||||
*szSrc++;
|
||||
*szDst += BiToHe(*szSrc);
|
||||
*szSrc++;
|
||||
*szDst++;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><>ƾ<EFBFBD><C6BE><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>۵<EFBFBD><DBB5><EFBFBD><EFBFBD><EFBFBD> <20>ʽ<EFBFBD><CABD>ϴ<EFBFBD>(szDst<73><74> <20>ƹ<EFBFBD><C6B9>͵<EFBFBD> <20><><EFBFBD>簡 <20>ȵ<EFBFBD>).
|
||||
<EFBFBD>ٸ<EFBFBD> <20>е<EFBFBD><D0B5><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>? --<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (2002-08-17)
|
||||
|
||||
// while (iCount--) {
|
||||
// *szDst++ = (BiToHe(*szSrc++) << 4) + BiToHe(*szSrc++);
|
||||
// }
|
||||
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
char CFastMath::StrToHex08(char *szSrc)
|
||||
{
|
||||
char *pStart = szSrc + 2;
|
||||
char cHex = 0;
|
||||
|
||||
for (int i=0; i<1; i++) {
|
||||
char c1 = BiToHe(*pStart++);
|
||||
c1 <<= (8*(7-i)+4);
|
||||
char c2 = BiToHe(*pStart++);
|
||||
c2 <<= (8*(7-i));
|
||||
char cRet = c1 + c2;
|
||||
cHex += cRet;
|
||||
|
||||
}
|
||||
return cHex;
|
||||
|
||||
}
|
||||
|
||||
unsigned short CFastMath::StrToHex16(char *szSrc)
|
||||
{
|
||||
char *pStart = szSrc + 2;
|
||||
unsigned short sHex = 0;
|
||||
|
||||
|
||||
for (int i=0; i<2; i++) {
|
||||
|
||||
unsigned short s1 = BiToHe(*pStart++);
|
||||
s1 <<= (8*(1-i)+4);
|
||||
|
||||
unsigned short s2 = BiToHe(*pStart++);
|
||||
s2 <<= (8*(1-i));
|
||||
|
||||
unsigned short sRet = s1 + s2;
|
||||
|
||||
sHex += sRet;
|
||||
|
||||
}
|
||||
|
||||
return sHex;
|
||||
|
||||
}
|
||||
|
||||
// convert string to hexadecimal value
|
||||
DWORD CFastMath::StrToHex32(char *szSrc)
|
||||
{
|
||||
char *pStart = szSrc + 2;
|
||||
DWORD dwHex = 0;
|
||||
|
||||
|
||||
for (int i=0; i<4; i++) {
|
||||
DWORD dw1 = BiToHe(*pStart++);
|
||||
dw1 <<= (8*(3-i)+4);
|
||||
DWORD dw2 = BiToHe(*pStart++);
|
||||
dw2 <<= (8*(3-i));
|
||||
|
||||
DWORD dwRet = dw1 + dw2;
|
||||
|
||||
dwHex += dwRet;
|
||||
|
||||
}
|
||||
|
||||
return dwHex;
|
||||
|
||||
}
|
||||
|
||||
// convert string to hexadecimal value
|
||||
__int64 CFastMath::StrToHex64(char *szSrc)
|
||||
{
|
||||
char *pStart = szSrc + 2;
|
||||
__int64 dlHex = 0;
|
||||
|
||||
for (int i=0; i<8; i++) {
|
||||
__int64 dl1 = BiToHe(*pStart++);
|
||||
dl1 <<= (8*(7-i)+4);
|
||||
__int64 dl2 = BiToHe(*pStart++);
|
||||
dl2 <<= (8*(7-i));
|
||||
|
||||
__int64 dlRet = dl1 + dl2;
|
||||
|
||||
dlHex += dlRet;
|
||||
|
||||
}
|
||||
return dlHex;
|
||||
}
|
||||
|
||||
char CFastMath::Atoc( char *szSrc )
|
||||
{
|
||||
if( strncmp( szSrc, "0x", 2 ) == 0 ) {
|
||||
return StrToHex08( szSrc );
|
||||
} else {
|
||||
return (char) _ttol( szSrc );
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// TCHAR *<2A><> <20><>Ĩ<EFBFBD>ô<EFBFBD>! (By Standil)
|
||||
//
|
||||
unsigned short CFastMath::Atos( char *szSrc )
|
||||
{
|
||||
if( strncmp( szSrc, "0x", 2 ) == 0 ) {
|
||||
return StrToHex16( szSrc );
|
||||
} else {
|
||||
return _ttoi( szSrc );
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// TCHAR *<2A><> <20><>Ĩ<EFBFBD>ô<EFBFBD>! (By Standil)
|
||||
//
|
||||
unsigned int CFastMath::Atoi( char *szSrc )
|
||||
{
|
||||
if( strncmp( szSrc, "0x", 2 ) == 0 ) {
|
||||
return StrToHex32( szSrc );
|
||||
} else {
|
||||
return _ttol( szSrc );
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// TCHAR *<2A><> <20><>Ĩ<EFBFBD>ô<EFBFBD>! (By Standil)
|
||||
//
|
||||
_int64 CFastMath::Atol64( char *szSrc )
|
||||
{
|
||||
if( strncmp( szSrc, "0x", 2 ) == 0 ) {
|
||||
return StrToHex32( szSrc );
|
||||
} else {
|
||||
return _ttoi64( szSrc );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CFastMath::SRand( unsigned int seed )
|
||||
{
|
||||
m_HoldRand = (long) seed;
|
||||
}
|
||||
|
||||
int CFastMath::Rand( void )
|
||||
{
|
||||
return( ((m_HoldRand = m_HoldRand * 214013L + 2531011L) >> 16) & 0x7FFF );
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// utility functions
|
||||
// 0 -0x7FFFFFFF.
|
||||
DWORD CFastMath::ComplexRandom(int nExtent)
|
||||
{
|
||||
static unsigned long x = 1;
|
||||
static unsigned long c = 0;
|
||||
static unsigned long a = 2083801278UL;
|
||||
|
||||
#define addto(rh,rl,ah,al) (rl) = ((rl) + (al)) & 0xFFFFFFFFUL; \
|
||||
(rh) = ((rh) + (ah) + (((rl) < (al)) ? 1 : 0)) & 0xFFFFFFFFUL
|
||||
|
||||
unsigned long xl = (x & 0xFFFFUL);
|
||||
unsigned long xh = (x >> 16) & 0xFFFFUL;
|
||||
unsigned long al = (a & 0xFFFFUL);
|
||||
unsigned long ah = (a >> 16) & 0xFFFFUL;
|
||||
unsigned long tmp;
|
||||
|
||||
x = c;
|
||||
c = 0;
|
||||
tmp = xl * al;
|
||||
addto(c, x, 0, tmp);
|
||||
tmp = xl * ah;
|
||||
addto(c, x, (tmp >> 16), (tmp & 0xFFFFUL) << 16);
|
||||
tmp = xh * ah;
|
||||
addto(c, x, tmp, 1);
|
||||
tmp = xh * al;
|
||||
addto(c, x, (tmp >> 16), (tmp & 0xFFFFUL) << 16);
|
||||
if (nExtent < 1)
|
||||
return 1;
|
||||
return (x % nExtent); // return x & 0x7FFFFFFFUL;
|
||||
}
|
||||
|
||||
/*
|
||||
_rand From GNU Libc source
|
||||
|
||||
This algorithm is mentioned in the ISO C standard, here extended for 32 bits.
|
||||
|
||||
int rand_r (unsigned int *seed)
|
||||
{
|
||||
unsigned int next = *seed;
|
||||
int result;
|
||||
|
||||
next *= 1103515245;
|
||||
next += 12345;
|
||||
result = (unsigned int) (next / 65536) % 2048;
|
||||
|
||||
next *= 1103515245;
|
||||
next += 12345;
|
||||
result <<= 10;
|
||||
result ^= (unsigned int) (next / 65536) % 1024;
|
||||
|
||||
next *= 1103515245;
|
||||
next += 12345;
|
||||
result <<= 10;
|
||||
result ^= (unsigned int) (next / 65536) % 1024;
|
||||
|
||||
*seed = next;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static double SinTable[] = {
|
||||
0.000000, 0.017452, 0.034899, 0.052336, 0.069756,
|
||||
0.087156, 0.104528, 0.121869, 0.139173, 0.156434,
|
||||
0.173648, 0.190809, 0.207912, 0.224951, 0.241922,
|
||||
0.258819, 0.275637, 0.292372, 0.309017, 0.325568,
|
||||
0.342020, 0.358368, 0.374607, 0.390731, 0.406737,
|
||||
0.422618, 0.438371, 0.453990, 0.469472, 0.484810,
|
||||
0.500000, 0.515038, 0.529919, 0.544639, 0.559193,
|
||||
0.573576, 0.587785, 0.601815, 0.615661, 0.629320,
|
||||
0.642788, 0.656059, 0.669131, 0.681998, 0.694658,
|
||||
0.707107, 0.719340, 0.731354, 0.743145, 0.754710,
|
||||
0.766044, 0.777146, 0.788011, 0.798636, 0.809017,
|
||||
0.819152, 0.829038, 0.838671, 0.848048, 0.857167,
|
||||
0.866025, 0.874620, 0.882948, 0.891007, 0.898794,
|
||||
0.906308, 0.913545, 0.920505, 0.927184, 0.933580,
|
||||
0.939693, 0.945519, 0.951057, 0.956305, 0.961262,
|
||||
0.965926, 0.970296, 0.974370, 0.978148, 0.981627,
|
||||
0.984808, 0.987688, 0.990268, 0.992546, 0.994522,
|
||||
0.996195, 0.997564, 0.998630, 0.999391, 0.999848,
|
||||
1.000000, 0.999848, 0.999391, 0.998630, 0.997564,
|
||||
0.996195, 0.994522, 0.992546, 0.990268, 0.987688,
|
||||
0.984808, 0.981627, 0.978148, 0.974370, 0.970296,
|
||||
0.965926, 0.961262, 0.956305, 0.951057, 0.945519,
|
||||
0.939693, 0.933580, 0.927184, 0.920505, 0.913545,
|
||||
0.906308, 0.898794, 0.891007, 0.882948, 0.874620,
|
||||
0.866025, 0.857167, 0.848048, 0.838671, 0.829038,
|
||||
0.819152, 0.809017, 0.798636, 0.788011, 0.777146,
|
||||
0.766044, 0.754710, 0.743145, 0.731354, 0.719340,
|
||||
0.707107, 0.694658, 0.681998, 0.669131, 0.656059,
|
||||
0.642788, 0.629320, 0.615661, 0.601815, 0.587785,
|
||||
0.573576, 0.559193, 0.544639, 0.529919, 0.515038,
|
||||
0.500000, 0.484810, 0.469472, 0.453990, 0.438371,
|
||||
0.422618, 0.406737, 0.390731, 0.374607, 0.358368,
|
||||
0.342020, 0.325568, 0.309017, 0.292372, 0.275637,
|
||||
0.258819, 0.241922, 0.224951, 0.207912, 0.190809,
|
||||
0.173648, 0.156434, 0.139173, 0.121869, 0.104528,
|
||||
0.087156, 0.069756, 0.052336, 0.034899, 0.017452,
|
||||
0.000000, -0.017452, -0.034899, -0.052336, -0.069756,
|
||||
-0.087156, -0.104528, -0.121869, -0.139173, -0.156434,
|
||||
-0.173648, -0.190809, -0.207912, -0.224951, -0.241922,
|
||||
-0.258819, -0.275637, -0.292372, -0.309017, -0.325568,
|
||||
-0.342020, -0.358368, -0.374607, -0.390731, -0.406737,
|
||||
-0.422618, -0.438371, -0.453990, -0.469472, -0.484810,
|
||||
-0.500000, -0.515038, -0.529919, -0.544639, -0.559193,
|
||||
-0.573576, -0.587785, -0.601815, -0.615661, -0.629320,
|
||||
-0.642788, -0.656059, -0.669131, -0.681998, -0.694658,
|
||||
-0.707107, -0.719340, -0.731354, -0.743145, -0.754710,
|
||||
-0.766044, -0.777146, -0.788011, -0.798636, -0.809017,
|
||||
-0.819152, -0.829038, -0.838671, -0.848048, -0.857167,
|
||||
-0.866025, -0.874620, -0.882948, -0.891007, -0.898794,
|
||||
-0.906308, -0.913545, -0.920505, -0.927184, -0.933580,
|
||||
-0.939693, -0.945519, -0.951057, -0.956305, -0.961262,
|
||||
-0.965926, -0.970296, -0.974370, -0.978148, -0.981627,
|
||||
-0.984808, -0.987688, -0.990268, -0.992546, -0.994522,
|
||||
-0.996195, -0.997564, -0.998630, -0.999391, -0.999848,
|
||||
-1.000000, -0.999848, -0.999391, -0.998630, -0.997564,
|
||||
-0.996195, -0.994522, -0.992546, -0.990268, -0.987688,
|
||||
-0.984808, -0.981627, -0.978148, -0.974370, -0.970296,
|
||||
-0.965926, -0.961262, -0.956305, -0.951057, -0.945519,
|
||||
-0.939693, -0.933580, -0.927184, -0.920505, -0.913545,
|
||||
-0.906308, -0.898794, -0.891007, -0.882948, -0.874620,
|
||||
-0.866025, -0.857167, -0.848048, -0.838671, -0.829038,
|
||||
-0.819152, -0.809017, -0.798636, -0.788011, -0.777146,
|
||||
-0.766044, -0.754710, -0.743145, -0.731354, -0.719340,
|
||||
-0.707107, -0.694658, -0.681998, -0.669131, -0.656059,
|
||||
-0.642788, -0.629320, -0.615661, -0.601815, -0.587785,
|
||||
-0.573576, -0.559193, -0.544639, -0.529919, -0.515038,
|
||||
-0.500000, -0.484810, -0.469472, -0.453990, -0.438371,
|
||||
-0.422618, -0.406737, -0.390731, -0.374607, -0.358368,
|
||||
-0.342020, -0.325568, -0.309017, -0.292372, -0.275637,
|
||||
-0.258819, -0.241922, -0.224951, -0.207912, -0.190809,
|
||||
-0.173648, -0.156434, -0.139173, -0.121869, -0.104528,
|
||||
-0.087156, -0.069756, -0.052336, -0.034899, -0.017452
|
||||
};
|
||||
|
||||
static double CosTable[] = {
|
||||
1.000000, 0.999848, 0.999391, 0.998630, 0.997564,
|
||||
0.996195, 0.994522, 0.992546, 0.990268, 0.987688,
|
||||
0.984808, 0.981627, 0.978148, 0.974370, 0.970296,
|
||||
0.965926, 0.961262, 0.956305, 0.951057, 0.945519,
|
||||
0.939693, 0.933580, 0.927184, 0.920505, 0.913545,
|
||||
0.906308, 0.898794, 0.891007, 0.882948, 0.874620,
|
||||
0.866025, 0.857167, 0.848048, 0.838671, 0.829038,
|
||||
0.819152, 0.809017, 0.798636, 0.788011, 0.777146,
|
||||
0.766044, 0.754710, 0.743145, 0.731354, 0.719340,
|
||||
0.707107, 0.694658, 0.681998, 0.669131, 0.656059,
|
||||
0.642788, 0.629320, 0.615661, 0.601815, 0.587785,
|
||||
0.573576, 0.559193, 0.544639, 0.529919, 0.515038,
|
||||
0.500000, 0.484810, 0.469472, 0.453990, 0.438371,
|
||||
0.422618, 0.406737, 0.390731, 0.374607, 0.358368,
|
||||
0.342020, 0.325568, 0.309017, 0.292372, 0.275637,
|
||||
0.258819, 0.241922, 0.224951, 0.207912, 0.190809,
|
||||
0.173648, 0.156434, 0.139173, 0.121869, 0.104528,
|
||||
0.087156, 0.069756, 0.052336, 0.034899, 0.017452,
|
||||
0.000000, -0.017452, -0.034899, -0.052336, -0.069756,
|
||||
-0.087156, -0.104528, -0.121869, -0.139173, -0.156434,
|
||||
-0.173648, -0.190809, -0.207912, -0.224951, -0.241922,
|
||||
-0.258819, -0.275637, -0.292372, -0.309017, -0.325568,
|
||||
-0.342020, -0.358368, -0.374607, -0.390731, -0.406737,
|
||||
-0.422618, -0.438371, -0.453990, -0.469472, -0.484810,
|
||||
-0.500000, -0.515038, -0.529919, -0.544639, -0.559193,
|
||||
-0.573576, -0.587785, -0.601815, -0.615661, -0.629320,
|
||||
-0.642788, -0.656059, -0.669131, -0.681998, -0.694658,
|
||||
-0.707107, -0.719340, -0.731354, -0.743145, -0.754710,
|
||||
-0.766044, -0.777146, -0.788011, -0.798636, -0.809017,
|
||||
-0.819152, -0.829038, -0.838671, -0.848048, -0.857167,
|
||||
-0.866025, -0.874620, -0.882948, -0.891007, -0.898794,
|
||||
-0.906308, -0.913545, -0.920505, -0.927184, -0.933580,
|
||||
-0.939693, -0.945519, -0.951057, -0.956305, -0.961262,
|
||||
-0.965926, -0.970296, -0.974370, -0.978148, -0.981627,
|
||||
-0.984808, -0.987688, -0.990268, -0.992546, -0.994522,
|
||||
-0.996195, -0.997564, -0.998630, -0.999391, -0.999848,
|
||||
-1.000000, -0.999848, -0.999391, -0.998630, -0.997564,
|
||||
-0.996195, -0.994522, -0.992546, -0.990268, -0.987688,
|
||||
-0.984808, -0.981627, -0.978148, -0.974370, -0.970296,
|
||||
-0.965926, -0.961262, -0.956305, -0.951057, -0.945519,
|
||||
-0.939693, -0.933580, -0.927184, -0.920505, -0.913545,
|
||||
-0.906308, -0.898794, -0.891007, -0.882948, -0.874620,
|
||||
-0.866025, -0.857167, -0.848048, -0.838671, -0.829038,
|
||||
-0.819152, -0.809017, -0.798636, -0.788011, -0.777146,
|
||||
-0.766044, -0.754710, -0.743145, -0.731354, -0.719340,
|
||||
-0.707107, -0.694658, -0.681998, -0.669131, -0.656059,
|
||||
-0.642788, -0.629320, -0.615661, -0.601815, -0.587785,
|
||||
-0.573576, -0.559193, -0.544639, -0.529919, -0.515038,
|
||||
-0.500000, -0.484810, -0.469472, -0.453990, -0.438371,
|
||||
-0.422618, -0.406737, -0.390731, -0.374607, -0.358368,
|
||||
-0.342020, -0.325568, -0.309017, -0.292372, -0.275637,
|
||||
-0.258819, -0.241922, -0.224951, -0.207912, -0.190809,
|
||||
-0.173648, -0.156434, -0.139173, -0.121869, -0.104528,
|
||||
-0.087156, -0.069756, -0.052336, -0.034899, -0.017452,
|
||||
-0.000000, 0.017452, 0.034899, 0.052336, 0.069756,
|
||||
0.087156, 0.104528, 0.121869, 0.139173, 0.156434,
|
||||
0.173648, 0.190809, 0.207912, 0.224951, 0.241922,
|
||||
0.258819, 0.275637, 0.292372, 0.309017, 0.325568,
|
||||
0.342020, 0.358368, 0.374607, 0.390731, 0.406737,
|
||||
0.422618, 0.438371, 0.453990, 0.469472, 0.484810,
|
||||
0.500000, 0.515038, 0.529919, 0.544639, 0.559193,
|
||||
0.573576, 0.587785, 0.601815, 0.615661, 0.629320,
|
||||
0.642788, 0.656059, 0.669131, 0.681998, 0.694658,
|
||||
0.707107, 0.719340, 0.731354, 0.743145, 0.754710,
|
||||
0.766044, 0.777146, 0.788011, 0.798636, 0.809017,
|
||||
0.819152, 0.829038, 0.838671, 0.848048, 0.857167,
|
||||
0.866025, 0.874620, 0.882948, 0.891007, 0.898794,
|
||||
0.906308, 0.913545, 0.920505, 0.927184, 0.933580,
|
||||
0.939693, 0.945519, 0.951057, 0.956305, 0.961262,
|
||||
0.965926, 0.970296, 0.974370, 0.978148, 0.981627,
|
||||
0.984808, 0.987688, 0.990268, 0.992546, 0.994522,
|
||||
0.996195, 0.997564, 0.998630, 0.999391, 0.999848
|
||||
};
|
||||
|
||||
double as_sin( int degree )
|
||||
{
|
||||
while( degree < 0 ) degree += 360;
|
||||
degree = degree%360;
|
||||
|
||||
return SinTable[degree];
|
||||
}
|
||||
|
||||
double as_cos( int degree )
|
||||
{
|
||||
while( degree < 0 ) degree += 360;
|
||||
degree = degree%360;
|
||||
|
||||
return CosTable[degree];
|
||||
}
|
||||
|
||||
// -90 - 90
|
||||
int as_asin( double as )
|
||||
{
|
||||
double
|
||||
nearest_diff = 2.0;
|
||||
int
|
||||
nearest_index;
|
||||
|
||||
for( int i = -90; i <=90; i++ ){
|
||||
int
|
||||
index = i;
|
||||
if( index < 0 ) index += 360;
|
||||
|
||||
if( fabs(SinTable[index]-as) < nearest_diff ){
|
||||
nearest_diff = fabs(SinTable[index]-as);
|
||||
nearest_index = i;
|
||||
}
|
||||
}
|
||||
|
||||
return nearest_index;
|
||||
}
|
||||
|
||||
// 0 - 180
|
||||
int as_acos( double ac )
|
||||
{
|
||||
double
|
||||
nearest_diff = 2.0;
|
||||
int
|
||||
nearest_index;
|
||||
|
||||
for( int i = 0; i <= 180; i++ ){
|
||||
if( fabs(CosTable[i]-ac) < nearest_diff ){
|
||||
nearest_diff = fabs(CosTable[i]-ac);
|
||||
nearest_index = i;
|
||||
}
|
||||
}
|
||||
|
||||
return nearest_index;
|
||||
}
|
||||
|
||||
*/
|
||||
137
Engine/Zalla3D Base Class/FastMath.h
Normal file
137
Engine/Zalla3D Base Class/FastMath.h
Normal file
@@ -0,0 +1,137 @@
|
||||
// FastMath.h: interface for the CFastMath class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_FASTMATH_H__ED69578B_18C1_42EA_9C5E_888DC38101C2__INCLUDED_)
|
||||
#define AFX_FASTMATH_H__ED69578B_18C1_42EA_9C5E_888DC38101C2__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include <d3d8.h>
|
||||
#include "MathBase.h"
|
||||
#define FP_BITS(fp) (*(DWORD *)&(fp))
|
||||
|
||||
class CFastMath
|
||||
{
|
||||
typedef union FastSqrtUnion {
|
||||
float f;
|
||||
unsigned int i;
|
||||
} FastSqrtUnion;
|
||||
|
||||
static unsigned int m_FastSqrtTable[0x10000];
|
||||
static unsigned short m_FastHeToBi[0x100];
|
||||
static long m_HoldRand;
|
||||
|
||||
public:
|
||||
|
||||
// constructor and destructor
|
||||
CFastMath();
|
||||
virtual ~CFastMath();
|
||||
|
||||
static void Init();
|
||||
inline static float FastSqrt(float n) // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ϴ<EFBFBD> <20>Լ<EFBFBD>.
|
||||
{
|
||||
if (FP_BITS(n) == 0)
|
||||
return 0.0f; // check for square root of 0
|
||||
FP_BITS(n) = m_FastSqrtTable[(FP_BITS(n) >> 8) & 0xFFFF] | ((((FP_BITS(n) - 0x3F800000) >> 1) + 0x3F800000) & 0x7F800000);
|
||||
return n;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// converts ascii type of IPX address to hexadecimal format
|
||||
// returns the equivalent binary value for an individual character specified in the ascii format
|
||||
|
||||
static UCHAR BiToHe(char cBin); // SPX, IPX <20>ּ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> <20>Լ<EFBFBD>
|
||||
static void AcToHe(char *szDst, char *szSrc, int iCount); // SPX, IPX <20>ּ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> <20>Լ<EFBFBD>
|
||||
|
||||
static char StrToHex08(char *szSrc); // convert string to hexa
|
||||
static unsigned short StrToHex16(char *szSrc); // convert string to hexa
|
||||
static DWORD StrToHex32(char *szSrc); // convert string to hexa
|
||||
static _int64 StrToHex64(char *szSrc); // convert string to hexa
|
||||
|
||||
static inline void Hex08ToStr(char *szDest, BYTE hex); // convert hexa to string
|
||||
static inline void Hex16ToStr(char *szDest, WORD hex); // convert hexa to string
|
||||
static inline void Hex32ToStr(char *szDest, DWORD hex); // convert hexa to string
|
||||
static inline void Hex64ToStr(char *szDest, DWORD64 hex); // convert hexa to string
|
||||
|
||||
static char Atoc(char *szSrc); // ascii to U8
|
||||
static unsigned short Atos(char *szSrc); // ascii to U16
|
||||
static unsigned int Atoi(char *szSrc); // ascii to U32
|
||||
static _int64 Atol64(char *szSrc); // ascii to U64
|
||||
|
||||
static void SRand( unsigned int seed );
|
||||
static int Rand( void );
|
||||
|
||||
// <20><><EFBFBD>ϰ<EFBFBD><CFB0><EFBFBD> 0 ~ nExtent - 1<><31> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>´<EFBFBD>.
|
||||
static DWORD ComplexRandom(int nExtent);
|
||||
static DWORD AGLRandom(int nExtent) { return ComplexRandom(nExtent); };
|
||||
|
||||
};
|
||||
|
||||
inline void CFastMath::Hex08ToStr( char *szDest, BYTE hex )
|
||||
{
|
||||
*((WORD *) szDest) = m_FastHeToBi[ hex ]; szDest += 2;
|
||||
*(szDest) = '\0';
|
||||
}
|
||||
|
||||
inline void CFastMath::Hex16ToStr( char *szDest, WORD hex )
|
||||
{
|
||||
LPBYTE pSrc = (LPBYTE) &hex;
|
||||
|
||||
#ifdef BIG_ENDIAN
|
||||
*((WORD *) (szDest + 0)) = m_FastHeToBi[ *(pSrc++) ];
|
||||
*((WORD *) (szDest + 2)) = m_FastHeToBi[ *(pSrc++) ];
|
||||
#else
|
||||
*((WORD *) (szDest + 2)) = m_FastHeToBi[ *(pSrc++) ];
|
||||
*((WORD *) (szDest + 0)) = m_FastHeToBi[ *(pSrc++) ];
|
||||
#endif
|
||||
*(szDest + 4) = '\0';
|
||||
}
|
||||
|
||||
inline void CFastMath::Hex32ToStr( char *szDest, DWORD hex )
|
||||
{
|
||||
LPBYTE pSrc = (LPBYTE) &hex;
|
||||
|
||||
#ifdef BIG_ENDIAN
|
||||
*((WORD *) (szDest + 0)) = m_FastHeToBi[ *(pSrc++) ];
|
||||
*((WORD *) (szDest + 2)) = m_FastHeToBi[ *(pSrc++) ];
|
||||
*((WORD *) (szDest + 4)) = m_FastHeToBi[ *(pSrc++) ];
|
||||
*((WORD *) (szDest + 6)) = m_FastHeToBi[ *(pSrc++) ];
|
||||
#else
|
||||
*((WORD *) (szDest + 6)) = m_FastHeToBi[ *(pSrc++) ];
|
||||
*((WORD *) (szDest + 4)) = m_FastHeToBi[ *(pSrc++) ];
|
||||
*((WORD *) (szDest + 2)) = m_FastHeToBi[ *(pSrc++) ];
|
||||
*((WORD *) (szDest + 0)) = m_FastHeToBi[ *(pSrc++) ];
|
||||
#endif
|
||||
*(szDest + 8) = '\0';
|
||||
}
|
||||
|
||||
inline void CFastMath::Hex64ToStr( char *szDest, DWORD64 hex )
|
||||
{
|
||||
LPBYTE pSrc = (LPBYTE) &hex;
|
||||
|
||||
#ifdef BIG_ENDIAN
|
||||
*((WORD *) (szDest + 0)) = m_FastHeToBi[ *(pSrc++) ];
|
||||
*((WORD *) (szDest + 2)) = m_FastHeToBi[ *(pSrc++) ];
|
||||
*((WORD *) (szDest + 4)) = m_FastHeToBi[ *(pSrc++) ];
|
||||
*((WORD *) (szDest + 6)) = m_FastHeToBi[ *(pSrc++) ];
|
||||
*((WORD *) (szDest + 8)) = m_FastHeToBi[ *(pSrc++) ];
|
||||
*((WORD *) (szDest + 10)) = m_FastHeToBi[ *(pSrc++) ];
|
||||
*((WORD *) (szDest + 12)) = m_FastHeToBi[ *(pSrc++) ];
|
||||
*((WORD *) (szDest + 14)) = m_FastHeToBi[ *(pSrc++) ];
|
||||
#else
|
||||
*((WORD *) (szDest + 14)) = m_FastHeToBi[ *(pSrc++) ];
|
||||
*((WORD *) (szDest + 12)) = m_FastHeToBi[ *(pSrc++) ];
|
||||
*((WORD *) (szDest + 10)) = m_FastHeToBi[ *(pSrc++) ];
|
||||
*((WORD *) (szDest + 8)) = m_FastHeToBi[ *(pSrc++) ];
|
||||
*((WORD *) (szDest + 6)) = m_FastHeToBi[ *(pSrc++) ];
|
||||
*((WORD *) (szDest + 4)) = m_FastHeToBi[ *(pSrc++) ];
|
||||
*((WORD *) (szDest + 2)) = m_FastHeToBi[ *(pSrc++) ];
|
||||
*((WORD *) (szDest + 0)) = m_FastHeToBi[ *(pSrc++) ];
|
||||
#endif
|
||||
*(szDest + 16) = '\0';
|
||||
}
|
||||
|
||||
#endif // !defined(AFX_FASTMATH_H__ED69578B_18C1_42EA_9C5E_888DC38101C2__INCLUDED_)
|
||||
70
Engine/Zalla3D Base Class/FileLoad.cpp
Normal file
70
Engine/Zalla3D Base Class/FileLoad.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
// FileLoad.cpp: implementation of the CFileLoad class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "FileLoad.h"
|
||||
#include <windows.h>
|
||||
#include "GMMemory.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CFileLoad::CFileLoad()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CFileLoad::~CFileLoad()
|
||||
{
|
||||
if ( m_Data )
|
||||
{
|
||||
delete[] m_Data;
|
||||
m_Data = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void CFileLoad::Load(char *strFilename)
|
||||
{
|
||||
strcpy(m_strFilename,strFilename);
|
||||
|
||||
m_Data=0;
|
||||
m_Len=0;
|
||||
|
||||
FILE *fp=fopen(strFilename,"rb");
|
||||
|
||||
if(fp)
|
||||
{
|
||||
fseek(fp,0L,SEEK_END);
|
||||
m_Len=ftell(fp);
|
||||
if(m_Len)
|
||||
{
|
||||
fseek(fp,0L,SEEK_SET);
|
||||
m_Data=(void*)new unsigned char[m_Len];
|
||||
if(m_Data)
|
||||
{
|
||||
int r=fread(m_Data,m_Len,1,fp);
|
||||
if(!r)
|
||||
{
|
||||
if(m_Data) {
|
||||
delete[] m_Data;
|
||||
m_Data=NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox(NULL,strFilename,0,0);
|
||||
}
|
||||
m_ReadLoc=(char*)m_Data;
|
||||
m_ReadLen=m_Len;
|
||||
}
|
||||
|
||||
void CFileLoad::GetData(void *pData, size_t size)
|
||||
{
|
||||
memcpy(pData,m_ReadLoc,size);
|
||||
m_ReadLoc+=size;
|
||||
}
|
||||
34
Engine/Zalla3D Base Class/FileLoad.h
Normal file
34
Engine/Zalla3D Base Class/FileLoad.h
Normal file
@@ -0,0 +1,34 @@
|
||||
// FileLoad.h: interface for the CFileLoad class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_FILELOAD_H__95D97159_9B6D_4BBC_BD14_1DB1825501BF__INCLUDED_)
|
||||
#define AFX_FILELOAD_H__95D97159_9B6D_4BBC_BD14_1DB1825501BF__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
|
||||
#define MAX_NAMEBUFFER 256
|
||||
|
||||
class CFileLoad
|
||||
{
|
||||
public:
|
||||
void GetData(void* pData,size_t size);
|
||||
void Load(char *strFilename);
|
||||
|
||||
char m_strFilename[MAX_NAMEBUFFER];
|
||||
void *m_Data;
|
||||
int m_Len;
|
||||
char *m_ReadLoc;
|
||||
int m_ReadLen;
|
||||
|
||||
CFileLoad();
|
||||
virtual ~CFileLoad();
|
||||
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_FILELOAD_H__95D97159_9B6D_4BBC_BD14_1DB1825501BF__INCLUDED_)
|
||||
73
Engine/Zalla3D Base Class/FrameTimer.cpp
Normal file
73
Engine/Zalla3D Base Class/FrameTimer.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
// FrameTimer.cpp: implementation of the CFrameTimer class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "FrameTimer.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
std::vector<float> CFrameTimer::m_fUpdateTimeList;
|
||||
std::vector<float> CFrameTimer::m_fTimeRemainList;
|
||||
std::vector<float> CFrameTimer::m_fPerSecondUpdateList;
|
||||
DWORD CFrameTimer::m_dwTickTime;
|
||||
DWORD CFrameTimer::m_dwLastUpdateTime;
|
||||
|
||||
|
||||
CFrameTimer g_FrameTimer;
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CFrameTimer::CFrameTimer()
|
||||
{
|
||||
m_dwTickTime = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
CFrameTimer::~CFrameTimer()
|
||||
{
|
||||
m_fUpdateTimeList.clear();
|
||||
m_fTimeRemainList.clear();
|
||||
m_fPerSecondUpdateList.clear();
|
||||
}
|
||||
|
||||
void CFrameTimer::Create()
|
||||
{
|
||||
m_dwTickTime = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
void CFrameTimer::UpdateTime()
|
||||
{
|
||||
if(m_dwTickTime == 0xFFFFFFFF)
|
||||
{
|
||||
m_dwTickTime=GetTickCount();
|
||||
m_dwLastUpdateTime=m_dwTickTime;
|
||||
}
|
||||
DWORD dwOldTickTime=m_dwTickTime;
|
||||
m_dwTickTime=GetTickCount();
|
||||
|
||||
DWORD dwIntervalPreTime=m_dwTickTime-dwOldTickTime;
|
||||
|
||||
for(int i=0;i<(int)m_fUpdateTimeList.size();i++)
|
||||
{
|
||||
m_fUpdateTimeList[i]=(float)dwIntervalPreTime/(1000.0f/m_fPerSecondUpdateList[i]);
|
||||
m_fUpdateTimeList[i]+=m_fTimeRemainList[i];
|
||||
m_fTimeRemainList[i]=m_fUpdateTimeList[i]-(int)m_fUpdateTimeList[i];
|
||||
}
|
||||
}
|
||||
|
||||
int CFrameTimer::Regist(float fPerSecondUpdate)
|
||||
{
|
||||
m_fUpdateTimeList.push_back(0.0f);
|
||||
m_fTimeRemainList.push_back(0.0f);
|
||||
m_fPerSecondUpdateList.push_back(fPerSecondUpdate);
|
||||
return (int)m_fUpdateTimeList.size()-1;
|
||||
}
|
||||
|
||||
float CFrameTimer::GetUpdateTimer(int nTimer)
|
||||
{
|
||||
return m_fUpdateTimeList[nTimer];
|
||||
}
|
||||
|
||||
void CFrameTimer::ResetTimer(int nTimer)
|
||||
{
|
||||
m_fUpdateTimeList[nTimer] = 0;
|
||||
}
|
||||
32
Engine/Zalla3D Base Class/FrameTimer.h
Normal file
32
Engine/Zalla3D Base Class/FrameTimer.h
Normal file
@@ -0,0 +1,32 @@
|
||||
// FrameTimer.h: interface for the CFrameTimer class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_FRAMETIMER_H__6C017430_DEBB_4372_B200_70D57C02B061__INCLUDED_)
|
||||
#define AFX_FRAMETIMER_H__6C017430_DEBB_4372_B200_70D57C02B061__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
#include <d3d8.h>
|
||||
#include <vector>
|
||||
|
||||
class CFrameTimer
|
||||
{
|
||||
public:
|
||||
static float GetUpdateTimer(int nTimer);
|
||||
static void ResetTimer(int nTimer);
|
||||
static int Regist(float fPerSecondUpdate);
|
||||
static void UpdateTime();
|
||||
|
||||
static std::vector<float> m_fUpdateTimeList;
|
||||
static std::vector<float> m_fTimeRemainList;
|
||||
static std::vector<float> m_fPerSecondUpdateList;
|
||||
static DWORD m_dwTickTime;
|
||||
static DWORD m_dwLastUpdateTime;
|
||||
static void Create();
|
||||
CFrameTimer();
|
||||
virtual ~CFrameTimer();
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_FRAMETIMER_H__6C017430_DEBB_4372_B200_70D57C02B061__INCLUDED_)
|
||||
764
Engine/Zalla3D Base Class/GlareTexture.cpp
Normal file
764
Engine/Zalla3D Base Class/GlareTexture.cpp
Normal file
@@ -0,0 +1,764 @@
|
||||
// GlareTexture.cpp: implementation of the CGlareTexture class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "GlareTexture.h"
|
||||
#include "BaseGraphicsLayer.h"
|
||||
|
||||
#define CV_WORLDVIEWPROJ_0 0
|
||||
#define CV_WORLDVIEWPROJ_1 1
|
||||
#define CV_WORLDVIEWPROJ_2 2
|
||||
#define CV_WORLDVIEWPROJ_3 3
|
||||
|
||||
#define CV_UV_OFFSET_TO_USE 4
|
||||
|
||||
#define CV_T0_BASE 8
|
||||
#define CV_T1_BASE 13
|
||||
#define CV_T2_BASE 18
|
||||
#define CV_T3_BASE 23
|
||||
|
||||
#define CV_UV_T0_NO_OFFSET 8
|
||||
#define CV_UV_T0_TYPE1 9
|
||||
#define CV_UV_T0_TYPE2 10
|
||||
#define CV_UV_T0_TYPE3 11
|
||||
#define CV_UV_T0_TYPE4 12
|
||||
|
||||
#define CV_UV_T1_NO_OFFSET 13
|
||||
#define CV_UV_T1_TYPE1 14
|
||||
#define CV_UV_T1_TYPE2 15
|
||||
#define CV_UV_T1_TYPE3 16
|
||||
#define CV_UV_T1_TYPE4 17
|
||||
|
||||
#define CV_UV_T2_NO_OFFSET 18
|
||||
#define CV_UV_T2_TYPE1 19
|
||||
#define CV_UV_T2_TYPE2 20
|
||||
#define CV_UV_T2_TYPE3 21
|
||||
#define CV_UV_T2_TYPE4 22
|
||||
|
||||
#define CV_UV_T3_NO_OFFSET 23
|
||||
#define CV_UV_T3_TYPE1 24
|
||||
#define CV_UV_T3_TYPE2 25
|
||||
#define CV_UV_T3_TYPE3 26
|
||||
#define CV_UV_T3_TYPE4 27
|
||||
|
||||
|
||||
|
||||
|
||||
char strBlurVertexShader[]=
|
||||
"vs.1.1\n"
|
||||
"dp4 oPos.x, v0, c[0]\n"
|
||||
"dp4 oPos.y, v0, c[1]\n"
|
||||
"dp4 oPos.z, v0, c[2]\n"
|
||||
"dp4 oPos.w, v0, c[3]\n"
|
||||
|
||||
"mov a0.x, c[4]\n"
|
||||
|
||||
"add oT0, v1, c[a0.x + 8]\n"
|
||||
"add oT1, v1, c[a0.x + 13]\n"
|
||||
"add oT2, v1, c[a0.x + 18]\n"
|
||||
"add oT3, v1, c[a0.x + 23]\n";
|
||||
|
||||
char strBlurPixelShader[]=
|
||||
"ps.1.1\n"
|
||||
//"def c0, 0.0f, 0.0f, 1.0f, 0.0f\n"
|
||||
//"def c0, 0.25f, 0.25f, 0.25f, 0.25f\n"
|
||||
"tex t0\n"
|
||||
"tex t1\n"
|
||||
"tex t2\n"
|
||||
"tex t3\n"
|
||||
//"mov r0,c0\n";
|
||||
"mul r0, c0, t0\n"
|
||||
"mad r0, c0, t1, r0\n"
|
||||
"mad r0, c0, t2, r0\n"
|
||||
"mad r0, c0, t3, r0\n";
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
LPDIRECT3DSURFACE8 CGlareTexture::m_pRenderZBuffer=NULL;
|
||||
|
||||
CGlareTexture::CGlareTexture()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CGlareTexture::~CGlareTexture()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CGlareTexture::GenerateGlareTexture(LPDIRECT3DDEVICE8 pd3dDevice, LPDIRECT3DBASETEXTURE8 pTexture,vector3 vecNeighbor,int nDepth)
|
||||
{
|
||||
LPDIRECT3DSURFACE8 m_pTempRenderSurface;
|
||||
LPDIRECT3DSURFACE8 m_pTempRenderZBuffer;
|
||||
|
||||
pd3dDevice->GetRenderTarget(&m_pTempRenderSurface);
|
||||
pd3dDevice->GetDepthStencilSurface(&m_pTempRenderZBuffer);
|
||||
|
||||
long QUADVERTEX2FVF=D3DFVF_XYZRHW | D3DFVF_TEX4;
|
||||
|
||||
|
||||
/*
|
||||
CreateAndWriteUVOffsets(m_nSize,m_nSize);
|
||||
|
||||
matrix matOldWorld,matOldProjection,matOldView;
|
||||
|
||||
pd3dDevice->GetTransform(D3DTS_WORLD,matOldWorld);
|
||||
pd3dDevice->GetTransform(D3DTS_PROJECTION,matOldProjection);
|
||||
pd3dDevice->GetTransform(D3DTS_VIEW,matOldView);
|
||||
*/
|
||||
|
||||
//pd3dDevice->EndScene();
|
||||
////////////////////
|
||||
|
||||
/*
|
||||
D3DXMATRIX matWorld;
|
||||
D3DXMATRIX matView;
|
||||
D3DXMATRIX matProj;
|
||||
D3DXMATRIX matViewProj;
|
||||
D3DXMATRIX matWorldViewProj;
|
||||
D3DXVECTOR4 offset(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
offset.x = 2.0f;
|
||||
pd3dDevice->SetVertexShaderConstant(CV_UV_OFFSET_TO_USE, &offset, 1);
|
||||
pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
|
||||
|
||||
pd3dDevice->SetVertexShader(m_BlurVertexShader);
|
||||
pd3dDevice->SetStreamSource(0,m_pVertexBuffer,sizeof(QuadVertex));
|
||||
|
||||
D3DXVECTOR3 const vEyePt = D3DXVECTOR3( 0.0f, 0.0f, -5.0f );
|
||||
D3DXVECTOR3 const vLookatPt = D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
|
||||
D3DXVECTOR3 const vUp = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
|
||||
|
||||
D3DXMatrixLookAtLH(&matView, &vEyePt, &vLookatPt, &vUp);
|
||||
D3DXMatrixOrthoLH(&matProj, 4.0f, 4.0f, 0.2f, 20.0f);
|
||||
|
||||
D3DXMatrixMultiply(&matViewProj, &matView, &matProj);
|
||||
|
||||
D3DXMatrixScaling(&matWorld, 2.0f, 2.0f, 1.0f);
|
||||
D3DXMatrixMultiply(&matWorldViewProj, &matWorld, &matViewProj);
|
||||
D3DXMatrixTranspose(&matWorldViewProj, &matWorldViewProj);
|
||||
pd3dDevice->SetVertexShaderConstant(CV_WORLDVIEWPROJ_0, &matWorldViewProj(0, 0), 4);
|
||||
*/
|
||||
|
||||
pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE,FALSE);
|
||||
|
||||
pd3dDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
|
||||
|
||||
pd3dDevice->SetRenderState( D3DRS_LIGHTING,FALSE);
|
||||
pd3dDevice->SetRenderState( D3DRS_FOGENABLE,FALSE);
|
||||
|
||||
pd3dDevice->SetRenderState(D3DRS_ZWRITEENABLE,FALSE);
|
||||
|
||||
pd3dDevice->SetPixelShader(m_BlurPixelShader);
|
||||
pd3dDevice->SetVertexShader(QUADVERTEX2FVF);
|
||||
|
||||
QuadVertex2 pVertex[4];
|
||||
|
||||
pVertex[0].v.x=0.0f;
|
||||
pVertex[1].v.x=0.0f;
|
||||
pVertex[2].v.x=(float)m_nSize;
|
||||
pVertex[3].v.x=(float)m_nSize;
|
||||
|
||||
pVertex[1].v.y=0.0f;
|
||||
pVertex[3].v.y=0.0f;
|
||||
pVertex[0].v.y=(float)m_nSize;
|
||||
pVertex[2].v.y=(float)m_nSize;
|
||||
|
||||
pVertex[0].tu0=0.0f;
|
||||
pVertex[1].tu0=0.0f;
|
||||
pVertex[0].tu1=0.0f;
|
||||
pVertex[1].tu1=0.0f;
|
||||
pVertex[0].tu2=0.0f;
|
||||
pVertex[1].tu2=0.0f;
|
||||
pVertex[0].tu3=0.0f;
|
||||
pVertex[1].tu3=0.0f;
|
||||
|
||||
float fXPerPixel=(1.0f/m_nSize)*0.5f*(800.0f/1024.0f);
|
||||
float fYPerPixel=(1.0f/m_nSize)*0.5f*(600.0f/1024.0f);
|
||||
|
||||
pVertex[3].tu0=800.0f/1024.0f;//-fXPerPixel;
|
||||
pVertex[2].tu0=800.0f/1024.0f;//-fXPerPixel;
|
||||
|
||||
pVertex[3].tu1=800.0f/1024.0f+fXPerPixel*2.0f;
|
||||
pVertex[2].tu1=800.0f/1024.0f+fXPerPixel*2.0f;
|
||||
|
||||
pVertex[3].tu2=800.0f/1024.0f;//-fXPerPixel;
|
||||
pVertex[2].tu2=800.0f/1024.0f;//-fXPerPixel;
|
||||
|
||||
pVertex[3].tu3=800.0f/1024.0f+fXPerPixel*2.0f;
|
||||
pVertex[2].tu3=800.0f/1024.0f+fXPerPixel*2.0f;
|
||||
|
||||
pVertex[1].tv0=0.0f;
|
||||
pVertex[3].tv0=0.0f;
|
||||
pVertex[1].tv1=0.0f;
|
||||
pVertex[3].tv1=0.0f;
|
||||
pVertex[1].tv2=0.0f;
|
||||
pVertex[3].tv2=0.0f;
|
||||
pVertex[1].tv3=0.0f;
|
||||
pVertex[3].tv3=0.0f;
|
||||
|
||||
pVertex[0].tv0=600.0f/1024.0f;//-fYPerPixel;
|
||||
pVertex[2].tv0=600.0f/1024.0f;//-fYPerPixel;
|
||||
pVertex[0].tv1=600.0f/1024.0f;//-fYPerPixel;
|
||||
pVertex[2].tv1=600.0f/1024.0f;//-fYPerPixel;
|
||||
|
||||
pVertex[0].tv2=600.0f/1024.0f+fYPerPixel*2.0f;
|
||||
pVertex[2].tv2=600.0f/1024.0f+fYPerPixel*2.0f;
|
||||
pVertex[0].tv3=600.0f/1024.0f+fYPerPixel*2.0f;
|
||||
pVertex[2].tv3=600.0f/1024.0f+fYPerPixel*2.0f;
|
||||
|
||||
|
||||
for(int i=0;i<4;i++)
|
||||
{
|
||||
pVertex[i].w=0.1f;
|
||||
pVertex[i].v.z=0.1f;
|
||||
}
|
||||
|
||||
float fConst[4];
|
||||
fConst[0]=vecNeighbor.x;
|
||||
fConst[1]=vecNeighbor.y;
|
||||
fConst[2]=vecNeighbor.z;
|
||||
fConst[3]=1.0f;
|
||||
|
||||
pd3dDevice->SetPixelShaderConstant(0,fConst, 1);
|
||||
|
||||
pd3dDevice->SetRenderState(D3DRS_CULLMODE,D3DCULL_NONE);
|
||||
|
||||
for(i=0;i<nDepth;i++)
|
||||
{
|
||||
pd3dDevice->SetRenderTarget(m_pRenderSurface[i%2],m_pRenderZBuffer);
|
||||
//pd3dDevice->SetRenderTarget(m_pRenderSurface[i%2],NULL);
|
||||
|
||||
D3DVIEWPORT8 viewData = { 0, 0, m_nSize, m_nSize, 0.0f, 1.0f };
|
||||
pd3dDevice->SetViewport(&viewData);
|
||||
//pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB( 0xFF, 0x0, 0x0 ), 1.0, 0);
|
||||
//pd3dDevice->BeginScene();
|
||||
|
||||
if(i>0)
|
||||
{
|
||||
fXPerPixel=(1.0f/m_nSize)*0.5f;
|
||||
fYPerPixel=(1.0f/m_nSize)*0.5f;
|
||||
|
||||
pVertex[3].tu0=1.0f+fXPerPixel;
|
||||
pVertex[2].tu0=1.0f+fXPerPixel;
|
||||
|
||||
pVertex[3].tu1=1.0f+fXPerPixel*2.0f;
|
||||
pVertex[2].tu1=1.0f+fXPerPixel*2.0f;
|
||||
|
||||
pVertex[3].tu2=1.0f+fXPerPixel;
|
||||
pVertex[2].tu2=1.0f+fXPerPixel;
|
||||
|
||||
pVertex[3].tu3=1.0f+fXPerPixel*2.0f;
|
||||
pVertex[2].tu3=1.0f+fXPerPixel*2.0f;
|
||||
|
||||
pVertex[0].tv0=1.0f+fYPerPixel;
|
||||
pVertex[2].tv0=1.0f+fYPerPixel;
|
||||
pVertex[0].tv1=1.0f+fYPerPixel;
|
||||
pVertex[2].tv1=1.0f+fYPerPixel;
|
||||
|
||||
pVertex[0].tv2=1.0f+fYPerPixel*2.0f;
|
||||
pVertex[2].tv2=1.0f+fYPerPixel*2.0f;
|
||||
pVertex[0].tv3=1.0f+fYPerPixel*2.0f;
|
||||
pVertex[2].tv3=1.0f+fYPerPixel*2.0f;
|
||||
|
||||
}
|
||||
if(i==0)
|
||||
{
|
||||
pd3dDevice->SetTexture(0,pTexture);
|
||||
pd3dDevice->SetTexture(1,pTexture);
|
||||
pd3dDevice->SetTexture(2,pTexture);
|
||||
pd3dDevice->SetTexture(3,pTexture);
|
||||
}
|
||||
else
|
||||
{
|
||||
pd3dDevice->SetTexture(0,m_pRenderTexture[(i-1)%2]);
|
||||
pd3dDevice->SetTexture(1,m_pRenderTexture[(i-1)%2]);
|
||||
pd3dDevice->SetTexture(2,m_pRenderTexture[(i-1)%2]);
|
||||
pd3dDevice->SetTexture(3,m_pRenderTexture[(i-1)%2]);
|
||||
}
|
||||
//pd3dDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, 0, 2);
|
||||
pd3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,pVertex,sizeof(QuadVertex2));
|
||||
//pd3dDevice->EndScene();
|
||||
m_nFinalRenderTexture=i%2;
|
||||
}
|
||||
|
||||
pd3dDevice->SetRenderState(D3DRS_CULLMODE,D3DCULL_CCW);
|
||||
|
||||
//pd3dDevice->BeginScene();
|
||||
pd3dDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
|
||||
pd3dDevice->SetRenderState(D3DRS_ZWRITEENABLE,TRUE);
|
||||
/*
|
||||
pd3dDevice->SetTransform(D3DTS_WORLD,matOldWorld);
|
||||
pd3dDevice->SetTransform(D3DTS_PROJECTION,matOldProjection);
|
||||
pd3dDevice->SetTransform(D3DTS_VIEW,matOldView);
|
||||
*/
|
||||
|
||||
pd3dDevice->SetRenderTarget(m_pTempRenderSurface,m_pTempRenderZBuffer);
|
||||
|
||||
pd3dDevice->SetPixelShader(NULL);
|
||||
}
|
||||
|
||||
void CGlareTexture::Create(int nSize)
|
||||
{
|
||||
m_nSize=nSize;
|
||||
D3DDISPLAYMODE mode;
|
||||
BaseGraphicsLayer::GetDevice()->GetDisplayMode(&mode);
|
||||
BaseGraphicsLayer::GetDevice()->CreateTexture(nSize,nSize,1,D3DUSAGE_RENDERTARGET,BaseGraphicsLayer::m_d3dpp.BackBufferFormat,D3DPOOL_DEFAULT,&m_pRenderTexture[0]);
|
||||
m_pRenderTexture[0]->GetSurfaceLevel(0, &m_pRenderSurface[0]);
|
||||
|
||||
BaseGraphicsLayer::GetDevice()->CreateTexture(nSize,nSize,1,D3DUSAGE_RENDERTARGET,BaseGraphicsLayer::m_d3dpp.BackBufferFormat,D3DPOOL_DEFAULT,&m_pRenderTexture[1]);
|
||||
m_pRenderTexture[1]->GetSurfaceLevel(0, &m_pRenderSurface[1]);
|
||||
|
||||
if(m_pRenderZBuffer==NULL)
|
||||
BaseGraphicsLayer::GetDevice()->CreateDepthStencilSurface(nSize,nSize,BaseGraphicsLayer::m_d3dpp.AutoDepthStencilFormat,D3DMULTISAMPLE_NONE,&m_pRenderZBuffer);
|
||||
|
||||
|
||||
LPD3DXBUFFER pCode;
|
||||
D3DXAssembleShader(strBlurPixelShader,strlen(strBlurPixelShader),0,NULL,&pCode,NULL);
|
||||
BaseGraphicsLayer::GetDevice()->CreatePixelShader((DWORD*)pCode->GetBufferPointer(),&m_BlurPixelShader);
|
||||
pCode->Release();
|
||||
|
||||
DWORD Declaration[] =
|
||||
{
|
||||
D3DVSD_STREAM( 0 ),
|
||||
D3DVSD_REG(0,D3DVSDT_FLOAT3), // Position
|
||||
D3DVSD_REG(1,D3DVSDT_FLOAT2), // Texture Coordinate
|
||||
D3DVSD_END()
|
||||
};
|
||||
|
||||
|
||||
D3DXAssembleShader(strBlurVertexShader,strlen(strBlurVertexShader),0,NULL,&pCode,NULL);
|
||||
|
||||
BaseGraphicsLayer::GetDevice()->CreateVertexShader( Declaration,
|
||||
(DWORD*)pCode->GetBufferPointer(),
|
||||
&m_BlurVertexShader, 0 );
|
||||
|
||||
pCode->Release();
|
||||
|
||||
|
||||
BaseGraphicsLayer::GetDevice()->CreateVertexBuffer( 4 * sizeof(QuadVertex), D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC, 0, D3DPOOL_DEFAULT, &m_pVertexBuffer);
|
||||
|
||||
QuadVertex *pBuff;
|
||||
if(m_pVertexBuffer)
|
||||
{
|
||||
m_pVertexBuffer->Lock(0, 4 * sizeof(QuadVertex),(BYTE**)&pBuff, 0);
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
pBuff->Position = D3DXVECTOR3((i==0 || i==3) ? -1.0f : 1.0f,
|
||||
(i<2) ? -1.0f : 1.0f,
|
||||
0.0f);
|
||||
|
||||
pBuff->Tex = D3DXVECTOR2((i==0 || i==3) ? 0.0f : 1.0f,
|
||||
(i<2) ? 1.0f : 0.0f);
|
||||
/*
|
||||
|
||||
pBuff->Tex = D3DXVECTOR2((i==0 || i==3) ? 0.0f : 1024.0f,
|
||||
(i<2) ? 1024.0f : 0.0f);
|
||||
*/
|
||||
|
||||
pBuff++;
|
||||
}
|
||||
m_pVertexBuffer->Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
void CGlareTexture::CreateAndWriteUVOffsets(int width, int height)
|
||||
{
|
||||
float const noOffsetX[4] = { 0.0f, 0.0f, 0.0f, 0.0f};
|
||||
float const noOffsetY[4] = { 0.0f, 0.0f, 0.0f, 0.0f};
|
||||
|
||||
float const kPerTexelWidth = 1.0f/static_cast<float>(width);
|
||||
float const kPerTexelHeight = 1.0f/static_cast<float>(height);
|
||||
float s = 0.5f;
|
||||
float const eps = 10.0e-4f;
|
||||
float const rotAngle1 = D3DXToRadian( 0.0f );
|
||||
float const rotAngle2 = rotAngle1 + D3DXToRadian(120.0f);
|
||||
float const rotAngle3 = rotAngle1 + D3DXToRadian(240.0f);
|
||||
|
||||
// Change filter kernel for 9-sample box filtering, but for edge-detection we are
|
||||
// going to use interpolated texels. Why? Because we detect diagonal edges only
|
||||
// and the vertical and horizontal filtering seems to help.
|
||||
|
||||
float const type1OffsetX[4] = { -s * kPerTexelWidth,
|
||||
-s * kPerTexelWidth,
|
||||
s * kPerTexelWidth,
|
||||
s * kPerTexelWidth };
|
||||
float const type1OffsetY[4] = { -s * kPerTexelHeight,
|
||||
s * kPerTexelHeight,
|
||||
s * kPerTexelHeight,
|
||||
-s * kPerTexelHeight };
|
||||
|
||||
// we have to bring the 16 texel-sample-filter a bit closer to the center to avoid
|
||||
// separation due to floating point inaccuracies.
|
||||
float const type2OffsetX[4] = { -.5f * kPerTexelWidth + eps,
|
||||
-.5f * kPerTexelWidth + eps,
|
||||
1.5f * kPerTexelWidth - eps,
|
||||
1.5f * kPerTexelWidth - eps };
|
||||
float const type2OffsetY[4] = { -.5f * kPerTexelHeight+ eps,
|
||||
1.5f * kPerTexelHeight- eps,
|
||||
1.5f * kPerTexelHeight- eps,
|
||||
-.5f * kPerTexelHeight+ eps };
|
||||
|
||||
float const type3OffsetX[4] = {0.0f, sinf(rotAngle1)*kPerTexelWidth,
|
||||
sinf(rotAngle2)*kPerTexelWidth,
|
||||
sinf(rotAngle3)*kPerTexelWidth };
|
||||
float const type3OffsetY[4] = {0.0f, -cosf(rotAngle1)*kPerTexelHeight,
|
||||
-cosf(rotAngle2)*kPerTexelHeight,
|
||||
-cosf(rotAngle3)*kPerTexelHeight };
|
||||
|
||||
s = 2.0f/3.0f; // same as type 1, except s is different
|
||||
float const type4OffsetX[4] = { -s * kPerTexelWidth,
|
||||
-s * kPerTexelWidth,
|
||||
s * kPerTexelWidth,
|
||||
s * kPerTexelWidth };
|
||||
float const type4OffsetY[4] = { -s * kPerTexelHeight,
|
||||
s * kPerTexelHeight,
|
||||
s * kPerTexelHeight,
|
||||
-s * kPerTexelHeight };
|
||||
// write all these offsets to constant memory
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
D3DXVECTOR4 noOffset( noOffsetX[i], noOffsetY[i], 0.0f, 0.0f);
|
||||
D3DXVECTOR4 type1Offset(type1OffsetX[i], type1OffsetY[i], 0.0f, 0.0f);
|
||||
D3DXVECTOR4 type2Offset(type2OffsetX[i], type2OffsetY[i], 0.0f, 0.0f);
|
||||
D3DXVECTOR4 type3Offset(type3OffsetX[i], type3OffsetY[i], 0.0f, 0.0f);
|
||||
D3DXVECTOR4 type4Offset(type4OffsetX[i], type4OffsetY[i], 0.0f, 0.0f);
|
||||
|
||||
BaseGraphicsLayer::GetDevice()->SetVertexShaderConstant(CV_UV_T0_NO_OFFSET + 5*i, &noOffset, 1);
|
||||
BaseGraphicsLayer::GetDevice()->SetVertexShaderConstant(CV_UV_T0_TYPE1 + 5*i, &type1Offset, 1);
|
||||
BaseGraphicsLayer::GetDevice()->SetVertexShaderConstant(CV_UV_T0_TYPE2 + 5*i, &type2Offset, 1);
|
||||
BaseGraphicsLayer::GetDevice()->SetVertexShaderConstant(CV_UV_T0_TYPE3 + 5*i, &type3Offset, 1);
|
||||
BaseGraphicsLayer::GetDevice()->SetVertexShaderConstant(CV_UV_T0_TYPE4 + 5*i, &type4Offset, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CGlareTexture::ProcedualGenerateGlareTexture(LPDIRECT3DDEVICE8 pd3dDevice, LPDIRECT3DBASETEXTURE8 pTexture, vector3 vecNeighbor, int nDepth)
|
||||
{
|
||||
if(pTexture)
|
||||
m_nFinalRenderTexture=0;
|
||||
|
||||
long QUADVERTEX2FVF=D3DFVF_XYZRHW | D3DFVF_TEX4;
|
||||
|
||||
LPDIRECT3DSURFACE8 m_pTempRenderSurface;
|
||||
LPDIRECT3DSURFACE8 m_pTempRenderZBuffer;
|
||||
|
||||
pd3dDevice->GetRenderTarget(&m_pTempRenderSurface);
|
||||
pd3dDevice->GetDepthStencilSurface(&m_pTempRenderZBuffer);
|
||||
|
||||
|
||||
pd3dDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
|
||||
|
||||
pd3dDevice->SetVertexShader(QUADVERTEX2FVF);
|
||||
pd3dDevice->SetPixelShader(m_BlurPixelShader);
|
||||
|
||||
pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE,FALSE);
|
||||
|
||||
pd3dDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
|
||||
pd3dDevice->SetRenderState( D3DRS_LIGHTING,FALSE);
|
||||
pd3dDevice->SetRenderState( D3DRS_FOGENABLE,FALSE);
|
||||
|
||||
pd3dDevice->SetRenderState(D3DRS_ZWRITEENABLE,FALSE);
|
||||
|
||||
|
||||
float fConst[4];
|
||||
fConst[0]=vecNeighbor.x;
|
||||
fConst[1]=vecNeighbor.y;
|
||||
fConst[2]=vecNeighbor.z;
|
||||
fConst[3]=0.27f;
|
||||
|
||||
pd3dDevice->SetPixelShaderConstant(0,fConst, 1 );
|
||||
|
||||
QuadVertex2 pVertex[4];
|
||||
|
||||
pVertex[0].v.x=0.0f;
|
||||
pVertex[1].v.x=0.0f;
|
||||
pVertex[2].v.x=(float)m_nSize;
|
||||
pVertex[3].v.x=(float)m_nSize;
|
||||
|
||||
pVertex[1].v.y=0.0f;
|
||||
pVertex[3].v.y=0.0f;
|
||||
pVertex[0].v.y=(float)m_nSize;
|
||||
pVertex[2].v.y=(float)m_nSize;
|
||||
|
||||
pVertex[0].tu0=0.0f;
|
||||
pVertex[1].tu0=0.0f;
|
||||
pVertex[0].tu1=0.0f;
|
||||
pVertex[1].tu1=0.0f;
|
||||
pVertex[0].tu2=0.0f;
|
||||
pVertex[1].tu2=0.0f;
|
||||
pVertex[0].tu3=0.0f;
|
||||
pVertex[1].tu3=0.0f;
|
||||
|
||||
pVertex[1].tv0=0.0f;
|
||||
pVertex[3].tv0=0.0f;
|
||||
pVertex[1].tv1=0.0f;
|
||||
pVertex[3].tv1=0.0f;
|
||||
pVertex[1].tv2=0.0f;
|
||||
pVertex[3].tv2=0.0f;
|
||||
pVertex[1].tv3=0.0f;
|
||||
pVertex[3].tv3=0.0f;
|
||||
|
||||
|
||||
float fXPerPixel=(1.0f/m_nSize)*0.5f*(800.0f/1024.0f);
|
||||
float fYPerPixel=(1.0f/m_nSize)*0.5f*(600.0f/1024.0f);
|
||||
|
||||
|
||||
|
||||
//pd3dDevice->SetRenderState(D3DRS_COLORWRITEENABLE,D3DCOLORWRITEENABLE_ALPHA|D3DCOLORWRITEENABLE_BLUE|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_RED);
|
||||
|
||||
if(pTexture==NULL)
|
||||
{
|
||||
fXPerPixel=(1.0f/m_nSize)*0.5f;
|
||||
fYPerPixel=(1.0f/m_nSize)*0.5f;
|
||||
|
||||
pVertex[3].tu0=1.0f;
|
||||
pVertex[2].tu0=1.0f;
|
||||
pVertex[3].tu1=1.0f;
|
||||
pVertex[2].tu1=1.0f;
|
||||
pVertex[3].tu2=1.0f;
|
||||
pVertex[2].tu2=1.0f;
|
||||
pVertex[3].tu3=1.0f;
|
||||
pVertex[2].tu3=1.0f;
|
||||
|
||||
pVertex[0].tv0=1.0f;
|
||||
pVertex[2].tv0=1.0f;
|
||||
pVertex[0].tv1=1.0f;
|
||||
pVertex[2].tv1=1.0f;
|
||||
pVertex[0].tv2=1.0f;
|
||||
pVertex[2].tv2=1.0f;
|
||||
pVertex[0].tv3=1.0f;
|
||||
pVertex[2].tv3=1.0f;
|
||||
|
||||
/*
|
||||
|
||||
pVertex[3].tu0=1.0f+fXPerPixel;
|
||||
pVertex[2].tu0=1.0f+fXPerPixel;
|
||||
pVertex[3].tu1=1.0f+fXPerPixel*2.0f;
|
||||
pVertex[2].tu1=1.0f+fXPerPixel*2.0f;
|
||||
pVertex[3].tu2=1.0f+fXPerPixel;
|
||||
pVertex[2].tu2=1.0f+fXPerPixel;
|
||||
pVertex[3].tu3=1.0f+fXPerPixel*2.0f;
|
||||
pVertex[2].tu3=1.0f+fXPerPixel*2.0f;
|
||||
|
||||
pVertex[0].tv0=1.0f+fYPerPixel;
|
||||
pVertex[2].tv0=1.0f+fYPerPixel;
|
||||
pVertex[0].tv1=1.0f+fYPerPixel;
|
||||
pVertex[2].tv1=1.0f+fYPerPixel;
|
||||
pVertex[0].tv2=1.0f+fYPerPixel*2.0f;
|
||||
pVertex[2].tv2=1.0f+fYPerPixel*2.0f;
|
||||
pVertex[0].tv3=1.0f+fYPerPixel*2.0f;
|
||||
pVertex[2].tv3=1.0f+fYPerPixel*2.0f;
|
||||
*/
|
||||
|
||||
for(int i=0;i<nDepth;i++)
|
||||
{
|
||||
pd3dDevice->SetRenderTarget(m_pRenderSurface[(m_nFinalRenderTexture+i+1)%2],m_pRenderZBuffer);
|
||||
|
||||
pd3dDevice->SetTexture(0,m_pRenderTexture[(m_nFinalRenderTexture+i)%2]);
|
||||
pd3dDevice->SetTexture(1,m_pRenderTexture[(m_nFinalRenderTexture+i)%2]);
|
||||
pd3dDevice->SetTexture(2,m_pRenderTexture[(m_nFinalRenderTexture+i)%2]);
|
||||
pd3dDevice->SetTexture(3,m_pRenderTexture[(m_nFinalRenderTexture+i)%2]);
|
||||
|
||||
}
|
||||
pd3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,pVertex,sizeof(QuadVertex2));
|
||||
m_nFinalRenderTexture=(m_nFinalRenderTexture+i)%2;
|
||||
//m_nFinalRenderTexture=i%2;
|
||||
}
|
||||
else
|
||||
{
|
||||
pVertex[3].tu0=800.0f/1024.0f;//-fXPerPixel;
|
||||
pVertex[2].tu0=800.0f/1024.0f;//-fXPerPixel;
|
||||
pVertex[3].tu1=800.0f/1024.0f+fXPerPixel*2.0f;
|
||||
pVertex[2].tu1=800.0f/1024.0f+fXPerPixel*2.0f;
|
||||
pVertex[3].tu2=800.0f/1024.0f;//-fXPerPixel;
|
||||
pVertex[2].tu2=800.0f/1024.0f;//-fXPerPixel;
|
||||
pVertex[3].tu3=800.0f/1024.0f+fXPerPixel*2.0f;
|
||||
pVertex[2].tu3=800.0f/1024.0f+fXPerPixel*2.0f;
|
||||
|
||||
pVertex[0].tv0=600.0f/1024.0f;//-fYPerPixel;
|
||||
pVertex[2].tv0=600.0f/1024.0f;//-fYPerPixel;
|
||||
pVertex[0].tv1=600.0f/1024.0f;//-fYPerPixel;
|
||||
pVertex[2].tv1=600.0f/1024.0f;//-fYPerPixel;
|
||||
pVertex[0].tv2=600.0f/1024.0f+fYPerPixel*2.0f;
|
||||
pVertex[2].tv2=600.0f/1024.0f+fYPerPixel*2.0f;
|
||||
pVertex[0].tv3=600.0f/1024.0f+fYPerPixel*2.0f;
|
||||
pVertex[2].tv3=600.0f/1024.0f+fYPerPixel*2.0f;
|
||||
|
||||
for(int i=0;i<nDepth;i++)
|
||||
{
|
||||
pd3dDevice->SetRenderTarget(m_pRenderSurface[i%2],m_pRenderZBuffer);
|
||||
if(i==0)
|
||||
{
|
||||
if(pTexture)
|
||||
{
|
||||
pd3dDevice->SetTexture(0,pTexture);
|
||||
pd3dDevice->SetTexture(1,pTexture);
|
||||
pd3dDevice->SetTexture(2,pTexture);
|
||||
pd3dDevice->SetTexture(3,pTexture);
|
||||
}
|
||||
else
|
||||
{
|
||||
pd3dDevice->SetTexture(0,m_pRenderTexture[m_nFinalRenderTexture]);
|
||||
pd3dDevice->SetTexture(1,m_pRenderTexture[m_nFinalRenderTexture]);
|
||||
pd3dDevice->SetTexture(2,m_pRenderTexture[m_nFinalRenderTexture]);
|
||||
pd3dDevice->SetTexture(3,m_pRenderTexture[m_nFinalRenderTexture]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pd3dDevice->SetTexture(0,m_pRenderTexture[(i-1)%2]);
|
||||
pd3dDevice->SetTexture(1,m_pRenderTexture[(i-1)%2]);
|
||||
pd3dDevice->SetTexture(2,m_pRenderTexture[(i-1)%2]);
|
||||
pd3dDevice->SetTexture(3,m_pRenderTexture[(i-1)%2]);
|
||||
}
|
||||
pd3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,pVertex,sizeof(QuadVertex2));
|
||||
m_nFinalRenderTexture=i%2;
|
||||
}
|
||||
}
|
||||
|
||||
//pd3dDevice->SetRenderState(D3DRS_COLORWRITEENABLE,D3DCOLORWRITEENABLE_BLUE|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_RED);
|
||||
pd3dDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
|
||||
|
||||
|
||||
pd3dDevice->SetRenderTarget(m_pTempRenderSurface,m_pTempRenderZBuffer);
|
||||
pd3dDevice->SetRenderState(D3DRS_ZWRITEENABLE,FALSE);
|
||||
|
||||
pd3dDevice->SetPixelShader(NULL);
|
||||
}
|
||||
|
||||
void CGlareTexture::GenerateGlareTexture2(LPDIRECT3DDEVICE8 pd3dDevice,LPDIRECT3DBASETEXTURE8 pTexture,vector3 vecNeighbor,int nDepth)
|
||||
{
|
||||
|
||||
LPDIRECT3DSURFACE8 m_pTempRenderSurface;
|
||||
LPDIRECT3DSURFACE8 m_pTempRenderZBuffer;
|
||||
|
||||
pd3dDevice->GetRenderTarget(&m_pTempRenderSurface);
|
||||
pd3dDevice->GetDepthStencilSurface(&m_pTempRenderZBuffer);
|
||||
|
||||
|
||||
CreateAndWriteUVOffsets(m_nSize,m_nSize);
|
||||
|
||||
matrix matOldWorld,matOldProjection,matOldView;
|
||||
|
||||
pd3dDevice->GetTransform(D3DTS_WORLD,matOldWorld);
|
||||
pd3dDevice->GetTransform(D3DTS_PROJECTION,matOldProjection);
|
||||
pd3dDevice->GetTransform(D3DTS_VIEW,matOldView);
|
||||
|
||||
|
||||
D3DXMATRIX matWorld;
|
||||
D3DXMATRIX matView;
|
||||
D3DXMATRIX matProj;
|
||||
D3DXMATRIX matViewProj;
|
||||
D3DXMATRIX matWorldViewProj;
|
||||
D3DXVECTOR4 offset(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
offset.x = 2.0f;
|
||||
pd3dDevice->SetVertexShaderConstant(CV_UV_OFFSET_TO_USE, &offset, 1);
|
||||
pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
|
||||
|
||||
pd3dDevice->SetVertexShader(m_BlurVertexShader);
|
||||
pd3dDevice->SetStreamSource(0,m_pVertexBuffer,sizeof(QuadVertex));
|
||||
|
||||
D3DXVECTOR3 const vEyePt = D3DXVECTOR3( 0.0f, 0.0f, -5.0f );
|
||||
D3DXVECTOR3 const vLookatPt = D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
|
||||
D3DXVECTOR3 const vUp = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
|
||||
|
||||
D3DXMatrixLookAtLH(&matView, &vEyePt, &vLookatPt, &vUp);
|
||||
D3DXMatrixOrthoLH(&matProj, 4.0f, 4.0f, 0.2f, 20.0f);
|
||||
|
||||
D3DXMatrixMultiply(&matViewProj, &matView, &matProj);
|
||||
|
||||
D3DXMatrixScaling(&matWorld, 2.0f, 2.0f, 1.0f);
|
||||
D3DXMatrixMultiply(&matWorldViewProj, &matWorld, &matViewProj);
|
||||
D3DXMatrixTranspose(&matWorldViewProj, &matWorldViewProj);
|
||||
|
||||
pd3dDevice->GetTransform(D3DTS_WORLD,&matWorld);
|
||||
pd3dDevice->GetTransform(D3DTS_PROJECTION,&matProj);
|
||||
pd3dDevice->GetTransform(D3DTS_VIEW,&matView);
|
||||
|
||||
for(int i=0;i<4;i++)
|
||||
{
|
||||
pd3dDevice->SetTextureStageState(i, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
|
||||
pd3dDevice->SetTextureStageState(i, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
|
||||
pd3dDevice->SetTextureStageState(i, D3DTSS_MIPFILTER, D3DTEXF_NONE);
|
||||
pd3dDevice->SetTextureStageState(i, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP);
|
||||
pd3dDevice->SetTextureStageState(i, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP);
|
||||
}
|
||||
|
||||
pd3dDevice->SetVertexShaderConstant(CV_WORLDVIEWPROJ_0, &matWorldViewProj(0, 0), 4);
|
||||
|
||||
pd3dDevice->SetPixelShader(m_BlurPixelShader);
|
||||
pd3dDevice->SetVertexShader(m_BlurVertexShader);
|
||||
|
||||
pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE,FALSE);
|
||||
|
||||
pd3dDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
|
||||
pd3dDevice->SetRenderState(D3DRS_ZWRITEENABLE,FALSE);
|
||||
|
||||
pd3dDevice->SetRenderState( D3DRS_LIGHTING,FALSE);
|
||||
pd3dDevice->SetRenderState( D3DRS_FOGENABLE,FALSE);
|
||||
|
||||
pd3dDevice->SetRenderState(D3DRS_CULLMODE,D3DCULL_NONE);
|
||||
|
||||
pd3dDevice->SetStreamSource(0, m_pVertexBuffer, sizeof(QuadVertex));
|
||||
|
||||
float fBlurConst[4]={vecNeighbor.x,vecNeighbor.x,vecNeighbor.x,vecNeighbor.x};
|
||||
|
||||
pd3dDevice->SetPixelShaderConstant(0,fBlurConst,1);
|
||||
|
||||
for( i=0;i<nDepth;i++)
|
||||
{
|
||||
//pd3dDevice->SetRenderTarget(m_pRenderSurface[i%2],NULL);
|
||||
|
||||
pd3dDevice->SetRenderTarget(m_pRenderSurface[i%2],m_pRenderZBuffer);
|
||||
|
||||
//D3DVIEWPORT8 viewData = { 0, 0, m_nSize, m_nSize, 0.0f, 1.0f };
|
||||
//pd3dDevice->SetViewport(&viewData);
|
||||
|
||||
if(i==0)
|
||||
{
|
||||
pd3dDevice->SetTexture(0,pTexture);
|
||||
pd3dDevice->SetTexture(1,pTexture);
|
||||
pd3dDevice->SetTexture(2,pTexture);
|
||||
pd3dDevice->SetTexture(3,pTexture);
|
||||
}
|
||||
else
|
||||
{
|
||||
pd3dDevice->SetTexture(0,m_pRenderTexture[(i-1)%2]);
|
||||
pd3dDevice->SetTexture(1,m_pRenderTexture[(i-1)%2]);
|
||||
pd3dDevice->SetTexture(2,m_pRenderTexture[(i-1)%2]);
|
||||
pd3dDevice->SetTexture(3,m_pRenderTexture[(i-1)%2]);
|
||||
}
|
||||
|
||||
pd3dDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, 0, 2);
|
||||
|
||||
m_nFinalRenderTexture=i%2;
|
||||
}
|
||||
|
||||
for(i=0;i<4;i++)
|
||||
{
|
||||
pd3dDevice->SetTextureStageState(i, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
|
||||
pd3dDevice->SetTextureStageState(i, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
|
||||
pd3dDevice->SetTextureStageState(i, D3DTSS_MIPFILTER, D3DTEXF_LINEAR);
|
||||
pd3dDevice->SetTextureStageState(i, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
|
||||
pd3dDevice->SetTextureStageState(i, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
|
||||
}
|
||||
|
||||
pd3dDevice->SetRenderState(D3DRS_CULLMODE,D3DCULL_CCW);
|
||||
|
||||
|
||||
pd3dDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
|
||||
pd3dDevice->SetRenderState(D3DRS_ZWRITEENABLE,TRUE);
|
||||
|
||||
pd3dDevice->SetTransform(D3DTS_WORLD,matOldWorld);
|
||||
pd3dDevice->SetTransform(D3DTS_PROJECTION,matOldProjection);
|
||||
pd3dDevice->SetTransform(D3DTS_VIEW,matOldView);
|
||||
|
||||
|
||||
pd3dDevice->SetRenderTarget(m_pTempRenderSurface,m_pTempRenderZBuffer);
|
||||
|
||||
pd3dDevice->SetPixelShader(NULL);
|
||||
|
||||
}
|
||||
57
Engine/Zalla3D Base Class/GlareTexture.h
Normal file
57
Engine/Zalla3D Base Class/GlareTexture.h
Normal file
@@ -0,0 +1,57 @@
|
||||
// GlareTexture.h: interface for the CGlareTexture class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_GLARETEXTURE_H__18B36EBC_004F_4F55_A006_DE21B3FC4CCB__INCLUDED_)
|
||||
#define AFX_GLARETEXTURE_H__18B36EBC_004F_4F55_A006_DE21B3FC4CCB__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "RenderTexture.h"
|
||||
#include "D3DX8.h"
|
||||
#include "3DMath.h"
|
||||
|
||||
class CGlareTexture
|
||||
{
|
||||
class QuadVertex
|
||||
{
|
||||
public:
|
||||
D3DXVECTOR3 Position;
|
||||
D3DXVECTOR2 Tex;
|
||||
};
|
||||
|
||||
class QuadVertex2
|
||||
{
|
||||
public:
|
||||
vector3 v;
|
||||
float w;
|
||||
float tu0,tv0;
|
||||
float tu1,tv1;
|
||||
float tu2,tv2;
|
||||
float tu3,tv3;
|
||||
};
|
||||
|
||||
|
||||
LPDIRECT3DTEXTURE8 m_pRenderTexture[2];
|
||||
LPDIRECT3DSURFACE8 m_pRenderSurface[2];
|
||||
static LPDIRECT3DSURFACE8 m_pRenderZBuffer;
|
||||
DWORD m_BlurPixelShader,m_BlurVertexShader;
|
||||
LPDIRECT3DVERTEXBUFFER8 m_pVertexBuffer;
|
||||
|
||||
int m_nSize;
|
||||
int m_nFinalRenderTexture;
|
||||
public:
|
||||
void GenerateGlareTexture2(LPDIRECT3DDEVICE8 pd3dDevice,LPDIRECT3DBASETEXTURE8 pTexture,vector3 vecNeighbor,int nDepth);
|
||||
void ProcedualGenerateGlareTexture(LPDIRECT3DDEVICE8 pd3dDevice, LPDIRECT3DBASETEXTURE8 pTexture,vector3 vecNeighbor,int nDepth);
|
||||
LPDIRECT3DTEXTURE8 GetTexture(){return m_pRenderTexture[m_nFinalRenderTexture];};
|
||||
|
||||
void CreateAndWriteUVOffsets(int width, int height);
|
||||
void Create(int nSize);
|
||||
void GenerateGlareTexture(LPDIRECT3DDEVICE8 pd3dDevice,LPDIRECT3DBASETEXTURE8 pTexture,vector3 vecNeighbor,int nDepth);
|
||||
CGlareTexture();
|
||||
virtual ~CGlareTexture();
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_GLARETEXTURE_H__18B36EBC_004F_4F55_A006_DE21B3FC4CCB__INCLUDED_)
|
||||
20
Engine/Zalla3D Base Class/GraphicLayerError.cpp
Normal file
20
Engine/Zalla3D Base Class/GraphicLayerError.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
// GraphicLayerError.cpp: implementation of the CGraphicLayerError class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "GraphicLayerError.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CGraphicLayerError::CGraphicLayerError()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CGraphicLayerError::~CGraphicLayerError()
|
||||
{
|
||||
|
||||
}
|
||||
34
Engine/Zalla3D Base Class/GraphicLayerError.h
Normal file
34
Engine/Zalla3D Base Class/GraphicLayerError.h
Normal file
@@ -0,0 +1,34 @@
|
||||
// GraphicLayerError.h: interface for the CGraphicLayerError class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_GRAPHICLAYERERROR_H__D06B571E_F0F8_41E8_AD22_257A312F48E0__INCLUDED_)
|
||||
#define AFX_GRAPHICLAYERERROR_H__D06B571E_F0F8_41E8_AD22_257A312F48E0__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "Error.h"
|
||||
|
||||
|
||||
class CGraphicLayerError : public CError
|
||||
{
|
||||
public:
|
||||
CGraphicLayerError();
|
||||
virtual ~CGraphicLayerError();
|
||||
char *GetErrorMsg()
|
||||
{
|
||||
char msgtemp[MAX_ERRORBUFFER];
|
||||
strcpy(msgtemp,"Graphics Layer Error:");
|
||||
strcat(msgtemp,m_strErrormsg);
|
||||
strcpy(m_strErrormsg,msgtemp);
|
||||
return m_strErrormsg;
|
||||
};
|
||||
CGraphicLayerError(char *msg)
|
||||
{
|
||||
SetErrorMsg(msg);
|
||||
};
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_GRAPHICLAYERERROR_H__D06B571E_F0F8_41E8_AD22_257A312F48E0__INCLUDED_)
|
||||
250
Engine/Zalla3D Base Class/IMEFont.cpp
Normal file
250
Engine/Zalla3D Base Class/IMEFont.cpp
Normal file
@@ -0,0 +1,250 @@
|
||||
// IMEFont.cpp: implementation of the CIMEFont class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "IMEFont.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CIMEFont::CIMEFont()
|
||||
{
|
||||
for(int i=0;i<10;i++)
|
||||
{
|
||||
strcpy(m_strPrint[i],"");
|
||||
strcpy(m_strPrinted[i],"");
|
||||
}
|
||||
m_RenderX=0;
|
||||
m_RenderY=0;
|
||||
}
|
||||
|
||||
CIMEFont::~CIMEFont()
|
||||
{
|
||||
if(m_pTexture)
|
||||
m_pTexture->Release();
|
||||
}
|
||||
|
||||
void CIMEFont::Render(LPDIRECT3DDEVICE8 pd3dDevice)
|
||||
{
|
||||
if(isRewirte())
|
||||
MakeTexture();
|
||||
m_pVertex[0].v.x=0.0f+m_RenderX;
|
||||
m_pVertex[1].v.x=0.0f+m_RenderX;
|
||||
m_pVertex[2].v.x=(float)m_SizeX+m_RenderX;
|
||||
m_pVertex[3].v.x=(float)m_SizeX+m_RenderX;
|
||||
|
||||
m_pVertex[1].v.y=0.0f+m_RenderY;
|
||||
m_pVertex[3].v.y=0.0f+m_RenderY;
|
||||
m_pVertex[0].v.y=(float)m_SizeY+m_RenderY;
|
||||
m_pVertex[2].v.y=(float)m_SizeY+m_RenderY;
|
||||
|
||||
m_pVertex[0].tu=0.0f;
|
||||
m_pVertex[1].tu=0.0f;
|
||||
|
||||
m_pVertex[3].tu=1.0f;
|
||||
m_pVertex[2].tu=1.0f;
|
||||
|
||||
m_pVertex[1].tv=0.0f;
|
||||
m_pVertex[3].tv=0.0f;
|
||||
|
||||
m_pVertex[0].tv=1.0f;
|
||||
m_pVertex[2].tv=1.0f;
|
||||
|
||||
for(int i=0;i<4;i++)
|
||||
{
|
||||
m_pVertex[i].w=0.1f;
|
||||
m_pVertex[i].v.z=0.1f;
|
||||
m_pVertex[i].Diffuse.c=0xffffffff;
|
||||
m_pVertex[i].Specular.c=0xffffffff;
|
||||
}
|
||||
pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
|
||||
pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
|
||||
pd3dDevice->SetTexture(0,m_pTexture);
|
||||
//3dDevice->SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TEXTURE);
|
||||
//3dDevice->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_SELECTARG1);
|
||||
|
||||
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
|
||||
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
|
||||
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
|
||||
|
||||
//m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
|
||||
//m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
|
||||
|
||||
pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_POINT );
|
||||
pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_POINT );
|
||||
//m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MIPFILTER, D3DTEXF_NONE );
|
||||
|
||||
pd3dDevice->SetVertexShader(TLVERTEXFVF);
|
||||
pd3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,m_pVertex,sizeof(TLVertex));
|
||||
pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE,FALSE);
|
||||
pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
|
||||
pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
|
||||
pd3dDevice->SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TEXTURE);
|
||||
pd3dDevice->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_SELECTARG1);
|
||||
}
|
||||
|
||||
void CIMEFont::Create(LPDIRECT3DDEVICE8 pd3dDevice,long sizeX,long sizeY)
|
||||
{
|
||||
m_SizeX=sizeX;
|
||||
m_SizeY=sizeY;
|
||||
// Chatting Message Font 512,64;
|
||||
m_cLine=m_SizeY/16;
|
||||
pd3dDevice->CreateTexture(sizeX,sizeY,1,0,D3DFMT_A4R4G4B4,D3DPOOL_MANAGED,&m_pTexture);
|
||||
}
|
||||
|
||||
void CIMEFont::PrintToTexture(char *str, long line)
|
||||
{
|
||||
if( line >=0 && line<m_cLine)
|
||||
strcpy(m_strPrint[line],str);
|
||||
}
|
||||
|
||||
|
||||
bool CIMEFont::isRewirte()
|
||||
{
|
||||
for(int cLine=0;cLine<m_cLine;cLine++)
|
||||
{
|
||||
if( strcmp(m_strPrint[cLine],m_strPrinted[cLine])!=0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CIMEFont::MakeTexture()
|
||||
{
|
||||
DWORD* pBitmapBits;
|
||||
BITMAPINFO bmi;
|
||||
ZeroMemory( &bmi.bmiHeader, sizeof(BITMAPINFOHEADER) );
|
||||
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
bmi.bmiHeader.biWidth = (int)m_SizeX;
|
||||
bmi.bmiHeader.biHeight = -(int)m_SizeY;
|
||||
bmi.bmiHeader.biPlanes = 1;
|
||||
bmi.bmiHeader.biCompression = BI_RGB;
|
||||
bmi.bmiHeader.biBitCount = 32;
|
||||
|
||||
// Create a DC and a bitmap for the font
|
||||
HDC hDC = CreateCompatibleDC( NULL );
|
||||
HBITMAP hbmBitmap = CreateDIBSection( hDC, &bmi, DIB_RGB_COLORS,
|
||||
(VOID**)&pBitmapBits, NULL, 0 );
|
||||
SetMapMode( hDC, MM_TEXT );
|
||||
|
||||
HFONT hFont=CreateFont(-12,6,0,0,0,FALSE,FALSE,FALSE, CHINESEBIG5_CHARSET, OUT_DEFAULT_PRECIS,
|
||||
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
|
||||
DEFAULT_PITCH, "MingLiu" );
|
||||
|
||||
SelectObject( hDC, hbmBitmap );
|
||||
SelectObject( hDC, hFont );
|
||||
|
||||
SetTextColor( hDC, RGB(255,255,255) );
|
||||
SetBkColor( hDC, 0x00000000 );
|
||||
SetTextAlign( hDC, TA_LEFT);
|
||||
|
||||
for(int cLine=0;cLine<m_cLine;cLine++)
|
||||
{
|
||||
ExtTextOut( hDC, 0, cLine*16, ETO_OPAQUE, NULL,m_strPrint[cLine],strlen(m_strPrint[cLine]), NULL );
|
||||
strcpy(m_strPrinted[cLine],m_strPrint[cLine]);
|
||||
}
|
||||
/*
|
||||
ExtTextOut( hDC, 0, 12, ETO_OPAQUE, NULL,m_strPrint[1],strlen(m_strPrint[1]), NULL );
|
||||
ExtTextOut( hDC, 0, 24, ETO_OPAQUE, NULL,m_strPrint[2],strlen(m_strPrint[2]), NULL );
|
||||
ExtTextOut( hDC, 0, 36, ETO_OPAQUE, NULL,m_strPrint[3],strlen(m_strPrint[3]), NULL );
|
||||
strcpy(m_strPrinted[0],m_strPrint[0]);
|
||||
strcpy(m_strPrinted[1],m_strPrint[1]);
|
||||
strcpy(m_strPrinted[2],m_strPrint[2]);
|
||||
strcpy(m_strPrinted[3],m_strPrint[3]);
|
||||
*/
|
||||
//SIZE p;
|
||||
//GetTextExtentPoint32(hDC,"<22><>",2,&p);
|
||||
|
||||
//RECT rcFont={0,0,25*15,4*16};
|
||||
//DrawText(hDC,strTemp,strlen(strTemp),&rcFont,DT_WORDBREAK|DT_LEFT);
|
||||
|
||||
D3DLOCKED_RECT d3dlr;
|
||||
m_pTexture->LockRect( 0, &d3dlr, 0, 0 );
|
||||
WORD* pDst16 = (WORD*)d3dlr.pBits;
|
||||
BYTE bAlpha;
|
||||
|
||||
int x,y;
|
||||
for( y=0;y<m_SizeY; y++ )
|
||||
{
|
||||
for( x=0;x<m_SizeX; x++ )
|
||||
{
|
||||
bAlpha = (BYTE)((pBitmapBits[m_SizeX*y + x] & 0xff) >> 4);
|
||||
|
||||
if (bAlpha > 0)
|
||||
{
|
||||
*pDst16++ = (bAlpha << 12) | 0x0fff;
|
||||
}
|
||||
else
|
||||
{
|
||||
*pDst16++=0x0000;
|
||||
}
|
||||
}
|
||||
}
|
||||
m_pTexture->UnlockRect(0);
|
||||
DeleteObject( hbmBitmap );
|
||||
DeleteDC( hDC );
|
||||
DeleteObject( hFont );
|
||||
}
|
||||
|
||||
void CIMEFont::Render(LPDIRECT3DDEVICE8 pd3dDevice, DWORD dwColor)
|
||||
{
|
||||
if(isRewirte())
|
||||
MakeTexture();
|
||||
m_pVertex[0].v.x=0.0f+m_RenderX;
|
||||
m_pVertex[1].v.x=0.0f+m_RenderX;
|
||||
m_pVertex[2].v.x=(float)m_SizeX+m_RenderX;
|
||||
m_pVertex[3].v.x=(float)m_SizeX+m_RenderX;
|
||||
|
||||
m_pVertex[1].v.y=0.0f+m_RenderY;
|
||||
m_pVertex[3].v.y=0.0f+m_RenderY;
|
||||
m_pVertex[0].v.y=(float)m_SizeY+m_RenderY;
|
||||
m_pVertex[2].v.y=(float)m_SizeY+m_RenderY;
|
||||
|
||||
m_pVertex[0].tu=0.0f;
|
||||
m_pVertex[1].tu=0.0f;
|
||||
|
||||
m_pVertex[3].tu=1.0f;
|
||||
m_pVertex[2].tu=1.0f;
|
||||
|
||||
m_pVertex[1].tv=0.0f;
|
||||
m_pVertex[3].tv=0.0f;
|
||||
|
||||
m_pVertex[0].tv=1.0f;
|
||||
m_pVertex[2].tv=1.0f;
|
||||
|
||||
for(int i=0;i<4;i++)
|
||||
{
|
||||
m_pVertex[i].w=0.1f;
|
||||
m_pVertex[i].v.z=0.1f;
|
||||
m_pVertex[i].Diffuse.c=dwColor;
|
||||
m_pVertex[i].Specular.c=dwColor;
|
||||
}
|
||||
pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
|
||||
pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
|
||||
pd3dDevice->SetTexture(0,m_pTexture);
|
||||
//3dDevice->SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TEXTURE);
|
||||
//3dDevice->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_SELECTARG1);
|
||||
|
||||
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
|
||||
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
|
||||
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
|
||||
|
||||
//m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
|
||||
//m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
|
||||
|
||||
pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_POINT );
|
||||
pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_POINT );
|
||||
//m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MIPFILTER, D3DTEXF_NONE );
|
||||
|
||||
pd3dDevice->SetVertexShader(TLVERTEXFVF);
|
||||
pd3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,m_pVertex,sizeof(TLVertex));
|
||||
pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE,FALSE);
|
||||
pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
|
||||
pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
|
||||
pd3dDevice->SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TEXTURE);
|
||||
pd3dDevice->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_SELECTARG1);
|
||||
}
|
||||
45
Engine/Zalla3D Base Class/IMEFont.h
Normal file
45
Engine/Zalla3D Base Class/IMEFont.h
Normal file
@@ -0,0 +1,45 @@
|
||||
// IMEFont.h: interface for the CIMEFont class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_IMEFONT_H__C8D7C988_BD4A_4270_AE9D_829679CEB5F4__INCLUDED_)
|
||||
#define AFX_IMEFONT_H__C8D7C988_BD4A_4270_AE9D_829679CEB5F4__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include <d3d8.h>
|
||||
#include <d3dx8.h>
|
||||
#include "Vertex.h"
|
||||
|
||||
class CIMEFont
|
||||
{
|
||||
TLVertex m_pVertex[4];
|
||||
char m_strPrint[20][256];
|
||||
char m_strPrinted[20][256];
|
||||
int m_cLine;
|
||||
public:
|
||||
void Render(LPDIRECT3DDEVICE8 pd3dDevice,DWORD dwColor);
|
||||
void MakeTexture();
|
||||
bool isRewirte();
|
||||
void PrintToTexture(char *str,long line);
|
||||
void Create(LPDIRECT3DDEVICE8 pd3dDevice,long sizeX,long sizeY);
|
||||
void Render(LPDIRECT3DDEVICE8 pd3dDevice);
|
||||
LPDIRECT3DTEXTURE8 m_pTexture;
|
||||
CIMEFont();
|
||||
virtual ~CIMEFont();
|
||||
long m_RenderX,m_RenderY;
|
||||
long m_SizeX,m_SizeY;
|
||||
void SetRenderPos(int RenderX,int RenderY)
|
||||
{
|
||||
m_RenderX=RenderX;
|
||||
m_RenderY=RenderY;
|
||||
};
|
||||
char* GetPrintText(int nText)
|
||||
{
|
||||
return m_strPrint[nText];
|
||||
};
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_IMEFONT_H__C8D7C988_BD4A_4270_AE9D_829679CEB5F4__INCLUDED_)
|
||||
22
Engine/Zalla3D Base Class/IPoolMgr.h
Normal file
22
Engine/Zalla3D Base Class/IPoolMgr.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
namespace CROSSM {
|
||||
class IPoolMgr
|
||||
{
|
||||
public:
|
||||
|
||||
IPoolMgr(void)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~IPoolMgr(void)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void ReleaseAll() = 0;
|
||||
virtual void *GetObj() = 0;
|
||||
virtual void ReleaseObj(void *pObj) = 0;
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
35
Engine/Zalla3D Base Class/IResourceMgr.h
Normal file
35
Engine/Zalla3D Base Class/IResourceMgr.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
namespace CROSSM {
|
||||
class IResourceMgr
|
||||
{
|
||||
public:
|
||||
|
||||
IResourceMgr(void)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~IResourceMgr(void)
|
||||
{
|
||||
}
|
||||
virtual void ReleaseAllData() = 0;
|
||||
virtual void ReleaseData(const char *strName) = 0;
|
||||
virtual void *GetData(const char *) = 0;
|
||||
virtual void Update() = 0;
|
||||
|
||||
// 2005.01.10 yundi ImmediateLoad <20>߰<EFBFBD>
|
||||
virtual void LockImmediateLoad() = 0;
|
||||
virtual void UnlockImmediateLoad() = 0;
|
||||
|
||||
void SetType(int iType) { m_iResourceType = iType; }
|
||||
int GetType() { return m_iResourceType; }
|
||||
|
||||
|
||||
protected:
|
||||
virtual void *LoadData(const char *) = 0;
|
||||
int m_iResourceType; // ResourceType
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
836
Engine/Zalla3D Base Class/Intersection.cpp
Normal file
836
Engine/Zalla3D Base Class/Intersection.cpp
Normal file
@@ -0,0 +1,836 @@
|
||||
// Intersection.cpp: implementation of the CIntersection class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Intersection.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CIntersection::CIntersection()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CIntersection::~CIntersection()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int CIntersection::PolygonRay(vector3 vecStart, vector3 vecEnd, vector3 *poly,float &fInterLens)
|
||||
{
|
||||
/*
|
||||
vector3 vecDir=(vecEnd-vecStart);
|
||||
vecDir.Normalize();
|
||||
vector3 vecPoly[3];
|
||||
vecPoly[0]=*poly[0];
|
||||
vecPoly[1]=*poly[1];
|
||||
vecPoly[2]=*poly[2];
|
||||
if(PolygonRay2(vecStart,vecDir,vecPoly))
|
||||
return 1;
|
||||
return 0;
|
||||
*/
|
||||
|
||||
///*
|
||||
vector3 n=(poly[1]-poly[0])^(poly[2]-poly[0]);
|
||||
n.Normalize();
|
||||
if((fabs(n.x) <= 0.00000001f) &&
|
||||
(fabs(n.y) <= 0.00000001f) &&
|
||||
(fabs(n.z) <= 0.00000001f)) {
|
||||
fInterLens = 1000000.0f;
|
||||
return 0;
|
||||
}
|
||||
vector3 vecDir=(vecEnd-vecStart);
|
||||
vecDir.Normalize();
|
||||
float h;
|
||||
if(fabs((n.x*vecDir.x + n.y*vecDir.y + n.z*vecDir.z)) < 0.00000001f)
|
||||
{
|
||||
fInterLens = 1000000.0f;
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
h=( (n.x*poly[0].x+n.y*poly[0].y+n.z*poly[0].z) - (n.x*vecStart.x+n.y*vecStart.y+n.z*vecStart.z) )
|
||||
/ (n.x*vecDir.x + n.y*vecDir.y + n.z*vecDir.z);
|
||||
fInterLens=h;
|
||||
}
|
||||
if(h<0.0f)return 0;
|
||||
vector3 vecInter=vecEnd-vecStart;
|
||||
if(vecInter.GetLens() < h)
|
||||
return 0;
|
||||
|
||||
vector3 vecInterpos=vecStart+vecDir*h;
|
||||
|
||||
|
||||
vector3 vecEgde,vecEdgeNormal;
|
||||
float fHalfPlane;
|
||||
long pos=0,neg=0;
|
||||
vecEgde=poly[0]-poly[1];
|
||||
vecEdgeNormal=vecEgde^n;
|
||||
vecEdgeNormal.Normalize();
|
||||
fHalfPlane=(vecInterpos*vecEdgeNormal)-(poly[1]*vecEdgeNormal);
|
||||
if(fHalfPlane >= 0.001f)
|
||||
pos++;
|
||||
if(fHalfPlane <= -0.001f)
|
||||
neg++;
|
||||
vecEgde=poly[1]-poly[2];
|
||||
vecEdgeNormal=vecEgde^n;
|
||||
vecEdgeNormal.Normalize();
|
||||
fHalfPlane=(vecInterpos*vecEdgeNormal)-(poly[2]*vecEdgeNormal);
|
||||
|
||||
if(fHalfPlane >= 0.001f)
|
||||
pos++;
|
||||
if(fHalfPlane <= -0.001f)
|
||||
neg++;
|
||||
|
||||
vecEgde=poly[2]-poly[0];
|
||||
vecEdgeNormal=vecEgde^n;
|
||||
vecEdgeNormal.Normalize();
|
||||
fHalfPlane=(vecInterpos*vecEdgeNormal)-(poly[0]*vecEdgeNormal);
|
||||
|
||||
if(fHalfPlane >= 0.001f)
|
||||
pos++;
|
||||
if(fHalfPlane <= -0.001f)
|
||||
neg++;
|
||||
|
||||
if (!pos || !neg)
|
||||
return 1;
|
||||
return 0;
|
||||
|
||||
/*
|
||||
vecFactor[0]=(vecInterpos-poly[0]);vecFactor[0].Normalize();
|
||||
vecFactor[1]=(vecInterpos-poly[1]);vecFactor[1].Normalize();
|
||||
vecFactor[2]=(vecInterpos-poly[2]);vecFactor[2].Normalize();
|
||||
|
||||
fAngle[0]=vecFactor[0]*vecFactor[1];
|
||||
fAngle[1]=vecFactor[1]*vecFactor[2];
|
||||
fAngle[2]=vecFactor[2]*vecFactor[0];
|
||||
fAngle[0]=acosf(fAngle[0]);
|
||||
fAngle[1]=acosf(fAngle[1]);
|
||||
fAngle[2]=acosf(fAngle[2]);
|
||||
/*
|
||||
if( fAngle[0] == 3.14159f ||
|
||||
fAngle[1] == 3.14159f ||
|
||||
fAngle[2] == 3.14159f)
|
||||
return 0;
|
||||
|
||||
if(fAngle[0]+fAngle[1]+fAngle[2] >= (3.14159f)*1.7f)
|
||||
return 1;
|
||||
return 0;
|
||||
//*/
|
||||
}
|
||||
|
||||
int CIntersection::PolygonToPolygon(vector3 *vecPoly1, vector3 *vecPoly2)
|
||||
{
|
||||
vector3 vecPolyNormal1=(vecPoly1[1]-vecPoly1[0])^(vecPoly1[2]-vecPoly1[1]);
|
||||
vector3 vecPolyNormal2=(vecPoly2[1]-vecPoly2[0])^(vecPoly2[2]-vecPoly2[1]);
|
||||
vecPolyNormal1.Normalize();
|
||||
vecPolyNormal2.Normalize();
|
||||
|
||||
float fDistance[3];
|
||||
fDistance[0]= vecPolyNormal1*(vecPoly2[0]-vecPoly1[0]);
|
||||
fDistance[1]= vecPolyNormal1*(vecPoly2[1]-vecPoly1[0]);
|
||||
fDistance[2]= vecPolyNormal1*(vecPoly2[2]-vecPoly1[0]);
|
||||
if( (fDistance[0] > 0.0f && fDistance[1] > 0.0f && fDistance[2] > 0.0f) )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if( (fDistance[0] < 0.0f && fDistance[1] < 0.0f && fDistance[2] < 0.0f) )
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
|
||||
fDistance[0]= vecPolyNormal2*(vecPoly1[0]-vecPoly2[0]);
|
||||
fDistance[1]= vecPolyNormal2*(vecPoly1[1]-vecPoly2[0]);
|
||||
fDistance[2]= vecPolyNormal2*(vecPoly1[2]-vecPoly2[0]);
|
||||
|
||||
if( (fDistance[0] > 0.0f && fDistance[1] > 0.0f && fDistance[2] > 0.0f) ||
|
||||
(fDistance[0] < 0.0f && fDistance[1] < 0.0f && fDistance[2] < 0.0f))
|
||||
return 0;
|
||||
|
||||
float fIntersection;
|
||||
vector3 vecLens;
|
||||
if(PolygonRay(vecPoly2[0],vecPoly2[1],vecPoly1,fIntersection)==1)
|
||||
{
|
||||
vecLens=vecPoly2[0]-vecPoly2[1];
|
||||
if(vecLens.GetLens()>=fIntersection)
|
||||
return 1;
|
||||
}
|
||||
if(PolygonRay(vecPoly2[1],vecPoly2[2],vecPoly1,fIntersection)==1)
|
||||
{
|
||||
vecLens=vecPoly2[1]-vecPoly2[2];
|
||||
if(vecLens.GetLens()>=fIntersection)
|
||||
return 1;
|
||||
}
|
||||
if(PolygonRay(vecPoly2[2],vecPoly2[0],vecPoly1,fIntersection)==1)
|
||||
{
|
||||
vecLens=vecPoly2[2]-vecPoly2[0];
|
||||
if(vecLens.GetLens()>=fIntersection)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(PolygonRay(vecPoly1[0],vecPoly1[1],vecPoly2,fIntersection)==1)
|
||||
{
|
||||
vecLens=vecPoly1[0]-vecPoly1[1];
|
||||
if(vecLens.GetLens()>=fIntersection)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(PolygonRay(vecPoly1[1],vecPoly1[2],vecPoly2,fIntersection)==1)
|
||||
{
|
||||
vecLens=vecPoly1[1]-vecPoly1[2];
|
||||
if(vecLens.GetLens()>=fIntersection)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(PolygonRay(vecPoly1[2],vecPoly1[0],vecPoly2,fIntersection)==1)
|
||||
{
|
||||
vecLens=vecPoly1[2]-vecPoly1[0];
|
||||
if(vecLens.GetLens()>=fIntersection)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CIntersection::BoxToRay(vector3 vecStart, vector3 vecEnd, vector3 *poly[], float &fIntersection)
|
||||
{
|
||||
vector3 n=(*poly[1]-*poly[0])^(*poly[2]-*poly[0]);
|
||||
n.Normalize();
|
||||
vector3 vecDir=(vecEnd-vecStart);
|
||||
vecDir.Normalize();
|
||||
float h=( (n.x*poly[0]->x+n.y*poly[0]->y+n.z*poly[0]->z) - (n.x*vecStart.x+n.y*vecStart.y+n.z*vecStart.z) )
|
||||
/ (n.x*vecDir.x + n.y*vecDir.y + n.z*vecDir.z);
|
||||
fIntersection=h;
|
||||
if(h<0.0f)return 0;
|
||||
|
||||
vector3 vecInterpos=vecStart+vecDir*h;
|
||||
vector3 vecFactor[4];
|
||||
float fAngle[4];
|
||||
|
||||
vecFactor[0]=(vecInterpos-*poly[0]);vecFactor[0].Normalize();
|
||||
vecFactor[1]=(vecInterpos-*poly[1]);vecFactor[1].Normalize();
|
||||
vecFactor[2]=(vecInterpos-*poly[2]);vecFactor[2].Normalize();
|
||||
vecFactor[3]=(vecInterpos-*poly[3]);vecFactor[3].Normalize();
|
||||
|
||||
|
||||
fAngle[0]=vecFactor[0]*vecFactor[1];
|
||||
fAngle[1]=vecFactor[1]*vecFactor[2];
|
||||
fAngle[2]=vecFactor[2]*vecFactor[3];
|
||||
fAngle[3]=vecFactor[3]*vecFactor[0];
|
||||
fAngle[0]=acosf(fAngle[0]);
|
||||
fAngle[1]=acosf(fAngle[1]);
|
||||
fAngle[2]=acosf(fAngle[2]);
|
||||
fAngle[3]=acosf(fAngle[3]);
|
||||
|
||||
if( fAngle[0] == 3.14159f ||
|
||||
fAngle[1] == 3.14159f ||
|
||||
fAngle[2] == 3.14159f ||
|
||||
fAngle[3] == 3.14159f)
|
||||
return 0;
|
||||
if(fAngle[0]+fAngle[1]+fAngle[2]+fAngle[3] >= (3.14159f)*2.0f)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool CIntersection::PlanePoint(vector3 *pPlane, vector3 &vecPoint)
|
||||
{
|
||||
vector3 vecPolyNormal=(pPlane[1]-pPlane[0])^(pPlane[2]-pPlane[1]);
|
||||
|
||||
if(vecPolyNormal*(vecPoint-pPlane[0]) > 0.0f)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
int CIntersection::PolygonQuad(vector3 *vecPoly, vector3 *vecQuad)
|
||||
{
|
||||
vector3 vecPolyNormal1=(vecPoly[1]-vecPoly[0])^(vecPoly[2]-vecPoly[1]);
|
||||
vector3 vecPolyNormal2=(vecQuad[1]-vecQuad[0])^(vecQuad[2]-vecQuad[1]);
|
||||
vecPolyNormal1.Normalize();
|
||||
vecPolyNormal2.Normalize();
|
||||
|
||||
float fDistance[4];
|
||||
fDistance[0]= vecPolyNormal1*(vecQuad[0]-vecPoly[0]);
|
||||
fDistance[1]= vecPolyNormal1*(vecQuad[1]-vecPoly[0]);
|
||||
fDistance[2]= vecPolyNormal1*(vecQuad[2]-vecPoly[0]);
|
||||
fDistance[3]= vecPolyNormal1*(vecQuad[3]-vecPoly[0]);
|
||||
if( (fDistance[0] > 0.0f && fDistance[1] > 0.0f && fDistance[2] > 0.0f && fDistance[3] > 0.0f ) )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if( (fDistance[0] < 0.0f && fDistance[1] < 0.0f && fDistance[2] < 0.0f && fDistance[3] > 0.0f ) )
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
|
||||
fDistance[0]= vecPolyNormal2*(vecPoly[0]-vecQuad[0]);
|
||||
fDistance[1]= vecPolyNormal2*(vecPoly[1]-vecQuad[0]);
|
||||
fDistance[2]= vecPolyNormal2*(vecPoly[2]-vecQuad[0]);
|
||||
|
||||
if( (fDistance[0] > 0.0f && fDistance[1] > 0.0f && fDistance[2] > 0.0f) ||
|
||||
(fDistance[0] < 0.0f && fDistance[1] < 0.0f && fDistance[2] < 0.0f))
|
||||
return 0;
|
||||
|
||||
float fIntersection;
|
||||
vector3 vecLens;
|
||||
|
||||
if(BoxToRay(vecPoly[0],vecPoly[1],&vecQuad,fIntersection)==1)
|
||||
{
|
||||
vecLens=vecPoly[0]-vecPoly[1];
|
||||
if(vecLens.GetLens()>=fIntersection)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(BoxToRay(vecPoly[1],vecPoly[2],&vecQuad,fIntersection)==1)
|
||||
{
|
||||
vecLens=vecPoly[1]-vecPoly[2];
|
||||
if(vecLens.GetLens()>=fIntersection)
|
||||
return 1;
|
||||
}
|
||||
if(BoxToRay(vecPoly[2],vecPoly[0],&vecQuad,fIntersection)==1)
|
||||
{
|
||||
vecLens=vecPoly[2]-vecPoly[0];
|
||||
if(vecLens.GetLens()>=fIntersection)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
/*
|
||||
if(PolygonRay(*vecPoly2[2],*vecPoly2[0],vecPoly1,fIntersection)==1)
|
||||
{
|
||||
vecLens=*vecPoly2[2]-*vecPoly2[0];
|
||||
if(vecLens.GetLens()>=fIntersection)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(PolygonRay(*vecPoly1[0],*vecPoly1[1],vecPoly2,fIntersection)==1)
|
||||
{
|
||||
vecLens=*vecPoly1[0]-*vecPoly1[1];
|
||||
if(vecLens.GetLens()>=fIntersection)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(PolygonRay(*vecPoly1[1],*vecPoly1[2],vecPoly2,fIntersection)==1)
|
||||
{
|
||||
vecLens=*vecPoly1[1]-*vecPoly1[2];
|
||||
if(vecLens.GetLens()>=fIntersection)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(PolygonRay(*vecPoly1[2],*vecPoly1[0],vecPoly2,fIntersection)==1)
|
||||
{
|
||||
vecLens=*vecPoly1[2]-*vecPoly1[0];
|
||||
if(vecLens.GetLens()>=fIntersection)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
*/
|
||||
}
|
||||
|
||||
float CIntersection::PolygonRay2(vector3 vecStart, vector3 vecEnd, vector3 *poly,float &fInterLens)
|
||||
{
|
||||
vector3 n=(poly[1]-poly[0])^(poly[2]-poly[0]);
|
||||
n.Normalize();
|
||||
vector3 vecDir=(vecEnd-vecStart);
|
||||
vecDir.Normalize();
|
||||
float h=( (n.x*poly[0].x+n.y*poly[0].y+n.z*poly[0].z) - (n.x*vecStart.x+n.y*vecStart.y+n.z*vecStart.z) )
|
||||
/ (n.x*vecDir.x + n.y*vecDir.y + n.z*vecDir.z);
|
||||
fInterLens=h;
|
||||
if(h<0.0f)return 0;
|
||||
vector3 vecInter=vecEnd-vecStart;
|
||||
if(vecInter.GetLens() < h)
|
||||
return 0;
|
||||
|
||||
///*
|
||||
vector3 vecInterpos=vecStart+vecDir*h;
|
||||
vector3 vecFactor[3];
|
||||
float fAngle[3];
|
||||
|
||||
vecFactor[0]=(vecInterpos-poly[0]);vecFactor[0].Normalize();
|
||||
vecFactor[1]=(vecInterpos-poly[1]);vecFactor[1].Normalize();
|
||||
vecFactor[2]=(vecInterpos-poly[2]);vecFactor[2].Normalize();
|
||||
|
||||
fAngle[0]=vecFactor[0]*vecFactor[1];
|
||||
fAngle[1]=vecFactor[1]*vecFactor[2];
|
||||
fAngle[2]=vecFactor[2]*vecFactor[0];
|
||||
fAngle[0]=acosf(fAngle[0]);
|
||||
fAngle[1]=acosf(fAngle[1]);
|
||||
fAngle[2]=acosf(fAngle[2]);
|
||||
/*
|
||||
if( fAngle[0] == 3.14159f ||
|
||||
fAngle[1] == 3.14159f ||
|
||||
fAngle[2] == 3.14159f)
|
||||
return 0;
|
||||
*/
|
||||
return fAngle[0]+fAngle[1]+fAngle[2];
|
||||
}
|
||||
|
||||
int CIntersection::PlaneSphere(vector3 &vecLoc, float &fRad, vector3 *pPoly)
|
||||
{
|
||||
float x1,y1,z1,x2,y2,z2,x3,y3,z3;
|
||||
|
||||
float x4,y4,z4;
|
||||
|
||||
x1=pPoly[1].x-pPoly[0].x;
|
||||
y1=pPoly[1].y-pPoly[0].y;
|
||||
z1=pPoly[1].z-pPoly[0].z;
|
||||
|
||||
x2=pPoly[2].x-pPoly[1].x;
|
||||
y2=pPoly[2].y-pPoly[1].y;
|
||||
z2=pPoly[2].z-pPoly[1].z;
|
||||
|
||||
x3=y1*z2-z1*y2;
|
||||
y3=z1*x2-x1*z2;
|
||||
z3=x1*y2-y1*x2;
|
||||
|
||||
|
||||
float invMag=1.0f/CFastMath::FastSqrt(x3*x3+y3*y3+z3*z3);
|
||||
x3=x3*invMag;
|
||||
y3=y3*invMag;
|
||||
z3=z3*invMag;
|
||||
|
||||
x4=vecLoc.x-pPoly[0].x;
|
||||
y4=vecLoc.y-pPoly[0].y;
|
||||
z4=vecLoc.z-pPoly[0].z;
|
||||
|
||||
float fDistance=x3*x4+y3*y4+z3*z4;
|
||||
float fAbsDistance=fDistance>0.0f ? fDistance : -fDistance;
|
||||
if(fRad >= fAbsDistance)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(fDistance>0.0f)
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
/*
|
||||
vector3 vecPolyNormal=(pPoly[1]-pPoly[0])^(pPoly[2]-pPoly[1]);
|
||||
vecPolyNormal.Normalize();
|
||||
|
||||
float fDistance=vecPolyNormal*(vecLoc-pPoly[0]);
|
||||
float fAbsDis=fabs(fDistance);
|
||||
if(fRad >= fAbsDis)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(fDistance>=0.0f)
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
int CIntersection::SplitPolygonPolygon(vector3 *pPolySour, vector3 *pPolyDest, vector3 *pPolyResult)
|
||||
{
|
||||
vector3 vecPolySourNormal=(pPolySour[1]-pPolySour[0])^(pPolySour[2]-pPolySour[1]);
|
||||
vecPolySourNormal.Normalize();
|
||||
|
||||
float fDistance[3];
|
||||
fDistance[0]=vecPolySourNormal*(pPolyDest[0]-pPolySour[0]);
|
||||
fDistance[1]=vecPolySourNormal*(pPolyDest[1]-pPolySour[0]);
|
||||
fDistance[2]=vecPolySourNormal*(pPolyDest[2]-pPolySour[0]);
|
||||
|
||||
if( (fDistance[0] >= 0.0f && fDistance[1] >= 0.0f && fDistance[2] >= 0.0f) )
|
||||
{
|
||||
pPolyResult[0]=pPolyDest[0];
|
||||
pPolyResult[1]=pPolyDest[1];
|
||||
pPolyResult[2]=pPolyDest[2];
|
||||
return 1;
|
||||
}
|
||||
if( (fDistance[0] <= 0.0f && fDistance[1] <= 0.0f && fDistance[2] <= 0.0f) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
float fIntersect;
|
||||
vector3 vecFirstInter,vecSecondInter;
|
||||
int FrontVector[2]={-1,-1};
|
||||
int BackVector[2]={-1,-1};
|
||||
int cFront=0;
|
||||
int cBack=0;
|
||||
for(int i=0;i<3;i++)
|
||||
{
|
||||
if(fDistance[i] >= 0.0f)
|
||||
{
|
||||
FrontVector[cFront]=0;
|
||||
cFront++;
|
||||
}
|
||||
else
|
||||
{
|
||||
BackVector[cBack]=0;
|
||||
cBack++;
|
||||
}
|
||||
}
|
||||
|
||||
if(cFront==2)
|
||||
{
|
||||
PolygonRay(pPolyDest[FrontVector[0]],pPolyDest[BackVector[0]],pPolySour,fIntersect);
|
||||
vecFirstInter=pPolyDest[BackVector[0]]-pPolyDest[FrontVector[0]];
|
||||
vecFirstInter.Normalize();
|
||||
vecFirstInter=pPolyDest[FrontVector[0]]+vecFirstInter*fIntersect;
|
||||
|
||||
PolygonRay(pPolyDest[FrontVector[1]],pPolyDest[BackVector[0]],pPolySour,fIntersect);
|
||||
vecSecondInter=pPolyDest[BackVector[0]]-pPolyDest[FrontVector[1]];
|
||||
vecSecondInter.Normalize();
|
||||
vecSecondInter=pPolyDest[FrontVector[1]]+vecFirstInter*fIntersect;
|
||||
|
||||
pPolyResult[0]=pPolyDest[FrontVector[0]];
|
||||
pPolyResult[1]=vecFirstInter;
|
||||
pPolyResult[2]=vecSecondInter;
|
||||
|
||||
pPolyResult[3]=vecFirstInter;
|
||||
pPolyResult[4]=vecSecondInter;
|
||||
pPolyResult[5]=pPolyDest[FrontVector[1]];
|
||||
return 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
PolygonRay( pPolyDest[FrontVector[0]],pPolyDest[BackVector[0]],pPolySour,fIntersect);
|
||||
vecFirstInter=pPolyDest[BackVector[0]]-pPolyDest[FrontVector[0]];
|
||||
vecFirstInter.Normalize();
|
||||
vecFirstInter=pPolyDest[FrontVector[0]]+vecFirstInter*fIntersect;
|
||||
|
||||
PolygonRay( pPolyDest[FrontVector[0]],pPolyDest[BackVector[1]],pPolySour,fIntersect);
|
||||
vecSecondInter=pPolyDest[BackVector[0]]-pPolyDest[FrontVector[1]];
|
||||
vecSecondInter.Normalize();
|
||||
vecSecondInter=pPolyDest[FrontVector[0]]+vecFirstInter*fIntersect;
|
||||
|
||||
pPolyResult[0]=pPolyDest[FrontVector[0]];
|
||||
pPolyResult[1]=vecFirstInter;
|
||||
pPolyResult[2]=vecSecondInter;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
/*
|
||||
float fIntersect;
|
||||
vector3 vecFirstInter,vecSecondInter;
|
||||
if( fDistance[0]==0.0f)
|
||||
{
|
||||
if(fDistance[1] > 0.0f)
|
||||
{
|
||||
PolygonRay(pPolyDest[1],pPolyDest[2],&pPolySour,fIntersect);
|
||||
vecFirstInter=pPolyDest[2]-pPolyDest[1];
|
||||
vecFirstInter.Normalize();
|
||||
vecFirstInter=pPolyDest[1]+vecFirstInter*fIntersect;
|
||||
pPolyResult[0]=pPolyDest[0];
|
||||
pPolyResult[1]=pPolyDest[1];
|
||||
pPolyResult[2]=vecFirstInter;
|
||||
}
|
||||
else
|
||||
{
|
||||
PolygonRay(pPolyDest[2],pPolyDest[1],&pPolySour,fIntersect);
|
||||
vecFirstInter=pPolyDest[1]-pPolyDest[2];
|
||||
vecFirstInter.Normalize();
|
||||
vecFirstInter=pPolyDest[2]+vecFirstInter*fIntersect;
|
||||
pPolyResult[0]=pPolyDest[0];
|
||||
pPolyResult[1]=vecFirstInter;
|
||||
pPolyResult[2]=pPolyDest[2];
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
if( fDistance[1]==0.0f)
|
||||
{
|
||||
if(fDistance[2] > 0.0f)
|
||||
{
|
||||
PolygonRay(pPolyDest[2],pPolyDest[0],&pPolySour,fIntersect);
|
||||
vecFirstInter=pPolyDest[0]-pPolyDest[2];
|
||||
vecFirstInter.Normalize();
|
||||
vecFirstInter=pPolyDest[2]+vecFirstInter*fIntersect;
|
||||
pPolyResult[0]=pPolyDest[1];
|
||||
pPolyResult[1]=vecFirstInter;
|
||||
pPolyResult[2]=pPolyDest[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
PolygonRay(pPolyDest[0],pPolyDest[2],&pPolySour,fIntersect);
|
||||
vecFirstInter=pPolyDest[2]-pPolyDest[0];
|
||||
vecFirstInter.Normalize();
|
||||
vecFirstInter=pPolyDest[0]+vecFirstInter*fIntersect;
|
||||
pPolyResult[0]=pPolyDest[1];
|
||||
pPolyResult[1]=vecFirstInter;
|
||||
pPolyResult[2]=pPolyDest[0];
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
if( fDistance[2]==0.0f)
|
||||
{
|
||||
if(fDistance[0] > 0.0f)
|
||||
{
|
||||
PolygonRay(pPolyDest[0],pPolyDest[1],&pPolySour,fIntersect);
|
||||
vecFirstInter=pPolyDest[1]-pPolyDest[0];
|
||||
vecFirstInter.Normalize();
|
||||
vecFirstInter=pPolyDest[0]+vecFirstInter*fIntersect;
|
||||
pPolyResult[0]=pPolyDest[2];
|
||||
pPolyResult[1]=vecFirstInter;
|
||||
pPolyResult[2]=pPolyDest[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
PolygonRay(pPolyDest[1],pPolyDest[0],&pPolySour,fIntersect);
|
||||
vecFirstInter=pPolyDest[0]-pPolyDest[1];
|
||||
vecFirstInter.Normalize();
|
||||
vecFirstInter=pPolyDest[1]+vecFirstInter*fIntersect;
|
||||
pPolyResult[0]=pPolyDest[2];
|
||||
pPolyResult[1]=pPolyDest[0];
|
||||
pPolyResult[2]=vecFirstInter;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(
|
||||
*/
|
||||
}
|
||||
// return-value 0 is not intersect
|
||||
// return-value 1 is Sphere in polygon
|
||||
// return-value 2 is
|
||||
int CIntersection::PolygonSphere(vector3 &vecCenter, float fRad, vector3 *pPoly,vector3 *vecIntersect,int &cIntersect)
|
||||
{
|
||||
vector3 vecPolyNormal=(pPoly[1]-pPoly[0])^(pPoly[2]-pPoly[1]);
|
||||
vecPolyNormal.Normalize();
|
||||
|
||||
float fDistance=vecPolyNormal*(vecCenter-pPoly[0]);
|
||||
float fAbsDis=fabs(fDistance);
|
||||
vector3 vecPolyInter;
|
||||
|
||||
if(fRad >= fAbsDis)
|
||||
{
|
||||
vecPolyNormal=-vecPolyNormal;
|
||||
float fInter;
|
||||
///*
|
||||
if(PolygonRay(vecCenter,vecCenter+vecPolyNormal*fRad,pPoly,fInter)==1)
|
||||
{
|
||||
*vecIntersect=vecCenter+vecPolyNormal*fInter;
|
||||
vecIntersect++;
|
||||
cIntersect++;
|
||||
return 3;
|
||||
}
|
||||
//*/
|
||||
/*
|
||||
if(PolygonRay(vecCenter,vecCenter+vector3(0.0f,-1.0f,0.0f)*fRad*10.0f,pTestPoly,fInter)==1)
|
||||
{
|
||||
//if(vecPolyNormal.y > 0.2f )
|
||||
{
|
||||
*vecIntersect=vecCenter+vecPolyNormal*fInter;
|
||||
vecIntersect++;
|
||||
cIntersect++;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
*/
|
||||
/*
|
||||
vecPolyInter=pPoly[0]-vecCenter;
|
||||
if(vecPolyInter.GetLens() <= fRad)
|
||||
{
|
||||
*vecIntersect=pPoly[0];
|
||||
vecIntersect++;
|
||||
cIntersect++;
|
||||
return 1;
|
||||
}
|
||||
|
||||
vecPolyInter=pPoly[1]-vecCenter;
|
||||
if(vecPolyInter.GetLens() <= fRad)
|
||||
{
|
||||
*vecIntersect=pPoly[1];
|
||||
vecIntersect++;
|
||||
cIntersect++;
|
||||
return 1;
|
||||
}
|
||||
vecPolyInter=pPoly[2]-vecCenter;
|
||||
if(vecPolyInter.GetLens() <= fRad)
|
||||
{
|
||||
*vecIntersect=pPoly[2];
|
||||
vecIntersect++;
|
||||
cIntersect++;
|
||||
return 1;
|
||||
}
|
||||
|
||||
float fMaxInter=0.0f;
|
||||
float b,c;
|
||||
float fInterD=0;
|
||||
vector3 vecOriginCenter;
|
||||
|
||||
vecPolyInter=pPoly[1]-pPoly[0];
|
||||
fMaxInter=vecPolyInter.GetLens();
|
||||
vecPolyInter.Normalize();
|
||||
|
||||
vecOriginCenter=pPoly[0]-vecCenter;
|
||||
b=vecPolyInter*(vecOriginCenter);
|
||||
c=vecOriginCenter*vecOriginCenter-(fRad*fRad);
|
||||
if((b*b-c)>0.0f)
|
||||
{
|
||||
fInterD=-b-sqrtf(b*b-c);
|
||||
if(fInterD >= 0.0f && fInterD <= fMaxInter)
|
||||
{
|
||||
*vecIntersect=pPoly[0]+fInterD*vecPolyInter;
|
||||
vecIntersect++;
|
||||
cIntersect++;
|
||||
}
|
||||
fInterD=-b+sqrtf(b*b-c);
|
||||
if(fInterD >= 0.0f && fInterD <= fMaxInter)
|
||||
{
|
||||
*vecIntersect=pPoly[0]+fInterD*vecPolyInter;
|
||||
vecIntersect++;
|
||||
cIntersect++;
|
||||
}
|
||||
}
|
||||
|
||||
vecPolyInter=pPoly[2]-pPoly[1];
|
||||
fMaxInter=vecPolyInter.GetLens();
|
||||
vecPolyInter.Normalize();
|
||||
|
||||
vecOriginCenter=pPoly[1]-vecCenter;
|
||||
b=vecPolyInter*(vecOriginCenter);
|
||||
c=vecOriginCenter*vecOriginCenter-(fRad*fRad);
|
||||
if((b*b-c)>0.0f)
|
||||
{
|
||||
fInterD=-b-sqrtf(b*b-c);
|
||||
if(fInterD >= 0.0f && fInterD <= fMaxInter)
|
||||
{
|
||||
*vecIntersect=pPoly[1]+fInterD*vecPolyInter;
|
||||
vecIntersect++;
|
||||
cIntersect++;
|
||||
}
|
||||
fInterD=-b+sqrtf(b*b-c);
|
||||
if(fInterD >= 0.0f && fInterD <= fMaxInter)
|
||||
{
|
||||
*vecIntersect=pPoly[1]+fInterD*vecPolyInter;
|
||||
vecIntersect++;
|
||||
cIntersect++;
|
||||
}
|
||||
}
|
||||
|
||||
vecPolyInter=pPoly[0]-pPoly[2];
|
||||
fMaxInter=vecPolyInter.GetLens();
|
||||
vecPolyInter.Normalize();
|
||||
|
||||
vecOriginCenter=pPoly[2]-vecCenter;
|
||||
b=vecPolyInter*(vecOriginCenter);
|
||||
c=vecOriginCenter*vecOriginCenter-(fRad*fRad);
|
||||
if((b*b-c)>0.0f)
|
||||
{
|
||||
fInterD=-b-sqrtf(b*b-c);
|
||||
if(fInterD >= 0.0f && fInterD <= fMaxInter)
|
||||
{
|
||||
*vecIntersect=pPoly[2]+fInterD*vecPolyInter;
|
||||
vecIntersect++;
|
||||
cIntersect++;
|
||||
}
|
||||
fInterD=-b+sqrtf(b*b-c);
|
||||
if(fInterD >= 0.0f && fInterD <= fMaxInter)
|
||||
{
|
||||
*vecIntersect=pPoly[2]+fInterD*vecPolyInter;
|
||||
vecIntersect++;
|
||||
cIntersect++;
|
||||
}
|
||||
}
|
||||
if(cIntersect!=0)
|
||||
return 2;
|
||||
|
||||
if(PolygonRay(vecCenter,vecCenter+vecPolyNormal*fRad,pTestPoly,fInter)==1)
|
||||
{
|
||||
*vecIntersect=vecCenter+vecPolyNormal*fInter;
|
||||
vecIntersect++;
|
||||
cIntersect++;
|
||||
return 3;
|
||||
}
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
float CIntersection::PlaneAABBBox(vector3 *vecPlane, vector3 &vecNormal, vector3 &vecMaxBox, vector3 &vecMinBox)
|
||||
{
|
||||
vector3 vecNearPoint;
|
||||
if(vecNormal.x > 0.0f)
|
||||
{
|
||||
if(vecNormal.y > 0.0f)
|
||||
{
|
||||
if(vecNormal.z > 0.0f)
|
||||
{
|
||||
vecNearPoint.x=vecMinBox.x;vecNearPoint.y=vecMinBox.y;vecNearPoint.z=vecMinBox.z;
|
||||
}
|
||||
else
|
||||
{
|
||||
vecNearPoint.x=vecMinBox.x;vecNearPoint.y=vecMinBox.y;vecNearPoint.z=vecMaxBox.z;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(vecNormal.z > 0.0f)
|
||||
{
|
||||
vecNearPoint.x=vecMinBox.x;vecNearPoint.y=vecMaxBox.y;vecNearPoint.z=vecMinBox.z;
|
||||
}
|
||||
else
|
||||
{
|
||||
vecNearPoint.x=vecMinBox.x;vecNearPoint.y=vecMaxBox.y;vecNearPoint.z=vecMaxBox.z;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(vecNormal.y > 0.0f)
|
||||
{
|
||||
if(vecNormal.z > 0.0f)
|
||||
{
|
||||
vecNearPoint.x=vecMaxBox.x;vecNearPoint.y=vecMinBox.y;vecNearPoint.z=vecMinBox.z;
|
||||
}
|
||||
else
|
||||
{
|
||||
vecNearPoint.x=vecMaxBox.x;vecNearPoint.y=vecMinBox.y;vecNearPoint.z=vecMaxBox.z;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(vecNormal.z > 0.0f)
|
||||
{
|
||||
vecNearPoint.x=vecMaxBox.x;vecNearPoint.y=vecMaxBox.y;vecNearPoint.z=vecMinBox.z;
|
||||
}
|
||||
else
|
||||
{
|
||||
vecNearPoint.x=vecMaxBox.x;vecNearPoint.y=vecMaxBox.y;vecNearPoint.z=vecMaxBox.z;
|
||||
}
|
||||
}
|
||||
}
|
||||
return vecNormal*(vecNearPoint-vecPlane[0]);
|
||||
}
|
||||
|
||||
float CIntersection::PointFromPlane(vector3 *pPlane, vector3 &vecPoint)
|
||||
{
|
||||
vector3 vecPolyNormal=(pPlane[1]-pPlane[0])^(pPlane[2]-pPlane[1]);
|
||||
vecPolyNormal.Normalize();
|
||||
|
||||
return vecPolyNormal*(vecPoint-pPlane[0]);
|
||||
}
|
||||
|
||||
float CIntersection::PointFromPlane(vector3 &pNormal, vector3 &pPlaneOrigin, vector3 &vecPoint)
|
||||
{
|
||||
return pNormal*(vecPoint-pPlaneOrigin);
|
||||
}
|
||||
|
||||
int CIntersection::PlaneSphereNormal(vector3 &vecPos, float &fRad, vector3 &vecNormal, vector3 &vecPoly)
|
||||
{
|
||||
float x4,y4,z4;
|
||||
x4=vecPos.x-vecPoly.x;
|
||||
y4=vecPos.y-vecPoly.y;
|
||||
z4=vecPos.z-vecPoly.z;
|
||||
|
||||
float fDistance=vecNormal.x*x4+vecNormal.y*y4+vecNormal.z*z4;
|
||||
|
||||
float fAbsDistance=fDistance>0.0f ? fDistance : -fDistance;
|
||||
if(fRad >= fAbsDistance)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(fDistance>0.0f)
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
34
Engine/Zalla3D Base Class/Intersection.h
Normal file
34
Engine/Zalla3D Base Class/Intersection.h
Normal file
@@ -0,0 +1,34 @@
|
||||
// Intersection.h: interface for the CIntersection class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_INTERSECTION_H__2C579563_8B13_41AA_BD24_5DF348664376__INCLUDED_)
|
||||
#define AFX_INTERSECTION_H__2C579563_8B13_41AA_BD24_5DF348664376__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
#include "3DMath.h"
|
||||
|
||||
|
||||
class CIntersection
|
||||
{
|
||||
public:
|
||||
static int PlaneSphereNormal(vector3 &vecPos,float &fRad,vector3 &vecNormal,vector3 &vecPoly);
|
||||
static float PointFromPlane(vector3 &pNormal,vector3 &pPlaneOrigin,vector3 &vecPoint);
|
||||
static float PointFromPlane(vector3 *pPlane,vector3 &vecPoint);
|
||||
static float PlaneAABBBox(vector3 *vecPlane,vector3 &vecNormal,vector3 &vecMaxBox,vector3 &vecMinBox);
|
||||
static int PolygonSphere(vector3 &vecCenter,float fRad,vector3 *pPoly,vector3 *vecIntersect,int &cIntersect);
|
||||
static int SplitPolygonPolygon(vector3 *pPolySour,vector3 *pPolyDest,vector3 *pPolyResult);
|
||||
static int PlaneSphere(vector3 &vecLoc,float &fRad,vector3 *pPoly);
|
||||
static float PolygonRay2(vector3 vecStart, vector3 vecEnd, vector3 *poly,float &fInterLens);
|
||||
static int PolygonQuad(vector3 *vecPoly,vector3 *vecQuad);
|
||||
static bool PlanePoint(vector3 *pPlane,vector3 &vecPoint);
|
||||
static int BoxToRay(vector3 vecStart,vector3 vecEnd,vector3 *poly[4],float &fIntersection);
|
||||
static int PolygonToPolygon(vector3 *vecPoly1,vector3 *vecPoly2);
|
||||
static int PolygonRay(vector3 vecStart, vector3 vecEnd, vector3 *poly,float &fInterLens);
|
||||
CIntersection();
|
||||
virtual ~CIntersection();
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_INTERSECTION_H__2C579563_8B13_41AA_BD24_5DF348664376__INCLUDED_)
|
||||
11
Engine/Zalla3D Base Class/MathBase.h
Normal file
11
Engine/Zalla3D Base Class/MathBase.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#ifndef _MATHBASE_H
|
||||
#define _MATHBASE_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#define EPSILON 0.04f
|
||||
typedef unsigned char COLORVALUE;
|
||||
|
||||
#endif
|
||||
272
Engine/Zalla3D Base Class/NTexture.cpp
Normal file
272
Engine/Zalla3D Base Class/NTexture.cpp
Normal file
@@ -0,0 +1,272 @@
|
||||
#include ".\ntexture.h"
|
||||
#include <d3dx8.h>
|
||||
#include "./GraphicLayerError.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
namespace CROSSM {
|
||||
|
||||
char CNTexture::m_strPath[256];
|
||||
LPDIRECT3DDEVICE8 CNTexture::ms_pd3dDevice = NULL;
|
||||
int CNTexture::m_SkipMipLevel=0;
|
||||
|
||||
IDirect3DTexture8* CNTexture::ms_pNullTexture = NULL;
|
||||
bool CNTexture::ms_bNullTextureMode = false;
|
||||
|
||||
|
||||
void CNTexture::Init(LPDIRECT3DDEVICE8 lpDevice)
|
||||
{
|
||||
ms_pd3dDevice = lpDevice;
|
||||
ms_pd3dDevice->AddRef();
|
||||
|
||||
// create 1x1 texture
|
||||
if (FAILED(ms_pd3dDevice->CreateTexture(1, 1, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &ms_pNullTexture)))
|
||||
{
|
||||
ms_pd3dDevice->Release();
|
||||
}
|
||||
D3DLOCKED_RECT lr;
|
||||
ms_pNullTexture->LockRect(0, &lr, NULL, 0);
|
||||
*((D3DCOLOR*)(lr.pBits)) = D3DCOLOR_ARGB(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
ms_pNullTexture->UnlockRect(0);
|
||||
|
||||
ms_bNullTextureMode = false;
|
||||
}
|
||||
|
||||
|
||||
void CNTexture::Close()
|
||||
{
|
||||
if (NULL != ms_pNullTexture)
|
||||
{
|
||||
ms_pNullTexture->Release();
|
||||
ms_pNullTexture = NULL;
|
||||
}
|
||||
|
||||
if (NULL != ms_pd3dDevice)
|
||||
{
|
||||
ms_pd3dDevice->Release();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CNTexture::CNTexture(void) :m_pddTexture(NULL), m_bInterface(false)
|
||||
{
|
||||
m_dwWidth = m_dwHeight = 0;
|
||||
m_bCreateEmpty = false;
|
||||
|
||||
}
|
||||
|
||||
CNTexture::~CNTexture(void)
|
||||
{
|
||||
if(m_pddTexture)
|
||||
{
|
||||
SafeRelease(m_pddTexture);
|
||||
m_pddTexture =NULL;
|
||||
}
|
||||
}
|
||||
bool CNTexture::Load()
|
||||
{
|
||||
DDS_HEADER ddsh;
|
||||
|
||||
if(strstr(m_strPath,"Interface")==0)
|
||||
{
|
||||
m_bInterface = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bInterface = true;
|
||||
}
|
||||
|
||||
if(m_bInterface)
|
||||
{
|
||||
if(!m_pByteDataObj)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// magic header(ignore)
|
||||
m_pByteDataObj->Read(&m_dwValue[0],sizeof(DWORD),1);
|
||||
// DDS HEADER
|
||||
m_pByteDataObj->Read(&ddsh,sizeof(ddsh),1);
|
||||
|
||||
m_dwWidth=ddsh.dwWidth;
|
||||
m_dwHeight=ddsh.dwHeight;
|
||||
// num mip
|
||||
m_dwValue[0] = (ddsh.dwMipMapCount == 0) ? 1 : ddsh.dwMipMapCount;
|
||||
// depth
|
||||
m_dwValue[1] = (ddsh.dwHeaderFlags & DDS_HEADER_FLAGS_VOLUME) ? ddsh.dwDepth : 0;
|
||||
|
||||
if (ddsh.ddspf.dwFourCC == D3DFMT_DXT1)
|
||||
m_fmt = D3DFMT_DXT1;
|
||||
else if (ddsh.ddspf.dwFourCC == D3DFMT_DXT2)
|
||||
m_fmt = D3DFMT_DXT2;
|
||||
else if (ddsh.ddspf.dwFourCC == D3DFMT_DXT3)
|
||||
m_fmt = D3DFMT_DXT3;
|
||||
else if (ddsh.ddspf.dwFourCC == D3DFMT_DXT4)
|
||||
m_fmt = D3DFMT_DXT4;
|
||||
else if (ddsh.ddspf.dwFourCC == D3DFMT_DXT5)
|
||||
m_fmt = D3DFMT_DXT5;
|
||||
else if (ddsh.ddspf.dwFlags == DDS_RGBA && ddsh.ddspf.dwRGBBitCount == 32 && ddsh.ddspf.dwABitMask == 0xff000000)
|
||||
m_fmt = D3DFMT_A8R8G8B8;
|
||||
else if (ddsh.ddspf.dwFlags == DDS_RGB && ddsh.ddspf.dwRGBBitCount == 24)
|
||||
m_fmt = D3DFMT_R8G8B8;
|
||||
else if (ddsh.ddspf.dwFlags == DDS_RGB && ddsh.ddspf.dwRGBBitCount == 16 && ddsh.ddspf.dwGBitMask == 0x000007e0)
|
||||
m_fmt = D3DFMT_R5G6B5;
|
||||
else if (ddsh.ddspf.dwFlags == DDS_RGBA && ddsh.ddspf.dwRGBBitCount == 16 && ddsh.ddspf.dwABitMask == 0x00008000)
|
||||
m_fmt = D3DFMT_A1R5G5B5;
|
||||
else if (ddsh.ddspf.dwFlags == DDS_RGBA && ddsh.ddspf.dwRGBBitCount == 16 && ddsh.ddspf.dwABitMask == 0x0000f000)
|
||||
m_fmt = D3DFMT_A4R4G4B4;
|
||||
else
|
||||
return false;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
bool CNTexture::Unload()
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
bool CNTexture::PostLoad()
|
||||
{
|
||||
if(!m_pByteDataObj)
|
||||
return false;
|
||||
|
||||
LPDIRECT3DTEXTURE8 pmiptex = NULL;
|
||||
|
||||
if(!m_bInterface)
|
||||
{
|
||||
DWORD dwMagic=MAKEFOURCC('D','D','S',' ');
|
||||
DWORD *pHeader = NULL;
|
||||
pHeader = (DWORD *)m_pByteDataObj->GetReadPtr();
|
||||
|
||||
if(pHeader == NULL)
|
||||
return false;
|
||||
|
||||
*pHeader = dwMagic;
|
||||
|
||||
HRESULT hr=D3DXCreateTextureFromFileInMemory(ms_pd3dDevice,pHeader,m_pByteDataObj->GetByteSize(),&pmiptex);
|
||||
if(hr != D3D_OK)
|
||||
{
|
||||
printf("");
|
||||
}
|
||||
if(pmiptex == NULL)
|
||||
{
|
||||
printf("");
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (FAILED(ms_pd3dDevice->CreateTexture(m_dwWidth>>m_SkipMipLevel, m_dwHeight>>m_SkipMipLevel, m_dwValue[0]-m_SkipMipLevel, 0, m_fmt, D3DPOOL_MANAGED, &pmiptex)))
|
||||
{
|
||||
CGraphicLayerError("CTexture:ReadDDSTexture , CreateTexture is failed");
|
||||
}
|
||||
if (FAILED(LoadAllMipSurfaces(pmiptex, m_dwValue[0])))
|
||||
{
|
||||
MessageBox(NULL,"LoadAllMipSurface Load Failed",0,0);
|
||||
CGraphicLayerError("CTexture:ReadDDSTexture , LoadAllMipSurfaces is failed");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
m_pddTexture = pmiptex;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
HRESULT CNTexture::LoadAllMipSurfaces(LPDIRECT3DBASETEXTURE8 ptex, long numMips)
|
||||
{
|
||||
HRESULT hr;
|
||||
LPDIRECT3DSURFACE8 psurf;
|
||||
D3DSURFACE_DESC sd;
|
||||
D3DLOCKED_RECT lr;
|
||||
LPDIRECT3DTEXTURE8 pmiptex = NULL;
|
||||
DWORD dwBytesPerRow;
|
||||
|
||||
|
||||
pmiptex = (LPDIRECT3DTEXTURE8)ptex;
|
||||
|
||||
long iLevel;
|
||||
for (iLevel = 0; iLevel < numMips; iLevel++)
|
||||
{
|
||||
if (pmiptex != NULL)
|
||||
hr = pmiptex->GetSurfaceLevel(iLevel-m_SkipMipLevel, &psurf);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
psurf->GetDesc(&sd);
|
||||
switch (sd.Format)
|
||||
{
|
||||
case D3DFMT_DXT1:
|
||||
case D3DFMT_DXT2:
|
||||
case D3DFMT_DXT3:
|
||||
case D3DFMT_DXT4:
|
||||
case D3DFMT_DXT5:
|
||||
dwBytesPerRow = 0; // magic value indicates texture's memory is contiguous
|
||||
break;
|
||||
case D3DFMT_A8R8G8B8:
|
||||
dwBytesPerRow = 4 * sd.Width;
|
||||
break;
|
||||
case D3DFMT_R8G8B8:
|
||||
dwBytesPerRow = 3 * sd.Width;
|
||||
break;
|
||||
case D3DFMT_A1R5G5B5:
|
||||
case D3DFMT_A4R4G4B4:
|
||||
case D3DFMT_R5G6B5:
|
||||
dwBytesPerRow = 2 * sd.Width;
|
||||
break;
|
||||
default:
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if (pmiptex != NULL)
|
||||
hr = pmiptex->LockRect(iLevel, &lr, NULL, 0);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
if (dwBytesPerRow == 0)
|
||||
{
|
||||
//fread(lr.pBits,sd.Size,1,fp);
|
||||
m_pByteDataObj->Read(lr.pBits,sd.Size,1);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
DWORD yp;
|
||||
BYTE* pbDest = (BYTE*)lr.pBits;
|
||||
for (yp = 0; yp < sd.Height; yp++)
|
||||
{
|
||||
//fread(pbDest,dwBytesPerRow,1,fp);
|
||||
m_pByteDataObj->Read(pbDest,dwBytesPerRow,1);
|
||||
|
||||
pbDest += lr.Pitch;
|
||||
}
|
||||
}
|
||||
|
||||
if (pmiptex != NULL)
|
||||
hr = pmiptex->UnlockRect(iLevel);
|
||||
ReleasePpo(&psurf);
|
||||
}
|
||||
return S_OK;
|
||||
|
||||
|
||||
}
|
||||
|
||||
LPDIRECT3DBASETEXTURE8 CNTexture::GetTexture()
|
||||
{
|
||||
if (ms_bNullTextureMode)
|
||||
{
|
||||
return ms_pNullTexture;
|
||||
}
|
||||
|
||||
return m_pddTexture;
|
||||
}
|
||||
|
||||
|
||||
void CNTexture::NullTextureMode(bool bNullTexture)
|
||||
{
|
||||
ms_bNullTextureMode = bNullTexture;
|
||||
}
|
||||
|
||||
}
|
||||
66
Engine/Zalla3D Base Class/NTexture.h
Normal file
66
Engine/Zalla3D Base Class/NTexture.h
Normal file
@@ -0,0 +1,66 @@
|
||||
#pragma once
|
||||
#include "./CrossMHeader.h"
|
||||
#include "./resourceobj.h"
|
||||
#include "./dds.h"
|
||||
|
||||
#include <d3d8.h>
|
||||
|
||||
#ifndef ReleasePpo
|
||||
#define ReleasePpo(ppo) \
|
||||
if (*(ppo) != NULL) \
|
||||
{ \
|
||||
(*(ppo))->Release(); \
|
||||
*(ppo) = NULL; \
|
||||
} \
|
||||
else (VOID)0
|
||||
#endif
|
||||
|
||||
namespace CROSSM {
|
||||
class CNTexture :
|
||||
public CResourceObj
|
||||
{
|
||||
public:
|
||||
CNTexture(void);
|
||||
virtual ~CNTexture(void);
|
||||
virtual bool Load();
|
||||
virtual bool Unload();
|
||||
virtual bool PostLoad();
|
||||
|
||||
LPDIRECT3DBASETEXTURE8 GetTexture();
|
||||
HRESULT LoadAllMipSurfaces(LPDIRECT3DBASETEXTURE8 ptex, long numMips);
|
||||
|
||||
static void SetPath(char *strPath){strcpy(m_strPath,strPath);};
|
||||
static const char* GetPath(){ return m_strPath; };
|
||||
|
||||
static void Init(LPDIRECT3DDEVICE8 lpDevice);
|
||||
static void Close();
|
||||
|
||||
static void NullTextureMode(bool bNullTexture);
|
||||
|
||||
|
||||
protected:
|
||||
static char m_strPath[256];
|
||||
bool m_bCreateEmpty;
|
||||
DWORD m_stage;
|
||||
|
||||
DWORD m_dwValue[2]; // 0 : NumMip, 1 : Depth
|
||||
D3DFORMAT m_fmt;
|
||||
bool m_bInterface;
|
||||
|
||||
public:
|
||||
static LPDIRECT3DDEVICE8 ms_pd3dDevice;
|
||||
|
||||
static int m_SkipMipLevel;
|
||||
|
||||
// char m_strName[TEXTURENAMEBUFFER];
|
||||
long m_dwWidth,m_dwHeight;
|
||||
|
||||
|
||||
private:
|
||||
LPDIRECT3DBASETEXTURE8 m_pddTexture;
|
||||
|
||||
static IDirect3DTexture8* ms_pNullTexture;
|
||||
static bool ms_bNullTextureMode;
|
||||
};
|
||||
|
||||
}
|
||||
101
Engine/Zalla3D Base Class/Pool.cpp
Normal file
101
Engine/Zalla3D Base Class/Pool.cpp
Normal file
@@ -0,0 +1,101 @@
|
||||
#include ".\pool.h"
|
||||
#include "./PoolMgr.h"
|
||||
#include "./Z3DByteDataObj.h"
|
||||
#include "./NTexture.h"
|
||||
#include "./ResourceMgr.h"
|
||||
#include "../zalla3d scene class/NMesh.h"
|
||||
#include "../zalla3d scene class/HouseObjectScene.h"
|
||||
#include "../zalla3d scene class/HouseObject.h"
|
||||
#include "../zalla3d scene class/ObjectScene.h"
|
||||
#include "../zalla3d scene class/OctreeScene.h"
|
||||
#include "../zalla3d scene class/Octree.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
|
||||
|
||||
namespace CROSSM {
|
||||
CPool::CPool(void)
|
||||
{
|
||||
}
|
||||
|
||||
CPool::~CPool(void)
|
||||
{
|
||||
ReleaseAllData();
|
||||
}
|
||||
void CPool::AddPool(int iType,IPoolMgr *pMgr)
|
||||
{
|
||||
POOLTABLEITER itr = m_PoolMap.find(iType);
|
||||
if(itr == m_PoolMap.end())
|
||||
{
|
||||
m_PoolMap.insert(POOLTABLEOBJ(iType,pMgr));
|
||||
|
||||
}
|
||||
}
|
||||
void CPool::Init()
|
||||
{
|
||||
|
||||
// AddPool(POOL_BYTEDATAOBJ,new CPoolMgr<CZ3DByteDataObj>);
|
||||
// AddPool(POOL_DELRESOURCEINFOOBJ,new CPoolMgr<CDelResourceInfo>);
|
||||
// AddPool(POOL_RESOURCEMGROBJ,new CPoolMgr<CResourceMgrObj>);
|
||||
// AddPool(POOL_HOUSEOBJSCENE,new CPoolMgr<CHouseObjectScene>);
|
||||
// AddPool(POOL_HOUSEOBJ,new CPoolMgr<CHouseObject>);
|
||||
// AddPool(POOL_OBJECTSCENE,new CPoolMgr<CObjectScene>);
|
||||
// AddPool(POOL_OCTREEOBJ,new CPoolMgr<COctree>);
|
||||
// AddPool(POOL_POLYNODE,new CPoolMgr<PolyNode>);
|
||||
AddPool(RESOURCE_TEXTURE,new CPoolMgr<CNTexture>);
|
||||
AddPool(RESOURCE_MESH,new CPoolMgr<CNMesh>);
|
||||
AddPool(RESOURCE_OCTREESCENE,new CPoolMgr<COctreeScene>);
|
||||
|
||||
}
|
||||
|
||||
void CPool::Release()
|
||||
{
|
||||
|
||||
}
|
||||
void CPool::ReleaseAllData()
|
||||
{
|
||||
for(POOLTABLEITER itr = m_PoolMap.begin(); itr != m_PoolMap.end();)
|
||||
{
|
||||
if(itr->second != NULL)
|
||||
{
|
||||
itr->second->ReleaseAll();
|
||||
SafeDelete(itr->second);
|
||||
itr->second = NULL;
|
||||
}
|
||||
itr++;
|
||||
}
|
||||
m_PoolMap.clear();
|
||||
|
||||
}
|
||||
void CPool::ReleaseObj(int iType,void *pObj)
|
||||
{
|
||||
if(pObj)
|
||||
{
|
||||
POOLTABLEITER itr = m_PoolMap.find(iType);
|
||||
if(itr != m_PoolMap.end())
|
||||
{
|
||||
if(itr->second)
|
||||
{
|
||||
itr->second->ReleaseObj(pObj);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
void *CPool::GetObj(int iType)
|
||||
{
|
||||
POOLTABLEITER itr = m_PoolMap.find(iType);
|
||||
if(itr != m_PoolMap.end())
|
||||
{
|
||||
if(itr->second)
|
||||
{
|
||||
return itr->second->GetObj();
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
35
Engine/Zalla3D Base Class/Pool.h
Normal file
35
Engine/Zalla3D Base Class/Pool.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "./CrossMHeader.h"
|
||||
#include "./IPoolMgr.h"
|
||||
|
||||
namespace CROSSM {
|
||||
|
||||
typedef std::map<int ,IPoolMgr *> POOLTABLE;
|
||||
typedef POOLTABLE::iterator POOLTABLEITER;
|
||||
typedef POOLTABLE::value_type POOLTABLEOBJ;
|
||||
|
||||
|
||||
class CPool
|
||||
{
|
||||
public:
|
||||
CPool(void);
|
||||
~CPool(void);
|
||||
void Init();
|
||||
|
||||
void Release();
|
||||
void ReleaseObj(int iType,void *pObj);
|
||||
void ReleaseAllData();
|
||||
void *GetObj(int iType);
|
||||
|
||||
void AddPool(int iType,IPoolMgr *pMgr);
|
||||
|
||||
protected:
|
||||
POOLTABLE m_PoolMap;
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
40
Engine/Zalla3D Base Class/PoolMgr.h
Normal file
40
Engine/Zalla3D Base Class/PoolMgr.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
#include "ipoolmgr.h"
|
||||
#include "./boost/pool/pool.hpp"
|
||||
#include "./boost/pool/object_pool.hpp"
|
||||
|
||||
namespace CROSSM {
|
||||
template <class T>
|
||||
class CPoolMgr : public IPoolMgr
|
||||
{
|
||||
public:
|
||||
CPoolMgr(void)
|
||||
{
|
||||
}
|
||||
virtual ~CPoolMgr(void)
|
||||
{
|
||||
}
|
||||
virtual void ReleaseAll()
|
||||
{
|
||||
}
|
||||
virtual void *GetObj()
|
||||
{
|
||||
T *pObj = m_BoostPool.construct();
|
||||
if(pObj == NULL)
|
||||
MessageBox(NULL,"tt","tt",MB_OK);
|
||||
return pObj;
|
||||
}
|
||||
virtual void ReleaseObj(void *pObj)
|
||||
{
|
||||
if(pObj)
|
||||
{
|
||||
m_BoostPool.destroy((T *)pObj);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
boost::object_pool<T> m_BoostPool;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
21
Engine/Zalla3D Base Class/ReadMe.txt
Normal file
21
Engine/Zalla3D Base Class/ReadMe.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
========================================================================
|
||||
<20><><EFBFBD><EFBFBD> <20><><EFBFBD>̺귯<CCBA><EAB7AF> : Zalla3D Base Class <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD><EFBFBD>
|
||||
========================================================================
|
||||
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>翡<EFBFBD><E7BFA1> <20><> Zalla3D Base Class <20><><EFBFBD>̺귯<CCBA><EAB7AF> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>.
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʾҽ<CABE><D2BD>ϴ<EFBFBD>.
|
||||
|
||||
|
||||
Zalla3D Base Class.vcproj
|
||||
<20><><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>縦 <20><><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> VC++ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20>⺻ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD><EFBFBD><EFBFBD>Դϴ<D4B4>.
|
||||
<20>ش<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Visual C++<2B><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD>
|
||||
<20><><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>翡<EFBFBD><E7BFA1> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>÷<EFBFBD><C3B7><EFBFBD>, <20><><EFBFBD><EFBFBD> <20><>
|
||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD>ɿ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ֽ<EFBFBD><D6BD>ϴ<EFBFBD>.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
<EFBFBD><EFBFBD>Ÿ <20><><EFBFBD><EFBFBD>:
|
||||
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>翡<EFBFBD><E7BFA1> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> "TODO:" <20>ּ<EFBFBD><D6BC><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ڰ<EFBFBD> <20>߰<EFBFBD><DFB0>ϰų<CFB0> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD> <20>ϴ<EFBFBD>
|
||||
<EFBFBD>ҽ<EFBFBD> <20>ڵ<EFBFBD> <20>κ<EFBFBD><CEBA><EFBFBD> <20><>Ÿ<EFBFBD><C5B8><EFBFBD>ϴ<EFBFBD>.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
25
Engine/Zalla3D Base Class/RenderDevice.cpp
Normal file
25
Engine/Zalla3D Base Class/RenderDevice.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
// RenderDevice.cpp: implementation of the CRenderDevice class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RenderDevice.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CRenderDevice::CRenderDevice()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CRenderDevice::~CRenderDevice()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CRenderDevice::Init(LPDIRECT3DDEVICE8 pd3dDevice)
|
||||
{
|
||||
|
||||
}
|
||||
32
Engine/Zalla3D Base Class/RenderDevice.h
Normal file
32
Engine/Zalla3D Base Class/RenderDevice.h
Normal file
@@ -0,0 +1,32 @@
|
||||
// RenderDevice.h: interface for the CRenderDevice class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_RENDERDEVICE_H__30AB566D_E435_4433_A0C2_7491B2733FB3__INCLUDED_)
|
||||
#define AFX_RENDERDEVICE_H__30AB566D_E435_4433_A0C2_7491B2733FB3__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include <d3d8.h>
|
||||
#include "3DMath.h"
|
||||
|
||||
enum RenderState
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
class CRenderDevice
|
||||
{
|
||||
LPDIRECT3DDEVICE8 m_pd3dDevice;
|
||||
public:
|
||||
matrix m_matWorld[4],m_matView,m_matProj;
|
||||
LPDIRECT3DDEVICE8 GetDeivce(){return m_pd3dDevice;};
|
||||
void Init(LPDIRECT3DDEVICE8 pd3dDevice);
|
||||
CRenderDevice();
|
||||
virtual ~CRenderDevice();
|
||||
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_RENDERDEVICE_H__30AB566D_E435_4433_A0C2_7491B2733FB3__INCLUDED_)
|
||||
307
Engine/Zalla3D Base Class/RenderEnvTexture.cpp
Normal file
307
Engine/Zalla3D Base Class/RenderEnvTexture.cpp
Normal file
@@ -0,0 +1,307 @@
|
||||
// RenderEnvTexture.cpp: implementation of the CRenderEnvTexture class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//#include "DXUtil.h"
|
||||
#include "RenderEnvTexture.h"
|
||||
#include "BaseGraphicsLayer.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define CUBEMAP_RESOLUTION 256
|
||||
|
||||
|
||||
////////<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>~
|
||||
D3DXMATRIX D3DUtil_GetCubeMapViewMatrix( DWORD dwFace )
|
||||
{
|
||||
D3DXVECTOR3 vEyePt = D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
|
||||
D3DXVECTOR3 vLookDir;
|
||||
D3DXVECTOR3 vUpDir;
|
||||
|
||||
switch( dwFace )
|
||||
{
|
||||
case D3DCUBEMAP_FACE_POSITIVE_X:
|
||||
vLookDir = D3DXVECTOR3( 1.0f, 0.0f, 0.0f );
|
||||
vUpDir = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
|
||||
break;
|
||||
case D3DCUBEMAP_FACE_NEGATIVE_X:
|
||||
vLookDir = D3DXVECTOR3(-1.0f, 0.0f, 0.0f );
|
||||
vUpDir = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
|
||||
break;
|
||||
case D3DCUBEMAP_FACE_POSITIVE_Y:
|
||||
vLookDir = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
|
||||
vUpDir = D3DXVECTOR3( 0.0f, 0.0f,-1.0f );
|
||||
break;
|
||||
case D3DCUBEMAP_FACE_NEGATIVE_Y:
|
||||
vLookDir = D3DXVECTOR3( 0.0f,-1.0f, 0.0f );
|
||||
vUpDir = D3DXVECTOR3( 0.0f, 0.0f, 1.0f );
|
||||
break;
|
||||
case D3DCUBEMAP_FACE_POSITIVE_Z:
|
||||
vLookDir = D3DXVECTOR3( 0.0f, 0.0f, 1.0f );
|
||||
vUpDir = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
|
||||
break;
|
||||
case D3DCUBEMAP_FACE_NEGATIVE_Z:
|
||||
vLookDir = D3DXVECTOR3( 0.0f, 0.0f,-1.0f );
|
||||
vUpDir = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
|
||||
break;
|
||||
}
|
||||
|
||||
// Set the view transform for this cubemap surface
|
||||
D3DXMATRIX matView;
|
||||
D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookDir, &vUpDir );
|
||||
return matView;
|
||||
}
|
||||
|
||||
CRenderEnvTexture::CRenderEnvTexture()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CRenderEnvTexture::~CRenderEnvTexture()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CRenderEnvTexture::RenderCubeMap(LPDIRECT3DDEVICE8 pd3dDevice)
|
||||
{
|
||||
/////////<2F><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!!!!!!!!!!!!!!///////////////
|
||||
HRESULT hr;
|
||||
|
||||
// Set the projection matrix for a field of view of 90 degrees
|
||||
D3DXMATRIX matProj;
|
||||
D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/2.0f , 1.0f, 1.0f, 100.0f );
|
||||
|
||||
D3DXMATRIX matOldView,matOldProjection;
|
||||
|
||||
pd3dDevice->GetTransform(D3DTS_VIEW,&matOldView);
|
||||
pd3dDevice->GetTransform(D3DTS_PROJECTION,&matOldProjection);
|
||||
|
||||
// Get the current view matrix, to concat it with the cubemap view vectors
|
||||
D3DXMATRIX matViewDir( matOldView);
|
||||
matViewDir._41 = 0.0f; matViewDir._42 = 0.0f; matViewDir._43 = 0.0f;
|
||||
|
||||
// Render the six cube faces into the environment map
|
||||
if(m_bCube)
|
||||
hr = m_pRenderToEnvMap->BeginCube( m_pCubeMap );
|
||||
else
|
||||
hr = m_pRenderToEnvMap->BeginSphere( m_pSphereMap );
|
||||
|
||||
pd3dDevice->SetRenderState( D3DRS_ZFUNC, D3DCMP_ALWAYS );
|
||||
|
||||
for( UINT i = 0; i < 6; i++ )
|
||||
{
|
||||
m_pRenderToEnvMap->Face( (D3DCUBEMAP_FACES) i );
|
||||
|
||||
// Set the view transform for this cubemap surface
|
||||
D3DXMATRIX matView;
|
||||
matView = D3DUtil_GetCubeMapViewMatrix( (D3DCUBEMAP_FACES) i );
|
||||
D3DXMatrixMultiply( &matView, &matViewDir, &matView );
|
||||
|
||||
//D3DXMatrixMultiply( &matView, &matView,&matViewDir);
|
||||
|
||||
// Render the scene (except for the teapot)
|
||||
//RenderScene( &matView, &matProj, FALSE );
|
||||
pd3dDevice->SetTransform(D3DTS_VIEW,&matView);
|
||||
pd3dDevice->SetTransform(D3DTS_PROJECTION,&matProj);
|
||||
switch(i)
|
||||
{
|
||||
case 0:
|
||||
pd3dDevice->Clear( 0, NULL, D3DCLEAR_ZBUFFER|D3DCLEAR_TARGET, 0xff000000, 1.0f, 0 );
|
||||
//RenderSkymap(pd3dDevice);
|
||||
break;
|
||||
case 1:
|
||||
pd3dDevice->Clear( 0, NULL, D3DCLEAR_ZBUFFER|D3DCLEAR_TARGET, 0xff000000, 1.0f, 0 );
|
||||
//RenderSkymap(pd3dDevice);
|
||||
break;
|
||||
case 2:
|
||||
pd3dDevice->Clear( 0, NULL, D3DCLEAR_ZBUFFER|D3DCLEAR_TARGET, 0xff000000, 1.0f, 0 );
|
||||
break;
|
||||
case 3:
|
||||
pd3dDevice->Clear( 0, NULL, D3DCLEAR_ZBUFFER|D3DCLEAR_TARGET, 0xff000000, 1.0f, 0 );
|
||||
break;
|
||||
|
||||
case 4:
|
||||
pd3dDevice->Clear( 0, NULL, D3DCLEAR_ZBUFFER|D3DCLEAR_TARGET, 0xff000000, 1.0f, 0 );
|
||||
//RenderSkymap(pd3dDevice);
|
||||
break;
|
||||
case 5:
|
||||
pd3dDevice->Clear( 0, NULL, D3DCLEAR_ZBUFFER|D3DCLEAR_TARGET, 0xff000000, 1.0f, 0 );
|
||||
//RenderSkymap(pd3dDevice);
|
||||
break;
|
||||
}
|
||||
RenderSkymap(pd3dDevice);
|
||||
}
|
||||
|
||||
pd3dDevice->SetRenderState( D3DRS_ZFUNC, D3DCMP_LESSEQUAL );
|
||||
|
||||
m_pRenderToEnvMap->End();
|
||||
|
||||
pd3dDevice->SetTransform(D3DTS_VIEW,&matOldView);
|
||||
pd3dDevice->SetTransform(D3DTS_PROJECTION,&matOldProjection);
|
||||
}
|
||||
|
||||
void CRenderEnvTexture::RenderSkymap(LPDIRECT3DDEVICE8 pd3dDevice)
|
||||
{
|
||||
//D3DXMATRIX matWorld;
|
||||
//D3DXMatrixScaling( &matWorld, 1.0f, 1.0f, 1.0f );
|
||||
|
||||
matrix matWorld;
|
||||
matWorld.MakeIdent();
|
||||
pd3dDevice->SetTransform(D3DTS_WORLD,matWorld);
|
||||
|
||||
pd3dDevice->SetRenderState(D3DRS_CULLMODE,D3DCULL_NONE);
|
||||
|
||||
//pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
|
||||
|
||||
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
|
||||
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
|
||||
pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
|
||||
pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
|
||||
pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSU, D3DTADDRESS_MIRROR );
|
||||
pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSV, D3DTADDRESS_MIRROR );
|
||||
|
||||
// Always pass Z-test, so we can avoid clearing color and depth buffers
|
||||
//pd3dDevice->SetRenderState( D3DRS_ZFUNC, D3DCMP_ALWAYS );
|
||||
////////////////////
|
||||
/////Render Sky Box/
|
||||
////////////////////
|
||||
|
||||
|
||||
float fSize=10.0f;
|
||||
LVertex Vertex[4];
|
||||
WORD Indices[6];
|
||||
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
||||
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
|
||||
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
||||
pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE);
|
||||
|
||||
pd3dDevice->SetTextureStageState(0, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP);
|
||||
pd3dDevice->SetTextureStageState(0, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP);
|
||||
|
||||
pd3dDevice->SetTexture(1,NULL);
|
||||
|
||||
pd3dDevice->SetRenderState( D3DRS_LIGHTING,FALSE);
|
||||
pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE,FALSE);
|
||||
pd3dDevice->SetRenderState( D3DRS_FOGENABLE,FALSE);
|
||||
|
||||
Indices[0]=0;
|
||||
Indices[1]=2;
|
||||
Indices[2]=1;
|
||||
Indices[3]=0;
|
||||
Indices[4]=3;
|
||||
Indices[5]=2;
|
||||
|
||||
Vertex[0].v=vector3(-fSize,-fSize,fSize);
|
||||
Vertex[0].tu=0.0f;
|
||||
Vertex[0].tv=1.0f;
|
||||
Vertex[1].v=vector3(fSize,-fSize,fSize);
|
||||
Vertex[1].tu=1.0f;
|
||||
Vertex[1].tv=1.0f;
|
||||
Vertex[2].v=vector3(fSize,-fSize,-fSize);
|
||||
Vertex[2].tu=1.0f;
|
||||
Vertex[2].tv=0.0f;
|
||||
Vertex[3].v=vector3(-fSize,-fSize,-fSize);
|
||||
Vertex[3].tu=0.0f;
|
||||
Vertex[3].tv=0.0f;
|
||||
|
||||
Vertex[0].diff.c=Vertex[1].diff.c=Vertex[2].diff.c=Vertex[3].diff.c=0xffffffff;
|
||||
|
||||
pd3dDevice->SetVertexShader(LVERTEXFVF);
|
||||
pd3dDevice->SetTexture(0,m_SkyTexture[4].GetTexture());
|
||||
pd3dDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST,
|
||||
0,4,2,Indices,D3DFMT_INDEX16,Vertex, sizeof(LVertex));
|
||||
|
||||
Vertex[0].v=vector3(-fSize,-fSize,fSize);
|
||||
Vertex[0].tu=0.0;
|
||||
Vertex[0].tv=1.0;
|
||||
|
||||
|
||||
Vertex[1].v=vector3(fSize,-fSize,fSize);
|
||||
Vertex[1].tu=1.0;
|
||||
Vertex[1].tv=1.0;
|
||||
|
||||
Vertex[2].v=vector3(fSize,fSize,fSize);
|
||||
Vertex[2].tu=1.0;
|
||||
Vertex[2].tv=0.0;
|
||||
|
||||
Vertex[3].v=vector3(-fSize,fSize,fSize);
|
||||
Vertex[3].tu=0.0;
|
||||
Vertex[3].tv=0.0;
|
||||
|
||||
pd3dDevice->SetTexture(0,m_SkyTexture[0].GetTexture());
|
||||
|
||||
|
||||
|
||||
pd3dDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST,
|
||||
0,4,2,Indices,D3DFMT_INDEX16,Vertex, sizeof(LVertex));
|
||||
|
||||
Vertex[0].v=vector3(fSize,-fSize,fSize);
|
||||
Vertex[1].v=vector3(fSize,-fSize,-fSize);
|
||||
Vertex[2].v=vector3(fSize,fSize,-fSize);
|
||||
Vertex[3].v=vector3(fSize,fSize,fSize);
|
||||
|
||||
Vertex[0].diff.c=Vertex[1].diff.c=Vertex[2].diff.c=Vertex[3].diff.c=0xffff0000;
|
||||
pd3dDevice->SetTexture(0,m_SkyTexture[1].GetTexture());
|
||||
|
||||
pd3dDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST,
|
||||
0,4,2,Indices,D3DFMT_INDEX16,Vertex, sizeof(LVertex));
|
||||
|
||||
|
||||
Vertex[0].v=vector3(fSize,-fSize,-fSize);
|
||||
Vertex[1].v=vector3(-fSize,-fSize,-fSize);
|
||||
Vertex[2].v=vector3(-fSize,fSize,-fSize);
|
||||
Vertex[3].v=vector3(fSize,fSize,-fSize);
|
||||
|
||||
Vertex[0].diff.c=Vertex[1].diff.c=Vertex[2].diff.c=Vertex[3].diff.c=0xffffff00;
|
||||
pd3dDevice->SetTexture(0,m_SkyTexture[2].GetTexture());
|
||||
|
||||
|
||||
pd3dDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST,
|
||||
0,4,2,Indices,D3DFMT_INDEX16,Vertex, sizeof(LVertex));
|
||||
|
||||
Vertex[0].v=vector3(-fSize,-fSize,-fSize);
|
||||
Vertex[1].v=vector3(-fSize,-fSize,fSize);
|
||||
Vertex[2].v=vector3(-fSize,fSize,fSize);
|
||||
Vertex[3].v=vector3(-fSize,fSize,-fSize);
|
||||
Vertex[0].diff.c=Vertex[1].diff.c=Vertex[2].diff.c=Vertex[3].diff.c=0xff0000ff;
|
||||
pd3dDevice->SetTexture(0,m_SkyTexture[3].GetTexture());
|
||||
|
||||
pd3dDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST,
|
||||
0,4,2,Indices,D3DFMT_INDEX16,Vertex, sizeof(LVertex));
|
||||
|
||||
pd3dDevice->SetTextureStageState(0, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
|
||||
pd3dDevice->SetTextureStageState(0, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
|
||||
pd3dDevice->SetRenderState( D3DRS_FOGENABLE,TRUE);
|
||||
|
||||
pd3dDevice->SetRenderState(D3DRS_CULLMODE,D3DCULL_CCW);
|
||||
//pd3dDevice->SetRenderState( D3DRS_ZFUNC, D3DCMP_LESSEQUAL );
|
||||
}
|
||||
|
||||
void CRenderEnvTexture::Create(LPDIRECT3DDEVICE8 pd3dDevice,char strSkyTexturename[256],char strTexturePath[256],bool bCube)
|
||||
{
|
||||
D3DDISPLAYMODE mode;
|
||||
BaseGraphicsLayer::GetDevice()->GetDisplayMode(&mode);
|
||||
m_bCube=bCube;
|
||||
|
||||
D3DXCreateRenderToEnvMap(pd3dDevice,CUBEMAP_RESOLUTION,mode.Format,TRUE,D3DFMT_D16,&m_pRenderToEnvMap);
|
||||
|
||||
if(m_bCube)
|
||||
{
|
||||
D3DXCreateCubeTexture(pd3dDevice,CUBEMAP_RESOLUTION,1,D3DUSAGE_RENDERTARGET,mode.Format,D3DPOOL_DEFAULT,&m_pCubeMap);
|
||||
}
|
||||
else
|
||||
{
|
||||
D3DXCreateTexture(pd3dDevice,CUBEMAP_RESOLUTION,CUBEMAP_RESOLUTION,1,D3DUSAGE_RENDERTARGET,mode.Format,D3DPOOL_DEFAULT,&m_pSphereMap);
|
||||
}
|
||||
|
||||
CTexture::SetPath(strTexturePath);
|
||||
|
||||
char strTextureName[256];
|
||||
for(int i=1;i<6;i++)
|
||||
{
|
||||
sprintf(strTextureName,"%s%d.dds",strSkyTexturename,i);
|
||||
m_SkyTexture[i-1].Load(strTextureName);
|
||||
}
|
||||
|
||||
}
|
||||
38
Engine/Zalla3D Base Class/RenderEnvTexture.h
Normal file
38
Engine/Zalla3D Base Class/RenderEnvTexture.h
Normal file
@@ -0,0 +1,38 @@
|
||||
// RenderEnvTexture.h: interface for the CRenderEnvTexture class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_RENDERENVTEXTURE_H__39EF09BE_861F_466D_9D47_63BFFE575865__INCLUDED_)
|
||||
#define AFX_RENDERENVTEXTURE_H__39EF09BE_861F_466D_9D47_63BFFE575865__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include <D3DX8.h>
|
||||
#include "Vertex.h"
|
||||
#include "Texture.h"
|
||||
|
||||
class CRenderEnvTexture
|
||||
{
|
||||
ID3DXRenderToEnvMap* m_pRenderToEnvMap;
|
||||
CTexture m_SkyTexture[6];
|
||||
bool m_bCube;
|
||||
public:
|
||||
IDirect3DCubeTexture8* m_pCubeMap;
|
||||
IDirect3DTexture8* m_pSphereMap;
|
||||
void Create(LPDIRECT3DDEVICE8 pd3dDevice,char strSkyTexturename[256],char strTexturePath[256],bool bCube=true);
|
||||
void RenderSkymap(LPDIRECT3DDEVICE8 pd3dDevice);
|
||||
void RenderCubeMap(LPDIRECT3DDEVICE8 pd3dDevice);
|
||||
LPDIRECT3DBASETEXTURE8 GetTexture()
|
||||
{
|
||||
if(m_bCube)
|
||||
return (LPDIRECT3DBASETEXTURE8)m_pCubeMap;
|
||||
return (LPDIRECT3DBASETEXTURE8)m_pSphereMap;
|
||||
};
|
||||
CRenderEnvTexture();
|
||||
virtual ~CRenderEnvTexture();
|
||||
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_RENDERENVTEXTURE_H__39EF09BE_861F_466D_9D47_63BFFE575865__INCLUDED_)
|
||||
43
Engine/Zalla3D Base Class/RenderTargetTexture.cpp
Normal file
43
Engine/Zalla3D Base Class/RenderTargetTexture.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
// RenderTargetTexture.cpp: implementation of the CRenderTargetTexture class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RenderTargetTexture.h"
|
||||
#include "BaseGraphicsLayer.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
LPDIRECT3DTEXTURE8 CRenderTargetTexture::m_pTexture;
|
||||
|
||||
CRenderTargetTexture::CRenderTargetTexture()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CRenderTargetTexture::~CRenderTargetTexture()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CRenderTargetTexture::Create(LPDIRECT3DDEVICE8 pd3dDevice,int nSizeX,int nSizeY)
|
||||
{
|
||||
pd3dDevice->CreateTexture(nSizeX,nSizeY,1,0,BaseGraphicsLayer::m_d3dpp.BackBufferFormat,D3DPOOL_DEFAULT,&m_pTexture);
|
||||
}
|
||||
|
||||
LPDIRECT3DTEXTURE8 CRenderTargetTexture::GetTexture(LPDIRECT3DDEVICE8 pd3dDevice,RECT rcCopy)
|
||||
{
|
||||
LPDIRECT3DSURFACE8 pSurface;
|
||||
m_pTexture->GetSurfaceLevel(0,&pSurface);
|
||||
|
||||
LPDIRECT3DSURFACE8 pBackBuffer;
|
||||
pd3dDevice->GetBackBuffer(0,D3DBACKBUFFER_TYPE_MONO,&pBackBuffer);
|
||||
|
||||
POINT pt={0,0};
|
||||
pd3dDevice->CopyRects(pBackBuffer,&rcCopy,1,pSurface,&pt);
|
||||
pSurface->Release();
|
||||
pBackBuffer->Release();
|
||||
|
||||
return m_pTexture;
|
||||
}
|
||||
25
Engine/Zalla3D Base Class/RenderTargetTexture.h
Normal file
25
Engine/Zalla3D Base Class/RenderTargetTexture.h
Normal file
@@ -0,0 +1,25 @@
|
||||
// RenderTargetTexture.h: interface for the CRenderTargetTexture class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_RENDERTARGETTEXTURE_H__2704A75E_C01D_4D6D_86C0_08F1D6E224AB__INCLUDED_)
|
||||
#define AFX_RENDERTARGETTEXTURE_H__2704A75E_C01D_4D6D_86C0_08F1D6E224AB__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include <d3d8.h>
|
||||
|
||||
class CRenderTargetTexture
|
||||
{
|
||||
static LPDIRECT3DTEXTURE8 m_pTexture;
|
||||
public:
|
||||
static LPDIRECT3DTEXTURE8 GetTexture(LPDIRECT3DDEVICE8 pd3dDevice,RECT rcCopy);
|
||||
static void Create(LPDIRECT3DDEVICE8 pd3dDevice,int nSizeX,int nSizeY);
|
||||
CRenderTargetTexture();
|
||||
virtual ~CRenderTargetTexture();
|
||||
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_RENDERTARGETTEXTURE_H__2704A75E_C01D_4D6D_86C0_08F1D6E224AB__INCLUDED_)
|
||||
102
Engine/Zalla3D Base Class/RenderTexture.cpp
Normal file
102
Engine/Zalla3D Base Class/RenderTexture.cpp
Normal file
@@ -0,0 +1,102 @@
|
||||
// RenderTexture.cpp: implementation of the CRenderTexture class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RenderTexture.h"
|
||||
|
||||
#include "BaseGraphicsLayer.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
LPDIRECT3DSURFACE8 CRenderTexture::m_pRenderZBuffer;
|
||||
LPDIRECT3DTEXTURE8 CRenderTexture::m_pCopyLockTexture;
|
||||
LPDIRECT3DSURFACE8 CRenderTexture::m_pCopyLockSurface;
|
||||
|
||||
CRenderTexture::CRenderTexture()
|
||||
{
|
||||
m_pRenderTexture=NULL;
|
||||
m_pRenderSurface=NULL;
|
||||
}
|
||||
|
||||
CRenderTexture::~CRenderTexture()
|
||||
{
|
||||
if(m_pRenderTexture)
|
||||
m_pRenderTexture->Release();
|
||||
if(m_pRenderSurface)
|
||||
m_pRenderSurface->Release();
|
||||
if(m_pRenderZBuffer)
|
||||
{
|
||||
m_pRenderZBuffer->Release();
|
||||
m_pRenderZBuffer=NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void CRenderTexture::Create(long SizeX,long SizeY)
|
||||
{
|
||||
if(SizeX==0 || SizeY==0)
|
||||
return;
|
||||
//D3DDISPLAYMODE mode;
|
||||
//BaseGraphicsLayer::GetDevice()->GetDisplayMode(&mode);
|
||||
BaseGraphicsLayer::GetDevice()->CreateTexture(SizeX,SizeY,1,D3DUSAGE_RENDERTARGET,BaseGraphicsLayer::m_d3dpp.BackBufferFormat,D3DPOOL_DEFAULT,&m_pRenderTexture);
|
||||
if(m_pRenderTexture==NULL)
|
||||
{
|
||||
SizeX=0;
|
||||
SizeY=0;
|
||||
return;
|
||||
}
|
||||
m_pRenderTexture->GetSurfaceLevel(0, &m_pRenderSurface);
|
||||
|
||||
if(m_pRenderZBuffer==NULL)
|
||||
{
|
||||
BaseGraphicsLayer::GetDevice()->CreateDepthStencilSurface(SizeX,SizeY,BaseGraphicsLayer::m_d3dpp.AutoDepthStencilFormat,D3DMULTISAMPLE_NONE,&m_pRenderZBuffer);
|
||||
BaseGraphicsLayer::GetDevice()->CreateTexture(SizeX,SizeY,1,0,BaseGraphicsLayer::m_d3dpp.BackBufferFormat,D3DPOOL_MANAGED,&m_pCopyLockTexture);
|
||||
m_pCopyLockTexture->GetSurfaceLevel(0,&m_pCopyLockSurface);
|
||||
}
|
||||
}
|
||||
|
||||
void CRenderTexture::Begin(LPDIRECT3DDEVICE8 pd3dDevice)
|
||||
{
|
||||
pd3dDevice->GetRenderTarget(&m_pTempRenderSurface);
|
||||
pd3dDevice->GetDepthStencilSurface(&m_pTempRenderZBuffer);
|
||||
pd3dDevice->GetViewport(&m_pTempViewPort);
|
||||
|
||||
pd3dDevice->SetRenderTarget(m_pRenderSurface,m_pRenderZBuffer);
|
||||
//pd3dDevice->SetRenderTarget(m_pRenderSurface,m_pTempRenderZBuffer);
|
||||
|
||||
}
|
||||
|
||||
void CRenderTexture::End(LPDIRECT3DDEVICE8 pd3dDevice)
|
||||
{
|
||||
pd3dDevice->SetRenderTarget(m_pTempRenderSurface,m_pTempRenderZBuffer);
|
||||
m_pTempRenderSurface->Release();
|
||||
m_pTempRenderZBuffer->Release();
|
||||
pd3dDevice->SetViewport(&m_pTempViewPort);
|
||||
//pd3dDevice->GetViewport(&m_pTempViewPort);
|
||||
}
|
||||
|
||||
void* CRenderTexture::Lock()
|
||||
{
|
||||
D3DLOCKED_RECT pRect;
|
||||
//m_pRenderTexture->LockRect(0,&pRect,NULL,D3DLOCK_READONLY);
|
||||
D3DDISPLAYMODE mode;
|
||||
BaseGraphicsLayer::GetDevice()->GetDisplayMode(&mode);
|
||||
RECT rect;
|
||||
rect.left=0;
|
||||
rect.right=256;
|
||||
rect.top=0;
|
||||
rect.bottom=256;
|
||||
POINT pt;
|
||||
pt.x=0;
|
||||
pt.y=0;
|
||||
BaseGraphicsLayer::GetDevice()->CopyRects(m_pRenderSurface,&rect,1,m_pCopyLockSurface,&pt);
|
||||
m_pCopyLockSurface->LockRect(&pRect,NULL,D3DLOCK_READONLY);
|
||||
return pRect.pBits;
|
||||
//return (void*)
|
||||
}
|
||||
|
||||
void CRenderTexture::Unlock()
|
||||
{
|
||||
m_pCopyLockSurface->UnlockRect();
|
||||
}
|
||||
39
Engine/Zalla3D Base Class/RenderTexture.h
Normal file
39
Engine/Zalla3D Base Class/RenderTexture.h
Normal file
@@ -0,0 +1,39 @@
|
||||
// RenderTexture.h: interface for the CRenderTexture class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_RENDERTEXTURE_H__0EC50F46_F5C3_4873_AC41_9702AF503767__INCLUDED_)
|
||||
#define AFX_RENDERTEXTURE_H__0EC50F46_F5C3_4873_AC41_9702AF503767__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include <d3dx8.h>
|
||||
|
||||
class CRenderTexture
|
||||
{
|
||||
LPDIRECT3DTEXTURE8 m_pRenderTexture;
|
||||
LPDIRECT3DSURFACE8 m_pRenderSurface;
|
||||
static LPDIRECT3DSURFACE8 m_pRenderZBuffer;
|
||||
|
||||
static LPDIRECT3DTEXTURE8 m_pCopyLockTexture;
|
||||
static LPDIRECT3DSURFACE8 m_pCopyLockSurface;
|
||||
|
||||
LPDIRECT3DSURFACE8 m_pTempRenderSurface;
|
||||
LPDIRECT3DSURFACE8 m_pTempRenderZBuffer;
|
||||
D3DVIEWPORT8 m_pTempViewPort;
|
||||
public:
|
||||
void Unlock();
|
||||
void* Lock();
|
||||
void Begin(LPDIRECT3DDEVICE8 pd3dDevice);
|
||||
void End(LPDIRECT3DDEVICE8 pd3dDevice);
|
||||
LPDIRECT3DTEXTURE8 GetTexture(){return m_pRenderTexture;};
|
||||
LPDIRECT3DSURFACE8 GetSurface(){return m_pRenderSurface;};
|
||||
long m_SizeX,m_Sizey;
|
||||
void Create(long SizeX,long SizeY);
|
||||
CRenderTexture();
|
||||
virtual ~CRenderTexture();
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_RENDERTEXTURE_H__0EC50F46_F5C3_4873_AC41_9702AF503767__INCLUDED_)
|
||||
169
Engine/Zalla3D Base Class/RenderTextureMipmap.cpp
Normal file
169
Engine/Zalla3D Base Class/RenderTextureMipmap.cpp
Normal file
@@ -0,0 +1,169 @@
|
||||
// RenderTextureMipmap.cpp: implementation of the CRenderTextureMipmap class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "BaseGraphicsLayer.h"
|
||||
#include "RenderTextureMipmap.h"
|
||||
#include "Vertex.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CRenderTextureMipmap::CRenderTextureMipmap()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CRenderTextureMipmap::~CRenderTextureMipmap()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CRenderTextureMipmap::Create(int nSizeX, int nSizeY)
|
||||
{
|
||||
D3DDISPLAYMODE mode;
|
||||
BaseGraphicsLayer::GetDevice()->GetDisplayMode(&mode);
|
||||
//BaseGraphicsLayer::GetDevice()->CreateTexture(SizeX,SizeY,1,D3DUSAGE_RENDERTARGET,mode.Format,D3DPOOL_DEFAULT,&m_pRenderTexture);
|
||||
//m_pRenderTexture->GetSurfaceLevel(0, &m_pRenderSurface);
|
||||
BaseGraphicsLayer::GetDevice()->CreateDepthStencilSurface(nSizeX,nSizeY,BaseGraphicsLayer::m_d3dpp.AutoDepthStencilFormat,D3DMULTISAMPLE_NONE,&m_pRenderZBuffer);
|
||||
|
||||
m_nSize=nSizeX;
|
||||
LPDIRECT3DTEXTURE8 pMipmapTexture;
|
||||
LPDIRECT3DSURFACE8 pRenderSurface;
|
||||
|
||||
for(int i=nSizeX;i>=32;i=i>>1)
|
||||
{
|
||||
BaseGraphicsLayer::GetDevice()->CreateTexture(i,i,1,D3DUSAGE_RENDERTARGET,mode.Format,D3DPOOL_DEFAULT,&pMipmapTexture);
|
||||
pMipmapTexture->GetSurfaceLevel(0, &pRenderSurface);
|
||||
m_pRenderTextureList.push_back(pMipmapTexture);
|
||||
m_pRenderSurfaceList.push_back(pRenderSurface);
|
||||
}
|
||||
/*
|
||||
for(int i=nSizeX;i>=32;i=i>>1)
|
||||
{
|
||||
CRenderTexture *AddNode=new CRenderTexture();
|
||||
AddNode->Create(i,i);
|
||||
m_TextureMipmap.Add(AddNode);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
LPDIRECT3DTEXTURE8 CRenderTextureMipmap::GetTexture(int nTexture)
|
||||
{
|
||||
if((int)m_pRenderTextureList.size()>0)
|
||||
{
|
||||
return m_pRenderTextureList[nTexture];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CRenderTextureMipmap::GenerateMipmap(LPDIRECT3DDEVICE8 pd3dDevice)
|
||||
{
|
||||
pd3dDevice->EndScene();
|
||||
LPDIRECT3DSURFACE8 m_pTempRenderSurface;
|
||||
LPDIRECT3DSURFACE8 m_pTempRenderZBuffer;
|
||||
pd3dDevice->GetRenderTarget(&m_pTempRenderSurface);
|
||||
pd3dDevice->GetDepthStencilSurface(&m_pTempRenderZBuffer);
|
||||
|
||||
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1,D3DTA_TEXTURE);
|
||||
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2,D3DTA_DIFFUSE);
|
||||
pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP,D3DTOP_SELECTARG1);
|
||||
|
||||
pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP,D3DTOP_DISABLE);
|
||||
pd3dDevice->SetTextureStageState( 2, D3DTSS_COLOROP,D3DTOP_DISABLE);
|
||||
pd3dDevice->SetTextureStageState( 3, D3DTSS_COLOROP,D3DTOP_DISABLE);
|
||||
|
||||
pd3dDevice->SetTextureStageState(0, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP);
|
||||
pd3dDevice->SetTextureStageState(0, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP);
|
||||
|
||||
pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE,FALSE);
|
||||
pd3dDevice->SetRenderState( D3DRS_LIGHTING,FALSE);
|
||||
pd3dDevice->SetRenderState( D3DRS_FOGENABLE,FALSE);
|
||||
|
||||
|
||||
TLVertex pVertex[4];
|
||||
int TextureSize=m_nSize>>1;
|
||||
|
||||
pVertex[0].v.x=0.0f;
|
||||
pVertex[1].v.x=0.0f;
|
||||
pVertex[2].v.x=(float)TextureSize;
|
||||
pVertex[3].v.x=(float)TextureSize;
|
||||
|
||||
|
||||
pVertex[1].v.y=0.0f;
|
||||
pVertex[3].v.y=0.0f;
|
||||
pVertex[0].v.y=(float)TextureSize;
|
||||
pVertex[2].v.y=(float)TextureSize;
|
||||
|
||||
pVertex[0].tu=0.0f;
|
||||
pVertex[1].tu=0.0f;
|
||||
|
||||
pVertex[3].tu=1.0f;
|
||||
pVertex[2].tu=1.0f;
|
||||
|
||||
pVertex[1].tv=0.0f;
|
||||
pVertex[3].tv=0.0f;
|
||||
|
||||
pVertex[0].tv=1.0f;
|
||||
pVertex[2].tv=1.0f;
|
||||
|
||||
for(int i=0;i<4;i++)
|
||||
{
|
||||
pVertex[i].w=0.1f;
|
||||
pVertex[i].v.z=0.1f;
|
||||
pVertex[i].Diffuse.c=0xffff0000;
|
||||
pVertex[i].Specular.c=0xffffffff;
|
||||
}
|
||||
|
||||
pd3dDevice->SetRenderState(D3DRS_CULLMODE,D3DCULL_NONE);
|
||||
|
||||
pd3dDevice->SetTexture(1,NULL);
|
||||
pd3dDevice->SetVertexShader(TLVERTEXFVF);
|
||||
|
||||
pd3dDevice->SetRenderState(D3DRS_ZWRITEENABLE,FALSE);
|
||||
pd3dDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
|
||||
|
||||
|
||||
for(int i=1;i<(int)m_pRenderTextureList.size();i++,TextureSize=TextureSize>>1)
|
||||
{
|
||||
pVertex[2].v.x=(float)TextureSize;
|
||||
pVertex[3].v.x=(float)TextureSize;
|
||||
pVertex[0].v.y=(float)TextureSize;
|
||||
pVertex[2].v.y=(float)TextureSize;
|
||||
|
||||
pd3dDevice->SetRenderTarget(m_pRenderSurfaceList[i],m_pTempRenderZBuffer);
|
||||
|
||||
pd3dDevice->BeginScene();
|
||||
pd3dDevice->Clear(0,NULL,D3DCLEAR_TARGET,0xffffffff,1.0f,0);
|
||||
|
||||
pd3dDevice->SetTexture(0,m_pRenderTextureList[0]);
|
||||
pd3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,pVertex,sizeof(TLVertex));
|
||||
pd3dDevice->EndScene();
|
||||
|
||||
}
|
||||
|
||||
pd3dDevice->SetRenderState(D3DRS_ZWRITEENABLE,TRUE);
|
||||
pd3dDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
|
||||
|
||||
pd3dDevice->SetRenderState(D3DRS_CULLMODE,D3DCULL_CCW);
|
||||
|
||||
pd3dDevice->SetTextureStageState(0, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
|
||||
pd3dDevice->SetTextureStageState(0, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
|
||||
|
||||
pd3dDevice->SetRenderTarget(m_pTempRenderSurface,m_pTempRenderZBuffer);
|
||||
m_pTempRenderSurface->Release();
|
||||
m_pTempRenderZBuffer->Release();
|
||||
|
||||
pd3dDevice->BeginScene();
|
||||
}
|
||||
|
||||
LPDIRECT3DSURFACE8 CRenderTextureMipmap::GetSurface()
|
||||
{
|
||||
if((int)m_pRenderSurfaceList.size()>0)
|
||||
{
|
||||
return m_pRenderSurfaceList[0];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
33
Engine/Zalla3D Base Class/RenderTextureMipmap.h
Normal file
33
Engine/Zalla3D Base Class/RenderTextureMipmap.h
Normal file
@@ -0,0 +1,33 @@
|
||||
// RenderTextureMipmap.h: interface for the CRenderTextureMipmap class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_RENDERTEXTUREMIPMAP_H__C4579775_6CD9_4F2B_A3CC_7E128F86C7D3__INCLUDED_)
|
||||
#define AFX_RENDERTEXTUREMIPMAP_H__C4579775_6CD9_4F2B_A3CC_7E128F86C7D3__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "RenderTexture.h"
|
||||
#include <vector>
|
||||
|
||||
class CRenderTextureMipmap
|
||||
{
|
||||
std::vector<LPDIRECT3DTEXTURE8> m_pRenderTextureList;
|
||||
std::vector<LPDIRECT3DSURFACE8> m_pRenderSurfaceList;
|
||||
LPDIRECT3DSURFACE8 m_pRenderZBuffer;
|
||||
int m_nSize;
|
||||
public:
|
||||
LPDIRECT3DSURFACE8 GetSurface();
|
||||
void GenerateMipmap(LPDIRECT3DDEVICE8 pd3dDevice);
|
||||
LPDIRECT3DTEXTURE8 GetTexture(int nTexture=0);
|
||||
LPDIRECT3DSURFACE8 GetZBuffer(){return m_pRenderZBuffer;};
|
||||
int GetTextureCount(){return (int)m_pRenderTextureList.size();};
|
||||
void Create(int nSizeX,int nSizeY);
|
||||
CRenderTextureMipmap();
|
||||
virtual ~CRenderTextureMipmap();
|
||||
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_RENDERTEXTUREMIPMAP_H__C4579775_6CD9_4F2B_A3CC_7E128F86C7D3__INCLUDED_)
|
||||
136
Engine/Zalla3D Base Class/Resource.cpp
Normal file
136
Engine/Zalla3D Base Class/Resource.cpp
Normal file
@@ -0,0 +1,136 @@
|
||||
#include ".\resource.h"
|
||||
#include "./ResourceMgr.h"
|
||||
#include "./NTexture.h"
|
||||
#include "../zalla3d scene class/NMesh.h"
|
||||
#include "../zalla3d scene class/OctreeScene.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
namespace CROSSM {
|
||||
CResource::CResource(void)
|
||||
{
|
||||
}
|
||||
|
||||
CResource::~CResource(void)
|
||||
{
|
||||
for(RESOURCETABLEITER itr = m_ResourceMgrMap.begin(); itr != m_ResourceMgrMap.end();)
|
||||
{
|
||||
if(itr->second != NULL)
|
||||
{
|
||||
SafeDelete(itr->second);
|
||||
}
|
||||
itr++;
|
||||
}
|
||||
m_ResourceMgrMap.clear();
|
||||
|
||||
}
|
||||
void CResource::Init()
|
||||
{
|
||||
m_ResourceMgrMap.clear();
|
||||
AddResourceMgr(RESOURCE_TEXTURE,new CResourceMgr<CNTexture>);
|
||||
AddResourceMgr(RESOURCE_MESH,new CResourceMgr<CNMesh>);
|
||||
AddResourceMgr(RESOURCE_OCTREESCENE,new CResourceMgr<COctreeScene>);
|
||||
}
|
||||
|
||||
void CResource::Update()
|
||||
{
|
||||
RESOURCETABLEITER itr = m_ResourceMgrMap.find(RESOURCE_TEXTURE);
|
||||
if(itr != m_ResourceMgrMap.end())
|
||||
{
|
||||
itr->second->Update();
|
||||
}
|
||||
|
||||
itr = m_ResourceMgrMap.find(RESOURCE_MESH);
|
||||
if(itr != m_ResourceMgrMap.end())
|
||||
{
|
||||
itr->second->Update();
|
||||
}
|
||||
|
||||
itr = m_ResourceMgrMap.find(RESOURCE_OCTREESCENE);
|
||||
if(itr != m_ResourceMgrMap.end())
|
||||
{
|
||||
itr->second->Update();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CResource::AddResourceMgr(int iType,IResourceMgr *pMgr)
|
||||
{
|
||||
RESOURCETABLEITER itr = m_ResourceMgrMap.find(iType);
|
||||
if(itr == m_ResourceMgrMap.end())
|
||||
{
|
||||
|
||||
if(pMgr)
|
||||
{
|
||||
pMgr->SetType(iType); // Resource Type Setting.
|
||||
m_ResourceMgrMap.insert(RESOURCETABLEOBJ(iType,pMgr));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// CLogMgr::_LogError(" CResource::AddResourceMgr(), <20>̹<EFBFBD> <20><><EFBFBD><EFBFBD> <20≯<EFBFBD> <20><><EFBFBD><EFBFBD> resourcemgr<67><72> <20><><EFBFBD>ϵǾ<CFB5> <20>ֽ<EFBFBD><D6BD>ϴ<EFBFBD>");
|
||||
|
||||
}
|
||||
}
|
||||
void CResource::Release()
|
||||
{
|
||||
for(RESOURCETABLEITER itr = m_ResourceMgrMap.begin(); itr != m_ResourceMgrMap.end();)
|
||||
{
|
||||
if(itr->second != NULL)
|
||||
{
|
||||
SafeDelete(itr->second);
|
||||
}
|
||||
itr++;
|
||||
}
|
||||
m_ResourceMgrMap.clear();
|
||||
|
||||
}
|
||||
void CResource::ReleaseAllData()
|
||||
{
|
||||
for(RESOURCETABLEITER itr = m_ResourceMgrMap.begin(); itr != m_ResourceMgrMap.end();)
|
||||
{
|
||||
if(itr->second != NULL)
|
||||
{
|
||||
itr->second->ReleaseAllData();
|
||||
}
|
||||
itr++;
|
||||
}
|
||||
}
|
||||
void *CResource::GetData(int iType,const char *strName)
|
||||
{
|
||||
RESOURCETABLEITER itr = m_ResourceMgrMap.find(iType);
|
||||
if(itr != m_ResourceMgrMap.end())
|
||||
{
|
||||
return itr->second->GetData(strName);
|
||||
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
void CResource::ReleaseObj(int iType,char *strName)
|
||||
{
|
||||
|
||||
RESOURCETABLEITER itr = m_ResourceMgrMap.find(iType);
|
||||
if(itr != m_ResourceMgrMap.end())
|
||||
{
|
||||
itr->second->ReleaseData(strName);
|
||||
}
|
||||
}
|
||||
|
||||
// 2005.01.10 yundi ImmediateLoad <20><><EFBFBD><EFBFBD> <20>߰<EFBFBD>
|
||||
void CResource::LockImmediateLoad(int iType)
|
||||
{
|
||||
RESOURCETABLEITER itr = m_ResourceMgrMap.find(iType);
|
||||
if(itr != m_ResourceMgrMap.end())
|
||||
{
|
||||
itr->second->LockImmediateLoad();
|
||||
}
|
||||
}
|
||||
void CResource::UnlockImmediateLoad(int iType)
|
||||
{
|
||||
RESOURCETABLEITER itr = m_ResourceMgrMap.find(iType);
|
||||
if(itr != m_ResourceMgrMap.end())
|
||||
{
|
||||
itr->second->UnlockImmediateLoad();
|
||||
}
|
||||
}
|
||||
}
|
||||
36
Engine/Zalla3D Base Class/Resource.h
Normal file
36
Engine/Zalla3D Base Class/Resource.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
#include "./CrossMHeader.h"
|
||||
#include "./IResourceMgr.h"
|
||||
|
||||
namespace CROSSM {
|
||||
|
||||
typedef std::map<int , IResourceMgr *> RESOURCETABLE;
|
||||
typedef RESOURCETABLE::value_type RESOURCETABLEOBJ;
|
||||
typedef RESOURCETABLE::iterator RESOURCETABLEITER;
|
||||
|
||||
class CResource
|
||||
{
|
||||
public:
|
||||
CResource(void);
|
||||
~CResource(void);
|
||||
void Init();
|
||||
|
||||
void AddResourceMgr(int ,IResourceMgr *);
|
||||
void ReleaseAllData();
|
||||
void Release();
|
||||
void ReleaseObj(int iType,char *pObj);
|
||||
|
||||
void *GetData(int iType,const char *);
|
||||
void Update();
|
||||
|
||||
void LockImmediateLoad(int iType);
|
||||
void UnlockImmediateLoad(int iType);
|
||||
|
||||
|
||||
protected:
|
||||
RESOURCETABLE m_ResourceMgrMap;
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
189
Engine/Zalla3D Base Class/ResourceLoader.cpp
Normal file
189
Engine/Zalla3D Base Class/ResourceLoader.cpp
Normal file
@@ -0,0 +1,189 @@
|
||||
#include ".\resourceloader.h"
|
||||
#include "GMMemory.h"
|
||||
namespace CROSSM {
|
||||
|
||||
unsigned int __stdcall LoaderThreadProc(void *lpParam)
|
||||
{
|
||||
CResourceLoader *pLoader = (CResourceLoader *)(lpParam);
|
||||
pLoader->LoaderFunc();
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
unsigned int __stdcall ProcessThreadProc(void *lpParam)
|
||||
{
|
||||
CResourceLoader *pLoader = (CResourceLoader *)(lpParam);
|
||||
pLoader->ProcessFunc();
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
void CResourceLoader::StartLoader()
|
||||
{
|
||||
if(!m_LoaderHandle)
|
||||
{
|
||||
|
||||
if((m_LoaderHandle =(HANDLE)_beginthreadex(NULL,0,LoaderThreadProc,(LPVOID)this,0,&m_LoaderThreadID)) == NULL ) {
|
||||
//CLogMgr::_LogError("CResourceLoader::Loading() : Create Loader Thread Failed");
|
||||
}
|
||||
}
|
||||
if(!m_ProcessHandle)
|
||||
{
|
||||
if((m_ProcessHandle =(HANDLE)_beginthreadex(NULL,0,ProcessThreadProc,(LPVOID)this,0,&m_ProcessThreadID)) == NULL ) {
|
||||
//CLogMgr::_LogError("CResourceLoader::Loading() : Create Process Thread Failed");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
void CResourceLoader::LoaderFunc()
|
||||
{
|
||||
CResourceObj *pObj = NULL;
|
||||
|
||||
while( m_ReadyQueue.RemoveFront(pObj))
|
||||
{
|
||||
if(pObj)
|
||||
{
|
||||
pObj->Init();
|
||||
|
||||
if(!(pObj->LoadByte()))
|
||||
{
|
||||
pObj->SetLoaded(false);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Queue.PushBack(pObj);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
void CResourceLoader::ProcessFunc()
|
||||
{
|
||||
|
||||
CResourceObj *pObj = NULL;
|
||||
while( m_Queue.RemoveFront(pObj))
|
||||
{
|
||||
if(pObj)
|
||||
{
|
||||
if(!pObj->Load())
|
||||
{ // <20>ε<EFBFBD> <20><><EFBFBD>нÿ<D0BD> <20>ٽ<EFBFBD> queue<75><65> <20>־ ReLoading <20>õ<EFBFBD> <20>Ѵ<EFBFBD>.
|
||||
if(pObj->Reloading() < MAX_RELOADING) {
|
||||
m_Queue.PushBack(pObj);
|
||||
//CLogMgr::_LogError("CResourceLoader::ProcessFunc: Load fail, Reloading.");
|
||||
}
|
||||
else
|
||||
{
|
||||
pObj->ReleaseByte();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ResultQueue.PushBack(pObj);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//CLogMgr::_LogError("CResourceLoader::ProcessFunc: Obj Ptr is NULL");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
void CResourceLoader::ProcessAllData()
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
|
||||
if(!m_ReadyQueue.GetQueueSize() &&
|
||||
!m_Queue.GetQueueSize())
|
||||
{
|
||||
|
||||
break;
|
||||
}
|
||||
Sleep(2000);
|
||||
}
|
||||
if(m_ResultQueue.GetQueueSize())
|
||||
{
|
||||
int iProcess = m_ResultQueue.GetQueueSize();
|
||||
CResourceObj *pObj = NULL;
|
||||
|
||||
while(iProcess)
|
||||
{
|
||||
if(m_ResultQueue.RemoveFront(pObj))
|
||||
{
|
||||
pObj->PostLoad();
|
||||
pObj->SetLoaded(true);
|
||||
pObj->ReleaseByte();
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
iProcess--;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CResourceLoader::Process()
|
||||
{
|
||||
if(m_ResultQueue.GetQueueSize())
|
||||
{
|
||||
int iProcess = (m_ResultQueue.GetQueueSize() > g_iMaxProcessNums) ? g_iMaxProcessNums : m_ResultQueue.GetQueueSize();
|
||||
CResourceObj *pObj = NULL;
|
||||
|
||||
while(iProcess)
|
||||
{
|
||||
if(m_ResultQueue.RemoveFront(pObj))
|
||||
{
|
||||
pObj->PostLoad();
|
||||
pObj->SetLoaded(true);
|
||||
pObj->ReleaseByte();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
iProcess--;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
void CResourceLoader::Clear()
|
||||
{
|
||||
ProcessAllData();
|
||||
m_ReadyQueue.ClearQueue();
|
||||
m_Queue.ClearQueue();
|
||||
|
||||
m_ResultQueue.ClearQueue();
|
||||
|
||||
}
|
||||
|
||||
// 2005.01.10 yundi ImmediateLoad <20>߰<EFBFBD>
|
||||
void CResourceLoader::ImmediateLoad(CResourceObj *pObj)
|
||||
{
|
||||
pObj->Init();
|
||||
|
||||
if(!(pObj->LoadByte()))
|
||||
{
|
||||
pObj->SetLoaded(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!pObj->Load())
|
||||
{
|
||||
// <20>ε<EFBFBD> <20><><EFBFBD>н<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
pObj->ReleaseByte();
|
||||
return;
|
||||
}
|
||||
|
||||
pObj->PostLoad();
|
||||
pObj->SetLoaded(true);
|
||||
pObj->ReleaseByte();
|
||||
}
|
||||
}
|
||||
|
||||
213
Engine/Zalla3D Base Class/ResourceLoader.h
Normal file
213
Engine/Zalla3D Base Class/ResourceLoader.h
Normal file
@@ -0,0 +1,213 @@
|
||||
#pragma once
|
||||
#include "./CrossMHeader.h"
|
||||
#include "./ResourceObj.h"
|
||||
|
||||
namespace CROSSM {
|
||||
|
||||
enum SGTHREADEVENT_ID {
|
||||
SGTHREAD_SEMAPHORE = 0,
|
||||
SGTHREAD_TERMINATE,
|
||||
};
|
||||
template<class T>
|
||||
class CThreadQueue
|
||||
{
|
||||
public:
|
||||
CThreadQueue(int iMaxQueueSize)
|
||||
{
|
||||
InitializeCriticalSection(&m_CriticalSection);
|
||||
m_Handle[SGTHREAD_SEMAPHORE] = CreateSemaphore(NULL,0,iMaxQueueSize,NULL);
|
||||
m_Handle[SGTHREAD_TERMINATE] = CreateEvent(NULL,TRUE,FALSE,NULL);
|
||||
|
||||
}
|
||||
virtual ~CThreadQueue()
|
||||
{
|
||||
ClearQueue();
|
||||
DeleteCriticalSection(&m_CriticalSection);
|
||||
CloseHandle(m_Handle[SGTHREAD_SEMAPHORE]);
|
||||
CloseHandle(m_Handle[SGTHREAD_TERMINATE]);
|
||||
}
|
||||
bool PushBack(T Obj)
|
||||
{
|
||||
EnterCriticalSection(&m_CriticalSection);
|
||||
m_Queue.push(Obj);
|
||||
|
||||
// semaphore count <20><><EFBFBD><EFBFBD>
|
||||
bool bResult = (ReleaseSemaphore(m_Handle[SGTHREAD_SEMAPHORE],1,NULL) != 0);
|
||||
if(!bResult)
|
||||
{
|
||||
m_Queue.pop(); // pop()<29><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ٷ<EFBFBD><D9B7><EFBFBD><EFBFBD><EFBFBD> remove <20><>Ų<EFBFBD><C5B2>.
|
||||
// //CLogMgr::_LogError("CThreadQueue::PushBack() : Queue is Full~!");
|
||||
}
|
||||
|
||||
LeaveCriticalSection(&m_CriticalSection);
|
||||
return bResult;
|
||||
}
|
||||
void ClearQueue()
|
||||
{
|
||||
EnterCriticalSection(&m_CriticalSection);
|
||||
while(m_Queue.size())
|
||||
{
|
||||
m_Queue.pop();
|
||||
|
||||
}
|
||||
LeaveCriticalSection(&m_CriticalSection);
|
||||
|
||||
}
|
||||
bool RemoveFront(T &Obj)
|
||||
{
|
||||
bool bResult = false;
|
||||
// Semarphore <20><> <20><><EFBFBD><EFBFBD> <20><>ŭ Return <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EEB0A3>
|
||||
SGTHREADEVENT_ID ReturnID = (SGTHREADEVENT_ID)WaitForMultipleObjects(2,m_Handle,FALSE,INFINITE);
|
||||
|
||||
if(ReturnID == SGTHREAD_SEMAPHORE)
|
||||
{
|
||||
bResult = true;
|
||||
EnterCriticalSection(&m_CriticalSection);
|
||||
if(m_Queue.size())
|
||||
{
|
||||
Obj = m_Queue.front();
|
||||
m_Queue.pop(); // pop()<29><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ٷ<EFBFBD><D9B7><EFBFBD><EFBFBD><EFBFBD> remove <20><>Ų<EFBFBD><C5B2>.
|
||||
}
|
||||
else
|
||||
{
|
||||
//CLogMgr::_LogError("CThreadQueue::RemoveFront() : Queue is Empty~!");
|
||||
bResult = false;
|
||||
}
|
||||
LeaveCriticalSection(&m_CriticalSection);
|
||||
return bResult;
|
||||
}
|
||||
return bResult;
|
||||
}
|
||||
void Terminate()
|
||||
{
|
||||
SetEvent(m_Handle[SGTHREAD_TERMINATE]);
|
||||
}
|
||||
void UnTerminate()
|
||||
{
|
||||
ResetEvent(m_Handle[SGTHREAD_TERMINATE]);
|
||||
}
|
||||
int GetQueueSize()
|
||||
{
|
||||
return (int)m_Queue.size();
|
||||
}
|
||||
protected:
|
||||
|
||||
HANDLE m_Handle[2];
|
||||
CRITICAL_SECTION m_CriticalSection;
|
||||
std::queue<T> m_Queue;
|
||||
|
||||
};
|
||||
template<class T>
|
||||
class CCriticalSectionQueue
|
||||
{
|
||||
public:
|
||||
CCriticalSectionQueue(int iMaxQueueSize)
|
||||
{
|
||||
InitializeCriticalSection(&m_CriticalSection);
|
||||
}
|
||||
virtual ~CCriticalSectionQueue()
|
||||
{
|
||||
ClearQueue();
|
||||
DeleteCriticalSection(&m_CriticalSection);
|
||||
}
|
||||
void PushBack(T Obj)
|
||||
{
|
||||
EnterCriticalSection(&m_CriticalSection);
|
||||
m_Queue.push(Obj);
|
||||
LeaveCriticalSection(&m_CriticalSection);
|
||||
}
|
||||
bool RemoveFront(T &Obj)
|
||||
{
|
||||
bool bReturn = false;
|
||||
EnterCriticalSection(&m_CriticalSection);
|
||||
if(m_Queue.size())
|
||||
{
|
||||
Obj = m_Queue.front();
|
||||
m_Queue.pop(); // pop()<29><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ٷ<EFBFBD><D9B7><EFBFBD><EFBFBD><EFBFBD> remove <20><>Ų<EFBFBD><C5B2>.
|
||||
bReturn = true;
|
||||
}
|
||||
LeaveCriticalSection(&m_CriticalSection);
|
||||
return bReturn;
|
||||
|
||||
}
|
||||
int GetQueueSize()
|
||||
{
|
||||
return (int)m_Queue.size();
|
||||
}
|
||||
void ClearQueue()
|
||||
{
|
||||
EnterCriticalSection(&m_CriticalSection);
|
||||
while(m_Queue.size())
|
||||
{
|
||||
m_Queue.pop();
|
||||
|
||||
}
|
||||
LeaveCriticalSection(&m_CriticalSection);
|
||||
|
||||
}
|
||||
|
||||
protected:
|
||||
CRITICAL_SECTION m_CriticalSection;
|
||||
std::queue<T> m_Queue;
|
||||
|
||||
};
|
||||
|
||||
enum RESOURCELOADEROBJSTATE {
|
||||
RLOBJSTATE_READY = 0,
|
||||
RLOBJSTATE_LOADING,
|
||||
RLOBJSTATE_LOADED,
|
||||
RLOBJSTATE_FAILED,
|
||||
|
||||
};
|
||||
const int g_iMaxLoaderQueue = 500;
|
||||
const int g_iMaxResultQueue = 500;
|
||||
const int g_iMaxProcessNums = 5;
|
||||
const int MAX_RELOADING = 3;
|
||||
|
||||
class CResourceLoader
|
||||
{
|
||||
public:
|
||||
CResourceLoader() :m_ReadyQueue(g_iMaxLoaderQueue),m_Queue(g_iMaxLoaderQueue),m_ResultQueue(g_iMaxResultQueue),
|
||||
m_LoaderThreadID(0),m_ProcessThreadID(0),
|
||||
m_LoaderHandle(0),m_ProcessHandle(0)
|
||||
{}
|
||||
~CResourceLoader()
|
||||
{
|
||||
Clear();
|
||||
m_ReadyQueue.Terminate();
|
||||
m_Queue.Terminate();
|
||||
Sleep(3); // Thread Terminate<74><65> <20><><EFBFBD><EFBFBD> sleep
|
||||
CloseHandle(m_LoaderHandle);
|
||||
CloseHandle(m_ProcessHandle);
|
||||
|
||||
}
|
||||
void StartLoader();
|
||||
void AddObj(CResourceObj *pAddObj)
|
||||
{
|
||||
m_ReadyQueue.PushBack(pAddObj);
|
||||
}
|
||||
void LoaderFunc();
|
||||
void ProcessFunc();
|
||||
void Process();
|
||||
void ProcessAllData();
|
||||
|
||||
void Clear();
|
||||
|
||||
// 2005.01.10 yundi ImmediateLoad <20>߰<EFBFBD>
|
||||
void ImmediateLoad(CResourceObj *pObj);
|
||||
|
||||
|
||||
protected:
|
||||
CThreadQueue<CResourceObj *> m_ReadyQueue;
|
||||
CThreadQueue<CResourceObj *> m_Queue;
|
||||
CCriticalSectionQueue<CResourceObj *> m_ResultQueue;
|
||||
|
||||
unsigned m_LoaderThreadID;
|
||||
unsigned m_ProcessThreadID;
|
||||
|
||||
HANDLE m_LoaderHandle;
|
||||
HANDLE m_ProcessHandle;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
6
Engine/Zalla3D Base Class/ResourceMgr.cpp
Normal file
6
Engine/Zalla3D Base Class/ResourceMgr.cpp
Normal file
@@ -0,0 +1,6 @@
|
||||
#include ".\resourcemgr.h"
|
||||
#include "GMMemory.h"
|
||||
namespace CROSSM {
|
||||
|
||||
|
||||
}
|
||||
518
Engine/Zalla3D Base Class/ResourceMgr.h
Normal file
518
Engine/Zalla3D Base Class/ResourceMgr.h
Normal file
@@ -0,0 +1,518 @@
|
||||
#pragma once
|
||||
#include "iresourcemgr.h"
|
||||
#include "CrossMHeader.h"
|
||||
#include "ResourceObj.h"
|
||||
#include "../zalla3d scene class/SceneManager.h"
|
||||
|
||||
|
||||
namespace CROSSM {
|
||||
|
||||
|
||||
#define RESOURCE_MAXCOUNT 70
|
||||
#define RESOURCE_MAXDELCOUNT 5
|
||||
|
||||
#define SG_RESOURCE_RELEASEPROCESS
|
||||
class CResourceMgrObj
|
||||
{
|
||||
|
||||
|
||||
public:
|
||||
|
||||
CResourceMgrObj() : m_iObjsNum(0)
|
||||
{
|
||||
m_lstObjs.clear();
|
||||
}
|
||||
CResourceMgrObj(int iResourceType,CResourceObj *pObj) : m_iObjsNum(1)
|
||||
{
|
||||
m_lstObjs.clear();
|
||||
m_lstObjs.push_back(pObj);
|
||||
pObj->SetType(iResourceType);
|
||||
pObj->AddRef();
|
||||
}
|
||||
~CResourceMgrObj()
|
||||
{
|
||||
for(int i = 0; i < m_iObjsNum; i++ )
|
||||
{
|
||||
//SafeDelete(m_lstObjs[i]);
|
||||
if(m_lstObjs[i])
|
||||
{
|
||||
CSceneManager::_ReleaseObj(m_lstObjs[i]->GetType(),m_lstObjs[i]);
|
||||
m_lstObjs[i] = NULL;
|
||||
}
|
||||
}
|
||||
m_lstObjs.clear();
|
||||
|
||||
}
|
||||
int AddObj(int iResourceType,CResourceObj *pObj)
|
||||
{
|
||||
m_iObjsNum++;
|
||||
m_lstObjs.push_back(pObj);
|
||||
pObj->AddRef();
|
||||
pObj->SetType(iResourceType);
|
||||
return m_iObjsNum;
|
||||
}
|
||||
CResourceObj *GetObj(int iNum)
|
||||
{
|
||||
if(iNum < m_iObjsNum)
|
||||
{
|
||||
m_lstObjs[iNum]->AddRef();
|
||||
return m_lstObjs[iNum];
|
||||
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
bool IsLoaded(int iNum)
|
||||
{
|
||||
|
||||
if(iNum < m_iObjsNum)
|
||||
{
|
||||
return m_lstObjs[iNum]->IsLoaded();
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
bool ReleaseObj(int iNum)
|
||||
{
|
||||
if(iNum < m_iObjsNum)
|
||||
{
|
||||
|
||||
// if(!m_lstObjs[iNum]->IsLoaded()) // Load <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ü<EFBFBD><C3BC> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʴ´<CAB4>.
|
||||
// return false;
|
||||
|
||||
|
||||
if(m_lstObjs[iNum]->Release() <= 0)
|
||||
{
|
||||
#ifndef SG_RESOURCE_RELEASEPROCESS
|
||||
m_iObjsNum--;
|
||||
m_lstObjs.erase(&m_lstObjs[iNum]);
|
||||
#endif
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#ifdef SG_RESOURCE_RELEASEPROCESS
|
||||
bool RealReleaseObj(int iNum)
|
||||
{
|
||||
if(iNum < m_iObjsNum)
|
||||
{
|
||||
if(m_lstObjs[iNum]->GetRef() <= 0) // DelList <20><> <20>ִ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ﶧ <20><><EFBFBD><EFBFBD><EFBFBD>ϹǷ<CFB9> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ref count<6E><74> <20><><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD> <20>ȵȴ<C8B5>.
|
||||
{
|
||||
if(m_lstObjs[iNum]->RealRelease() <= 0)
|
||||
{
|
||||
m_iObjsNum--;
|
||||
m_lstObjs.erase(m_lstObjs.begin() + iNum);
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
int m_iObjsNum;
|
||||
std::vector<CResourceObj *> m_lstObjs;
|
||||
|
||||
|
||||
};
|
||||
|
||||
class CDelResourceInfo
|
||||
{
|
||||
public:
|
||||
unsigned long m_iID;
|
||||
char m_strName[256];
|
||||
void SetValue(unsigned long iID,const char *strName)
|
||||
{
|
||||
m_iID = iID;
|
||||
strcpy(m_strName,strName);
|
||||
|
||||
}
|
||||
CDelResourceInfo() : m_iID(0)
|
||||
{
|
||||
memset(m_strName,0,sizeof(char) * 256);
|
||||
}
|
||||
CDelResourceInfo(unsigned long iID,const char *strName)
|
||||
{
|
||||
m_iID = iID;
|
||||
strcpy(m_strName,strName);
|
||||
|
||||
|
||||
}
|
||||
~CDelResourceInfo()
|
||||
{}
|
||||
|
||||
};
|
||||
|
||||
|
||||
typedef std::map<unsigned long , CResourceMgrObj *> RESOURCEMGRTABLE;
|
||||
typedef RESOURCEMGRTABLE::value_type RESOURCEMGRTABLEOBJ;
|
||||
typedef RESOURCEMGRTABLE::iterator RESOURCEMGRTABLEITER;
|
||||
|
||||
template <class T>
|
||||
class CResourceMgr :
|
||||
public IResourceMgr
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
CResourceMgr(void) : m_iResourceObjsNum(0), m_iMaxCount(RESOURCE_MAXCOUNT),m_DelObjNums(0)
|
||||
{
|
||||
m_ResourceTable.clear();
|
||||
m_iDelCount = 0;
|
||||
|
||||
// 2005.01.10 yundi <20><><EFBFBD><EFBFBD> <20>ε<EFBFBD> <20><><EFBFBD>¸<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>߰<EFBFBD>
|
||||
m_nLockedImmediateLoadCount = 0;
|
||||
}
|
||||
virtual ~CResourceMgr(void)
|
||||
{
|
||||
if(m_iResourceObjsNum > 0)
|
||||
{
|
||||
for(RESOURCEMGRTABLEITER itr = m_ResourceTable.begin(); itr != m_ResourceTable.end();)
|
||||
{
|
||||
if(itr->second != NULL)
|
||||
{
|
||||
SafeDelete(itr->second);
|
||||
//CSceneManager::_ReleaseObj(POOL_RESOURCEMGROBJ,itr->second);
|
||||
itr->second = NULL;
|
||||
|
||||
}
|
||||
itr++;
|
||||
}
|
||||
m_ResourceTable.clear();
|
||||
m_iResourceObjsNum = 0;
|
||||
}
|
||||
while(!m_DelObjQueue.empty())
|
||||
{
|
||||
|
||||
CDelResourceInfo *pDelObj = m_DelObjQueue.front();
|
||||
m_DelObjQueue.pop();
|
||||
SafeDelete(pDelObj);
|
||||
// CSceneManager::_ReleaseObj(POOL_DELRESOURCEINFOOBJ,pDelObj);
|
||||
}
|
||||
|
||||
}
|
||||
void SetMaxCount(int iCount)
|
||||
{
|
||||
m_iMaxCount = iCount;
|
||||
|
||||
}
|
||||
virtual void ReleaseAllData()
|
||||
{
|
||||
if(m_iResourceObjsNum > 0)
|
||||
{
|
||||
for(RESOURCEMGRTABLEITER itr = m_ResourceTable.begin(); itr != m_ResourceTable.end();)
|
||||
{
|
||||
if(itr->second != NULL)
|
||||
{
|
||||
SafeDelete(itr->second);
|
||||
//CSceneManager::_ReleaseObj(POOL_RESOURCEMGROBJ,itr->second);
|
||||
itr->second = NULL;
|
||||
|
||||
}
|
||||
itr++;
|
||||
}
|
||||
m_ResourceTable.clear();
|
||||
m_iResourceObjsNum = 0;
|
||||
}
|
||||
}
|
||||
virtual void ReleaseData(const char *strName)
|
||||
{
|
||||
|
||||
bool bEraseObj = false;
|
||||
unsigned long DataID = GetHashID(strName);
|
||||
|
||||
RESOURCEMGRTABLEITER itr = m_ResourceTable.find(DataID);
|
||||
|
||||
if(itr != m_ResourceTable.end())
|
||||
{
|
||||
if((*itr).second != NULL)
|
||||
{
|
||||
for(int iNum = 0; iNum < (*itr).second->m_iObjsNum; iNum++)
|
||||
{
|
||||
if(!strcmp((*itr).second->m_lstObjs[iNum]->m_strName,strName))
|
||||
{
|
||||
bool bRelease = false;
|
||||
#ifndef SG_RESOURCE_RELEASEPROCESS
|
||||
if((bRelease = ((*itr).second)->ReleaseObj(iNum)) && !(*itr).second->m_iObjsNum)
|
||||
{
|
||||
// Release <20>Ϸ<EFBFBD>(map<61><70> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>).
|
||||
SafeDelete(itr->second);
|
||||
//CSceneManager::_ReleaseObj(POOL_RESOURCEMGROBJ,itr->second);
|
||||
itr->second = NULL;
|
||||
m_ResourceTable.erase(itr);
|
||||
|
||||
}
|
||||
#else
|
||||
if(((*itr).second)->ReleaseObj(iNum))
|
||||
{
|
||||
//CDelResourceInfo *pDel = new CDelResourceInfo(DataID,strName);
|
||||
CDelResourceInfo *pDel = new CDelResourceInfo();//(CDelResourceInfo *)CSceneManager::_CreateObj(POOL_DELRESOURCEINFOOBJ);
|
||||
pDel->SetValue(DataID,strName);
|
||||
m_DelObjQueue.push(pDel);
|
||||
m_DelObjNums++;
|
||||
|
||||
}
|
||||
#endif
|
||||
if(bRelease)
|
||||
{
|
||||
m_iResourceObjsNum--;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
virtual void *GetData(const char *strName)
|
||||
{
|
||||
|
||||
unsigned long DataID = GetHashID(strName);
|
||||
|
||||
RESOURCEMGRTABLEITER itr = m_ResourceTable.find(DataID);
|
||||
|
||||
if(itr == m_ResourceTable.end())
|
||||
{
|
||||
return LoadData(strName);
|
||||
}
|
||||
else // Table <20>ȿ<EFBFBD> <20>̹<EFBFBD> texture <20><> <20>ε<EFBFBD><CEB5>Ǿ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
if((*itr).second != NULL)
|
||||
{
|
||||
for(int iNum = 0; iNum < (*itr).second->m_iObjsNum; iNum++)
|
||||
{
|
||||
if(!strcmp((*itr).second->m_lstObjs[iNum]->m_strName,strName))
|
||||
{
|
||||
return (*itr).second->GetObj(iNum);
|
||||
}
|
||||
}
|
||||
return LoadData(strName); // Table <20><> obj<62><6A> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ϴ<EFBFBD> obj <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
else
|
||||
{
|
||||
CResourceMgrObj *pObj = new CResourceMgrObj();
|
||||
// CResourceMgrObj *pObj = (CResourceMgrObj *)CSceneManager::_CreateObj(POOL_RESOURCEMGROBJ);
|
||||
(*itr).second = pObj;
|
||||
return LoadData(strName); // Table <20><> obj<62><6A> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ϴ<EFBFBD> obj <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
|
||||
}
|
||||
protected:
|
||||
#ifdef SG_RESOURCE_RELEASEPROCESS
|
||||
void DelObjClear(int iNum)
|
||||
{
|
||||
|
||||
for(int i = 0; i < iNum; i++ )
|
||||
{
|
||||
if(!m_DelObjQueue.empty())
|
||||
{
|
||||
CDelResourceInfo *pDelObj = m_DelObjQueue.front();
|
||||
m_DelObjQueue.pop();
|
||||
m_DelObjNums--;
|
||||
|
||||
if(pDelObj)
|
||||
{
|
||||
if(!ResourceLoaded(pDelObj->m_iID,pDelObj->m_strName))
|
||||
{
|
||||
m_DelObjQueue.push(pDelObj);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
RealRelease(pDelObj->m_iID,pDelObj->m_strName);
|
||||
//SafeDelete(pDelObj);
|
||||
SafeDelete(pDelObj);
|
||||
// CSceneManager::_ReleaseObj(POOL_DELRESOURCEINFOOBJ,pDelObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
bool ResourceLoaded(unsigned long ID,char *strName)
|
||||
{
|
||||
RESOURCEMGRTABLEITER itr = m_ResourceTable.find(ID);
|
||||
|
||||
if(itr != m_ResourceTable.end())
|
||||
{
|
||||
if((*itr).second != NULL)
|
||||
{
|
||||
for(int iNum = 0; iNum < (*itr).second->m_iObjsNum; iNum++)
|
||||
{
|
||||
if(!strcmp((*itr).second->m_lstObjs[iNum]->m_strName,strName))
|
||||
{
|
||||
if(((*itr).second)->IsLoaded(iNum))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
void RealRelease(unsigned long ID,char *strName)
|
||||
{
|
||||
bool bEraseObj = false;
|
||||
|
||||
RESOURCEMGRTABLEITER itr = m_ResourceTable.find(ID);
|
||||
|
||||
if(itr != m_ResourceTable.end())
|
||||
{
|
||||
if((*itr).second != NULL)
|
||||
{
|
||||
for(int iNum = 0; iNum < (*itr).second->m_iObjsNum; iNum++)
|
||||
{
|
||||
if(!strcmp((*itr).second->m_lstObjs[iNum]->m_strName,strName))
|
||||
{
|
||||
bool bRelease = false;
|
||||
|
||||
if((bRelease = ((*itr).second)->RealReleaseObj(iNum)) && !(*itr).second->m_iObjsNum)
|
||||
{
|
||||
// Release <20>Ϸ<EFBFBD>(map<61><70> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>).
|
||||
SafeDelete(itr->second);
|
||||
//CSceneManager::_ReleaseObj(POOL_RESOURCEMGROBJ,itr->second);
|
||||
itr->second = NULL;
|
||||
|
||||
m_ResourceTable.erase(itr);
|
||||
if(bRelease)
|
||||
{
|
||||
m_iResourceObjsNum--;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if(bRelease)
|
||||
{
|
||||
m_iResourceObjsNum--;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
virtual void *LoadData(const char *strName)
|
||||
{
|
||||
//T *pNode = new T;
|
||||
T *pNode = (T *)CSceneManager::_CreateObj(m_iResourceType);
|
||||
strcpy(pNode->m_strName,strName);
|
||||
if( m_nLockedImmediateLoadCount > 0)
|
||||
{
|
||||
CSceneManager::_LoadResourceObj(pNode, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
CSceneManager::_LoadResourceObj(pNode, false);
|
||||
}
|
||||
/*Scene::CMainSceneMgr::_GetResourceLoader()->AddObj(pNode);
|
||||
*/
|
||||
unsigned long DataID = GetHashID(strName);
|
||||
RESOURCEMGRTABLEITER itr = m_ResourceTable.find(DataID);
|
||||
|
||||
m_iResourceObjsNum++;
|
||||
#ifdef SG_RESOURCE_RELEASEPROCESS
|
||||
if(m_iMaxCount < m_iResourceObjsNum)
|
||||
{
|
||||
SetDelCount(m_iResourceObjsNum - m_iMaxCount);
|
||||
//DelObjClear(m_iResourceObjsNum - m_iMaxCount);
|
||||
}
|
||||
#endif
|
||||
if(itr == m_ResourceTable.end())
|
||||
{
|
||||
|
||||
//CResourceMgrObj*pObj = new CResourceMgrObj(m_iResourceType,pNode);
|
||||
CResourceMgrObj *pObj = new CResourceMgrObj();//(CResourceMgrObj *)CSceneManager::_CreateObj(POOL_RESOURCEMGROBJ);
|
||||
pObj->AddObj(m_iResourceType,pNode);
|
||||
|
||||
m_ResourceTable.insert(RESOURCEMGRTABLEOBJ(DataID,pObj));
|
||||
|
||||
}
|
||||
else
|
||||
{// map <20>ȿ<EFBFBD> <20>Ȱ<EFBFBD><C8B0><EFBFBD> Hash Index <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
|
||||
((*itr).second)->AddObj(m_iResourceType,pNode);
|
||||
}
|
||||
|
||||
return pNode;
|
||||
|
||||
|
||||
}
|
||||
void SetDelCount(int i)
|
||||
{
|
||||
m_iDelCount = i;
|
||||
}
|
||||
virtual void Update()
|
||||
{
|
||||
int iNum;
|
||||
if(m_iDelCount > 0)
|
||||
{
|
||||
|
||||
iNum = (RESOURCE_MAXDELCOUNT < m_iDelCount) ? RESOURCE_MAXDELCOUNT : m_iDelCount;
|
||||
m_iDelCount -= iNum;
|
||||
DelObjClear(iNum);
|
||||
}
|
||||
}
|
||||
|
||||
void LockImmediateLoad()
|
||||
{
|
||||
++m_nLockedImmediateLoadCount;
|
||||
}
|
||||
|
||||
void UnlockImmediateLoad()
|
||||
{
|
||||
if( m_nLockedImmediateLoadCount > 0 )
|
||||
{
|
||||
--m_nLockedImmediateLoadCount;
|
||||
}
|
||||
}
|
||||
|
||||
RESOURCEMGRTABLE m_ResourceTable;
|
||||
int m_iResourceObjsNum;
|
||||
|
||||
std::queue<CDelResourceInfo *> m_DelObjQueue;
|
||||
int m_DelObjNums;
|
||||
|
||||
int m_iMaxCount;
|
||||
int m_iDelCount;
|
||||
|
||||
// 2005.01.10 yundi <20><><EFBFBD><EFBFBD> <20>ε<EFBFBD> <20><><EFBFBD>¸<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>߰<EFBFBD>
|
||||
int m_nLockedImmediateLoadCount;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user