Holy fucking shit I don't want to work on this. Sibly, you son of a ...
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
// Direct Draw
|
||||
#define DIRECTDRAW_VERSION 0x0700
|
||||
#include <ddraw.h>
|
||||
|
||||
// Direct3D
|
||||
#define DIRECT3D_VERSION 0x0700
|
||||
#include <d3d.h>
|
||||
|
||||
// Direct Input
|
||||
#define DIRECTINPUT_VERSION 0x0800
|
||||
#include <dinput.h>
|
||||
|
||||
// Redefine GUIDs
|
||||
DEFINE_GUID(CLSID_DirectDraw, 0xD7B70EE0, 0x4340, 0x11CF, 0xB0, 0x63, 0x00, 0x20, 0xAF, 0xC2, 0xCD, 0x35);
|
||||
DEFINE_GUID(CLSID_DirectDraw7, 0x3c305196, 0x50db, 0x11d3, 0x9c, 0xfe, 0x00, 0xc0, 0x4f, 0xd9, 0x30, 0xc5);
|
||||
DEFINE_GUID(CLSID_DirectDrawClipper, 0x593817A0, 0x7DB3, 0x11CF, 0xA2, 0xDE, 0x00, 0xAA, 0x00, 0xb9, 0x33, 0x56);
|
||||
DEFINE_GUID(IID_IDirectDraw, 0x6C14DB80, 0xA733, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60);
|
||||
DEFINE_GUID(IID_IDirectDraw2, 0xB3A6F3E0, 0x2B43, 0x11CF, 0xA2, 0xDE, 0x00, 0xAA, 0x00, 0xB9, 0x33, 0x56);
|
||||
DEFINE_GUID(IID_IDirectDraw4, 0x9c59509a, 0x39bd, 0x11d1, 0x8c, 0x4a, 0x00, 0xc0, 0x4f, 0xd9, 0x30, 0xc5);
|
||||
DEFINE_GUID(IID_IDirectDraw7, 0x15e65ec0, 0x3b9c, 0x11d2, 0xb9, 0x2f, 0x00, 0x60, 0x97, 0x97, 0xea, 0x5b);
|
||||
DEFINE_GUID(IID_IDirectDrawSurface, 0x6C14DB81, 0xA733, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60);
|
||||
DEFINE_GUID(IID_IDirectDrawSurface2, 0x57805885, 0x6eec, 0x11cf, 0x94, 0x41, 0xa8, 0x23, 0x03, 0xc1, 0x0e, 0x27);
|
||||
DEFINE_GUID(IID_IDirectDrawSurface3, 0xDA044E00, 0x69B2, 0x11D0, 0xA1, 0xD5, 0x00, 0xAA, 0x00, 0xB8, 0xDF, 0xBB);
|
||||
DEFINE_GUID(IID_IDirectDrawSurface4, 0x0B2B8630, 0xAD35, 0x11D0, 0x8E, 0xA6, 0x00, 0x60, 0x97, 0x97, 0xEA, 0x5B);
|
||||
DEFINE_GUID(IID_IDirectDrawSurface7, 0x06675a80, 0x3b9b, 0x11d2, 0xb9, 0x2f, 0x00, 0x60, 0x97, 0x97, 0xea, 0x5b);
|
||||
DEFINE_GUID(IID_IDirectDrawPalette, 0x6C14DB84, 0xA733, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60);
|
||||
DEFINE_GUID(IID_IDirectDrawClipper, 0x6C14DB85, 0xA733, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60);
|
||||
DEFINE_GUID(IID_IDirectDrawColorControl, 0x4B9F0EE0, 0x0D7E, 0x11D0, 0x9B, 0x06, 0x00, 0xA0, 0xC9, 0x03, 0xA3, 0xB8);
|
||||
DEFINE_GUID(IID_IDirectDrawGammaControl, 0x69C11C3E, 0xB46B, 0x11D1, 0xAD, 0x7A, 0x00, 0xC0, 0x4F, 0xC2, 0x9B, 0x4E);
|
||||
DEFINE_GUID(CLSID_AMMultiMediaStream, 0x49c47ce5, 0x9ba4, 0x11d0, 0x82, 0x12, 0x00, 0xc0, 0x4f, 0xc3, 0x2c, 0x45);
|
||||
DEFINE_GUID(CLSID_AMDirectDrawStream, 0x49c47ce4, 0x9ba4, 0x11d0, 0x82, 0x12, 0x00, 0xc0, 0x4f, 0xc3, 0x2c, 0x45);
|
||||
DEFINE_GUID(CLSID_AMAudioStream, 0x8496e040, 0xaf4c, 0x11d0, 0x82, 0x12, 0x00, 0xc0, 0x4f, 0xc3, 0x2c, 0x45);
|
||||
DEFINE_GUID(CLSID_AMAudioData, 0xf2468580, 0xaf8a, 0x11d0, 0x82, 0x12, 0x00, 0xc0, 0x4f, 0xc3, 0x2c, 0x45);
|
||||
DEFINE_GUID(CLSID_AMMediaTypeStream, 0xcf0f2f7c, 0xf7bf, 0x11d0, 0x90, 0xd, 0x0, 0xc0, 0x4f, 0xd9, 0x18, 0x9d);
|
||||
DEFINE_GUID(MSPID_PrimaryVideo, 0xa35ff56a, 0x9fda, 0x11d0, 0x8f, 0xdf, 0x0, 0xc0, 0x4f, 0xd9, 0x18, 0x9d);
|
||||
DEFINE_GUID(MSPID_PrimaryAudio, 0xa35ff56b, 0x9fda, 0x11d0, 0x8f, 0xdf, 0x0, 0xc0, 0x4f, 0xd9, 0x18, 0x9d);
|
||||
DEFINE_GUID(IID_IDirect3D7, 0xf5049e77, 0x4861, 0x11d2, 0xa4, 0x7, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0xa8);
|
||||
DEFINE_GUID(IID_IDirect3DRampDevice, 0xF2086B20, 0x259F, 0x11CF, 0xA3, 0x1A, 0x00, 0xAA, 0x00, 0xB9, 0x33, 0x56);
|
||||
DEFINE_GUID(IID_IDirect3DRGBDevice, 0xA4665C60, 0x2673, 0x11CF, 0xA3, 0x1A, 0x00, 0xAA, 0x00, 0xB9, 0x33, 0x56);
|
||||
DEFINE_GUID(IID_IDirect3DHALDevice, 0x84E63dE0, 0x46AA, 0x11CF, 0x81, 0x6F, 0x00, 0x00, 0xC0, 0x20, 0x15, 0x6E);
|
||||
DEFINE_GUID(IID_IDirect3DMMXDevice, 0x881949a1, 0xd6f3, 0x11d0, 0x89, 0xab, 0x00, 0xa0, 0xc9, 0x05, 0x41, 0x29);
|
||||
DEFINE_GUID(IID_IDirect3DRefDevice, 0x50936643, 0x13e9, 0x11d1, 0x89, 0xaa, 0x0, 0xa0, 0xc9, 0x5, 0x41, 0x29);
|
||||
DEFINE_GUID(IID_IDirect3DNullDevice, 0x8767df22, 0xbacc, 0x11d1, 0x89, 0x69, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0xa8);
|
||||
DEFINE_GUID(IID_IDirect3DTnLHalDevice, 0xf5049e78, 0x4861, 0x11d2, 0xa4, 0x7, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0xa8);
|
||||
+300
-302
@@ -1,4 +1,5 @@
|
||||
|
||||
#include "GraphicsRuntime.h"
|
||||
#include "std.h"
|
||||
#include "ddutil.h"
|
||||
#include "asmcoder.h"
|
||||
@@ -7,321 +8,327 @@
|
||||
|
||||
extern gxRuntime *gx_runtime;
|
||||
|
||||
#include "..\freeimage241\source\freeimage.h"
|
||||
#include "..\#ThirdParty\FreeImage\Dist\x32\freeimage.h"
|
||||
|
||||
static AsmCoder asm_coder;
|
||||
|
||||
static void calcShifts( unsigned mask,unsigned char *shr,unsigned char *shl ){
|
||||
if( mask ){
|
||||
for( *shl=0;!(mask&1);++*shl,mask>>=1 ){}
|
||||
for( *shr=8;mask&1;--*shr,mask>>=1 ){}
|
||||
}else *shr=*shl=0;
|
||||
static void calcShifts(unsigned mask, unsigned char *shr, unsigned char *shl) {
|
||||
if (mask) {
|
||||
for (*shl = 0; !(mask & 1); ++*shl, mask >>= 1) {}
|
||||
for (*shr = 8; mask & 1; --*shr, mask >>= 1) {}
|
||||
} else *shr = *shl = 0;
|
||||
}
|
||||
|
||||
PixelFormat::~PixelFormat(){
|
||||
if( plot_code ){
|
||||
VirtualFree( plot_code,0,MEM_RELEASE );
|
||||
PixelFormat::~PixelFormat() {
|
||||
if (plot_code) {
|
||||
VirtualFree(plot_code, 0, MEM_RELEASE);
|
||||
}
|
||||
}
|
||||
|
||||
void PixelFormat::setFormat( const DDPIXELFORMAT &pf ){
|
||||
if( plot_code ){
|
||||
VirtualFree( plot_code,0,MEM_RELEASE );
|
||||
void PixelFormat::setFormat(const DDPIXELFORMAT &pf) {
|
||||
if (plot_code) {
|
||||
VirtualFree(plot_code, 0, MEM_RELEASE);
|
||||
}
|
||||
|
||||
if( !(pf.dwFlags & DDPF_RGB) ){
|
||||
memset( this,0,sizeof(*this) );
|
||||
if (!(pf.dwFlags & DDPF_RGB)) {
|
||||
memset(this, 0, sizeof(*this));
|
||||
return;
|
||||
}
|
||||
|
||||
plot_code=(char*)VirtualAlloc( 0,128,MEM_COMMIT|MEM_RESERVE,PAGE_EXECUTE_READWRITE );
|
||||
point_code=plot_code+64;
|
||||
plot_code = (char*)VirtualAlloc(0, 128, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
|
||||
point_code = plot_code + 64;
|
||||
|
||||
depth=pf.dwRGBBitCount;
|
||||
amask=pf.dwRGBAlphaBitMask;
|
||||
rmask=pf.dwRBitMask;
|
||||
gmask=pf.dwGBitMask;
|
||||
bmask=pf.dwBBitMask;
|
||||
pitch=depth/8;argbfill=0;
|
||||
if( !amask ) argbfill|=0xff000000;
|
||||
if( !rmask ) argbfill|=0x00ff0000;
|
||||
if( !gmask ) argbfill|=0x0000ff00;
|
||||
if( !bmask ) argbfill|=0x000000ff;
|
||||
calcShifts( amask,&ashr,&ashl );ashr+=24;
|
||||
calcShifts( rmask,&rshr,&rshl );rshr+=16;
|
||||
calcShifts( gmask,&gshr,&gshl );gshr+=8;
|
||||
calcShifts( bmask,&bshr,&bshl );
|
||||
plot=(Plot)(void*)plot_code;
|
||||
point=(Point)(void*)point_code;
|
||||
asm_coder.CodePlot( plot_code,depth,amask,rmask,gmask,bmask );
|
||||
asm_coder.CodePoint( point_code,depth,amask,rmask,gmask,bmask );
|
||||
depth = pf.dwRGBBitCount;
|
||||
amask = pf.dwRGBAlphaBitMask;
|
||||
rmask = pf.dwRBitMask;
|
||||
gmask = pf.dwGBitMask;
|
||||
bmask = pf.dwBBitMask;
|
||||
pitch = depth / 8; argbfill = 0;
|
||||
if (!amask) argbfill |= 0xff000000;
|
||||
if (!rmask) argbfill |= 0x00ff0000;
|
||||
if (!gmask) argbfill |= 0x0000ff00;
|
||||
if (!bmask) argbfill |= 0x000000ff;
|
||||
calcShifts(amask, &ashr, &ashl); ashr += 24;
|
||||
calcShifts(rmask, &rshr, &rshl); rshr += 16;
|
||||
calcShifts(gmask, &gshr, &gshl); gshr += 8;
|
||||
calcShifts(bmask, &bshr, &bshl);
|
||||
plot = (Plot)(void*)plot_code;
|
||||
point = (Point)(void*)point_code;
|
||||
asm_coder.CodePlot(plot_code, depth, amask, rmask, gmask, bmask);
|
||||
asm_coder.CodePoint(point_code, depth, amask, rmask, gmask, bmask);
|
||||
}
|
||||
|
||||
static void adjustTexSize( int *width,int *height,IDirect3DDevice7 *dir3dDev ){
|
||||
D3DDEVICEDESC7 ddDesc={0};
|
||||
if( dir3dDev->GetCaps( &ddDesc )<0 ){
|
||||
*width=*height=256;
|
||||
static void adjustTexSize(int *width, int *height, IDirect3DDevice7 *dir3dDev) {
|
||||
D3DDEVICEDESC7 ddDesc = { 0 };
|
||||
if (dir3dDev->GetCaps(&ddDesc) < 0) {
|
||||
*width = *height = 256;
|
||||
return;
|
||||
}
|
||||
int w=*width,h=*height,min,max;
|
||||
int w = *width, h = *height, min, max;
|
||||
//make power of 2
|
||||
//Try *always* making POW2 size to fix GF6800 non-pow2 tex issue
|
||||
// if( ddDesc.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_POW2 ){
|
||||
for( w=1;w<*width;w<<=1 ){}
|
||||
for( h=1;h<*height;h<<=1 ){}
|
||||
// }
|
||||
//make square
|
||||
if( ddDesc.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_SQUAREONLY ){
|
||||
if( w>h ) h=w;
|
||||
else w=h;
|
||||
for (w = 1; w < *width; w <<= 1) {}
|
||||
for (h = 1; h < *height; h <<= 1) {}
|
||||
// }
|
||||
//make square
|
||||
if (ddDesc.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_SQUAREONLY) {
|
||||
if (w > h) h = w;
|
||||
else w = h;
|
||||
}
|
||||
//check aspect ratio
|
||||
if( max=ddDesc.dwMaxTextureAspectRatio ){
|
||||
int asp=w>h ? w/h : h/w;
|
||||
if( asp>max ){
|
||||
if( w>h ) h=w/max;
|
||||
else w=h/max;
|
||||
if (max = ddDesc.dwMaxTextureAspectRatio) {
|
||||
int asp = w > h ? w / h : h / w;
|
||||
if (asp > max) {
|
||||
if (w > h) h = w / max;
|
||||
else w = h / max;
|
||||
}
|
||||
}
|
||||
//clamp size
|
||||
if( (min=ddDesc.dwMinTextureWidth) && w<min ) w=min;
|
||||
if( (min=ddDesc.dwMinTextureHeight) && h<min ) h=min;
|
||||
if( (max=ddDesc.dwMaxTextureWidth) && w>max ) w=max;
|
||||
if( (max=ddDesc.dwMaxTextureHeight) && h>max ) h=max;
|
||||
if ((min = ddDesc.dwMinTextureWidth) && w < min) w = min;
|
||||
if ((min = ddDesc.dwMinTextureHeight) && h < min) h = min;
|
||||
if ((max = ddDesc.dwMaxTextureWidth) && w > max) w = max;
|
||||
if ((max = ddDesc.dwMaxTextureHeight) && h > max) h = max;
|
||||
|
||||
*width=w;*height=h;
|
||||
*width = w; *height = h;
|
||||
}
|
||||
|
||||
static ddSurf *createSurface( int width,int height,int pitch,void *bits,IDirectDraw7 *dirDraw ){
|
||||
DDSURFACEDESC2 desc={sizeof(desc)};
|
||||
desc.dwFlags=DDSD_WIDTH|DDSD_HEIGHT|DDSD_LPSURFACE|DDSD_PITCH|DDSD_PIXELFORMAT|DDSD_CAPS;
|
||||
desc.ddsCaps.dwCaps=DDSCAPS_OFFSCREENPLAIN|DDSCAPS_SYSTEMMEMORY;
|
||||
desc.dwWidth=width;desc.dwHeight=height;
|
||||
desc.lPitch=pitch;desc.lpSurface=bits;
|
||||
desc.ddpfPixelFormat.dwSize=sizeof(DDPIXELFORMAT);
|
||||
desc.ddpfPixelFormat.dwFlags=DDPF_RGB|DDPF_ALPHAPIXELS;
|
||||
desc.ddpfPixelFormat.dwRGBBitCount=32;
|
||||
desc.ddpfPixelFormat.dwRBitMask=0xff0000;
|
||||
desc.ddpfPixelFormat.dwGBitMask=0x00ff00;
|
||||
desc.ddpfPixelFormat.dwBBitMask=0x0000ff;
|
||||
desc.ddpfPixelFormat.dwRGBAlphaBitMask=0xff000000;
|
||||
static ddSurf *createSurface(int width, int height, int pitch, void *bits, IDirectDraw7 *dirDraw) {
|
||||
DDSURFACEDESC2 desc = { sizeof(desc) };
|
||||
desc.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_LPSURFACE | DDSD_PITCH | DDSD_PIXELFORMAT | DDSD_CAPS;
|
||||
desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
|
||||
desc.dwWidth = width; desc.dwHeight = height;
|
||||
desc.lPitch = pitch; desc.lpSurface = bits;
|
||||
desc.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
|
||||
desc.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
|
||||
desc.ddpfPixelFormat.dwRGBBitCount = 32;
|
||||
desc.ddpfPixelFormat.dwRBitMask = 0xff0000;
|
||||
desc.ddpfPixelFormat.dwGBitMask = 0x00ff00;
|
||||
desc.ddpfPixelFormat.dwBBitMask = 0x0000ff;
|
||||
desc.ddpfPixelFormat.dwRGBAlphaBitMask = 0xff000000;
|
||||
ddSurf *surf;
|
||||
if( dirDraw->CreateSurface( &desc,&surf,0 )>=0 ) return surf;
|
||||
if (dirDraw->CreateSurface(&desc, &surf, 0) >= 0) return surf;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void buildMask( ddSurf *surf ){
|
||||
DDSURFACEDESC2 desc={sizeof(desc)};
|
||||
surf->Lock( 0,&desc,DDLOCK_WAIT,0 );
|
||||
unsigned char *surf_p=(unsigned char*)desc.lpSurface;
|
||||
PixelFormat fmt( desc.ddpfPixelFormat );
|
||||
static void buildMask(ddSurf *surf) {
|
||||
DDSURFACEDESC2 desc = { sizeof(desc) };
|
||||
surf->Lock(0, &desc, DDLOCK_WAIT, 0);
|
||||
unsigned char *surf_p = (unsigned char*)desc.lpSurface;
|
||||
PixelFormat fmt(desc.ddpfPixelFormat);
|
||||
|
||||
for( int y=0;y<desc.dwHeight;++y ){
|
||||
unsigned char *p=surf_p;
|
||||
for( int x=0;x<desc.dwWidth;++x ){
|
||||
unsigned argb=fmt.getPixel( p );
|
||||
unsigned rgb=argb&0xffffff;
|
||||
unsigned a=rgb ? 0xff000000 : 0;
|
||||
fmt.setPixel( p,a|rgb );
|
||||
p+=fmt.getPitch();
|
||||
for (int y = 0; y < desc.dwHeight; ++y) {
|
||||
unsigned char *p = surf_p;
|
||||
for (int x = 0; x < desc.dwWidth; ++x) {
|
||||
unsigned argb = fmt.getPixel(p);
|
||||
unsigned rgb = argb & 0xffffff;
|
||||
unsigned a = rgb ? 0xff000000 : 0;
|
||||
fmt.setPixel(p, a | rgb);
|
||||
p += fmt.getPitch();
|
||||
}
|
||||
surf_p+=desc.lPitch;
|
||||
surf_p += desc.lPitch;
|
||||
}
|
||||
surf->Unlock( 0 );
|
||||
surf->Unlock(0);
|
||||
}
|
||||
|
||||
static void buildAlpha( ddSurf *surf,bool whiten ){
|
||||
static void buildAlpha(ddSurf *surf, bool whiten) {
|
||||
|
||||
DDSURFACEDESC2 desc={sizeof(desc)};
|
||||
surf->Lock( 0,&desc,DDLOCK_WAIT,0 );
|
||||
unsigned char *surf_p=(unsigned char*)desc.lpSurface;
|
||||
PixelFormat fmt( desc.ddpfPixelFormat );
|
||||
DDSURFACEDESC2 desc = { sizeof(desc) };
|
||||
surf->Lock(0, &desc, DDLOCK_WAIT, 0);
|
||||
unsigned char *surf_p = (unsigned char*)desc.lpSurface;
|
||||
PixelFormat fmt(desc.ddpfPixelFormat);
|
||||
|
||||
for( int y=0;y<desc.dwHeight;++y ){
|
||||
unsigned char *p=surf_p;
|
||||
for( int x=0;x<desc.dwWidth;++x ){
|
||||
unsigned argb=fmt.getPixel( p );
|
||||
unsigned alpha=(((argb>>16)&0xff)+((argb>>8)&0xff)+(argb&0xff))/3;
|
||||
argb=(alpha<<24) | (argb & 0xffffff);
|
||||
if( whiten ) argb|=0xffffff;
|
||||
fmt.setPixel( p,argb );
|
||||
p+=fmt.getPitch();
|
||||
for (int y = 0; y < desc.dwHeight; ++y) {
|
||||
unsigned char *p = surf_p;
|
||||
for (int x = 0; x < desc.dwWidth; ++x) {
|
||||
unsigned argb = fmt.getPixel(p);
|
||||
unsigned alpha = (((argb >> 16) & 0xff) + ((argb >> 8) & 0xff) + (argb & 0xff)) / 3;
|
||||
argb = (alpha << 24) | (argb & 0xffffff);
|
||||
if (whiten) argb |= 0xffffff;
|
||||
fmt.setPixel(p, argb);
|
||||
p += fmt.getPitch();
|
||||
}
|
||||
surf_p+=desc.lPitch;
|
||||
surf_p += desc.lPitch;
|
||||
}
|
||||
surf->Unlock( 0 );
|
||||
surf->Unlock(0);
|
||||
}
|
||||
|
||||
void ddUtil::buildMipMaps( ddSurf *surf ){
|
||||
void ddUtil::buildMipMaps(ddSurf *surf) {
|
||||
|
||||
DDSURFACEDESC2 desc={sizeof(desc)};
|
||||
surf->GetSurfaceDesc( &desc );
|
||||
if( !(desc.ddsCaps.dwCaps & DDSCAPS_TEXTURE) ) return;
|
||||
if( !(desc.ddpfPixelFormat.dwFlags & DDPF_RGB) ) return;
|
||||
DDSURFACEDESC2 desc = { sizeof(desc) };
|
||||
surf->GetSurfaceDesc(&desc);
|
||||
if (!(desc.ddsCaps.dwCaps & DDSCAPS_TEXTURE)) return;
|
||||
if (!(desc.ddpfPixelFormat.dwFlags & DDPF_RGB)) return;
|
||||
|
||||
DDSCAPS2 caps={0};
|
||||
caps.dwCaps=DDSCAPS_TEXTURE;
|
||||
caps.dwCaps2=DDSCAPS2_MIPMAPSUBLEVEL;
|
||||
DDSCAPS2 caps = { 0 };
|
||||
caps.dwCaps = DDSCAPS_TEXTURE;
|
||||
caps.dwCaps2 = DDSCAPS2_MIPMAPSUBLEVEL;
|
||||
|
||||
IDirectDrawSurface7 *src=surf,*dest;
|
||||
IDirectDrawSurface7 *src = surf, *dest;
|
||||
|
||||
while( src->GetAttachedSurface( &caps,&dest )>=0 ){
|
||||
while (src->GetAttachedSurface(&caps, &dest) >= 0) {
|
||||
|
||||
DDSURFACEDESC2 src_desc={sizeof(src_desc)};
|
||||
if( src->Lock( 0,&src_desc,DDLOCK_WAIT,0 )<0 ) abort();
|
||||
unsigned char *src_p=(unsigned char*)src_desc.lpSurface;
|
||||
PixelFormat src_fmt( src_desc.ddpfPixelFormat );
|
||||
DDSURFACEDESC2 src_desc = { sizeof(src_desc) };
|
||||
if (src->Lock(0, &src_desc, DDLOCK_WAIT, 0) < 0) abort();
|
||||
unsigned char *src_p = (unsigned char*)src_desc.lpSurface;
|
||||
PixelFormat src_fmt(src_desc.ddpfPixelFormat);
|
||||
|
||||
DDSURFACEDESC2 dest_desc={sizeof(dest_desc)};
|
||||
if( dest->Lock( 0,&dest_desc,DDLOCK_WAIT,0 )<0 ) abort();
|
||||
unsigned char *dest_p=(unsigned char *)dest_desc.lpSurface;
|
||||
PixelFormat dest_fmt( dest_desc.ddpfPixelFormat );
|
||||
DDSURFACEDESC2 dest_desc = { sizeof(dest_desc) };
|
||||
if (dest->Lock(0, &dest_desc, DDLOCK_WAIT, 0) < 0) abort();
|
||||
unsigned char *dest_p = (unsigned char *)dest_desc.lpSurface;
|
||||
PixelFormat dest_fmt(dest_desc.ddpfPixelFormat);
|
||||
|
||||
if( src_desc.dwWidth==1 ){
|
||||
for( int y=0;y<dest_desc.dwHeight;++y ){
|
||||
unsigned p1=src_fmt.getPixel( src_p );
|
||||
unsigned p2=src_fmt.getPixel( src_p+src_desc.lPitch );
|
||||
unsigned argb=
|
||||
((p1&0xfefefefe)>>1)+((p2&0xfefefefe)>>1);
|
||||
argb+=( (
|
||||
(p1&0x01010101)+(p2&0x01010101) )>>1 ) & 0x01010101;
|
||||
dest_fmt.setPixel( dest_p,argb );
|
||||
src_p+=src_desc.lPitch*2;
|
||||
dest_p+=dest_desc.lPitch;
|
||||
if (src_desc.dwWidth == 1) {
|
||||
for (int y = 0; y < dest_desc.dwHeight; ++y) {
|
||||
unsigned p1 = src_fmt.getPixel(src_p);
|
||||
unsigned p2 = src_fmt.getPixel(src_p + src_desc.lPitch);
|
||||
unsigned argb =
|
||||
((p1 & 0xfefefefe) >> 1) + ((p2 & 0xfefefefe) >> 1);
|
||||
argb += ((
|
||||
(p1 & 0x01010101) + (p2 & 0x01010101)) >> 1) & 0x01010101;
|
||||
dest_fmt.setPixel(dest_p, argb);
|
||||
src_p += src_desc.lPitch * 2;
|
||||
dest_p += dest_desc.lPitch;
|
||||
}
|
||||
}else if( src_desc.dwHeight==1 ){
|
||||
for( int x=0;x<dest_desc.dwWidth;++x ){
|
||||
unsigned p1=src_fmt.getPixel( src_p );
|
||||
unsigned p2=src_fmt.getPixel( src_p+src_fmt.getPitch() );
|
||||
unsigned argb=
|
||||
((p1&0xfefefefe)>>1)+((p2&0xfefefefe)>>1);
|
||||
argb+=( (
|
||||
(p1&0x01010101)+(p2&0x01010101) )>>1 ) & 0x01010101;
|
||||
dest_fmt.setPixel( dest_p,argb );
|
||||
src_p+=src_fmt.getPitch()*2;
|
||||
dest_p+=dest_fmt.getPitch();
|
||||
} else if (src_desc.dwHeight == 1) {
|
||||
for (int x = 0; x < dest_desc.dwWidth; ++x) {
|
||||
unsigned p1 = src_fmt.getPixel(src_p);
|
||||
unsigned p2 = src_fmt.getPixel(src_p + src_fmt.getPitch());
|
||||
unsigned argb =
|
||||
((p1 & 0xfefefefe) >> 1) + ((p2 & 0xfefefefe) >> 1);
|
||||
argb += ((
|
||||
(p1 & 0x01010101) + (p2 & 0x01010101)) >> 1) & 0x01010101;
|
||||
dest_fmt.setPixel(dest_p, argb);
|
||||
src_p += src_fmt.getPitch() * 2;
|
||||
dest_p += dest_fmt.getPitch();
|
||||
}
|
||||
}else{
|
||||
for( int y=0;y<dest_desc.dwHeight;++y ){
|
||||
unsigned char *src_t=src_p;
|
||||
unsigned char *dest_t=dest_p;
|
||||
for( int x=0;x<dest_desc.dwWidth;++x ){
|
||||
} else {
|
||||
for (int y = 0; y < dest_desc.dwHeight; ++y) {
|
||||
unsigned char *src_t = src_p;
|
||||
unsigned char *dest_t = dest_p;
|
||||
for (int x = 0; x < dest_desc.dwWidth; ++x) {
|
||||
|
||||
unsigned p1=src_fmt.getPixel( src_t );
|
||||
unsigned p2=src_fmt.getPixel( src_t+src_fmt.getPitch() );
|
||||
unsigned p3=src_fmt.getPixel( src_t+src_desc.lPitch+src_fmt.getPitch() );
|
||||
unsigned p4=src_fmt.getPixel( src_t+src_desc.lPitch );
|
||||
unsigned p1 = src_fmt.getPixel(src_t);
|
||||
unsigned p2 = src_fmt.getPixel(src_t + src_fmt.getPitch());
|
||||
unsigned p3 = src_fmt.getPixel(src_t + src_desc.lPitch + src_fmt.getPitch());
|
||||
unsigned p4 = src_fmt.getPixel(src_t + src_desc.lPitch);
|
||||
|
||||
unsigned argb=
|
||||
((p1&0xfcfcfcfc)>>2)+((p2&0xfcfcfcfc)>>2)+
|
||||
((p3&0xfcfcfcfc)>>2)+((p4&0xfcfcfcfc)>>2);
|
||||
argb+=( (
|
||||
(p1&0x03030303)+(p2&0x03030303)+
|
||||
(p3&0x03030303)+(p4&0x03030303) )>>2 ) & 0x03030303;
|
||||
unsigned argb =
|
||||
((p1 & 0xfcfcfcfc) >> 2) + ((p2 & 0xfcfcfcfc) >> 2) +
|
||||
((p3 & 0xfcfcfcfc) >> 2) + ((p4 & 0xfcfcfcfc) >> 2);
|
||||
argb += ((
|
||||
(p1 & 0x03030303) + (p2 & 0x03030303) +
|
||||
(p3 & 0x03030303) + (p4 & 0x03030303)) >> 2) & 0x03030303;
|
||||
|
||||
dest_fmt.setPixel( dest_t,argb );
|
||||
src_t+=src_fmt.getPitch()*2;
|
||||
dest_t+=dest_fmt.getPitch();
|
||||
dest_fmt.setPixel(dest_t, argb);
|
||||
src_t += src_fmt.getPitch() * 2;
|
||||
dest_t += dest_fmt.getPitch();
|
||||
}
|
||||
src_p+=src_desc.lPitch*2;
|
||||
dest_p+=dest_desc.lPitch;
|
||||
src_p += src_desc.lPitch * 2;
|
||||
dest_p += dest_desc.lPitch;
|
||||
}
|
||||
}
|
||||
src->Unlock( 0 );
|
||||
dest->Unlock( 0 );
|
||||
src->Unlock(0);
|
||||
dest->Unlock(0);
|
||||
dest->Release();
|
||||
src=dest;
|
||||
src = dest;
|
||||
}
|
||||
}
|
||||
|
||||
void ddUtil::copy( ddSurf *dest,int dx,int dy,int dw,int dh,ddSurf *src,int sx,int sy,int sw,int sh ){
|
||||
void ddUtil::copy(ddSurf *dest, int dx, int dy, int dw, int dh, ddSurf *src, int sx, int sy, int sw, int sh) {
|
||||
|
||||
DDSURFACEDESC2 src_desc={sizeof(src_desc)};
|
||||
src->Lock( 0,&src_desc,DDLOCK_WAIT,0 );
|
||||
PixelFormat src_fmt( src_desc.ddpfPixelFormat );
|
||||
unsigned char *src_p=(unsigned char*)src_desc.lpSurface;
|
||||
src_p+=src_desc.lPitch*sy+src_fmt.getPitch()*sx;
|
||||
DDSURFACEDESC2 src_desc = { sizeof(src_desc) };
|
||||
src->Lock(0, &src_desc, DDLOCK_WAIT, 0);
|
||||
PixelFormat src_fmt(src_desc.ddpfPixelFormat);
|
||||
unsigned char *src_p = (unsigned char*)src_desc.lpSurface;
|
||||
src_p += src_desc.lPitch*sy + src_fmt.getPitch()*sx;
|
||||
|
||||
DDSURFACEDESC2 dest_desc={sizeof(dest_desc)};
|
||||
dest->Lock( 0,&dest_desc,DDLOCK_WAIT,0 );
|
||||
PixelFormat dest_fmt( dest_desc.ddpfPixelFormat );
|
||||
unsigned char *dest_p=(unsigned char *)dest_desc.lpSurface;
|
||||
dest_p+=dest_desc.lPitch*dy+dest_fmt.getPitch()*dx;
|
||||
DDSURFACEDESC2 dest_desc = { sizeof(dest_desc) };
|
||||
dest->Lock(0, &dest_desc, DDLOCK_WAIT, 0);
|
||||
PixelFormat dest_fmt(dest_desc.ddpfPixelFormat);
|
||||
unsigned char *dest_p = (unsigned char *)dest_desc.lpSurface;
|
||||
dest_p += dest_desc.lPitch*dy + dest_fmt.getPitch()*dx;
|
||||
|
||||
for( int y=0;y<dh;++y ){
|
||||
unsigned char *dest=dest_p;
|
||||
unsigned char *src=src_p+src_desc.lPitch*(y*sh/dh);
|
||||
for( int x=0;x<dw;++x ){
|
||||
dest_fmt.setPixel( dest,src_fmt.getPixel( src+src_fmt.getPitch()*(x*sw/dw) ) );
|
||||
dest+=dest_fmt.getPitch();
|
||||
for (int y = 0; y < dh; ++y) {
|
||||
unsigned char *dest = dest_p;
|
||||
unsigned char *src = src_p + src_desc.lPitch*(y*sh / dh);
|
||||
for (int x = 0; x < dw; ++x) {
|
||||
dest_fmt.setPixel(dest, src_fmt.getPixel(src + src_fmt.getPitch()*(x*sw / dw)));
|
||||
dest += dest_fmt.getPitch();
|
||||
}
|
||||
dest_p+=dest_desc.lPitch;
|
||||
dest_p += dest_desc.lPitch;
|
||||
}
|
||||
|
||||
src->Unlock( 0 );
|
||||
dest->Unlock( 0 );
|
||||
src->Unlock(0);
|
||||
dest->Unlock(0);
|
||||
}
|
||||
|
||||
ddSurf *ddUtil::createSurface( int w,int h,int flags,gxGraphics *gfx ){
|
||||
ddSurf *ddUtil::createSurface(int w, int h, int flags, gxGraphics *gfx) {
|
||||
|
||||
DDSURFACEDESC2 desc={sizeof(desc)};
|
||||
DDSURFACEDESC2 desc = { sizeof(desc) };
|
||||
|
||||
desc.dwFlags=DDSD_CAPS;
|
||||
desc.dwFlags = DDSD_CAPS;
|
||||
|
||||
int hi=flags & gxCanvas::CANVAS_TEX_HICOLOR?1:0;
|
||||
int hi = flags & gxCanvas::CANVAS_TEX_HICOLOR ? 1 : 0;
|
||||
|
||||
if( w ){ desc.dwWidth=w;desc.dwFlags|=DDSD_WIDTH; }
|
||||
if( h ){ desc.dwHeight=h;desc.dwFlags|=DDSD_HEIGHT; }
|
||||
if (w) { desc.dwWidth = w; desc.dwFlags |= DDSD_WIDTH; }
|
||||
if (h) { desc.dwHeight = h; desc.dwFlags |= DDSD_HEIGHT; }
|
||||
|
||||
if( flags & gxCanvas::CANVAS_TEX_MASK ){
|
||||
desc.dwFlags|=DDSD_PIXELFORMAT;
|
||||
desc.ddpfPixelFormat=gfx->texRGBMaskFmt[hi];
|
||||
}else if( flags & gxCanvas::CANVAS_TEX_RGB ){
|
||||
desc.dwFlags|=DDSD_PIXELFORMAT;
|
||||
desc.ddpfPixelFormat=(flags&gxCanvas::CANVAS_TEX_ALPHA)?gfx->texRGBAlphaFmt[hi]:gfx->texRGBFmt[hi];
|
||||
}else if( flags & gxCanvas::CANVAS_TEX_ALPHA ){
|
||||
desc.dwFlags|=DDSD_PIXELFORMAT;
|
||||
desc.ddpfPixelFormat=gfx->texAlphaFmt[hi];
|
||||
}else if( flags & gxCanvas::CANVAS_TEXTURE ){
|
||||
desc.dwFlags|=DDSD_PIXELFORMAT;
|
||||
desc.ddpfPixelFormat=gfx->primFmt;
|
||||
if (flags & gxCanvas::CANVAS_TEX_MASK) {
|
||||
desc.dwFlags |= DDSD_PIXELFORMAT;
|
||||
desc.ddpfPixelFormat = gfx->texRGBMaskFmt[hi];
|
||||
} else if (flags & gxCanvas::CANVAS_TEX_RGB) {
|
||||
desc.dwFlags |= DDSD_PIXELFORMAT;
|
||||
desc.ddpfPixelFormat = (flags&gxCanvas::CANVAS_TEX_ALPHA) ? gfx->texRGBAlphaFmt[hi] : gfx->texRGBFmt[hi];
|
||||
} else if (flags & gxCanvas::CANVAS_TEX_ALPHA) {
|
||||
desc.dwFlags |= DDSD_PIXELFORMAT;
|
||||
desc.ddpfPixelFormat = gfx->texAlphaFmt[hi];
|
||||
} else if (flags & gxCanvas::CANVAS_TEXTURE) {
|
||||
desc.dwFlags |= DDSD_PIXELFORMAT;
|
||||
desc.ddpfPixelFormat = gfx->primFmt;
|
||||
}
|
||||
if( flags & gxCanvas::CANVAS_TEXTURE ){
|
||||
desc.ddsCaps.dwCaps|=DDSCAPS_TEXTURE;
|
||||
if( !(flags & gxCanvas::CANVAS_TEX_VIDMEM) ){
|
||||
desc.ddsCaps.dwCaps2|=DDSCAPS2_TEXTUREMANAGE;
|
||||
if( flags & gxCanvas::CANVAS_TEX_MIPMAP ){
|
||||
desc.ddsCaps.dwCaps|=DDSCAPS_MIPMAP|DDSCAPS_COMPLEX;
|
||||
|
||||
if (flags & gxCanvas::CANVAS_TEXTURE) {
|
||||
desc.ddsCaps.dwCaps |= DDSCAPS_TEXTURE;
|
||||
if (!(flags & gxCanvas::CANVAS_TEX_VIDMEM)) {
|
||||
desc.ddsCaps.dwCaps2 |= DDSCAPS2_TEXTUREMANAGE;
|
||||
if (flags & gxCanvas::CANVAS_TEX_MIPMAP) {
|
||||
desc.ddsCaps.dwCaps |= DDSCAPS_MIPMAP | DDSCAPS_COMPLEX;
|
||||
}
|
||||
}
|
||||
if( flags & (gxCanvas::CANVAS_TEX_CUBE) ){
|
||||
desc.ddsCaps.dwCaps|=DDSCAPS_COMPLEX;
|
||||
desc.ddsCaps.dwCaps2|=DDSCAPS2_CUBEMAP|DDSCAPS2_CUBEMAP_ALLFACES;
|
||||
if (flags & (gxCanvas::CANVAS_TEX_CUBE)) {
|
||||
desc.ddsCaps.dwCaps |= DDSCAPS_COMPLEX;
|
||||
desc.ddsCaps.dwCaps2 |= DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_ALLFACES;
|
||||
}
|
||||
adjustTexSize( (int*)&desc.dwWidth,(int*)&desc.dwHeight,gfx->dir3dDev );
|
||||
}else{
|
||||
desc.ddsCaps.dwCaps=DDSCAPS_OFFSCREENPLAIN;
|
||||
if( flags & gxCanvas::CANVAS_HIGHCOLOR ){
|
||||
desc.dwFlags|=DDSD_PIXELFORMAT;
|
||||
desc.ddsCaps.dwCaps|=DDSCAPS_SYSTEMMEMORY;
|
||||
desc.ddpfPixelFormat.dwSize=sizeof(DDPIXELFORMAT);
|
||||
desc.ddpfPixelFormat.dwFlags=DDPF_RGB|DDPF_ALPHAPIXELS;
|
||||
desc.ddpfPixelFormat.dwRGBBitCount=32;
|
||||
desc.ddpfPixelFormat.dwRBitMask=0xff0000;
|
||||
desc.ddpfPixelFormat.dwGBitMask=0x00ff00;
|
||||
desc.ddpfPixelFormat.dwBBitMask=0x0000ff;
|
||||
desc.ddpfPixelFormat.dwRGBAlphaBitMask=0xff000000;
|
||||
}else if( flags & gxCanvas::CANVAS_NONDISPLAY ){
|
||||
desc.ddsCaps.dwCaps|=DDSCAPS_SYSTEMMEMORY;
|
||||
adjustTexSize((int*)&desc.dwWidth, (int*)&desc.dwHeight, gfx->dir3dDev);
|
||||
} else {
|
||||
desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
||||
if (flags & gxCanvas::CANVAS_HIGHCOLOR) {
|
||||
desc.dwFlags |= DDSD_PIXELFORMAT;
|
||||
desc.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY;
|
||||
desc.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
|
||||
desc.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
|
||||
desc.ddpfPixelFormat.dwRGBBitCount = 32;
|
||||
desc.ddpfPixelFormat.dwRBitMask = 0xff0000;
|
||||
desc.ddpfPixelFormat.dwGBitMask = 0x00ff00;
|
||||
desc.ddpfPixelFormat.dwBBitMask = 0x0000ff;
|
||||
desc.ddpfPixelFormat.dwRGBAlphaBitMask = 0xff000000;
|
||||
} else if (flags & gxCanvas::CANVAS_NONDISPLAY) {
|
||||
desc.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & gxCanvas::CANVAS_3DRENDER) {
|
||||
desc.ddsCaps.dwCaps = DDSCAPS_3DDEVICE | DDSCAPS_LOCALVIDMEM;
|
||||
}
|
||||
|
||||
ddSurf *surf;
|
||||
if( gfx->dirDraw->CreateSurface( &desc,&surf,0 )>=0 ) return surf;
|
||||
if( desc.ddsCaps.dwCaps & DDSCAPS_OFFSCREENPLAIN ){
|
||||
if( !(desc.ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY) ){
|
||||
if (gfx->dirDraw->CreateSurface(&desc, &surf, 0) >= 0) return surf;
|
||||
if (desc.ddsCaps.dwCaps & DDSCAPS_OFFSCREENPLAIN) {
|
||||
if (!(desc.ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY)) {
|
||||
//try again in system memory!
|
||||
desc.ddsCaps.dwCaps|=DDSCAPS_SYSTEMMEMORY;
|
||||
if( gfx->dirDraw->CreateSurface( &desc,&surf,0 )>=0 ) return surf;
|
||||
desc.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY;
|
||||
if (gfx->dirDraw->CreateSurface(&desc, &surf, 0) >= 0) return surf;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -329,8 +336,7 @@ ddSurf *ddUtil::createSurface( int w,int h,int flags,gxGraphics *gfx ){
|
||||
|
||||
//Tom Speed's DXTC loader
|
||||
//
|
||||
IDirectDrawSurface7 *loadDXTC(const char* filename,gxGraphics *gfx)
|
||||
{
|
||||
IDirectDrawSurface7 *loadDXTC(const char* filename, gxGraphics *gfx) {
|
||||
HRESULT hr;
|
||||
DDSURFACEDESC2 ddsd;
|
||||
DDSURFACEDESC2 fileddsd;
|
||||
@@ -339,12 +345,11 @@ IDirectDrawSurface7 *loadDXTC(const char* filename,gxGraphics *gfx)
|
||||
|
||||
/* try to open the file */
|
||||
fp = fopen(filename, "rb");
|
||||
if(!fp) return NULL;
|
||||
if (!fp) return NULL;
|
||||
|
||||
/* valid DDS? */
|
||||
fread(magicID, 1, 4, fp);
|
||||
if (strncmp(magicID, "DDS ", 4) != 0)
|
||||
{
|
||||
if (strncmp(magicID, "DDS ", 4) != 0) {
|
||||
fclose(fp);
|
||||
return NULL;
|
||||
}
|
||||
@@ -352,15 +357,14 @@ IDirectDrawSurface7 *loadDXTC(const char* filename,gxGraphics *gfx)
|
||||
/* get the DXTC file surface description */
|
||||
fread(&fileddsd, sizeof(DDSURFACEDESC2), 1, fp);
|
||||
|
||||
if (fileddsd.dwSize != sizeof(DDSURFACEDESC2))
|
||||
{
|
||||
if (fileddsd.dwSize != sizeof(DDSURFACEDESC2)) {
|
||||
fclose(fp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* copy the fileddsd before we manipulate it so you
|
||||
can get neccessary info you want about it later */
|
||||
memcpy(&ddsd, &fileddsd,sizeof(DDSURFACEDESC2));
|
||||
memcpy(&ddsd, &fileddsd, sizeof(DDSURFACEDESC2));
|
||||
|
||||
/* remove unwanted flags if they exist */
|
||||
//not sure if this is needed, works without it though
|
||||
@@ -369,29 +373,27 @@ IDirectDrawSurface7 *loadDXTC(const char* filename,gxGraphics *gfx)
|
||||
int blockSize = 0;
|
||||
int chunkSize = 0;
|
||||
|
||||
if(ddsd.ddpfPixelFormat.dwFourCC == FOURCC_DXT1)
|
||||
if (ddsd.ddpfPixelFormat.dwFourCC == FOURCC_DXT1)
|
||||
blockSize = 8; // DXT1
|
||||
if(ddsd.ddpfPixelFormat.dwFourCC == FOURCC_DXT3)
|
||||
if (ddsd.ddpfPixelFormat.dwFourCC == FOURCC_DXT3)
|
||||
blockSize = 16; // DXT3
|
||||
if(ddsd.ddpfPixelFormat.dwFourCC == FOURCC_DXT5)
|
||||
if (ddsd.ddpfPixelFormat.dwFourCC == FOURCC_DXT5)
|
||||
blockSize = 16; // DXT5
|
||||
|
||||
/* if it isn't a format we support, exit */
|
||||
if (blockSize == 0)
|
||||
{
|
||||
if (blockSize == 0) {
|
||||
fclose(fp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* add texture manage flag */
|
||||
ddsd.ddsCaps.dwCaps2|=DDSCAPS2_TEXTUREMANAGE;
|
||||
ddsd.ddsCaps.dwCaps2 |= DDSCAPS2_TEXTUREMANAGE;
|
||||
|
||||
/* Create the new DXTC surface using the DDSURFACEDESC2
|
||||
we read in from the file */
|
||||
IDirectDrawSurface7 * newSurf = NULL;
|
||||
hr = gfx->dirDraw->CreateSurface(&ddsd, &newSurf, NULL);
|
||||
if(FAILED(hr))
|
||||
{
|
||||
if (FAILED(hr)) {
|
||||
fclose(fp);
|
||||
return NULL;
|
||||
}
|
||||
@@ -399,8 +401,8 @@ IDirectDrawSurface7 *loadDXTC(const char* filename,gxGraphics *gfx)
|
||||
/* Define what type of child surfaces we may wish
|
||||
to access, in this case MipMaps */
|
||||
DDSCAPS2 mipmapddsd;
|
||||
ZeroMemory(&mipmapddsd,sizeof(DDSCAPS2));
|
||||
mipmapddsd.dwCaps = DDSCAPS_TEXTURE|DDSCAPS_MIPMAP|DDSCAPS_COMPLEX;
|
||||
ZeroMemory(&mipmapddsd, sizeof(DDSCAPS2));
|
||||
mipmapddsd.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP | DDSCAPS_COMPLEX;
|
||||
|
||||
/* pointers used when iterating through mipmaps */
|
||||
IDirectDrawSurface7 *topDDS = NULL;
|
||||
@@ -409,12 +411,10 @@ IDirectDrawSurface7 *loadDXTC(const char* filename,gxGraphics *gfx)
|
||||
topDDS = newSurf;
|
||||
topDDS->AddRef();
|
||||
|
||||
while(TRUE)
|
||||
{
|
||||
while (TRUE) {
|
||||
/* get a description of this surface */
|
||||
hr = topDDS->Lock(NULL,&ddsd,DDLOCK_WAIT,NULL);
|
||||
if(FAILED(hr))
|
||||
{
|
||||
hr = topDDS->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
|
||||
if (FAILED(hr)) {
|
||||
fclose(fp);
|
||||
topDDS->Release();
|
||||
newSurf->Release();
|
||||
@@ -423,11 +423,10 @@ IDirectDrawSurface7 *loadDXTC(const char* filename,gxGraphics *gfx)
|
||||
}
|
||||
|
||||
/* how big the raw data is for this surface */
|
||||
chunkSize = ((ddsd.dwWidth+3)/4) * ((ddsd.dwHeight+3)/4) * blockSize;
|
||||
chunkSize = ((ddsd.dwWidth + 3) / 4) * ((ddsd.dwHeight + 3) / 4) * blockSize;
|
||||
|
||||
/* read in the raw DXTC surface data */
|
||||
if(!fread(ddsd.lpSurface, chunkSize, 1, fp))
|
||||
{
|
||||
if (!fread(ddsd.lpSurface, chunkSize, 1, fp)) {
|
||||
fclose(fp);
|
||||
topDDS->Release();
|
||||
newSurf->Release();
|
||||
@@ -438,9 +437,8 @@ IDirectDrawSurface7 *loadDXTC(const char* filename,gxGraphics *gfx)
|
||||
|
||||
|
||||
/* Get next mipmap in chain, or exit the loop if there's no more */
|
||||
hr = topDDS->GetAttachedSurface(&mipmapddsd,&nextDDS);
|
||||
if(FAILED(hr))
|
||||
{
|
||||
hr = topDDS->GetAttachedSurface(&mipmapddsd, &nextDDS);
|
||||
if (FAILED(hr)) {
|
||||
fclose(fp);
|
||||
topDDS->Release();
|
||||
break;
|
||||
@@ -454,72 +452,72 @@ IDirectDrawSurface7 *loadDXTC(const char* filename,gxGraphics *gfx)
|
||||
return newSurf;
|
||||
}
|
||||
|
||||
ddSurf *ddUtil::loadSurface( const std::string &f,int flags,gxGraphics *gfx ){
|
||||
ddSurf *ddUtil::loadSurface(const std::string &f, int flags, gxGraphics *gfx) {
|
||||
|
||||
int i=f.find( ".dds" );
|
||||
if( i!=string::npos && i+4==f.size() ){
|
||||
int i = f.find(".dds");
|
||||
if (i != string::npos && i + 4 == f.size()) {
|
||||
//dds file!
|
||||
ddSurf *surf=loadDXTC( f.c_str(),gfx );
|
||||
ddSurf *surf = loadDXTC(f.c_str(), gfx);
|
||||
return surf;
|
||||
}
|
||||
|
||||
FreeImage_Initialise();
|
||||
FREE_IMAGE_FORMAT fmt=FreeImage_GetFileType( f.c_str(),f.size() );
|
||||
if( fmt==FIF_UNKNOWN ){
|
||||
int n=f.find( "." );if( n==string::npos ) return 0;
|
||||
fmt=FreeImage_GetFileTypeFromExt( f.substr(n+1).c_str() );
|
||||
if( fmt==FIF_UNKNOWN ) return 0;
|
||||
FREE_IMAGE_FORMAT fmt = FreeImage_GetFileType(f.c_str(), f.size());
|
||||
if (fmt == FIF_UNKNOWN) {
|
||||
int n = f.find("."); if (n == string::npos) return 0;
|
||||
fmt = FreeImage_GetFileType(f.c_str());
|
||||
if (fmt == FIF_UNKNOWN) return 0;
|
||||
}
|
||||
FIBITMAP *t_dib=FreeImage_Load( fmt,f.c_str(),0 );
|
||||
if( !t_dib ) return 0;
|
||||
FIBITMAP *t_dib = FreeImage_Load(fmt, f.c_str(), 0);
|
||||
if (!t_dib) return 0;
|
||||
|
||||
bool trans=FreeImage_GetBPP( t_dib )==32 || FreeImage_IsTransparent( t_dib );
|
||||
bool trans = FreeImage_GetBPP(t_dib) == 32 || FreeImage_IsTransparent(t_dib);
|
||||
|
||||
FIBITMAP *dib=FreeImage_ConvertTo32Bits( t_dib );
|
||||
|
||||
if( dib ) FreeImage_Unload( t_dib );
|
||||
else dib=t_dib;
|
||||
FIBITMAP *dib = FreeImage_ConvertTo32Bits(t_dib);
|
||||
|
||||
int width=FreeImage_GetWidth(dib);
|
||||
int height=FreeImage_GetHeight(dib);
|
||||
int pitch=FreeImage_GetPitch(dib);
|
||||
void *bits=FreeImage_GetBits(dib);
|
||||
if (dib) FreeImage_Unload(t_dib);
|
||||
else dib = t_dib;
|
||||
|
||||
ddSurf *src=::createSurface( width,height,pitch,bits,gfx->dirDraw );
|
||||
if( !src ){
|
||||
FreeImage_Unload( dib );
|
||||
int width = FreeImage_GetWidth(dib);
|
||||
int height = FreeImage_GetHeight(dib);
|
||||
int pitch = FreeImage_GetPitch(dib);
|
||||
void *bits = FreeImage_GetBits(dib);
|
||||
|
||||
ddSurf *src = ::createSurface(width, height, pitch, bits, gfx->dirDraw);
|
||||
if (!src) {
|
||||
FreeImage_Unload(dib);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( flags & gxCanvas::CANVAS_TEX_ALPHA ){
|
||||
if( flags & gxCanvas::CANVAS_TEX_MASK ){
|
||||
buildMask( src );
|
||||
}else if( !trans ){
|
||||
buildAlpha( src,(flags & gxCanvas::CANVAS_TEX_RGB)?false:true );
|
||||
if (flags & gxCanvas::CANVAS_TEX_ALPHA) {
|
||||
if (flags & gxCanvas::CANVAS_TEX_MASK) {
|
||||
buildMask(src);
|
||||
} else if (!trans) {
|
||||
buildAlpha(src, (flags & gxCanvas::CANVAS_TEX_RGB) ? false : true);
|
||||
}
|
||||
}else{
|
||||
unsigned char *p=(unsigned char *)bits;
|
||||
for( int k=0;k<height;++k ){
|
||||
unsigned char *t=p+3;
|
||||
for( int j=0;j<width;++j ){
|
||||
*t=0xff;t+=4;
|
||||
} else {
|
||||
unsigned char *p = (unsigned char *)bits;
|
||||
for (int k = 0; k < height; ++k) {
|
||||
unsigned char *t = p + 3;
|
||||
for (int j = 0; j < width; ++j) {
|
||||
*t = 0xff; t += 4;
|
||||
}
|
||||
p+=pitch;
|
||||
p += pitch;
|
||||
}
|
||||
}
|
||||
|
||||
ddSurf *dest=createSurface( width,height,flags,gfx );
|
||||
if( !dest ){
|
||||
ddSurf *dest = createSurface(width, height, flags, gfx);
|
||||
if (!dest) {
|
||||
src->Release();
|
||||
FreeImage_Unload( dib );
|
||||
FreeImage_Unload(dib);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int t_w=width,t_h=height;
|
||||
if( flags & gxCanvas::CANVAS_TEXTURE ) adjustTexSize( &t_w,&t_h,gfx->dir3dDev );
|
||||
copy( dest,0,0,t_w,t_h,src,0,height-1,width,-height );
|
||||
int t_w = width, t_h = height;
|
||||
if (flags & gxCanvas::CANVAS_TEXTURE) adjustTexSize(&t_w, &t_h, gfx->dir3dDev);
|
||||
copy(dest, 0, 0, t_w, t_h, src, 0, height - 1, width, -height);
|
||||
|
||||
src->Release();
|
||||
FreeImage_Unload( dib );
|
||||
FreeImage_Unload(dib);
|
||||
return dest;
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
#ifndef DDUTIL_H
|
||||
#define DDUTIL_H
|
||||
|
||||
#include <ddraw.h>
|
||||
#include "GraphicsRuntime.h"
|
||||
|
||||
class gxGraphics;
|
||||
typedef IDirectDrawSurface7 ddSurf;
|
||||
|
||||
+65
-62
@@ -9,35 +9,35 @@ class gxGraphics;
|
||||
|
||||
typedef IDirectDrawSurface7 ddSurf;
|
||||
|
||||
class gxCanvas{
|
||||
class gxCanvas {
|
||||
public:
|
||||
gxCanvas( gxGraphics *graphics,ddSurf *surface,int flags );
|
||||
gxCanvas(gxGraphics *graphics, ddSurf *surface, int flags);
|
||||
~gxCanvas();
|
||||
|
||||
void backup()const;
|
||||
void restore()const;
|
||||
ddSurf *getSurface()const;
|
||||
ddSurf *getTexSurface()const;
|
||||
void setModify( int n );
|
||||
void setModify(int n);
|
||||
int getModify()const;
|
||||
|
||||
bool attachZBuffer();
|
||||
void releaseZBuffer();
|
||||
|
||||
bool clip( RECT *d )const;
|
||||
bool clip( RECT *d,RECT *s )const;
|
||||
void damage( const RECT &r )const;
|
||||
bool clip(RECT *d)const;
|
||||
bool clip(RECT *d, RECT *s)const;
|
||||
void damage(const RECT &r)const;
|
||||
|
||||
private:
|
||||
int flags,cube_mode;
|
||||
int flags, cube_mode;
|
||||
gxGraphics *graphics;
|
||||
|
||||
ddSurf *main_surf,*surf,*z_surf,*cube_surfs[6];
|
||||
ddSurf *main_surf, *surf, *z_surf, *cube_surfs[6];
|
||||
|
||||
mutable int mod_cnt;
|
||||
mutable ddSurf *t_surf;
|
||||
|
||||
mutable int locked_pitch,locked_cnt,lock_mod_cnt,remip_cnt;
|
||||
mutable int locked_pitch, locked_cnt, lock_mod_cnt, remip_cnt;
|
||||
mutable unsigned char *locked_surf;
|
||||
|
||||
mutable int cm_pitch;
|
||||
@@ -49,85 +49,88 @@ private:
|
||||
|
||||
gxFont *font;
|
||||
RECT viewport;
|
||||
int origin_x,origin_y,handle_x,handle_y;
|
||||
unsigned mask_surf,color_surf,color_argb,clsColor_surf;
|
||||
int origin_x, origin_y, handle_x, handle_y;
|
||||
unsigned mask_surf, color_surf, color_argb, clsColor_surf;
|
||||
|
||||
void updateBitMask( const RECT &r )const;
|
||||
void updateBitMask(const RECT &r)const;
|
||||
|
||||
/***** GX INTERFACE *****/
|
||||
public:
|
||||
enum{
|
||||
CANVAS_TEX_RGB= 0x0001,
|
||||
CANVAS_TEX_ALPHA= 0x0002,
|
||||
CANVAS_TEX_MASK= 0x0004,
|
||||
CANVAS_TEX_MIPMAP= 0x0008,
|
||||
CANVAS_TEX_CLAMPU= 0x0010,
|
||||
CANVAS_TEX_CLAMPV= 0x0020,
|
||||
CANVAS_TEX_SPHERE= 0x0040,
|
||||
CANVAS_TEX_CUBE= 0x0080,
|
||||
CANVAS_TEX_VIDMEM= 0x0100,
|
||||
CANVAS_TEX_HICOLOR= 0x0200,
|
||||
enum {
|
||||
CANVAS_TEX_RGB = 0x0001,
|
||||
CANVAS_TEX_ALPHA = 0x0002,
|
||||
CANVAS_TEX_MASK = 0x0004,
|
||||
CANVAS_TEX_MIPMAP = 0x0008,
|
||||
CANVAS_TEX_CLAMPU = 0x0010,
|
||||
CANVAS_TEX_CLAMPV = 0x0020,
|
||||
CANVAS_TEX_SPHERE = 0x0040,
|
||||
CANVAS_TEX_CUBE = 0x0080,
|
||||
CANVAS_TEX_VIDMEM = 0x0100,
|
||||
CANVAS_TEX_HICOLOR = 0x0200,
|
||||
|
||||
CANVAS_TEXTURE= 0x10000,
|
||||
CANVAS_NONDISPLAY= 0x20000,
|
||||
CANVAS_HIGHCOLOR= 0x40000
|
||||
CANVAS_TEXTURE = 0x10000,
|
||||
CANVAS_NONDISPLAY = 0x20000,
|
||||
CANVAS_HIGHCOLOR = 0x40000,
|
||||
|
||||
CANVAS_3DRENDER = 0x1000,
|
||||
CANVAS_3DZRENDER = 0x2000,
|
||||
};
|
||||
|
||||
enum{
|
||||
CUBEMODE_REFLECTION=1,
|
||||
CUBEMODE_NORMAL=2,
|
||||
CUBEMODE_POSITION=3,
|
||||
enum {
|
||||
CUBEMODE_REFLECTION = 1,
|
||||
CUBEMODE_NORMAL = 2,
|
||||
CUBEMODE_POSITION = 3,
|
||||
|
||||
CUBESPACE_WORLD=0,
|
||||
CUBESPACE_CAMERA=4
|
||||
CUBESPACE_WORLD = 0,
|
||||
CUBESPACE_CAMERA = 4
|
||||
};
|
||||
|
||||
//MANIPULATORS
|
||||
void setFont( gxFont *font );
|
||||
void setMask( unsigned argb );
|
||||
void setColor( unsigned argb );
|
||||
void setClsColor( unsigned argb );
|
||||
void setOrigin( int x,int y );
|
||||
void setHandle( int x,int y );
|
||||
void setViewport( int x,int y,int w,int h );
|
||||
void setFont(gxFont *font);
|
||||
void setMask(unsigned argb);
|
||||
void setColor(unsigned argb);
|
||||
void setClsColor(unsigned argb);
|
||||
void setOrigin(int x, int y);
|
||||
void setHandle(int x, int y);
|
||||
void setViewport(int x, int y, int w, int h);
|
||||
|
||||
void cls();
|
||||
void plot( int x,int y );
|
||||
void line( int x,int y,int x2,int y2 );
|
||||
void rect( int x,int y,int w,int h,bool solid );
|
||||
void oval( int x,int y,int w,int h,bool solid );
|
||||
void text( int x,int y,const std::string &t );
|
||||
void blit( int x,int y,gxCanvas *src,int src_x,int src_y,int src_w,int src_h,bool solid );
|
||||
void plot(int x, int y);
|
||||
void line(int x, int y, int x2, int y2);
|
||||
void rect(int x, int y, int w, int h, bool solid);
|
||||
void oval(int x, int y, int w, int h, bool solid);
|
||||
void text(int x, int y, const std::string &t);
|
||||
void blit(int x, int y, gxCanvas *src, int src_x, int src_y, int src_w, int src_h, bool solid);
|
||||
|
||||
bool collide( int x,int y,const gxCanvas *src,int src_x,int src_y,bool solid )const;
|
||||
bool rect_collide( int x,int y,int rect_x,int rect_y,int rect_w,int rect_h,bool solid )const;
|
||||
bool collide(int x, int y, const gxCanvas *src, int src_x, int src_y, bool solid)const;
|
||||
bool rect_collide(int x, int y, int rect_x, int rect_y, int rect_w, int rect_h, bool solid)const;
|
||||
|
||||
bool lock()const;
|
||||
void setPixel( int x,int y,unsigned argb );
|
||||
void setPixelFast( int x,int y,unsigned argb ){
|
||||
format.setPixel( locked_surf+y*locked_pitch+x*format.getPitch(),argb );
|
||||
void setPixel(int x, int y, unsigned argb);
|
||||
void setPixelFast(int x, int y, unsigned argb) {
|
||||
format.setPixel(locked_surf + y*locked_pitch + x*format.getPitch(), argb);
|
||||
++mod_cnt;
|
||||
}
|
||||
void copyPixel( int x,int y,gxCanvas *src,int src_x,int src_y );
|
||||
void copyPixelFast( int x,int y,gxCanvas *src,int src_x,int src_y );
|
||||
unsigned getPixel( int x,int y )const;
|
||||
unsigned getPixelFast( int x,int y )const{
|
||||
return format.getPixel( locked_surf+y*locked_pitch+x*format.getPitch() );
|
||||
void copyPixel(int x, int y, gxCanvas *src, int src_x, int src_y);
|
||||
void copyPixelFast(int x, int y, gxCanvas *src, int src_x, int src_y);
|
||||
unsigned getPixel(int x, int y)const;
|
||||
unsigned getPixelFast(int x, int y)const {
|
||||
return format.getPixel(locked_surf + y*locked_pitch + x*format.getPitch());
|
||||
};
|
||||
void unlock()const;
|
||||
|
||||
void setCubeMode( int mode );
|
||||
void setCubeFace( int face );
|
||||
void setCubeMode(int mode);
|
||||
void setCubeFace(int face);
|
||||
|
||||
//ACCESSORS
|
||||
int getWidth()const;
|
||||
int getHeight()const;
|
||||
int getDepth()const;
|
||||
int getFlags()const{ return flags; }
|
||||
int cubeMode()const{ return cube_mode; }
|
||||
void getOrigin( int *x,int *y )const;
|
||||
void getHandle( int *x,int *y )const;
|
||||
void getViewport( int *x,int *y,int *w,int *h )const;
|
||||
int getFlags()const { return flags; }
|
||||
int cubeMode()const { return cube_mode; }
|
||||
void getOrigin(int *x, int *y)const;
|
||||
void getHandle(int *x, int *y)const;
|
||||
void getViewport(int *x, int *y, int *w, int *h)const;
|
||||
unsigned getMask()const;
|
||||
unsigned getColor()const;
|
||||
unsigned getClsColor()const;
|
||||
|
||||
+321
-329
@@ -5,49 +5,47 @@
|
||||
|
||||
extern gxRuntime *gx_runtime;
|
||||
|
||||
gxGraphics::gxGraphics( gxRuntime *rt,IDirectDraw7 *dd,IDirectDrawSurface7 *fs,IDirectDrawSurface7 *bs,bool d3d ):
|
||||
runtime(rt),dirDraw(dd),dir3d(0),dir3dDev(0),def_font(0),gfx_lost(false),dummy_mesh(0){
|
||||
gxGraphics::gxGraphics(gxRuntime *rt, IDirectDraw7 *dd, IDirectDrawSurface7 *fs, IDirectDrawSurface7 *bs, bool d3d) :
|
||||
runtime(rt), dirDraw(dd), dir3d(0), dir3dDev(0), def_font(0), gfx_lost(false), dummy_mesh(0) {
|
||||
|
||||
dirDraw->QueryInterface( IID_IDirectDraw,(void**)&ds_dirDraw );
|
||||
dirDraw->QueryInterface(IID_IDirectDraw, (void**)&ds_dirDraw);
|
||||
|
||||
front_canvas=d_new gxCanvas( this,fs,0 );
|
||||
back_canvas=d_new gxCanvas( this,bs,0 );
|
||||
front_canvas = d_new gxCanvas(this, fs, 0);
|
||||
back_canvas = d_new gxCanvas(this, bs, 0);
|
||||
|
||||
front_canvas->cls();
|
||||
back_canvas->cls();
|
||||
|
||||
def_font=loadFont( "courier",12,0 );
|
||||
def_font = loadFont("courier", 12, 0);
|
||||
|
||||
front_canvas->setFont( def_font );
|
||||
back_canvas->setFont( def_font );
|
||||
front_canvas->setFont(def_font);
|
||||
back_canvas->setFont(def_font);
|
||||
|
||||
memset(&primFmt,0,sizeof(primFmt));
|
||||
primFmt.dwSize=sizeof(primFmt);
|
||||
fs->GetPixelFormat( &primFmt );
|
||||
memset(&primFmt, 0, sizeof(primFmt));
|
||||
primFmt.dwSize = sizeof(primFmt);
|
||||
fs->GetPixelFormat(&primFmt);
|
||||
|
||||
//are we fullscreen?
|
||||
_gamma=0;
|
||||
if( fs!=bs ){
|
||||
if( fs->QueryInterface( IID_IDirectDrawGammaControl,(void**)&_gamma )>=0 ){
|
||||
if( _gamma->GetGammaRamp( 0,&_gammaRamp )<0 ) _gamma=0;
|
||||
_gamma = 0;
|
||||
if (fs != bs) {
|
||||
if (fs->QueryInterface(IID_IDirectDrawGammaControl, (void**)&_gamma) >= 0) {
|
||||
if (_gamma->GetGammaRamp(0, &_gammaRamp) < 0) _gamma = 0;
|
||||
}
|
||||
}
|
||||
if( !_gamma ){
|
||||
for( int k=0;k<256;++k ) _gammaRamp.red[k]=_gammaRamp.blue[k]=_gammaRamp.green[k]=k;
|
||||
if (!_gamma) {
|
||||
for (int k = 0; k < 256; ++k) _gammaRamp.red[k] = _gammaRamp.blue[k] = _gammaRamp.green[k] = k;
|
||||
}
|
||||
}
|
||||
|
||||
gxGraphics::~gxGraphics(){
|
||||
if( _gamma ) _gamma->Release();
|
||||
#ifdef PRO
|
||||
while( scene_set.size() ) freeScene( *scene_set.begin() );
|
||||
#endif
|
||||
while( movie_set.size() ) closeMovie( *movie_set.begin() );
|
||||
while( font_set.size() ) freeFont( *font_set.begin() );
|
||||
while( canvas_set.size() ) freeCanvas( *canvas_set.begin() );
|
||||
gxGraphics::~gxGraphics() {
|
||||
if (_gamma) _gamma->Release();
|
||||
while (scene_set.size()) freeScene(*scene_set.begin());
|
||||
while (movie_set.size()) closeMovie(*movie_set.begin());
|
||||
while (font_set.size()) freeFont(*font_set.begin());
|
||||
while (canvas_set.size()) freeCanvas(*canvas_set.begin());
|
||||
|
||||
set<string>::iterator it;
|
||||
for( it=font_res.begin();it!=font_res.end();++it ) RemoveFontResource( (*it).c_str() );
|
||||
for (it = font_res.begin(); it != font_res.end(); ++it) RemoveFontResource((*it).c_str());
|
||||
font_res.clear();
|
||||
|
||||
delete back_canvas;
|
||||
@@ -59,561 +57,555 @@ gxGraphics::~gxGraphics(){
|
||||
dirDraw->Release();
|
||||
}
|
||||
|
||||
void gxGraphics::setGamma( int r,int g,int b,float dr,float dg,float db ){
|
||||
_gammaRamp.red[r&255]=dr*257.0f;
|
||||
_gammaRamp.green[g&255]=dg*257.0f;
|
||||
_gammaRamp.blue[b&255]=db*257.0f;
|
||||
void gxGraphics::setGamma(int r, int g, int b, float dr, float dg, float db) {
|
||||
_gammaRamp.red[r & 255] = dr*257.0f;
|
||||
_gammaRamp.green[g & 255] = dg*257.0f;
|
||||
_gammaRamp.blue[b & 255] = db*257.0f;
|
||||
}
|
||||
|
||||
void gxGraphics::updateGamma( bool calibrate ){
|
||||
if( !_gamma ) return;
|
||||
_gamma->SetGammaRamp( calibrate ? DDSGR_CALIBRATE : 0,&_gammaRamp );
|
||||
void gxGraphics::updateGamma(bool calibrate) {
|
||||
if (!_gamma) return;
|
||||
_gamma->SetGammaRamp(calibrate ? DDSGR_CALIBRATE : 0, &_gammaRamp);
|
||||
}
|
||||
|
||||
void gxGraphics::getGamma( int r,int g,int b,float *dr,float *dg,float *db ){
|
||||
*dr=_gammaRamp.red[r&255]/257.0f;
|
||||
*dg=_gammaRamp.green[g&255]/257.0f;
|
||||
*db=_gammaRamp.blue[b&255]/257.0f;
|
||||
void gxGraphics::getGamma(int r, int g, int b, float *dr, float *dg, float *db) {
|
||||
*dr = _gammaRamp.red[r & 255] / 257.0f;
|
||||
*dg = _gammaRamp.green[g & 255] / 257.0f;
|
||||
*db = _gammaRamp.blue[b & 255] / 257.0f;
|
||||
}
|
||||
|
||||
void gxGraphics::backup(){
|
||||
void gxGraphics::backup() {
|
||||
}
|
||||
|
||||
bool gxGraphics::restore(){
|
||||
bool gxGraphics::restore() {
|
||||
|
||||
while( dirDraw->TestCooperativeLevel()!=DD_OK ){
|
||||
while (dirDraw->TestCooperativeLevel() != DD_OK) {
|
||||
|
||||
if( dirDraw->TestCooperativeLevel()==DDERR_WRONGMODE ) return false;
|
||||
if (dirDraw->TestCooperativeLevel() == DDERR_WRONGMODE) return false;
|
||||
|
||||
Sleep( 100 );
|
||||
Sleep(100);
|
||||
}
|
||||
|
||||
if( back_canvas->getSurface()->IsLost()==DD_OK ) return true;
|
||||
if (back_canvas->getSurface()->IsLost() == DD_OK) return true;
|
||||
|
||||
dirDraw->RestoreAllSurfaces();
|
||||
|
||||
//restore all canvases
|
||||
set<gxCanvas*>::iterator it;
|
||||
for( it=canvas_set.begin();it!=canvas_set.end();++it ){
|
||||
for (it = canvas_set.begin(); it != canvas_set.end(); ++it) {
|
||||
(*it)->restore();
|
||||
}
|
||||
|
||||
#ifdef PRO
|
||||
//restore all meshes (b3d surfaces)
|
||||
set<gxMesh*>::iterator mesh_it;
|
||||
for( mesh_it=mesh_set.begin();mesh_it!=mesh_set.end();++mesh_it ){
|
||||
for (mesh_it = mesh_set.begin(); mesh_it != mesh_set.end(); ++mesh_it) {
|
||||
(*mesh_it)->restore();
|
||||
}
|
||||
if( dir3d ) dir3d->EvictManagedTextures();
|
||||
#endif
|
||||
if (dir3d) dir3d->EvictManagedTextures();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
gxCanvas *gxGraphics::getFrontCanvas()const{
|
||||
gxCanvas *gxGraphics::getFrontCanvas()const {
|
||||
return front_canvas;
|
||||
}
|
||||
|
||||
gxCanvas *gxGraphics::getBackCanvas()const{
|
||||
gxCanvas *gxGraphics::getBackCanvas()const {
|
||||
return back_canvas;
|
||||
}
|
||||
|
||||
gxFont *gxGraphics::getDefaultFont()const{
|
||||
gxFont *gxGraphics::getDefaultFont()const {
|
||||
return def_font;
|
||||
}
|
||||
|
||||
void gxGraphics::vwait(){
|
||||
dirDraw->WaitForVerticalBlank( DDWAITVB_BLOCKBEGIN,0 );
|
||||
void gxGraphics::vwait() {
|
||||
dirDraw->WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, 0);
|
||||
}
|
||||
|
||||
void gxGraphics::flip( bool v ){
|
||||
runtime->flip( v );
|
||||
void gxGraphics::flip(bool v) {
|
||||
runtime->flip(v);
|
||||
}
|
||||
|
||||
void gxGraphics::copy( gxCanvas *dest,int dx,int dy,int dw,int dh,gxCanvas *src,int sx,int sy,int sw,int sh ){
|
||||
RECT r={ dx,dy,dx+dw,dy+dh };
|
||||
ddUtil::copy( dest->getSurface(),dx,dy,dw,dh,src->getSurface(),sx,sy,sw,sh );
|
||||
dest->damage( r );
|
||||
void gxGraphics::copy(gxCanvas *dest, int dx, int dy, int dw, int dh, gxCanvas *src, int sx, int sy, int sw, int sh) {
|
||||
RECT r = { dx,dy,dx + dw,dy + dh };
|
||||
ddUtil::copy(dest->getSurface(), dx, dy, dw, dh, src->getSurface(), sx, sy, sw, sh);
|
||||
dest->damage(r);
|
||||
}
|
||||
|
||||
int gxGraphics::getScanLine()const{
|
||||
DWORD t=0;
|
||||
dirDraw->GetScanLine( &t );
|
||||
int gxGraphics::getScanLine()const {
|
||||
DWORD t = 0;
|
||||
dirDraw->GetScanLine(&t);
|
||||
return t;
|
||||
}
|
||||
|
||||
int gxGraphics::getTotalVidmem()const{
|
||||
DDCAPS caps={sizeof(caps)};
|
||||
dirDraw->GetCaps( &caps,0 );
|
||||
int gxGraphics::getTotalVidmem()const {
|
||||
DDCAPS caps = { sizeof(caps) };
|
||||
dirDraw->GetCaps(&caps, 0);
|
||||
return caps.dwVidMemTotal;
|
||||
}
|
||||
|
||||
int gxGraphics::getAvailVidmem()const{
|
||||
DDCAPS caps={sizeof(caps)};
|
||||
dirDraw->GetCaps( &caps,0 );
|
||||
int gxGraphics::getAvailVidmem()const {
|
||||
DDCAPS caps = { sizeof(caps) };
|
||||
dirDraw->GetCaps(&caps, 0);
|
||||
return caps.dwVidMemFree;
|
||||
}
|
||||
|
||||
gxMovie *gxGraphics::openMovie( const string &file,int flags ){
|
||||
gxMovie *gxGraphics::openMovie(const string &file, int flags) {
|
||||
|
||||
IAMMultiMediaStream *iam_stream;
|
||||
/*IAMMultiMediaStream *iam_stream;
|
||||
|
||||
if( CoCreateInstance(
|
||||
CLSID_AMMultiMediaStream,NULL,CLSCTX_INPROC_SERVER,
|
||||
IID_IAMMultiMediaStream,(void **)&iam_stream )==S_OK ){
|
||||
if (CoCreateInstance(
|
||||
CLSID_AMMultiMediaStream, NULL, CLSCTX_INPROC_SERVER,
|
||||
IID_IAMMultiMediaStream, (void **)&iam_stream) == S_OK) {
|
||||
|
||||
if( iam_stream->Initialize( STREAMTYPE_READ,AMMSF_NOGRAPHTHREAD,NULL )==S_OK ){
|
||||
if (iam_stream->Initialize(STREAMTYPE_READ, AMMSF_NOGRAPHTHREAD, NULL) == S_OK) {
|
||||
|
||||
if( iam_stream->AddMediaStream( ds_dirDraw,&MSPID_PrimaryVideo,0,NULL )==S_OK ){
|
||||
if (iam_stream->AddMediaStream(ds_dirDraw, &MSPID_PrimaryVideo, 0, NULL) == S_OK) {
|
||||
|
||||
iam_stream->AddMediaStream( NULL,&MSPID_PrimaryAudio,AMMSF_ADDDEFAULTRENDERER,NULL );
|
||||
iam_stream->AddMediaStream(NULL, &MSPID_PrimaryAudio, AMMSF_ADDDEFAULTRENDERER, NULL);
|
||||
|
||||
WCHAR *path=new WCHAR[ file.size()+1 ];
|
||||
MultiByteToWideChar( CP_ACP,0,file.c_str(),-1,path,sizeof(WCHAR)*(file.size()+1) );
|
||||
int n=iam_stream->OpenFile( path,0 );
|
||||
WCHAR *path = new WCHAR[file.size() + 1];
|
||||
MultiByteToWideChar(CP_ACP, 0, file.c_str(), -1, path, sizeof(WCHAR)*(file.size() + 1));
|
||||
int n = iam_stream->OpenFile(path, 0);
|
||||
delete path;
|
||||
|
||||
if( n==S_OK ){
|
||||
gxMovie *movie=d_new gxMovie( this,iam_stream );
|
||||
movie_set.insert( movie );
|
||||
if (n == S_OK) {
|
||||
gxMovie *movie = d_new gxMovie(this, iam_stream);
|
||||
movie_set.insert(movie);
|
||||
return movie;
|
||||
}
|
||||
}
|
||||
}
|
||||
iam_stream->Release();
|
||||
}
|
||||
}*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
gxMovie *gxGraphics::verifyMovie( gxMovie *m ){
|
||||
return movie_set.count( m ) ? m : 0;
|
||||
gxMovie *gxGraphics::verifyMovie(gxMovie *m) {
|
||||
return movie_set.count(m) ? m : 0;
|
||||
}
|
||||
|
||||
void gxGraphics::closeMovie( gxMovie *m ){
|
||||
if( movie_set.erase( m ) ) delete m;
|
||||
void gxGraphics::closeMovie(gxMovie *m) {
|
||||
if (movie_set.erase(m)) delete m;
|
||||
}
|
||||
|
||||
gxCanvas *gxGraphics::createCanvas( int w,int h,int flags ){
|
||||
ddSurf *s=ddUtil::createSurface( w,h,flags,this );
|
||||
if( !s ) return 0;
|
||||
gxCanvas *c=d_new gxCanvas( this,s,flags );
|
||||
canvas_set.insert( c );
|
||||
gxCanvas *gxGraphics::createCanvas(int w, int h, int flags) {
|
||||
ddSurf *s = ddUtil::createSurface(w, h, flags, this);
|
||||
if (!s) return 0;
|
||||
gxCanvas *c = d_new gxCanvas(this, s, flags);
|
||||
canvas_set.insert(c);
|
||||
c->cls();
|
||||
return c;
|
||||
}
|
||||
|
||||
gxCanvas *gxGraphics::loadCanvas( const string &f,int flags ){
|
||||
ddSurf *s=ddUtil::loadSurface( f,flags,this );
|
||||
if( !s ) return 0;
|
||||
gxCanvas *c=d_new gxCanvas( this,s,flags );
|
||||
canvas_set.insert( c );
|
||||
gxCanvas *gxGraphics::loadCanvas(const string &f, int flags) {
|
||||
ddSurf *s = ddUtil::loadSurface(f, flags, this);
|
||||
if (!s) return 0;
|
||||
gxCanvas *c = d_new gxCanvas(this, s, flags);
|
||||
canvas_set.insert(c);
|
||||
return c;
|
||||
}
|
||||
|
||||
gxCanvas *gxGraphics::verifyCanvas( gxCanvas *c ){
|
||||
return canvas_set.count( c ) || c==front_canvas || c==back_canvas ? c : 0;
|
||||
gxCanvas *gxGraphics::verifyCanvas(gxCanvas *c) {
|
||||
return canvas_set.count(c) || c == front_canvas || c == back_canvas ? c : 0;
|
||||
}
|
||||
|
||||
void gxGraphics::freeCanvas( gxCanvas *c ){
|
||||
if( canvas_set.erase( c ) ) delete c;
|
||||
void gxGraphics::freeCanvas(gxCanvas *c) {
|
||||
if (canvas_set.erase(c)) delete c;
|
||||
}
|
||||
|
||||
int gxGraphics::getWidth()const{
|
||||
int gxGraphics::getWidth()const {
|
||||
return front_canvas->getWidth();
|
||||
}
|
||||
|
||||
int gxGraphics::getHeight()const{
|
||||
int gxGraphics::getHeight()const {
|
||||
return front_canvas->getHeight();
|
||||
}
|
||||
|
||||
int gxGraphics::getDepth()const{
|
||||
int gxGraphics::getDepth()const {
|
||||
return front_canvas->getDepth();
|
||||
}
|
||||
|
||||
gxFont *gxGraphics::loadFont( const string &f,int height,int flags ){
|
||||
gxFont *gxGraphics::loadFont(const string &f, int height, int flags) {
|
||||
|
||||
int bold=flags & gxFont::FONT_BOLD ? FW_BOLD : FW_REGULAR;
|
||||
int italic=flags & gxFont::FONT_ITALIC ? 1 : 0;
|
||||
int underline=flags & gxFont::FONT_UNDERLINE ? 1 : 0;
|
||||
int strikeout=0;
|
||||
int bold = flags & gxFont::FONT_BOLD ? FW_BOLD : FW_REGULAR;
|
||||
int italic = flags & gxFont::FONT_ITALIC ? 1 : 0;
|
||||
int underline = flags & gxFont::FONT_UNDERLINE ? 1 : 0;
|
||||
int strikeout = 0;
|
||||
|
||||
string t;
|
||||
int n=f.find('.');
|
||||
if( n!=string::npos ){
|
||||
t=fullfilename(f);
|
||||
if( !font_res.count(t) && AddFontResource( t.c_str() ) ) font_res.insert( t );
|
||||
t=filenamefile( f.substr(0,n) );
|
||||
}else{
|
||||
t=f;
|
||||
int n = f.find('.');
|
||||
if (n != string::npos) {
|
||||
t = fullfilename(f);
|
||||
if (!font_res.count(t) && AddFontResource(t.c_str())) font_res.insert(t);
|
||||
t = filenamefile(f.substr(0, n));
|
||||
} else {
|
||||
t = f;
|
||||
}
|
||||
|
||||
//save and turn off font smoothing....
|
||||
BOOL smoothing=FALSE;
|
||||
SystemParametersInfo( SPI_GETFONTSMOOTHING,0,&smoothing,0 );
|
||||
SystemParametersInfo( SPI_SETFONTSMOOTHING,FALSE,0,0 );
|
||||
BOOL smoothing = FALSE;
|
||||
SystemParametersInfo(SPI_GETFONTSMOOTHING, 0, &smoothing, 0);
|
||||
SystemParametersInfo(SPI_SETFONTSMOOTHING, FALSE, 0, 0);
|
||||
|
||||
HFONT hfont=CreateFont(
|
||||
height,0,0,0,
|
||||
bold,italic,underline,strikeout,
|
||||
ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
|
||||
DEFAULT_PITCH|FF_DONTCARE,t.c_str() );
|
||||
HFONT hfont = CreateFont(
|
||||
height, 0, 0, 0,
|
||||
bold, italic, underline, strikeout,
|
||||
ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
|
||||
DEFAULT_PITCH | FF_DONTCARE, t.c_str());
|
||||
|
||||
if( !hfont ){
|
||||
if (!hfont) {
|
||||
//restore font smoothing
|
||||
SystemParametersInfo( SPI_SETFONTSMOOTHING,smoothing,0,0 );
|
||||
SystemParametersInfo(SPI_SETFONTSMOOTHING, smoothing, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
HDC hdc=CreateCompatibleDC( 0 );
|
||||
HFONT pfont=(HFONT)SelectObject( hdc,hfont );
|
||||
HDC hdc = CreateCompatibleDC(0);
|
||||
HFONT pfont = (HFONT)SelectObject(hdc, hfont);
|
||||
|
||||
TEXTMETRIC tm={0};
|
||||
if( !GetTextMetrics( hdc,&tm ) ){
|
||||
SelectObject( hdc,pfont );
|
||||
DeleteDC( hdc );
|
||||
DeleteObject( hfont );
|
||||
SystemParametersInfo( SPI_SETFONTSMOOTHING,smoothing,0,0 );
|
||||
TEXTMETRIC tm = { 0 };
|
||||
if (!GetTextMetrics(hdc, &tm)) {
|
||||
SelectObject(hdc, pfont);
|
||||
DeleteDC(hdc);
|
||||
DeleteObject(hfont);
|
||||
SystemParametersInfo(SPI_SETFONTSMOOTHING, smoothing, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
height=tm.tmHeight;
|
||||
height = tm.tmHeight;
|
||||
|
||||
int first=tm.tmFirstChar,last=tm.tmLastChar;
|
||||
int sz=last-first+1;
|
||||
int *offs=d_new int[sz];
|
||||
int *widths=d_new int[sz];
|
||||
int *as=d_new int[sz];
|
||||
int first = tm.tmFirstChar, last = tm.tmLastChar;
|
||||
int sz = last - first + 1;
|
||||
int *offs = d_new int[sz];
|
||||
int *widths = d_new int[sz];
|
||||
int *as = d_new int[sz];
|
||||
|
||||
//calc size of canvas to hold font.
|
||||
int x=0,y=0,max_x=0;
|
||||
for( int k=0;k<sz;++k ){
|
||||
int x = 0, y = 0, max_x = 0;
|
||||
for (int k = 0; k < sz; ++k) {
|
||||
|
||||
char t=k+first;
|
||||
char t = k + first;
|
||||
|
||||
SIZE sz;
|
||||
GetTextExtentPoint32( hdc,&t,1,&sz );
|
||||
int w=sz.cx;
|
||||
GetTextExtentPoint32(hdc, &t, 1, &sz);
|
||||
int w = sz.cx;
|
||||
|
||||
as[k]=0;
|
||||
as[k] = 0;
|
||||
|
||||
ABC abc;
|
||||
if( GetCharABCWidths( hdc,t,t,&abc ) ){
|
||||
if( abc.abcA<0 ){
|
||||
as[k]=ceil(-abc.abcA);
|
||||
w+=as[k];
|
||||
if (GetCharABCWidths(hdc, t, t, &abc)) {
|
||||
if (abc.abcA < 0) {
|
||||
as[k] = ceil(-abc.abcA);
|
||||
w += as[k];
|
||||
}
|
||||
if( abc.abcC<0 ) w+=ceil(-abc.abcC);
|
||||
if (abc.abcC < 0) w += (int)ceil(-abc.abcC);
|
||||
}
|
||||
|
||||
if( x && x+w>getWidth() ){ x=0;y+=height; }
|
||||
offs[k]=(x<<16)|y;
|
||||
widths[k]=w;
|
||||
x+=w;if( x>max_x ) max_x=x;
|
||||
if (x && x + w > getWidth()) { x = 0; y += height; }
|
||||
offs[k] = (x << 16) | y;
|
||||
widths[k] = w;
|
||||
x += w; if (x > max_x) max_x = x;
|
||||
}
|
||||
SelectObject( hdc,pfont );
|
||||
DeleteDC( hdc );
|
||||
SelectObject(hdc, pfont);
|
||||
DeleteDC(hdc);
|
||||
|
||||
int cw=max_x,ch=y+height;
|
||||
int cw = max_x, ch = y + height;
|
||||
|
||||
if( gxCanvas *c=createCanvas( cw,ch,0 ) ){
|
||||
ddSurf *surf=c->getSurface();
|
||||
if (gxCanvas *c = createCanvas(cw, ch, 0)) {
|
||||
ddSurf *surf = c->getSurface();
|
||||
|
||||
HDC surf_hdc;
|
||||
if( surf->GetDC( &surf_hdc )>=0 ){
|
||||
HFONT pfont=(HFONT)SelectObject( surf_hdc,hfont );
|
||||
if (surf->GetDC(&surf_hdc) >= 0) {
|
||||
HFONT pfont = (HFONT)SelectObject(surf_hdc, hfont);
|
||||
|
||||
SetBkColor( surf_hdc,0x000000 );
|
||||
SetTextColor( surf_hdc,0xffffff );
|
||||
SetBkColor(surf_hdc, 0x000000);
|
||||
SetTextColor(surf_hdc, 0xffffff);
|
||||
|
||||
for( int k=0;k<sz;++k ){
|
||||
int x=(offs[k]>>16)&0xffff,y=offs[k]&0xffff;
|
||||
char t=k+first;
|
||||
RECT rect={x,y,x+widths[k],y+height};
|
||||
ExtTextOut( surf_hdc,x+as[k],y,ETO_CLIPPED,&rect,&t,1,0 );
|
||||
for (int k = 0; k < sz; ++k) {
|
||||
int x = (offs[k] >> 16) & 0xffff, y = offs[k] & 0xffff;
|
||||
char t = k + first;
|
||||
RECT rect = { x,y,x + widths[k],y + height };
|
||||
ExtTextOut(surf_hdc, x + as[k], y, ETO_CLIPPED, &rect, &t, 1, 0);
|
||||
}
|
||||
|
||||
SelectObject( surf_hdc,pfont );
|
||||
surf->ReleaseDC( surf_hdc );
|
||||
DeleteObject( hfont );
|
||||
SelectObject(surf_hdc, pfont);
|
||||
surf->ReleaseDC(surf_hdc);
|
||||
DeleteObject(hfont);
|
||||
delete[] as;
|
||||
|
||||
c->backup();
|
||||
gxFont *font=d_new gxFont( this,c,tm.tmMaxCharWidth,height,first,last+1,tm.tmDefaultChar,offs,widths );
|
||||
font_set.insert( font );
|
||||
gxFont *font = d_new gxFont(this, c, tm.tmMaxCharWidth, height, first, last + 1, tm.tmDefaultChar, offs, widths);
|
||||
font_set.insert(font);
|
||||
|
||||
//restore font smoothing
|
||||
SystemParametersInfo( SPI_SETFONTSMOOTHING,smoothing,0,0 );
|
||||
SystemParametersInfo(SPI_SETFONTSMOOTHING, smoothing, 0, 0);
|
||||
return font;
|
||||
}else{
|
||||
} else {
|
||||
}
|
||||
freeCanvas( c );
|
||||
}else{
|
||||
freeCanvas(c);
|
||||
} else {
|
||||
}
|
||||
DeleteObject( hfont );
|
||||
DeleteObject(hfont);
|
||||
delete[] as;
|
||||
delete[] widths;
|
||||
delete[] offs;
|
||||
|
||||
//restore font smoothing
|
||||
SystemParametersInfo( SPI_SETFONTSMOOTHING,smoothing,0,0 );
|
||||
SystemParametersInfo(SPI_SETFONTSMOOTHING, smoothing, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
gxFont *gxGraphics::verifyFont( gxFont *f ){
|
||||
return font_set.count( f ) ? f : 0;
|
||||
gxFont *gxGraphics::verifyFont(gxFont *f) {
|
||||
return font_set.count(f) ? f : 0;
|
||||
}
|
||||
|
||||
void gxGraphics::freeFont( gxFont *f ){
|
||||
if( font_set.erase( f ) ) delete f;
|
||||
void gxGraphics::freeFont(gxFont *f) {
|
||||
if (font_set.erase(f)) delete f;
|
||||
}
|
||||
|
||||
//////////////
|
||||
// 3D STUFF //
|
||||
//////////////
|
||||
|
||||
#ifdef PRO
|
||||
|
||||
static int maxDevType;
|
||||
|
||||
static HRESULT CALLBACK enumDevice( char *desc,char *name,D3DDEVICEDESC7 *devDesc,void *context ){
|
||||
gxGraphics *g=(gxGraphics*)context;
|
||||
int t=0;
|
||||
GUID guid=devDesc->deviceGUID;
|
||||
if( guid==IID_IDirect3DRGBDevice ) t=1;
|
||||
else if( guid==IID_IDirect3DHALDevice ) t=2;
|
||||
else if( guid==IID_IDirect3DTnLHalDevice ) t=3;
|
||||
if( t>maxDevType ){
|
||||
g->dir3dDevDesc=*devDesc;
|
||||
maxDevType=t;
|
||||
static HRESULT CALLBACK enumDevice(char *desc, char *name, D3DDEVICEDESC7 *devDesc, void *context) {
|
||||
gxGraphics *g = (gxGraphics*)context;
|
||||
int t = 0;
|
||||
GUID guid = devDesc->deviceGUID;
|
||||
if (guid == IID_IDirect3DRGBDevice) t = 1;
|
||||
else if (guid == IID_IDirect3DHALDevice) t = 2;
|
||||
else if (guid == IID_IDirect3DTnLHalDevice) t = 3;
|
||||
if (t > maxDevType) {
|
||||
g->dir3dDevDesc = *devDesc;
|
||||
maxDevType = t;
|
||||
}
|
||||
return D3DENUMRET_OK;
|
||||
}
|
||||
|
||||
static HRESULT CALLBACK enumZbuffFormat( LPDDPIXELFORMAT format,void *context ){
|
||||
gxGraphics *g=(gxGraphics*)context;
|
||||
if( format->dwZBufferBitDepth==g->primFmt.dwRGBBitCount ){
|
||||
g->zbuffFmt=*format;
|
||||
static HRESULT CALLBACK enumZbuffFormat(LPDDPIXELFORMAT format, void *context) {
|
||||
gxGraphics *g = (gxGraphics*)context;
|
||||
if (format->dwZBufferBitDepth == g->primFmt.dwRGBBitCount) {
|
||||
g->zbuffFmt = *format;
|
||||
return D3DENUMRET_CANCEL;
|
||||
}
|
||||
if( format->dwZBufferBitDepth>g->zbuffFmt.dwZBufferBitDepth ){
|
||||
if( format->dwZBufferBitDepth<g->primFmt.dwRGBBitCount ){
|
||||
g->zbuffFmt=*format;
|
||||
if (format->dwZBufferBitDepth > g->zbuffFmt.dwZBufferBitDepth) {
|
||||
if (format->dwZBufferBitDepth < g->primFmt.dwRGBBitCount) {
|
||||
g->zbuffFmt = *format;
|
||||
}
|
||||
}
|
||||
return D3DENUMRET_OK;
|
||||
}
|
||||
|
||||
struct TexFmt{
|
||||
struct TexFmt {
|
||||
DDPIXELFORMAT fmt;
|
||||
int bits,a_bits,rgb_bits;
|
||||
int bits, a_bits, rgb_bits;
|
||||
};
|
||||
|
||||
static int cntBits( int mask ){
|
||||
int n=0;
|
||||
for( int k=0;k<32;++k ){
|
||||
if( mask & (1<<k) ) ++n;
|
||||
static int cntBits(int mask) {
|
||||
int n = 0;
|
||||
for (int k = 0; k < 32; ++k) {
|
||||
if (mask & (1 << k)) ++n;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
static vector<TexFmt> tex_fmts;
|
||||
|
||||
static HRESULT CALLBACK enumTextureFormat( DDPIXELFORMAT *fmt,void *p ){
|
||||
static HRESULT CALLBACK enumTextureFormat(DDPIXELFORMAT *fmt, void *p) {
|
||||
TexFmt t;
|
||||
t.fmt=*fmt;
|
||||
t.bits=fmt->dwRGBBitCount;
|
||||
t.a_bits=(fmt->dwFlags & DDPF_ALPHAPIXELS) ? cntBits(fmt->dwRGBAlphaBitMask) : 0;
|
||||
t.rgb_bits=(fmt->dwFlags & DDPF_RGB) ? cntBits(fmt->dwRBitMask|fmt->dwGBitMask|fmt->dwBBitMask) : 0;
|
||||
t.fmt = *fmt;
|
||||
t.bits = fmt->dwRGBBitCount;
|
||||
t.a_bits = (fmt->dwFlags & DDPF_ALPHAPIXELS) ? cntBits(fmt->dwRGBAlphaBitMask) : 0;
|
||||
t.rgb_bits = (fmt->dwFlags & DDPF_RGB) ? cntBits(fmt->dwRBitMask | fmt->dwGBitMask | fmt->dwBBitMask) : 0;
|
||||
|
||||
tex_fmts.push_back( t );
|
||||
tex_fmts.push_back(t);
|
||||
|
||||
return D3DENUMRET_OK;
|
||||
}
|
||||
|
||||
static string itobin( int n ){
|
||||
static string itobin(int n) {
|
||||
string t;
|
||||
for( int k=0;k<32;n<<=1,++k ){
|
||||
t+=(n&0x80000000) ? '1' : '0';
|
||||
for (int k = 0; k < 32; n <<= 1, ++k) {
|
||||
t += (n & 0x80000000) ? '1' : '0';
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
static void debugPF( const DDPIXELFORMAT &pf ){
|
||||
static void debugPF(const DDPIXELFORMAT &pf) {
|
||||
string t;
|
||||
t="Bits:"+itoa( pf.dwRGBBitCount );
|
||||
gx_runtime->debugLog( t.c_str() );
|
||||
t="R Mask:"+itobin( pf.dwRBitMask );
|
||||
gx_runtime->debugLog( t.c_str() );
|
||||
t="G Mask:"+itobin( pf.dwGBitMask );
|
||||
gx_runtime->debugLog( t.c_str() );
|
||||
t="B Mask:"+itobin( pf.dwBBitMask );
|
||||
gx_runtime->debugLog( t.c_str() );
|
||||
t="A Mask:"+itobin( pf.dwRGBAlphaBitMask );
|
||||
gx_runtime->debugLog( t.c_str() );
|
||||
t = "Bits:" + itoa(pf.dwRGBBitCount);
|
||||
gx_runtime->debugLog(t.c_str());
|
||||
t = "R Mask:" + itobin(pf.dwRBitMask);
|
||||
gx_runtime->debugLog(t.c_str());
|
||||
t = "G Mask:" + itobin(pf.dwGBitMask);
|
||||
gx_runtime->debugLog(t.c_str());
|
||||
t = "B Mask:" + itobin(pf.dwBBitMask);
|
||||
gx_runtime->debugLog(t.c_str());
|
||||
t = "A Mask:" + itobin(pf.dwRGBAlphaBitMask);
|
||||
gx_runtime->debugLog(t.c_str());
|
||||
}
|
||||
|
||||
static void pickTexFmts( gxGraphics *g,int hi ){
|
||||
static void pickTexFmts(gxGraphics *g, int hi) {
|
||||
//texRGBFmt.
|
||||
{
|
||||
int pick=-1,max=0,bits;
|
||||
for( int d=g->primFmt.dwRGBBitCount;d<=32;d+=8 ){
|
||||
for( int k=0;k<tex_fmts.size();++k ){
|
||||
const TexFmt &t=tex_fmts[k];
|
||||
if( t.bits>d || !t.rgb_bits || t.rgb_bits<max ) continue;
|
||||
if( t.rgb_bits==max && t.bits>=bits ) continue;
|
||||
pick=k;max=t.rgb_bits;bits=t.bits;
|
||||
int pick = -1, max = 0, bits;
|
||||
for (int d = g->primFmt.dwRGBBitCount; d <= 32; d += 8) {
|
||||
for (int k = 0; k < tex_fmts.size(); ++k) {
|
||||
const TexFmt &t = tex_fmts[k];
|
||||
if (t.bits > d || !t.rgb_bits || t.rgb_bits < max) continue;
|
||||
if (t.rgb_bits == max && t.bits >= bits) continue;
|
||||
pick = k; max = t.rgb_bits; bits = t.bits;
|
||||
}
|
||||
if( !hi && pick>=0 ) break;
|
||||
if (!hi && pick >= 0) break;
|
||||
}
|
||||
if( pick<0 ) g->texRGBFmt[hi]=g->primFmt;
|
||||
else g->texRGBFmt[hi]=tex_fmts[pick].fmt;
|
||||
if (pick < 0) g->texRGBFmt[hi] = g->primFmt;
|
||||
else g->texRGBFmt[hi] = tex_fmts[pick].fmt;
|
||||
}
|
||||
//texAlphaFmt
|
||||
{
|
||||
int pick=-1,max=0,bits;
|
||||
for( int d=g->primFmt.dwRGBBitCount;d<=32;d+=8 ){
|
||||
for( int k=0;k<tex_fmts.size();++k ){
|
||||
const TexFmt &t=tex_fmts[k];
|
||||
if( t.bits>d || !t.a_bits || t.a_bits<max ) continue;
|
||||
if( t.a_bits==max && t.bits>=bits ) continue;
|
||||
pick=k;max=t.a_bits;bits=t.bits;
|
||||
int pick = -1, max = 0, bits;
|
||||
for (int d = g->primFmt.dwRGBBitCount; d <= 32; d += 8) {
|
||||
for (int k = 0; k < tex_fmts.size(); ++k) {
|
||||
const TexFmt &t = tex_fmts[k];
|
||||
if (t.bits > d || !t.a_bits || t.a_bits < max) continue;
|
||||
if (t.a_bits == max && t.bits >= bits) continue;
|
||||
pick = k; max = t.a_bits; bits = t.bits;
|
||||
}
|
||||
if( !hi && pick>=0 ) break;
|
||||
if (!hi && pick >= 0) break;
|
||||
}
|
||||
if( pick<0 ) g->texAlphaFmt[hi]=g->primFmt;
|
||||
else g->texAlphaFmt[hi]=tex_fmts[pick].fmt;
|
||||
if (pick < 0) g->texAlphaFmt[hi] = g->primFmt;
|
||||
else g->texAlphaFmt[hi] = tex_fmts[pick].fmt;
|
||||
}
|
||||
//texRGBAlphaFmt
|
||||
{
|
||||
int pick=-1,a8rgb8=-1,max=0,bits;
|
||||
for( int d=g->primFmt.dwRGBBitCount;d<=32;d+=8 ){
|
||||
for( int k=0;k<tex_fmts.size();++k ){
|
||||
const TexFmt &t=tex_fmts[k];
|
||||
if( t.a_bits==8 && t.bits==16 ){ a8rgb8=k;continue; }
|
||||
if( t.bits>d || !t.a_bits || !t.rgb_bits || t.a_bits<max ) continue;
|
||||
if( t.a_bits==max && t.bits>=bits ) continue;
|
||||
pick=k;max=t.a_bits;bits=t.bits;
|
||||
int pick = -1, a8rgb8 = -1, max = 0, bits;
|
||||
for (int d = g->primFmt.dwRGBBitCount; d <= 32; d += 8) {
|
||||
for (int k = 0; k < tex_fmts.size(); ++k) {
|
||||
const TexFmt &t = tex_fmts[k];
|
||||
if (t.a_bits == 8 && t.bits == 16) { a8rgb8 = k; continue; }
|
||||
if (t.bits > d || !t.a_bits || !t.rgb_bits || t.a_bits < max) continue;
|
||||
if (t.a_bits == max && t.bits >= bits) continue;
|
||||
pick = k; max = t.a_bits; bits = t.bits;
|
||||
}
|
||||
if( !hi && pick>=0 ) break;
|
||||
if (!hi && pick >= 0) break;
|
||||
}
|
||||
if( pick<0 ) pick=a8rgb8;
|
||||
if( pick<0 ) g->texRGBAlphaFmt[hi]=g->primFmt;
|
||||
else g->texRGBAlphaFmt[hi]=tex_fmts[pick].fmt;
|
||||
if (pick < 0) pick = a8rgb8;
|
||||
if (pick < 0) g->texRGBAlphaFmt[hi] = g->primFmt;
|
||||
else g->texRGBAlphaFmt[hi] = tex_fmts[pick].fmt;
|
||||
}
|
||||
//texRGBMaskFmt...
|
||||
{
|
||||
int pick=-1,max=0,bits;
|
||||
for( int d=g->primFmt.dwRGBBitCount;d<=32;d+=8 ){
|
||||
for( int k=0;k<tex_fmts.size();++k ){
|
||||
const TexFmt &t=tex_fmts[k];
|
||||
if( !t.a_bits || !t.rgb_bits || t.rgb_bits<max ) continue;
|
||||
if( t.rgb_bits==max && t.bits>=bits ) continue;
|
||||
pick=k;max=t.rgb_bits;bits=t.bits;
|
||||
int pick = -1, max = 0, bits;
|
||||
for (int d = g->primFmt.dwRGBBitCount; d <= 32; d += 8) {
|
||||
for (int k = 0; k < tex_fmts.size(); ++k) {
|
||||
const TexFmt &t = tex_fmts[k];
|
||||
if (!t.a_bits || !t.rgb_bits || t.rgb_bits < max) continue;
|
||||
if (t.rgb_bits == max && t.bits >= bits) continue;
|
||||
pick = k; max = t.rgb_bits; bits = t.bits;
|
||||
}
|
||||
if( !hi && pick>=0 ) break;
|
||||
if (!hi && pick >= 0) break;
|
||||
}
|
||||
if( pick<0 ) g->texRGBMaskFmt[hi]=g->primFmt;
|
||||
else g->texRGBMaskFmt[hi]=tex_fmts[pick].fmt;
|
||||
if (pick < 0) g->texRGBMaskFmt[hi] = g->primFmt;
|
||||
else g->texRGBMaskFmt[hi] = tex_fmts[pick].fmt;
|
||||
}
|
||||
}
|
||||
|
||||
gxScene *gxGraphics::createScene( int flags ){
|
||||
if( scene_set.size() ) return 0;
|
||||
gxScene *gxGraphics::createScene(int flags) {
|
||||
if (scene_set.size()) return 0;
|
||||
|
||||
//get d3d
|
||||
if( dirDraw->QueryInterface( IID_IDirect3D7,(void**)&dir3d )>=0 ){
|
||||
if (dirDraw->QueryInterface(IID_IDirect3D7, (void**)&dir3d) >= 0) {
|
||||
//enum devices
|
||||
maxDevType=0;
|
||||
if( dir3d->EnumDevices( enumDevice,this )>=0 && maxDevType>1 ){
|
||||
maxDevType = 0;
|
||||
if (dir3d->EnumDevices(enumDevice, this) >= 0 && maxDevType > 1) {
|
||||
//enum zbuffer formats
|
||||
zbuffFmt.dwZBufferBitDepth=0;
|
||||
if( dir3d->EnumZBufferFormats( dir3dDevDesc.deviceGUID,enumZbuffFormat,this )>=0 ){
|
||||
zbuffFmt.dwZBufferBitDepth = 0;
|
||||
if (dir3d->EnumZBufferFormats(dir3dDevDesc.deviceGUID, enumZbuffFormat, this) >= 0) {
|
||||
//create zbuff for back buffer
|
||||
if( back_canvas->attachZBuffer() ){
|
||||
if (back_canvas->attachZBuffer()) {
|
||||
//create 3d device
|
||||
if( dir3d->CreateDevice( dir3dDevDesc.deviceGUID,back_canvas->getSurface(),&dir3dDev )>=0 ){
|
||||
if (dir3d->CreateDevice(dir3dDevDesc.deviceGUID, back_canvas->getSurface(), &dir3dDev) >= 0) {
|
||||
//enum texture formats
|
||||
tex_fmts.clear();
|
||||
if( dir3dDev->EnumTextureFormats( enumTextureFormat,this )>=0 ){
|
||||
pickTexFmts( this,0 );
|
||||
pickTexFmts( this,1 );
|
||||
if (dir3dDev->EnumTextureFormats(enumTextureFormat, this) >= 0) {
|
||||
pickTexFmts(this, 0);
|
||||
pickTexFmts(this, 1);
|
||||
tex_fmts.clear();
|
||||
#ifdef BETA
|
||||
gx_runtime->debugLog( "Texture RGB format:" );
|
||||
debugPF( texRGBFmt );
|
||||
gx_runtime->debugLog( "Texture Alpha format:" );
|
||||
debugPF( texAlphaFmt );
|
||||
gx_runtime->debugLog( "Texture RGB Alpha format:" );
|
||||
debugPF( texRGBAlphaFmt );
|
||||
gx_runtime->debugLog( "Texture RGB Mask format:" );
|
||||
debugPF( texRGBMaskFmt );
|
||||
gx_runtime->debugLog( "Texture Primary format:" );
|
||||
debugPF( primFmt );
|
||||
string ts="ZBuffer Bit Depth:"+itoa( zbuffFmt.dwZBufferBitDepth );
|
||||
gx_runtime->debugLog( ts.c_str() );
|
||||
gx_runtime->debugLog("Texture RGB format:");
|
||||
debugPF(texRGBFmt);
|
||||
gx_runtime->debugLog("Texture Alpha format:");
|
||||
debugPF(texAlphaFmt);
|
||||
gx_runtime->debugLog("Texture RGB Alpha format:");
|
||||
debugPF(texRGBAlphaFmt);
|
||||
gx_runtime->debugLog("Texture RGB Mask format:");
|
||||
debugPF(texRGBMaskFmt);
|
||||
gx_runtime->debugLog("Texture Primary format:");
|
||||
debugPF(primFmt);
|
||||
string ts = "ZBuffer Bit Depth:" + itoa(zbuffFmt.dwZBufferBitDepth);
|
||||
gx_runtime->debugLog(ts.c_str());
|
||||
#endif
|
||||
gxScene *scene=d_new gxScene( this,back_canvas );
|
||||
scene_set.insert( scene );
|
||||
gxScene *scene = d_new gxScene(this, back_canvas);
|
||||
scene_set.insert(scene);
|
||||
|
||||
dummy_mesh=createMesh( 8,12,0 );
|
||||
dummy_mesh = createMesh(8, 12, 0);
|
||||
|
||||
return scene;
|
||||
}
|
||||
dir3dDev->Release();
|
||||
dir3dDev=0;
|
||||
dir3dDev = 0;
|
||||
}
|
||||
back_canvas->releaseZBuffer();
|
||||
}
|
||||
}
|
||||
}
|
||||
dir3d->Release();
|
||||
dir3d=0;
|
||||
dir3d = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
gxScene *gxGraphics::verifyScene( gxScene *s ){
|
||||
return scene_set.count( s ) ? s : 0;
|
||||
gxScene *gxGraphics::verifyScene(gxScene *s) {
|
||||
return scene_set.count(s) ? s : 0;
|
||||
}
|
||||
|
||||
void gxGraphics::freeScene( gxScene *scene ){
|
||||
if( !scene_set.erase( scene ) ) return;
|
||||
dummy_mesh=0;
|
||||
while( mesh_set.size() ) freeMesh( *mesh_set.begin() );
|
||||
void gxGraphics::freeScene(gxScene *scene) {
|
||||
if (!scene_set.erase(scene)) return;
|
||||
dummy_mesh = 0;
|
||||
while (mesh_set.size()) freeMesh(*mesh_set.begin());
|
||||
back_canvas->releaseZBuffer();
|
||||
if( dir3dDev ){ dir3dDev->Release();dir3dDev=0; }
|
||||
if( dir3d ){ dir3d->Release();dir3d=0; }
|
||||
if (dir3dDev) { dir3dDev->Release(); dir3dDev = 0; }
|
||||
if (dir3d) { dir3d->Release(); dir3d = 0; }
|
||||
delete scene;
|
||||
}
|
||||
|
||||
gxMesh *gxGraphics::createMesh( int max_verts,int max_tris,int flags ){
|
||||
gxMesh *gxGraphics::createMesh(int max_verts, int max_tris, int flags) {
|
||||
|
||||
static const int VTXFMT=
|
||||
D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_DIFFUSE|D3DFVF_TEX2|
|
||||
D3DFVF_TEXCOORDSIZE2(0)|D3DFVF_TEXCOORDSIZE2(1);
|
||||
static const int VTXFMT =
|
||||
D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX2 |
|
||||
D3DFVF_TEXCOORDSIZE2(0) | D3DFVF_TEXCOORDSIZE2(1);
|
||||
|
||||
int vbflags=0;
|
||||
int vbflags = 0;
|
||||
|
||||
//XP or less?
|
||||
if( runtime->osinfo.dwMajorVersion<6 ){
|
||||
vbflags|=D3DVBCAPS_WRITEONLY;
|
||||
}
|
||||
/*if (runtime->osinfo.dwMajorVersion < 6) {
|
||||
vbflags |= D3DVBCAPS_WRITEONLY;
|
||||
}*/
|
||||
|
||||
D3DVERTEXBUFFERDESC desc={ sizeof(desc),vbflags,VTXFMT,max_verts };
|
||||
D3DVERTEXBUFFERDESC desc = { sizeof(desc),vbflags,VTXFMT,max_verts };
|
||||
|
||||
IDirect3DVertexBuffer7 *buff;
|
||||
if( dir3d->CreateVertexBuffer( &desc,&buff,0 )<0 ) return 0;
|
||||
WORD *indices=d_new WORD[max_tris*3];
|
||||
gxMesh *mesh=d_new gxMesh( this,buff,indices,max_verts,max_tris );
|
||||
mesh_set.insert( mesh );
|
||||
if (dir3d->CreateVertexBuffer(&desc, &buff, 0) < 0) return 0;
|
||||
WORD *indices = d_new WORD[max_tris * 3];
|
||||
gxMesh *mesh = d_new gxMesh(this, buff, indices, max_verts, max_tris);
|
||||
mesh_set.insert(mesh);
|
||||
return mesh;
|
||||
}
|
||||
|
||||
gxMesh *gxGraphics::verifyMesh( gxMesh *m ){
|
||||
return mesh_set.count( m ) ? m : 0;
|
||||
gxMesh *gxGraphics::verifyMesh(gxMesh *m) {
|
||||
return mesh_set.count(m) ? m : 0;
|
||||
}
|
||||
|
||||
void gxGraphics::freeMesh( gxMesh *mesh ){
|
||||
if( mesh_set.erase( mesh ) ) delete mesh;
|
||||
}
|
||||
|
||||
#endif
|
||||
void gxGraphics::freeMesh(gxMesh *mesh) {
|
||||
if (mesh_set.erase(mesh)) delete mesh;
|
||||
}
|
||||
+44
-35
@@ -4,6 +4,8 @@
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#include "GraphicsRuntime.h"
|
||||
#include <d3d.h>
|
||||
|
||||
#include "ddutil.h"
|
||||
@@ -16,8 +18,18 @@
|
||||
|
||||
class gxRuntime;
|
||||
|
||||
class gxGraphics{
|
||||
class gxGraphics {
|
||||
private:
|
||||
// Direct3D9
|
||||
//LPDIRECT3D9 d3d9;
|
||||
//LPDIRECT3DDEVICE9 d3d9dev;
|
||||
//IDirect3DDevice9* d3d9Device;
|
||||
|
||||
public:
|
||||
gxGraphics(gxRuntime* runtime);
|
||||
gxGraphics(gxRuntime* runtime, IDirectDraw7 *dirDraw, IDirectDrawSurface7 *front, IDirectDrawSurface7 *back, bool d3d);
|
||||
~gxGraphics();
|
||||
|
||||
IDirectDraw7 *dirDraw;
|
||||
IDirectDraw *ds_dirDraw;
|
||||
|
||||
@@ -26,10 +38,7 @@ public:
|
||||
D3DDEVICEDESC7 dir3dDevDesc;
|
||||
DDPIXELFORMAT primFmt,zbuffFmt;
|
||||
|
||||
DDPIXELFORMAT texRGBFmt[2],texAlphaFmt[2],texRGBAlphaFmt[2],texRGBMaskFmt[2];
|
||||
|
||||
gxGraphics( gxRuntime *runtime,IDirectDraw7 *dirDraw,IDirectDrawSurface7 *front,IDirectDrawSurface7 *back,bool d3d );
|
||||
~gxGraphics();
|
||||
DDPIXELFORMAT texRGBFmt[2], texAlphaFmt[2], texRGBAlphaFmt[2], texRGBMaskFmt[2];
|
||||
|
||||
void backup();
|
||||
bool restore();
|
||||
@@ -38,14 +47,14 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
gxCanvas *front_canvas,*back_canvas;
|
||||
gxCanvas *front_canvas, *back_canvas;
|
||||
gxFont *def_font;
|
||||
bool gfx_lost;
|
||||
gxMesh *dummy_mesh;
|
||||
|
||||
DDSURFACEDESC2 initDesc( int w,int h,int flags );
|
||||
ddSurf *createSurface( int width,int height,int flags );
|
||||
ddSurf *loadSurface( const std::string &f,int flags );
|
||||
DDSURFACEDESC2 initDesc(int w, int h, int flags);
|
||||
ddSurf *createSurface(int width, int height, int flags);
|
||||
ddSurf *loadSurface(const std::string &f, int flags);
|
||||
|
||||
std::set<gxFont*> font_set;
|
||||
std::set<gxCanvas*> canvas_set;
|
||||
@@ -59,24 +68,24 @@ private:
|
||||
|
||||
/***** GX INTERFACE *****/
|
||||
public:
|
||||
enum{
|
||||
GRAPHICS_WINDOWED=1, //windowed mode
|
||||
GRAPHICS_SCALED=2, //scaled window
|
||||
GRAPHICS_3D=4, //3d mode! Hurrah!
|
||||
GRAPHICS_AUTOSUSPEND=8 //suspend graphics when app suspended
|
||||
enum {
|
||||
GRAPHICS_WINDOWED = 1, //windowed mode
|
||||
GRAPHICS_SCALED = 2, //scaled window
|
||||
GRAPHICS_3D = 4, //3d mode! Hurrah!
|
||||
GRAPHICS_AUTOSUSPEND = 8 //suspend graphics when app suspended
|
||||
};
|
||||
|
||||
//MANIPULATORS
|
||||
void vwait();
|
||||
void flip( bool vwait );
|
||||
void flip(bool vwait);
|
||||
|
||||
//SPECIAL!
|
||||
void copy( gxCanvas *dest,int dx,int dy,int dw,int dh,gxCanvas *src,int sx,int sy,int sw,int sh );
|
||||
void copy(gxCanvas *dest, int dx, int dy, int dw, int dh, gxCanvas *src, int sx, int sy, int sw, int sh);
|
||||
|
||||
//NEW! Gamma control!
|
||||
void setGamma( int r,int g,int b,float dr,float dg,float db );
|
||||
void getGamma( int r,int g,int b,float *dr,float *dg,float *db );
|
||||
void updateGamma( bool calibrate );
|
||||
void setGamma(int r, int g, int b, float dr, float dg, float db);
|
||||
void getGamma(int r, int g, int b, float *dr, float *dg, float *db);
|
||||
void updateGamma(bool calibrate);
|
||||
|
||||
//ACCESSORS
|
||||
int getWidth()const;
|
||||
@@ -91,26 +100,26 @@ public:
|
||||
gxFont *getDefaultFont()const;
|
||||
|
||||
//OBJECTS
|
||||
gxCanvas *createCanvas( int width,int height,int flags );
|
||||
gxCanvas *loadCanvas( const std::string &file,int flags );
|
||||
gxCanvas *verifyCanvas( gxCanvas *canvas );
|
||||
void freeCanvas( gxCanvas *canvas );
|
||||
gxCanvas *createCanvas(int width, int height, int flags);
|
||||
gxCanvas *loadCanvas(const std::string &file, int flags);
|
||||
gxCanvas *verifyCanvas(gxCanvas *canvas);
|
||||
void freeCanvas(gxCanvas *canvas);
|
||||
|
||||
gxMovie *openMovie( const std::string &file,int flags );
|
||||
gxMovie *verifyMovie( gxMovie *movie );
|
||||
void closeMovie( gxMovie *movie );
|
||||
gxMovie *openMovie(const std::string &file, int flags);
|
||||
gxMovie *verifyMovie(gxMovie *movie);
|
||||
void closeMovie(gxMovie *movie);
|
||||
|
||||
gxFont *loadFont( const std::string &font,int height,int flags );
|
||||
gxFont *verifyFont( gxFont *font );
|
||||
void freeFont( gxFont *font );
|
||||
gxFont *loadFont(const std::string &font, int height, int flags);
|
||||
gxFont *verifyFont(gxFont *font);
|
||||
void freeFont(gxFont *font);
|
||||
|
||||
gxScene *createScene( int flags );
|
||||
gxScene *verifyScene( gxScene *scene );
|
||||
void freeScene( gxScene *scene );
|
||||
gxScene *createScene(int flags);
|
||||
gxScene *verifyScene(gxScene *scene);
|
||||
void freeScene(gxScene *scene);
|
||||
|
||||
gxMesh *createMesh( int max_verts,int max_tris,int flags );
|
||||
gxMesh *verifyMesh( gxMesh *mesh );
|
||||
void freeMesh( gxMesh *mesh );
|
||||
gxMesh *createMesh(int max_verts, int max_tris, int flags);
|
||||
gxMesh *verifyMesh(gxMesh *mesh);
|
||||
void freeMesh(gxMesh *mesh);
|
||||
};
|
||||
|
||||
#endif
|
||||
+194
-193
@@ -1,126 +1,128 @@
|
||||
#pragma once
|
||||
|
||||
#include "std.h"
|
||||
#include "gxinput.h"
|
||||
#include "gxruntime.h"
|
||||
|
||||
#include <dinput.h>
|
||||
static const int QUE_SIZE = 32;
|
||||
|
||||
static const int QUE_SIZE=32;
|
||||
|
||||
class Device : public gxDevice{
|
||||
class Device : public gxDevice {
|
||||
public:
|
||||
bool acquired;
|
||||
gxInput *input;
|
||||
IDirectInputDevice7 *device;
|
||||
LPDIRECTINPUTDEVICE8 device;
|
||||
|
||||
Device( gxInput *i,IDirectInputDevice7 *d ):input(i),acquired(false),device(d){
|
||||
Device(gxInput *i, LPDIRECTINPUTDEVICE8 d) :input(i), acquired(false), device(d) {
|
||||
}
|
||||
virtual ~Device(){
|
||||
virtual ~Device() {
|
||||
device->Release();
|
||||
//device->Release();
|
||||
}
|
||||
bool acquire(){
|
||||
return acquired=device->Acquire()>=0;
|
||||
bool acquire() {
|
||||
return device->Acquire() >= 0;
|
||||
//return acquired=device->Acquire()>=0;
|
||||
}
|
||||
void unacquire(){
|
||||
void unacquire() {
|
||||
device->Unacquire();
|
||||
acquired=false;
|
||||
//device->Unacquire();
|
||||
acquired = false;
|
||||
}
|
||||
};
|
||||
|
||||
class Keyboard : public Device{
|
||||
class Keyboard : public Device {
|
||||
public:
|
||||
Keyboard( gxInput *i,IDirectInputDevice7 *d ):Device(i,d){
|
||||
Keyboard(gxInput *i, LPDIRECTINPUTDEVICE8 d) :Device(i, d) {
|
||||
}
|
||||
void update(){
|
||||
if( !acquired ){
|
||||
void update() {
|
||||
if (!acquired) {
|
||||
input->runtime->idle();
|
||||
return;
|
||||
}
|
||||
int k,cnt=32;
|
||||
DIDEVICEOBJECTDATA data[32],*curr;
|
||||
if( device->GetDeviceData( sizeof(DIDEVICEOBJECTDATA),data,(DWORD*)&cnt,0 )<0 ) return;
|
||||
curr=data;
|
||||
for( k=0;k<cnt;++curr,++k ){
|
||||
int n=curr->dwOfs;if( !n || n>255 ) continue;
|
||||
if( curr->dwData&0x80 ) downEvent( n );
|
||||
else upEvent( n );
|
||||
int k, cnt = 32;
|
||||
DIDEVICEOBJECTDATA data[32], *curr;
|
||||
if (device->GetDeviceData(sizeof(DIDEVICEOBJECTDATA), data, (DWORD*)&cnt, 0) < 0) return;
|
||||
curr = data;
|
||||
for (k = 0; k < cnt; ++curr, ++k) {
|
||||
int n = curr->dwOfs; if (!n || n > 255) continue;
|
||||
if (curr->dwData & 0x80) downEvent(n);
|
||||
else upEvent(n);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class Mouse : public Device{
|
||||
class Mouse : public Device {
|
||||
public:
|
||||
Mouse( gxInput *i,IDirectInputDevice7 *d ):Device(i,d){
|
||||
Mouse(gxInput *i, LPDIRECTINPUTDEVICE8 d) :Device(i, d) {
|
||||
}
|
||||
void update(){
|
||||
if( !acquired ){
|
||||
void update() {
|
||||
if (!acquired) {
|
||||
input->runtime->idle();
|
||||
return;
|
||||
}
|
||||
DIMOUSESTATE state;
|
||||
if( device->GetDeviceState(sizeof(state),&state)<0 ) return;
|
||||
if( gxGraphics *g=input->runtime->graphics ){
|
||||
int mx=axis_states[0]+state.lX;
|
||||
int my=axis_states[1]+state.lY;
|
||||
if( mx<0 ) mx=0;
|
||||
else if( mx>=g->getWidth() ) mx=g->getWidth()-1;
|
||||
if( my<0 ) my=0;
|
||||
else if( my>=g->getHeight() ) my=g->getHeight()-1;
|
||||
axis_states[0]=mx;
|
||||
axis_states[1]=my;
|
||||
axis_states[2]+=state.lZ;
|
||||
if (device->GetDeviceState(sizeof(state), &state) < 0) return;
|
||||
if (gxGraphics *g = input->runtime->graphics) {
|
||||
int mx = axis_states[0] + state.lX;
|
||||
int my = axis_states[1] + state.lY;
|
||||
if (mx < 0) mx = 0;
|
||||
else if (mx >= g->getWidth()) mx = g->getWidth() - 1;
|
||||
if (my < 0) my = 0;
|
||||
else if (my >= g->getHeight()) my = g->getHeight() - 1;
|
||||
axis_states[0] = mx;
|
||||
axis_states[1] = my;
|
||||
axis_states[2] += state.lZ;
|
||||
}
|
||||
for( int k=0;k<3;++k ){
|
||||
setDownState( k+1,state.rgbButtons[k]&0x80 ? true : false );
|
||||
for (int k = 0; k < 3; ++k) {
|
||||
setDownState(k + 1, state.rgbButtons[k] & 0x80 ? true : false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class Joystick : public Device{
|
||||
class Joystick : public Device {
|
||||
public:
|
||||
int type,poll_time;
|
||||
int mins[12],maxs[12];
|
||||
Joystick( gxInput *i,IDirectInputDevice7 *d,int t ):Device(i,d),type(t),poll_time(0){
|
||||
for( int k=0;k<12;++k ){
|
||||
int type, poll_time;
|
||||
int mins[12], maxs[12];
|
||||
Joystick(gxInput *i, LPDIRECTINPUTDEVICE8 d, int t) :Device(i, d), type(t), poll_time(0) {
|
||||
for (int k = 0; k < 12; ++k) {
|
||||
//initialize joystick axis ranges (d'oh!)
|
||||
DIPROPRANGE range;
|
||||
range.diph.dwSize=sizeof(DIPROPRANGE);
|
||||
range.diph.dwHeaderSize=sizeof(DIPROPHEADER);
|
||||
range.diph.dwObj=k*4+12;
|
||||
range.diph.dwHow=DIPH_BYOFFSET;
|
||||
if( d->GetProperty( DIPROP_RANGE,&range.diph )<0 ){
|
||||
mins[k]=0;
|
||||
maxs[k]=65535;
|
||||
range.diph.dwSize = sizeof(DIPROPRANGE);
|
||||
range.diph.dwHeaderSize = sizeof(DIPROPHEADER);
|
||||
range.diph.dwObj = k * 4 + 12;
|
||||
range.diph.dwHow = DIPH_BYOFFSET;
|
||||
if (d->GetProperty(DIPROP_RANGE, &range.diph) < 0) {
|
||||
mins[k] = 0;
|
||||
maxs[k] = 65535;
|
||||
continue;
|
||||
}
|
||||
mins[k]=range.lMin;
|
||||
maxs[k]=range.lMax-range.lMin;
|
||||
mins[k] = range.lMin;
|
||||
maxs[k] = range.lMax - range.lMin;
|
||||
}
|
||||
}
|
||||
void update(){
|
||||
unsigned tm=timeGetTime();
|
||||
if( tm-poll_time<3 ) return;
|
||||
if( device->Poll()<0 ){
|
||||
acquired=false;
|
||||
void update() {
|
||||
unsigned tm = timeGetTime();
|
||||
if (tm - poll_time < 3) return;
|
||||
if (device->Poll() < 0) {
|
||||
acquired = false;
|
||||
input->runtime->idle();
|
||||
acquire();if( device->Poll()<0 ) return;
|
||||
acquire(); if (device->Poll() < 0) return;
|
||||
}
|
||||
poll_time=tm;
|
||||
poll_time = tm;
|
||||
DIJOYSTATE state;
|
||||
if( device->GetDeviceState( sizeof( state ),&state )<0 ) return;
|
||||
axis_states[0]=(state.lX-mins[0])/(float)maxs[0]*2-1;
|
||||
axis_states[1]=(state.lY-mins[1])/(float)maxs[1]*2-1;
|
||||
axis_states[2]=(state.lZ-mins[2])/(float)maxs[2]*2-1;
|
||||
axis_states[3]=(state.rglSlider[0]-mins[6])/(float)maxs[6]*2-1;
|
||||
axis_states[4]=(state.rglSlider[1]-mins[7])/(float)maxs[7]*2-1;
|
||||
axis_states[5]=(state.lRx-mins[3])/(float)maxs[3]*2-1;
|
||||
axis_states[6]=(state.lRy-mins[4])/(float)maxs[4]*2-1;
|
||||
axis_states[7]=(state.lRz-mins[5])/(float)maxs[5]*2-1;
|
||||
if( (state.rgdwPOV[0]&0xffff)==0xffff ) axis_states[8]=-1;
|
||||
else axis_states[8]=floor(state.rgdwPOV[0]/100.0f+.5f);
|
||||
if (device->GetDeviceState(sizeof(state), &state) < 0) return;
|
||||
axis_states[0] = (state.lX - mins[0]) / (float)maxs[0] * 2 - 1;
|
||||
axis_states[1] = (state.lY - mins[1]) / (float)maxs[1] * 2 - 1;
|
||||
axis_states[2] = (state.lZ - mins[2]) / (float)maxs[2] * 2 - 1;
|
||||
axis_states[3] = (state.rglSlider[0] - mins[6]) / (float)maxs[6] * 2 - 1;
|
||||
axis_states[4] = (state.rglSlider[1] - mins[7]) / (float)maxs[7] * 2 - 1;
|
||||
axis_states[5] = (state.lRx - mins[3]) / (float)maxs[3] * 2 - 1;
|
||||
axis_states[6] = (state.lRy - mins[4]) / (float)maxs[4] * 2 - 1;
|
||||
axis_states[7] = (state.lRz - mins[5]) / (float)maxs[5] * 2 - 1;
|
||||
if ((state.rgdwPOV[0] & 0xffff) == 0xffff) axis_states[8] = -1;
|
||||
else axis_states[8] = floor(state.rgdwPOV[0] / 100.0f + .5f);
|
||||
|
||||
for( int k=0;k<31;++k ){
|
||||
setDownState( k+1,state.rgbButtons[k]&0x80 ? true : false );
|
||||
for (int k = 0; k < 31; ++k) {
|
||||
setDownState(k + 1, state.rgbButtons[k] & 0x80 ? true : false);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -128,69 +130,69 @@ public:
|
||||
static Keyboard *keyboard;
|
||||
static Mouse *mouse;
|
||||
static vector<Joystick*> joysticks;
|
||||
|
||||
static Keyboard *createKeyboard( gxInput *input ){
|
||||
IDirectInputDevice7 *dev;
|
||||
if( input->dirInput->CreateDeviceEx( GUID_SysKeyboard,IID_IDirectInputDevice7,(void**)&dev,0 )>=0 ){
|
||||
if( dev->SetCooperativeLevel( input->runtime->hwnd,DISCL_FOREGROUND|DISCL_EXCLUSIVE )>=0 ){
|
||||
|
||||
if( dev->SetDataFormat( &c_dfDIKeyboard )>=0 ){
|
||||
static Keyboard *createKeyboard(gxInput *input) {
|
||||
LPDIRECTINPUTDEVICE8 dev;
|
||||
if (input->dirInput->CreateDevice(GUID_SysKeyboard, &dev, NULL) >= 0) {
|
||||
if (dev->SetCooperativeLevel(input->runtime->hwnd, DISCL_FOREGROUND | DISCL_EXCLUSIVE) >= 0) {
|
||||
|
||||
if (dev->SetDataFormat(&c_dfDIKeyboard) >= 0) {
|
||||
DIPROPDWORD dword;
|
||||
memset( &dword,0,sizeof(dword) );
|
||||
dword.diph.dwSize=sizeof(DIPROPDWORD);
|
||||
dword.diph.dwHeaderSize=sizeof(DIPROPHEADER);
|
||||
dword.diph.dwObj=0;
|
||||
dword.diph.dwHow=DIPH_DEVICE;
|
||||
dword.dwData=32;
|
||||
if( dev->SetProperty( DIPROP_BUFFERSIZE,&dword.diph )>=0 ){
|
||||
return d_new Keyboard( input,dev );
|
||||
}else{
|
||||
// input->runtime->debugInfo( "keyboard: SetProperty failed" );
|
||||
memset(&dword, 0, sizeof(dword));
|
||||
dword.diph.dwSize = sizeof(DIPROPDWORD);
|
||||
dword.diph.dwHeaderSize = sizeof(DIPROPHEADER);
|
||||
dword.diph.dwObj = 0;
|
||||
dword.diph.dwHow = DIPH_DEVICE;
|
||||
dword.dwData = 32;
|
||||
if (dev->SetProperty(DIPROP_BUFFERSIZE, &dword.diph) >= 0) {
|
||||
return d_new Keyboard(input, dev);
|
||||
} else {
|
||||
// input->runtime->debugInfo( "keyboard: SetProperty failed" );
|
||||
}
|
||||
}else{
|
||||
// input->runtime->debugInfo( "keyboard: SetDataFormat failed" );
|
||||
} else {
|
||||
// input->runtime->debugInfo( "keyboard: SetDataFormat failed" );
|
||||
}
|
||||
return d_new Keyboard( input,dev );
|
||||
return d_new Keyboard(input, dev);
|
||||
|
||||
}else{
|
||||
input->runtime->debugInfo( "keyboard: SetCooperativeLevel failed" );
|
||||
} else {
|
||||
input->runtime->debugInfo("keyboard: SetCooperativeLevel failed");
|
||||
}
|
||||
dev->Release();
|
||||
}else{
|
||||
input->runtime->debugInfo( "keyboard: CreateDeviceEx failed" );
|
||||
} else {
|
||||
input->runtime->debugInfo("keyboard: CreateDeviceEx failed");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Mouse *createMouse( gxInput *input ){
|
||||
IDirectInputDevice7 *dev;
|
||||
if( input->dirInput->CreateDeviceEx( GUID_SysMouse,IID_IDirectInputDevice7,(void**)&dev,0 )>=0 ){
|
||||
if( dev->SetCooperativeLevel( input->runtime->hwnd,DISCL_FOREGROUND|DISCL_EXCLUSIVE )>=0 ){
|
||||
static Mouse *createMouse(gxInput *input) {
|
||||
LPDIRECTINPUTDEVICE8 dev;
|
||||
if (input->dirInput->CreateDevice(GUID_SysMouse, &dev, 0) >= 0) {
|
||||
if (dev->SetCooperativeLevel(input->runtime->hwnd, DISCL_FOREGROUND | DISCL_EXCLUSIVE) >= 0) {
|
||||
|
||||
if( dev->SetDataFormat( &c_dfDIMouse )>=0 ){
|
||||
return d_new Mouse( input,dev );
|
||||
}else{
|
||||
// input->runtime->debugInfo( "mouse: SetDataFormat failed" );
|
||||
if (dev->SetDataFormat(&c_dfDIMouse) >= 0) {
|
||||
return d_new Mouse(input, dev);
|
||||
} else {
|
||||
// input->runtime->debugInfo( "mouse: SetDataFormat failed" );
|
||||
}
|
||||
return d_new Mouse( input,dev );
|
||||
return d_new Mouse(input, dev);
|
||||
|
||||
}else{
|
||||
input->runtime->debugInfo( "mouse: SetCooperativeLevel failed" );
|
||||
} else {
|
||||
input->runtime->debugInfo("mouse: SetCooperativeLevel failed");
|
||||
}
|
||||
dev->Release();
|
||||
}else{
|
||||
input->runtime->debugInfo( "mouse: CreateDeviceEx failed" );
|
||||
} else {
|
||||
input->runtime->debugInfo("mouse: CreateDeviceEx failed");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Joystick *createJoystick( gxInput *input,LPCDIDEVICEINSTANCE devinst ){
|
||||
IDirectInputDevice7 *dev;
|
||||
if( input->dirInput->CreateDeviceEx( devinst->guidInstance,IID_IDirectInputDevice7,(void**)&dev,0 )>=0 ){
|
||||
if( dev->SetCooperativeLevel( input->runtime->hwnd,DISCL_FOREGROUND|DISCL_EXCLUSIVE )>=0 ){
|
||||
if( dev->SetDataFormat( &c_dfDIJoystick )>=0 ){
|
||||
int t=((devinst->dwDevType>>8)&0xff)==DIDEVTYPEJOYSTICK_GAMEPAD ? 1 : 2;
|
||||
return d_new Joystick( input,dev,t );
|
||||
static Joystick *createJoystick(gxInput *input, LPCDIDEVICEINSTANCE devinst) {
|
||||
LPDIRECTINPUTDEVICE8 dev;
|
||||
if (input->dirInput->CreateDevice(devinst->guidInstance, &dev, 0) >= 0) {
|
||||
if (dev->SetCooperativeLevel(input->runtime->hwnd, DISCL_FOREGROUND | DISCL_EXCLUSIVE) >= 0) {
|
||||
if (dev->SetDataFormat(&c_dfDIJoystick) >= 0) {
|
||||
int t = ((devinst->dwDevType >> 8) & 0xff) == DI8DEVCLASS_GAMECTRL ? 1 : 2;
|
||||
return d_new Joystick(input, dev, t);
|
||||
}
|
||||
}
|
||||
dev->Release();
|
||||
@@ -198,26 +200,25 @@ static Joystick *createJoystick( gxInput *input,LPCDIDEVICEINSTANCE devinst ){
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL CALLBACK enumJoystick( LPCDIDEVICEINSTANCE devinst,LPVOID pvRef ){
|
||||
static BOOL CALLBACK enumJoystick(LPCDIDEVICEINSTANCE devinst, LPVOID pvRef) {
|
||||
|
||||
if( (devinst->dwDevType&0xff)!=DIDEVTYPE_JOYSTICK ) return DIENUM_CONTINUE;
|
||||
if ((devinst->dwDevType & 0xff) != DI8DEVCLASS_GAMECTRL) return DIENUM_CONTINUE;
|
||||
|
||||
if( Joystick *joy=createJoystick( (gxInput*)pvRef,devinst ) ){
|
||||
joysticks.push_back( joy );
|
||||
if (Joystick *joy = createJoystick((gxInput*)pvRef, devinst)) {
|
||||
joysticks.push_back(joy);
|
||||
}
|
||||
return DIENUM_CONTINUE;
|
||||
}
|
||||
|
||||
gxInput::gxInput( gxRuntime *rt,IDirectInput7 *di ):
|
||||
runtime(rt),dirInput(di){
|
||||
keyboard=createKeyboard( this );
|
||||
mouse=createMouse( this );
|
||||
gxInput::gxInput(gxRuntime *rt, LPDIRECTINPUT8 di) : runtime(rt), dirInput(di) {
|
||||
keyboard = createKeyboard(this);
|
||||
mouse = createMouse(this);
|
||||
joysticks.clear();
|
||||
dirInput->EnumDevices( DIDEVTYPE_JOYSTICK,enumJoystick,this,DIEDFL_ATTACHEDONLY );
|
||||
dirInput->EnumDevices(DI8DEVCLASS_GAMECTRL, enumJoystick, this, DIEDFL_ATTACHEDONLY);
|
||||
}
|
||||
|
||||
gxInput::~gxInput(){
|
||||
for( int k=0;k<joysticks.size();++k ) delete joysticks[k];
|
||||
gxInput::~gxInput() {
|
||||
for (int k = 0; k < joysticks.size(); ++k) delete joysticks[k];
|
||||
joysticks.clear();
|
||||
delete mouse;
|
||||
delete keyboard;
|
||||
@@ -225,110 +226,110 @@ gxInput::~gxInput(){
|
||||
dirInput->Release();
|
||||
}
|
||||
|
||||
void gxInput::wm_keydown( int key ){
|
||||
if( keyboard ) keyboard->downEvent( key );
|
||||
void gxInput::wm_keydown(int key) {
|
||||
if (keyboard) keyboard->downEvent(key);
|
||||
}
|
||||
|
||||
void gxInput::wm_keyup( int key ){
|
||||
if( keyboard ) keyboard->upEvent( key );
|
||||
void gxInput::wm_keyup(int key) {
|
||||
if (keyboard) keyboard->upEvent(key);
|
||||
}
|
||||
|
||||
void gxInput::wm_mousedown( int key ){
|
||||
if( mouse ) mouse->downEvent( key );
|
||||
void gxInput::wm_mousedown(int key) {
|
||||
if (mouse) mouse->downEvent(key);
|
||||
}
|
||||
|
||||
void gxInput::wm_mouseup( int key ){
|
||||
if( mouse ) mouse->upEvent( key );
|
||||
void gxInput::wm_mouseup(int key) {
|
||||
if (mouse) mouse->upEvent(key);
|
||||
}
|
||||
|
||||
void gxInput::wm_mousemove( int x,int y ){
|
||||
if( mouse ){
|
||||
mouse->axis_states[0]=x;
|
||||
mouse->axis_states[1]=y;
|
||||
void gxInput::wm_mousemove(int x, int y) {
|
||||
if (mouse) {
|
||||
mouse->axis_states[0] = x;
|
||||
mouse->axis_states[1] = y;
|
||||
}
|
||||
}
|
||||
|
||||
void gxInput::wm_mousewheel( int dz ){
|
||||
if( mouse ) mouse->axis_states[2]+=dz;
|
||||
void gxInput::wm_mousewheel(int dz) {
|
||||
if (mouse) mouse->axis_states[2] += dz;
|
||||
}
|
||||
|
||||
void gxInput::reset(){
|
||||
if( mouse ) mouse->reset();
|
||||
if( keyboard ) keyboard->reset();
|
||||
for( int k=0;k<joysticks.size();++k ) joysticks[k]->reset();
|
||||
void gxInput::reset() {
|
||||
if (mouse) mouse->reset();
|
||||
if (keyboard) keyboard->reset();
|
||||
for (int k = 0; k < joysticks.size(); ++k) joysticks[k]->reset();
|
||||
}
|
||||
|
||||
bool gxInput::acquire(){
|
||||
bool m_ok=true,k_ok=true;
|
||||
if( mouse ) m_ok=mouse->acquire();
|
||||
if( keyboard ) k_ok=keyboard->acquire();
|
||||
if( m_ok && k_ok ) return true;
|
||||
if( k_ok ) keyboard->unacquire();
|
||||
if( m_ok ) mouse->unacquire();
|
||||
bool gxInput::acquire() {
|
||||
bool m_ok = true, k_ok = true;
|
||||
if (mouse) m_ok = mouse->acquire();
|
||||
if (keyboard) k_ok = keyboard->acquire();
|
||||
if (m_ok && k_ok) return true;
|
||||
if (k_ok) keyboard->unacquire();
|
||||
if (m_ok) mouse->unacquire();
|
||||
return false;
|
||||
}
|
||||
|
||||
void gxInput::unacquire(){
|
||||
if( keyboard ) keyboard->unacquire();
|
||||
if( mouse ) mouse->unacquire();
|
||||
void gxInput::unacquire() {
|
||||
if (keyboard) keyboard->unacquire();
|
||||
if (mouse) mouse->unacquire();
|
||||
}
|
||||
|
||||
void gxInput::moveMouse( int x,int y ){
|
||||
if( !mouse ) return;
|
||||
mouse->axis_states[0]=x;
|
||||
mouse->axis_states[1]=y;
|
||||
runtime->moveMouse( x,y );
|
||||
void gxInput::moveMouse(int x, int y) {
|
||||
if (!mouse) return;
|
||||
mouse->axis_states[0] = x;
|
||||
mouse->axis_states[1] = y;
|
||||
runtime->moveMouse(x, y);
|
||||
}
|
||||
|
||||
gxDevice *gxInput::getMouse()const{
|
||||
gxDevice *gxInput::getMouse()const {
|
||||
return mouse;
|
||||
}
|
||||
|
||||
gxDevice *gxInput::getKeyboard()const{
|
||||
gxDevice *gxInput::getKeyboard()const {
|
||||
return keyboard;
|
||||
}
|
||||
|
||||
gxDevice *gxInput::getJoystick( int n )const{
|
||||
return n>=0 && n<joysticks.size() ? joysticks[n] : 0;
|
||||
gxDevice *gxInput::getJoystick(int n)const {
|
||||
return n >= 0 && n < joysticks.size() ? joysticks[n] : 0;
|
||||
}
|
||||
|
||||
int gxInput::getJoystickType( int n )const{
|
||||
return n>=0 && n<joysticks.size() ? joysticks[n]->type : 0;
|
||||
int gxInput::getJoystickType(int n)const {
|
||||
return n >= 0 && n < joysticks.size() ? joysticks[n]->type : 0;
|
||||
}
|
||||
|
||||
int gxInput::numJoysticks()const{
|
||||
int gxInput::numJoysticks()const {
|
||||
return joysticks.size();
|
||||
}
|
||||
|
||||
int gxInput::toAscii( int scan )const{
|
||||
switch( scan ){
|
||||
case DIK_INSERT:return ASC_INSERT;
|
||||
case DIK_DELETE:return ASC_DELETE;
|
||||
case DIK_HOME:return ASC_HOME;
|
||||
case DIK_END:return ASC_END;
|
||||
case DIK_PGUP:return ASC_PAGEUP;
|
||||
case DIK_PGDN:return ASC_PAGEDOWN;
|
||||
case DIK_UP:return ASC_UP;
|
||||
case DIK_DOWN:return ASC_DOWN;
|
||||
case DIK_LEFT:return ASC_LEFT;
|
||||
case DIK_RIGHT:return ASC_RIGHT;
|
||||
int gxInput::toAscii(int scan)const {
|
||||
switch (scan) {
|
||||
case DIK_INSERT:return ASC_INSERT;
|
||||
case DIK_DELETE:return ASC_DELETE;
|
||||
case DIK_HOME:return ASC_HOME;
|
||||
case DIK_END:return ASC_END;
|
||||
case DIK_PGUP:return ASC_PAGEUP;
|
||||
case DIK_PGDN:return ASC_PAGEDOWN;
|
||||
case DIK_UP:return ASC_UP;
|
||||
case DIK_DOWN:return ASC_DOWN;
|
||||
case DIK_LEFT:return ASC_LEFT;
|
||||
case DIK_RIGHT:return ASC_RIGHT;
|
||||
}
|
||||
scan&=0x7f;
|
||||
int virt=MapVirtualKey( scan,1 );
|
||||
if( !virt ) return 0;
|
||||
scan &= 0x7f;
|
||||
int virt = MapVirtualKey(scan, 1);
|
||||
if (!virt) return 0;
|
||||
|
||||
static unsigned char mat[256];
|
||||
mat[VK_LSHIFT]=keyboard->keyDown( DIK_LSHIFT ) ? 0x80 : 0;
|
||||
mat[VK_RSHIFT]=keyboard->keyDown( DIK_RSHIFT ) ? 0x80 : 0;
|
||||
mat[VK_SHIFT]=mat[VK_LSHIFT]|mat[VK_RSHIFT];
|
||||
mat[VK_LCONTROL]=keyboard->keyDown( DIK_LCONTROL ) ? 0x80 : 0;
|
||||
mat[VK_RCONTROL]=keyboard->keyDown( DIK_RCONTROL ) ? 0x80 : 0;
|
||||
mat[VK_CONTROL]=mat[VK_LCONTROL]|mat[VK_RCONTROL];
|
||||
mat[VK_LMENU]=keyboard->keyDown( DIK_LMENU ) ? 0x80 : 0;
|
||||
mat[VK_RMENU]=keyboard->keyDown( DIK_RMENU ) ? 0x80 : 0;
|
||||
mat[VK_MENU]=mat[VK_LMENU]|mat[VK_RMENU];
|
||||
mat[VK_LSHIFT] = keyboard->keyDown(DIK_LSHIFT) ? 0x80 : 0;
|
||||
mat[VK_RSHIFT] = keyboard->keyDown(DIK_RSHIFT) ? 0x80 : 0;
|
||||
mat[VK_SHIFT] = mat[VK_LSHIFT] | mat[VK_RSHIFT];
|
||||
mat[VK_LCONTROL] = keyboard->keyDown(DIK_LCONTROL) ? 0x80 : 0;
|
||||
mat[VK_RCONTROL] = keyboard->keyDown(DIK_RCONTROL) ? 0x80 : 0;
|
||||
mat[VK_CONTROL] = mat[VK_LCONTROL] | mat[VK_RCONTROL];
|
||||
mat[VK_LMENU] = keyboard->keyDown(DIK_LMENU) ? 0x80 : 0;
|
||||
mat[VK_RMENU] = keyboard->keyDown(DIK_RMENU) ? 0x80 : 0;
|
||||
mat[VK_MENU] = mat[VK_LMENU] | mat[VK_RMENU];
|
||||
|
||||
WORD ch;
|
||||
if( ToAscii( virt,scan,mat,&ch,0 )!=1 ) return 0;
|
||||
if (ToAscii(virt, scan, mat, &ch, 0) != 1) return 0;
|
||||
return ch & 255;
|
||||
}
|
||||
|
||||
+6
-10
@@ -1,19 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef GXINPUT_H
|
||||
#define GXINPUT_H
|
||||
|
||||
#include <dinput.h>
|
||||
|
||||
#include "std.h"
|
||||
#include "gxdevice.h"
|
||||
#include "GraphicsRuntime.h"
|
||||
|
||||
class gxRuntime;
|
||||
|
||||
class gxInput{
|
||||
public:
|
||||
gxRuntime *runtime;
|
||||
IDirectInput7 *dirInput;
|
||||
LPDIRECTINPUT8 dirInput;
|
||||
|
||||
gxInput( gxRuntime *runtime,IDirectInput7 *di );
|
||||
gxInput( gxRuntime *runtime, LPDIRECTINPUT8 di );
|
||||
~gxInput();
|
||||
|
||||
void reset();
|
||||
@@ -45,6 +43,4 @@ public:
|
||||
int getJoystickType( int port )const;
|
||||
int numJoysticks()const;
|
||||
int toAscii( int key )const;
|
||||
};
|
||||
|
||||
#endif
|
||||
};
|
||||
@@ -7,7 +7,6 @@
|
||||
const float PI=3.14159265359f; //180 degrees
|
||||
const float TWOPI=PI*2.0f; //360 degrees
|
||||
const float HALFPI=PI*.5f; //90 degrees
|
||||
const float FLT_EPSILON=.000001f;
|
||||
|
||||
gxLight::gxLight( gxScene *s,int type ):
|
||||
scene(s){
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
|
||||
#include "GraphicsRuntime.h"
|
||||
|
||||
#ifndef GXLIGHT_H
|
||||
#define GXLIGHT_H
|
||||
|
||||
|
||||
@@ -35,9 +35,9 @@ bool gxMesh::lock( bool all ){
|
||||
int flags=DDLOCK_WAIT|DDLOCK_WRITEONLY;
|
||||
|
||||
//XP or less?
|
||||
if( graphics->runtime->osinfo.dwMajorVersion<6 ){
|
||||
/*if( graphics->runtime->osinfo.dwMajorVersion<6 ){
|
||||
flags|=(all ? DDLOCK_DISCARDCONTENTS : DDLOCK_NOOVERWRITE);
|
||||
}
|
||||
}*/
|
||||
|
||||
if( vertex_buff->Lock( flags,(void**)&locked_verts,0 )>=0 ){
|
||||
mesh_dirty=false;
|
||||
|
||||
+24
-24
@@ -3,28 +3,28 @@
|
||||
#include "gxmovie.h"
|
||||
#include "gxgraphics.h"
|
||||
|
||||
gxMovie::gxMovie( gxGraphics *g,IMultiMediaStream *mm )
|
||||
:gfx(g),mm_stream( mm ),playing(true){
|
||||
gxMovie::gxMovie(gxGraphics *g, IMultiMediaStream *mm)
|
||||
:gfx(g), mm_stream(mm), playing(true) {
|
||||
|
||||
mm_stream->GetMediaStream( MSPID_PrimaryVideo,&vid_stream );
|
||||
vid_stream->QueryInterface( IID_IDirectDrawMediaStream,(void**)&dd_stream );
|
||||
////mm_stream->GetMediaStream( MSPID_PrimaryVideo,&vid_stream );
|
||||
////vid_stream->QueryInterface(IID_IDirectDrawMediaStream, (void**)&dd_stream);
|
||||
|
||||
DDSURFACEDESC desc={sizeof(desc)};
|
||||
dd_stream->GetFormat( &desc,0,0,0 );
|
||||
//DDSURFACEDESC desc = { sizeof(desc) };
|
||||
//dd_stream->GetFormat(&desc, 0, 0, 0);
|
||||
|
||||
canvas=gfx->createCanvas( desc.dwWidth,desc.dwHeight,0 ); //gxCanvas::CANVAS_NONDISPLAY );
|
||||
canvas->getSurface()->QueryInterface( IID_IDirectDrawSurface,(void**)&dd_surf );
|
||||
//canvas = gfx->createCanvas(desc.dwWidth, desc.dwHeight, 0); //gxCanvas::CANVAS_NONDISPLAY );
|
||||
//canvas->getSurface()->QueryInterface(IID_IDirectDrawSurface, (void**)&dd_surf);
|
||||
|
||||
src_rect.left=src_rect.top=0;
|
||||
src_rect.right=desc.dwWidth;src_rect.bottom=desc.dwHeight;
|
||||
//src_rect.left = src_rect.top = 0;
|
||||
//src_rect.right = desc.dwWidth; src_rect.bottom = desc.dwHeight;
|
||||
|
||||
dd_stream->CreateSample( dd_surf,&src_rect,0,&dd_sample );
|
||||
//dd_stream->CreateSample(dd_surf, &src_rect, 0, &dd_sample);
|
||||
|
||||
mm_stream->SetState( STREAMSTATE_RUN );
|
||||
//mm_stream->SetState(STREAMSTATE_RUN);
|
||||
}
|
||||
|
||||
gxMovie::~gxMovie(){
|
||||
mm_stream->SetState( STREAMSTATE_STOP );
|
||||
gxMovie::~gxMovie() {
|
||||
/*mm_stream->SetState(STREAMSTATE_STOP);
|
||||
|
||||
dd_sample->Release();
|
||||
dd_surf->Release();
|
||||
@@ -32,17 +32,17 @@ gxMovie::~gxMovie(){
|
||||
vid_stream->Release();
|
||||
mm_stream->Release();
|
||||
|
||||
gfx->freeCanvas( canvas );
|
||||
gfx->freeCanvas(canvas);*/
|
||||
}
|
||||
|
||||
bool gxMovie::draw( gxCanvas *dest,int x,int y,int w,int h ){
|
||||
if( !playing ) return false;
|
||||
if( !dd_sample->Update( 0,0,0,0 ) ){
|
||||
RECT dest_rect={x,y,x+w,y+h};
|
||||
dest->getSurface()->Blt( &dest_rect,canvas->getSurface(),&src_rect,DDBLT_WAIT,0 );
|
||||
dest->damage( dest_rect );
|
||||
}else{
|
||||
playing=false;
|
||||
}
|
||||
bool gxMovie::draw(gxCanvas *dest, int x, int y, int w, int h) {
|
||||
if (!playing) return false;
|
||||
/*if (!dd_sample->Update(0, 0, 0, 0)) {
|
||||
RECT dest_rect = { x,y,x + w,y + h };
|
||||
dest->getSurface()->Blt(&dest_rect, canvas->getSurface(), &src_rect, DDBLT_WAIT, 0);
|
||||
dest->damage(dest_rect);
|
||||
} else {
|
||||
playing = false;
|
||||
}*/
|
||||
return playing;
|
||||
}
|
||||
|
||||
+644
-684
File diff suppressed because it is too large
Load Diff
@@ -110,10 +110,10 @@ public:
|
||||
void debugError( const char *t );
|
||||
void debugLog( const char *t );
|
||||
|
||||
int numGraphicsDrivers();
|
||||
int enumerateGraphicsDrivers();
|
||||
void graphicsDriverInfo( int driver,std::string *name,int *caps );
|
||||
|
||||
int numGraphicsModes( int driver );
|
||||
int countGraphicsModes( int driver );
|
||||
void graphicsModeInfo( int driver,int mode,int *w,int *h,int *d,int *caps );
|
||||
|
||||
void windowedModeInfo( int *caps );
|
||||
|
||||
+48
-141
@@ -1,14 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Blitz2DRelease|Win32">
|
||||
<Configuration>Blitz2DRelease</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Blitz3DRelease|Win32">
|
||||
<Configuration>Blitz3DRelease</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
@@ -17,52 +9,32 @@
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Template|Win32">
|
||||
<Configuration>Template</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<SccProjectName />
|
||||
<SccLocalPath />
|
||||
<ProjectGuid>{FF2D8BF7-1930-4CAB-BC48-05CD33B7DC18}</ProjectGuid>
|
||||
<WindowsTargetPlatformVersion>10.0.10586.0</WindowsTargetPlatformVersion>
|
||||
<ProjectName>GraphicsRuntime</ProjectName>
|
||||
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Template|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Blitz3DRelease|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Blitz2DRelease|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Template|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
|
||||
@@ -71,113 +43,44 @@
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Blitz3DRelease|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Blitz2DRelease|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Blitz2DRelease|Win32'">
|
||||
<OutDir>.\gxruntime___Win32_Blitz2DRelease\</OutDir>
|
||||
<IntDir>.\gxruntime___Win32_Blitz2DRelease\</IntDir>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Blitz3DRelease|Win32'">
|
||||
<OutDir>.\gxruntime___Win32_Blitz3DRelease\</OutDir>
|
||||
<IntDir>.\gxruntime___Win32_Blitz3DRelease\</IntDir>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>.\Release\</OutDir>
|
||||
<IntDir>.\Release\</IntDir>
|
||||
<OutDir>..\#Build\$(ProjectName)\$(ConfigurationName)\</OutDir>
|
||||
<IntDir>..\#Intermediate\$(ProjectName)\$(ConfigurationName)\</IntDir>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>$(DXSDK_DIR)Include\;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
|
||||
<LibraryPath>$(DXSDK_DIR)Lib\x86\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>..\#Build\$(ProjectName)\$(ConfigurationName)\</OutDir>
|
||||
<IntDir>..\#Intermediate\$(ProjectName)\$(ConfigurationName)\</IntDir>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>$(DXSDK_DIR)Include\;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
|
||||
<LibraryPath>$(DXSDK_DIR)Lib\x86\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Blitz2DRelease|Win32'">
|
||||
<ClCompile>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<StringPooling>true</StringPooling>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AssemblerListingLocation>.\gxruntime___Win32_Blitz2DRelease\</AssemblerListingLocation>
|
||||
<PrecompiledHeaderOutputFile>.\gxruntime___Win32_Blitz2DRelease\gxruntime.pch</PrecompiledHeaderOutputFile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>std.h</PrecompiledHeaderFile>
|
||||
<ObjectFileName>.\gxruntime___Win32_Blitz2DRelease\</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\gxruntime___Win32_Blitz2DRelease\</ProgramDataBaseFileName>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
<Bscmake>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<OutputFile>.\gxruntime___Win32_Blitz2DRelease\gxruntime.bsc</OutputFile>
|
||||
</Bscmake>
|
||||
<Lib>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<OutputFile>.\gxruntime___Win32_Blitz2DRelease\gxruntime.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Blitz3DRelease|Win32'">
|
||||
<ClCompile>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<StringPooling>true</StringPooling>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PreprocessorDefinitions>_LIB;WIN32;NDEBUG;PRO;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AssemblerListingLocation>.\gxruntime___Win32_Blitz3DRelease\</AssemblerListingLocation>
|
||||
<PrecompiledHeaderOutputFile>.\gxruntime___Win32_Blitz3DRelease\gxruntime.pch</PrecompiledHeaderOutputFile>
|
||||
<PrecompiledHeader />
|
||||
<ObjectFileName>.\gxruntime___Win32_Blitz3DRelease\</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\gxruntime___Win32_Blitz3DRelease\</ProgramDataBaseFileName>
|
||||
<CallingConvention>StdCall</CallingConvention>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
<Bscmake>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<OutputFile>.\gxruntime___Win32_Blitz3DRelease\gxruntime.bsc</OutputFile>
|
||||
</Bscmake>
|
||||
<Lib>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<OutputFile>.\gxruntime___Win32_Blitz3DRelease\gxruntime.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<StringPooling>true</StringPooling>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AssemblerListingLocation>.\Release\</AssemblerListingLocation>
|
||||
<PrecompiledHeaderOutputFile>.\Release\gxruntime.pch</PrecompiledHeaderOutputFile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>std.h</PrecompiledHeaderFile>
|
||||
<ObjectFileName>.\Release\</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\Release\</ProgramDataBaseFileName>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<CreateHotpatchableImage>true</CreateHotpatchableImage>
|
||||
<FloatingPointExceptions>true</FloatingPointExceptions>
|
||||
<CompileAsManaged>false</CompileAsManaged>
|
||||
<CompileAsWinRT>false</CompileAsWinRT>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<ControlFlowGuard>Guard</ControlFlowGuard>
|
||||
<ProgramDataBaseFileName>$(IntDir)vc$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>
|
||||
<EnforceTypeConversionRules>false</EnforceTypeConversionRules>
|
||||
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
||||
<OpenMPSupport>false</OpenMPSupport>
|
||||
<CallingConvention>StdCall</CallingConvention>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
@@ -189,26 +92,34 @@
|
||||
</Bscmake>
|
||||
<Lib>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<OutputFile>.\Release\gxruntime.lib</OutputFile>
|
||||
<AdditionalDependencies>dxguid.lib;ddraw.lib;dinput8.lib;dsound.lib;d3dxof.lib;dxgi.lib;d3dx9.lib</AdditionalDependencies>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
|
||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AssemblerListingLocation>.\Debug\</AssemblerListingLocation>
|
||||
<PrecompiledHeaderOutputFile>.\Debug\gxruntime.pch</PrecompiledHeaderOutputFile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>std.h</PrecompiledHeaderFile>
|
||||
<ObjectFileName>.\Debug\</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\Debug\</ProgramDataBaseFileName>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<CreateHotpatchableImage>true</CreateHotpatchableImage>
|
||||
<FloatingPointExceptions>true</FloatingPointExceptions>
|
||||
<CompileAsManaged>false</CompileAsManaged>
|
||||
<CompileAsWinRT>false</CompileAsWinRT>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<StringPooling>true</StringPooling>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<ControlFlowGuard>Guard</ControlFlowGuard>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<ProgramDataBaseFileName>$(IntDir)vc$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>
|
||||
<EnforceTypeConversionRules>true</EnforceTypeConversionRules>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<OpenMPSupport>false</OpenMPSupport>
|
||||
<CallingConvention>StdCall</CallingConvention>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
@@ -220,7 +131,8 @@
|
||||
</Bscmake>
|
||||
<Lib>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<OutputFile>.\Debug\gxruntime.lib</OutputFile>
|
||||
<AdditionalDependencies>dxguid.lib;ddraw.lib;dinput8.lib;dsound.lib;d3dxof.lib;dxgi.lib;d3dx9.lib</AdditionalDependencies>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
@@ -238,18 +150,12 @@
|
||||
<ClCompile Include="gxmesh.cpp" />
|
||||
<ClCompile Include="gxmovie.cpp" />
|
||||
<ClCompile Include="gxruntime.cpp">
|
||||
<AssemblerOutput Condition="'$(Configuration)|$(Platform)'=='Blitz2DRelease|Win32'">AssemblyAndSourceCode</AssemblerOutput>
|
||||
<AssemblerOutput Condition="'$(Configuration)|$(Platform)'=='Blitz3DRelease|Win32'">AssemblyAndSourceCode</AssemblerOutput>
|
||||
<AssemblerOutput Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AssemblyAndSourceCode</AssemblerOutput>
|
||||
</ClCompile>
|
||||
<ClCompile Include="gxscene.cpp" />
|
||||
<ClCompile Include="gxsound.cpp" />
|
||||
<ClCompile Include="gxtimer.cpp" />
|
||||
<ClCompile Include="std.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Blitz2DRelease|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Blitz2DRelease|Win32'">std.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Blitz3DRelease|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Blitz3DRelease|Win32'">std.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">std.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
@@ -259,6 +165,7 @@
|
||||
<ItemGroup>
|
||||
<ClInclude Include="asmcoder.h" />
|
||||
<ClInclude Include="ddutil.h" />
|
||||
<ClInclude Include="GraphicsRuntime.h" />
|
||||
<ClInclude Include="gxaudio.h" />
|
||||
<ClInclude Include="gxcanvas.h" />
|
||||
<ClInclude Include="gxchannel.h" />
|
||||
|
||||
@@ -124,5 +124,8 @@
|
||||
<ClInclude Include="std.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="GraphicsRuntime.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -560,6 +560,7 @@ void gxScene::render( gxMesh *m,int first_vert,int vert_cnt,int first_tri,int tr
|
||||
tris_drawn+=tri_cnt;
|
||||
if( n_texs<=tex_stages ) return;
|
||||
|
||||
|
||||
setTSS( 0,D3DTSS_COLOROP,D3DTOP_SELECTARG1 );
|
||||
setTSS( 0,D3DTSS_ALPHAOP,D3DTOP_SELECTARG1 );
|
||||
if( tex_stages>1 ){
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
|
||||
#include "GraphicsRuntime.h"
|
||||
|
||||
#ifndef GXSCENE_H
|
||||
#define GXSCENE_H
|
||||
|
||||
|
||||
+2
-5
@@ -2,7 +2,7 @@
|
||||
#ifndef STD_H
|
||||
#define STD_H
|
||||
|
||||
#include "../fmodapi375win/api/inc/fmod.h"
|
||||
#include "../#ThirdParty/fmodapi375win/api/inc/fmod.h"
|
||||
|
||||
#include "../config/config.h"
|
||||
#include "../stdutil/stdutil.h"
|
||||
@@ -10,7 +10,6 @@
|
||||
#pragma warning( disable:4786 )
|
||||
|
||||
#define DIRECTSOUND_VERSION 0x700
|
||||
#define DIRECTINPUT_VERSION 0x700
|
||||
|
||||
#include <set>
|
||||
#include <map>
|
||||
@@ -22,9 +21,7 @@
|
||||
|
||||
#include <math.h>
|
||||
#include <windows.h>
|
||||
#include <ddraw.h>
|
||||
#include <dinput.h>
|
||||
#include <d3d.h>
|
||||
#include "GraphicsRuntime.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user