Remove d3d driver

This commit is contained in:
Kristian Høgsberg 2010-02-25 15:52:32 -05:00
parent 4387580e50
commit 97972244d5
22 changed files with 0 additions and 8769 deletions

View File

@ -1,124 +0,0 @@
DirectX 6 Driver for Mesa 3.0
This software is distributed under the terms of the GNU Library
General Public License, see the LICENSE file for details.
What do you need ?
------------------
- A PC with a DirectX 6 video driver installed.
- Mesa 3.0
- The 3Dfx Glide library 2.3 or later for your OS (the 2.4 works fine).
The Voodoo2 requires the Glide library 2.51. The Glide 3.0 is not
compatible with the Glide 2.x so it doesn't work with the current
version of the driver;
- Visual C++ 5.0 is only compiler test but others should be ok with
changes to the makefiles (CFLAGS/LFLAGS).
- DirectX 6 SDK (was a MS download but not sure if still available).
- SoftIce or another debugger that will get DPF's is nice.
Tested on:
----------
Windows 95
Windows 98
Windows NT 5.0 (beta 2)
What is able to do ?
--------------------
- the driver will try and use DirectX to rasterize the OpenGL primitives
that are sent to the driver. The driver will fall back to SW if the rendering
context is too big. The fallback to SW still uses DirectDraw. If the driver
fails to support and operation (accum, stencil, etc) then it will try and get
Mesa to render it in SW. DirectX 6 features that are unsupported by the
installed DirectX 6 driver will be mapped to some other best fit feature.
How to compile:
---------------
These instructions assume you have Visual C++ installed.
You might need to increase you enviroment space. You can do this by
adding the following statement to you config.sys.
shell=C:\COMMAND.COM C:\ /p /e:8198
Next setup you compiler enviroment by running vcvars32.bat in the Visual C++
'bin' directoy.
c:\DevStudio\VC\bin\vcvars32.bat
Modify the D3D makefile to point at your SDK install. Example has the SDK
installed on my 'f' drive in the root.
file: \Mesa-3.0\src\makefile.d3d
SDKROOT=f:\mssdk
Now you can simply make the project. If you look in the makefile you can see
I have some different targets like 'install'.
nmake /f makefile.d3d
FAQ:
----
1) I don't think the driver is using my DirectX driver.
This maybe true as the current version will only select the Primary D3D driver
installed. If you 3D card is the secondary (3dfx) then your out of luck for this
release.
2) The driver seems like its not HW accelerated.
If you have a video card with limited memory then you might want to try and
change your destop resolution to a low setting (640x480x16) so that the 3D part
of the card has more resources. Remeber the driver can't make the card better...
3) Nothing works.
Make sure you have a DirectX '6' driver installed. Check you driver docs for this
info or use the SDK info utilities.
The final 'dll' is named opengl32.dll and is either in the same directory as the
OpenGL program or in your system directory (x:\windows\system or x:\winnt\system32).
Check your destop resolution. Most DirectX 6 drivers will only support 16bit and
32bit color depth. To find out for sure you can check the DirectX Info Viewer in
the SDK.
4) Rendering doesn't look right.
Sometimes this is because the card doesn't support a feature that that is required.
This is usually due to unsupported alpha functions (test/blend) or texture mapping.
Some cards suffer from too small of an alpha channel. The driver does its best to
fallback on unsupported features. This is not to say the driver may not have a bug(s).
5) Textures look bad.
No mipmapping in this release.
Thanks to:
----------
Brian Paul
Leigh McRae (leigh@altsoftware.com)
February 9, 1999

View File

@ -1,250 +0,0 @@
/*===========================================================================*/
/* */
/* Mesa-3.0 DirectX 6 Driver Build 5 */
/* */
/* By Leigh McRae */
/* */
/* http://www.altsoftware.com/ */
/* */
/* Copyright (c) 1999-1998 alt.software inc. All Rights Reserved */
/*===========================================================================*/
#include "D3DHAL.h"
/*===========================================================================*/
/* Macros. */
/*===========================================================================*/
#define SRCBLEND_MAP(gl,d3d,fall) if ( pHAL->D3DHWDevDesc.dpcTriCaps.dwSrcBlendCaps & d3d ) \
{ \
sprintf( buffer, "SRC Blend: %s -> %s", # gl, # d3d ); \
DPF(( (DBG_CNTX_INFO|DBG_TXT_INFO), buffer )); \
pShared->dwSrcBlendCaps[index] = d3d; \
} \
else \
{ \
sprintf( buffer, "SRC Blend: %s -> %s", # gl, # fall ); \
DPF(( (DBG_CNTX_INFO|DBG_TXT_INFO), buffer )); \
pShared->dwSrcBlendCaps[index] = fall; \
}
#define DSTBLEND_MAP(gl,d3d,fall) if ( pHAL->D3DHWDevDesc.dpcTriCaps.dwDestBlendCaps & d3d ) \
{ \
sprintf( buffer, "DST Blend: %s -> %s", # gl, # d3d ); \
DPF(( (DBG_CNTX_INFO|DBG_TXT_INFO), buffer )); \
pShared->dwDestBlendCaps[index] = d3d; \
} \
else \
{ \
sprintf( buffer, "DST Blend: %s -> %s", # gl, # fall ); \
DPF(( (DBG_CNTX_INFO|DBG_TXT_INFO), buffer )); \
pShared->dwDestBlendCaps[index] = fall; \
}
/*===========================================================================*/
/* I use this function to handle the fact that the D3D texture blending and */
/* OpenGL texture blending functions don't map one to one. Also there is the*/
/* problem with cards not supporting all the D3D functions. So I use the CAPS*/
/* of the card to make a table of functions that will have defaults for the */
/* unsupported functions. */
/* So first I fill the table with the fallback function then I check to see */
/* if the card supports the requested function. If it does I replace the */
/* default thats already in the array. Now order does matter as I used an */
/* enum type in D3DShared.h so that the mapping would be a little easier. */
/*===========================================================================*/
/* RETURN: */
/*===========================================================================*/
void AlphaBlendTableHAL( PMESAD3DHAL pHAL )
{
PMESAD3DSHARED pShared = &pHAL->shared;
int index;
char buffer[128];
DPF(( DBG_FUNC, "AlphaBlendTableHAL();" ));
/* Make the fallback for the Source blend. */
for( index = 0; index < 14; index++ )
{
switch( index )
{
case s_zero:
SRCBLEND_MAP( GL_ZERO, D3DBLEND_ZERO, D3DBLEND_ONE );
break;
case s_one:
SRCBLEND_MAP( GL_ONE, D3DBLEND_ONE, D3DBLEND_ONE );
break;
case s_dst_color:
SRCBLEND_MAP( GL_DST_COLOR, D3DBLEND_DESTCOLOR, D3DBLEND_ONE );
break;
case s_one_minus_dst_color:
SRCBLEND_MAP( GL_ONE_MINUS_DST_COLOR, D3DBLEND_INVDESTCOLOR, D3DBLEND_ONE );
break;
case s_src_alpha:
SRCBLEND_MAP( GL_SRC_ALPHA, D3DBLEND_SRCALPHA, D3DBLEND_ONE );
break;
case s_one_minus_src_alpha:
SRCBLEND_MAP( GL_ONE_MINUS_SRC_ALPHA, D3DBLEND_INVSRCALPHA, D3DBLEND_ONE );
break;
case s_dst_alpha:
SRCBLEND_MAP( GL_DST_ALPHA, D3DBLEND_DESTALPHA, D3DBLEND_ONE );
break;
case s_one_minus_dst_alpha:
SRCBLEND_MAP( GL_ONE_MINUS_DST_ALPHA, D3DBLEND_INVDESTALPHA, D3DBLEND_ONE );
break;
case s_src_alpha_saturate:
SRCBLEND_MAP( GL_SRC_ALPHA_SATURATE, D3DBLEND_SRCALPHASAT, D3DBLEND_ONE );
break;
case s_constant_color:
SRCBLEND_MAP( GL_CONSTANT_COLOR, D3DBLEND_SRCCOLOR, D3DBLEND_ONE );
break;
case s_one_minus_constant_color:
SRCBLEND_MAP( GL_ONE_MINUS_CONSTANT_COLOR, D3DBLEND_INVSRCCOLOR, D3DBLEND_ONE );
break;
case s_constant_alpha:
SRCBLEND_MAP( GL_CONSTANT_ALPHA, D3DBLEND_BOTHSRCALPHA, D3DBLEND_ONE );
break;
case s_one_minus_constant_alpha:
SRCBLEND_MAP( GL_ONE_MINUS_CONSTANT_ALPHA, D3DBLEND_BOTHINVSRCALPHA, D3DBLEND_ONE );
break;
}
}
/* Make the fallback for the Destination blend. */
for( index = 0; index < 14; index++ )
{
switch( index )
{
case d_zero:
DSTBLEND_MAP( GL_ZERO, D3DBLEND_ZERO, D3DBLEND_ONE );
break;
case d_one:
DSTBLEND_MAP( GL_ONE, D3DBLEND_ONE, D3DBLEND_ONE );
break;
case d_src_color:
DSTBLEND_MAP( GL_SRC_COLOR, D3DBLEND_SRCCOLOR, D3DBLEND_ONE );
break;
case d_one_minus_src_color:
DSTBLEND_MAP( GL_ONE_MINUS_SRC_COLOR, D3DBLEND_INVSRCCOLOR, D3DBLEND_ONE );
break;
case d_src_alpha:
DSTBLEND_MAP( GL_SRC_ALPHA, D3DBLEND_SRCALPHA, D3DBLEND_ONE );
break;
case d_one_minus_src_alpha:
DSTBLEND_MAP( GL_ONE_MINUS_SRC_ALPHA, D3DBLEND_INVSRCALPHA, D3DBLEND_ONE );
break;
case d_dst_alpha:
DSTBLEND_MAP( GL_DST_ALPHA, D3DBLEND_DESTALPHA, D3DBLEND_ONE );
break;
case d_one_minus_dst_alpha:
DSTBLEND_MAP( GL_ONE_MINUS_DST_ALPHA, D3DBLEND_INVDESTALPHA, D3DBLEND_ONE );
break;
case d_constant_color:
DSTBLEND_MAP( GL_CONSTANT_COLOR, D3DBLEND_DESTCOLOR, D3DBLEND_ONE );
break;
case d_one_minus_constant_color:
DSTBLEND_MAP( GL_ONE_MINUS_CONSTANT_COLOR, D3DBLEND_INVDESTCOLOR, D3DBLEND_ONE );
break;
case d_constant_alpha:
DSTBLEND_MAP( GL_CONSTANT_ALPHAR, D3DBLEND_BOTHSRCALPHA, D3DBLEND_ONE );
break;
case d_one_minus_constant_alpha:
DSTBLEND_MAP( GL_ONE_MINUS_CONSTANT_ALPHA, D3DBLEND_BOTHINVSRCALPHA, D3DBLEND_ONE );
break;
}
}
/* Make the fallbacks for the texture functions. */
for( index = 0; index < 4; index++ )
{
switch( index )
{
case d3dtblend_decal:
if ( pHAL->D3DHWDevDesc.dpcTriCaps.dwTextureBlendCaps & D3DTBLEND_DECAL )
{
DPF(( (DBG_CNTX_INFO|DBG_TXT_INFO), "D3DTBLEND_DECAL -> D3DTBLEND_DECAL" ));
pShared->dwTexFunc[index] = D3DTBLEND_DECAL;
}
else
{
if ( pHAL->D3DHWDevDesc.dpcTriCaps.dwTextureBlendCaps & D3DTBLEND_MODULATE )
{
DPF(( (DBG_CNTX_INFO|DBG_TXT_INFO), "D3DTBLEND_DECAL -> D3DTBLEND_MODULATE" ));
pShared->dwTexFunc[index] = D3DTBLEND_MODULATE;
}
else
{
DPF(( (DBG_CNTX_INFO|DBG_TXT_INFO), "D3DTBLEND_DECAL -> D3DTBLEND_ADD" ));
pShared->dwTexFunc[index] = D3DTBLEND_ADD;
}
}
break;
case d3dtblend_decalalpha:
if ( pHAL->D3DHWDevDesc.dpcTriCaps.dwTextureBlendCaps & D3DTBLEND_DECALALPHA )
{
DPF(( (DBG_CNTX_INFO|DBG_TXT_INFO), "D3DTBLEND_DECALALPHA -> D3DTBLEND_DECALALPHA" ));
pShared->dwTexFunc[index] = D3DTBLEND_DECALALPHA;
}
else
{
if ( pHAL->D3DHWDevDesc.dpcTriCaps.dwTextureBlendCaps & D3DTBLEND_DECAL )
{
DPF(( (DBG_CNTX_INFO|DBG_TXT_INFO), "D3DTBLEND_DECALALPA -> D3DTBLEND_DECAL" ));
pShared->dwTexFunc[index] = D3DTBLEND_DECAL;
}
else
{
DPF(( (DBG_CNTX_INFO|DBG_TXT_INFO), "D3DTBLEND_DECALALPHA -> D3DTBLEND_ADD" ));
pShared->dwTexFunc[index] = D3DTBLEND_ADD;
}
}
break;
case d3dtblend_modulate:
if ( pHAL->D3DHWDevDesc.dpcTriCaps.dwTextureBlendCaps & D3DTBLEND_MODULATE )
{
DPF(( (DBG_CNTX_INFO|DBG_TXT_INFO), "D3DTBLEND_MODULATE -> D3DTBLEND_MODULATE" ));
pShared->dwTexFunc[index] = D3DTBLEND_MODULATE;
}
else
{
if ( pHAL->D3DHWDevDesc.dpcTriCaps.dwTextureBlendCaps & D3DTBLEND_MODULATEALPHA )
{
DPF(( (DBG_CNTX_INFO|DBG_TXT_INFO), "D3DTBLEND_MODULATE -> D3DTBLEND_MODULATEALPHA" ));
pShared->dwTexFunc[index] = D3DTBLEND_MODULATEALPHA;
}
else if ( pHAL->D3DHWDevDesc.dpcTriCaps.dwTextureBlendCaps & D3DTBLEND_DECAL )
{
DPF(( (DBG_CNTX_INFO|DBG_TXT_INFO), "D3DTBLEND_MODULATE -> D3DTBLEND_DECAL" ));
pShared->dwTexFunc[index] = D3DTBLEND_DECAL;
}
else
{
DPF(( (DBG_CNTX_INFO|DBG_TXT_INFO), "D3DTBLEND_MODULATE -> D3DTBLEND_ADD" ));
pShared->dwTexFunc[index] = D3DTBLEND_ADD;
}
}
break;
case d3dtblend_modulatealpha:
if ( pHAL->D3DHWDevDesc.dpcTriCaps.dwTextureBlendCaps & D3DTBLEND_MODULATEALPHA )
{
DPF(( (DBG_CNTX_INFO|DBG_TXT_INFO), "D3DTBLEND_MODULATEALPHA -> D3DTBLEND_MODULATEALPHA" ));
pShared->dwTexFunc[index] = D3DTBLEND_MODULATEALPHA;
}
else
{
if ( pHAL->D3DHWDevDesc.dpcTriCaps.dwTextureBlendCaps & D3DTBLEND_MODULATE )
{
DPF(( (DBG_CNTX_INFO|DBG_TXT_INFO), "D3DTBLEND_MODULATEALPHA -> D3DTBLEND_MODULATE" ));
pShared->dwTexFunc[index] = D3DTBLEND_MODULATE;
}
else if ( pHAL->D3DHWDevDesc.dpcTriCaps.dwTextureBlendCaps & D3DTBLEND_DECAL )
{
DPF(( (DBG_CNTX_INFO|DBG_TXT_INFO), "D3DTBLEND_MODULATEALPHA -> D3DTBLEND_DECALE" ));
pShared->dwTexFunc[index] = D3DTBLEND_DECAL;
}
else
{
DPF(( (DBG_CNTX_INFO|DBG_TXT_INFO), "D3DTBLEND_MODULATEALPHA -> D3DTBLEND_ADD" ));
pShared->dwTexFunc[index] = D3DTBLEND_ADD;
}
}
break;
}
}
}

View File

@ -1,68 +0,0 @@
/*===========================================================================*/
/* */
/* Mesa-3.0 DirectX 6 Driver */
/* */
/* By Leigh McRae */
/* */
/* http://www.altsoftware.com/ */
/* */
/* Copyright (c) 1999-1998 alt.software inc. All Rights Reserved */
/*===========================================================================*/
#ifndef _D3D_HAL_INC
#define _D3D_HAL_INC
/*===========================================================================*/
/* Includes. */
/*===========================================================================*/
#include <windows.h>
#include <ddraw.h>
#include <d3d.h>
#include <stdlib.h>
#include <time.h>
#include "D3DShared.h"
#include "D3DTextureMgr.h"
#include "Debug.h"
/*===========================================================================*/
/* Defines. */
/*===========================================================================*/
#define DX_RESTORE(ps) if ( (ps) && (ps)->IsLost() ) (ps)->Restore();
/*===========================================================================*/
/* Type defines. */
/*===========================================================================*/
typedef struct _d3d_hal_struct
{
MESAD3DSHARED shared;
GUID guid;
LPDIRECTDRAW lpDD;
LPDIRECTDRAW4 lpDD4;
LPDIRECT3D3 lpD3D3;
LPDIRECT3DDEVICE3 lpD3DDevice;
D3DDEVICEDESC D3DHWDevDesc;
LPDIRECTDRAWSURFACE4 lpDDSPrimary,
lpDDSRender,
lpDDSZbuffer;
LPDIRECT3DVIEWPORT3 lpViewport;
LPDIRECTDRAWCLIPPER lpClipper;
DDPIXELFORMAT ddpf,
ddpfZBuffer;
PTM_OBJECT pTMList;
} MESAD3DHAL, *PMESAD3DHAL;
/*===========================================================================*/
/* External function prototypes. */
/*===========================================================================*/
extern BOOL InitTMgrHAL( PMESAD3DHAL pHAL );
extern void TermTMgrHAL( PMESAD3DHAL pHAL );
extern void AlphaBlendTableHAL( PMESAD3DHAL pHAL );
extern void Solve8BitChannelPixelFormat( DDPIXELFORMAT *pddpf, PPIXELINFO pPixel );
extern char *ErrorStringD3D( HRESULT hr );
extern void FatalShutDown( PMESAD3DHAL pHAL );
/*===========================================================================*/
/* Global variables. */
/*===========================================================================*/
extern char *errorMsg;
#endif

View File

@ -1,891 +0,0 @@
/*===========================================================================*/
/* */
/* Mesa-3.0 DirectX 6 Driver Build 5 */
/* */
/* By Leigh McRae */
/* */
/* http://www.altsoftware.com/ */
/* */
/* Copyright (c) 1999-1998 alt.software inc. All Rights Reserved */
/*===========================================================================*/
#include "D3DHAL.h"
/*===========================================================================*/
/* Local function prototypes. */
/*===========================================================================*/
static void DestroyAllSurfaces( PMESAD3DHAL pHAL );
static void DestroyDevice( PMESAD3DHAL pHAL );
static void DestroyInterfaces( PMESAD3DHAL pHAL );
HRESULT WINAPI EnumSurfacesHook( LPDIRECTDRAWSURFACE4 lpDDS, LPDDSURFACEDESC2 lpDDSDesc, LPVOID pVoid );
HRESULT CALLBACK EnumZBufferHook( DDPIXELFORMAT* pddpf, VOID *pVoid );
HRESULT CALLBACK EnumDeviceHook( GUID FAR* lpGuid, LPSTR lpDesc, LPSTR lpName, LPD3DDEVICEDESC lpD3DHWDesc, LPD3DDEVICEDESC lpD3DHELDesc, void *pVoid );
/*===========================================================================*/
/* Globals. */
/*===========================================================================*/
//char *errorMsg;
/*===========================================================================*/
/* This function is responable for allocating the actual MESAD3DHAL struct. */
/* Each Mesa context will have its own MESAD3DHAL struct so its like a mini */
/* context to some extent. All one time allocations/operations get done here.*/
/*===========================================================================*/
/* RETURN: TRUE, FALSE. */
/*===========================================================================*/
extern "C" PMESAD3DSHARED InitHAL( HWND hwnd )
{
PMESAD3DHAL pHAL;
ULONG rc;
DPF(( DBG_FUNC, "InitHAL();" ));
DPF(( DBG_CNTX_INFO, "hwnd: %d", hwnd ));
/* Allocate the structure and zero it out. */
pHAL = (PMESAD3DHAL)ALLOC( sizeof(MESAD3DHAL) );
if ( pHAL == NULL )
{
RIP( pHAL, "InitHAL->", "Memory Allocation" );
return (PMESAD3DSHARED)NULL;
}
memset( pHAL, 0, sizeof(MESAD3DHAL) );
/* Get the texture manager going. */
rc = InitTMgrHAL( pHAL );
if ( rc == FALSE )
{
RIP( pHAL, "InitTMgrHAL->", "Failed" );
return (PMESAD3DSHARED)NULL;
}
/* Fill in the window parameters if we can. */
pHAL->shared.hwnd = hwnd;
/* Parse the user's enviroment variables to generate a debug mask. */
ReadDBGEnv();
return (PMESAD3DSHARED)pHAL;
}
/*===========================================================================*/
/* This function will unload all the resources that the MESAD3DHAL struct */
/* has bound to it. The actual structure itself will be freed. */
/*===========================================================================*/
/* RETURN: */
/*===========================================================================*/
extern "C" void TermHAL( PMESAD3DSHARED pShared )
{
PMESAD3DHAL pHAL = (PMESAD3DHAL)pShared;
DPF(( DBG_FUNC, "TermHAL();" ));
/* Check for an empty wrapper structure. */
if ( pHAL == NULL )
return;
/* Kill this texture manager. */
TermTMgrHAL( pHAL );
/* Kill any DDraw stuff if exists. */
DestroyDevice( pHAL );
DestroyAllSurfaces( pHAL );
DestroyInterfaces( pHAL );
FREE( pHAL );
}
/*===========================================================================*/
/* This function is used to init and resize the rendering surface as the two*/
/* are almost the same. First the device and all the surfaces are destoryed */
/* if they already exist. Next we create a OffScreen rendering surface and */
/* save some pixelformat info to do color convertions. Next we start to take */
/* care of getting the most out of the hardware. I use bHardware to determine*/
/* the state of the device we found in the device enumeration. The enum proc*/
/* will try for hardware first. I next use a bForceSW to make the enum proc */
/* choose a software device. So I will try some combinations with HW first */
/* until I feel I have to set the bForceSW and call this function again. If */
/* this function is called with no width or height then use the internals. */
/* NOTE: The worst case is that all will be in SW (RGBDevice) and really */
/* I should forget the whole thing and fall back to a DDraw span type*/
/* rendering but what is the point. This way I always know I have a */
/* D3DDevice and that makes things easier. I do impliment the span */
/* rendering function for stuff that I haven't done support for such */
/* as points and lines. */
/*===========================================================================*/
/* RETURN: TRUE, FALSE */
/*===========================================================================*/
extern "C" BOOL CreateHAL( PMESAD3DSHARED pShared )
{
PMESAD3DHAL pHAL = (PMESAD3DHAL)pShared;
DDSURFACEDESC2 ddsd2;
D3DDEVICEDESC D3DSWDevDesc;
DDSCAPS2 ddscaps;
DWORD dwCoopFlags,
dwWidth,
dwHeight;
ULONG rc;
DPF(( DBG_FUNC, "CreateHAL();" ));
#define InitDDSD2(f) memset( &ddsd2, 0, sizeof(DDSURFACEDESC2) ); \
ddsd2.dwSize = sizeof( DDSURFACEDESC2 ); \
ddsd2.dwFlags = f;
if ( pHAL == NULL )
return FALSE;
/* Use the internal rectangle struct. */
dwWidth = pShared->rectW.right - pShared->rectW.left;
dwHeight = pShared->rectW.bottom - pShared->rectW.top;
DPF(( DBG_CNTX_INFO, "Width: %d Height: %d", dwWidth, dwHeight ));
/* The dimensions might still be the same so just leave. */
if ( (dwWidth == pShared->dwWidth) && (dwHeight == pShared->dwHeight) )
{
DPF(( DBG_CNTX_WARN, "Context size hasn't changed" ));
return TRUE;
}
/* If one of the dimensions are zero then leave. WM_SIZE should get us back here. */
if ( (dwWidth == 0) || (dwHeight == 0) )
return TRUE;
/* Save the renders dimensions. */
pShared->dwWidth = dwWidth;
pShared->dwHeight = dwHeight;
DPF(( DBG_CNTX_INFO, "Creating Context:\n cx:%d cy:%d", pShared->dwWidth, pShared->dwHeight ));
/*=================================*/
/* Create all required interfaces. */
/*=================================*/
/* Kill any DDraw stuff if exists. */
DestroyDevice( pHAL );
DestroyAllSurfaces( pHAL );
DestroyInterfaces( pHAL );
/* Create a instance of DDraw using the Primary display driver. */
rc = DirectDrawCreate( NULL, &pHAL->lpDD, NULL );
if( FAILED(rc) )
{
RIP( pHAL, "DirectDrawCreate->", ErrorStringD3D(rc) );
return FALSE;
}
/* Get the DDraw4 interface. */
rc = pHAL->lpDD->QueryInterface( IID_IDirectDraw4, (void **)&pHAL->lpDD4 );
if( FAILED(rc) )
{
RIP( pHAL, "QueryInterface (IID_IDirectDraw4) ->", ErrorStringD3D(rc) );
return FALSE;
}
/* Get the Direct3D3 interface. */
rc = pHAL->lpDD4->QueryInterface( IID_IDirect3D3, (void **)&pHAL->lpD3D3 );
if( FAILED(rc) )
{
RIP( pHAL, "QueryInterface (IID_IDirect3D3) ->", ErrorStringD3D(rc) );
return FALSE;
}
/* Set the Cooperative level. NOTE: we need to know if we are FS at this point.*/
dwCoopFlags = (pShared->bWindow == TRUE) ? DDSCL_NORMAL : (DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
rc = pHAL->lpDD4->SetCooperativeLevel( pShared->hwnd, dwCoopFlags );
if ( FAILED(rc) )
{
RIP( pHAL, "SetCooperativeLevel->", ErrorStringD3D(rc) );
return FALSE;
}
/*==================================================================*/
/* Get the best device we can and note whether its hardware or not. */
/*==================================================================*/
pShared->bForceSW = FALSE;
pHAL->lpD3D3->EnumDevices( EnumDeviceHook, (void *)pHAL );
pShared->bHardware = IsEqualIID( pHAL->guid, IID_IDirect3DHALDevice );
DPF(( DBG_CNTX_INFO, "bHardware: %s", (pShared->bHardware) ? "TRUE" : "FALSE" ));
DPF(( DBG_CNTX_INFO, "bWindowed: %s", (pShared->bWindow) ? "TRUE" : "FALSE" ));
/*========================================================================*/
/* HARDWARE was found. */
/*========================================================================*/
if ( pShared->bHardware == TRUE )
{
/*===================================*/
/* HARDWARE -> Z-BUFFER. */
/*===================================*/
/* Get a Z-Buffer pixelformat. */
memset( &ddsd2, 0, sizeof(DDSURFACEDESC2) );
ddsd2.dwSize = sizeof( DDSURFACEDESC2 );
rc = pHAL->lpD3D3->EnumZBufferFormats( pHAL->guid, EnumZBufferHook, (VOID*)&ddsd2.ddpfPixelFormat );
if ( FAILED(rc) )
{
RIP( pHAL, "EnumZBufferFormatsl->", ErrorStringD3D(rc) );
return FALSE;
}
/* Setup our request structure for the Z-buffer surface. */
ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
ddsd2.ddsCaps.dwCaps = DDSCAPS_ZBUFFER | DDSCAPS_VIDEOMEMORY;
ddsd2.dwWidth = dwWidth;
ddsd2.dwHeight = dwHeight;
rc = pHAL->lpDD4->CreateSurface( &ddsd2, &pHAL->lpDDSZbuffer, NULL );
if ( !FAILED(rc) )
{
DPF(( DBG_CNTX_INFO, "HW ZBuffer" ));
/*===================================*/
/* HARDWARE -> Z-BUFFER -> FLIPABLE */
/*===================================*/
if ( pShared->bWindow == FALSE )
{
InitDDSD2( DDSD_CAPS | DDSD_BACKBUFFERCOUNT );
ddsd2.dwBackBufferCount = 1;
ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
rc = pHAL->lpDD4->CreateSurface( &ddsd2, &pHAL->lpDDSPrimary, NULL );
if ( FAILED(rc) )
{
/* Make sure we try the next fall back. */
DPF(( DBG_CNTX_WARN, "HW Flip/Complex not available" ));
pHAL->lpDDSPrimary = NULL;
}
else
{
/* Get the back buffer that was created. */
ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
rc = pHAL->lpDDSPrimary->GetAttachedSurface( &ddscaps, &pHAL->lpDDSRender );
if ( FAILED(rc) )
{
DPF(( DBG_CNTX_WARN, "GetAttachedSurface failed -> HW Flip/Complex" ));
/* Make sure we try the next fall back. */
pHAL->lpDDSPrimary->Release();
pHAL->lpDDSPrimary = NULL;
}
else
{
/* I have had problems when a complex surface comes back */
/* with the back buffer being created in SW. Not sure why */
/* or how this is possable but I'm checking for it here. */
memset( &ddsd2, 0, sizeof(DDSURFACEDESC2) );
ddsd2.dwSize = sizeof( DDSURFACEDESC2 );
DX_RESTORE( pHAL->lpDDSRender );
rc = pHAL->lpDDSRender->GetSurfaceDesc( &ddsd2 );
if ( FAILED(rc) )
{
RIP( pHAL, "GetSurfaceDesc (RENDER) ->", ErrorStringD3D(rc) );
return FALSE;
}
/* If the surface is in VID then we are happy with are Flipable. */
if ( ddsd2.ddsCaps.dwCaps & DDSCAPS_LOCALVIDMEM )
{
pShared->bFlipable = TRUE;
DPF(( DBG_CNTX_INFO, "HW Flip/Complex!" ));
}
else
{
/* Kill this setup. */
pHAL->lpDDSPrimary->Release();
pHAL->lpDDSPrimary = NULL;
}
}
}
}
/*===================================*/
/* HARDWARE -> Z-BUFFER -> BLT */
/*===================================*/
if ( pHAL->lpDDSPrimary == NULL )
{
pShared->bFlipable = FALSE;
/* Create the Primary (front buffer). */
InitDDSD2( DDSD_CAPS );
ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
rc = pHAL->lpDD4->CreateSurface( &ddsd2, &pHAL->lpDDSPrimary, NULL );
if ( FAILED(rc) )
{
/* This is an error as we should be able to do this at minimum. */
RIP( pHAL, "CreateSurface (PRIMARY) ->", ErrorStringD3D(rc) );
return FALSE;
}
/* Create the Render (back buffer). */
InitDDSD2( DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT );
ddsd2.dwWidth = dwWidth;
ddsd2.dwHeight = dwHeight;
ddsd2.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
rc = pHAL->lpDD4->CreateSurface( &ddsd2, &pHAL->lpDDSRender, NULL );
if ( FAILED(rc) )
{
DPF(( DBG_CNTX_WARN, "Failed HW Offscreen surface" ));
/* Make sure we try the next fall back. */
pHAL->lpDDSPrimary->Release();
pHAL->lpDDSPrimary = NULL;
}
else
{
/* Might as well check here too see if this surface is in */
/* hardware. If nothing else just to be consistant. */
memset( &ddsd2, 0, sizeof(DDSURFACEDESC2) );
ddsd2.dwSize = sizeof( DDSURFACEDESC2 );
DX_RESTORE( pHAL->lpDDSRender );
rc = pHAL->lpDDSRender->GetSurfaceDesc( &ddsd2 );
if ( FAILED(rc) )
{
RIP( pHAL, "GetSurfaceDesc (RENDER) ->", ErrorStringD3D(rc) );
return FALSE;
}
/* If the surface is in VID then we are happy. */
if ( ddsd2.ddsCaps.dwCaps & DDSCAPS_LOCALVIDMEM )
{
/* Create a clipper object so that DDraw will be able to blt windows that */
/* have been clipped by the screen or other windows. */
pHAL->lpDD4->CreateClipper( 0, &pHAL->lpClipper, NULL );
pHAL->lpClipper->SetHWnd( 0, pShared->hwnd );
pHAL->lpDDSPrimary->SetClipper( pHAL->lpClipper );
pHAL->lpClipper->Release();
DPF(( DBG_CNTX_INFO, "HW RENDER surface" ));
}
else
{
/* Kill this setup. */
pHAL->lpDDSRender->Release();
pHAL->lpDDSRender = NULL;
pHAL->lpDDSPrimary->Release();
pHAL->lpDDSPrimary = NULL;
}
}
}
/*===================================*/
/* Create D3DDEVICE -> HARDWARE. */
/*===================================*/
if ( pHAL->lpDDSZbuffer && pHAL->lpDDSPrimary && pHAL->lpDDSRender )
{
DX_RESTORE( pHAL->lpDDSRender );
DX_RESTORE( pHAL->lpDDSZbuffer );
rc = pHAL->lpDDSRender->AddAttachedSurface( pHAL->lpDDSZbuffer );
if ( FAILED(rc) )
{
RIP( pHAL, "AddAttachedSurface (ZBUFFER) ->", ErrorStringD3D(rc) );
return FALSE;
}
rc = pHAL->lpD3D3->CreateDevice( IID_IDirect3DHALDevice, pHAL->lpDDSRender, &pHAL->lpD3DDevice, NULL );
if ( rc != D3D_OK )
{
DPF(( DBG_CNTX_WARN, "Failed HW Device" ));
pHAL->lpD3DDevice = NULL;
}
else
{
DPF(( DBG_CNTX_INFO, "HW Device" ));
}
}
}
}
/*========================================================================*/
/* SOFTWARE fallback. */
/*========================================================================*/
if ( pHAL->lpD3DDevice == NULL )
{
DPF(( DBG_CNTX_INFO, "SW fallback :(" ));
/* Make sure we have no surfaces allocated. Just incase. */
DestroyAllSurfaces( pHAL );
/* Get a software device. */
pShared->bFlipable = FALSE;
pShared->bForceSW = TRUE;
pHAL->lpD3D3->EnumDevices( EnumDeviceHook, (void *)pHAL );
pShared->bHardware = IsEqualIID( pHAL->guid, IID_IDirect3DHALDevice );
/*===================================*/
/* SOFTWARE -> Z-BUFFER. */
/*===================================*/
/*===================================*/
/* SOFTWARE -> Z-BUFFER -> FLIPABLE */
/*===================================*/
if ( pShared->bWindow == FALSE )
{
InitDDSD2( DDSD_CAPS | DDSD_BACKBUFFERCOUNT );
ddsd2.dwBackBufferCount = 1;
ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
ddsd2.ddpfPixelFormat.dwSize = sizeof( DDPIXELFORMAT );
ddsd2.ddpfPixelFormat.dwFlags = (DDPF_RGB | DDPF_ALPHAPIXELS);
rc = pHAL->lpDD4->CreateSurface( &ddsd2, &pHAL->lpDDSPrimary, NULL );
if ( FAILED(rc) )
{
DPF(( DBG_CNTX_WARN, "Failed SW Flip/Complex" ));
/* Make sure we try the next fall back. */
pHAL->lpDDSPrimary = NULL;
}
else
{
ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
rc = pHAL->lpDDSPrimary->GetAttachedSurface( &ddscaps, &pHAL->lpDDSRender );
if ( FAILED(rc) )
{
/* Make sure we try the next fall back. */
DPF(( DBG_CNTX_WARN, "GetAttachedSurface failed -> SW Flip/Complex" ));
pHAL->lpDDSPrimary->Release();
pHAL->lpDDSPrimary = NULL;
}
else
{
DPF(( DBG_CNTX_INFO, "SW Flip/Complex" ));
pShared->bFlipable = TRUE;
}
}
}
/*===================================*/
/* SOFTWARE -> Z-BUFFER -> BLT */
/*===================================*/
if ( pHAL->lpDDSPrimary == NULL )
{
/* Create the Primary (front buffer). */
InitDDSD2( DDSD_CAPS );
ddsd2.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
rc = pHAL->lpDD4->CreateSurface( &ddsd2, &pHAL->lpDDSPrimary, NULL );
if ( FAILED(rc) )
{
/* This is an error as we should be able to do this at minimum. */
RIP( pHAL, "CreateSurface (PRIMARY) ->", ErrorStringD3D(rc) );
return FALSE;
}
/* Create the Render (back buffer). */
InitDDSD2( DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT );
ddsd2.dwWidth = dwWidth;
ddsd2.dwHeight = dwHeight;
ddsd2.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
ddsd2.ddpfPixelFormat.dwSize = sizeof( DDPIXELFORMAT );
ddsd2.ddpfPixelFormat.dwFlags = (DDPF_RGB | DDPF_ALPHAPIXELS);
rc = pHAL->lpDD4->CreateSurface( &ddsd2, &pHAL->lpDDSRender, NULL );
if ( FAILED(rc) )
{
/* That was our last hope. */
RIP( pHAL, "CreateSurface (RENDER) ->", ErrorStringD3D(rc) );
return FALSE;
}
else
{
DPF(( DBG_CNTX_INFO, "SW RENDER surface" ));
/* Create a clipper object so that DDraw will be able to blt windows that */
/* have been clipped by the screen or other windows. */
pHAL->lpDD4->CreateClipper( 0, &pHAL->lpClipper, NULL );
pHAL->lpClipper->SetHWnd( 0, pShared->hwnd );
pHAL->lpDDSPrimary->SetClipper( pHAL->lpClipper );
pHAL->lpClipper->Release();
}
}
/*===================================*/
/* Create D3DDEVICE -> SOFTWARE. */
/*===================================*/
if ( pHAL->lpDDSPrimary && pHAL->lpDDSRender )
{
DX_RESTORE( pHAL->lpDDSRender );
rc = pHAL->lpD3D3->CreateDevice( IID_IDirect3DRGBDevice, pHAL->lpDDSRender, &pHAL->lpD3DDevice, NULL );
if ( rc != D3D_OK )
{
/* That was our last hope. */
RIP( pHAL, "CreateDevice (IID_IDirect3DRGBDevice) ->", ErrorStringD3D(rc) );
return FALSE;
}
DPF(( DBG_CNTX_INFO, "SW Device" ));
}
}
/*==============================================================================*/
/* Get a copy of the render pixelformat so that wgl.c can call GetPixelInfoD3D. */
/*==============================================================================*/
memset( &pHAL->ddpf, 0, sizeof(DDPIXELFORMAT) );
pHAL->ddpf.dwSize = sizeof( DDPIXELFORMAT );
rc = pHAL->lpDDSRender->GetPixelFormat( &pHAL->ddpf );
if ( FAILED(rc) )
{
RIP( pHAL, "GetPixelFormat ->", ErrorStringD3D(rc) );
return FALSE;
}
DebugPixelFormat( "Using OFFSCREEN", &pHAL->ddpf );
DebugPixelFormat( "Using ZBUFFER", &ddsd2.ddpfPixelFormat );
/* Get a copy of what the D3DDevice supports for later use. */
memset( &D3DSWDevDesc, 0, sizeof(D3DDEVICEDESC) );
memset( &pHAL->D3DHWDevDesc, 0, sizeof(D3DDEVICEDESC) );
D3DSWDevDesc.dwSize = sizeof( D3DDEVICEDESC );
pHAL->D3DHWDevDesc.dwSize = sizeof( D3DDEVICEDESC );
rc = pHAL->lpD3DDevice->GetCaps( &pHAL->D3DHWDevDesc, &D3DSWDevDesc );
if ( FAILED(rc) )
{
RIP( pHAL, "GetCaps ->", ErrorStringD3D(rc) );
return FALSE;
}
/* Get a copy of the pixel convertion stuff for direct buffer access. */
Solve8BitChannelPixelFormat( &pHAL->ddpf, &pShared->pixel );
AlphaBlendTableHAL( pHAL );
/* We must prime the Begin/End scene for SwapBuffers to work. */
rc = pHAL->lpD3DDevice->BeginScene();
if ( FAILED(rc) )
{
RIP( pHAL, "BeginScene ->", ErrorStringD3D(rc) );
return FALSE;
}
#undef InitDDSD2
return TRUE;
}
/*===========================================================================*/
/* This function will make sure a viewport is created and set for the device*/
/* in the supplied structure. If a rect is supplied then it will be used for*/
/* the viewport otherwise the current setting in the strucute will be used. */
/* Note that the rect is relative to the window. So left/top must be 0,0 to */
/* use the whole window else there is scissoring going down. */
/*===========================================================================*/
/* RETURN: TRUE, FALSE. */
/*===========================================================================*/
extern "C" BOOL SetViewportHAL( PMESAD3DSHARED pShared, RECT *pRect, float minZ, float maxZ )
{
PMESAD3DHAL pHAL = (PMESAD3DHAL)pShared;
D3DVIEWPORT2 vdData;
ULONG rc;
POINT pt;
DPF(( DBG_FUNC, "SetViewportHAL();" ));
/* Make sure we have enough info. */
if ( !pHAL || !pHAL->lpDDSPrimary || !pHAL->lpD3DDevice )
{
DPF(( DBG_CNTX_WARN, "SetViewport() -> NULL Pointer" ));
return FALSE;
}
/* TODO: this is just a temp fix to stop redundant changes. */
if ( pRect &&
(pShared->rectV.left == pRect->left) &&
(pShared->rectV.right == pRect->right) &&
(pShared->rectV.top == pRect->top) &&
(pShared->rectV.bottom == pRect->bottom) )
{
DPF(( DBG_CNTX_WARN, "Redundant viewport" ));
return TRUE;
}
DPF(( DBG_CNTX_INFO, "Current Viewport:" ));
DPF(( DBG_CNTX_INFO, "x: %d y: %d", pShared->rectV.left, pShared->rectV.top ));
DPF(( DBG_CNTX_INFO, "cx: %d cy: %d", (pShared->rectV.right-pShared->rectV.left), (pShared->rectV.bottom-pShared->rectV.top) ));
DPF(( DBG_CNTX_INFO, "New Viewport:" ));
DPF(( DBG_CNTX_INFO, "x: %d y: %d", pRect->left, pRect->top ));
DPF(( DBG_CNTX_INFO, "cx: %d cy: %d", (pRect->right-pRect->left), (pRect->bottom-pRect->top) ));
/* Update the current viewport rect if one is supplied. */
if ( pRect )
memcpy( &pShared->rectV, pRect, sizeof(RECT) );
/* Build the request structure. */
memset( &vdData, 0, sizeof(D3DVIEWPORT2) );
vdData.dwSize = sizeof(D3DVIEWPORT2);
vdData.dwX = pShared->rectV.left;
vdData.dwY = pShared->rectV.top;
vdData.dwWidth = (pShared->rectV.right - pShared->rectV.left);
vdData.dwHeight = (pShared->rectV.bottom - pShared->rectV.top);
if ( !vdData.dwWidth || !vdData.dwHeight )
{
GetClientRect( pShared->hwnd, &pShared->rectW );
pt.x = pt.y = 0;
ClientToScreen( pShared->hwnd, &pt );
OffsetRect( &pShared->rectW, pt.x, pt.y);
vdData.dwX = pShared->rectW.left;
vdData.dwY = pShared->rectW.top;
vdData.dwWidth = (pShared->rectW.right - pShared->rectW.left);
vdData.dwHeight = (pShared->rectW.bottom - pShared->rectW.top);
memcpy( &pShared->rectV, &pShared->rectW, sizeof(RECT) );
}
// The dvClipX, dvClipY, dvClipWidth, dvClipHeight, dvMinZ,
// and dvMaxZ members define the non-normalized post-perspective
// 3-D view volume which is visible to the viewer. In most cases,
// dvClipX is set to -1.0 and dvClipY is set to the inverse of
// the viewport's aspect ratio on the target surface, which can be
// calculated by dividing the dwHeight member by dwWidth. Similarly,
// the dvClipWidth member is typically 2.0 and dvClipHeight is set
// to twice the aspect ratio set in dwClipY. The dvMinZ and dvMaxZ
// are usually set to 0.0 and 1.0.
vdData.dvClipX = -1.0f;
vdData.dvClipWidth = 2.0f;
vdData.dvClipY = 1.0f;
vdData.dvClipHeight = 2.0f;
vdData.dvMaxZ = maxZ;
vdData.dvMinZ = minZ;
DPF(( DBG_CNTX_INFO, "zMin: %f zMax: %f", minZ, maxZ ));
/* I'm going to destroy the viewport everytime as when we size we will */
/* have a new D3DDevice. As this area doesn't need to be fast... */
if ( pHAL->lpViewport )
{
DPF(( DBG_CNTX_INFO, "DeleteViewport" ));
pHAL->lpD3DDevice->DeleteViewport( pHAL->lpViewport );
rc = pHAL->lpViewport->Release();
pHAL->lpViewport = NULL;
}
rc = pHAL->lpD3D3->CreateViewport( &pHAL->lpViewport, NULL );
if ( rc != D3D_OK )
{
DPF(( DBG_CNTX_ERROR, "CreateViewport Failed" ));
return FALSE;
}
/* Update the device with the new viewport. */
pHAL->lpD3DDevice->AddViewport( pHAL->lpViewport );
pHAL->lpViewport->SetViewport2( &vdData );
pHAL->lpD3DDevice->SetCurrentViewport( pHAL->lpViewport );
return TRUE;
}
/*===========================================================================*/
/* */
/* */
/*===========================================================================*/
/* RETURN: */
/*===========================================================================*/
HRESULT WINAPI EnumSurfacesHook( LPDIRECTDRAWSURFACE4 lpDDS, LPDDSURFACEDESC2 lpDDSDesc, LPVOID pVoid )
{
DDSURFACEDESC2 *pddsd2 = (DDSURFACEDESC2 *)pVoid;
DPF(( DBG_FUNC, "EnumSurfacesHook();" ));
if ( (lpDDSDesc->ddpfPixelFormat.dwFlags == pddsd2->ddpfPixelFormat.dwFlags) && (lpDDSDesc->ddsCaps.dwCaps == pddsd2->ddsCaps.dwCaps) )
{
/* Save the pixelformat now so that we know we have one. */
memcpy( pddsd2, lpDDSDesc, sizeof(DDSURFACEDESC2) );
return D3DENUMRET_CANCEL;
}
return D3DENUMRET_OK;
}
/*===========================================================================*/
/* This is the callback proc to get a Z-Buffer. Thats it. */
/*===========================================================================*/
/* RETURN: */
/*===========================================================================*/
HRESULT CALLBACK EnumZBufferHook( DDPIXELFORMAT* pddpf, VOID *pVoid )
{
DDPIXELFORMAT *pddpfChoice = (DDPIXELFORMAT *)pVoid;
DPF(( DBG_FUNC, "EnumZBufferHook();" ));
/* If this is ANY type of depth-buffer, stop. */
if( pddpf->dwFlags == DDPF_ZBUFFER )
{
/* Save the pixelformat now so that we know we have one. */
memcpy( pddpfChoice, pddpf, sizeof(DDPIXELFORMAT) );
/* I feel if the hardware supports this low then lets use it. Could get ugly. */
if( pddpf->dwZBufferBitDepth >= 8 )
{
return D3DENUMRET_CANCEL;
}
}
return D3DENUMRET_OK;
}
/*===========================================================================*/
/* This function handles the callback for the D3DDevice enumeration. Good */
/* god who's idea was this? The D3D wrapper has two variable related to what*/
/* kind of device we want and have. First we have a Bool that is set if we */
/* have allocated a HW device. We always look for the HW device first. The */
/* other variable is used to force SW. If we have run into a case that we */
/* want to fallback to SW then we set this. We will fallback if we cannot */
/* texture in video memory (among others). */
/*===========================================================================*/
/* RETURN: */
/*===========================================================================*/
HRESULT CALLBACK EnumDeviceHook( GUID FAR* lpGuid, LPSTR lpDesc, LPSTR lpName, LPD3DDEVICEDESC lpD3DHWDesc, LPD3DDEVICEDESC lpD3DHELDesc, void *pVoid )
{
PMESAD3DHAL pHAL = (PMESAD3DHAL)pVoid;
LPD3DDEVICEDESC pChoice = lpD3DHWDesc;
DPF(( DBG_FUNC, "EnumDeviceHook();" ));
/* Determine if which device description is valid. */
if ( pChoice->dcmColorModel == 0 )
pChoice = lpD3DHELDesc;
/* Make sure we always have a GUID. */
memcpy( &pHAL->guid, lpGuid, sizeof(GUID) );
/* This controls whether we will except HW or not. */
if ( pHAL->shared.bForceSW == TRUE )
{
return (pChoice == lpD3DHELDesc) ? D3DENUMRET_CANCEL : D3DENUMRET_OK;
}
/* Always try for hardware. */
if ( pChoice == lpD3DHWDesc )
{
return D3DENUMRET_CANCEL;
}
return D3DENUMRET_OK;
}
/*===========================================================================*/
/* This function will destroy any and all surfaces that this context has */
/* allocated. If there is a clipper object then it will also be destoryed as*/
/* it is part of the Primary Surface. */
/*===========================================================================*/
/* RETURN: */
/*===========================================================================*/
static void DestroyAllSurfaces( PMESAD3DHAL pHAL )
{
LONG refCount;
DPF(( DBG_FUNC, "DestroyAllSurfaces();" ));
DX_RESTORE( pHAL->lpDDSPrimary );
DX_RESTORE( pHAL->lpDDSRender );
DX_RESTORE( pHAL->lpDDSZbuffer);
if ( pHAL->lpDDSRender )
{
pHAL->lpDDSRender->Unlock( NULL );
/* If this isn't a Flipable surface then we must clean up the render. */
if ( pHAL->shared.bFlipable == FALSE)
{
if ( pHAL->lpDDSZbuffer )
{
DPF(( DBG_CNTX_INFO, "Remove attached surfaces from RENDER" ));
pHAL->lpDDSRender->DeleteAttachedSurface( 0, NULL );
}
DPF(( DBG_CNTX_INFO, "Release RENDER" ));
refCount = pHAL->lpDDSRender->Release();
pHAL->lpDDSRender = NULL;
}
}
if ( pHAL->lpDDSZbuffer )
{
DPF(( DBG_CNTX_INFO, "Release ZBuffer" ));
pHAL->lpDDSZbuffer->Unlock( NULL );
refCount = pHAL->lpDDSZbuffer->Release();
pHAL->lpDDSZbuffer = NULL;
}
if ( pHAL->lpClipper )
{
DPF(( DBG_CNTX_INFO, "Release Clipper" ));
refCount = pHAL->lpClipper->Release();
pHAL->lpClipper = NULL;
}
if ( pHAL->lpDDSPrimary )
{
pHAL->lpDDSPrimary->Unlock( NULL );
DPF(( DBG_CNTX_INFO, "Release PRIMARY" ));
refCount = pHAL->lpDDSPrimary->Release();
pHAL->lpDDSPrimary = NULL;
}
}
/*===========================================================================*/
/* This function will destroy the current D3DDevice and any resources that */
/* belong to it. */
/*===========================================================================*/
/* RETURN: */
/*===========================================================================*/
static void DestroyDevice( PMESAD3DHAL pHAL )
{
LONG refCount;
DPF(( DBG_FUNC, "DestroyDevice();" ));
/* Kill the D3D stuff if exists. */
if ( pHAL->lpViewport )
{
DPF(( DBG_CNTX_INFO, "Delete Viewport" ));
pHAL->lpD3DDevice->DeleteViewport( pHAL->lpViewport );
DPF(( DBG_CNTX_INFO, "Release Viewport" ));
refCount = pHAL->lpViewport->Release();
pHAL->lpViewport = NULL;
}
if ( pHAL->lpD3DDevice != NULL )
{
DPF(( DBG_CNTX_INFO, "Release D3DDevice" ));
refCount = pHAL->lpD3DDevice->EndScene();
refCount = pHAL->lpD3DDevice->Release();
pHAL->lpD3DDevice = NULL;
}
}
/*===========================================================================*/
/* This function will destroy the current D3DDevice and any resources that */
/* belong to it. */
/*===========================================================================*/
/* RETURN: */
/*===========================================================================*/
static void DestroyInterfaces( PMESAD3DHAL pHAL )
{
LONG refCount;
DPF(( DBG_FUNC, "DestroyInterfaces();" ));
if ( pHAL->lpD3D3 != NULL )
{
DPF(( DBG_CNTX_INFO, "Release Direct3D3" ));
refCount = pHAL->lpD3D3->Release();
pHAL->lpD3D3 = NULL;
}
if ( pHAL->lpDD4 != NULL )
{
DPF(( DBG_CNTX_INFO, "Release DDraw4" ));
refCount = pHAL->lpDD4->Release();
pHAL->lpDD4 = NULL;
}
if ( pHAL->lpDD != NULL )
{
DPF(( DBG_CNTX_INFO, "Release DDraw" ));
refCount = pHAL->lpDD->Release();
pHAL->lpDD = NULL;
}
}
/*===========================================================================*/
/* This function will first send (not post) a message to the client window */
/* that this context is using. The client will respond by unbinding itself */
/* and binding the 'default' context. This allows the API to be supported */
/* until the window can be destroyed. Finally we post the quit message to */
/* the client in hopes to end the application. */
/*===========================================================================*/
/* RETURN: */
/*===========================================================================*/
void FatalShutDown( PMESAD3DHAL pHAL )
{
/* Whip this baby in too try and support the API until we die... */
if ( pHAL )
SendMessage( pHAL->shared.hwnd, UM_FATALSHUTDOWN, 0L, 0L );
/* Close the client application down. */
PostQuitMessage( 0 );
}

View File

@ -1,84 +0,0 @@
/*===========================================================================*/
/* */
/* Mesa-3.0 DirectX 6 Driver */
/* */
/* By Leigh McRae */
/* */
/* http://www.altsoftware.com/ */
/* */
/* Copyright (c) 1999-1998 alt.software inc. All Rights Reserved */
/*===========================================================================*/
#ifndef D3D_MESA_H
#define D3D_MESA_H
/*===========================================================================*/
/* Includes. */
/*===========================================================================*/
#include <windows.h>
#include <ddraw.h>
#include <d3d.h>
#include "matrix.h"
#include "context.h"
#include "mtypes.h"
#include "vb.h"
#include "D3DShared.h"
#include "Debug.h"
#include "NULLProcs.h"
/*===========================================================================*/
/* Macros. */
/*===========================================================================*/
#define FLIP(h,y) (h-y)
/*===========================================================================*/
/* Magic numbers. */
/*===========================================================================*/
/*===========================================================================*/
/* Type defines. */
/*===========================================================================*/
struct __extensions__
{
PROC proc;
char *name;
};
typedef GLbitfield (*ClearPROC)( GLcontext *ctx, GLbitfield mask, GLboolean all, GLint x, GLint y, GLint width, GLint height );
typedef void (*WSpanRGBPROC)( const GLcontext* ctx, GLuint n, GLint x, GLint y, const GLubyte rgb[][3], const GLubyte mask[] );
typedef void (*WSpanRGBAPROC)( const GLcontext* ctx, GLuint n, GLint x, GLint y, const GLubyte rgba[][4], const GLubyte mask[] );
typedef void (*WSpanRGBAMonoPROC)( const GLcontext* ctx, GLuint n, GLint x, GLint y, const GLubyte mask[] );
typedef void (*WPixelsRGBAPROC)( const GLcontext* ctx, GLuint n, const GLint x[], const GLint y[], const GLubyte rgba[][4], const GLubyte mask[] );
typedef void (*WPixelsRGBAMonoPROC)( const GLcontext* ctx, GLuint n, const GLint x[], const GLint y[], const GLubyte mask[] );
typedef void (*RSpanRGBAPROC)( const GLcontext* ctx, GLuint n, GLint x, GLint y, GLubyte rgba[][4] );
typedef void (*RPixelsRGBAPROC)( const GLcontext* ctx, GLuint n, const GLint x[], const GLint y[], GLubyte rgba[][4], const GLubyte mask[] );
typedef struct D3D_mesa_context
{
PMESAD3DSHARED pShared;
GLcontext *gl_ctx; /* The core GL/Mesa context */
GLvisual *gl_visual; /* Describes the buffers */
GLframebuffer *gl_buffer; /* Depth, stencil, accum, etc buffers */
HDC hdc;
WNDPROC hOldProc;
UCHAR rClear, /* Current clear colors. */
gClear,
bClear,
aClear,
rCurrent, /* Current rendering colors. */
gCurrent,
bCurrent,
aCurrent;
struct D3D_mesa_context *next;
} D3DMESACONTEXT, *PD3DMESACONTEXT;
/*===========================================================================*/
/* Extern function prototypes. */
/*===========================================================================*/
extern void gl_Viewport( GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height );
/*===========================================================================*/
/* Global variables. */
/*===========================================================================*/
extern D3DTLVERTEX D3DTLVertices[(VB_MAX*6)];
#endif

View File

@ -1,213 +0,0 @@
/*===========================================================================*/
/* */
/* Mesa-3.0 DirectX 6 Driver */
/* */
/* By Leigh McRae */
/* */
/* http://www.altsoftware.com/ */
/* */
/* Copyright (c) 1999-1998 alt.software inc. All Rights Reserved */
/*===========================================================================*/
#include "D3DHAL.h"
/*===========================================================================*/
/* This function clears the context bound to the supplied shared context. */
/* The function takes the D3D flags D3DCLEAR_TARGET, D3DCLEAR_STENCIL and */
/* D3DCLEAR_ZBUFFER. Set bAll to TRUE for a full clear else supply the coord*/
/* of the rect to be cleared relative to the window. The color is always a */
/* 32bit value (RGBA). Fill in the z-value and stencil if needed. */
/* */
/* TODO: this can be redone to be called by Mesa directly. */
/*===========================================================================*/
/* RETURN: */
/*===========================================================================*/
extern "C" void ClearHAL( PMESAD3DSHARED pShared, DWORD dwFlags, BOOL bAll, int x, int y, int cx, int cy, DWORD dwColor, float zv, DWORD dwStencil )
{
PMESAD3DHAL pHAL = (PMESAD3DHAL)pShared;
D3DRECT d3dRect;
#ifdef D3D_DEBUG
HRESULT rc;
DPF(( DBG_FUNC, "CleaHAL();" ));
/* Make sure we have enough info. */
if ( (pHAL == NULL) || (pHAL->lpViewport == NULL) )
return;
#endif
if ( bAll )
{
/* I assume my viewport is valid. */
d3dRect.lX1 = pShared->rectV.left;
d3dRect.lY1 = pShared->rectV.top;
d3dRect.lX2 = pShared->rectV.right;
d3dRect.lY2 = pShared->rectV.bottom;
}
else
{
d3dRect.lX1 = pShared->rectV.left + x;
d3dRect.lY1 = pShared->rectV.top + y;
d3dRect.lX2 = d3dRect.lX1 + cx;
d3dRect.lY2 = d3dRect.lY1 + cy;
}
#ifdef D3D_DEBUG
rc = pHAL->lpViewport->Clear2( 1, &d3dRect, dwFlags, dwColor, zv, dwStencil );
if ( FAILED(rc) )
{
RIP( pHAL, "Clear2 ->", ErrorStringD3D(rc) );
}
#else
pHAL->lpViewport->Clear2( 1, &d3dRect, dwFlags, dwColor, zv, dwStencil );
#endif
}
/*===========================================================================*/
/* Well this is the guts of it all. Here we rasterize the primitives that */
/* are in their final form. OpenGL has done all the lighting, transfomations*/
/* and clipping at this point. */
/* */
/* TODO: I'm not sure if I want to bother to check for errors on this call. */
/* The overhead kills me... */
/*===========================================================================*/
/* RETURN: */
/*===========================================================================*/
extern "C" void DrawPrimitiveHAL( PMESAD3DSHARED pShared, D3DPRIMITIVETYPE dptPrimitiveType, D3DTLVERTEX *pVertices, DWORD dwCount )
{
PMESAD3DHAL pHAL = (PMESAD3DHAL)pShared;
#ifdef D3D_DEBUG
HRESULT rc;
DPF(( DBG_FUNC, "DrawPrimitveHAL();" ));
/* Make sure we have enough info. */
if ( (pHAL == NULL) || (pHAL->lpD3DDevice == NULL) )
return;
DPF(( DBG_PRIM_INFO, "DP( %d )", dwCount ));
rc = pHAL->lpD3DDevice->DrawPrimitive( dptPrimitiveType,
D3DFVF_TLVERTEX,
(LPVOID)pVertices,
dwCount,
(D3DDP_DONOTCLIP | D3DDP_DONOTLIGHT) );
if ( FAILED(rc) )
{
RIP( pHAL, "DrawPrimitive ->", ErrorStringD3D(rc) );
}
#else
pHAL->lpD3DDevice->DrawPrimitive( dptPrimitiveType,
D3DFVF_TLVERTEX,
(LPVOID)pVertices,
dwCount,
(D3DDP_DONOTCLIP | D3DDP_DONOTLIGHT) );
#endif
}
/*===========================================================================*/
/* This call will handle the swapping of the buffers. Now I didn't bother */
/* to support single buffered so this will be used for glFlush() as its all */
/* the same. So first we do an EndScene as we are always considered to be in*/
/* a BeginScene because when we leave we do a BeginScene. Now note that when*/
/* the context is created in the first place we do a BeginScene also just to */
/* get things going. The call will use either Flip/blt based on the type of */
/* surface was created for rendering. */
/*===========================================================================*/
/* RETURN: */
/*===========================================================================*/
extern "C" void SwapBuffersHAL( PMESAD3DSHARED pShared )
{
PMESAD3DHAL pHAL = (PMESAD3DHAL)pShared;
#ifdef D3D_DEBUG
HRESULT rc;
DPF(( DBG_FUNC, "SwapBuffersHAL();" ));
DPF(( DBG_ALL_PROFILE, "=================SWAP===================" ));
/* Make sure we have enough info. */
if ( (pHAL == NULL) || (pHAL->lpD3DDevice == NULL) )
return;
/* Make sure we have enough info. */
if ( pHAL->lpDDSPrimary != NULL )
{
rc = pHAL->lpD3DDevice->EndScene();
if ( FAILED(rc) )
{
RIP( pHAL, "EndScene ->", ErrorStringD3D(rc) );
}
if ( pShared->bFlipable )
{
DPF(( DBG_CNTX_PROFILE, "Swap->FLIP" ));
rc = pHAL->lpDDSPrimary->Flip( NULL, DDFLIP_WAIT );
}
else
{
DPF(( DBG_CNTX_PROFILE, "Swap->Blt" ));
rc = pHAL->lpDDSPrimary->Blt( &pShared->rectW, pHAL->lpDDSRender, NULL, DDBLT_WAIT, NULL );
}
if ( FAILED(rc) )
{
RIP( pHAL, "Blt (RENDER/PRIMARY) ->", ErrorStringD3D(rc) );
}
rc = pHAL->lpD3DDevice->BeginScene();
if ( FAILED(rc) )
{
RIP( pHAL, "BeginScene ->", ErrorStringD3D(rc) );
}
}
#else
pHAL->lpD3DDevice->EndScene();
if ( pShared->bFlipable )
pHAL->lpDDSPrimary->Flip( NULL, DDFLIP_WAIT );
else
pHAL->lpDDSPrimary->Blt( &pShared->rectW, pHAL->lpDDSRender, NULL, DDBLT_WAIT, NULL );
pHAL->lpD3DDevice->BeginScene();
#endif
}
/*===========================================================================*/
/* This function is a very thin wrapper for the D3D call 'SetRenderState'. */
/* Using this function requires all the types to be defined by including the */
/* D3D header file. */
/* */
/* TODO: would be much better to get ride of all these calls per VBRender. */
/* I feel I should get this call into SetRenderStates() the RenderVB. */
/*===========================================================================*/
/* RETURN: */
/*===========================================================================*/
extern "C" void SetStateHAL( PMESAD3DSHARED pShared, DWORD dwType, DWORD dwState )
{
PMESAD3DHAL pHAL = (PMESAD3DHAL)pShared;
#ifdef D3D_DEBUG
HRESULT rc;
DPF(( DBG_FUNC, "SetStateHAL();" ));
/* Make sure we have enough info. */
if ( (pHAL == NULL) || (pHAL->lpD3DDevice == NULL) )
return;
rc = pHAL->lpD3DDevice->SetRenderState( (D3DRENDERSTATETYPE)dwType, dwState );
if ( FAILED(rc) )
{
RIP( pHAL, "SetRenderState ->", ErrorStringD3D(rc) );
}
#else
pHAL->lpD3DDevice->SetRenderState( (D3DRENDERSTATETYPE)dwType, dwState );
#endif
}

View File

@ -1,154 +0,0 @@
/*===========================================================================*/
/* */
/* Mesa-3.0 DirectX 6 Driver */
/* */
/* By Leigh McRae */
/* */
/* http://www.altsoftware.com/ */
/* */
/* Copyright (c) 1999-1998 alt.software inc. All Rights Reserved */
/*===========================================================================*/
#ifndef D3D_MESA_ALL_H
#define D3D_MESA_ALL_H
#ifdef __cplusplus
extern "C" {
#endif
/*===========================================================================*/
/* Includes. */
/*===========================================================================*/
#include <stdio.h>
#include <string.h>
/*===========================================================================*/
/* Magic numbers. */
/*===========================================================================*/
#define TM_ACTION_LOAD 0x01
#define TM_ACTION_BIND 0x02
#define TM_ACTION_UPDATE 0x04
#define UM_FATALSHUTDOWN (WM_USER+42)
/*===========================================================================*/
/* Macros defines. */
/*===========================================================================*/
#define ALLOC(cb) malloc( (cb) )
#define FREE(p) { free( (p) ); (p) = NULL; }
/*===========================================================================*/
/* Type defines. */
/*===========================================================================*/
typedef struct _pixel_convert
{
int cb, /* Count in bytes of one pixel. */
rShift, /* Shift count that postions each componet. */
gShift,
bShift,
aShift;
float rScale, /* Value that scales a color that ranges 0.0 -> 1.0 */
gScale, /* to this pixel format. */
bScale,
aScale;
DWORD dwRMask, /* Color mask per component. */
dwGMask,
dwBMask,
dwAMask;
} PIXELINFO, *PPIXELINFO;
typedef struct _d3d_shared_info
{
HWND hwnd;
BOOL bWindow,
bFlipable,
bForceSW,
bHardware;
RECT rectW, /* Window size and postion in screen space. */
rectV; /* Viewport size and postion. */
DWORD dwWidth, /* Current render size for quick checks. */
dwHeight;
PIXELINFO pixel;
DWORD dwSrcBlendCaps[14], /* See D3DCAPS.CPP */
dwDestBlendCaps[14],
dwTexFunc[4];
} MESAD3DSHARED, *PMESAD3DSHARED;
typedef struct _render_options
{
BOOL bForceSoftware, /* TODO: Add user switches. */
bStretchtoPrimary;
} USER_CTRL, *PUSER_CRTL;
enum { s_zero = 0,
s_one,
s_dst_color,
s_one_minus_dst_color,
s_src_alpha,
s_one_minus_src_alpha,
s_dst_alpha,
s_one_minus_dst_alpha,
s_src_alpha_saturate,
s_constant_color,
s_one_minus_constant_color,
s_constant_alpha,
s_one_minus_constant_alpha };
enum { d_zero = 0,
d_one,
d_src_color,
d_one_minus_src_color,
d_src_alpha,
d_one_minus_src_alpha,
d_dst_alpha,
d_one_minus_dst_alpha,
d_constant_color,
d_one_minus_constant_color,
d_constant_alpha,
d_one_minus_constant_alpha };
enum { d3dtblend_decal = 0,
d3dtblend_decalalpha,
d3dtblend_modulate,
d3dtblend_modulatealpha };
/*===========================================================================*/
/* Function prototypes. */
/*===========================================================================*/
PMESAD3DSHARED InitHAL( HWND hwnd );
void TermHAL( PMESAD3DSHARED pShared );
BOOL CreateHAL( PMESAD3DSHARED pShared );
BOOL SetViewportHAL( PMESAD3DSHARED pShared, RECT *pRect, float minZ, float maxZ );
void ClearHAL( PMESAD3DSHARED pShared, DWORD dwFlags, BOOL bAll, int x, int y, int cx, int cy, DWORD dwColor, float zv, DWORD dwStencil );
void SetStateHAL( PMESAD3DSHARED pShared, DWORD dwType, DWORD dwState );
void DrawPrimitiveHAL( PMESAD3DSHARED pShared, D3DPRIMITIVETYPE dptPrimitiveType, D3DTLVERTEX *pVertices, DWORD dwCount );
void SwapBuffersHAL( PMESAD3DSHARED pShared );
DDSURFACEDESC2 *LockHAL( PMESAD3DSHARED pShared, BOOL bBack );
void UnlockHAL( PMESAD3DSHARED pShared, BOOL bBack );
void UpdateScreenPosHAL( PMESAD3DSHARED pShared );
void GetPixelInfoHAL( PMESAD3DSHARED pShared, PPIXELINFO pPixel );
BOOL CreateTMgrHAL( PMESAD3DSHARED pShared, DWORD dwName, int level, DWORD dwRequestFlags, RECT *rectDirty, DWORD dwWidth, DWORD dwHeight, DWORD dwAction, void *pPixels );
void DisableTMgrHAL( PMESAD3DSHARED pShared );
int SaveDIBitmap( char *filename, BITMAPINFO *info, void *bits );
int ARGB_SaveBitmap( char *filename, int width, int height, unsigned char *pARGB );
int BGRA_SaveBitmap( char *filename, int width, int height, unsigned char *pBGRA );
int BGR_SaveBitmap( char *filename, int width, int height, unsigned char *pBGR );
/*===========================================================================*/
/* Global variables. */
/*===========================================================================*/
extern float g_DepthScale, /* Mesa needs to scale Z in SW. The HAL */
g_MaxDepth; /* doesn't but I wanted SW still to work.*/
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,576 +0,0 @@
/*===========================================================================*/
/* */
/* Mesa-3.0 DirectX 6 Driver */
/* */
/* By Leigh McRae */
/* */
/* http://www.altsoftware.com/ */
/* */
/* Copyright (c) 1999-1998 alt.software inc. All Rights Reserved */
/*===========================================================================*/
#include "d3dText.h"
/*=============================================================================
1
------
| |
6 | | 2
| 7 |
------
| |
5 | | 3
| |
------
4
TL_0 TR_0
TLL TL_1 TR_1 TRR
MLL_0 ML_0 MR_0 MRR_0
MLL_1 ML_1 MR_1 MRR_1
BLL BL_0 BR_0 BRR
BL_1 BR_1
=============================================================================*/
#define TLL 0
#define TRR 1
#define TL_0 2
#define TL_1 3
#define TR_0 4
#define TR_1 5
#define MLL_0 6
#define MLL_1 7
#define MRR_0 8
#define MRR_1 9
#define ML_0 10
#define ML_1 11
#define MR_0 12
#define MR_1 13
#define BL_0 14
#define BL_1 15
#define BR_0 16
#define BR_1 17
#define BLL 18
#define BRR 19
#define BIT1 0x00000001
#define BIT2 0x00000002
#define BIT3 0x00000004
#define BIT4 0x00000008
#define BIT5 0x00000010
#define BIT6 0x00000020
#define BIT7 0x00000040
#define TOP BIT4
#define MIDDLE BIT7
#define BOTTOM BIT1
#define TLEFT BIT5
#define BLEFT BIT6
#define LEFT (TLEFT|BLEFT)
#define TRIGHT BIT3
#define BRIGHT BIT2
#define RIGHT (TRIGHT|BRIGHT)
#define ALL 0xFFFFFFFF
/*===========================================================================*/
/* This is the static array that will map the ASCII value of the character */
/* being draw to the bit mask that will be scan converted to the LED display.*/
/*===========================================================================*/
DWORD textBitMasks[] =
{
0xFFFFFFFF, // 000
0xFFFFFFFF, // 001
0xFFFFFFFF, // 002
0xFFFFFFFF, // 003
0xFFFFFFFF, // 004
0xFFFFFFFF, // 005
0xFFFFFFFF, // 006
0xFFFFFFFF, // 007
0xFFFFFFFF, // 008
0xFFFFFFFF, // 009
0xFFFFFFFF, // 010
0xFFFFFFFF, // 011
0xFFFFFFFF, // 012
0xFFFFFFFF, // 013
0xFFFFFFFF, // 014
0xFFFFFFFF, // 015
0xFFFFFFFF, // 016
0xFFFFFFFF, // 017
0xFFFFFFFF, // 018
0xFFFFFFFF, // 019
0xFFFFFFFF, // 020
0xFFFFFFFF, // 021
0xFFFFFFFF, // 022
0xFFFFFFFF, // 023
0xFFFFFFFF, // 024
0xFFFFFFFF, // 025
0xFFFFFFFF, // 026
0xFFFFFFFF, // 027
0xFFFFFFFF, // 028
0xFFFFFFFF, // 029
0xFFFFFFFF, // 030
0XFFFFFFFF, // 031
0x00000000, // 032 'SPC'
0xFFFFFFFF, // 033
0xFFFFFFFF, // 034
0xFFFFFFFF, // 035
0xFFFFFFFF, // 036
0xFFFFFFFF, // 037
0xFFFFFFFF, // 038
0xFFFFFFFF, // 039
0xFFFFFFFF, // 040
0xFFFFFFFF, // 041
0xFFFFFFFF, // 042
0xFFFFFFFF, // 043
0xFFFFFFFF, // 044
0xFFFFFFFF, // 045
0xFFFFFFFF, // 046
0xFFFFFFFF, // 047
(ALL &~ MIDDLE), // 048 '0'
(RIGHT), // 049 '1'
(ALL &~ TLEFT &~ BRIGHT), // 050 '2'
(ALL &~ LEFT), // 051 '3'
(TLEFT | MIDDLE | RIGHT), // 052 '4'
(ALL &~ TRIGHT &~ BLEFT), // 053 '5'
(ALL &~ TRIGHT), // 054 '6'
(TOP | RIGHT), // 055 '7'
(ALL), // 056 '8'
(ALL &~ BOTTOM &~ BLEFT), // 057 '9'
0xFFFFFFFF, // 058
0xFFFFFFFF, // 059
0xFFFFFFFF, // 060
0XFFFFFFFF, // 061
0xFFFFFFFF, // 062
0xFFFFFFFF, // 063
0xFFFFFFFF, // 064
(ALL &~ BOTTOM), // 065 'A'
(ALL), // 066 'B'
(TOP | LEFT | BOTTOM), // 067 'C'
(ALL &~ MIDDLE), // 068 'D'
(ALL &~ RIGHT), // 069 'E'
(LEFT | TOP | MIDDLE), // 070 'F'
0x00000000, // 071 'G'
(ALL &~ TOP &~ BOTTOM), // 072 'H'
(RIGHT), // 073 'I'
(RIGHT | BOTTOM), // 074 'J'
0x00000000, // 075 'K'
(LEFT | BOTTOM), // 076 'L'
0x00000000, // 088 'M'
0x00000000, // 089 'N'
(ALL &~ MIDDLE), // 090 'O'
(ALL &~ BRIGHT &~ BOTTOM),// 091 'P'
0x00000000, // 092 'Q'
0x00000000, // 093 'R'
(ALL &~ TRIGHT &~ BLEFT), // 094 'S'
0X00000000, // 095 'T'
(LEFT | RIGHT | BOTTOM), // 096 'U'
0x00000000, // 097 'V'
0x00000000, // 098 'W'
0x00000000, // 099 'X'
0x00000000, // 1000 'Z'
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, // 100
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, // 104
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, // 108
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, // 112
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, // 116
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, // 120
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF // 124
};
#define CT 1.0f
#define CX 7.0f
#define CY 13.0f
#define CM ((CY-(CT*3.0f))/2.0f)
float lCoords[][2] =
{
/* Top outsides. */
{ 0, (CY-CT) },
{ CX, (CY-CT) },
/* Top Line. */
{ CT, CY },
{ CT, (CY-CT) },
{ (CX-CT), CY },
{ (CX-CT), (CY-CT) },
/* Middle outsides. */
{ 0.0f, (CT+CM+CT) },
{ 0.0f, (CT+CM) },
{ CX, (CT+CM+CT) },
{ CX, (CT+CM) },
/* Middle Line. */
{ CT, (CT+CM+CT) },
{ CT, (CT+CM) },
{ (CX-CT), (CT+CM+CT) },
{ (CX-CT), (CT+CM) },
/* Bottom line. */
{ CT, CT },
{ CT, 0.0f },
{ (CX-CT), CT },
{ (CX-CT), 0.0f },
/* Bottom outsides. */
{ 0.0f, CT},
{ CX, CT }
};
static int ConvertCharacter( char *c, int cIndex, PD3DFONTMETRICS pfntMetrics );
D3DTLVERTEX TextVertices[MAX_VERTICES];
/*===========================================================================*/
/* When we attach I will zero out the whole D3D vertex buffer I'm using for */
/* the text. This way I don't need to set all the redundant values. I also */
/* set all the oow values to 1 as I will be doing direct rendering. */
/*===========================================================================*/
/* RETURN: TRUE, FALSE. */
/*===========================================================================*/
extern "C" BOOL InitD3DText( void )
{
int index;
/* Set the D3D Vertex Buffer up once so we don't do redundant changes. */
memset( &TextVertices[0], 0, sizeof(TextVertices) );
for( index = 0; index < MAX_VERTICES; index++ )
TextVertices[index].rhw = D3DVAL( 1.0 );
return TRUE;
}
/*===========================================================================*/
/* This function takes a single character and draw it using the supplied */
/* fontmetrics structure. */
/*===========================================================================*/
/* RETURN: */
/*===========================================================================*/
extern "C" void d3dTextDrawString( char *pszString, int x, int y, PD3DFONTMETRICS pfntMetrics )
{
int cIndex,
nIndex,
index;
float cWidth = CX,
cHeight = CY;
/* Find the max width/height of a character and add the spacing so */
/* that we can use this value to calculate the x,y of the character.*/
cWidth = (cWidth * pfntMetrics->fntXScale) + pfntMetrics->fntXSpacing;
cHeight = (cHeight * pfntMetrics->fntYScale) + pfntMetrics->fntYSpacing;
/* Walk the string. This must be NULL terminated. */
for( cIndex = 0, nIndex = 0; *pszString; pszString++, cIndex = nIndex, x++ )
{
/* Convert the character and get the index into the text vertex buffer. */
nIndex = ConvertCharacter( &pszString[0], cIndex, pfntMetrics );
if ( (nIndex - cIndex) > 2 )
{
/* Modify the text vertex buffer based on the fntMetrics structure. */
for( index = cIndex; index < nIndex; index++ )
{
/* Scale the character. */
TextVertices[index].sx *= pfntMetrics->fntXScale;
TextVertices[index].sy *= pfntMetrics->fntYScale;
/* Move the character. */
TextVertices[index].sx += (cWidth*x);
TextVertices[index].sy += (cHeight*y);
/* Set the color. */
TextVertices[index].color = pfntMetrics->dwColor;
}
}
}
if ( nIndex < 3 )
return;
/* Set the states that slim things down. */
pfntMetrics->lpD3DDevice->SetRenderState( D3DRENDERSTATE_CULLMODE, D3DCULL_NONE );
pfntMetrics->lpD3DDevice->SetRenderState( D3DRENDERSTATE_FILLMODE, D3DFILL_SOLID );
pfntMetrics->lpD3DDevice->SetRenderState( D3DRENDERSTATE_ZENABLE, FALSE );
pfntMetrics->lpD3DDevice->SetRenderState( D3DRENDERSTATE_ZWRITEENABLE , FALSE );
pfntMetrics->lpD3DDevice->SetRenderState( D3DRENDERSTATE_ALPHATESTENABLE, FALSE );
pfntMetrics->lpD3DDevice->SetRenderState( D3DRENDERSTATE_ALPHABLENDENABLE, FALSE );
/* Blast them baby... */
pfntMetrics->lpD3DDevice->DrawPrimitive( D3DPT_TRIANGLELIST,
D3DFVF_TLVERTEX,
(LPVOID)&TextVertices[0],
nIndex,
(D3DDP_DONOTCLIP | D3DDP_DONOTLIGHT) );
}
/*===========================================================================*/
/* This function takes a single character and draw it directly to the screen*/
/* unsing the supplied fntMetrics structure. The character will be drawn at */
/* the supplied x,y. The x,y position is relative to the top left and uses */
/* the spacing in the fntMetrics structure. */
/*===========================================================================*/
/* RETURN: */
/*===========================================================================*/
extern "C" void d3dTextDrawCharacter( char *c, int x, int y, PD3DFONTMETRICS pfntMetrics )
{
int cIndex = 0,
index;
float cWidth = CX,
cHeight = CY;
/* Convert the character and get the index into the text vertex buffer. */
cIndex = ConvertCharacter( c, 0, pfntMetrics );
if ( cIndex < 3 )
return;
/* Find the max width/height of a character and add the spacing so */
/* that we can use this value to calculate the x,y of the character.*/
cWidth = (cWidth * pfntMetrics->fntXScale) + pfntMetrics->fntXSpacing;
cHeight = (cHeight * pfntMetrics->fntYScale) + pfntMetrics->fntYSpacing;
/* Modify the text vertex buffer based on the fntMetrics structure. */
for( index = 0; index < cIndex; index++ )
{
/* Scale the character. */
TextVertices[index].sx *= pfntMetrics->fntXScale;
TextVertices[index].sy *= pfntMetrics->fntYScale;
/* Move the character. */
TextVertices[index].sx += (cWidth*x);
TextVertices[index].sy += (cHeight*y);
/* Set the color. */
TextVertices[index].color = pfntMetrics->dwColor;
}
/* Set the states that slim things down. */
pfntMetrics->lpD3DDevice->SetRenderState( D3DRENDERSTATE_CULLMODE, D3DCULL_NONE );
pfntMetrics->lpD3DDevice->SetRenderState( D3DRENDERSTATE_FILLMODE, D3DFILL_SOLID );
pfntMetrics->lpD3DDevice->SetRenderState( D3DRENDERSTATE_ZENABLE, FALSE );
pfntMetrics->lpD3DDevice->SetRenderState( D3DRENDERSTATE_ZWRITEENABLE , FALSE );
pfntMetrics->lpD3DDevice->SetRenderState( D3DRENDERSTATE_ALPHATESTENABLE, FALSE );
pfntMetrics->lpD3DDevice->SetRenderState( D3DRENDERSTATE_ALPHABLENDENABLE, FALSE );
/* Blast them baby... */
pfntMetrics->lpD3DDevice->DrawPrimitive( D3DPT_TRIANGLELIST,
D3DFVF_TLVERTEX,
(LPVOID)&TextVertices[0],
cIndex,
(D3DDP_DONOTCLIP | D3DDP_DONOTLIGHT) );
}
/*===========================================================================*/
/* This function takes a single character and draw it using the supplied */
/* fontmetrics structure. */
/*===========================================================================*/
/* RETURN: */
/*===========================================================================*/
static int ConvertCharacter( char *c, int cIndex, PD3DFONTMETRICS pfntMetrics )
{
DWORD asciiChar = (int)(*c);
/* Handle the TOP line. */
if ( textBitMasks[asciiChar] & BIT1 )
{
TextVertices[cIndex].sx = D3DVAL( lCoords[TL_0][0] );
TextVertices[cIndex++].sy= D3DVAL( lCoords[TL_0][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[TR_0][0] );
TextVertices[cIndex++].sy= D3DVAL( lCoords[TR_0][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[TR_1][0] );
TextVertices[cIndex++].sy= D3DVAL( lCoords[TR_1][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[TR_1][0] );
TextVertices[cIndex++].sy= D3DVAL( lCoords[TR_1][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[TL_1][0] );
TextVertices[cIndex++].sy= D3DVAL( lCoords[TL_1][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[TL_0][0] );
TextVertices[cIndex++].sy= D3DVAL( lCoords[TL_0][1] );
}
/* Handle the TOP/BOTTOM RIGHT lines. */
// if ( textBitMasks[index] & (BIT2|BIT3) )
if ( 1 == 0 )
{
TextVertices[cIndex].sx = D3DVAL( lCoords[TR_1][0] );
TextVertices[cIndex++].sy= D3DVAL( lCoords[TR_1][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[TRR][0] );
TextVertices[cIndex++].sy= D3DVAL( lCoords[TRR][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[BRR][0] );
TextVertices[cIndex++].sy= D3DVAL( lCoords[BRR][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[BRR][0] );
TextVertices[cIndex++].sy= D3DVAL( lCoords[BRR][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[BR_0][0] );
TextVertices[cIndex++].sy= D3DVAL( lCoords[BR_0][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[TR_1][0] );
TextVertices[cIndex++].sy= D3DVAL( lCoords[TR_1][1] );
}
else
{
if ( textBitMasks[asciiChar] & BIT2 )
{
TextVertices[cIndex].sx = D3DVAL( lCoords[TR_1][0] );
TextVertices[cIndex++].sy = D3DVAL( lCoords[TR_1][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[TRR][0] );
TextVertices[cIndex++].sy = D3DVAL( lCoords[TRR][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[MRR_0][0] );
TextVertices[cIndex++].sy = D3DVAL( lCoords[MRR_0][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[MRR_0][0] );
TextVertices[cIndex++].sy = D3DVAL( lCoords[MRR_0][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[MR_0][0] );
TextVertices[cIndex++].sy = D3DVAL( lCoords[MR_0][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[TR_1][0] );
TextVertices[cIndex++].sy = D3DVAL( lCoords[TR_1][1] );
}
if ( textBitMasks[asciiChar] & BIT3 )
{
TextVertices[cIndex].sx = D3DVAL( lCoords[MR_1][0] );
TextVertices[cIndex++].sy = D3DVAL( lCoords[MR_1][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[MRR_1][0] );
TextVertices[cIndex++].sy = D3DVAL( lCoords[MRR_1][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[BRR][0] );
TextVertices[cIndex++].sy = D3DVAL( lCoords[BRR][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[BRR][0] );
TextVertices[cIndex++].sy = D3DVAL( lCoords[BRR][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[BR_0][0] );
TextVertices[cIndex++].sy = D3DVAL( lCoords[BR_0][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[MR_1][0] );
TextVertices[cIndex++].sy = D3DVAL( lCoords[MR_1][1] );
}
}
/* Handle the TOP/BOTTOM LEFT lines. */
// if ( textBitMasks[asciiChar] & (BIT5|BIT6) )
if ( 1 == 0 )
{
TextVertices[cIndex].sx = D3DVAL( lCoords[TLL][0] );
TextVertices[cIndex++].sy= D3DVAL( lCoords[TLL][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[TL_1][0] );
TextVertices[cIndex++].sy= D3DVAL( lCoords[TL_1][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[BL_0][0] );
TextVertices[cIndex++].sy= D3DVAL( lCoords[BL_0][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[BL_0][0] );
TextVertices[cIndex++].sy= D3DVAL( lCoords[BL_0][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[BLL][0] );
TextVertices[cIndex++].sy= D3DVAL( lCoords[BLL][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[TLL][0] );
TextVertices[cIndex++].sy= D3DVAL( lCoords[TLL][1] );
}
else
{
if ( textBitMasks[asciiChar] & BIT5 )
{
TextVertices[cIndex].sx = D3DVAL( lCoords[MLL_1][0] );
TextVertices[cIndex++].sy = D3DVAL( lCoords[MLL_1][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[ML_1][0] );
TextVertices[cIndex++].sy = D3DVAL( lCoords[ML_1][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[BL_0][0] );
TextVertices[cIndex++].sy = D3DVAL( lCoords[BL_0][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[BL_0][0] );
TextVertices[cIndex++].sy = D3DVAL( lCoords[BL_0][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[BLL][0] );
TextVertices[cIndex++].sy = D3DVAL( lCoords[BLL][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[MLL_1][0] );
TextVertices[cIndex++].sy = D3DVAL( lCoords[MLL_1][1] );
}
if ( textBitMasks[asciiChar] & BIT6 )
{
TextVertices[cIndex].sx = D3DVAL( lCoords[TLL][0] );
TextVertices[cIndex++].sy = D3DVAL( lCoords[TLL][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[TL_1][0] );
TextVertices[cIndex++].sy = D3DVAL( lCoords[TL_1][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[ML_0][0] );
TextVertices[cIndex++].sy = D3DVAL( lCoords[ML_0][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[ML_0][0] );
TextVertices[cIndex++].sy = D3DVAL( lCoords[ML_0][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[MLL_0][0] );
TextVertices[cIndex++].sy = D3DVAL( lCoords[MLL_0][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[TLL][0] );
TextVertices[cIndex++].sy = D3DVAL( lCoords[TLL][1] );
}
}
/* Handle the MIDDLE line. */
if ( textBitMasks[asciiChar] & BIT7 )
{
TextVertices[cIndex].sx = D3DVAL( lCoords[ML_0][0] );
TextVertices[cIndex++].sy= D3DVAL( lCoords[ML_0][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[MR_0][0] );
TextVertices[cIndex++].sy= D3DVAL( lCoords[MR_0][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[MR_1][0] );
TextVertices[cIndex++].sy= D3DVAL( lCoords[MR_1][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[MR_1][0] );
TextVertices[cIndex++].sy= D3DVAL( lCoords[MR_1][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[ML_1][0] );
TextVertices[cIndex++].sy= D3DVAL( lCoords[ML_1][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[ML_0][0] );
TextVertices[cIndex++].sy= D3DVAL( lCoords[ML_0][1] );
}
/* Handle the BOTTOM line. */
if ( textBitMasks[asciiChar] & BIT4 )
{
TextVertices[cIndex].sx = D3DVAL( lCoords[BL_0][0] );
TextVertices[cIndex++].sy= D3DVAL( lCoords[BL_0][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[BR_0][0] );
TextVertices[cIndex++].sy= D3DVAL( lCoords[BR_0][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[BR_1][0] );
TextVertices[cIndex++].sy= D3DVAL( lCoords[BR_1][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[BR_1][0] );
TextVertices[cIndex++].sy= D3DVAL( lCoords[BR_1][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[BL_1][0] );
TextVertices[cIndex++].sy= D3DVAL( lCoords[BL_1][1] );
TextVertices[cIndex].sx = D3DVAL( lCoords[BL_0][0] );
TextVertices[cIndex++].sy= D3DVAL( lCoords[BL_0][1] );
}
return cIndex;
}
#undef CM
#undef CY
#undef CX
#undef CT
#undef TLL
#undef TRR
#undef TL_0
#undef TL_1
#undef TR_0
#undef TR_1
#undef MLL_0
#undef MLL_1
#undef MRR_0
#undef MRR_1
#undef ML_0
#undef ML_1
#undef MR_0
#undef MR_1
#undef BL_0
#undef BL_1
#undef BR_0
#undef BR_1
#undef BLL
#undef BRR
#undef BIT1
#undef BIT2
#undef BIT3
#undef BIT4
#undef BIT5
#undef BIT6
#undef BIT7
#undef TOP
#undef MIDDLE
#undef BOTTOM
#undef TLEFT
#undef BLEFT
#undef LEFT
#undef TRIGHT
#undef BRIGHT
#undef RIGHT
#undef ALL

View File

@ -1,947 +0,0 @@
/*===========================================================================*/
/* */
/* Mesa-3.0 DirectX 6 Driver */
/* */
/* By Leigh McRae */
/* */
/* http://www.altsoftware.com/ */
/* */
/* Copyright (c) 1999-1998 alt.software inc. All Rights Reserved */
/*===========================================================================*/
#include "D3DHAL.h"
/*===========================================================================*/
/* Local function prototypes. */
/*===========================================================================*/
static void UpdateTexture( PTM_OBJECT pTMObj, BOOL bVideo, RECT *pRect, UCHAR *pixels );
static BOOL LoadTextureInVideo( PMESAD3DHAL pHAL, PTM_OBJECT pTMObj );
static BOOL FreeTextureMemory( PMESAD3DHAL pHAL, PTM_OBJECT pTMObject );
static BOOL DestroyTextureObject( PMESAD3DHAL pHAL, PTM_OBJECT pTMObject );
HRESULT CALLBACK EnumPFHook( LPDDPIXELFORMAT lpDDPixFmt, LPVOID lpContext );
/*===========================================================================*/
/* This function will simply set the top of stack to NULL. I only used it */
/* just incase I want to add something later. */
/*===========================================================================*/
/* RETURN: TRUE. */
/*===========================================================================*/
BOOL InitTMgrHAL( PMESAD3DHAL pHAL )
{
DPF(( DBG_FUNC, "InitTMgrHAL();" ));
/* Be clean my friend. */
pHAL->pTMList = NULL;
return TRUE;
}
/*===========================================================================*/
/* This function will walk the Texture Managers linked list and destroy all */
/* surfaces (SYSTEM/VIDEO). The texture objects themselves also will be */
/* freed. */
/* NOTE: this is per/context. */
/*===========================================================================*/
/* RETURN: */
/*===========================================================================*/
void TermTMgrHAL( PMESAD3DHAL pHAL )
{
DPF(( DBG_FUNC, "TermTMgrHAL();" ));
if ( pHAL && pHAL->pTMList )
{
/* Destroy the surface and remove the TMO from the stack. */
while( DestroyTextureObject(pHAL,NULL) );
/* Be clean my friend. */
pHAL->pTMList = NULL;
}
}
/*===========================================================================*/
/* This function is a HACK as I don't know how I can disable a texture with-*/
/* out booting it out. Is there know state change? */
/*===========================================================================*/
/* RETURN: */
/*===========================================================================*/
extern "C" void DisableTMgrHAL( PMESAD3DSHARED pShared )
{
PMESAD3DHAL pHAL = (PMESAD3DHAL)pShared;
DPF(( DBG_FUNC, "DisableTMgrHAL();" ));
/* Check too see that we have a valid context. */
if ( (pHAL == NULL) && (pHAL->lpD3DDevice != NULL) )
{
DPF(( DBG_TXT_WARN, "Null HAL/Direct3D Device!" ));
return;
}
// TODO: This is a hack to shut off textures.
pHAL->lpD3DDevice->SetTexture( 0, NULL );
}
/*===========================================================================*/
/* This function is the only entry into the TextureManager that Mesa/wgl */
/* will see. It uses a dwAction to specify what we are doing. I did this as*/
/* depending on the cards resources the action taken can change. */
/* When this function is called we will always search the Texture Managers */
/* linked list (per context remember) and try and find a structure that has */
/* the same dwName. If we have a match we pull it out of the list and put it*/
/* at the top of the list (TOL). If we don't find one then we create a struc*/
/* and put it a TOL. This TOL idea makes for some caching as we will always */
/* destroy Texture Surfaces from the bottom up... */
/* All texture objects at this point will create a texture surface in System*/
/* memory (SMEM). Then we will copy the Mesa texture into the surface using */
/* the 'pixel' struc to get the translation info. So now this means that all*/
/* textures that Mesa gives me I will have a Surface with a copy. If Mesa */
/* changes the texture the I update the surface in (SMEM). */
/* Now we have a texture struc and a Texture Surface in SMEM. At this point*/
/* we create another surface on the card (VMEM). Finally we blt from the */
/* SMEM to the VMEM and set the texture as current. Why do I need two? First*/
/* this solves square textures. If the cards CAPS is square textures only */
/* then I change the dimensions of the VMEM surface and the blt solves it for*/
/* me. Second it saves me from filling D3D textures over and over if the */
/* card needs to be creating and destroying surfaces because of low memory. */
/* The surface in SMEM is expected to work always. When a surface has to be*/
/* created in VMEM then we put it in a loop that tries to create the surface.*/
/* If we create the surface ok then we brake from the loop. If we fail then */
/* we will call 'FreeTextureMemory' that will return TRUE/FALSE as to whether*/
/* memory was freed. If memory was freed then we can try again. If no memory*/
/* was freed then it just can't fit. */
/* 'FreeTextureMemory' will find the end of the list and start freeing VMEM */
/* (never SMEM) surfaces that are not locked. */
/* BIND - when we bind and there is a texture struct with a texture surface */
/* in VMEM then we just make it current. If we have a struct and a surface */
/* in SMEM but no VMEM surface then we create the surface in VMEM and blt */
/* from the SMEM surface. If we have nothing its just like a creation... */
/*===========================================================================*/
/* RETURN: TRUE, FALSE. */
/*===========================================================================*/
extern "C" BOOL CreateTMgrHAL( PMESAD3DSHARED pShared, DWORD dwName, int level, DWORD dwRequestFlags,
RECT *rectDirty, DWORD dwWidth, DWORD dwHeight, DWORD dwAction, void *pPixels )
{
PMESAD3DHAL pHAL = (PMESAD3DHAL)pShared;
PTM_OBJECT pTMObj,
pTemp;
DDSURFACEDESC2 ddsd2;
HRESULT rc;
DPF(( DBG_FUNC, "CreateTMgrHAL();" ));
DPF(( DBG_TXT_INFO, "Texture:" ));
DPF(( DBG_TXT_INFO, "cx: %d cy: %d", dwWidth, dwHeight ));
DPF(( DBG_TXT_INFO, "Rect:" ));
if ( rectDirty )
{
DPF(( DBG_TXT_INFO, "x0: %d y0: %d", rectDirty->left, rectDirty->top ));
DPF(( DBG_TXT_INFO, "x1: %d y1: %d", rectDirty->right, rectDirty->bottom ));
}
/* Check too see that we have a valid context. */
if ( (pHAL == NULL) && (pHAL->lpD3DDevice != NULL) )
{
DPF(( DBG_TXT_WARN, "Null HAL/Direct3D Device!" ));
return FALSE;
}
/*=================================================*/
/* See if we can find this texture object by name. */
/*=================================================*/
for( pTMObj = pHAL->pTMList; pTMObj && (pTMObj->dwName != dwName); pTMObj = pTMObj->next );
/*=========================================================*/
/* Allocate a new object if we didn't get a matching name. */
/*=========================================================*/
if ( pTMObj == NULL )
{
pTMObj = (PTM_OBJECT)ALLOC( sizeof(TM_OBJECT) );
if ( pTMObj == NULL )
return FALSE;
memset( pTMObj, 0, sizeof(TM_OBJECT) );
/* Put the object at the beginning of the list. */
pTMObj->next = pHAL->pTMList;
if ( pTMObj->next )
{
pTemp = pTMObj->next;
pTemp->prev = pTMObj;
}
pHAL->pTMList = pTMObj;
}
else
{
/*===============================================================*/
/* Make some caching happen by pulling this object to the front. */
/*===============================================================*/
if ( pHAL->pTMList != pTMObj )
{
/* Pull the object out of the list. */
if ( pTMObj->prev )
{
pTemp = pTMObj->prev;
pTemp->next = pTMObj->next;
}
if ( pTMObj->next )
{
pTemp = pTMObj->next;
pTemp->prev = pTMObj->prev;
}
pTMObj->prev = NULL;
pTMObj->next = NULL;
/* Put the object at the front of the list. */
pTMObj->next = pHAL->pTMList;
if ( pTMObj->next )
{
pTemp = pTMObj->next;
pTemp->prev = pTMObj;
}
pHAL->pTMList = pTMObj;
}
}
/*========================================================*/
/* If we are doing BIND and the texture is in VID memory. */
/*========================================================*/
if ( (dwAction == TM_ACTION_BIND) && pTMObj->lpDDS_Video )
{
DPF(( DBG_TXT_PROFILE, "Cache HIT (%d)", dwName ));
/* Make this the current texture. */
rc = pHAL->lpD3DDevice->SetTexture( 0, pTMObj->lpD3DTexture2 );
if ( FAILED(rc) )
{
DPF(( DBG_TXT_WARN, "Failed SetTexture() (%s)", ErrorStringD3D(rc) ));
pHAL->lpD3DDevice->SetTexture( 0, NULL );
return FALSE;
}
return TRUE;
}
/*=================================================================*/
/* If we are doing BIND and the texture is at least in SYS memory. */
/*=================================================================*/
if ( (dwAction == TM_ACTION_BIND) && pTMObj->lpDDS_System )
{
DPF(( DBG_TXT_PROFILE, "Cache MISS (%d)", dwName ));
/* Create the texture on the card. */
rc = LoadTextureInVideo( pHAL, pTMObj );
if ( rc == FALSE )
return FALSE;
/* Make this the current texture. */
rc = pHAL->lpD3DDevice->SetTexture( 0, pTMObj->lpD3DTexture2 );
if ( FAILED(rc) )
{
DPF(( DBG_TXT_WARN, "Failed SetTexture() (%s)", ErrorStringD3D(rc) ));
pHAL->lpD3DDevice->SetTexture( 0, NULL );
return FALSE;
}
return TRUE;
}
/*=========================================================*/
/* If we are doing UPDATE then try in VID first for speed. */
/*=========================================================*/
if ( (dwAction == TM_ACTION_UPDATE) && pTMObj->lpDDS_Video &&
!(pHAL->D3DHWDevDesc.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_SQUAREONLY) )
{
DPF(( DBG_TXT_INFO, "Fix the SubTexture update Leigh!" ));
/* Update the texture on the card. */
UpdateTexture( pTMObj, TRUE, rectDirty, (UCHAR *)pPixels );
/* We updated the texture in VID so kill the SYS so we know its dirty. */
if ( pTMObj->lpDDS_System )
{
DPF(( DBG_TXT_INFO, "Release texture (SYS)" ));
DX_RESTORE( pTMObj->lpDDS_System );
pTMObj->lpDDS_System->Release();
pTMObj->lpDDS_System = NULL;
}
/* Make this the current texture. */
rc = pHAL->lpD3DDevice->SetTexture( 0, pTMObj->lpD3DTexture2 );
if ( FAILED(rc) )
{
DPF(( DBG_TXT_WARN, "Failed SetTexture() (%s)", ErrorStringD3D(rc) ));
pHAL->lpD3DDevice->SetTexture( 0, NULL );
return FALSE;
}
return TRUE;
}
/*===========================================================*/
/* If we are doing UPDATE then try in SYS still gives speed. */
/*===========================================================*/
if ( (dwAction == TM_ACTION_UPDATE) && pTMObj->lpDDS_System )
{
DPF(( DBG_TXT_INFO, "Fix the SubTexture update Leigh!" ));
/* Update the texture in SYS. */
UpdateTexture( pTMObj, FALSE, NULL, (UCHAR *)pPixels );
/* We updated the SYS texture only so now blt to the VID. */
rc = LoadTextureInVideo( pHAL, pTMObj );
if ( rc == FALSE )
return FALSE;
/* Make this the current texture. */
rc = pHAL->lpD3DDevice->SetTexture( 0, pTMObj->lpD3DTexture2 );
if ( FAILED(rc) )
{
DPF(( DBG_TXT_WARN, "Failed SetTexture() (%s)", ErrorStringD3D(rc) ));
pHAL->lpD3DDevice->SetTexture( 0, NULL );
return FALSE;
}
return TRUE;
}
/* At this point we have a valid Texture Manager Object with updated */
/* links. We now need to create or update a texture surface that is */
/* in system memory. Every texture has a copy in system so we can use*/
/* blt to solve problems with textures allocated on the card (square */
/* only textures, pixelformats...). */
// TODO: make support for update also. Dirty rectangle basicly...
/* Kill the interface if we have one no matter what. */
if ( pTMObj->lpD3DTexture2 )
{
DPF(( DBG_TXT_INFO, "Release Texture2" ));
pTMObj->lpD3DTexture2->Release();
pTMObj->lpD3DTexture2 = NULL;
}
/* Kill the system surface. TODO: should try to get the SubIMage going again */
if ( pTMObj->lpDDS_System )
{
DPF(( DBG_TXT_INFO, "Release texture (SYS)" ));
DX_RESTORE( pTMObj->lpDDS_System );
pTMObj->lpDDS_System->Release();
pTMObj->lpDDS_System = NULL;
}
/* Kill the Video surface. TODO: need some reuse system... */
if ( pTMObj->lpDDS_Video )
{
DPF(( DBG_TXT_INFO, "Release texture (VID)" ));
DX_RESTORE( pTMObj->lpDDS_Video );
pTMObj->lpDDS_Video->Release();
pTMObj->lpDDS_Video = NULL;
}
/*================================================================*/
/* Translate the the Mesa/OpenGL pixel channels to the D3D flags. */
/*================================================================*/
switch( dwRequestFlags )
{
case GL_ALPHA:
dwRequestFlags = DDPF_ALPHA;
DPF(( DBG_TXT_WARN, "GL_ALPHA not supported!)" ));
return FALSE;
case GL_INTENSITY:
case GL_LUMINANCE:
DPF(( DBG_TXT_WARN, "GL_INTENSITY/GL_LUMINANCE not supported!)" ));
dwRequestFlags = DDPF_LUMINANCE;
return FALSE;
case GL_LUMINANCE_ALPHA:
DPF(( DBG_TXT_WARN, "GL_LUMINANCE_ALPHA not supported!)" ));
dwRequestFlags = DDPF_LUMINANCE | DDPF_ALPHAPIXELS;
return FALSE;
case GL_RGB:
DPF(( DBG_TXT_INFO, "Texture -> GL_RGB" ));
dwRequestFlags = DDPF_RGB;
break;
case GL_RGBA:
DPF(( DBG_TXT_INFO, "Texture -> GL_RGBA" ));
dwRequestFlags = DDPF_RGB | DDPF_ALPHAPIXELS;
break;
}
/*==============================*/
/* Populate the texture object. */
/*==============================*/
pTMObj->dwName = dwName;
pTMObj->lpD3DDevice = pHAL->lpD3DDevice;
pTMObj->dwFlags = dwRequestFlags;
if ( pHAL->D3DHWDevDesc.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_SQUAREONLY )
{
DPF(( DBG_TXT_INFO, "Convert to Square..." ));
pTMObj->dwSHeight = dwHeight;
pTMObj->dwSWidth = dwWidth;
/* Shrink non-square textures. */
pTMObj->dwVHeight = (dwHeight > dwWidth) ? dwWidth : dwHeight;
pTMObj->dwVWidth = (dwHeight > dwWidth) ? dwWidth : dwHeight;
}
else
{
pTMObj->dwSHeight = dwHeight;
pTMObj->dwSWidth = dwWidth;
pTMObj->dwVHeight = dwHeight;
pTMObj->dwVWidth = dwWidth;
}
/*========================*/
/* Create SYSTEM surface. */
/*========================*/
/* Request a surface in system memory. */
memset( &ddsd2, 0, sizeof(DDSURFACEDESC2) );
ddsd2.dwSize = sizeof( DDSURFACEDESC2 );
ddsd2.dwWidth = pTMObj->dwSWidth;
ddsd2.dwHeight = pTMObj->dwSHeight;
ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_SYSTEMMEMORY;
ddsd2.ddsCaps.dwCaps2 = 0L;
memset( &ddsd2.ddpfPixelFormat, 0, sizeof(DDPIXELFORMAT) );
ddsd2.ddpfPixelFormat.dwSize = sizeof( DDPIXELFORMAT );
ddsd2.ddpfPixelFormat.dwFlags = dwRequestFlags;
rc = pHAL->lpD3DDevice->EnumTextureFormats( EnumPFHook, &ddsd2.ddpfPixelFormat );
if ( FAILED(rc) )
{
RIP( pHAL, "EnumerTextureFormats (SYSTEM)->", ErrorStringD3D(rc) );
return FALSE;
}
/* Create the surface using the enumerated pixelformat. */
rc = pHAL->lpDD4->CreateSurface( &ddsd2, &pTMObj->lpDDS_System, NULL );
if ( FAILED(rc) )
{
RIP( pHAL, "CreateSurface (TEXTURE/SYSTEM)->", ErrorStringD3D(rc) );
return FALSE;
}
/* Solve the pixel mapping info using the surface pixelformat. */
Solve8BitChannelPixelFormat( &ddsd2.ddpfPixelFormat, &pTMObj->pixel );
/*===================================================================*/
/* Fill the texture using the PixelInfo structure to do the mapping. */
/*===================================================================*/
UpdateTexture( pTMObj, FALSE, NULL, (UCHAR *)pPixels );
/*=======================*/
/* Create VIDEO surface. */
/*=======================*/
rc = LoadTextureInVideo( pHAL, pTMObj );
if ( rc == FALSE )
return FALSE;
/* Make this the current texture. */
rc = pHAL->lpD3DDevice->SetTexture( 0, pTMObj->lpD3DTexture2 );
if ( FAILED(rc) )
{
DPF(( DBG_TXT_WARN, "Failed SetTexture() (%s)", ErrorStringD3D(rc) ));
pHAL->lpD3DDevice->SetTexture( 0, NULL );
return FALSE;
}
return TRUE;
}
/*===========================================================================*/
/* This function will handle the creation and destruction of the texture */
/* surfaces on the card. Using the dw'V'Width/Height dimensions the call */
/* try and create the texture on the card and keep using FreeTextureMemory */
/* until the surace can be created. Once the surface is created we get the */
/* interface that we will use to make it the current texture. I didn't put */
/* the code to make the texture current in this function as BIND needs to */
/* use the same code and this function doesn't always get called when we do a*/
/* bind. */
/*===========================================================================*/
/* RETURN: TRUE, FALSE. */
/*===========================================================================*/
static BOOL LoadTextureInVideo( PMESAD3DHAL pHAL, PTM_OBJECT pTMObj )
{
DDSURFACEDESC2 ddsd2;
HRESULT rc;
DPF(( DBG_FUNC, "LoadTextureInVideo();" ));
/* Kill the interface if we have one no matter what. */
if ( pTMObj->lpD3DTexture2 )
{
DPF(( DBG_TXT_INFO, "Release Texture2" ));
pTMObj->lpD3DTexture2->Release();
pTMObj->lpD3DTexture2 = NULL;
}
/* Kill the Video surface. TODO: need some reuse system... */
if ( pTMObj->lpDDS_Video )
{
DPF(( DBG_TXT_INFO, "Release texture (VID)" ));
DX_RESTORE( pTMObj->lpDDS_Video );
pTMObj->lpDDS_Video->Release();
pTMObj->lpDDS_Video = NULL;
}
/* Request a surface in Video memory. */
memset( &ddsd2, 0, sizeof(DDSURFACEDESC2) );
ddsd2.dwSize = sizeof( DDSURFACEDESC2 );
ddsd2.dwWidth = pTMObj->dwVWidth;
ddsd2.dwHeight = pTMObj->dwVHeight;
ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
ddsd2.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_VIDEOMEMORY;
ddsd2.ddsCaps.dwCaps2 = 0L;
memset( &ddsd2.ddpfPixelFormat, 0, sizeof(DDPIXELFORMAT) );
ddsd2.ddpfPixelFormat.dwSize = sizeof( DDPIXELFORMAT );
ddsd2.ddpfPixelFormat.dwFlags = pTMObj->dwFlags;
rc = pHAL->lpD3DDevice->EnumTextureFormats( EnumPFHook, &ddsd2.ddpfPixelFormat );
if ( FAILED(rc) )
{
RIP( pHAL, "EnumerTextureFormats ->", ErrorStringD3D(rc) );
return FALSE;
}
/* Make sure we lock so we don't nuke this texture trying to free memory for it. */
pTMObj->bLock = TRUE;
/* Start a loop that will free all textures until we have created the texture */
/* surface or we can't free up more memory. */
do
{
/* Try to create the texture surface. */
rc = pHAL->lpDD4->CreateSurface( &ddsd2, &pTMObj->lpDDS_Video, NULL );
if ( !FAILED(rc) )
break;
DPF(( DBG_TXT_INFO, "Free Texture Memory" ));
/* DestroyTexture will return TRUE if a surface was freed. */
} while( FreeTextureMemory(pHAL,NULL) );
/* Make sure we unlock or we won't be able to nuke the TMO later. */
pTMObj->bLock = FALSE;
/* Did we create a valid texture surface? */
if ( FAILED(rc) )
{
DPF(( DBG_TXT_WARN, "Failed to load texture" ));
pHAL->lpD3DDevice->SetTexture( 0, NULL );
return FALSE;
}
DX_RESTORE( pTMObj->lpDDS_System );
DX_RESTORE( pTMObj->lpDDS_Video );
DPF(( DBG_TXT_INFO, "Texture Blt SYSTEM -> VID" ));
/* Now blt the texture in system memory to the card. */
rc = pTMObj->lpDDS_Video->Blt( NULL, pTMObj->lpDDS_System, NULL, DDBLT_WAIT, NULL );
if ( FAILED(rc) )
{
RIP( pHAL, "Blt (TEXTURE) ->", ErrorStringD3D(rc) );
return FALSE;
}
/* Get the Texture interface that is used to render with. */
pTMObj->lpDDS_Video->QueryInterface( IID_IDirect3DTexture2, (void **)&pTMObj->lpD3DTexture2 );
if ( pTMObj->lpD3DTexture2 == NULL )
{
DPF(( DBG_TXT_WARN, "Failed QueryTextureInterface" ));
pHAL->lpD3DDevice->SetTexture( 0, NULL );
return FALSE;
}
return TRUE;
}
/*===========================================================================*/
/* If this function gets a texture object struc then we will try and free */
/* it. If we get a NULL then we will search from the bottom up and free one */
/* VMEM surface. I can only free when the surface isn't locked and of course*/
/* there must be a VMEM surface. We never free SMEM surfaces as that isn't */
/* the point. */
/* TODO: should have a pointer to the bottom of the stack really. */
/*===========================================================================*/
/* RETURN: */
/*===========================================================================*/
static BOOL FreeTextureMemory( PMESAD3DHAL pHAL, PTM_OBJECT pTMObject )
{
PTM_OBJECT pCurrent;
BOOL bFreed = FALSE;
DPF(( DBG_FUNC, "FreeTextureMemory();" ));
DPF(( DBG_TXT_WARN, "FREE TEXTURE!" ));
/* Just to be safe. */
if ( !pHAL || !pHAL->pTMList )
{
DPF(( DBG_TXT_WARN, "FreeTextureMemory() -> NULL pHAL/pHAL->pTMList" ));
return FALSE;
}
/* Free the last texture in the list. */
if ( pTMObject == NULL )
{
DPF(( DBG_TXT_INFO, "Free Last texture in cache" ));
/* Find the last texture object. */
for( pCurrent = pHAL->pTMList; pCurrent->next; pCurrent = pCurrent->next );
/* Now backup until we find a texture on the card. */
while( pCurrent && (pCurrent->lpDDS_Video == NULL) && (pCurrent->bLock == FALSE) )
pCurrent = pCurrent->prev;
/* Didn't find anything. */
if ( pCurrent == NULL )
{
DPF(( DBG_TXT_INFO, "No texture memory freed" ));
return FALSE;
}
}
else
{
/* See if we can find this texture object. */
for( pCurrent = pHAL->pTMList; pCurrent && (pCurrent != pTMObject); pCurrent = pCurrent->next );
/* Didn't find anything. */
if ( pCurrent == NULL )
{
DPF(( DBG_TXT_INFO, "Requested texture to be freed NOT FOUND" ));
return FALSE;
}
}
/* Can't free this baby. */
if ( pCurrent->bLock == TRUE )
{
DPF(( DBG_TXT_WARN, "Requested texture LOCKED" ));
return FALSE;
}
/* Free the texture memory. */
if ( pCurrent->lpD3DTexture2 )
{
DPF(( DBG_TXT_INFO, "Release Texture2" ));
pCurrent->lpD3DTexture2->Release();
pCurrent->lpD3DTexture2 = NULL;
bFreed = TRUE;
}
if ( pCurrent->lpDDS_Video )
{
DPF(( DBG_TXT_INFO, "Release texture (VID):" ));
DPF(( DBG_TXT_INFO, "dwName: %d", pCurrent->dwName ));
DPF(( DBG_TXT_INFO, "cx: %d, cy: %d", pCurrent->dwVWidth, pCurrent->dwVHeight ));
pCurrent->lpDDS_Video->Release();
pCurrent->lpDDS_Video = NULL;
bFreed = TRUE;
}
return bFreed;
}
/*===========================================================================*/
/* This function searches the linked list of texture objects in the supplied*/
/* D3Dwrapper structure. If it finds a match it will free it and pull it out*/
/* of the linked list. The function works on the bases of a matching pointer*/
/* to the object (not matching content). */
/* If the function gets passed a NULL then we want to free the last texture */
/* object in the list. Used in a loop to destory all. */
/*===========================================================================*/
/* RETURN: TRUE, FALSE. */
/*===========================================================================*/
static BOOL DestroyTextureObject( PMESAD3DHAL pHAL, PTM_OBJECT pTMObject )
{
PTM_OBJECT pCurrent;
DPF(( DBG_FUNC, "DestoryTextureObject();" ));
/* Just to be safe. */
if ( !pHAL || !pHAL->pTMList )
{
DPF(( DBG_TXT_WARN, "DestroyTextureObject() -> NULL pHAL/pHAL->pTMList" ));
return FALSE;
}
/* Free the last texture in the list. */
if ( pTMObject == NULL )
{
/* Find the last texture object. */
for( pCurrent = pHAL->pTMList; pCurrent->next; pCurrent = pCurrent->next );
}
else
{
/* See if we can find this texture object. */
for( pCurrent = pHAL->pTMList; pCurrent && (pCurrent != pTMObject); pCurrent = pCurrent->next );
/* Didn't find anything. */
if ( pCurrent == NULL )
{
DPF(( DBG_TXT_WARN, "No textures to be freed" ));
return FALSE;
}
}
/* Can't free this baby. */
if ( pCurrent->bLock == TRUE )
{
DPF(( DBG_TXT_WARN, "Requested texture to be freed LOCKED" ));
return FALSE;
}
/* Free the texture memory. */
if ( pCurrent->lpD3DTexture2 )
{
DPF(( DBG_TXT_INFO, "Release Texture2" ));
pCurrent->lpD3DTexture2->Release();
pCurrent->lpD3DTexture2 = NULL;
}
if ( pCurrent->lpDDS_Video )
{
DPF(( DBG_TXT_INFO, "Release texture (VID):" ));
pCurrent->lpDDS_Video->Release();
pCurrent->lpDDS_Video = NULL;
}
if ( pCurrent->lpDDS_System )
{
DPF(( DBG_TXT_INFO, "Release texture (SYS):" ));
pCurrent->lpDDS_System->Release();
pCurrent->lpDDS_System = NULL;
}
/* Pull this texture out of the list. */
if ( pCurrent == pHAL->pTMList )
pHAL->pTMList = NULL;
if ( pCurrent->prev )
(pCurrent->prev)->next = pCurrent->next;
if ( pCurrent->next )
(pCurrent->next)->prev = pCurrent->prev;
FREE( pCurrent );
return TRUE;
}
/*===========================================================================*/
/* This function is the callback function that gets called when we are doing*/
/* an enumeration of the texture formats supported by this device. The choice*/
/* is made by checking to see if we have a match with the supplied D3D pixel-*/
/* format. So the enumeration has to pass a desired D3D PF as the user var. */
/*===========================================================================*/
/* RETURN: D3DENUMRET_OK, D3DENUMRET_CANCEL. */
/*===========================================================================*/
static void UpdateTexture( PTM_OBJECT pTMObj, BOOL bVideo, RECT *pRect, UCHAR *pixels )
{
LPDIRECTDRAWSURFACE4 lpDDS;
DDSURFACEDESC2 ddsd2;
DWORD srcPitch,
dwHeight,
dwWidth,
dwCol,
dwColor;
UCHAR *pSrc,
*pSrcRow,
*pDest,
*pDestRow;
int rc;
// TODO: Do I need to pass the h/w when its in the object!
DPF(( DBG_FUNC, "UpdateTexture();" ));
/* Get the surface pointer we are looking for. */
lpDDS = (bVideo) ? pTMObj->lpDDS_Video : pTMObj->lpDDS_System;
/*===================================================================*/
/* Fill the texture using the PixelInfo structure to do the mapping. */
/*===================================================================*/
/* Get the surface pointer. */
memset( &ddsd2, 0, sizeof(DDSURFACEDESC2) );
ddsd2.dwSize = sizeof(DDSURFACEDESC2);
rc = lpDDS->Lock( NULL, &ddsd2, DDLOCK_WAIT, NULL );
if ( FAILED(rc) )
{
RIP( NULL, "Lock (TEXTURE/SYSTEM)->", ErrorStringD3D(rc) );
return;
}
/* For now we are only updating the system surface so use its dimensions. */
dwWidth = (bVideo) ? pTMObj->dwVWidth : pTMObj->dwSWidth;
dwHeight = (bVideo) ? pTMObj->dwVHeight : pTMObj->dwSHeight;
/* If we are updating the whole surface then the pDest/pSrc will */
/* always be the same. */
if ( pRect == NULL )
{
pDest = (UCHAR *)ddsd2.lpSurface;
pSrc = pixels;
}
/* Fill the texture surface based on the pixelformat flags. */
if ( pTMObj->dwFlags == (DDPF_RGB | DDPF_ALPHAPIXELS) )
{
srcPitch = dwWidth * 4;
if ( pRect )
{
pDest = ((UCHAR *)ddsd2.lpSurface) + (pRect->top * ddsd2.lPitch) + (pRect->left * pTMObj->pixel.cb);
pSrc = pixels + (pRect->top * dwWidth * 4) + (pRect->left * 4);
dwHeight = (pRect->bottom - pRect->top);
dwWidth = (pRect->right - pRect->left);
}
for( pDestRow = pDest, pSrcRow = pSrc; dwHeight > 0; dwHeight--, pDestRow += ddsd2.lPitch, pSrcRow += srcPitch )
{
for( dwCol = 0, pDest = pDestRow, pSrc = pSrcRow; dwCol < dwWidth; dwCol++ )
{
dwColor = ( ((DWORD)(*(pSrc ) * pTMObj->pixel.rScale)) << pTMObj->pixel.rShift );
dwColor |= ( ((DWORD)(*(pSrc+1) * pTMObj->pixel.gScale)) << pTMObj->pixel.gShift );
dwColor |= ( ((DWORD)(*(pSrc+2) * pTMObj->pixel.bScale)) << pTMObj->pixel.bShift );
if ( pTMObj->pixel.aScale == -1.0 )
dwColor |= ( (*(pSrc+3) & 0x80) ? (1 << pTMObj->pixel.aShift) : 0 );
else
dwColor |= ( ((DWORD)(*(pSrc+3) * pTMObj->pixel.aScale)) << pTMObj->pixel.aShift );
memcpy( pDest, &dwColor, pTMObj->pixel.cb );
pDest += pTMObj->pixel.cb;
pSrc += 4;
}
}
}
else if ( pTMObj->dwFlags == DDPF_RGB )
{
srcPitch = dwWidth * 3;
if ( pRect )
{
pDest = ((UCHAR *)ddsd2.lpSurface) + (pRect->top * ddsd2.lPitch) + (pRect->left * pTMObj->pixel.cb);
pSrc = pixels + (pRect->top * dwWidth * 3) + (pRect->left * 3);
dwHeight = (pRect->bottom - pRect->top);
dwWidth = (pRect->right - pRect->left);
}
for( pDestRow = pDest, pSrcRow = pSrc; dwHeight > 0; dwHeight--, pDestRow += ddsd2.lPitch, pSrcRow += srcPitch )
{
for( dwCol = 0, pDest = pDestRow, pSrc = pSrcRow; dwCol < dwWidth; dwCol++ )
{
dwColor = ( ((DWORD)(*(pSrc ) * pTMObj->pixel.rScale)) << pTMObj->pixel.rShift );
dwColor |= ( ((DWORD)(*(pSrc+1) * pTMObj->pixel.gScale)) << pTMObj->pixel.gShift );
dwColor |= ( ((DWORD)(*(pSrc+2) * pTMObj->pixel.bScale)) << pTMObj->pixel.bShift );
memcpy( pDest, &dwColor, pTMObj->pixel.cb );
pDest += pTMObj->pixel.cb;
pSrc += 3;
}
}
}
else if ( pTMObj->dwFlags == (DDPF_LUMINANCE | DDPF_ALPHAPIXELS) )
{
srcPitch = dwWidth * 2;
if ( pRect )
{
pDest = ((UCHAR *)ddsd2.lpSurface) + (pRect->top * ddsd2.lPitch) + (pRect->left * pTMObj->pixel.cb);
pSrc = pixels + (pRect->top * dwWidth * 2) + (pRect->left * 2);
dwHeight = (pRect->bottom - pRect->top);
dwWidth = (pRect->right - pRect->left);
}
for( pDestRow = pDest, pSrcRow = pSrc; dwHeight > 0; dwHeight--, pDestRow += ddsd2.lPitch, pSrcRow += srcPitch )
{
for( dwCol = 0, pDest = pDestRow, pSrc = pSrcRow; dwCol < dwWidth; dwCol++ )
{
dwColor = ( ((DWORD)(*(pSrc ) * pTMObj->pixel.rScale)) << pTMObj->pixel.rShift );
if ( pTMObj->pixel.aScale == -1.0 )
dwColor |= ( (*(pSrc+1) & 0x80) ? (1 << pTMObj->pixel.aShift) : 0 );
else
dwColor |= ( ((DWORD)(*(pSrc+1) * pTMObj->pixel.aScale)) << pTMObj->pixel.aShift );
memcpy( pDest, &dwColor, pTMObj->pixel.cb );
pDest += pTMObj->pixel.cb;
pSrc += 2;
}
}
}
else if ( pTMObj->dwFlags == DDPF_LUMINANCE )
{
srcPitch = dwWidth;
if ( pRect )
{
pDest = ((UCHAR *)ddsd2.lpSurface) + (pRect->top * ddsd2.lPitch) + (pRect->left * pTMObj->pixel.cb);
pSrc = pixels + (pRect->top * dwWidth) + (pRect->left);
dwHeight = (pRect->bottom - pRect->top);
dwWidth = (pRect->right - pRect->left);
}
for( pDestRow = pDest, pSrcRow = pSrc; dwHeight > 0; dwHeight--, pDestRow += ddsd2.lPitch, pSrcRow += srcPitch )
{
for( dwCol = 0, pDest = pDestRow, pSrc = pSrcRow; dwCol < dwWidth; dwCol++ )
{
dwColor = ( ((DWORD)(*pSrc * pTMObj->pixel.rScale)) << pTMObj->pixel.rShift );
memcpy( pDest, &dwColor, pTMObj->pixel.cb );
pDest += pTMObj->pixel.cb;
pSrc++;
}
}
}
else if ( pTMObj->dwFlags == DDPF_ALPHAPIXELS )
{
srcPitch = dwWidth;
if ( pRect )
{
pDest = ((UCHAR *)ddsd2.lpSurface) + (pRect->top * ddsd2.lPitch) + (pRect->left * pTMObj->pixel.cb);
pSrc = pixels + (pRect->top * dwWidth) + (pRect->left);
dwHeight = (pRect->bottom - pRect->top);
dwWidth = (pRect->right - pRect->left);
}
for( pDestRow = pDest, pSrcRow = pSrc; dwHeight > 0; dwHeight--, pDestRow += ddsd2.lPitch, pSrcRow += srcPitch )
{
for( dwCol = 0, pDest = pDestRow, pSrc = pSrcRow; dwCol < dwWidth; dwCol++ )
{
if ( pTMObj->pixel.aScale == -1.0 )
dwColor = ( (*pSrc & 0x80) ? (1 << pTMObj->pixel.aShift) : 0 );
else
dwColor = ( ((DWORD)(*pSrc * pTMObj->pixel.aScale)) << pTMObj->pixel.aShift );
memcpy( pDest, &dwColor, pTMObj->pixel.cb );
pDest += pTMObj->pixel.cb;
pSrc++;
}
}
}
/* Unlock the surface. */
rc = lpDDS->Unlock( NULL );
if ( FAILED(rc) )
{
RIP( NULL, "Unlock (TEXTURE/SYSTEM)->", ErrorStringD3D(rc) );
}
}
/*===========================================================================*/
/* This function is the callback function that gets called when we are doing*/
/* an enumeration of the texture formats supported by this device. The choice*/
/* is made by checking to see if we have a match with the supplied D3D pixel-*/
/* format. So the enumeration has to pass a desired D3D PF as the user var. */
/*===========================================================================*/
/* RETURN: D3DENUMRET_OK, D3DENUMRET_CANCEL. */
/*===========================================================================*/
HRESULT CALLBACK EnumPFHook( LPDDPIXELFORMAT lpDDPixFmt, LPVOID lpContext )
{
LPDDPIXELFORMAT lpDDPixFmtRequest = (LPDDPIXELFORMAT)lpContext;
PIXELINFO pixel;
DPF(( DBG_FUNC, "EnumPFHook();" ));
if ( lpDDPixFmt->dwFlags == lpDDPixFmtRequest->dwFlags )
{
/* Are we looking for an alpha channel? */
if ( lpDDPixFmtRequest->dwFlags & DDPF_ALPHAPIXELS )
{
/* Try for something that has more then 1bits of Alpha. */
Solve8BitChannelPixelFormat( lpDDPixFmt, &pixel );
if ( pixel.aScale == -1.0 )
{
/* Save this format no matter what as its a match of sorts. */
memcpy( lpDDPixFmtRequest, lpDDPixFmt, sizeof(DDPIXELFORMAT) );
return D3DENUMRET_OK;
}
}
/* Save this format as its a good match. */
memcpy( lpDDPixFmtRequest, lpDDPixFmt, sizeof(DDPIXELFORMAT) );
/* We are happy at this point so lets leave. */
return D3DENUMRET_CANCEL;
}
return D3DENUMRET_OK;
}

View File

@ -1,62 +0,0 @@
/*===========================================================================*/
/* */
/* Mesa-3.0 DirectX 6 Driver */
/* */
/* By Leigh McRae */
/* */
/* http://www.altsoftware.com/ */
/* */
/* Copyright (c) 1999-1998 alt.software inc. All Rights Reserved */
/*===========================================================================*/
#ifndef _TEXTURE_MGR_INC
#define _TEXTURE_MGR_INC
/*===========================================================================*/
/* Includes. */
/*===========================================================================*/
#include <windows.h>
#include <ddraw.h>
#include <d3d.h>
#include <stdlib.h>
#include <stdlib.h>
#include "GL/gl.h"
/*========================================================================*/
/* Defines. */
/*========================================================================*/
/*========================================================================*/
/* Type defines. */
/*========================================================================*/
typedef struct _local_texture_object
{
DWORD dwName,
dwPriority,
dwFlags,
dwSWidth,
dwSHeight,
dwVWidth,
dwVHeight;
BOOL bLock,
bDirty; /* I only update VID on SubImage calls so the system */
/* texture can get invalid. */
LPDIRECT3DDEVICE3 lpD3DDevice; /* If the device changes we must get new handles... */
LPDIRECTDRAWSURFACE4 lpDDS_System,
lpDDS_Video;
LPDIRECT3DTEXTURE2 lpD3DTexture2;
PIXELINFO pixel;
struct _local_texture_object *next;
struct _local_texture_object *prev;
} TM_OBJECT, *PTM_OBJECT;
/*========================================================================*/
/* Function prototypes. */
/*========================================================================*/
void APIENTRY InitTMD3D( void *pVoid );
void APIENTRY TermTMD3D( void *pVoid );
/*========================================================================*/
/* Global variables declaration. */
/*========================================================================*/
#endif

View File

@ -1,638 +0,0 @@
/*===========================================================================*/
/* */
/* Mesa-3.0 DirectX 6 Driver */
/* */
/* By Leigh McRae */
/* */
/* http://www.altsoftware.com/ */
/* */
/* Copyright (c) 1999-1998 alt.software inc. All Rights Reserved */
/*===========================================================================*/
#include "D3DHAL.h"
/*===========================================================================*/
/* Local only functions. */
/*===========================================================================*/
static int CountTrailingZeros( DWORD dwMask );
/*===========================================================================*/
/* This function is used to get the pointer to the surface and the pitch for*/
/* the scanline rendering functions. */
/*===========================================================================*/
/* RETURN: */
/*===========================================================================*/
extern "C" DDSURFACEDESC2 *LockHAL( PMESAD3DSHARED pShared, BOOL bBack )
{
PMESAD3DHAL pHAL = (PMESAD3DHAL)pShared;
static DDSURFACEDESC2 ddsd2;
HRESULT rc;
DPF(( DBG_FUNC, "LockHAL();" ));
/* Set the request structure up first. */
memset( &ddsd2, 0, sizeof(DDSURFACEDESC2) );
ddsd2.dwSize = sizeof(DDSURFACEDESC2);
/* Make sure we have enough info. */
if ( pHAL )
{
rc = pHAL->lpDDSRender->Lock( NULL, &ddsd2, DDLOCK_WAIT, NULL );
if ( FAILED(rc) )
{
RIP( pHAL, "Lock (RENDER) ->", ErrorStringD3D(rc) );
}
}
return &ddsd2;
}
/*===========================================================================*/
/* This is just a simple wrapper. I probably don't need to do any error */
/* checking as the Lock must have worked inorder to get here... */
/*===========================================================================*/
/* RETURN: */
/*===========================================================================*/
extern "C" void UnlockHAL( PMESAD3DSHARED pShared, BOOL bBack )
{
PMESAD3DHAL pHAL = (PMESAD3DHAL)pShared;
HRESULT rc;
DPF(( DBG_FUNC, "UnlockHAL();" ));
/* Make sure we have enough info. */
if ( pHAL )
{
rc = pHAL->lpDDSRender->Unlock( NULL );
if ( FAILED(rc) )
{
RIP( pHAL, "Unlock (RENDER) ->", ErrorStringD3D(rc) );
}
}
}
/*===========================================================================*/
/* This function will track the main/Primary window that will be used as the*/
/* target for the Blt in SwapBuffers. As a side effect the call will check */
/* to see if the primary surface is the same size and position as the screen.*/
/* If they are the same size we will call it fullscreen... */
/*===========================================================================*/
/* RETURN: */
/*===========================================================================*/
extern "C" void UpdateScreenPosHAL( PMESAD3DSHARED pShared )
{
PMESAD3DHAL pHAL = (PMESAD3DHAL)pShared;
POINT pt;
DWORD dwWidth, dwHeight;
DPF(( DBG_FUNC, "UpdateScreenPosHAL();" ));
/* Make sure we have enough info. */
if ( pHAL != NULL )
{
/* Update the windows screen position. */
GetClientRect( pShared->hwnd, &pShared->rectW );
pt.x = pt.y = 0;
ClientToScreen( pShared->hwnd, &pt );
OffsetRect( &pShared->rectW, pt.x, pt.y);
/* Compare the primary to the screen. */
dwWidth = GetSystemMetrics( SM_CXSCREEN );
dwHeight = GetSystemMetrics( SM_CYSCREEN );
if ( (pShared->rectW.left > 0) || (pShared->rectW.top > 0) ||
(pShared->rectW.right > dwWidth) || (pShared->rectW.bottom > dwHeight) )
pShared->bWindow = TRUE;
else
pShared->bWindow = FALSE;
}
}
/*===========================================================================*/
/* This function will fill in the pixel info structure defined in D3Dshared.*/
/* Basicly it will take a DirectDraw pixelformat structure and make scaling */
/* values that will convert from 8bit channels to whatever the supplied ddpf */
/* uses. Also we will generate shift values that will be used to get move */
/* each component of the pixel into place. */
/* I have now added a special case for a 1bit alpha channel. If I find a 1b*/
/* alpha then I will set the scale to -1.0 which should be unique. Later I */
/* can check the alpha scale value too see if its -1.0 and thus handle it. I*/
/* was finding that the case was not working tom my advantage so this is my */
/* HACK for the day. As a TODO I should work on this... */
/*===========================================================================*/
/* RETURN: */
/*===========================================================================*/
void Solve8BitChannelPixelFormat( DDPIXELFORMAT *pddpf, PPIXELINFO pPixel )
{
DPF(( DBG_FUNC, "Solve8BitChannelPixelFromat();" ));
memset( pPixel, 0, sizeof(PPIXELINFO) );
/* Check too see if the color space is valid in the PF. */
if ( pddpf->dwFlags & DDPF_RGB )
{
/* Solve the red stuff. */
pPixel->dwRMask = pddpf->dwRBitMask;
pPixel->rShift = CountTrailingZeros( pPixel->dwRMask );
pPixel->rScale = (float)0.00392156 * (float)(pPixel->dwRMask >> pPixel->rShift);
/* Solve the green thingy's. */
pPixel->dwGMask = pddpf->dwGBitMask;
pPixel->gShift = CountTrailingZeros( pPixel->dwGMask );
pPixel->gScale = (float)0.00392156 * (float)(pPixel->dwGMask >> pPixel->gShift);
/* Solve the blues. */
pPixel->dwBMask = pddpf->dwBBitMask;
pPixel->bShift = CountTrailingZeros( pddpf->dwBBitMask );
pPixel->bScale = (float)0.00392156 * (float)(pddpf->dwBBitMask >> pPixel->bShift);
}
/* Do the alpha channel if there is one. */
if ( pddpf->dwFlags & DDPF_ALPHAPIXELS )
{
pPixel->dwAMask = pddpf->dwRGBAlphaBitMask;
pPixel->aShift = CountTrailingZeros( pPixel->dwAMask );
/* Special case a 1bit alpha. */
if ( (pPixel->dwAMask >> pPixel->aShift) == 1 )
pPixel->aScale = -1.0;
else
pPixel->aScale = (float)0.00392156 * (float)(pPixel->dwAMask >> pPixel->aShift);
}
/* Get the size of the pixel in bytes. Should work as dwRGBBitCount is in a union. */
pPixel->cb = pddpf->dwRGBBitCount / 8;
}
/*===========================================================================*/
/* See RETURN :) */
/*===========================================================================*/
/* RETURN: number of contiguous zeros starting from the right. */
/*===========================================================================*/
static int CountTrailingZeros( DWORD dwMask )
{
DWORD Mask;
if ( dwMask == 0 )
return 32;
/* Can't take credit for this one! */
Mask = dwMask & -(int)dwMask;
return ((Mask & 0xFFFF0000)!=0) << 4
| ((Mask & 0xFF00FF00)!=0) << 3
| ((Mask & 0xF0F0F0F0)!=0) << 2
| ((Mask & 0xCCCCCCCC)!=0) << 1
| ((Mask & 0xAAAAAAAA)!=0);
}
/*===========================================================================*/
/* This function will convert the DDraw error code to its macro string. The*/
/* returned pointer is static so you need not worry about memory managemnet */
/* but the error message gets written over from call to call... */
/*===========================================================================*/
/* RETURN: pointer to the single static buffer that hold the error message. */
/*===========================================================================*/
char *ErrorStringD3D( HRESULT hr )
{
static char errorString[128];
switch( hr )
{
case DDERR_ALREADYINITIALIZED:
strcpy( errorString, "DDERR_ALREADYINITIALIZED" );
break;
case DDERR_CANNOTATTACHSURFACE:
strcpy( errorString, "DDERR_CANNOTATTACHSURFACE" );
break;
case DDERR_CANNOTDETACHSURFACE:
strcpy( errorString, "DDERR_CANNOTDETACHSURFACE" );
break;
case DDERR_CURRENTLYNOTAVAIL:
strcpy( errorString, "DDERR_CURRENTLYNOTAVAIL" );
break;
case DDERR_EXCEPTION:
strcpy( errorString, "DDERR_EXCEPTION" );
break;
case DDERR_GENERIC:
strcpy( errorString, "DDERR_GENERIC" );
break;
case DDERR_HEIGHTALIGN:
strcpy( errorString, "DDERR_HEIGHTALIGN" );
break;
case DDERR_INCOMPATIBLEPRIMARY:
strcpy( errorString, "DDERR_INCOMPATIBLEPRIMARY" );
break;
case DDERR_INVALIDCAPS:
strcpy( errorString, "DDERR_INVALIDCAPS" );
break;
case DDERR_INVALIDCLIPLIST:
strcpy( errorString, "DDERR_INVALIDCLIPLIST" );
break;
case DDERR_INVALIDMODE:
strcpy( errorString, "DDERR_INVALIDMODE" );
break;
case DDERR_INVALIDOBJECT:
strcpy( errorString, "DDERR_INVALIDOBJECT" );
break;
case DDERR_INVALIDPARAMS:
strcpy( errorString, "DDERR_INVALIDPARAMS" );
break;
case DDERR_INVALIDPIXELFORMAT:
strcpy( errorString, "DDERR_INVALIDPIXELFORMAT" );
break;
case DDERR_INVALIDRECT:
strcpy( errorString, "DDERR_INVALIDRECT" );
break;
case DDERR_LOCKEDSURFACES:
strcpy( errorString, "DDERR_LOCKEDSURFACES" );
break;
case DDERR_NO3D:
strcpy( errorString, "DDERR_NO3D" );
break;
case DDERR_NOALPHAHW:
strcpy( errorString, "DDERR_NOALPHAHW" );
break;
case DDERR_NOCLIPLIST:
strcpy( errorString, "DDERR_NOCLIPLIST" );
break;
case DDERR_NOCOLORCONVHW:
strcpy( errorString, "DDERR_NOCOLORCONVHW" );
break;
case DDERR_NOCOOPERATIVELEVELSET:
strcpy( errorString, "DDERR_NOCOOPERATIVELEVELSET" );
break;
case DDERR_NOCOLORKEY:
strcpy( errorString, "DDERR_NOCOLORKEY" );
break;
case DDERR_NOCOLORKEYHW:
strcpy( errorString, "DDERR_NOCOLORKEYHW" );
break;
case DDERR_NODIRECTDRAWSUPPORT:
strcpy( errorString, "DDERR_NODIRECTDRAWSUPPORT" );
break;
case DDERR_NOEXCLUSIVEMODE:
strcpy( errorString, "DDERR_NOEXCLUSIVEMODE" );
break;
case DDERR_NOFLIPHW:
strcpy( errorString, "DDERR_NOFLIPHW" );
break;
case DDERR_NOGDI:
strcpy( errorString, "DDERR_NOGDI" );
break;
case DDERR_NOMIRRORHW:
strcpy( errorString, "DDERR_NOMIRRORHW" );
break;
case DDERR_NOTFOUND:
strcpy( errorString, "DDERR_NOTFOUND" );
break;
case DDERR_NOOVERLAYHW:
strcpy( errorString, "DDERR_NOOVERLAYHW" );
break;
case DDERR_OVERLAPPINGRECTS:
strcpy( errorString, "DDERR_OVERLAPPINGRECTS" );
break;
case DDERR_NORASTEROPHW:
strcpy( errorString, "DDERR_NORASTEROPHW" );
break;
case DDERR_NOROTATIONHW:
strcpy( errorString, "DDERR_NOROTATIONHW" );
break;
case DDERR_NOSTRETCHHW:
strcpy( errorString, "DDERR_NOSTRETCHHW" );
break;
case DDERR_NOT4BITCOLOR:
strcpy( errorString, "DDERR_NOT4BITCOLOR" );
break;
case DDERR_NOT4BITCOLORINDEX:
strcpy( errorString, "DDERR_NOT4BITCOLORINDEX" );
break;
case DDERR_NOT8BITCOLOR:
strcpy( errorString, "DDERR_NOT8BITCOLOR" );
break;
case DDERR_NOTEXTUREHW:
strcpy( errorString, "DDERR_NOTEXTUREHW" );
break;
case DDERR_NOVSYNCHW:
strcpy( errorString, "DDERR_NOVSYNCHW" );
break;
case DDERR_NOZBUFFERHW:
strcpy( errorString, "DDERR_NOZBUFFERHW" );
break;
case DDERR_NOZOVERLAYHW:
strcpy( errorString, "DDERR_NOZOVERLAYHW" );
break;
case DDERR_OUTOFCAPS:
strcpy( errorString, "DDERR_OUTOFCAPS" );
break;
case DDERR_OUTOFMEMORY:
strcpy( errorString, "DDERR_OUTOFMEMORY" );
break;
case DDERR_OUTOFVIDEOMEMORY:
strcpy( errorString, "DDERR_OUTOFVIDEOMEMORY" );
break;
case DDERR_OVERLAYCANTCLIP:
strcpy( errorString, "DDERR_OVERLAYCANTCLIP" );
break;
case DDERR_OVERLAYCOLORKEYONLYONEACTIVE:
strcpy( errorString, "DDERR_OVERLAYCOLORKEYONLYONEACTIVE" );
break;
case DDERR_PALETTEBUSY:
strcpy( errorString, "DDERR_PALETTEBUSY" );
break;
case DDERR_COLORKEYNOTSET:
strcpy( errorString, "DDERR_COLORKEYNOTSET" );
break;
case DDERR_SURFACEALREADYATTACHED:
strcpy( errorString, "DDERR_SURFACEALREADYATTACHED" );
break;
case DDERR_SURFACEALREADYDEPENDENT:
strcpy( errorString, "DDERR_SURFACEALREADYDEPENDENT" );
break;
case DDERR_SURFACEBUSY:
strcpy( errorString, "DDERR_SURFACEBUSY" );
break;
case DDERR_CANTLOCKSURFACE:
strcpy( errorString, "DDERR_CANTLOCKSURFACE" );
break;
case DDERR_SURFACEISOBSCURED:
strcpy( errorString, "DDERR_SURFACEISOBSCURED" );
break;
case DDERR_SURFACELOST:
strcpy( errorString, "DDERR_SURFACELOST" );
break;
case DDERR_SURFACENOTATTACHED:
strcpy( errorString, "DDERR_SURFACENOTATTACHED" );
break;
case DDERR_TOOBIGHEIGHT:
strcpy( errorString, "DDERR_TOOBIGHEIGHT" );
break;
case DDERR_TOOBIGSIZE:
strcpy( errorString, "DDERR_TOOBIGSIZE" );
break;
case DDERR_TOOBIGWIDTH:
strcpy( errorString, "DDERR_TOOBIGWIDTH" );
break;
case DDERR_UNSUPPORTED:
strcpy( errorString, "DDERR_UNSUPPORTED" );
break;
case DDERR_UNSUPPORTEDFORMAT:
strcpy( errorString, "DDERR_UNSUPPORTEDFORMAT" );
break;
case DDERR_UNSUPPORTEDMASK:
strcpy( errorString, "DDERR_UNSUPPORTEDMASK" );
break;
case DDERR_INVALIDSTREAM:
strcpy( errorString, "DDERR_INVALIDSTREAM" );
break;
case DDERR_VERTICALBLANKINPROGRESS:
strcpy( errorString, "DDERR_VERTICALBLANKINPROGRESS" );
break;
case DDERR_WASSTILLDRAWING:
strcpy( errorString, "DDERR_WASSTILLDRAWING" );
break;
case DDERR_XALIGN:
strcpy( errorString, "DDERR_XALIGN" );
break;
case DDERR_INVALIDDIRECTDRAWGUID:
strcpy( errorString, "DDERR_INVALIDDIRECTDRAWGUID" );
break;
case DDERR_DIRECTDRAWALREADYCREATED:
strcpy( errorString, "DDERR_DIRECTDRAWALREADYCREATED" );
break;
case DDERR_NODIRECTDRAWHW:
strcpy( errorString, "DDERR_NODIRECTDRAWHW" );
break;
case DDERR_PRIMARYSURFACEALREADYEXISTS:
strcpy( errorString, "DDERR_PRIMARYSURFACEALREADYEXISTS" );
break;
case DDERR_NOEMULATION:
strcpy( errorString, "DDERR_NOEMULATION" );
break;
case DDERR_REGIONTOOSMALL:
strcpy( errorString, "DDERR_REGIONTOOSMALL" );
break;
case DDERR_CLIPPERISUSINGHWND:
strcpy( errorString, "DDERR_CLIPPERISUSINGHWND" );
break;
case DDERR_NOCLIPPERATTACHED:
strcpy( errorString, "DDERR_NOCLIPPERATTACHED" );
break;
case DDERR_NOHWND:
strcpy( errorString, "DDERR_NOHWND" );
break;
case DDERR_HWNDSUBCLASSED:
strcpy( errorString, "DDERR_HWNDSUBCLASSED" );
break;
case DDERR_HWNDALREADYSET:
strcpy( errorString, "DDERR_HWNDALREADYSET" );
break;
case DDERR_NOPALETTEATTACHED:
strcpy( errorString, "DDERR_NOPALETTEATTACHED" );
break;
case DDERR_NOPALETTEHW:
strcpy( errorString, "DDERR_NOPALETTEHW" );
break;
case DDERR_BLTFASTCANTCLIP:
strcpy( errorString, "DDERR_BLTFASTCANTCLIP" );
break;
case DDERR_NOBLTHW:
strcpy( errorString, "DDERR_NOBLTHW" );
break;
case DDERR_NODDROPSHW:
strcpy( errorString, "DDERR_NODDROPSHW" );
break;
case DDERR_OVERLAYNOTVISIBLE:
strcpy( errorString, "DDERR_OVERLAYNOTVISIBLE" );
break;
case DDERR_NOOVERLAYDEST:
strcpy( errorString, "DDERR_NOOVERLAYDEST" );
break;
case DDERR_INVALIDPOSITION:
strcpy( errorString, "DDERR_INVALIDPOSITION" );
break;
case DDERR_NOTAOVERLAYSURFACE:
strcpy( errorString, "DDERR_NOTAOVERLAYSURFACE" );
break;
case DDERR_EXCLUSIVEMODEALREADYSET:
strcpy( errorString, "DDERR_EXCLUSIVEMODEALREADYSET" );
break;
case DDERR_NOTFLIPPABLE:
strcpy( errorString, "DDERR_NOTFLIPPABLE" );
break;
case DDERR_CANTDUPLICATE:
strcpy( errorString, "DDERR_CANTDUPLICATE" );
break;
case DDERR_NOTLOCKED:
strcpy( errorString, "DDERR_NOTLOCKED" );
break;
case DDERR_CANTCREATEDC:
strcpy( errorString, "DDERR_CANTCREATEDC" );
break;
case DDERR_NODC:
strcpy( errorString, "DDERR_NODC" );
break;
case DDERR_WRONGMODE:
strcpy( errorString, "DDERR_WRONGMODE" );
break;
case DDERR_IMPLICITLYCREATED:
strcpy( errorString, "DDERR_IMPLICITLYCREATED" );
break;
case DDERR_NOTPALETTIZED:
strcpy( errorString, "DDERR_NOTPALETTIZED" );
break;
case DDERR_UNSUPPORTEDMODE:
strcpy( errorString, "DDERR_UNSUPPORTEDMODE" );
break;
case DDERR_NOMIPMAPHW:
strcpy( errorString, "DDERR_NOMIPMAPHW" );
break;
case DDERR_INVALIDSURFACETYPE:
strcpy( errorString, "DDERR_INVALIDSURFACETYPE" );
break;
case DDERR_NOOPTIMIZEHW:
strcpy( errorString, "DDERR_NOOPTIMIZEHW" );
break;
case DDERR_NOTLOADED:
strcpy( errorString, "DDERR_NOTLOADED" );
break;
case DDERR_NOFOCUSWINDOW:
strcpy( errorString, "DDERR_NOFOCUSWINDOW" );
break;
case DDERR_DCALREADYCREATED:
strcpy( errorString, "DDERR_DCALREADYCREATED" );
break;
case DDERR_NONONLOCALVIDMEM:
strcpy( errorString, "DDERR_NONONLOCALVIDMEM" );
break;
case DDERR_CANTPAGELOCK:
strcpy( errorString, "DDERR_CANTPAGELOCK" );
break;
case DDERR_CANTPAGEUNLOCK:
strcpy( errorString, "DDERR_CANTPAGEUNLOCK" );
break;
case DDERR_NOTPAGELOCKED:
strcpy( errorString, "DDERR_NOTPAGELOCKED" );
break;
case DDERR_MOREDATA:
strcpy( errorString, "DDERR_MOREDATA" );
break;
case DDERR_EXPIRED:
strcpy( errorString, "DDERR_EXPIRED" );
break;
case DDERR_VIDEONOTACTIVE:
strcpy( errorString, "DDERR_VIDEONOTACTIVE" );
break;
case DDERR_DEVICEDOESNTOWNSURFACE:
strcpy( errorString, "DDERR_DEVICEDOESNTOWNSURFACE" );
break;
case DDERR_NOTINITIALIZED:
strcpy( errorString, "DDERR_NOTINITIALIZED" );
break;
default:
strcpy( errorString, "<unknown error code>" );
break;
}
return &errorString[0];
}

File diff suppressed because it is too large Load Diff

View File

@ -1,399 +0,0 @@
/*===========================================================================*/
/* */
/* Mesa-3.0 DirectX 6 Driver */
/* */
/* By Leigh McRae */
/* */
/* http://www.altsoftware.com/ */
/* */
/* Copyright (c) 1999-1998 alt.software inc. All Rights Reserved */
/*===========================================================================*/
#include "D3DMesa.h"
/*===========================================================================*/
/* This call will clear the render surface using the pixel info built from */
/* the surface at creation time. The call uses Lock/Unlock to access the */
/* surface. The call also special cases a full clear or a dirty rectangle. */
/* Finally the call returns the new clear mask that reflects that the color */
/* buffer was cleared. */
/*===========================================================================*/
/* RETURN: the original mask with the bits cleared that represents the buffer*/
/* or buffers we just cleared. */
/*===========================================================================*/
GLbitfield ClearBuffers( GLcontext *ctx, GLbitfield mask, GLboolean all, GLint x, GLint y, GLint width, GLint height )
{
D3DMESACONTEXT *pContext = (D3DMESACONTEXT *)ctx->DriverCtx;
DDSURFACEDESC2 *pddsd2;
UCHAR *pBuffer,
*pScanLine;
int index,
index2;
DWORD dwColor;
if ( mask & GL_COLOR_BUFFER_BIT )
{
/* Lock the surface to get the surface pointer. */
pddsd2 = LockHAL( pContext->pShared, TRUE );
/* Solve the color once only. */
dwColor = ( ((DWORD)((float)pContext->rClear * pContext->pShared->pixel.rScale)) << pContext->pShared->pixel.rShift );
dwColor |= ( ((DWORD)((float)pContext->gClear * pContext->pShared->pixel.gScale)) << pContext->pShared->pixel.gShift );
dwColor |= ( ((DWORD)((float)pContext->bClear * pContext->pShared->pixel.bScale)) << pContext->pShared->pixel.bShift );
if ( all )
{
for( index = 0, pScanLine = (UCHAR *)pddsd2->lpSurface; index < pContext->pShared->dwHeight; index++, pScanLine += pddsd2->lPitch )
for( pBuffer = pScanLine, index2 = 0; index2 < pContext->pShared->dwWidth; index2++, pBuffer += pContext->pShared->pixel.cb )
memcpy( pBuffer, &dwColor, pContext->pShared->pixel.cb );
}
else
{
pScanLine = ((UCHAR *)pddsd2->lpSurface) +
( (FLIP( pContext->pShared->dwHeight, (y+height)) * pddsd2->lPitch) + (x * pContext->pShared->pixel.cb) );
for( index = 0; index < height; index++, pScanLine += pddsd2->lPitch )
{
for( index2 = 0, pBuffer = pScanLine; index2 < width; index2++, pBuffer += pContext->pShared->pixel.cb )
memcpy( pBuffer, &dwColor, pContext->pShared->pixel.cb );
}
}
UnlockHAL( pContext->pShared, TRUE );
}
return (mask & ~GL_COLOR_BUFFER_BIT);
}
/*===========================================================================*/
/* This proc (as all others) has been written for the general case. I use */
/* the PIXELINFO structure to pack the pixel from RGB24 to whatever the Off- */
/* Screen render surface uses. The alpha is ignored as Mesa does it in SW. */
/*===========================================================================*/
/* RETURN: */
/*===========================================================================*/
void WSpanRGB( const GLcontext* ctx, GLuint n, GLint x, GLint y, const GLubyte rgb[][3], const GLubyte mask[] )
{
D3DMESACONTEXT *pContext = (D3DMESACONTEXT *)ctx->DriverCtx;
DDSURFACEDESC2 *pddsd2;
UCHAR *pBuffer;
int index;
DWORD dwColor;
/* Get the surface pointer and the pitch. */
pddsd2 = LockHAL( pContext->pShared, TRUE );
/* Find the start of the span. Invert y for Windows. */
pBuffer = (UCHAR *)pddsd2->lpSurface + (FLIP(pContext->pShared->dwHeight,y) * pddsd2->lPitch) + (x*pContext->pShared->pixel.cb);
if ( mask )
{
for( index = 0; index < n; index++, pBuffer += pContext->pShared->pixel.cb )
{
if ( mask[index] )
{
/* Pack the color components. */
dwColor = ( ((DWORD)((float)rgb[index][RCOMP] * pContext->pShared->pixel.rScale)) << pContext->pShared->pixel.rShift );
dwColor |= ( ((DWORD)((float)rgb[index][GCOMP] * pContext->pShared->pixel.gScale)) << pContext->pShared->pixel.gShift );
dwColor |= ( ((DWORD)((float)rgb[index][BCOMP] * pContext->pShared->pixel.bScale)) << pContext->pShared->pixel.bShift );
memcpy( pBuffer, &dwColor, pContext->pShared->pixel.cb );
}
}
}
else
{
for( index = 0; index < n; index++, pBuffer += pContext->pShared->pixel.cb )
{
/* Pack the color components. */
dwColor = ( ((DWORD)((float)rgb[index][RCOMP] * pContext->pShared->pixel.rScale)) << pContext->pShared->pixel.rShift );
dwColor |= ( ((DWORD)((float)rgb[index][GCOMP] * pContext->pShared->pixel.gScale)) << pContext->pShared->pixel.gShift );
dwColor |= ( ((DWORD)((float)rgb[index][BCOMP] * pContext->pShared->pixel.bScale)) << pContext->pShared->pixel.bShift );
memcpy( pBuffer, &dwColor, pContext->pShared->pixel.cb );
}
}
/* Giver back. */
UnlockHAL( pContext->pShared, TRUE );
}
/*===========================================================================*/
/* This proc (as all others) has been written for the general case. I use */
/* the PIXELINFO structure to pack the pixel from RGB24 to whatever the Off- */
/* Screen render surface uses. The alpha is ignored as Mesa does it in SW. */
/*===========================================================================*/
/* RETURN: */
/*===========================================================================*/
void WSpanRGBA( const GLcontext* ctx, GLuint n, GLint x, GLint y, const GLubyte rgba[][4], const GLubyte mask[] )
{
D3DMESACONTEXT *pContext = (D3DMESACONTEXT *)ctx->DriverCtx;
DDSURFACEDESC2 *pddsd2;
UCHAR *pBuffer;
int index;
DWORD dwColor;
/* Get the surface pointer and the pitch. */
pddsd2 = LockHAL( pContext->pShared, TRUE );
/* Find the start of the span. Invert y for Windows. */
pBuffer = (UCHAR *)pddsd2->lpSurface + (FLIP(pContext->pShared->dwHeight,y) * pddsd2->lPitch) + (x*pContext->pShared->pixel.cb);
if ( mask )
{
for( index = 0; index < n; index++, pBuffer += pContext->pShared->pixel.cb )
{
if ( mask[index] )
{
/* Pack the color components. */
dwColor = ( ((DWORD)((float)rgba[index][RCOMP] * pContext->pShared->pixel.rScale)) << pContext->pShared->pixel.rShift );
dwColor |= ( ((DWORD)((float)rgba[index][GCOMP] * pContext->pShared->pixel.gScale)) << pContext->pShared->pixel.gShift );
dwColor |= ( ((DWORD)((float)rgba[index][BCOMP] * pContext->pShared->pixel.bScale)) << pContext->pShared->pixel.bShift );
memcpy( pBuffer, &dwColor, pContext->pShared->pixel.cb );
}
}
}
else
{
for( index = 0; index < n; index++, pBuffer += pContext->pShared->pixel.cb )
{
/* Pack the color components. */
dwColor = ( ((DWORD)((float)rgba[index][RCOMP] * pContext->pShared->pixel.rScale)) << pContext->pShared->pixel.rShift );
dwColor |= ( ((DWORD)((float)rgba[index][GCOMP] * pContext->pShared->pixel.gScale)) << pContext->pShared->pixel.gShift );
dwColor |= ( ((DWORD)((float)rgba[index][BCOMP] * pContext->pShared->pixel.bScale)) << pContext->pShared->pixel.bShift );
memcpy( pBuffer, &dwColor, pContext->pShared->pixel.cb );
}
}
/* Giver back. */
UnlockHAL( pContext->pShared, TRUE );
}
/*===========================================================================*/
/* This proc (as all others) has been written for the general case. I use */
/* the PIXELINFO structure to pack the pixel from RGB24 to whatever the Off- */
/* Screen render surface uses. The color is solved once from the current */
/* color components. The alpha is ignored as Mesa is doing it in SW. */
/*===========================================================================*/
/* RETURN: */
/*===========================================================================*/
void WSpanRGBAMono( const GLcontext* ctx, GLuint n, GLint x, GLint y, const GLubyte mask[] )
{
D3DMESACONTEXT *pContext = (D3DMESACONTEXT *)ctx->DriverCtx;
DDSURFACEDESC2 *pddsd2;
UCHAR *pBuffer;
int index;
DWORD dwColor;
/* Lock the surface to get the surface pointer and the pitch. */
pddsd2 = LockHAL( pContext->pShared, TRUE );
/* Solve the color once only. (no alpha) */
dwColor = ( ((DWORD)((float)pContext->rCurrent * pContext->pShared->pixel.rScale)) << pContext->pShared->pixel.rShift );
dwColor |= ( ((DWORD)((float)pContext->gCurrent * pContext->pShared->pixel.gScale)) << pContext->pShared->pixel.gShift );
dwColor |= ( ((DWORD)((float)pContext->bCurrent * pContext->pShared->pixel.bScale)) << pContext->pShared->pixel.bShift );
/* Find the start of the span. Invert y for Windows. */
pBuffer = (UCHAR *)pddsd2->lpSurface + (FLIP(pContext->pShared->dwHeight,y) * pddsd2->lPitch) + (x*pContext->pShared->pixel.cb);
if ( mask )
{
for( index = 0; index < n; index++, pBuffer += pContext->pShared->pixel.cb )
if ( mask[index] )
memcpy( pBuffer, &dwColor, pContext->pShared->pixel.cb );
}
else
{
for( index = 0; index < n; index++, pBuffer += pContext->pShared->pixel.cb )
memcpy( pBuffer, &dwColor, pContext->pShared->pixel.cb );
}
/* Giver back. */
UnlockHAL( pContext->pShared, TRUE );
}
/*===========================================================================*/
/* This proc (as all others) has been written for the general case. I use */
/* the PIXELINFO structure to pack the pixel from RGB24 to whatever the Off- */
/* Screen render surface uses. The alpha is ignored as Mesa does it in SW. */
/*===========================================================================*/
/* RETURN: */
/*===========================================================================*/
void WPixelsRGBA( const GLcontext* ctx, GLuint n, const GLint x[], const GLint y[], const GLubyte rgba[][4], const GLubyte mask[] )
{
D3DMESACONTEXT *pContext = (D3DMESACONTEXT *)ctx->DriverCtx;
DDSURFACEDESC2 *pddsd2;
UCHAR *pBuffer;
int index;
DWORD dwColor;
/* Get the surface pointer and the pitch. */
pddsd2 = LockHAL( pContext->pShared, TRUE );
if ( mask )
{
for( index = 0; index < n; index++ )
{
if ( mask[index] )
{
/* Pack the color components. */
dwColor = ( ((DWORD)((float)rgba[index][RCOMP] * pContext->pShared->pixel.rScale)) << pContext->pShared->pixel.rShift );
dwColor |= ( ((DWORD)((float)rgba[index][GCOMP] * pContext->pShared->pixel.gScale)) << pContext->pShared->pixel.gShift );
dwColor |= ( ((DWORD)((float)rgba[index][BCOMP] * pContext->pShared->pixel.bScale)) << pContext->pShared->pixel.bShift );
/* Find the pixel. Invert y for Windows. */
pBuffer = (UCHAR *)pddsd2->lpSurface + (FLIP(pContext->pShared->dwHeight,y[index]) * pddsd2->lPitch) + (x[index]*pContext->pShared->pixel.cb);
memcpy( pBuffer, &dwColor, pContext->pShared->pixel.cb );
}
}
}
else
{
for( index = 0; index < n; index++ )
{
/* Pack the color components. */
dwColor = ( ((DWORD)((float)rgba[index][RCOMP] * pContext->pShared->pixel.rScale)) << pContext->pShared->pixel.rShift );
dwColor |= ( ((DWORD)((float)rgba[index][GCOMP] * pContext->pShared->pixel.gScale)) << pContext->pShared->pixel.gShift );
dwColor |= ( ((DWORD)((float)rgba[index][BCOMP] * pContext->pShared->pixel.bScale)) << pContext->pShared->pixel.bShift );
/* Find the pixel. Invert y for Windows. */
pBuffer = (UCHAR *)pddsd2->lpSurface + (FLIP(pContext->pShared->dwHeight,y[index]) * pddsd2->lPitch) + (x[index]*pContext->pShared->pixel.cb);
memcpy( pBuffer, &dwColor, pContext->pShared->pixel.cb );
}
}
/* Giver back. */
UnlockHAL( pContext->pShared, TRUE );
}
/*===========================================================================*/
/* This proc (as all others) has been written for the general case. I use */
/* the PIXELINFO structure to pack the pixel from RGB24 to whatever the Off- */
/* Screen render surface uses. The color is solved once from the current */
/* color components. The alpha is ignored as Mesa is doing it in SW. */
/*===========================================================================*/
/* RETURN: */
/*===========================================================================*/
void WPixelsRGBAMono( const GLcontext* ctx, GLuint n, const GLint x[], const GLint y[], const GLubyte mask[] )
{
D3DMESACONTEXT *pContext = (D3DMESACONTEXT *)ctx->DriverCtx;
DDSURFACEDESC2 *pddsd2;
UCHAR *pBuffer;
int index;
DWORD dwColor;
/* Get the surface pointer and the pitch. */
pddsd2 = LockHAL( pContext->pShared, TRUE );
/* Solve the color once only. I don't uses the alpha. */
dwColor = ( ((DWORD)((float)pContext->rCurrent * pContext->pShared->pixel.rScale)) << pContext->pShared->pixel.rShift );
dwColor |= ( ((DWORD)((float)pContext->gCurrent * pContext->pShared->pixel.gScale)) << pContext->pShared->pixel.gShift );
dwColor |= ( ((DWORD)((float)pContext->bCurrent * pContext->pShared->pixel.bScale)) << pContext->pShared->pixel.bShift );
if ( mask )
{
/* We store the surface pointer as a UCHAR so that pixel.cb (count in btyles) will work for all. */
for( index = 0; index < n; index++ )
{
if ( mask[index] )
{
/* Find the pixel. Invert y for Windows. */
pBuffer = (UCHAR *)pddsd2->lpSurface + (FLIP(pContext->pShared->dwHeight,y[index]) * pddsd2->lPitch) + (x[index]*pContext->pShared->pixel.cb);
memcpy( pBuffer, &dwColor, pContext->pShared->pixel.cb );
}
}
}
else
{
/* We store the surface pointer as a UCHAR so that pixel.cb (count in btyles) will work for all. */
for( index = 0; index < n; index++ )
{
/* Find the pixel. Invert y for Windows. */
pBuffer = (UCHAR *)pddsd2->lpSurface + (FLIP(pContext->pShared->dwHeight,y[index]) * pddsd2->lPitch) + (x[index]*pContext->pShared->pixel.cb);
memcpy( pBuffer, &dwColor, pContext->pShared->pixel.cb );
}
}
/* Giver back. */
UnlockHAL( pContext->pShared, TRUE );
}
/*===========================================================================*/
/* This proc isn't written for speed rather its to handle the general case. */
/* I grab each pixel from the surface and unpack the info using the PIXELINFO*/
/* structure that was generated from the OffScreen surface pixelformat. The */
/* function will not fill in the alpha value as Mesa I have Mesa allocate its*/
/* own alpha channel when the context was created. I did this as I didn't */
/* feel that it was worth the effort to try and get HW to work (bus bound). */
/*===========================================================================*/
/* RETURN: */
/*===========================================================================*/
void RSpanRGBA( const GLcontext* ctx, GLuint n, GLint x, GLint y, GLubyte rgba[][4] )
{
D3DMESACONTEXT *pContext = (D3DMESACONTEXT *)ctx->DriverCtx;
DDSURFACEDESC2 *pddsd2;
UCHAR *pBuffer;
int index;
DWORD *pdwColor;
/* Get the surface pointer and the pitch. */
pddsd2 = LockHAL( pContext->pShared, TRUE );
/* Find the start of the span. Invert y for Windows. */
pBuffer = (UCHAR *)pddsd2->lpSurface +
(FLIP(pContext->pShared->dwHeight,y) * pddsd2->lPitch) +
(x*pContext->pShared->pixel.cb);
/* We store the surface pointer as a UCHAR so that pixel.cb (count in btyles) will work for all. */
for( index = 0; index < n; index++, pBuffer += pContext->pShared->pixel.cb )
{
pdwColor = (DWORD *)pBuffer;
rgba[index][RCOMP] = (GLubyte)((float)((*pdwColor & pContext->pShared->pixel.dwRMask) >> pContext->pShared->pixel.rShift) / pContext->pShared->pixel.rScale);
rgba[index][GCOMP] = (GLubyte)((float)((*pdwColor & pContext->pShared->pixel.dwGMask) >> pContext->pShared->pixel.gShift) / pContext->pShared->pixel.gScale);
rgba[index][BCOMP] = (GLubyte)((float)((*pdwColor & pContext->pShared->pixel.dwBMask) >> pContext->pShared->pixel.bShift) / pContext->pShared->pixel.bScale);
}
/* Giver back. */
UnlockHAL( pContext->pShared, TRUE );
}
/*===========================================================================*/
/* This proc isn't written for speed rather its to handle the general case. */
/* I grab each pixel from the surface and unpack the info using the PIXELINFO*/
/* structure that was generated from the OffScreen surface pixelformat. The */
/* function will not fill in the alpha value as Mesa I have Mesa allocate its*/
/* own alpha channel when the context was created. I did this as I didn't */
/* feel that it was worth the effort to try and get HW to work (bus bound). */
/*===========================================================================*/
/* RETURN: */
/*===========================================================================*/
void RPixelsRGBA( const GLcontext* ctx, GLuint n, const GLint x[], const GLint y[], GLubyte rgba[][4], const GLubyte mask[] )
{
D3DMESACONTEXT *pContext = (D3DMESACONTEXT *)ctx->DriverCtx;
DDSURFACEDESC2 *pddsd2;
int index;
DWORD *pdwColor;
/* Get the surface pointer and the pitch. */
pddsd2 = LockHAL( pContext->pShared, TRUE );
if ( mask )
{
/* We store the surface pointer as a UCHAR so that pixel.cb (count in btyles) will work for all. */
for( index = 0; index < n; index++ )
{
if ( mask[index] )
{
/* Find the start of the pixel. Invert y for Windows. */
pdwColor = (DWORD *)((UCHAR *)pddsd2->lpSurface + (FLIP(pContext->pShared->dwHeight,y[index]) * pddsd2->lPitch) + (x[index]*pContext->pShared->pixel.cb));
rgba[index][RCOMP] = (GLubyte)((float)((*pdwColor & pContext->pShared->pixel.dwRMask) >> pContext->pShared->pixel.rShift) / pContext->pShared->pixel.rScale);
rgba[index][GCOMP] = (GLubyte)((float)((*pdwColor & pContext->pShared->pixel.dwGMask) >> pContext->pShared->pixel.gShift) / pContext->pShared->pixel.gScale);
rgba[index][BCOMP] = (GLubyte)((float)((*pdwColor & pContext->pShared->pixel.dwBMask) >> pContext->pShared->pixel.bShift) / pContext->pShared->pixel.bScale);
}
}
}
else
{
/* We store the surface pointer as a UCHAR so that pixel.cb (count in btyles) will work for all. */
for( index = 0; index < n; index++ )
{
/* Find the start of the pixel. Invert y for Windows. */
pdwColor = (DWORD *)((UCHAR *)pddsd2->lpSurface + (FLIP(pContext->pShared->dwHeight,y[index]) * pddsd2->lPitch) + (x[index]*pContext->pShared->pixel.cb));
rgba[index][RCOMP] = (GLubyte)((float)((*pdwColor & pContext->pShared->pixel.dwRMask) >> pContext->pShared->pixel.rShift) / pContext->pShared->pixel.rScale);
rgba[index][GCOMP] = (GLubyte)((float)((*pdwColor & pContext->pShared->pixel.dwGMask) >> pContext->pShared->pixel.gShift) / pContext->pShared->pixel.gScale);
rgba[index][BCOMP] = (GLubyte)((float)((*pdwColor & pContext->pShared->pixel.dwBMask) >> pContext->pShared->pixel.bShift) / pContext->pShared->pixel.bScale);
}
}
/* Giver back. */
UnlockHAL( pContext->pShared, TRUE );
}

View File

@ -1,143 +0,0 @@
/*===========================================================================*/
/* */
/* Mesa-3.0 DirectX 6 Driver */
/* */
/* By Leigh McRae */
/* */
/* http://www.altsoftware.com/ */
/* */
/* Copyright (c) 1999-1998 alt.software inc. All Rights Reserved */
/*===========================================================================*/
#include "Debug.h"
/*===========================================================================*/
/* Global variables. */
/*===========================================================================*/
DWORD g_DBGMask = DBG_ALL_ERROR;
/*===========================================================================*/
/* This is your basic DPF function with printf like support. The function */
/* also works with a global debug mask variable. I have written support that*/
/* allows for the user's enviroment variable space to be read and set the */
/* masks. This is done when the dll starts and is only in the debug version.*/
/*===========================================================================*/
/* RETURN: */
/*===========================================================================*/
void _cdecl DebugPrint( int mask, char *pszFormat, ... )
{
char buffer[512];
va_list args;
/* A mask of 0 will always pass. Easy to remeber. */
if ( (mask == 0) || (mask & g_DBGMask) )
{
va_start( args, pszFormat );
if ( mask & DBG_ALL_ERROR )
OutputDebugString( "MesaD3D: (ERROR)" );
else
OutputDebugString( "MesaD3D: " );
vsprintf( buffer, pszFormat, args );
strcat( buffer, "\n" );
OutputDebugString( buffer );
va_end( args );
}
}
/*===========================================================================*/
/* This call reads the users enviroment variables and sets any debug mask */
/* that they have set to TRUE. Now the value must be "TRUE". */
/*===========================================================================*/
/* RETURN: */
/*===========================================================================*/
void ReadDBGEnv( void )
{
g_DBGMask = DBG_ALL_ERROR;
#define IS_VAR_SET(v) if ( getenv( # v ) && !strcmp(getenv( # v ),"TRUE") ) g_DBGMask |= v;
IS_VAR_SET( DBG_FUNC );
IS_VAR_SET( DBG_STATES );
IS_VAR_SET( DBG_CNTX_INFO );
IS_VAR_SET( DBG_CNTX_WARN );
IS_VAR_SET( DBG_CNTX_PROFILE );
IS_VAR_SET( DBG_CNTX_ERROR );
IS_VAR_SET( DBG_CNTX_ALL );
IS_VAR_SET( DBG_PRIM_INFO );
IS_VAR_SET( DBG_PRIM_WARN );
IS_VAR_SET( DBG_PRIM_PROFILE );
IS_VAR_SET( DBG_PRIM_ERROR );
IS_VAR_SET( DBG_PRIM_ALL );
IS_VAR_SET( DBG_TXT_INFO );
IS_VAR_SET( DBG_TXT_WARN );
IS_VAR_SET( DBG_TXT_PROFILE );
IS_VAR_SET( DBG_TXT_ERROR );
IS_VAR_SET( DBG_TXT_ALL );
IS_VAR_SET( DBG_ALL_INFO );
IS_VAR_SET( DBG_ALL_WARN );
IS_VAR_SET( DBG_ALL_PROFILE );
IS_VAR_SET( DBG_ALL_ERROR );
IS_VAR_SET( DBG_ALL );
#undef IS_VAR_SET
}
/*===========================================================================*/
/* This function will take a pointer to a DDSURFACEDESC2 structure & display*/
/* the parsed information using a DPF call. */
/*===========================================================================*/
/* RETURN: */
/*===========================================================================*/
void DebugPixelFormat( char *pszSurfaceName, DDPIXELFORMAT *pddpf )
{
char buffer[256];
/* Parse the flag type and write the string equivalent. */
if ( pddpf->dwFlags & DDPF_ALPHA )
strcat( buffer, "DDPF_ALPHA " );
if ( pddpf->dwFlags & DDPF_ALPHAPIXELS )
strcat( buffer, "DDPF_ALPHAPIXELS " );
if ( pddpf->dwFlags & DDPF_ALPHAPREMULT )
strcat( buffer, "DDPF_ALPHAPREMULT " );
if ( pddpf->dwFlags & DDPF_BUMPLUMINANCE )
strcat( buffer, "DDPF_BUMPLUMINANCE " );
if ( pddpf->dwFlags & DDPF_BUMPDUDV )
strcat( buffer, "DDPF_BUMPDUDV " );
if ( pddpf->dwFlags & DDPF_COMPRESSED )
strcat( buffer, "DDPF_COMPRESSED " );
if ( pddpf->dwFlags & DDPF_FOURCC )
strcat( buffer, "DDPF_FOURCC " );
if ( pddpf->dwFlags & DDPF_LUMINANCE )
strcat( buffer, "DDPF_LUMINANCE " );
if ( pddpf->dwFlags & DDPF_PALETTEINDEXED1 )
strcat( buffer, "DDPF_PALETTEINDEXED1 " );
if ( pddpf->dwFlags & DDPF_PALETTEINDEXED2 )
strcat( buffer, "DDPF_PALETTEINDEXED2 " );
if ( pddpf->dwFlags & DDPF_PALETTEINDEXED4 )
strcat( buffer, "DDPF_PALETTEINDEXED4 " );
if ( pddpf->dwFlags & DDPF_PALETTEINDEXED8 )
strcat( buffer, "DDPF_PALETTEINDEXED8 " );
if ( pddpf->dwFlags & DDPF_PALETTEINDEXEDTO8 )
strcat( buffer, "DDPF_PALETTEINDEXEDTO8 " );
if ( pddpf->dwFlags & DDPF_RGB )
strcat( buffer, "DDPF_RGB " );
if ( pddpf->dwFlags & DDPF_RGBTOYUV )
strcat( buffer, "DDPF_RGBTOYUV " );
if ( pddpf->dwFlags & DDPF_STENCILBUFFER )
strcat( buffer, "DDPF_STENCILBUFFER " );
if ( pddpf->dwFlags & DDPF_YUV )
strcat( buffer, "DDPF_YUV " );
if ( pddpf->dwFlags & DDPF_ZBUFFER )
strcat( buffer, "DDPF_ZBUFFER " );
if ( pddpf->dwFlags & DDPF_ZPIXELS )
strcat( buffer, "DDPF_ZPIXELS " );
DPF(( (DBG_TXT_INFO|DBG_CNTX_INFO),"%s", buffer ));
}

View File

@ -1,90 +0,0 @@
/*===========================================================================*/
/* */
/* Mesa-3.0 DirectX 6 Driver */
/* */
/* By Leigh McRae */
/* */
/* http://www.altsoftware.com/ */
/* */
/* Copyright (c) 1999-1998 alt.software inc. All Rights Reserved */
/*===========================================================================*/
#ifndef _DEBUG_H
#define _DEBUG_H
#ifdef __cplusplus
extern "C" {
#endif
/*===========================================================================*/
/* Includes. */
/*===========================================================================*/
#include <stdio.h>
#include <string.h>
#include <ddraw.h>
#include <d3d.h>
#include "D3DShared.h"
/*===========================================================================*/
/* Magic numbers. */
/*===========================================================================*/
/*===========================================================================*/
/* Macros defines. */
/*===========================================================================*/
#define DBG_FUNC 0x00000001
#define DBG_STATES 0x00000002
#define DBG_CNTX_INFO 0x00000010
#define DBG_CNTX_WARN 0x00000020
#define DBG_CNTX_PROFILE 0x00000040
#define DBG_CNTX_ERROR 0x00000080
#define DBG_CNTX_ALL 0x000000F0
#define DBG_PRIM_INFO 0x00000100
#define DBG_PRIM_WARN 0x00000200
#define DBG_PRIM_PROFILE 0x00000400
#define DBG_PRIM_ERROR 0x00000800
#define DBG_PRIM_ALL 0x00000F00
#define DBG_TXT_INFO 0x00001000
#define DBG_TXT_WARN 0x00002000
#define DBG_TXT_PROFILE 0x00004000
#define DBG_TXT_ERROR 0x00008000
#define DBG_TXT_ALL 0x0000F000
#define DBG_ALL_INFO 0x11111110
#define DBG_ALL_WARN 0x22222220
#define DBG_ALL_PROFILE 0x44444440
#define DBG_ALL_ERROR 0x88888880
#define DBG_ALL 0xFFFFFFFF
#ifdef D3D_DEBUG
# define DPF(arg) DebugPrint arg
# define RIP(pH,msg,err) OutputDebugString(msg); \
OutputDebugString(err); \
OutputDebugString("\n"); \
FatalShutDown(pH)
#else
# define DPF(arg)
# define RIP(pH,msg,err) FatalShutDown(pH)
#endif
/*===========================================================================*/
/* Type defines. */
/*===========================================================================*/
/*===========================================================================*/
/* Function prototypes. */
/*===========================================================================*/
extern void ReadDBGEnv( void );
extern void _cdecl DebugPrint( int mask, char *pszFormat, ... );
extern void DebugPixelFormat( char *pszSurfaceName, DDPIXELFORMAT *pddpf );
/*===========================================================================*/
/* Global variables. */
/*===========================================================================*/
extern DWORD g_DBGMask;
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,25 +0,0 @@
SET DBG_FUNC=FALSE
SET DBG_CNTX_INFO=TRUE
SET DBG_CNTX_WARN=TRUE
SET DBG_CNTX_PROFILE=FALSE
SET DBG_CNTX_ERROR=TRUE
SET DBG_CNTX_ALL=TRUE
SET DBG_PRIM_INFO=FALSE
SET DBG_PRIM_WARN=FALSE
SET DBG_PRIM_PROFILE=FALSE
SET DBG_PRIM_ERROR=TRUE
SET DBG_PRIM_ALL=FALSE
SET DBG_TXT_INFO=FALSE
SET DBG_TXT_WARN=TRUE
SET DBG_TXT_PROFILE=FALSE
SET DBG_TXT_ERROR=TRUE
SET DBG_TXT_ALL=FALSE
SET DBG_ALL_INFO=FALSE
SET DBG_ALL_WARN=TRUE
SET DBG_ALL_PROFILE=FALSE
SET DBG_ALL_ERROR=TRUE
SET DBG_ALL=FALSE

View File

@ -1,101 +0,0 @@
##############################################################################
#
# Mesa-3.0 Makefile for DirectX 6 Driver
#
# By Leigh McRae
#
# http://www.altsoftware.com/
#
# Copyright (c) 1999-1998 alt.software inc. All Rights Reserved
##############################################################################
NAME=
TARGET= WGL Driver (D3DHAL)
D3D_DIR=$(MAKEDIR)\D3D
TARGET_DIR=e:\WinNT\System32
TEMP_DIR=c:\Temp
SPACE=-
LINKER=link.exe
INCLUDE=$(SDKROOT)\include;$(INCLUDE)
LIB=$(SDKROOT)\lib;$(LIB)
##############################################################################
CFLAGS = /c /nologo /W1 /G5 /I..\ /I..\..\Include \
/D "_WIN32" /D "WIN32" /D "_WINDOWS" /D "__WIN32__" /D "__MSC__" /D "MESAD3D"
CPPFLAGS= /c /nologo /W1 /G5 /I..\ /I..\..\Include \
/D "_WIN32" /D "WIN32" /D "_WINDOWS" /D "__WIN32__" /D "__MSC__" /D "MESAD3D"
!IF "$(DEBUG)" == "1"
CFLAGS = /MTd /Od /Z7 /Yd /D "_DEBUG" /D "D3D_DEBUG" $(CFLAGS)
CPPFLAGS = /MTd /Od /Z7 /Yd /D "_DEBUG" /D "D3D_DEBUG" $(CPPFLAGS)
BUILD_TYPE=debug
!ELSE
CFLAGS = /MT /Ox /D "NDEBUG" $(CFLAGS)
CPPFLAGS = /MT /Ox /D "NDEBUG" $(CPPFLAGS)
BUILD_TYPE=release
!ENDIF
##############################################################################
SRCS_WGL = wgl.c D3Dvbrender.c DDrawPROCS.c NULLProcs.c Debug.c
SRCS_HAL = D3DInit.cpp D3DRaster.cpp D3DTextureMgr.cpp D3DUtils.cpp D3DCaps.cpp
OBJS_WGL = $(SRCS_WGL:.c=.obj)
OBJS_HAL = $(SRCS_HAL:.cpp=.obj)
WINLIBS = kernel32.lib user32.lib gdi32.lib oldnames.lib
DXLIBS =
LIBS = $(WINLIBS) $(DXLIBS)
###############################################################################
# Primary Targets #
###############################################################################
default: header WGL HAL footer
all: default
WGL : $(OBJS_WGL)
HAL : $(OBJS_HAL)
install : forceit
@echo $(SPACE)
@echo ========================================
@echo Install files created.
@echo ========================================
###############################################################################
# Secondary Targets #
###############################################################################
clean:
@echo ========================================
@echo Cleaning $(TARGET)
@del *.obj
@del *.dep
@del *.exp
@del *.ncb
@del *.plg
@del *.lib
@echo ========================================
header:
@echo ============================================================
@echo Building $(TARGET) ($(BUILD_TYPE) version)
@echo ============================================================
@echo $(SPACE)
footer:
@echo $(SPACE)
@echo ============================================================
@echo DONE building $(TARGET) ($(BUILD_TYPE) version)
@echo ============================================================
forceit:

View File

@ -1,49 +0,0 @@
/*===========================================================================*/
/* */
/* Mesa-3.0 DirectX 6 Driver */
/* */
/* By Leigh McRae */
/* */
/* http://www.altsoftware.com/ */
/* */
/* Copyright (c) 1999-1998 alt.software inc. All Rights Reserved */
/*===========================================================================*/
#ifndef NULL_MESA_PROCS_INC
#define NULL_MESA_PROCS_INC
/*===========================================================================*/
/* Includes. */
/*===========================================================================*/
#include "matrix.h"
#include "context.h"
#include "types.h"
#include "vb.h"
/*===========================================================================*/
/* Macros. */
/*===========================================================================*/
/*===========================================================================*/
/* Magic numbers. */
/*===========================================================================*/
/*===========================================================================*/
/* Type defines. */
/*===========================================================================*/
void NULLSetColor( GLcontext *ctx, GLubyte r, GLubyte g, GLubyte b, GLubyte a );
void NULLClearColor( GLcontext *ctx, GLubyte r, GLubyte g, GLubyte b, GLubyte a );
GLboolean NULLSetBuffer( GLcontext *ctx, GLenum mode );
void NULLGetBufferSize( GLcontext *ctx, GLuint *width, GLuint *height );
GLbitfield NULLClearBuffers( GLcontext *ctx, GLbitfield m, GLboolean a, GLint x, GLint y, GLint w, GLint h );
void NULLWrSpRGB( const GLcontext* ctx, GLuint n, GLint x, GLint y, const GLubyte r[][3], const GLubyte m[] );
void NULLWrSpRGBA( const GLcontext* ctx, GLuint n, GLint x, GLint y, const GLubyte r[][4], const GLubyte m[] );
void NULLWrSpRGBAMono( const GLcontext* ctx, GLuint n, GLint x, GLint y, const GLubyte m[] );
void NULLWrPiRGBA( const GLcontext* ctx, GLuint n, const GLint x[], const GLint y[], const GLubyte r[][4], const GLubyte m[] );
void NULLWrPiRGBAMono( const GLcontext* ctx, GLuint n, const GLint x[], const GLint y[], const GLubyte m[] );
void NULLReSpRGBA( const GLcontext* ctx, GLuint n, GLint x, GLint y, GLubyte r[][4] );
void NULLRePiRGBA( const GLcontext* ctx, GLuint n, const GLint x[], const GLint y[], GLubyte r[][4], const GLubyte m[] );
/*===========================================================================*/
/* Extern function prototypes. */
/*===========================================================================*/
/*===========================================================================*/
/* Global variables. */
/*===========================================================================*/
#endif

View File

@ -1,49 +0,0 @@
/*===========================================================================*/
/* */
/* Mesa-3.0 DirectX 6 Driver */
/* */
/* By Leigh McRae */
/* */
/* http://www.altsoftware.com/ */
/* */
/* Copyright (c) 1999-1998 alt.software inc. All Rights Reserved */
/*===========================================================================*/
#ifndef NULL_MESA_PROCS_INC
#define NULL_MESA_PROCS_INC
/*===========================================================================*/
/* Includes. */
/*===========================================================================*/
#include "matrix.h"
#include "context.h"
#include "mtypes.h"
#include "vb.h"
/*===========================================================================*/
/* Macros. */
/*===========================================================================*/
/*===========================================================================*/
/* Magic numbers. */
/*===========================================================================*/
/*===========================================================================*/
/* Type defines. */
/*===========================================================================*/
void NULLSetColor( GLcontext *ctx, GLubyte r, GLubyte g, GLubyte b, GLubyte a );
void NULLClearColor( GLcontext *ctx, GLubyte r, GLubyte g, GLubyte b, GLubyte a );
GLboolean NULLSetBuffer( GLcontext *ctx, GLframebuffer *buffer, GLuint bit );
void NULLGetBufferSize( GLcontext *ctx, GLuint *width, GLuint *height );
GLbitfield NULLClearBuffers( GLcontext *ctx, GLbitfield m, GLboolean a, GLint x, GLint y, GLint w, GLint h );
void NULLWrSpRGB( const GLcontext* ctx, GLuint n, GLint x, GLint y, const GLubyte r[][3], const GLubyte m[] );
void NULLWrSpRGBA( const GLcontext* ctx, GLuint n, GLint x, GLint y, const GLubyte r[][4], const GLubyte m[] );
void NULLWrSpRGBAMono( const GLcontext* ctx, GLuint n, GLint x, GLint y, const GLubyte m[] );
void NULLWrPiRGBA( const GLcontext* ctx, GLuint n, const GLint x[], const GLint y[], const GLubyte r[][4], const GLubyte m[] );
void NULLWrPiRGBAMono( const GLcontext* ctx, GLuint n, const GLint x[], const GLint y[], const GLubyte m[] );
void NULLReSpRGBA( const GLcontext* ctx, GLuint n, GLint x, GLint y, GLubyte r[][4] );
void NULLRePiRGBA( const GLcontext* ctx, GLuint n, const GLint x[], const GLint y[], GLubyte r[][4], const GLubyte m[] );
/*===========================================================================*/
/* Extern function prototypes. */
/*===========================================================================*/
/*===========================================================================*/
/* Global variables. */
/*===========================================================================*/
#endif

View File

@ -1,442 +0,0 @@
;===========================================================================
;
; Mesa-3.0 DirectX 6 Driver
;
; By Leigh McRae
;
; http://www.altsoftware.com/
;
; Copyright (c) 1999-1998 alt.software inc. All Rights Reserved
;===========================================================================
NAME OpenGL32.DLL
DESCRIPTION "Mesa-3.0 DX6 Driver Version 0.5"
EXPORTS
DllMain
glAccum
glAlphaFunc
glAreTexturesResident
glAreTexturesResidentEXT
glArrayElement
glArrayElementEXT
glBegin
glBindTexture
glBindTextureEXT
glBitmap
glBlendColorEXT
glBlendEquationEXT
glBlendFunc
glCallList
glCallLists
glClear
glClearAccum
glClearColor
glClearDepth
glClearIndex
glClearStencil
glClipPlane
glColor3b
glColor3bv
glColor3d
glColor3dv
glColor3f
glColor3fv
glColor3i
glColor3iv
glColor3s
glColor3sv
glColor3ub
glColor3ubv
glColor3ui
glColor3uiv
glColor3us
glColor3usv
glColor4b
glColor4bv
glColor4d
glColor4dv
glColor4f
glColor4fv
glColor4i
glColor4iv
glColor4s
glColor4sv
glColor4ub
glColor4ubv
glColor4ui
glColor4uiv
glColor4us
glColor4usv
glColorMask
glColorMaterial
glColorPointer
glColorPointerEXT
glColorSubTableEXT
glColorTableEXT
glCopyPixels
glCopyTexImage1D
glCopyTexImage2D
glCopyTexSubImage1D
glCopyTexSubImage2D
glCopyTexSubImage3DEXT
glCullFace
glDeleteLists
glDeleteTextures
glDeleteTexturesEXT
glDepthFunc
glDepthMask
glDepthRange
glDisable
glDisableClientState
glDrawArrays
glDrawArraysEXT
glDrawBuffer
glDrawElements
glDrawPixels
glEdgeFlag
glEdgeFlagPointer
glEdgeFlagPointerEXT
glEdgeFlagv
glEnable
glEnableClientState
glEnd
glEndList
glEvalCoord1d
glEvalCoord1dv
glEvalCoord1f
glEvalCoord1fv
glEvalCoord2d
glEvalCoord2dv
glEvalCoord2f
glEvalCoord2fv
glEvalMesh1
glEvalMesh2
glEvalPoint1
glEvalPoint2
glFeedbackBuffer
glFinish
glFlush
glFogf
glFogfv
glFogi
glFogiv
glFrontFace
glFrustum
glGenLists
glGenTextures
glGenTexturesEXT
glGetBooleanv
glGetClipPlane
glGetColorTableEXT
glGetColorTableParameterfvEXT
glGetColorTableParameterivEXT
glGetDoublev
glGetError
glGetFloatv
glGetIntegerv
glGetLightfv
glGetLightiv
glGetMapdv
glGetMapfv
glGetMapiv
glGetMaterialfv
glGetMaterialiv
glGetPixelMapfv
glGetPixelMapuiv
glGetPixelMapusv
glGetPointerv
glGetPointervEXT
glGetPolygonStipple
glGetString
glGetTexEnvfv
glGetTexEnviv
glGetTexGendv
glGetTexGenfv
glGetTexGeniv
glGetTexImage
glGetTexLevelParameterfv
glGetTexLevelParameteriv
glGetTexParameterfv
glGetTexParameteriv
glHint
glIndexd
glIndexdv
glIndexf
glIndexfv
glIndexi
glIndexiv
glIndexMask
glIndexPointer
glIndexPointerEXT
glIndexs
glIndexsv
glIndexub
glIndexubv
glInitNames
glInterleavedArrays
glIsEnabled
glIsList
glIsTexture
glIsTextureEXT
glLightf
glLightfv
glLighti
glLightiv
glLightModelf
glLightModelfv
glLightModeli
glLightModeliv
glLineStipple
glLineWidth
glListBase
glLoadIdentity
glLoadMatrixd
glLoadMatrixf
glLoadName
glLogicOp
glMap1d
glMap1f
glMap2d
glMap2f
glMapGrid1d
glMapGrid1f
glMapGrid2d
glMapGrid2f
glMaterialf
glMaterialfv
glMateriali
glMaterialiv
glMatrixMode
glMultMatrixd
glMultMatrixf
glNewList
glNormal3b
glNormal3bv
glNormal3d
glNormal3dv
glNormal3f
glNormal3fv
glNormal3i
glNormal3iv
glNormal3s
glNormal3sv
glNormalPointer
glNormalPointerEXT
glOrtho
glPassThrough
glPixelMapfv
glPixelMapuiv
glPixelMapusv
glPixelStoref
glPixelStorei
glPixelTransferf
glPixelTransferi
glPixelZoom
glPointParameterfEXT
glPointParameterfvEXT
glPointSize
glPolygonMode
glPolygonOffset
glPolygonOffsetEXT
glPolygonStipple
glPopAttrib
glPopClientAttrib
glPopMatrix
glPopName
glPrioritizeTextures
glPrioritizeTexturesEXT
glPushAttrib
glPushClientAttrib
glPushMatrix
glPushName
glRasterPos2d
glRasterPos2dv
glRasterPos2f
glRasterPos2fv
glRasterPos2i
glRasterPos2iv
glRasterPos2s
glRasterPos2sv
glRasterPos3d
glRasterPos3dv
glRasterPos3f
glRasterPos3fv
glRasterPos3i
glRasterPos3iv
glRasterPos3s
glRasterPos3sv
glRasterPos4d
glRasterPos4dv
glRasterPos4f
glRasterPos4fv
glRasterPos4i
glRasterPos4iv
glRasterPos4s
glRasterPos4sv
glReadBuffer
glReadPixels
glRectd
glRectdv
glRectf
glRectfv
glRecti
glRectiv
glRects
glRectsv
glRenderMode
glResizeBuffersMESA
glRotated
glRotatef
glScaled
glScalef
glScissor
glSelectBuffer
glShadeModel
glStencilFunc
glStencilMask
glStencilOp
glTexCoord1d
glTexCoord1dv
glTexCoord1f
glTexCoord1fv
glTexCoord1i
glTexCoord1iv
glTexCoord1s
glTexCoord1sv
glTexCoord2d
glTexCoord2dv
glTexCoord2f
glTexCoord2fv
glTexCoord2i
glTexCoord2iv
glTexCoord2s
glTexCoord2sv
glTexCoord3d
glTexCoord3dv
glTexCoord3f
glTexCoord3fv
glTexCoord3i
glTexCoord3iv
glTexCoord3s
glTexCoord3sv
glTexCoord4d
glTexCoord4dv
glTexCoord4f
glTexCoord4fv
glTexCoord4i
glTexCoord4iv
glTexCoord4s
glTexCoord4sv
glTexCoordPointer
glTexCoordPointerEXT
glTexEnvf
glTexEnvfv
glTexEnvi
glTexEnviv
glTexGend
glTexGendv
glTexGenf
glTexGenfv
glTexGeni
glTexGeniv
glTexImage1D
glTexImage2D
glTexImage3DEXT
glTexParameterf
glTexParameterfv
glTexParameteri
glTexParameteriv
glTexSubImage1D
glTexSubImage2D
glTexSubImage3DEXT
glTranslated
glTranslatef
glVertex2d
glVertex2dv
glVertex2f
glVertex2fv
glVertex2i
glVertex2iv
glVertex2s
glVertex2sv
glVertex3d
glVertex3dv
glVertex3f
glVertex3fv
glVertex3i
glVertex3iv
glVertex3s
glVertex3sv
glVertex4d
glVertex4dv
glVertex4f
glVertex4fv
glVertex4i
glVertex4iv
glVertex4s
glVertex4sv
glVertexPointer
glVertexPointerEXT
glViewport
glWindowPos2dMESA
glWindowPos2dvMESA
glWindowPos2fMESA
glWindowPos2fvMESA
glWindowPos2iMESA
glWindowPos2ivMESA
glWindowPos2sMESA
glWindowPos2svMESA
glWindowPos3dMESA
glWindowPos3dvMESA
glWindowPos3fMESA
glWindowPos3fvMESA
glWindowPos3iMESA
glWindowPos3ivMESA
glWindowPos3sMESA
glWindowPos3svMESA
glWindowPos4dMESA
glWindowPos4dvMESA
glWindowPos4fMESA
glWindowPos4fvMESA
glWindowPos4iMESA
glWindowPos4ivMESA
glWindowPos4sMESA
glWindowPos4svMESA
; WMesaCreateContext
; WMesaDestroyContext
; WMesaMakeCurrent
; WMesaPaletteChange
; WMesaSwapBuffers
; OSMesaCreateContext
; OSMesaDestroyContext
; OSMesaMakeCurrent
; OSMesaGetCurrentContext
; OSMesaPixelStore
; OSMesaGetIntegerv
; OSMesaGetDepthBuffer
wglCopyContext
wglCreateContext
wglCreateLayerContext
wglDeleteContext
; wglDescribeLayerPlane
wglGetCurrentContext
wglGetCurrentDC
; wglGetLayerPaletteEntries
wglGetProcAddress
wglMakeCurrent
; wglRealizeLayerPalette
; wglSetLayerPaletteEntries
wglShareLists
wglSwapLayerBuffers
wglUseFontBitmapsA
wglUseFontBitmapsW
wglUseFontOutlinesA
wglUseFontOutlinesW
wglChoosePixelFormat
wglDescribePixelFormat
wglGetPixelFormat
wglSetPixelFormat
wglSwapBuffers

File diff suppressed because it is too large Load Diff

View File

@ -1,53 +0,0 @@
#ifndef D3D_TEXT_H
#define D3D_TEXT_H
#ifdef __cplusplus
extern "C" {
#endif
/*===========================================================================*/
/* Includes. */
/*===========================================================================*/
#include <windows.h>
#include <ddraw.h>
#include <d3d.h>
/*===========================================================================*/
/* Magic numbers. */
/*===========================================================================*/
#define D3DLTEXT_BITSUSED 0xFFFFFFFF
#define MAX_VERTICES 700 // (14*40) 14 per character, 40 characters
/*===========================================================================*/
/* Macros defines. */
/*===========================================================================*/
/*===========================================================================*/
/* Type defines. */
/*===========================================================================*/
typedef struct _d3dText_metrics
{
float fntYScale,
fntXScale;
int fntXSpacing,
fntYSpacing;
DWORD dwColor;
LPDIRECT3DDEVICE3 lpD3DDevice;
} D3DFONTMETRICS, *PD3DFONTMETRICS;
/*===========================================================================*/
/* Function prototypes. */
/*===========================================================================*/
extern BOOL InitD3DText( void );
extern void d3dTextDrawCharacter( char *c, int x, int y, PD3DFONTMETRICS pfntMetrics );
extern void d3dTextDrawString( char *pszString, int x, int y, PD3DFONTMETRICS pfntMetrics );
/*===========================================================================*/
/* Global variables. */
/*===========================================================================*/
#ifdef __cplusplus
}
#endif
#endif