diff options
-rw-r--r-- | docs/README.D3D | 124 | ||||
-rw-r--r-- | src/mesa/drivers/d3d/D3DCAPS.CPP | 250 | ||||
-rw-r--r-- | src/mesa/drivers/d3d/D3DHAL.H | 68 | ||||
-rw-r--r-- | src/mesa/drivers/d3d/D3DInit.cpp | 891 | ||||
-rw-r--r-- | src/mesa/drivers/d3d/D3DMESA.H | 84 | ||||
-rw-r--r-- | src/mesa/drivers/d3d/D3DRaster.cpp | 213 | ||||
-rw-r--r-- | src/mesa/drivers/d3d/D3DShared.h | 154 | ||||
-rw-r--r-- | src/mesa/drivers/d3d/D3DTEXT.CPP | 576 | ||||
-rw-r--r-- | src/mesa/drivers/d3d/D3DTextureMgr.cpp | 947 | ||||
-rw-r--r-- | src/mesa/drivers/d3d/D3DTextureMgr.h | 62 | ||||
-rw-r--r-- | src/mesa/drivers/d3d/D3DUTILS.CPP | 638 | ||||
-rw-r--r-- | src/mesa/drivers/d3d/D3Dvbrender.c | 2149 | ||||
-rw-r--r-- | src/mesa/drivers/d3d/DDrawPROCS.c | 399 | ||||
-rw-r--r-- | src/mesa/drivers/d3d/DEBUG.C | 143 | ||||
-rw-r--r-- | src/mesa/drivers/d3d/DEBUG.H | 90 | ||||
-rw-r--r-- | src/mesa/drivers/d3d/DbgEnv.bat | 25 | ||||
-rw-r--r-- | src/mesa/drivers/d3d/MAKEFILE | 101 | ||||
-rw-r--r-- | src/mesa/drivers/d3d/NULLProcs.h | 49 | ||||
-rw-r--r-- | src/mesa/drivers/d3d/NullProcs.c | 49 | ||||
-rw-r--r-- | src/mesa/drivers/d3d/OPENGL32.DEF | 442 | ||||
-rw-r--r-- | src/mesa/drivers/d3d/WGL.C | 1262 | ||||
-rw-r--r-- | src/mesa/drivers/d3d/d3dText.h | 53 |
22 files changed, 0 insertions, 8769 deletions
diff --git a/docs/README.D3D b/docs/README.D3D deleted file mode 100644 index b41fcb62085..00000000000 --- a/docs/README.D3D +++ /dev/null @@ -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 ([email protected]) -February 9, 1999 - diff --git a/src/mesa/drivers/d3d/D3DCAPS.CPP b/src/mesa/drivers/d3d/D3DCAPS.CPP deleted file mode 100644 index 80ee91d9222..00000000000 --- a/src/mesa/drivers/d3d/D3DCAPS.CPP +++ /dev/null @@ -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; - } - } -} - diff --git a/src/mesa/drivers/d3d/D3DHAL.H b/src/mesa/drivers/d3d/D3DHAL.H deleted file mode 100644 index 2496d164e5c..00000000000 --- a/src/mesa/drivers/d3d/D3DHAL.H +++ /dev/null @@ -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 - diff --git a/src/mesa/drivers/d3d/D3DInit.cpp b/src/mesa/drivers/d3d/D3DInit.cpp deleted file mode 100644 index e21cd21e250..00000000000 --- a/src/mesa/drivers/d3d/D3DInit.cpp +++ /dev/null @@ -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 ); -} - diff --git a/src/mesa/drivers/d3d/D3DMESA.H b/src/mesa/drivers/d3d/D3DMESA.H deleted file mode 100644 index 71a7cd8aedf..00000000000 --- a/src/mesa/drivers/d3d/D3DMESA.H +++ /dev/null @@ -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 - diff --git a/src/mesa/drivers/d3d/D3DRaster.cpp b/src/mesa/drivers/d3d/D3DRaster.cpp deleted file mode 100644 index 41e42ad94ce..00000000000 --- a/src/mesa/drivers/d3d/D3DRaster.cpp +++ /dev/null @@ -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 -} - - - - - - - - diff --git a/src/mesa/drivers/d3d/D3DShared.h b/src/mesa/drivers/d3d/D3DShared.h deleted file mode 100644 index cc629e21111..00000000000 --- a/src/mesa/drivers/d3d/D3DShared.h +++ /dev/null @@ -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 - - - diff --git a/src/mesa/drivers/d3d/D3DTEXT.CPP b/src/mesa/drivers/d3d/D3DTEXT.CPP deleted file mode 100644 index 39855b65fa9..00000000000 --- a/src/mesa/drivers/d3d/D3DTEXT.CPP +++ /dev/null @@ -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 diff --git a/src/mesa/drivers/d3d/D3DTextureMgr.cpp b/src/mesa/drivers/d3d/D3DTextureMgr.cpp deleted file mode 100644 index a6600cab02c..00000000000 --- a/src/mesa/drivers/d3d/D3DTextureMgr.cpp +++ /dev/null @@ -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; -} - - diff --git a/src/mesa/drivers/d3d/D3DTextureMgr.h b/src/mesa/drivers/d3d/D3DTextureMgr.h deleted file mode 100644 index 8a64ceaaec7..00000000000 --- a/src/mesa/drivers/d3d/D3DTextureMgr.h +++ /dev/null @@ -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 diff --git a/src/mesa/drivers/d3d/D3DUTILS.CPP b/src/mesa/drivers/d3d/D3DUTILS.CPP deleted file mode 100644 index 02664f96e4d..00000000000 --- a/src/mesa/drivers/d3d/D3DUTILS.CPP +++ /dev/null @@ -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]; -} diff --git a/src/mesa/drivers/d3d/D3Dvbrender.c b/src/mesa/drivers/d3d/D3Dvbrender.c deleted file mode 100644 index 09857f1dc8d..00000000000 --- a/src/mesa/drivers/d3d/D3Dvbrender.c +++ /dev/null @@ -1,2149 +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 <stdio.h> -#include "clip.h" -#include "context.h" -#include "light.h" -#include "lines.h" -#include "macros.h" -#include "matrix.h" -#include "pb.h" -#include "points.h" -#include "mtypes.h" -#include "vb.h" -#include "vbrender.h" -#include "xform.h" -#include "D3DMesa.h" - -static void SetRenderStates( GLcontext *ctx ); -static void DebugRenderStates( GLcontext *ctx, BOOL bForce ); - -static void RenderPointsVB( GLcontext *ctx, GLuint start, GLuint end ); -static void RenderTriangleVB( GLcontext *ctx, GLuint start, GLuint end ); -static void RenderTriangleFanVB( GLcontext *ctx, GLuint start, GLuint end ); -static void RenderTriangleStripVB( GLcontext *ctx, GLuint start, GLuint end ); -static void RenderQuadVB( GLcontext *ctx, GLuint start, GLuint end ); -static void RenderQuad( GLcontext *ctx, GLuint v1, GLuint v2, GLuint v3, GLuint v4, GLuint pv ); -void RenderOneTriangle( GLcontext *ctx, GLuint v1, GLuint v2, GLuint v3, GLuint pv ); -void RenderOneLine( GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv ); - -/* I went with a D3D vertex buffer that is 6 times that of the Mesa one */ -/* instead of having the D3D one flush when its full. This way Mesa will*/ -/* handle all the flushing. I need x6 as points can use 4 vertex each. */ -D3DTLVERTEX D3DTLVertices[ (VB_MAX*6) ]; -GLuint VList[VB_SIZE]; -/*===========================================================================*/ -/* Compute Z offsets for a polygon with plane defined by (A,B,C,D) */ -/* D is not needed. TODO: Currently we are calculating this but not using it.*/ -/*===========================================================================*/ -/* RETURN: */ -/*===========================================================================*/ -static void OffsetPolygon( GLcontext *ctx, GLfloat a, GLfloat b, GLfloat c ) -{ - GLfloat ac, - bc, - m, - offset; - - DPF(( DBG_FUNC, "OffsetPolygon();" )); - - if ( (c < 0.001F) && (c > - 0.001F) ) - { - /* Prevents underflow problems. */ - ctx->PointZoffset = 0.0F; - ctx->LineZoffset = 0.0F; - ctx->PolygonZoffset = 0.0F; - } - else - { - ac = a / c; - bc = b / c; - if ( ac < 0.0F ) - ac = -ac; - if ( bc<0.0F ) - bc = -bc; - m = MAX2( ac, bc ); /* m = sqrt( ac*ac + bc*bc ); */ - - offset = (m * ctx->Polygon.OffsetFactor + ctx->Polygon.OffsetUnits); - ctx->PointZoffset = ctx->Polygon.OffsetPoint ? offset : 0.0F; - ctx->LineZoffset = ctx->Polygon.OffsetLine ? offset : 0.0F; - ctx->PolygonZoffset = ctx->Polygon.OffsetFill ? offset : 0.0F; - } - - DPF(( DBG_PRIM_INFO, "OffsetPolygon: %f", offset )); -} -/*===========================================================================*/ -/* Compute signed area of the n-sided polgyon specified by vertices */ -/* vb->Win[] and vertex list vlist[]. */ -/* A clockwise polygon will return a negative area. A counter-clockwise */ -/* polygon will return a positive area. I have changed this function to */ -/* actually calculate twice the area as its faster and still gives the sign. */ -/*===========================================================================*/ -/* RETURN: signed area of the polgon. */ -/*===========================================================================*/ -static GLfloat PolygonArea( const struct vertex_buffer *vb, GLuint n, const GLuint vlist[] ) -{ - GLfloat area; - GLuint i; - - DPF(( DBG_FUNC, "PolygonArea();" )); - -#define j0 vlist[i] -#define j1 vlist[(i+1)%n] -#define x0 vb->Win[j0][0] -#define y0 vb->Win[j0][1] -#define x1 vb->Win[j1][0] -#define y1 vb->Win[j1][1] - - /* area = sum of trapezoids */ - for( i = 0, area = 0.0; i < n; i++ ) - area += ((x0 - x1) * (y0 + y1)); /* Note: no divide by two here! */ - -#undef x0 -#undef y0 -#undef x1 -#undef y1 -#undef j1 -#undef j0 - - // TODO: I don't see the point or * 0.5 as we just want the sign... - return area; -} -/*===========================================================================*/ -/* Render a polygon that needs clipping on at least one vertex. The function*/ -/* will first clip the polygon to any user clipping planes then clip to the */ -/* viewing volume. The final polygon will be draw as single triangles that */ -/* first need minor proccessing (culling, offset, etc) before we draw the */ -/* polygon as a fan. NOTE: the fan is draw as single triangles as its not */ -/* formed sequentaly in the VB but is in the vlist[]. */ -/*===========================================================================*/ -/* RETURN: */ -/*===========================================================================*/ -static void RenderClippedPolygon( GLcontext *ctx, GLuint n, GLuint vlist[] ) -{ - struct vertex_buffer *VB = ctx->VB; - GLfloat (*win)[3] = VB->Win, - *proj = ctx->ProjectionMatrix, - ex, ey, - fx, fy, c, - wInv; - GLuint index, - pv, - facing; - - DPF(( DBG_FUNC, "RenderClippedPolygon();" )); - - DPF(( DBG_PRIM_INFO, "RenderClippedtPolygon( %d )", n )); - - /* Which vertex dictates the color when flat shading. */ - pv = (ctx->Primitive==GL_POLYGON) ? vlist[0] : vlist[n-1]; - - /* Clipping may introduce new vertices. New vertices will be stored in */ - /* the vertex buffer arrays starting with location VB->Free. After we've*/ - /* rendered the polygon, these extra vertices can be overwritten. */ - VB->Free = VB_MAX; - - /* Clip against user clipping planes in eye coord space. */ - if ( ctx->Transform.AnyClip ) - { - n = gl_userclip_polygon( ctx, n, vlist ); - if ( n < 3 ) - return; - - /* Transform vertices from eye to clip coordinates: clip = Proj * eye */ - for( index = 0; index < n; index++ ) - { - TRANSFORM_POINT( VB->Clip[vlist[index]], proj, VB->Eye[vlist[index]] ); - } - } - - /* Clip against view volume in clip coord space */ - n = gl_viewclip_polygon( ctx, n, vlist ); - if ( n < 3 ) - return; - - /* Transform new vertices from clip to ndc to window coords. */ - /* ndc = clip / W window = viewport_mapping(ndc) */ - /* Note that window Z values are scaled to the range of integer */ - /* depth buffer values. */ - - /* Only need to compute window coords for new vertices */ - for( index = VB_MAX; index < VB->Free; index++ ) - { - if ( VB->Clip[index][3] != 0.0F ) - { - wInv = 1.0F / VB->Clip[index][3]; - - win[index][0] = VB->Clip[index][0] * wInv * ctx->Viewport.Sx + ctx->Viewport.Tx; - win[index][1] = VB->Clip[index][1] * wInv * ctx->Viewport.Sy + ctx->Viewport.Ty; - win[index][2] = VB->Clip[index][2] * wInv * ctx->Viewport.Sz + ctx->Viewport.Tz; - } - else - { - /* Can't divide by zero, so... */ - win[index][0] = win[index][1] = win[index][2] = 0.0F; - } - } - - /* Draw filled polygon as a triangle fan */ - for( index = 2; index < n; index++ ) - { - /* Compute orientation of triangle */ - ex = win[vlist[index-1]][0] - win[vlist[0]][0]; - ey = win[vlist[index-1]][1] - win[vlist[0]][1]; - fx = win[vlist[index]][0] - win[vlist[0]][0]; - fy = win[vlist[index]][1] - win[vlist[0]][1]; - c = (ex * fy) - (ey * fx); - - /* polygon is perpindicular to view plane, don't draw it */ - if ( (c == 0.0F) && !ctx->Polygon.Unfilled ) - continue; - - /* Backface culling. */ - facing = (c < 0.0F) ^ ctx->Polygon.FrontBit; - if ( (facing + 1) & ctx->Polygon.CullBits ) - continue; - - if ( ctx->IndirectTriangles & DD_TRI_LIGHT_TWOSIDE ) - { - if ( facing == 1 ) - { - /* use back color */ - VB->Color = VB->Bcolor; - VB->Specular= VB->Bspec; - } - else - { - /* use front color */ - VB->Color = VB->Fcolor; - VB->Specular= VB->Fspec; - } - } - - if ( ctx->IndirectTriangles & DD_TRI_OFFSET ) - { - /* finish computing plane equation of polygon, compute offset */ - GLfloat fz = win[vlist[index]][2] - win[vlist[0]][2]; - GLfloat ez = win[vlist[index-1]][2] - win[vlist[0]][2]; - GLfloat a = (ey * fz) - (ez * fy); - GLfloat b = (ez * fx) - (ex * fz); - OffsetPolygon( ctx, a, b, c ); - } - RenderOneTriangle( ctx, vlist[0], vlist[index-1], vlist[index], pv ); - } -} -/*===========================================================================*/ -/* This function gets called when either the vertex buffer is full or glEnd */ -/* has been called. If the we aren't in rendering mode (FEEDBACK) then I */ -/* pass the vertex buffer back to Mesa to deal with by returning FALSE. */ -/* If I can render the primitive types in the buffer directly then I will */ -/* return TRUE after I render the vertex buffer and reset the vertex buffer. */ -/* */ -/* TODO: I don't handle the special case of when the vertex buffer is full */ -/* and we have a primitive that bounds this buffer and the next one to */ -/* come. I'm not sure right now if Mesa handles this for me... */ -/*===========================================================================*/ -/* RETURN: TRUE, FALSE. */ -/*===========================================================================*/ -GLboolean RenderVertexBuffer( GLcontext *ctx, GLboolean allDone ) -{ - struct vertex_buffer *VB = ctx->VB; - GLuint index, - vlist[VB_SIZE]; - - DPF(( DBG_FUNC, "RenderVertexBuffer();" )); - - /* We only need to hook actual tri's that need rendering. */ - if ( ctx->RenderMode != GL_RENDER ) - { - // (ctx->Visual->AccumBits > 0) ) - // (ctx->Visual->StencilBits > 0) ) - DPF(( DBG_PRIM_INFO, "Passing VB back to Mesa" )); - return FALSE; - } - - /* I'm going to set the states here so that all functions will */ - /* be assured to have the right states. If Mesa's vertex bufefr */ - /* function calls one of my primitive functions (TRI,POINT,LINE) */ - /* it will need the right states. So instead of doing it in the */ - /* primitive function I will always do it here at risk of some */ - /* slow down to some cases... */ - SetRenderStates( ctx ); - - switch( ctx->Primitive ) - { - case GL_POINTS: - DPF(( DBG_PRIM_INFO, "GL_POINTS( %d )", VB->Count )); - RenderPointsVB( ctx, 0, VB->Count ); - break; - - case GL_LINES: - case GL_LINE_STRIP: - case GL_LINE_LOOP: - /* Not supported functions yet so pass back that we failed to */ - /* render the vertex buffer and Mesa will have to do it. */ - DPF(( DBG_PRIM_INFO, "GL_LINE_?( %d )", VB->Count )); - return FALSE; - - case GL_TRIANGLES: - if ( VB->Count < 3 ) - { - DPF(( DBG_PRIM_WARN, "GL_TRIANGLES( %d )", VB->Count )); - return FALSE; - } - - DPF(( DBG_PRIM_INFO, "GL_TRIANGLES( %d )", VB->Count )); - RenderTriangleVB( ctx, 0, VB->Count ); - break; - - case GL_TRIANGLE_STRIP: - if ( VB->Count < 3 ) - { - DPF(( DBG_PRIM_WARN, "GL_TRIANGLE_STRIP( %d )", VB->Count )); - return FALSE; - } - - DPF(( DBG_PRIM_INFO, "GL_TRIANGLE_STRIP( %d )", VB->Count )); - RenderTriangleStripVB( ctx, 0, VB->Count ); - break; - - case GL_TRIANGLE_FAN: - if ( VB->Count < 3 ) - { - DPF(( DBG_PRIM_WARN, "GL_TRIANGLE_FAN( %d )", VB->Count )); - return FALSE; - } - - DPF(( DBG_PRIM_INFO, "GL_TRIANGLE_FAN( %d )", VB->Count )); - RenderTriangleFanVB( ctx, 0, VB->Count ); - break; - - case GL_QUADS: - if ( VB->Count < 4 ) - { - DPF(( DBG_PRIM_WARN, "GL_QUADS( %d )", VB->Count )); - return FALSE; - } - - DPF(( DBG_PRIM_INFO, "GL_QUADS( %d )", VB->Count )); - RenderQuadVB( ctx, 0, VB->Count ); - break; - - case GL_QUAD_STRIP: - if ( VB->Count < 4 ) - { - DPF(( DBG_PRIM_WARN, "GL_QUAD_STRIP( %d )", VB->Count )); - return FALSE; - } - - DPF(( DBG_PRIM_INFO, "GL_QUAD_STRIP( %d )", VB->Count )); - - if ( VB->ClipOrMask ) - { - for( index = 3; index < VB->Count; index += 2 ) - { - if ( VB->ClipMask[index-3] & VB->ClipMask[index-2] & VB->ClipMask[index-1] & VB->ClipMask[index] & CLIP_ALL_BITS ) - { - /* All points clipped by common plane */ - DPF(( DBG_PRIM_WARN, "GL_QUAD_STRIP( %d )", VB->Count )); - continue; - } - else if ( VB->ClipMask[index-3] | VB->ClipMask[index-2] | VB->ClipMask[index-1] | VB->ClipMask[index] ) - { - vlist[0] = index - 3; - vlist[1] = index - 2; - vlist[2] = index; - vlist[3] = index - 1; - RenderClippedPolygon( ctx, 4, vlist ); - } - else - { - RenderQuad( ctx, (index-3), (index-2), index, (index-1), index ); - } - } - } - else - { - /* No clipping needed */ - for( index = 3; index < VB->Count; index += 2 ) - RenderQuad( ctx, (index-3), (index-2), index, (index-1), index ); - } - break; - - case GL_POLYGON: - if ( VB->Count < 3 ) - { - DPF(( DBG_PRIM_WARN, "GL_POLYGON( %d )", VB->Count )); - return FALSE; - } - - DPF(( DBG_PRIM_INFO, "GL_POLYGON( %d )", VB->Count )); - - /* All points clipped by common plane, draw nothing */ - if ( !(VB->ClipAndMask & CLIP_ALL_BITS) ) - RenderTriangleFanVB( ctx, 0, VB->Count ); - break; - - default: - /* should never get here */ - _mesa_problem( ctx, "invalid mode in gl_render_vb" ); - } - - DPF(( DBG_PRIM_INFO, "ResetVB" )); - - /* We return TRUE to indicate we rendered the VB. */ - gl_reset_vb( ctx, allDone ); - return TRUE; -} -/*===========================================================================*/ -/* This function will render the current vertex buffer as triangles. The */ -/* buffer has to be able to be rendered directly. This means that we are */ -/* filled, no offsets, no culling and one sided rendering. Also we must be */ -/* in render mode of course. */ -/* First I will fill the global D3D vertice buffer. Next I will set all the*/ -/* states for D3D based on the current OGL state. Finally I pass the D3D VB */ -/* to the wrapper that call DrawPrimitives. */ -/*===========================================================================*/ -/* RETURN: */ -/*===========================================================================*/ -static void RenderTriangleVB( GLcontext *ctx, GLuint start, GLuint end ) -{ - D3DMESACONTEXT *pContext = (D3DMESACONTEXT *)ctx->DriverCtx; - struct vertex_buffer *VB = ctx->VB; - int index, - cVertex, - height = (pContext->pShared->rectW.bottom - pContext->pShared->rectW.top); - DWORD dwPVColor; - GLfloat ex, ey, - fx, fy, c; - GLuint facing; - - DPF(( DBG_FUNC, "RenderTriangleVB" )); - - if ( !VB->ClipOrMask ) - { - DPF(( DBG_PRIM_INFO, "DirectTriangles( %d )", (end-start) )); - for( index = start, cVertex = 0; index < end; ) - { - dwPVColor = (VB->Color[(index+2)][3]<<24) | (VB->Color[(index+2)][0]<<16) | (VB->Color[(index+2)][1]<<8) | VB->Color[(index+2)][2]; - - /*=====================================*/ - /* Populate the the triangle vertices. */ - /*=====================================*/ - D3DTLVertices[cVertex].sx = D3DVAL( VB->Win[index][0] ); - D3DTLVertices[cVertex].sy = D3DVAL( (height - VB->Win[index][1]) ); - D3DTLVertices[cVertex].sz = D3DVAL( VB->Win[index][2] ); - D3DTLVertices[cVertex].tu = D3DVAL( VB->TexCoord[index][0] ); - D3DTLVertices[cVertex].tv = D3DVAL( VB->TexCoord[index][1] ); - D3DTLVertices[cVertex].rhw = D3DVAL( (1.0 / VB->Clip[index][3]) ); - D3DTLVertices[cVertex++].color= (ctx->Light.ShadeModel == GL_FLAT) ? - dwPVColor : - (VB->Color[index][3]<<24) | (VB->Color[index][0]<<16) | (VB->Color[index][1]<<8) | VB->Color[index][2]; - index++; - - D3DTLVertices[cVertex].sx = D3DVAL( VB->Win[index][0] ); - D3DTLVertices[cVertex].sy = D3DVAL( (height - VB->Win[index][1]) ); - D3DTLVertices[cVertex].sz = D3DVAL( VB->Win[index][2] ); - D3DTLVertices[cVertex].tu = D3DVAL( VB->TexCoord[index][0] ); - D3DTLVertices[cVertex].tv = D3DVAL( VB->TexCoord[index][1] ); - D3DTLVertices[cVertex].rhw = D3DVAL( (1.0 / VB->Clip[index][3]) ); - D3DTLVertices[cVertex++].color= (ctx->Light.ShadeModel == GL_FLAT) ? - dwPVColor : - (VB->Color[index][3]<<24) | (VB->Color[index][0]<<16) | (VB->Color[index][1]<<8) | VB->Color[index][2]; - index++; - - D3DTLVertices[cVertex].sx = D3DVAL( VB->Win[index][0] ); - D3DTLVertices[cVertex].sy = D3DVAL( (height - VB->Win[index][1]) ); - D3DTLVertices[cVertex].sz = D3DVAL( VB->Win[index][2] ); - D3DTLVertices[cVertex].tu = D3DVAL( VB->TexCoord[index][0] ); - D3DTLVertices[cVertex].tv = D3DVAL( VB->TexCoord[index][1] ); - D3DTLVertices[cVertex].rhw = D3DVAL( (1.0 / VB->Clip[index][3]) ); - D3DTLVertices[cVertex++].color= dwPVColor; - index++; - } - } - else - { -#define v1 index -#define v2 (index+1) -#define v3 (index+2) - - for( index = start, cVertex = 0; index < end; index += 3 ) - { - if ( VB->ClipMask[v1] & VB->ClipMask[v2] & VB->ClipMask[v3] & CLIP_ALL_BITS ) - { - continue; - } - else if ( VB->ClipMask[v1] | VB->ClipMask[v2] | VB->ClipMask[v3] ) - { - VList[0] = v1; - VList[1] = v2; - VList[2] = v3; - RenderClippedPolygon( ctx, 3, VList ); - continue; - } - - /* Compute orientation of triangle */ - ex = VB->Win[v2][0] - VB->Win[v1][0]; - ey = VB->Win[v2][1] - VB->Win[v1][1]; - fx = VB->Win[v3][0] - VB->Win[v1][0]; - fy = VB->Win[v3][1] - VB->Win[v1][1]; - c = (ex * fy) - (ey * fx); - - /* polygon is perpindicular to view plane, don't draw it */ - if ( (c == 0.0F) && !ctx->Polygon.Unfilled ) - continue; - - /* Backface culling. */ - facing = (c < 0.0F) ^ ctx->Polygon.FrontBit; - if ( (facing + 1) & ctx->Polygon.CullBits ) - continue; - - if ( ctx->IndirectTriangles & DD_TRI_LIGHT_TWOSIDE ) - { - if ( facing == 1 ) - { - /* use back color */ - VB->Color = VB->Bcolor; - VB->Specular= VB->Bspec; - } - else - { - /* use front color */ - VB->Color = VB->Fcolor; - VB->Specular= VB->Fspec; - } - } - - if ( ctx->IndirectTriangles & DD_TRI_OFFSET ) - { - /* Finish computing plane equation of polygon, compute offset */ - GLfloat fz = VB->Win[v3][2] - VB->Win[v1][2]; - GLfloat ez = VB->Win[v2][2] - VB->Win[v1][2]; - GLfloat a = (ey * fz) - (ez * fy); - GLfloat b = (ez * fx) - (ex * fz); - OffsetPolygon( ctx, a, b, c ); - } - - /*=====================================*/ - /* Populate the the triangle vertices. */ - /*=====================================*/ - /* Solve the prevoking vertex color as we need it for the 3rd triangle and flat shading. */ - dwPVColor = (VB->Color[v3][3]<<24) | (VB->Color[v3][0]<<16) | (VB->Color[v3][1]<<8) | VB->Color[v3][2]; - - D3DTLVertices[cVertex].sx = D3DVAL( VB->Win[v1][0] ); - D3DTLVertices[cVertex].sy = D3DVAL( (height - VB->Win[v1][1]) ); - D3DTLVertices[cVertex].sz = D3DVAL( (VB->Win[v1][2] + ctx->PolygonZoffset) ); - D3DTLVertices[cVertex].tu = D3DVAL( VB->TexCoord[v1][0] ); - D3DTLVertices[cVertex].tv = D3DVAL( VB->TexCoord[v1][1] ); - D3DTLVertices[cVertex].rhw = D3DVAL( (1.0 / VB->Clip[v1][3]) ); - D3DTLVertices[cVertex++].color= (ctx->Light.ShadeModel == GL_FLAT) ? - dwPVColor : - (VB->Color[v1][3]<<24) | (VB->Color[v1][0]<<16) | (VB->Color[v1][1]<<8) | VB->Color[v1][2]; - - D3DTLVertices[cVertex].sx = D3DVAL( VB->Win[v2][0] ); - D3DTLVertices[cVertex].sy = D3DVAL( (height - VB->Win[v2][1]) ); - D3DTLVertices[cVertex].sz = D3DVAL( (VB->Win[v2][2] + ctx->PolygonZoffset) ); - D3DTLVertices[cVertex].tu = D3DVAL( VB->TexCoord[v2][0] ); - D3DTLVertices[cVertex].tv = D3DVAL( VB->TexCoord[v2][1] ); - D3DTLVertices[cVertex].rhw = D3DVAL( (1.0 / VB->Clip[v2][3]) ); - D3DTLVertices[cVertex++].color= (ctx->Light.ShadeModel == GL_FLAT) ? - dwPVColor : - (VB->Color[v2][3]<<24) | (VB->Color[v2][0]<<16) | (VB->Color[v2][1]<<8) | VB->Color[v2][2]; - - D3DTLVertices[cVertex].sx = D3DVAL( VB->Win[v3][0] ); - D3DTLVertices[cVertex].sy = D3DVAL( (height - VB->Win[v3][1]) ); - D3DTLVertices[cVertex].sz = D3DVAL( (VB->Win[v3][2] + ctx->PolygonZoffset) ); - D3DTLVertices[cVertex].tu = D3DVAL( VB->TexCoord[v3][0] ); - D3DTLVertices[cVertex].tv = D3DVAL( VB->TexCoord[v3][1] ); - D3DTLVertices[cVertex].rhw = D3DVAL( (1.0 / VB->Clip[v3][3]) ); - D3DTLVertices[cVertex++].color= dwPVColor; - } -#undef v1 -#undef v2 -#undef v3 - } - - /* Render the converted vertex buffer. */ - if ( cVertex > 2 ) - DrawPrimitiveHAL( pContext->pShared, D3DPT_TRIANGLELIST, &D3DTLVertices[0], cVertex ); -} -/*===========================================================================*/ -/* This function will render the current vertex buffer as a triangle fan. */ -/* The buffer has to be able to be rendered directly. This means that we are*/ -/* filled, no offsets, no culling and one sided rendering. Also we must be */ -/* in render mode of course. */ -/* First I will fill the global D3D vertice buffer. Next I will set all the*/ -/* states for D3D based on the current OGL state. Finally I pass the D3D VB */ -/* to the wrapper that call DrawPrimitives. */ -/*===========================================================================*/ -/* RETURN: */ -/*===========================================================================*/ -static void RenderTriangleFanVB( GLcontext *ctx, GLuint start, GLuint end ) -{ - D3DMESACONTEXT *pContext = (D3DMESACONTEXT *)ctx->DriverCtx; - struct vertex_buffer *VB = ctx->VB; - int index, - cVertex, - height = (pContext->pShared->rectW.bottom - pContext->pShared->rectW.top); - GLfloat ex, ey, - fx, fy, c; - GLuint facing; - DWORD dwPVColor; - - DPF(( DBG_FUNC, "RenderTriangleFanVB();" )); - - /* Special case that we can blast the fan without culling, offset, etc... */ - if ( !VB->ClipOrMask && (ctx->Light.ShadeModel != GL_FLAT) ) - { - DPF(( DBG_PRIM_INFO, "DirectTriangles( %d )", (end-start) )); - - /* Seed the the fan. */ - D3DTLVertices[0].sx = D3DVAL( VB->Win[start][0] ); - D3DTLVertices[0].sy = D3DVAL( (height - VB->Win[start][1]) ); - D3DTLVertices[0].sz = D3DVAL( VB->Win[start][2] ); - D3DTLVertices[0].tu = D3DVAL( VB->TexCoord[start][0] ); - D3DTLVertices[0].tv = D3DVAL( VB->TexCoord[start][1] ); - D3DTLVertices[0].rhw = D3DVAL( (1.0 / VB->Clip[start][3]) ); - D3DTLVertices[0].color= (VB->Color[start][3]<<24) | (VB->Color[start][0]<<16) | (VB->Color[start][1]<<8) | VB->Color[start][2]; - - /* Seed the the fan. */ - D3DTLVertices[1].sx = D3DVAL( VB->Win[(start+1)][0] ); - D3DTLVertices[1].sy = D3DVAL( (height - VB->Win[(start+1)][1]) ); - D3DTLVertices[1].sz = D3DVAL( VB->Win[(start+1)][2] ); - D3DTLVertices[1].tu = D3DVAL( VB->TexCoord[(start+1)][0] ); - D3DTLVertices[1].tv = D3DVAL( VB->TexCoord[(start+1)][1] ); - D3DTLVertices[1].rhw = D3DVAL( (1.0 / VB->Clip[(start+1)][3]) ); - D3DTLVertices[1].color= (VB->Color[(start+1)][3]<<24) | (VB->Color[(start+1)][0]<<16) | (VB->Color[(start+1)][1]<<8) | VB->Color[(start+1)][2]; - - for( index = (start+2), cVertex = 2; index < end; index++, cVertex++ ) - { - /*=================================*/ - /* Add the next vertex to the fan. */ - /*=================================*/ - D3DTLVertices[cVertex].sx = D3DVAL( VB->Win[index][0] ); - D3DTLVertices[cVertex].sy = D3DVAL( (height - VB->Win[index][1]) ); - D3DTLVertices[cVertex].sz = D3DVAL( VB->Win[index][2] ); - D3DTLVertices[cVertex].tu = D3DVAL( VB->TexCoord[index][0] ); - D3DTLVertices[cVertex].tv = D3DVAL( VB->TexCoord[index][1] ); - D3DTLVertices[cVertex].rhw = D3DVAL( (1.0 / VB->Clip[index][3]) ); - D3DTLVertices[cVertex].color = (VB->Color[index][3]<<24) | (VB->Color[index][0]<<16) | (VB->Color[index][1]<<8) | VB->Color[index][2]; - } - - /* Render the converted vertex buffer. */ - if ( cVertex ) - DrawPrimitiveHAL( pContext->pShared, D3DPT_TRIANGLEFAN, &D3DTLVertices[0], cVertex ); - } - else - { -#define v1 start -#define v2 (index-1) -#define v3 index - - for( index = (start+2), cVertex = 0; index < end; index++ ) - { - if ( VB->ClipOrMask ) - { - /* All points clipped by common plane */ - if ( VB->ClipMask[v1] & VB->ClipMask[v2] & VB->ClipMask[v3] & CLIP_ALL_BITS ) - { - continue; - } - else if ( VB->ClipMask[v1] | VB->ClipMask[v2] | VB->ClipMask[v3] ) - { - VList[0] = v1; - VList[1] = v2; - VList[2] = v3; - RenderClippedPolygon( ctx, 3, VList ); - continue; - } - } - - /* Compute orientation of triangle */ - ex = VB->Win[v2][0] - VB->Win[v1][0]; - ey = VB->Win[v2][1] - VB->Win[v1][1]; - fx = VB->Win[v3][0] - VB->Win[v1][0]; - fy = VB->Win[v3][1] - VB->Win[v1][1]; - c = (ex * fy) - (ey * fx); - - /* polygon is perpindicular to view plane, don't draw it */ - if ( (c == 0.0F) && !ctx->Polygon.Unfilled ) - continue; - - /* Backface culling. */ - facing = (c < 0.0F) ^ ctx->Polygon.FrontBit; - if ( (facing + 1) & ctx->Polygon.CullBits ) - continue; - - if ( ctx->IndirectTriangles & DD_TRI_OFFSET ) - { - /* Finish computing plane equation of polygon, compute offset */ - GLfloat fz = VB->Win[v3][2] - VB->Win[v1][2]; - GLfloat ez = VB->Win[v2][2] - VB->Win[v1][2]; - GLfloat a = (ey * fz) - (ez * fy); - GLfloat b = (ez * fx) - (ex * fz); - OffsetPolygon( ctx, a, b, c ); - } - - /*=====================================*/ - /* Populate the the triangle vertices. */ - /*=====================================*/ - dwPVColor = (VB->Color[v3][3]<<24) | (VB->Color[v3][0]<<16) | (VB->Color[v3][1]<<8) | VB->Color[v3][2]; - - D3DTLVertices[cVertex].sx = D3DVAL( VB->Win[v1][0] ); - D3DTLVertices[cVertex].sy = D3DVAL( (height - VB->Win[v1][1]) ); - D3DTLVertices[cVertex].sz = D3DVAL( (VB->Win[v1][2] + ctx->PolygonZoffset) ); - D3DTLVertices[cVertex].tu = D3DVAL( VB->TexCoord[v1][0] ); - D3DTLVertices[cVertex].tv = D3DVAL( VB->TexCoord[v1][1] ); - D3DTLVertices[cVertex].rhw = D3DVAL( (1.0 / VB->Clip[v1][3]) ); - D3DTLVertices[cVertex++].color= (ctx->Light.ShadeModel == GL_FLAT) ? dwPVColor : - (VB->Color[v1][3]<<24) | (VB->Color[v1][0]<<16) | (VB->Color[v1][1]<<8) | VB->Color[v1][2]; - - D3DTLVertices[cVertex].sx = D3DVAL( VB->Win[v2][0] ); - D3DTLVertices[cVertex].sy = D3DVAL( (height - VB->Win[v2][1]) ); - D3DTLVertices[cVertex].sz = D3DVAL( (VB->Win[v2][2] + ctx->PolygonZoffset) ); - D3DTLVertices[cVertex].tu = D3DVAL( VB->TexCoord[v2][0] ); - D3DTLVertices[cVertex].tv = D3DVAL( VB->TexCoord[v2][1] ); - D3DTLVertices[cVertex].rhw = D3DVAL( (1.0 / VB->Clip[v2][3]) ); - D3DTLVertices[cVertex++].color= (ctx->Light.ShadeModel == GL_FLAT) ? dwPVColor : - (VB->Color[v2][3]<<24) | (VB->Color[v2][0]<<16) | (VB->Color[v2][1]<<8) | VB->Color[v2][2]; - - D3DTLVertices[cVertex].sx = D3DVAL( VB->Win[v3][0] ); - D3DTLVertices[cVertex].sy = D3DVAL( (height - VB->Win[v3][1]) ); - D3DTLVertices[cVertex].sz = D3DVAL( (VB->Win[v3][2] + ctx->PolygonZoffset) ); - D3DTLVertices[cVertex].tu = D3DVAL( VB->TexCoord[v3][0] ); - D3DTLVertices[cVertex].tv = D3DVAL( VB->TexCoord[v3][1] ); - D3DTLVertices[cVertex].rhw = D3DVAL( (1.0 / VB->Clip[v3][3]) ); - D3DTLVertices[cVertex++].color= dwPVColor; - } - - /* Render the converted vertex buffer. */ - if ( cVertex ) - DrawPrimitiveHAL( pContext->pShared, D3DPT_TRIANGLELIST, &D3DTLVertices[0], cVertex ); -#undef v1 -#undef v2 -#undef v3 - } -} -/*===========================================================================*/ -/* This function will render the current vertex buffer as a triangle strip. */ -/* The buffer has to be able to be rendered directly. This means that we are*/ -/* filled, no offsets, no culling and one sided rendering. Also we must be */ -/* in render mode of course. */ -/* First I will fill the global D3D vertice buffer. Next I will set all the*/ -/* states for D3D based on the current OGL state. Finally I pass the D3D VB */ -/* to the wrapper that call DrawPrimitives. */ -/*===========================================================================*/ -/* RETURN: */ -/*===========================================================================*/ -static void RenderTriangleStripVB( GLcontext *ctx, GLuint start, GLuint end ) -{ - D3DMESACONTEXT *pContext = (D3DMESACONTEXT *)ctx->DriverCtx; - struct vertex_buffer *VB = ctx->VB; - int index, - cVertex = 0, - v1, v2, v3, - height = (pContext->pShared->rectW.bottom - pContext->pShared->rectW.top); - GLfloat ex, ey, - fx, fy, c; - GLuint facing; - DWORD dwPVColor; - - DPF(( DBG_FUNC, "RenderTriangleStripVB();" )); - - /* Special case that we can blast the fan without culling, offset, etc... */ - if ( !VB->ClipOrMask && (ctx->Light.ShadeModel != GL_FLAT) ) - { - DPF(( DBG_PRIM_PROFILE, "DirectTriangles" )); - - /* Seed the the strip. */ - D3DTLVertices[0].sx = D3DVAL( VB->Win[start][0] ); - D3DTLVertices[0].sy = D3DVAL( (height - VB->Win[start][1]) ); - D3DTLVertices[0].sz = D3DVAL( VB->Win[start][2] ); - D3DTLVertices[0].tu = D3DVAL( VB->TexCoord[start][0] ); - D3DTLVertices[0].tv = D3DVAL( VB->TexCoord[start][1] ); - D3DTLVertices[0].rhw = D3DVAL( (1.0 / VB->Clip[start][3]) ); - D3DTLVertices[0].color= (VB->Color[start][3]<<24) | (VB->Color[start][0]<<16) | (VB->Color[start][1]<<8) | VB->Color[start][2]; - - /* Seed the the strip. */ - D3DTLVertices[1].sx = D3DVAL( VB->Win[(start+1)][0] ); - D3DTLVertices[1].sy = D3DVAL( (height - VB->Win[(start+1)][1]) ); - D3DTLVertices[1].sz = D3DVAL( VB->Win[(start+1)][2] ); - D3DTLVertices[1].tu = D3DVAL( VB->TexCoord[(start+1)][0] ); - D3DTLVertices[1].tv = D3DVAL( VB->TexCoord[(start+1)][1] ); - D3DTLVertices[1].rhw = D3DVAL( (1.0 / VB->Clip[(start+1)][3]) ); - D3DTLVertices[1].color= (VB->Color[(start+1)][3]<<24) | (VB->Color[(start+1)][0]<<16) | (VB->Color[(start+1)][1]<<8) | VB->Color[(start+1)][2]; - - for( index = (start+2), cVertex = 2; index < end; index++, cVertex++ ) - { - /*===================================*/ - /* Add the next vertex to the strip. */ - /*===================================*/ - D3DTLVertices[cVertex].sx = D3DVAL( VB->Win[index][0] ); - D3DTLVertices[cVertex].sy = D3DVAL( (height - VB->Win[index][1]) ); - D3DTLVertices[cVertex].sz = D3DVAL( VB->Win[index][2] ); - D3DTLVertices[cVertex].tu = D3DVAL( VB->TexCoord[index][0] ); - D3DTLVertices[cVertex].tv = D3DVAL( VB->TexCoord[index][1] ); - D3DTLVertices[cVertex].rhw = D3DVAL( (1.0 / VB->Clip[index][3]) ); - D3DTLVertices[cVertex].color = (VB->Color[index][3]<<24) | (VB->Color[index][0]<<16) | (VB->Color[index][1]<<8) | VB->Color[index][2]; - } - - /* Render the converted vertex buffer. */ - if ( cVertex ) - DrawPrimitiveHAL( pContext->pShared, D3DPT_TRIANGLESTRIP, &D3DTLVertices[0], cVertex ); - } - else - { - for( index = (start+2); index < end; index++ ) - { - /* We need to switch order so that winding won't be a problem. */ - if ( index & 1 ) - { - v1 = index - 1; - v2 = index - 2; - v3 = index - 0; - } - else - { - v1 = index - 2; - v2 = index - 1; - v3 = index - 0; - } - - /* All vertices clipped by common plane */ - if ( VB->ClipMask[v1] & VB->ClipMask[v2] & VB->ClipMask[v3] & CLIP_ALL_BITS ) - continue; - - /* Check if any vertices need clipping. */ - if ( VB->ClipMask[v1] | VB->ClipMask[v2] | VB->ClipMask[v3] ) - { - VList[0] = v1; - VList[1] = v2; - VList[2] = v3; - RenderClippedPolygon( ctx, 3, VList ); - } - else - { - /* Compute orientation of triangle */ - ex = VB->Win[v2][0] - VB->Win[v1][0]; - ey = VB->Win[v2][1] - VB->Win[v1][1]; - fx = VB->Win[v3][0] - VB->Win[v1][0]; - fy = VB->Win[v3][1] - VB->Win[v1][1]; - c = (ex * fy) - (ey * fx); - - /* Polygon is perpindicular to view plane, don't draw it */ - if ( (c == 0.0F) && !ctx->Polygon.Unfilled ) - continue; - - /* Backface culling. */ - facing = (c < 0.0F) ^ ctx->Polygon.FrontBit; - if ( (facing + 1) & ctx->Polygon.CullBits ) - continue; - - /* Need right color if we have two sided lighting. */ - if ( ctx->IndirectTriangles & DD_TRI_LIGHT_TWOSIDE ) - { - if ( facing == 1 ) - { - /* use back color */ - VB->Color = VB->Bcolor; - VB->Specular= VB->Bspec; - } - else - { - /* use front color */ - VB->Color = VB->Fcolor; - VB->Specular= VB->Fspec; - } - } - - if ( ctx->IndirectTriangles & DD_TRI_OFFSET ) - { - /* Finish computing plane equation of polygon, compute offset */ - GLfloat fz = VB->Win[v3][2] - VB->Win[v1][2]; - GLfloat ez = VB->Win[v2][2] - VB->Win[v1][2]; - GLfloat a = (ey * fz) - (ez * fy); - GLfloat b = (ez * fx) - (ex * fz); - OffsetPolygon( ctx, a, b, c ); - } - /*=====================================*/ - /* Populate the the triangle vertices. */ - /*=====================================*/ - - /* Solve the prevoking vertex color as we need it for the 3rd triangle and flat shading. */ - dwPVColor = (VB->Color[v3][3]<<24) | (VB->Color[v3][0]<<16) | (VB->Color[v3][1]<<8) | VB->Color[v3][2]; - - D3DTLVertices[cVertex].sx = D3DVAL( VB->Win[v1][0] ); - D3DTLVertices[cVertex].sy = D3DVAL( (height - VB->Win[v1][1]) ); - D3DTLVertices[cVertex].sz = D3DVAL( (VB->Win[v1][2] + ctx->PolygonZoffset) ); - D3DTLVertices[cVertex].tu = D3DVAL( VB->TexCoord[v1][0] ); - D3DTLVertices[cVertex].tv = D3DVAL( VB->TexCoord[v1][1] ); - D3DTLVertices[cVertex].rhw = D3DVAL( (1.0 / VB->Clip[v1][3]) ); - D3DTLVertices[cVertex++].color= (ctx->Light.ShadeModel == GL_FLAT) ? - dwPVColor : - (VB->Color[v1][3]<<24) | (VB->Color[v1][0]<<16) | (VB->Color[v1][1]<<8) | VB->Color[v1][2]; - - D3DTLVertices[cVertex].sx = D3DVAL( VB->Win[v2][0] ); - D3DTLVertices[cVertex].sy = D3DVAL( (height - VB->Win[v2][1]) ); - D3DTLVertices[cVertex].sz = D3DVAL( (VB->Win[v2][2] + ctx->PolygonZoffset) ); - D3DTLVertices[cVertex].tu = D3DVAL( VB->TexCoord[v2][0] ); - D3DTLVertices[cVertex].tv = D3DVAL( VB->TexCoord[v2][1] ); - D3DTLVertices[cVertex].rhw = D3DVAL( (1.0 / VB->Clip[v2][3]) ); - D3DTLVertices[cVertex++].color= (ctx->Light.ShadeModel == GL_FLAT) ? - dwPVColor : - (VB->Color[v2][3]<<24) | (VB->Color[v2][0]<<16) | (VB->Color[v2][1]<<8) | VB->Color[v2][2]; - - D3DTLVertices[cVertex].sx = D3DVAL( VB->Win[v3][0] ); - D3DTLVertices[cVertex].sy = D3DVAL( (height - VB->Win[v3][1]) ); - D3DTLVertices[cVertex].sz = D3DVAL( (VB->Win[v3][2] + ctx->PolygonZoffset) ); - D3DTLVertices[cVertex].tu = D3DVAL( VB->TexCoord[v3][0] ); - D3DTLVertices[cVertex].tv = D3DVAL( VB->TexCoord[v3][1] ); - D3DTLVertices[cVertex].rhw = D3DVAL( (1.0 / VB->Clip[v3][3]) ); - D3DTLVertices[cVertex++].color= dwPVColor; - } - } - - /* Render the converted vertex buffer. */ - if ( cVertex ) - DrawPrimitiveHAL( pContext->pShared, D3DPT_TRIANGLELIST, &D3DTLVertices[0], cVertex ); - } -} -/*===========================================================================*/ -/* This function will render the current vertex buffer as Quads. The buffer*/ -/* has to be able to be rendered directly. This means that we are filled, no*/ -/* offsets, no culling and one sided rendering. Also we must be in render */ -/* mode of cource. */ -/* First I will fill the global D3D vertice buffer. Next I will set all the*/ -/* states for D3D based on the current OGL state. Finally I pass the D3D VB */ -/* to the wrapper that call DrawPrimitives. */ -/*===========================================================================*/ -/* RETURN: */ -/*===========================================================================*/ -static void RenderQuadVB( GLcontext *ctx, GLuint start, GLuint end ) -{ - D3DMESACONTEXT *pContext = (D3DMESACONTEXT *)ctx->DriverCtx; - struct vertex_buffer *VB = ctx->VB; - int index, - cVertex, - height = (pContext->pShared->rectW.bottom - pContext->pShared->rectW.top); - DWORD dwPVColor; - GLfloat ex, ey, - fx, fy, c; - GLuint facing; /* 0=front, 1=back */ - - DPF(( DBG_FUNC, "RenderQuadVB();" )); - -#define v1 (index) -#define v2 (index+1) -#define v3 (index+2) -#define v4 (index+3) - - if ( !VB->ClipOrMask ) - { - DPF(( DBG_PRIM_PROFILE, "DirectTriangles" )); - - for( cVertex = 0, index = start; index < end; index += 4 ) - { - if ( ctx->Light.ShadeModel == GL_FLAT ) - dwPVColor = (VB->Color[v4][3]<<24) | (VB->Color[v4][0]<<16) | (VB->Color[v4][1]<<8) | VB->Color[v4][2]; - - /*=====================================*/ - /* Populate the the triangle vertices. */ - /*=====================================*/ - D3DTLVertices[cVertex].sx = D3DVAL( VB->Win[v1][0] ); - D3DTLVertices[cVertex].sy = D3DVAL( (height - VB->Win[v1][1]) ); - D3DTLVertices[cVertex].sz = D3DVAL( VB->Win[v1][2] ); - D3DTLVertices[cVertex].tu = D3DVAL( VB->TexCoord[v1][0] ); - D3DTLVertices[cVertex].tv = D3DVAL( VB->TexCoord[v1][1] ); - D3DTLVertices[cVertex].rhw = D3DVAL( (1.0 / VB->Clip[v1][3]) ); - D3DTLVertices[cVertex++].color= (ctx->Light.ShadeModel == GL_FLAT) ? - dwPVColor : - (VB->Color[v1][3]<<24) | (VB->Color[v1][0]<<16) | (VB->Color[v1][1]<<8) | VB->Color[v1][2]; - - D3DTLVertices[cVertex].sx = D3DVAL( VB->Win[v2][0] ); - D3DTLVertices[cVertex].sy = D3DVAL( (height - VB->Win[v2][1]) ); - D3DTLVertices[cVertex].sz = D3DVAL( VB->Win[v2][2] ); - D3DTLVertices[cVertex].tu = D3DVAL( VB->TexCoord[v2][0] ); - D3DTLVertices[cVertex].tv = D3DVAL( VB->TexCoord[v2][1] ); - D3DTLVertices[cVertex].rhw = D3DVAL( (1.0 / VB->Clip[v2][3]) ); - D3DTLVertices[cVertex++].color= (ctx->Light.ShadeModel == GL_FLAT) ? - dwPVColor : - (VB->Color[v2][3]<<24) | (VB->Color[v2][0]<<16) | (VB->Color[v2][1]<<8) | VB->Color[v2][2]; - - D3DTLVertices[cVertex].sx = D3DVAL( VB->Win[v3][0] ); - D3DTLVertices[cVertex].sy = D3DVAL( (height - VB->Win[v3][1]) ); - D3DTLVertices[cVertex].sz = D3DVAL( VB->Win[v3][2] ); - D3DTLVertices[cVertex].tu = D3DVAL( VB->TexCoord[v3][0] ); - D3DTLVertices[cVertex].tv = D3DVAL( VB->TexCoord[v3][1] ); - D3DTLVertices[cVertex].rhw = D3DVAL( (1.0 / VB->Clip[v3][3]) ); - D3DTLVertices[cVertex++].color= (ctx->Light.ShadeModel == GL_FLAT) ? - dwPVColor : - (VB->Color[v3][3]<<24) | (VB->Color[v3][0]<<16) | (VB->Color[v3][1]<<8) | VB->Color[v3][2]; - - D3DTLVertices[cVertex].sx = D3DVAL( VB->Win[v1][0] ); - D3DTLVertices[cVertex].sy = D3DVAL( (height - VB->Win[v1][1]) ); - D3DTLVertices[cVertex].sz = D3DVAL( VB->Win[v1][2] ); - D3DTLVertices[cVertex].tu = D3DVAL( VB->TexCoord[v1][0] ); - D3DTLVertices[cVertex].tv = D3DVAL( VB->TexCoord[v1][1] ); - D3DTLVertices[cVertex].rhw = D3DVAL( (1.0 / VB->Clip[v1][3]) ); - D3DTLVertices[cVertex++].color= (ctx->Light.ShadeModel == GL_FLAT) ? - dwPVColor : - (VB->Color[v1][3]<<24) | (VB->Color[v1][0]<<16) | (VB->Color[v1][1]<<8) | VB->Color[v1][2]; - - D3DTLVertices[cVertex].sx = D3DVAL( VB->Win[v3][0] ); - D3DTLVertices[cVertex].sy = D3DVAL( (height - VB->Win[v3][1]) ); - D3DTLVertices[cVertex].sz = D3DVAL( VB->Win[v3][2] ); - D3DTLVertices[cVertex].tu = D3DVAL( VB->TexCoord[v3][0] ); - D3DTLVertices[cVertex].tv = D3DVAL( VB->TexCoord[v3][1] ); - D3DTLVertices[cVertex].rhw = D3DVAL( (1.0 / VB->Clip[v3][3]) ); - D3DTLVertices[cVertex++].color= (ctx->Light.ShadeModel == GL_FLAT) ? - dwPVColor : - (VB->Color[v3][3]<<24) | (VB->Color[v3][0]<<16) | (VB->Color[v3][1]<<8) | VB->Color[v3][2]; - - D3DTLVertices[cVertex].sx = D3DVAL( VB->Win[v4][0] ); - D3DTLVertices[cVertex].sy = D3DVAL( (height - VB->Win[v4][1]) ); - D3DTLVertices[cVertex].sz = D3DVAL( VB->Win[v4][2] ); - D3DTLVertices[cVertex].tu = D3DVAL( VB->TexCoord[v4][0] ); - D3DTLVertices[cVertex].tv = D3DVAL( VB->TexCoord[v4][1] ); - D3DTLVertices[cVertex].rhw = D3DVAL( (1.0 / VB->Clip[v4][3]) ); - D3DTLVertices[cVertex++].color= (ctx->Light.ShadeModel == GL_FLAT) ? - dwPVColor : - (VB->Color[v4][3]<<24) | (VB->Color[v4][0]<<16) | (VB->Color[v4][1]<<8) | VB->Color[v4][2]; - } - } - else - { - for( cVertex = 0, index = start; index < end; index += 4 ) - { - if ( VB->ClipMask[v1] & VB->ClipMask[v2] & VB->ClipMask[v3] & VB->ClipMask[v4] & CLIP_ALL_BITS ) - { - continue; - } - else if ( VB->ClipMask[v1] | VB->ClipMask[v2] | VB->ClipMask[v3] | VB->ClipMask[v4] ) - { - VList[0] = v1; - VList[1] = v2; - VList[2] = v3; - VList[3] = v4; - RenderClippedPolygon( ctx, 4, VList ); - continue; - } - - /* Compute orientation of triangle */ - ex = VB->Win[v2][0] - VB->Win[v1][0]; - ey = VB->Win[v2][1] - VB->Win[v1][1]; - fx = VB->Win[v3][0] - VB->Win[v1][0]; - fy = VB->Win[v3][1] - VB->Win[v1][1]; - c = (ex * fy) - (ey * fx); - - /* polygon is perpindicular to view plane, don't draw it */ - if ( (c == 0.0F) && !ctx->Polygon.Unfilled ) - continue; - - /* Backface culling. */ - facing = (c < 0.0F) ^ ctx->Polygon.FrontBit; - if ( (facing + 1) & ctx->Polygon.CullBits ) - continue; - - if ( ctx->IndirectTriangles & DD_TRI_LIGHT_TWOSIDE ) - { - if ( facing == 1 ) - { - /* use back color */ - VB->Color = VB->Bcolor; - VB->Specular= VB->Bspec; - } - else - { - /* use front color */ - VB->Color = VB->Fcolor; - VB->Specular= VB->Fspec; - } - } - - if ( ctx->IndirectTriangles & DD_TRI_OFFSET ) - { - /* Finish computing plane equation of polygon, compute offset */ - GLfloat fz = VB->Win[v3][2] - VB->Win[v1][2]; - GLfloat ez = VB->Win[v2][2] - VB->Win[v1][2]; - GLfloat a = (ey * fz) - (ez * fy); - GLfloat b = (ez * fx) - (ex * fz); - OffsetPolygon( ctx, a, b, c ); - } - - if ( ctx->Light.ShadeModel == GL_FLAT ) - dwPVColor = (VB->Color[v4][3]<<24) | (VB->Color[v4][0]<<16) | (VB->Color[v4][1]<<8) | VB->Color[v4][2]; - - /*=====================================*/ - /* Populate the the triangle vertices. */ - /*=====================================*/ - D3DTLVertices[cVertex].sx = D3DVAL( VB->Win[v1][0] ); - D3DTLVertices[cVertex].sy = D3DVAL( (height - VB->Win[v1][1]) ); - D3DTLVertices[cVertex].sz = D3DVAL( (VB->Win[v1][2] + ctx->PolygonZoffset) ); - D3DTLVertices[cVertex].tu = D3DVAL( VB->TexCoord[v1][0] ); - D3DTLVertices[cVertex].tv = D3DVAL( VB->TexCoord[v1][1] ); - D3DTLVertices[cVertex].rhw = D3DVAL( (1.0 / VB->Clip[v1][3]) ); - D3DTLVertices[cVertex++].color= (ctx->Light.ShadeModel == GL_FLAT) ? - dwPVColor : - (VB->Color[v1][3]<<24) | (VB->Color[v1][0]<<16) | (VB->Color[v1][1]<<8) | VB->Color[v1][2]; - - D3DTLVertices[cVertex].sx = D3DVAL( VB->Win[v2][0] ); - D3DTLVertices[cVertex].sy = D3DVAL( (height - VB->Win[v2][1]) ); - D3DTLVertices[cVertex].sz = D3DVAL( (VB->Win[v2][2] + ctx->PolygonZoffset) ); - D3DTLVertices[cVertex].tu = D3DVAL( VB->TexCoord[v2][0] ); - D3DTLVertices[cVertex].tv = D3DVAL( VB->TexCoord[v2][1] ); - D3DTLVertices[cVertex].rhw = D3DVAL( (1.0 / VB->Clip[v2][3]) ); - D3DTLVertices[cVertex++].color= (ctx->Light.ShadeModel == GL_FLAT) ? - dwPVColor : - (VB->Color[v2][3]<<24) | (VB->Color[v2][0]<<16) | (VB->Color[v2][1]<<8) | VB->Color[v2][2]; - - D3DTLVertices[cVertex].sx = D3DVAL( VB->Win[v3][0] ); - D3DTLVertices[cVertex].sy = D3DVAL( (height - VB->Win[v3][1]) ); - D3DTLVertices[cVertex].sz = D3DVAL( (VB->Win[v3][2] + ctx->PolygonZoffset) ); - D3DTLVertices[cVertex].tu = D3DVAL( VB->TexCoord[v3][0] ); - D3DTLVertices[cVertex].tv = D3DVAL( VB->TexCoord[v3][1] ); - D3DTLVertices[cVertex].rhw = D3DVAL( (1.0 / VB->Clip[v3][3]) ); - D3DTLVertices[cVertex++].color= (ctx->Light.ShadeModel == GL_FLAT) ? - dwPVColor : - (VB->Color[v3][3]<<24) | (VB->Color[v3][0]<<16) | (VB->Color[v3][1]<<8) | VB->Color[v3][2]; - - D3DTLVertices[cVertex].sx = D3DVAL( VB->Win[v1][0] ); - D3DTLVertices[cVertex].sy = D3DVAL( (height - VB->Win[v1][1]) ); - D3DTLVertices[cVertex].sz = D3DVAL( (VB->Win[v1][2] + ctx->PolygonZoffset) ); - D3DTLVertices[cVertex].tu = D3DVAL( VB->TexCoord[v1][0] ); - D3DTLVertices[cVertex].tv = D3DVAL( VB->TexCoord[v1][1] ); - D3DTLVertices[cVertex].rhw = D3DVAL( (1.0 / VB->Clip[v1][3]) ); - D3DTLVertices[cVertex++].color= (ctx->Light.ShadeModel == GL_FLAT) ? - dwPVColor : - (VB->Color[v1][3]<<24) | (VB->Color[v1][0]<<16) | (VB->Color[v1][1]<<8) | VB->Color[v1][2]; - - D3DTLVertices[cVertex].sx = D3DVAL( VB->Win[v3][0] ); - D3DTLVertices[cVertex].sy = D3DVAL( (height - VB->Win[v3][1]) ); - D3DTLVertices[cVertex].sz = D3DVAL( (VB->Win[v3][2] + ctx->PolygonZoffset) ); - D3DTLVertices[cVertex].tu = D3DVAL( VB->TexCoord[v3][0] ); - D3DTLVertices[cVertex].tv = D3DVAL( VB->TexCoord[v3][1] ); - D3DTLVertices[cVertex].rhw = D3DVAL( (1.0 / VB->Clip[v3][3]) ); - D3DTLVertices[cVertex++].color= (ctx->Light.ShadeModel == GL_FLAT) ? - dwPVColor : - (VB->Color[v3][3]<<24) | (VB->Color[v3][0]<<16) | (VB->Color[v3][1]<<8) | VB->Color[v3][2]; - - D3DTLVertices[cVertex].sx = D3DVAL( VB->Win[v4][0] ); - D3DTLVertices[cVertex].sy = D3DVAL( (height - VB->Win[v4][1]) ); - D3DTLVertices[cVertex].sz = D3DVAL( (VB->Win[v4][2] + ctx->PolygonZoffset) ); - D3DTLVertices[cVertex].tu = D3DVAL( VB->TexCoord[v4][0] ); - D3DTLVertices[cVertex].tv = D3DVAL( VB->TexCoord[v4][1] ); - D3DTLVertices[cVertex].rhw = D3DVAL( (1.0 / VB->Clip[v4][3]) ); - D3DTLVertices[cVertex++].color= (ctx->Light.ShadeModel == GL_FLAT) ? - dwPVColor : - (VB->Color[v4][3]<<24) | (VB->Color[v4][0]<<16) | (VB->Color[v4][1]<<8) | VB->Color[v4][2]; - } - } - -#undef v4 -#undef v3 -#undef v2 -#undef v1 - - /* Render the converted vertex buffer. */ - if ( cVertex ) - DrawPrimitiveHAL( pContext->pShared, D3DPT_TRIANGLELIST, &D3DTLVertices[0], cVertex ); -} -/*===========================================================================*/ -/* */ -/*===========================================================================*/ -/* RETURN: TRUE, FALSE. */ -/*===========================================================================*/ -static void RenderQuad( GLcontext *ctx, GLuint v1, GLuint v2, GLuint v3, GLuint v4, GLuint pv ) -{ - D3DMESACONTEXT *pContext = (D3DMESACONTEXT *)ctx->DriverCtx; - struct vertex_buffer *VB = ctx->VB; - int height = (pContext->pShared->rectW.bottom - pContext->pShared->rectW.top); - DWORD dwPVColor; - GLfloat ex, ey, - fx, fy, c; - GLuint facing; /* 0=front, 1=back */ - static D3DTLVERTEX TLVertices[6]; - - DPF(( DBG_FUNC, "RenderQuad" )); - DPF(( DBG_PRIM_INFO, "RenderQuad( 1 )" )); - - /* Compute orientation of triangle */ - ex = VB->Win[v2][0] - VB->Win[v1][0]; - ey = VB->Win[v2][1] - VB->Win[v1][1]; - fx = VB->Win[v3][0] - VB->Win[v1][0]; - fy = VB->Win[v3][1] - VB->Win[v1][1]; - c = (ex * fy) - (ey * fx); - - /* polygon is perpindicular to view plane, don't draw it */ - if ( (c == 0.0F) && !ctx->Polygon.Unfilled ) - return; - - /* Backface culling. */ - facing = (c < 0.0F) ^ ctx->Polygon.FrontBit; - if ( (facing + 1) & ctx->Polygon.CullBits ) - return; - - if ( ctx->IndirectTriangles & DD_TRI_LIGHT_TWOSIDE ) - { - if ( facing == 1 ) - { - /* use back color */ - VB->Color = VB->Bcolor; - VB->Specular= VB->Bspec; - } - else - { - /* use front color */ - VB->Color = VB->Fcolor; - VB->Specular= VB->Fspec; - } - } - - if ( ctx->IndirectTriangles & DD_TRI_OFFSET ) - { - /* Finish computing plane equation of polygon, compute offset */ - GLfloat fz = VB->Win[v3][2] - VB->Win[v1][2]; - GLfloat ez = VB->Win[v2][2] - VB->Win[v1][2]; - GLfloat a = (ey * fz) - (ez * fy); - GLfloat b = (ez * fx) - (ex * fz); - OffsetPolygon( ctx, a, b, c ); - } - - if ( ctx->Light.ShadeModel == GL_FLAT ) - dwPVColor = (VB->Color[pv][3]<<24) | (VB->Color[pv][0]<<16) | (VB->Color[pv][1]<<8) | VB->Color[pv][2]; - - /*=====================================*/ - /* Populate the the triangle vertices. */ - /*=====================================*/ - TLVertices[0].sx = D3DVAL( VB->Win[v1][0] ); - TLVertices[0].sy = D3DVAL( (height - VB->Win[v1][1]) ); - TLVertices[0].sz = D3DVAL( (VB->Win[v1][2] + ctx->PolygonZoffset) ); - TLVertices[0].tu = D3DVAL( VB->TexCoord[v1][0] ); - TLVertices[0].tv = D3DVAL( VB->TexCoord[v1][1] ); - TLVertices[0].rhw = D3DVAL( (1.0 / VB->Clip[v1][3]) ); - TLVertices[0].color = (ctx->Light.ShadeModel == GL_FLAT) ? dwPVColor : - (VB->Color[v1][3]<<24) | (VB->Color[v1][0]<<16) | (VB->Color[v1][1]<<8) | VB->Color[v1][2]; - - TLVertices[1].sx = D3DVAL( VB->Win[v2][0] ); - TLVertices[1].sy = D3DVAL( (height - VB->Win[v2][1]) ); - TLVertices[1].sz = D3DVAL( (VB->Win[v2][2] + ctx->PolygonZoffset) ); - TLVertices[1].tu = D3DVAL( VB->TexCoord[v2][0] ); - TLVertices[1].tv = D3DVAL( VB->TexCoord[v2][1] ); - TLVertices[1].rhw = D3DVAL( (1.0 / VB->Clip[v2][3]) ); - TLVertices[1].color = (ctx->Light.ShadeModel == GL_FLAT) ? dwPVColor : - (VB->Color[v2][3]<<24) | (VB->Color[v2][0]<<16) | (VB->Color[v2][1]<<8) | VB->Color[v2][2]; - - TLVertices[2].sx = D3DVAL( VB->Win[v3][0] ); - TLVertices[2].sy = D3DVAL( (height - VB->Win[v3][1]) ); - TLVertices[2].sz = D3DVAL( (VB->Win[v3][2] + ctx->PolygonZoffset) ); - TLVertices[2].tu = D3DVAL( VB->TexCoord[v3][0] ); - TLVertices[2].tv = D3DVAL( VB->TexCoord[v3][1] ); - TLVertices[2].rhw = D3DVAL( (1.0 / VB->Clip[v3][3]) ); - TLVertices[2].color = (ctx->Light.ShadeModel == GL_FLAT) ? dwPVColor : - (VB->Color[v3][3]<<24) | (VB->Color[v3][0]<<16) | (VB->Color[v3][1]<<8) | VB->Color[v3][2]; - - TLVertices[3].sx = D3DVAL( VB->Win[v3][0] ); - TLVertices[3].sy = D3DVAL( (height - VB->Win[v3][1]) ); - TLVertices[3].sz = D3DVAL( (VB->Win[v3][2] + ctx->PolygonZoffset) ); - TLVertices[3].tu = D3DVAL( VB->TexCoord[v3][0] ); - TLVertices[3].tv = D3DVAL( VB->TexCoord[v3][1] ); - TLVertices[3].rhw = D3DVAL( (1.0 / VB->Clip[v3][3]) ); - TLVertices[3].color = (ctx->Light.ShadeModel == GL_FLAT) ? dwPVColor : - (VB->Color[v3][3]<<24) | (VB->Color[v3][0]<<16) | (VB->Color[v3][1]<<8) | VB->Color[v3][2]; - - TLVertices[4].sx = D3DVAL( VB->Win[v4][0] ); - TLVertices[4].sy = D3DVAL( (height - VB->Win[v4][1]) ); - TLVertices[4].sz = D3DVAL( (VB->Win[v4][2] + ctx->PolygonZoffset) ); - TLVertices[4].tu = D3DVAL( VB->TexCoord[v4][0] ); - TLVertices[4].tv = D3DVAL( VB->TexCoord[v4][1] ); - TLVertices[4].rhw = D3DVAL( (1.0 / VB->Clip[v4][3]) ); - TLVertices[4].color = (ctx->Light.ShadeModel == GL_FLAT) ? dwPVColor : - (VB->Color[v4][3]<<24) | (VB->Color[v4][0]<<16) | (VB->Color[v4][1]<<8) | VB->Color[v4][2]; - - TLVertices[5].sx = D3DVAL( VB->Win[v1][0] ); - TLVertices[5].sy = D3DVAL( (height - VB->Win[v1][1]) ); - TLVertices[5].sz = D3DVAL( (VB->Win[v1][2] + ctx->PolygonZoffset) ); - TLVertices[5].tu = D3DVAL( VB->TexCoord[v1][0] ); - TLVertices[5].tv = D3DVAL( VB->TexCoord[v1][1] ); - TLVertices[5].rhw = D3DVAL( (1.0 / VB->Clip[v1][3]) ); - TLVertices[5].color = (ctx->Light.ShadeModel == GL_FLAT) ? dwPVColor : - (VB->Color[v1][3]<<24) | (VB->Color[v1][0]<<16) | (VB->Color[v1][1]<<8) | VB->Color[v1][2]; - - /* Draw the two triangles. */ - DrawPrimitiveHAL( pContext->pShared, D3DPT_TRIANGLELIST, &TLVertices[0], 6 ); -} -/*===========================================================================*/ -/* */ -/*===========================================================================*/ -/* RETURN: TRUE, FALSE. */ -/*===========================================================================*/ -void RenderOneTriangle( GLcontext *ctx, GLuint v1, GLuint v2, GLuint v3, GLuint pv ) -{ - D3DMESACONTEXT *pContext = (D3DMESACONTEXT *)ctx->DriverCtx; - struct vertex_buffer *VB = ctx->VB; - int height = (pContext->pShared->rectW.bottom - pContext->pShared->rectW.top); - DWORD dwPVColor; - static D3DTLVERTEX TLVertices[3]; - - DPF(( DBG_FUNC, "RenderOneTriangle" )); - DPF(( DBG_PRIM_INFO, "RenderTriangle( 1 )" )); - - /*=====================================*/ - /* Populate the the triangle vertices. */ - /*=====================================*/ - if ( ctx->Light.ShadeModel == GL_FLAT ) - dwPVColor = (VB->Color[pv][3]<<24) | (VB->Color[pv][0]<<16) | (VB->Color[pv][1]<<8) | VB->Color[pv][2]; - - TLVertices[0].sx = D3DVAL( VB->Win[v1][0] ); - TLVertices[0].sy = D3DVAL( (height - VB->Win[v1][1]) ); - TLVertices[0].sz = D3DVAL( (VB->Win[v1][2] + ctx->PolygonZoffset) ); - TLVertices[0].tu = D3DVAL( VB->TexCoord[v1][0] ); - TLVertices[0].tv = D3DVAL( VB->TexCoord[v1][1] ); - TLVertices[0].rhw = D3DVAL( (1.0 / VB->Clip[v1][3]) ); - TLVertices[0].color = (ctx->Light.ShadeModel == GL_FLAT) ? dwPVColor : - (VB->Color[v1][3]<<24) | (VB->Color[v1][0]<<16) | (VB->Color[v1][1]<<8) | VB->Color[v1][2]; - DPF(( DBG_PRIM_INFO, "V1 -> x:%f y:%f z:%f c:%x", - TLVertices[0].sx, - TLVertices[0].sy, - TLVertices[0].sz, - TLVertices[0].color )); - - TLVertices[1].sx = D3DVAL( VB->Win[v2][0] ); - TLVertices[1].sy = D3DVAL( (height - VB->Win[v2][1]) ); - TLVertices[1].sz = D3DVAL( (VB->Win[v2][2] + ctx->PolygonZoffset) ); - TLVertices[1].tu = D3DVAL( VB->TexCoord[v2][0] ); - TLVertices[1].tv = D3DVAL( VB->TexCoord[v2][1] ); - TLVertices[1].rhw = D3DVAL( (1.0 / VB->Clip[v2][3]) ); - TLVertices[1].color = (ctx->Light.ShadeModel == GL_FLAT) ? dwPVColor : - (VB->Color[v2][3]<<24) | (VB->Color[v2][0]<<16) | (VB->Color[v2][1]<<8) | VB->Color[v2][2]; - DPF(( DBG_PRIM_INFO, "V2 -> x:%f y:%f z:%f c:%x", - TLVertices[1].sx, - TLVertices[1].sy, - TLVertices[1].sz, - TLVertices[1].color )); - - TLVertices[2].sx = D3DVAL( VB->Win[v3][0] ); - TLVertices[2].sy = D3DVAL( (height - VB->Win[v3][1]) ); - TLVertices[2].sz = D3DVAL( (VB->Win[v3][2] + ctx->PolygonZoffset) ); - TLVertices[2].tu = D3DVAL( VB->TexCoord[v3][0] ); - TLVertices[2].tv = D3DVAL( VB->TexCoord[v3][1] ); - TLVertices[2].rhw = D3DVAL( (1.0 / VB->Clip[v3][3]) ); - TLVertices[2].color = (ctx->Light.ShadeModel == GL_FLAT) ? dwPVColor : - (VB->Color[v3][3]<<24) | (VB->Color[v3][0]<<16) | (VB->Color[v3][1]<<8) | VB->Color[v3][2]; - DPF(( DBG_PRIM_INFO, "V3 -> x:%f y:%f z:%f c:%x", - TLVertices[2].sx, - TLVertices[2].sy, - TLVertices[2].sz, - TLVertices[2].color )); - - /* Draw the triangle. */ - DrawPrimitiveHAL( pContext->pShared, D3DPT_TRIANGLELIST, &TLVertices[0], 3 ); -} -/*===========================================================================*/ -/* */ -/*===========================================================================*/ -/* RETURN: TRUE, FALSE. */ -/*===========================================================================*/ -void RenderOneLine( GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv ) -{ - D3DMESACONTEXT *pContext = (D3DMESACONTEXT *)ctx->DriverCtx; - struct vertex_buffer *VB = ctx->VB; - int height = (pContext->pShared->rectW.bottom - pContext->pShared->rectW.top); - DWORD dwPVColor; - static D3DTLVERTEX TLVertices[2]; - - DPF(( DBG_FUNC, "RenderOneLine" )); - DPF(( DBG_PRIM_INFO, "RenderLine( 1 )" )); - - if ( VB->MonoColor ) - dwPVColor = (pContext->aCurrent<<24) | (pContext->rCurrent<<16) | (pContext->gCurrent<<8) | pContext->bCurrent; - else - dwPVColor = (VB->Color[pv][3]<<24) | (VB->Color[pv][0]<<16) | (VB->Color[pv][1]<<8) | VB->Color[pv][2]; - - TLVertices[0].sx = D3DVAL( VB->Win[v1][0] ); - TLVertices[0].sy = D3DVAL( (height - VB->Win[v1][1]) ); - TLVertices[0].sz = D3DVAL( (VB->Win[v1][2] + ctx->LineZoffset) ); - TLVertices[0].tu = D3DVAL( VB->TexCoord[v1][0] ); - TLVertices[0].tv = D3DVAL( VB->TexCoord[v1][1] ); - TLVertices[0].rhw = D3DVAL( (1.0 / VB->Clip[v1][3]) ); - TLVertices[0].color = (ctx->Light.ShadeModel == GL_FLAT) ? dwPVColor : - (VB->Color[v1][3]<<24) | (VB->Color[v1][0]<<16) | (VB->Color[v1][1]<<8) | VB->Color[v1][2]; - - TLVertices[1].sx = D3DVAL( VB->Win[v2][0] ); - TLVertices[1].sy = D3DVAL( (height - VB->Win[v2][1]) ); - TLVertices[1].sz = D3DVAL( (VB->Win[v2][2] + ctx->LineZoffset) ); - TLVertices[1].tu = D3DVAL( VB->TexCoord[v2][0] ); - TLVertices[1].tv = D3DVAL( VB->TexCoord[v2][1] ); - TLVertices[1].rhw = D3DVAL( (1.0 / VB->Clip[v2][3]) ); - TLVertices[1].color = (ctx->Light.ShadeModel == GL_FLAT) ? dwPVColor : - (VB->Color[v2][3]<<24) | (VB->Color[v2][0]<<16) | (VB->Color[v2][1]<<8) | VB->Color[v2][2]; - - /* Draw line from (x0,y0) to (x1,y1) with current pixel color/index */ - DrawPrimitiveHAL( pContext->pShared, D3DPT_LINELIST, &TLVertices[0], 2 ); -} -/*===========================================================================*/ -/* This function was written to convert points into triangles. I did this */ -/* as all card accelerate triangles and most drivers do this anyway. In hind*/ -/* thought this might be a bad idea as some cards do better. */ -/*===========================================================================*/ -/* RETURN: */ -/*===========================================================================*/ -static void RenderPointsVB( GLcontext *ctx, GLuint start, GLuint end ) -{ - D3DMESACONTEXT *pContext = (D3DMESACONTEXT *)ctx->DriverCtx; - struct vertex_buffer *VB = ctx->VB; - struct pixel_buffer *PB = ctx->PB; - GLuint index; - GLfloat radius, z, - xmin, ymin, - xmax, ymax; - GLint cVertex, - height = (pContext->pShared->rectW.bottom - pContext->pShared->rectW.top); - DWORD dwPVColor; - - DPF(( DBG_FUNC, "RenderPointsVB();" )); - - radius = CLAMP( ctx->Point.Size, MIN_POINT_SIZE, MAX_POINT_SIZE ) * 0.5F; - - for( index = start, cVertex = 0; index <= end; index++ ) - { - if ( VB->ClipMask[index] == 0 ) - { - xmin = D3DVAL( VB->Win[index][0] - radius ); - xmax = D3DVAL( VB->Win[index][0] + radius ); - ymin = D3DVAL( height - VB->Win[index][1] - radius ); - ymax = D3DVAL( height - VB->Win[index][1] + radius ); - z = D3DVAL( (VB->Win[index][2] + ctx->PointZoffset) ); - - dwPVColor = (VB->Color[index][3]<<24) | - (VB->Color[index][0]<<16) | - (VB->Color[index][1]<<8) | - VB->Color[index][2]; - - D3DTLVertices[cVertex].sx = xmin; - D3DTLVertices[cVertex].sy = ymax; - D3DTLVertices[cVertex].sz = z; - D3DTLVertices[cVertex].tu = 0.0; - D3DTLVertices[cVertex].tv = 0.0; - D3DTLVertices[cVertex].rhw = D3DVAL( (1.0 / VB->Clip[index][3]) ); - D3DTLVertices[cVertex++].color = dwPVColor; - - D3DTLVertices[cVertex].sx = xmin; - D3DTLVertices[cVertex].sy = ymin; - D3DTLVertices[cVertex].sz = z; - D3DTLVertices[cVertex].tu = 0.0; - D3DTLVertices[cVertex].tv = 0.0; - D3DTLVertices[cVertex].rhw = D3DVAL( (1.0 / VB->Clip[index][3]) ); - D3DTLVertices[cVertex++].color = dwPVColor; - - D3DTLVertices[cVertex].sx = xmax; - D3DTLVertices[cVertex].sy = ymin; - D3DTLVertices[cVertex].sz = z; - D3DTLVertices[cVertex].tu = 0.0; - D3DTLVertices[cVertex].tv = 0.0; - D3DTLVertices[cVertex].rhw = D3DVAL( (1.0 / VB->Clip[index][3]) ); - D3DTLVertices[cVertex++].color = dwPVColor; - - D3DTLVertices[cVertex].sx = xmax; - D3DTLVertices[cVertex].sy = ymin; - D3DTLVertices[cVertex].sz = z; - D3DTLVertices[cVertex].tu = 0.0; - D3DTLVertices[cVertex].tv = 0.0; - D3DTLVertices[cVertex].rhw = D3DVAL( (1.0 / VB->Clip[index][3]) ); - D3DTLVertices[cVertex++].color = dwPVColor; - - D3DTLVertices[cVertex].sx = xmax; - D3DTLVertices[cVertex].sy = ymax; - D3DTLVertices[cVertex].sz = z; - D3DTLVertices[cVertex].tu = 0.0; - D3DTLVertices[cVertex].tv = 0.0; - D3DTLVertices[cVertex].rhw = D3DVAL( (1.0 / VB->Clip[index][3]) ); - D3DTLVertices[cVertex++].color = dwPVColor; - - D3DTLVertices[cVertex].sx = xmin; - D3DTLVertices[cVertex].sy = ymax; - D3DTLVertices[cVertex].sz = z; - D3DTLVertices[cVertex].tu = 0.0; - D3DTLVertices[cVertex].tv = 0.0; - D3DTLVertices[cVertex].rhw = D3DVAL( (1.0 / VB->Clip[index][3]) ); - D3DTLVertices[cVertex++].color = dwPVColor; - } - } - - /* Render the converted vertex buffer. */ - if ( cVertex ) - DrawPrimitiveHAL( pContext->pShared, D3DPT_TRIANGLELIST, &D3DTLVertices[0], cVertex ); -} -/*===========================================================================*/ -/* This gets call before we render any primitives so that the current OGL */ -/* states will be mapped the D3D context. I'm still not sure how D3D works */ -/* but I'm finding that it doesn't act like a state machine as OGL is. It */ -/* looks like the state gets set back to the defaults after a DrawPrimitives */ -/* or an EndScene. Also I set states that are the default even though this */ -/* is redundant as the defaults seem screwed up. */ -/* TODO: make a batch call. */ -/*===========================================================================*/ -/* RETURN: */ -/*===========================================================================*/ -static void SetRenderStates( GLcontext *ctx ) -{ - D3DMESACONTEXT *pContext = (D3DMESACONTEXT *)ctx->DriverCtx; - DWORD dwFunc; - static BOOL bTexture = FALSE; - static int texName = -1; - - DPF(( DBG_FUNC, "SetRenderStates();" )); - - if ( g_DBGMask & DBG_STATES ) - DebugRenderStates( ctx, FALSE ); - - SetStateHAL( pContext->pShared, D3DRENDERSTATE_CULLMODE, D3DCULL_NONE ); - SetStateHAL( pContext->pShared, D3DRENDERSTATE_DITHERENABLE, (ctx->Color.DitherFlag) ? TRUE : FALSE ); - - /*================================================*/ - /* Check too see if there are new TEXTURE states. */ - /*================================================*/ - if ( ctx->Texture._EnabledUnits ) - { - switch( ctx->Texture.Set[ctx->Texture.CurrentSet].EnvMode ) - { - case GL_MODULATE: - if ( ctx->Texture.Set[ctx->Texture.CurrentSet].Current->Image[0][0]->Format == GL_RGBA ) - dwFunc = pContext->pShared->dwTexFunc[d3dtblend_modulatealpha]; - else - dwFunc = pContext->pShared->dwTexFunc[d3dtblend_modulate]; - break; - - case GL_BLEND: - dwFunc = pContext->pShared->dwTexFunc[d3dtblend_decalalpha]; - break; - - case GL_REPLACE: - dwFunc = pContext->pShared->dwTexFunc[d3dtblend_decal]; - break; - - case GL_DECAL: - if ( ctx->Texture.Set[ctx->Texture.CurrentSet].Current->Image[0][0]->Format == GL_RGBA ) - dwFunc = pContext->pShared->dwTexFunc[d3dtblend_decalalpha]; - else - dwFunc = pContext->pShared->dwTexFunc[d3dtblend_decal]; - break; - } - SetStateHAL( pContext->pShared, D3DRENDERSTATE_TEXTUREMAPBLEND, dwFunc ); - - switch( ctx->Texture.Set[ctx->Texture.CurrentSet].Current->MagFilter ) - { - case GL_NEAREST: - dwFunc = D3DFILTER_NEAREST; - break; - case GL_LINEAR: - dwFunc = D3DFILTER_LINEAR; - break; - case GL_NEAREST_MIPMAP_NEAREST: - dwFunc = D3DFILTER_MIPNEAREST; - break; - case GL_LINEAR_MIPMAP_NEAREST: - dwFunc = D3DFILTER_LINEARMIPNEAREST; - break; - case GL_NEAREST_MIPMAP_LINEAR: - dwFunc = D3DFILTER_MIPLINEAR; - break; - case GL_LINEAR_MIPMAP_LINEAR: - dwFunc = D3DFILTER_LINEARMIPLINEAR; - break; - } - SetStateHAL( pContext->pShared, D3DRENDERSTATE_TEXTUREMAG, dwFunc ); - - switch( ctx->Texture.Set[ctx->Texture.CurrentSet].Current->MinFilter ) - { - case GL_NEAREST: - dwFunc = D3DFILTER_NEAREST; - break; - case GL_LINEAR: - dwFunc = D3DFILTER_LINEAR; - break; - case GL_NEAREST_MIPMAP_NEAREST: - dwFunc = D3DFILTER_MIPNEAREST; - break; - case GL_LINEAR_MIPMAP_NEAREST: - dwFunc = D3DFILTER_LINEARMIPNEAREST; - break; - case GL_NEAREST_MIPMAP_LINEAR: - dwFunc = D3DFILTER_MIPLINEAR; - break; - case GL_LINEAR_MIPMAP_LINEAR: - dwFunc = D3DFILTER_LINEARMIPLINEAR; - break; - } - SetStateHAL( pContext->pShared, D3DRENDERSTATE_TEXTUREMIN, dwFunc ); - - /* Another hack to cut down on redundant texture binding. */ - // if ( texName != ctx->Texture.Set[ctx->Texture.CurrentSet].Current->Name ) - // { - texName = ctx->Texture.Set[ctx->Texture.CurrentSet].Current->Name; - CreateTMgrHAL( pContext->pShared, - texName, - 0, - ctx->Texture.Set[ctx->Texture.CurrentSet].Current->Image[0][0]->Format, - (RECT *)NULL, - ctx->Texture.Set[ctx->Texture.CurrentSet].Current->Image[0][0]->Width, - ctx->Texture.Set[ctx->Texture.CurrentSet].Current->Image[0][0]->Height, - TM_ACTION_BIND, - (void *)ctx->Texture.Set[ctx->Texture.CurrentSet].Current->Image[0][0]->Data ); - // } - bTexture = TRUE; - } - else - { - /* This is nasty but should cut down on the number of redundant calls. */ - if ( bTexture == TRUE ) - { - DisableTMgrHAL( pContext->pShared ); - bTexture = FALSE; - } - } - - /*===============================================*/ - /* Check too see if there are new RASTER states. */ - /*===============================================*/ - - // TODO: no concept of front & back. - switch( ctx->Polygon.FrontMode ) - { - case GL_POINT: - SetStateHAL( pContext->pShared, D3DRENDERSTATE_FILLMODE, D3DFILL_POINT ); - break; - case GL_LINE: - SetStateHAL( pContext->pShared, D3DRENDERSTATE_FILLMODE, D3DFILL_WIREFRAME ); - break; - case GL_FILL: - SetStateHAL( pContext->pShared, D3DRENDERSTATE_FILLMODE, D3DFILL_SOLID ); - break; - } - - /*************/ - /* Z-Buffer. */ - /*************/ - if ( ctx->Depth.Test == GL_TRUE ) - { - switch( ctx->Depth.Func ) - { - case GL_NEVER: - dwFunc = D3DCMP_NEVER; - break; - case GL_LESS: - dwFunc = D3DCMP_LESS; - break; - case GL_GEQUAL: - dwFunc = D3DCMP_GREATEREQUAL; - break; - case GL_LEQUAL: - dwFunc = D3DCMP_LESSEQUAL; - break; - case GL_GREATER: - dwFunc = D3DCMP_GREATER; - break; - case GL_NOTEQUAL: - dwFunc = D3DCMP_NOTEQUAL; - break; - case GL_EQUAL: - dwFunc = D3DCMP_EQUAL; - break; - case GL_ALWAYS: - dwFunc = D3DCMP_ALWAYS; - break; - } - SetStateHAL( pContext->pShared, D3DRENDERSTATE_ZFUNC, dwFunc ); - SetStateHAL( pContext->pShared, D3DRENDERSTATE_ZENABLE, TRUE ); - } - else - { - SetStateHAL( pContext->pShared, D3DRENDERSTATE_ZENABLE, FALSE ); - } - - /*******************/ - /* Z-Write Enable. */ - /*******************/ - SetStateHAL( pContext->pShared, D3DRENDERSTATE_ZWRITEENABLE , (ctx->Depth.Mask == GL_TRUE) ? TRUE : FALSE ); - - /***************/ - /* Alpha test. */ - /***************/ - if ( ctx->Color.AlphaEnabled == GL_TRUE ) - { - switch( ctx->Color.AlphaFunc ) - { - case GL_NEVER: - dwFunc = D3DCMP_NEVER; - break; - case GL_LESS: - dwFunc = D3DCMP_LESS; - break; - case GL_GEQUAL: - dwFunc = D3DCMP_GREATEREQUAL; - break; - case GL_LEQUAL: - dwFunc = D3DCMP_LESSEQUAL; - break; - case GL_GREATER: - dwFunc = D3DCMP_GREATER; - break; - case GL_NOTEQUAL: - dwFunc = D3DCMP_NOTEQUAL; - break; - case GL_EQUAL: - dwFunc = D3DCMP_EQUAL; - break; - case GL_ALWAYS: - dwFunc = D3DCMP_ALWAYS; - break; - } - SetStateHAL( pContext->pShared, D3DRENDERSTATE_ALPHAFUNC , dwFunc ); - SetStateHAL( pContext->pShared, D3DRENDERSTATE_ALPHATESTENABLE, TRUE ); - } - else - { - SetStateHAL( pContext->pShared, D3DRENDERSTATE_ALPHATESTENABLE, FALSE ); - } - - /****************/ - /* Alpha blend. */ - /****************/ - if ( ctx->Color.BlendEnabled == GL_TRUE ) - { - switch( ctx->Color.BlendSrc ) - { - case GL_ZERO: - dwFunc = pContext->pShared->dwSrcBlendCaps[s_zero]; - break; - case GL_ONE: - dwFunc = pContext->pShared->dwSrcBlendCaps[s_one]; - break; - case GL_DST_COLOR: - dwFunc = pContext->pShared->dwSrcBlendCaps[s_dst_color]; - break; - case GL_ONE_MINUS_DST_COLOR: - dwFunc = pContext->pShared->dwSrcBlendCaps[s_one_minus_dst_color]; - break; - case GL_SRC_ALPHA: - dwFunc = pContext->pShared->dwSrcBlendCaps[s_src_alpha]; - break; - case GL_ONE_MINUS_SRC_ALPHA: - dwFunc = pContext->pShared->dwSrcBlendCaps[s_one_minus_src_alpha]; - break; - case GL_DST_ALPHA: - dwFunc = pContext->pShared->dwSrcBlendCaps[s_dst_alpha]; - break; - case GL_ONE_MINUS_DST_ALPHA: - dwFunc = pContext->pShared->dwSrcBlendCaps[s_one_minus_dst_alpha]; - break; - case GL_SRC_ALPHA_SATURATE: - dwFunc = pContext->pShared->dwSrcBlendCaps[s_src_alpha_saturate]; - break; - case GL_CONSTANT_COLOR: - dwFunc = pContext->pShared->dwSrcBlendCaps[s_constant_color]; - break; - case GL_ONE_MINUS_CONSTANT_COLOR: - dwFunc = pContext->pShared->dwSrcBlendCaps[s_one_minus_constant_color]; - break; - case GL_CONSTANT_ALPHA: - dwFunc = pContext->pShared->dwSrcBlendCaps[s_constant_alpha]; - break; - case GL_ONE_MINUS_CONSTANT_ALPHA: - dwFunc = pContext->pShared->dwSrcBlendCaps[s_one_minus_constant_alpha]; - break; - } - SetStateHAL( pContext->pShared, D3DRENDERSTATE_SRCBLEND, dwFunc ); - - switch( ctx->Color.BlendDst ) - { - case GL_ZERO: - dwFunc = pContext->pShared->dwDestBlendCaps[d_zero]; - break; - case GL_ONE: - dwFunc = pContext->pShared->dwDestBlendCaps[d_one]; - break; - case GL_SRC_COLOR: - dwFunc = pContext->pShared->dwDestBlendCaps[d_src_color]; - break; - case GL_ONE_MINUS_SRC_COLOR: - dwFunc = pContext->pShared->dwDestBlendCaps[d_one_minus_src_color]; - break; - case GL_SRC_ALPHA: - dwFunc = pContext->pShared->dwDestBlendCaps[d_src_alpha]; - break; - case GL_ONE_MINUS_SRC_ALPHA: - dwFunc = pContext->pShared->dwDestBlendCaps[d_one_minus_src_alpha]; - break; - case GL_DST_ALPHA: - dwFunc = pContext->pShared->dwDestBlendCaps[d_dst_alpha]; - break; - case GL_ONE_MINUS_DST_ALPHA: - dwFunc = pContext->pShared->dwDestBlendCaps[d_one_minus_dst_alpha]; - break; - case GL_CONSTANT_COLOR: - dwFunc = pContext->pShared->dwDestBlendCaps[d_constant_color]; - break; - case GL_ONE_MINUS_CONSTANT_COLOR: - dwFunc = pContext->pShared->dwDestBlendCaps[d_one_minus_constant_color]; - break; - case GL_CONSTANT_ALPHA: - dwFunc = pContext->pShared->dwDestBlendCaps[d_constant_alpha]; - break; - case GL_ONE_MINUS_CONSTANT_ALPHA: - dwFunc = pContext->pShared->dwDestBlendCaps[d_one_minus_constant_alpha]; - break; - } - SetStateHAL( pContext->pShared, D3DRENDERSTATE_DESTBLEND, dwFunc ); - SetStateHAL( pContext->pShared, D3DRENDERSTATE_ALPHABLENDENABLE, TRUE ); - } - else - { - SetStateHAL( pContext->pShared, D3DRENDERSTATE_ALPHABLENDENABLE, FALSE ); - } -} -/*===========================================================================*/ -/* If this function is called it will track the changes to the current */ -/* states that I'm setting in Direct3D. I did this so that the DPF's would */ -/* be under control! */ -/*===========================================================================*/ -/* RETURN: */ -/*===========================================================================*/ -static void DebugRenderStates( GLcontext *ctx, BOOL bForce ) -{ - D3DMESACONTEXT *pContext = (D3DMESACONTEXT *)ctx->DriverCtx; - DWORD dwFunc; - static int dither = -1, - texture = -1, - textName = -1, - textEnv = -1, - textMin = -1, - textMag = -1, - polyMode = -1, - depthTest = -1, - depthFunc = -1, - depthMask = -1, - alphaTest = -1, - alphaFunc = -1, - blend = -1, - blendSrc = -1, - blendDest = -1; - - /* Force a displayed update of all current states. */ - if ( bForce ) - { - dither = texture = textName = textEnv = textMin = textMag = -1; - polyMode = depthTest = depthFunc = depthMask = -1; - alphaTest = alphaFunc = blend = blendSrc = blendDest = -1; - } - - if ( dither != ctx->Color.DitherFlag ) - { - dither = ctx->Color.DitherFlag; - DPF(( 0, "\tDither\t\t%s", (dither) ? "ENABLED" : "--------" )); - } - if ( depthTest != ctx->Depth.Test ) - { - depthTest = ctx->Depth.Test; - DPF(( 0, "\tDepth Test\t%s", (depthTest) ? "ENABLED" : "--------" )); - } - if ( alphaTest != ctx->Color.AlphaEnabled ) - { - alphaTest = ctx->Color.AlphaEnabled; - - DPF(( 0, "\tAlpha Test\t%s", (alphaTest) ? "ENABLED" : "--------" )); - } - if ( blend != ctx->Color.BlendEnabled ) - { - blend = ctx->Color.BlendEnabled; - - DPF(( 0, "\tBlending\t%s", (blend) ? "ENABLED" : "--------" )); - } - - /*================================================*/ - /* Check too see if there are new TEXTURE states. */ - /*================================================*/ - if ( texture != ctx->Texture._EnabledUnits ) - { - texture = ctx->Texture._EnabledUnits; - DPF(( 0, "\tTexture\t\t%s", (texture) ? "ENABLED" : "--------" )); - } - - if ( ctx->Texture.Set[ctx->Texture.CurrentSet].Current ) - { - if ( ctx->Texture.Set[ctx->Texture.CurrentSet].Current->Name != textName ) - { - textName = ctx->Texture.Set[ctx->Texture.CurrentSet].Current->Name; - DPF(( 0, "\tTexture Name:\t%d", textName )); - DPF(( 0, "\tTexture Format:\t%s", - (ctx->Texture.Set[ctx->Texture.CurrentSet].Current->Image[0][0]->Format == GL_RGBA) ? - "GL_RGBA" : "GLRGB" )); - } - - if ( textEnv != ctx->Texture.Set[ctx->Texture.CurrentSet].EnvMode ) - { - textEnv = ctx->Texture.Set[ctx->Texture.CurrentSet].EnvMode; - - switch( textEnv ) - { - case GL_MODULATE: - DPF(( 0, "\tTexture\tMode\tGL_MODULATE" )); - break; - case GL_BLEND: - DPF(( 0, "\tTexture\tMode\tGL_BLEND" )); - break; - case GL_REPLACE: - DPF(( 0, "\tTexture\tMode\tGL_REPLACE" )); - break; - case GL_DECAL: - DPF(( 0, "\tTexture\tMode\tGL_DECAL" )); - break; - } - } - - if ( textMag != ctx->Texture.Set[ctx->Texture.CurrentSet].Current->MagFilter ) - { - textMag = ctx->Texture.Set[ctx->Texture.CurrentSet].Current->MagFilter; - - switch( textMag ) - { - case GL_NEAREST: - DPF(( 0, "\tTexture MAG\tGL_NEAREST" )); - break; - case GL_LINEAR: - DPF(( 0, "\tTexture MAG\tGL_LINEAR" )); - break; - case GL_NEAREST_MIPMAP_NEAREST: - DPF(( 0, "\tTexture MAG\tGL_NEAREST_MIPMAP_NEAREST" )); - break; - case GL_LINEAR_MIPMAP_NEAREST: - DPF(( 0, "\tTexture MAG\tGL_LINEAR_MIPMAP_NEAREST" )); - break; - case GL_NEAREST_MIPMAP_LINEAR: - DPF(( 0, "\tTexture MAG\tGL_NEAREST_MIPMAP_LINEAR" )); - break; - case GL_LINEAR_MIPMAP_LINEAR: - DPF(( 0, "\tTexture MAG\tGL_LINEAR_MIPMAP_LINEAR" )); - break; - } - } - - if ( textMin != ctx->Texture.Set[ctx->Texture.CurrentSet].Current->MinFilter ) - { - textMin = ctx->Texture.Set[ctx->Texture.CurrentSet].Current->MinFilter; - - switch( textMin ) - { - case GL_NEAREST: - DPF(( 0, "\tTexture MIN\tGL_NEAREST" )); - break; - case GL_LINEAR: - DPF(( 0, "\tTexture MIN\tGL_LINEAR" )); - break; - case GL_NEAREST_MIPMAP_NEAREST: - DPF(( 0, "\tTexture MIN\tGL_NEAREST_MIPMAP_NEAREST" )); - break; - case GL_LINEAR_MIPMAP_NEAREST: - DPF(( 0, "\tTexture MIN\tGL_LINEAR_MIPMAP_NEAREST" )); - break; - case GL_NEAREST_MIPMAP_LINEAR: - DPF(( 0, "\tTexture MIN\tGL_LINEAR_MIPMAP_LINEAR" )); - break; - case GL_LINEAR_MIPMAP_LINEAR: - DPF(( 0, "\tTexture MIN\tGL_LINEAR_MIPMAP_LINEAR" )); - break; - } - } - } - - if ( ctx->Polygon.FrontMode != polyMode ) - { - polyMode = ctx->Polygon.FrontMode; - - switch( polyMode ) - { - case GL_POINT: - DPF(( 0, "\tMode\t\tGL_POINT" )); - break; - case GL_LINE: - DPF(( 0, "\tMode\t\tGL_LINE" )); - break; - case GL_FILL: - DPF(( 0, "\tMode\t\tGL_FILL" )); - break; - } - } - - if ( depthFunc != ctx->Depth.Func ) - { - depthFunc = ctx->Depth.Func; - - switch( depthFunc ) - { - case GL_NEVER: - DPF(( 0, "\tDepth Func\tGL_NEVER" )); - break; - case GL_LESS: - DPF(( 0, "\tDepth Func\tGL_LESS" )); - break; - case GL_GEQUAL: - DPF(( 0, "\tDepth Func\tGL_GEQUAL" )); - break; - case GL_LEQUAL: - DPF(( 0, "\tDepth Func\tGL_LEQUAL" )); - break; - case GL_GREATER: - DPF(( 0, "\tDepth Func\tGL_GREATER" )); - break; - case GL_NOTEQUAL: - DPF(( 0, "\tDepth Func\tGL_NOTEQUAL" )); - break; - case GL_EQUAL: - DPF(( 0, "\tDepth Func\tGL_EQUAL" )); - break; - case GL_ALWAYS: - DPF(( 0, "\tDepth Func\tGL_ALWAYS" )); - break; - } - } - - if ( depthMask != ctx->Depth.Mask ) - { - depthMask = ctx->Depth.Mask; - DPF(( 0, "\tZWrite\t\t%s", (depthMask) ? "ENABLED" : "--------" )); - } - - if ( alphaFunc != ctx->Color.AlphaFunc ) - { - alphaFunc = ctx->Color.AlphaFunc; - - switch( alphaFunc ) - { - case GL_NEVER: - DPF(( 0, "\tAlpha Func\tGL_NEVER" )); - break; - case GL_LESS: - DPF(( 0, "\tAlpha Func\tGL_LESS" )); - break; - case GL_GEQUAL: - DPF(( 0, "\tAlpha Func\tGL_GEQUAL" )); - break; - case GL_LEQUAL: - DPF(( 0, "\tAlpha Func\tGL_LEQUAL" )); - break; - case GL_GREATER: - DPF(( 0, "\tAlpha Func\tGL_GREATER" )); - break; - case GL_NOTEQUAL: - DPF(( 0, "\tAlpha Func\tGL_NOTEQUAL" )); - break; - case GL_EQUAL: - DPF(( 0, "\tAlpha Func\tGL_EQUAL" )); - break; - case GL_ALWAYS: - DPF(( 0, "\tAlpha Func\tGL_ALWAYS" )); - break; - } - } - - if ( blendSrc != ctx->Color.BlendSrc ) - { - blendSrc = ctx->Color.BlendSrc; - - switch( blendSrc ) - { - case GL_ZERO: - DPF(( 0, "\tSRC Blend\tGL_ZERO" )); - break; - case GL_ONE: - DPF(( 0, "\tSRC Blend\tGL_ONE" )); - break; - case GL_DST_COLOR: - DPF(( 0, "\tSRC Blend\tGL_DST_COLOR" )); - break; - case GL_ONE_MINUS_DST_COLOR: - DPF(( 0, "\tSRC Blend\tGL_ONE_MINUS_DST_COLOR" )); - break; - case GL_SRC_ALPHA: - DPF(( 0, "\tSRC Blend\tGL_SRC_ALPHA" )); - break; - case GL_ONE_MINUS_SRC_ALPHA: - DPF(( 0, "\tSRC Blend\tGL_MINUS_SRC_ALPHA" )); - break; - case GL_DST_ALPHA: - DPF(( 0, "\tSRC Blend\tGL_DST_ALPHA" )); - break; - case GL_ONE_MINUS_DST_ALPHA: - DPF(( 0, "\tSRC Blend\tGL_ONE_MINUS_DST_ALPHA" )); - break; - case GL_SRC_ALPHA_SATURATE: - DPF(( 0, "\tSRC Blend\tGL_SRC_ALPHA_SATURATE" )); - break; - case GL_CONSTANT_COLOR: - DPF(( 0, "\tSRC Blend\tGL_CONSTANT_COLOR" )); - break; - case GL_ONE_MINUS_CONSTANT_COLOR: - DPF(( 0, "\tSRC Blend\tGL_ONE_MINUS_CONSTANT_COLOR" )); - break; - case GL_CONSTANT_ALPHA: - DPF(( 0, "\tSRC Blend\tGL_CONSTANT_ALPHA" )); - break; - case GL_ONE_MINUS_CONSTANT_ALPHA: - DPF(( 0, "\tSRC Blend\tGL_ONE_MINUS_CONSTANT_ALPHA" )); - break; - } - } - - if ( blendDest != ctx->Color.BlendDst ) - { - blendDest = ctx->Color.BlendDst; - - switch( blendDest ) - { - case GL_ZERO: - DPF(( 0, "\tDST Blend\tGL_ZERO" )); - break; - case GL_ONE: - DPF(( 0, "\tDST Blend\tGL_ONE" )); - break; - case GL_SRC_COLOR: - DPF(( 0, "\tDST Blend\tGL_SRC_COLOR" )); - break; - case GL_ONE_MINUS_SRC_COLOR: - DPF(( 0, "\tDST Blend\tGL_ONE_MINUS_SRC_COLOR" )); - break; - case GL_SRC_ALPHA: - DPF(( 0, "\tDST Blend\tGL_SRC_ALPHA" )); - break; - case GL_ONE_MINUS_SRC_ALPHA: - DPF(( 0, "\tDST Blend\tGL_ONE_MINUS_SRC_ALPHA" )); - break; - case GL_DST_ALPHA: - DPF(( 0, "\tDST Blend\tGL_DST_ALPHA" )); - break; - case GL_ONE_MINUS_DST_ALPHA: - DPF(( 0, "\tDST Blend\tGL_ONE_MINUS_DST_ALPHA" )); - break; - case GL_CONSTANT_COLOR: - DPF(( 0, "\tDST Blend\tGL_CONSTANT_COLOR" )); - break; - case GL_ONE_MINUS_CONSTANT_COLOR: - DPF(( 0, "\tDST Blend\tGL_ONE_MINUS_CONSTANT_COLOR" )); - break; - case GL_CONSTANT_ALPHA: - DPF(( 0, "\tDST Blend\tGL_CONSTANT_ALPHA" )); - break; - case GL_ONE_MINUS_CONSTANT_ALPHA: - DPF(( 0, "\tDST Blend\tGL_ONE_MINUS_CONSTANT_ALPHA" )); - break; - } - } -} diff --git a/src/mesa/drivers/d3d/DDrawPROCS.c b/src/mesa/drivers/d3d/DDrawPROCS.c deleted file mode 100644 index 10dcfdbabba..00000000000 --- a/src/mesa/drivers/d3d/DDrawPROCS.c +++ /dev/null @@ -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 ); -} diff --git a/src/mesa/drivers/d3d/DEBUG.C b/src/mesa/drivers/d3d/DEBUG.C deleted file mode 100644 index 79e273903ac..00000000000 --- a/src/mesa/drivers/d3d/DEBUG.C +++ /dev/null @@ -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 )); -} - - - - - diff --git a/src/mesa/drivers/d3d/DEBUG.H b/src/mesa/drivers/d3d/DEBUG.H deleted file mode 100644 index daeeb722784..00000000000 --- a/src/mesa/drivers/d3d/DEBUG.H +++ /dev/null @@ -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 - - - diff --git a/src/mesa/drivers/d3d/DbgEnv.bat b/src/mesa/drivers/d3d/DbgEnv.bat deleted file mode 100644 index acea0458565..00000000000 --- a/src/mesa/drivers/d3d/DbgEnv.bat +++ /dev/null @@ -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 diff --git a/src/mesa/drivers/d3d/MAKEFILE b/src/mesa/drivers/d3d/MAKEFILE deleted file mode 100644 index 6aa88f3cef4..00000000000 --- a/src/mesa/drivers/d3d/MAKEFILE +++ /dev/null @@ -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: - - - - diff --git a/src/mesa/drivers/d3d/NULLProcs.h b/src/mesa/drivers/d3d/NULLProcs.h deleted file mode 100644 index f0bbd2162dd..00000000000 --- a/src/mesa/drivers/d3d/NULLProcs.h +++ /dev/null @@ -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 - diff --git a/src/mesa/drivers/d3d/NullProcs.c b/src/mesa/drivers/d3d/NullProcs.c deleted file mode 100644 index d6fb598074b..00000000000 --- a/src/mesa/drivers/d3d/NullProcs.c +++ /dev/null @@ -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 - diff --git a/src/mesa/drivers/d3d/OPENGL32.DEF b/src/mesa/drivers/d3d/OPENGL32.DEF deleted file mode 100644 index bc0304da331..00000000000 --- a/src/mesa/drivers/d3d/OPENGL32.DEF +++ /dev/null @@ -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 - - - diff --git a/src/mesa/drivers/d3d/WGL.C b/src/mesa/drivers/d3d/WGL.C deleted file mode 100644 index 170d094ed49..00000000000 --- a/src/mesa/drivers/d3d/WGL.C +++ /dev/null @@ -1,1262 +0,0 @@ -/*===========================================================================*/ -/* */ -/* Mesa-3.0 Makefile for DirectX 6 */ -/* */ -/* By Leigh McRae */ -/* */ -/* http://www.altsoftware.com/ */ -/* */ -/* Copyright (c) 1998-1997 alt.software inc. All Rights Reserved */ -/*===========================================================================*/ -#include "D3DMesa.h" -/*===========================================================================*/ -/* Window managment. */ -/*===========================================================================*/ -static BOOL InitOpenGL( HINSTANCE hInst ); -static BOOL TermOpenGL( HINSTANCE hInst ); -static BOOL ResizeContext( GLcontext *ctx ); -static BOOL MakeCurrent( D3DMESACONTEXT *pContext ); -static void DestroyContext( D3DMESACONTEXT *pContext ); -static BOOL UnBindWindow( D3DMESACONTEXT *pContext ); -LONG APIENTRY wglMonitorProc( HWND hwnd, UINT message, UINT wParam, LONG lParam ); -/*===========================================================================*/ -/* Mesa hooks. */ -/*===========================================================================*/ -static void SetupDDPointers( GLcontext *ctx ); -static void SetupSWDDPointers( GLcontext *ctx ); -static void SetupHWDDPointers( GLcontext *ctx ); -static void SetupNULLDDPointers( GLcontext *ctx ); -static const char *RendererString( void ); - -/* State Management hooks. */ -static void SetColor( GLcontext *ctx, GLubyte r, GLubyte g, GLubyte b, GLubyte a ); -static void ClearColor( GLcontext *ctx, GLubyte r, GLubyte g, GLubyte b, GLubyte a ); -static GLboolean SetBuffer( GLcontext *ctx, GLenum buffer ); - -/* Window Management hooks. */ -static void GetBufferSize( GLcontext *ctx, GLuint *width, GLuint *height ); -static void SetViewport( GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h ); -static void Flush( GLcontext *ctx ); - -/* Span rendering hooks. */ -void WSpanRGB( const GLcontext* ctx, GLuint n, GLint x, GLint y, const GLubyte rgb[][3], const GLubyte mask[] ); -void WSpanRGBA( const GLcontext* ctx, GLuint n, GLint x, GLint y, const GLubyte rgba[][4], const GLubyte mask[] ); -void WSpanRGBAMono( const GLcontext* ctx, GLuint n, GLint x, GLint y, const GLubyte mask[] ); -void WPixelsRGBA( const GLcontext* ctx, GLuint n, const GLint x[], const GLint y[], const GLubyte rgba[][4], const GLubyte mask[] ); -void WPixelsRGBAMono( const GLcontext* ctx, GLuint n, const GLint x[], const GLint y[], const GLubyte mask[] ); -void RSpanRGBA( const GLcontext* ctx, GLuint n, GLint x, GLint y, GLubyte rgba[][4] ); -void RPixelsRGBA( const GLcontext* ctx, GLuint n, const GLint x[], const GLint y[], GLubyte rgba[][4], const GLubyte mask[] ); -GLbitfield ClearBuffers( GLcontext *ctx, GLbitfield mask, GLboolean all, GLint x, GLint y, GLint width, GLint height ); - -/* Primitve rendering hooks. */ -GLboolean RenderVertexBuffer( GLcontext *ctx, GLboolean allDone ); -void RenderOneTriangle( GLcontext *ctx, GLuint v1, GLuint v2, GLuint v3, GLuint pv ); -void RenderOneLine( GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv ); -GLbitfield ClearBuffersD3D( GLcontext *ctx, GLbitfield mask, GLboolean all, GLint x, GLint y, GLint width, GLint height ); - -/* Texture Management hooks. */ -static void TextureBind( GLcontext *ctx, GLenum target, struct gl_texture_object *tObj ); -static void TextureLoad( GLcontext *ctx, GLenum target, struct gl_texture_object *tObj, GLint level, GLint internalFormat, const struct gl_texture_image *image ); -static void TextureSubImage( GLcontext *ctx, GLenum target, struct gl_texture_object *tObj, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLint internalFormat, const struct gl_texture_image *image ); -/*===========================================================================*/ -/* Global variables. */ -/*===========================================================================*/ -D3DMESACONTEXT *pD3DCurrent, - *pD3DDefault; /* Thin support context. */ - -struct __extensions__ ext[] = { - - { (PROC)glPolygonOffsetEXT, "glPolygonOffsetEXT" }, - { (PROC)glBlendEquationEXT, "glBlendEquationEXT" }, - { (PROC)glBlendColorEXT, "glBlendColorExt" }, - { (PROC)glVertexPointerEXT, "glVertexPointerEXT" }, - { (PROC)glNormalPointerEXT, "glNormalPointerEXT" }, - { (PROC)glColorPointerEXT, "glColorPointerEXT" }, - { (PROC)glIndexPointerEXT, "glIndexPointerEXT" }, - { (PROC)glTexCoordPointerEXT, "glTexCoordPointer" }, - { (PROC)glEdgeFlagPointerEXT, "glEdgeFlagPointerEXT" }, - { (PROC)glGetPointervEXT, "glGetPointervEXT" }, - { (PROC)glArrayElementEXT, "glArrayElementEXT" }, - { (PROC)glDrawArraysEXT, "glDrawArrayEXT" }, - { (PROC)glAreTexturesResidentEXT, "glAreTexturesResidentEXT" }, - { (PROC)glBindTextureEXT, "glBindTextureEXT" }, - { (PROC)glDeleteTexturesEXT, "glDeleteTexturesEXT" }, - { (PROC)glGenTexturesEXT, "glGenTexturesEXT" }, - { (PROC)glIsTextureEXT, "glIsTextureEXT" }, - { (PROC)glPrioritizeTexturesEXT, "glPrioritizeTexturesEXT" }, - { (PROC)glCopyTexSubImage3DEXT, "glCopyTexSubImage3DEXT" }, - { (PROC)glTexImage3DEXT, "glTexImage3DEXT" }, - { (PROC)glTexSubImage3DEXT, "glTexSubImage3DEXT" }, -}; - -int qt_ext = sizeof(ext) / sizeof(ext[0]); -float g_DepthScale, - g_MaxDepth; -/*===========================================================================*/ -/* When a process loads this DLL we will setup the linked list for context */ -/* management and create a default context that will support the API until */ -/* the user creates and binds thier own. This THIN default context is useful*/ -/* to have around. */ -/* When the process terminates we will clean up all resources here. */ -/*===========================================================================*/ -/* RETURN: TRUE, FALSE. */ -/*===========================================================================*/ -BOOL APIENTRY DllMain( HINSTANCE hInst, DWORD reason, LPVOID reserved ) -{ - switch( reason ) - { - case DLL_PROCESS_ATTACH: - return InitOpenGL( hInst ); - - case DLL_PROCESS_DETACH: - return TermOpenGL( hInst ); - } - - return TRUE; -} -/*===========================================================================*/ -/* The first thing we do when this dll is hit is connect to the dll that has*/ -/* handles all the DirectX 6 rendering. I decided to use another dll as DX6 */ -/* is all C++ and Mesa-3.0 is C (thats a good thing). This way I can write */ -/* the DX6 in C++ and Mesa-3.0 in C without having to worry about linkage. */ -/* I feel this is easy and better then using static wrappers as it is likely */ -/* faster and it allows me to just develope the one without compiling the */ -/* other. */ -/* NOTE that at this point we don't have much other than a very thin context*/ -/* that will support the API calls only to the point of not causing the app */ -/* to crash from the API table being empty. */ -/*===========================================================================*/ -/* RETURN: TRUE, FALSE. */ -/*===========================================================================*/ -static BOOL InitOpenGL( HINSTANCE hInst ) -{ - /* Allocate and clear the default context. */ - pD3DDefault = (PD3DMESACONTEXT)ALLOC( sizeof(D3DMESACONTEXT) ); - if ( pD3DDefault == NULL ) - return FALSE; - memset( pD3DDefault, 0, sizeof(D3DMESACONTEXT) ); - - /* Clear the D3D vertex buffer so that values not used will be zero. This */ - /* save me from some redundant work. */ - memset( &D3DTLVertices, 0, sizeof(D3DTLVertices) ); - - /* Update the link. We uses a circular list so that it is easy to */ - /* add and search. This context will also be used for head and tail.*/ - pD3DDefault->next = pD3DDefault; - - /*========================================================================*/ - /* Do all core Mesa stuff. */ - /*========================================================================*/ - pD3DDefault->gl_visual = _mesa_create_visual( TRUE, - FALSE, /* db_flag */ - GL_FALSE, /* stereo */ - 8,8,8,8, /* r, g, b, a bits */ - 0, /* index bits */ - 16, /* depth_bits */ - 8, /* stencil_bits */ - 8,8,8,8, /* accum_bits */ - 1 ); - - if ( pD3DDefault->gl_visual == NULL) - { - FREE( pD3DDefault ); - return FALSE; - } - - /* Allocate a new Mesa context */ - pD3DDefault->gl_ctx = _mesa_create_context( pD3DDefault->gl_visual, NULL, pD3DDefault, GL_TRUE ); - if ( pD3DDefault->gl_ctx == NULL ) - { - _mesa_destroy_visual( pD3DDefault->gl_visual ); - FREE( pD3DDefault ); - return FALSE; - } - - /* Allocate a new Mesa frame buffer */ - pD3DDefault->gl_buffer = _mesa_create_framebuffer( pD3DDefault->gl_visual ); - if ( pD3DDefault->gl_buffer == NULL ) - { - _mesa_destroy_visual( pD3DDefault->gl_visual ); - _mesa_destroy_context( pD3DDefault->gl_ctx ); - FREE( pD3DDefault ); - return FALSE; - } - SetupDDPointers( pD3DDefault->gl_ctx ); - _mesa_make_current( pD3DDefault->gl_ctx, pD3DDefault->gl_buffer ); - - return TRUE; -} -/*===========================================================================*/ -/* This function will create a new D3D context but will not create the D3D */ -/* surfaces or even an instance of D3D (see at GetBufferSize). The only stuff*/ -/* done here is the internal Mesa stuff and some Win32 handles. */ -/*===========================================================================*/ -/* RETURN: casted pointer to the context, NULL. */ -/*===========================================================================*/ -HGLRC APIENTRY wglCreateContext( HDC hdc ) -{ - D3DMESACONTEXT *pNewContext; - DWORD dwCoopFlags = DDSCL_NORMAL; - RECT rectClient; - POINT pt; - - /* ALLOC and clear the new context. */ - pNewContext = (PD3DMESACONTEXT)ALLOC( sizeof(D3DMESACONTEXT) ); - if ( pNewContext == NULL ) - { - SetLastError( 0 ); - return (HGLRC)NULL; - } - memset( pNewContext, 0, sizeof(D3DMESACONTEXT) ); - - /*========================================================================*/ - /* Do all core Mesa stuff. */ - /*========================================================================*/ - - /* TODO: support more then one visual. */ - pNewContext->gl_visual = _mesa_create_visual( TRUE, - TRUE, /* db_flag */ - GL_FALSE, /* stereo */ - 8,8,8,8, /* r, g, b, a bits */ - 0, /* index bits */ - 16, /* depth_bits */ - 8, /* stencil_bits */ - 16,16,16,16,/* accum_bits */ - 1 ); - if ( pNewContext->gl_visual == NULL) - { - FREE( pNewContext ); - SetLastError( 0 ); - return (HGLRC)NULL; - } - - /* Allocate a new Mesa context */ - pNewContext->gl_ctx = _mesa_create_context( pNewContext->gl_visual, NULL, pNewContext, GL_TRUE ); - if ( pNewContext->gl_ctx == NULL ) - { - _mesa_destroy_visual( pNewContext->gl_visual ); - FREE( pNewContext ); - SetLastError( 0 ); - return (HGLRC)NULL; - } - - /* Allocate a new Mesa frame buffer */ - pNewContext->gl_buffer = _mesa_create_framebuffer( pNewContext->gl_visual ); - if ( pNewContext->gl_buffer == NULL ) - { - _mesa_destroy_visual( pNewContext->gl_visual ); - _mesa_destroy_context( pNewContext->gl_ctx ); - FREE( pNewContext ); - SetLastError( 0 ); - return (HGLRC)NULL; - } - - /*========================================================================*/ - /* Do all the driver stuff. */ - /*========================================================================*/ - pNewContext->hdc = hdc; - pNewContext->next = pD3DDefault->next; - pD3DDefault->next = pNewContext; /* Add to circular list. */ - - /* Create the HAL for the new context. */ - pNewContext->pShared = InitHAL( WindowFromDC(hdc) ); - - return (HGLRC)pNewContext; -} -/*===========================================================================*/ -/* This is a wrapper function that is supported by MakeCurrent. */ -/*===========================================================================*/ -/* RETURN: TRUE, FALSE. */ -/*===========================================================================*/ -BOOL APIENTRY wglMakeCurrent( HDC hdc, HGLRC hglrc ) -{ - return MakeCurrent((D3DMESACONTEXT *)hglrc); -} -/*===========================================================================*/ -/* MakeCurrent will unbind whatever context is current (if any) & then bind */ -/* the supplied context. A context that is bound has it's window proc hooked*/ -/* with the wglMonitorProc and the context pointer is saved in pD3DCurrent. */ -/* Once the context is bound we update the Mesa-3.0 hooks (SetDDPointers) and*/ -/* the viewport (Mesa-.30 and DX6). */ -/* */ -/* TODO: this function can't fail. */ -/*===========================================================================*/ -/* RETURN: TRUE */ -/*===========================================================================*/ -static BOOL MakeCurrent( D3DMESACONTEXT *pContext ) -{ - D3DMESACONTEXT *pNext; - - /*====================================================================*/ - /* This is a special case that is a request to have no context bound. */ - /*====================================================================*/ - if ( pContext == NULL ) - { - /* Walk the whole list. We start and end at the Default context. */ - for( pNext = pD3DDefault->next; pNext != pD3DDefault; pNext = pNext->next ) - UnBindWindow( pNext ); - - return TRUE; - } - - /*=================================================*/ - /* Make for a fast redundant use of this function. */ - /*=================================================*/ - if ( pD3DCurrent == pContext ) - return TRUE; - - /*=============================*/ - /* Unbind the current context. */ - /*=============================*/ - UnBindWindow( pD3DCurrent ); - - /*=====================================*/ - /* Let Mesa-3.0 we have a new context. */ - /*=====================================*/ - SetupDDPointers( pContext->gl_ctx ); - _mesa_make_current( pContext->gl_ctx, pContext->gl_buffer ); - - /* We are done so set the internal current context. */ - if ( pContext != pD3DDefault ) - { - ResizeContext( pContext->gl_ctx ); - pContext->hOldProc = (WNDPROC)GetWindowLong( pContext->pShared->hwnd, GWL_WNDPROC ); - SetWindowLong( pContext->pShared->hwnd, GWL_WNDPROC, (LONG)wglMonitorProc ); - } - pD3DCurrent = pContext; - - return TRUE; -} -/*===========================================================================*/ -/* This function will only return the current window size. I have re-done */ -/* this function so that it doesn't check the current size and react to it as*/ -/* I should be able to have all the react code in the WM_SIZE message. The */ -/* old version would check the current window size and create/resize the HAL */ -/* surfaces if they have changed. I needed to delay the creation if the */ -/* surfaces because sometimes I wouldn't have a window size so this is where */ -/* I delayed it. If you are reading this then all went ok! */ -/* The default context will return a zero sized window and I'm not sure if */ -/* this is ok at this point (TODO). */ -/*===========================================================================*/ -/* RETURN: */ -/*===========================================================================*/ -static void GetBufferSize( GLcontext *ctx, GLuint *width, GLuint *height ) -{ - D3DMESACONTEXT *pContext = (D3DMESACONTEXT *)ctx->DriverCtx; - - /* Fall through for the default because that is one of the uses for it. */ - if ( pContext == pD3DDefault ) - { - *width = 0; - *height = 0; - } - else - { - *width = pContext->pShared->dwWidth; - *height = pContext->pShared->dwHeight; - } -} -/*===========================================================================*/ -/* */ -/* */ -/*===========================================================================*/ -/* RETURN: */ -/*===========================================================================*/ -static BOOL ResizeContext( GLcontext *ctx ) -{ - D3DMESACONTEXT *pContext = (D3DMESACONTEXT *)ctx->DriverCtx, - *pCurrentTemp; - RECT rectClient; - POINT pt; - DWORD dwWidth, - dwHeight; - static BOOL bDDrawLock = FALSE; - - /* Make sure we have some values. */ - if ( (pContext->hdc == NULL ) || - (pContext->pShared->hwnd != WindowFromDC(pContext->hdc)) || - (pContext == pD3DDefault) ) - return FALSE; - - /* Having problems with DDraw sending resize messages before I was done. */ - if( bDDrawLock == TRUE ) - return FALSE; - - // TODO: don't think I need this anymore. - pCurrentTemp = pD3DCurrent; - pD3DCurrent = pD3DDefault; - bDDrawLock = TRUE; - - /* Get the current window dimentions. */ - UpdateScreenPosHAL( pContext->pShared ); - dwWidth = pContext->pShared->rectW.right - pContext->pShared->rectW.left; - dwHeight = pContext->pShared->rectW.bottom - pContext->pShared->rectW.top; - - /* Is the size of the OffScreen Render different? */ - if ( (dwWidth != pContext->pShared->dwWidth) || (dwHeight != pContext->pShared->dwHeight) ) - { - /* Create all the D3D surfaces and device. */ - CreateHAL( pContext->pShared ); - - /* I did this so that software rendering would still work as */ - /* I don't need to scale the z values twice. */ - g_DepthScale = (pContext->pShared->bHardware) ? 1.0 : ((float)0x00FFFFFF); - g_MaxDepth = (pContext->pShared->bHardware) ? 1.0 : ((float)0x00FFFFFF); - gl_DepthRange( pContext->gl_ctx, ctx->Viewport.Near, ctx->Viewport.Far ); - - /* Make sure we have a viewport. */ - gl_Viewport( pContext->gl_ctx, 0, 0, dwWidth, dwHeight ); - - /* Update Mesa as we might have changed from SW <-> HW. */ - SetupDDPointers( pContext->gl_ctx ); - _mesa_make_current( pContext->gl_ctx, pContext->gl_buffer ); - - /* If we are in HW we need to load the current texture if there is one already. */ - // if ( (ctx->Texture.Set[ctx->Texture.CurrentSet].Current != NULL) && - // (pContext->pShared->bHardware == TRUE) ) - // { - // CreateTMgrHAL( pContext->pShared, - // ctx->Texture.Set[ctx->Texture.CurrentSet].Current->Name, - // 0, - // ctx->Texture.Set[ctx->Texture.CurrentSet].Current->Image[0]->Format, - // (RECT *)NULL, - // ctx->Texture.Set[ctx->Texture.CurrentSet].Current->Image[0]->Width, - // ctx->Texture.Set[ctx->Texture.CurrentSet].Current->Image[0]->Height, - // TM_ACTION_BIND, - // (void *)ctx->Texture.Set[ctx->Texture.CurrentSet].Current->Image[0]->Data ); - // } - } - - // TODO: don't think I need this anymore. - pD3DCurrent = pCurrentTemp; - bDDrawLock = FALSE; - - return TRUE; -} - -/*===========================================================================* -/* This function will Blt the render buffer to the PRIMARY surface. I repeat*/ -/* this code for the other SwapBuffer like functions and the flush (didn't */ -/* want the function calling overhead). Thsi could have been a macro... */ -/* */ -/* TODO: there are some problems with viewport/scissoring. */ -/*===========================================================================*/ -/* RETURN: TRUE, FALSE. */ -/*===========================================================================*/ -BOOL APIENTRY wglSwapBuffers( HDC hdc ) -{ - /* Fall through for the default because that is one of the uses for it. */ - if ( pD3DCurrent == pD3DDefault ) - return FALSE; - - SwapBuffersHAL( pD3DCurrent->pShared ); - - return TRUE; -} -/*===========================================================================*/ -/* Same as wglSwapBuffers. */ -/*===========================================================================*/ -/* RETURN: TRUE, FALSE. */ -/*===========================================================================*/ -BOOL APIENTRY SwapBuffers( HDC hdc ) -{ - /* Fall through for the default because that is one of the uses for it. */ - if ( pD3DCurrent == pD3DDefault ) - return FALSE; - - SwapBuffersHAL( pD3DCurrent->pShared ); - - return TRUE; -} -/*===========================================================================*/ -/* This should be ok as none of the SwapBuffers will cause a redundant Blt */ -/* as none of my Swap functions will call flush. This should also allow */ -/* sinlge buffered applications to work (not really worried though). Some */ -/* applications may flush then swap but then this is there fault IMHO. */ -/*===========================================================================*/ -/* RETURN: */ -/*===========================================================================*/ -static void Flush( GLcontext *ctx ) -{ - /* Fall through for the default because that is one of the uses for it. */ - if ( pD3DCurrent == pD3DDefault ) - return; - - SwapBuffersHAL( pD3DCurrent->pShared ); -} -/*===========================================================================*/ -/* For now this function will ignore the supplied PF. If I'm going to allow */ -/* the user to choice the mode and device at startup I'm going to have to do */ -/* something different. */ -/* */ -/* TODO: use the linked list of modes to build a pixel format to be returned */ -/* to the caller. */ -/*===========================================================================*/ -/* RETURN: 1. */ -/*===========================================================================*/ -int APIENTRY wglChoosePixelFormat( HDC hdc, CONST PIXELFORMATDESCRIPTOR *ppfd ) -{ - return 1; -} -/*===========================================================================*/ -/* See wglChoosePixelFormat. */ -/*===========================================================================*/ -/* RETURN: 1. */ -/*===========================================================================*/ -int APIENTRY ChoosePixelFormat( HDC hdc, CONST PIXELFORMATDESCRIPTOR *ppfd ) -{ - return wglChoosePixelFormat(hdc,ppfd); -} -/*===========================================================================*/ -/* This function (for now) returns a static PF everytime. This is just to */ -/* allow things to continue. */ -/*===========================================================================*/ -/* RETURN: 1. */ -/*===========================================================================*/ -int APIENTRY wglDescribePixelFormat( HDC hdc, int iPixelFormat, UINT nBytes, LPPIXELFORMATDESCRIPTOR ppfd ) -{ - static PIXELFORMATDESCRIPTOR pfd = - { - sizeof(PIXELFORMATDESCRIPTOR), /* size */ - 1, /* version */ - PFD_SUPPORT_OPENGL | - PFD_DRAW_TO_WINDOW | - PFD_DOUBLEBUFFER, /* support double-buffering */ - PFD_TYPE_RGBA, /* color type */ - 16, /* prefered color depth */ - 0, 0, 0, 0, 0, 0, /* color bits (ignored) */ - 0, /* no alpha buffer */ - 0, /* alpha bits (ignored) */ - 0, /* no accumulation buffer */ - 0, 0, 0, 0, /* accum bits (ignored) */ - 16, /* depth buffer */ - 0, /* no stencil buffer */ - 0, /* no auxiliary buffers */ - PFD_MAIN_PLANE, /* main layer */ - 0, /* reserved */ - 0, 0, 0, /* no layer, visible, damage masks */ - }; - - /* Return the address of this static PF if one was requested. */ - if ( ppfd != NULL ) - memcpy( ppfd, &pfd, sizeof(PIXELFORMATDESCRIPTOR) ); - - return 1; -} -/*===========================================================================*/ -/* See wglDescribePixelFormat. */ -/*===========================================================================*/ -/* RETURN: 1. */ -/*===========================================================================*/ -int APIENTRY DescribePixelFormat( HDC hdc, int iPixelFormat, UINT nBytes, LPPIXELFORMATDESCRIPTOR ppfd ) -{ - return wglDescribePixelFormat(hdc,iPixelFormat,nBytes,ppfd); -} -/*===========================================================================*/ -/* This function will always return 1 for now. Just to allow for support. */ -/*===========================================================================*/ -/* RETURN: 1. */ -/*===========================================================================*/ -int APIENTRY wglGetPixelFormat( HDC hdc ) -{ - return 1; -} -/*===========================================================================*/ -/* See wglGetPixelFormat. */ -/*===========================================================================*/ -/* RETURN: 1. */ -/*===========================================================================*/ -int APIENTRY GetPixelFormat( HDC hdc ) -{ - return wglGetPixelFormat(hdc); -} -/*===========================================================================*/ -/* This will aways work for now. */ -/*===========================================================================*/ -/* RETURN: TRUE. */ -/*===========================================================================*/ -BOOL APIENTRY wglSetPixelFormat( HDC hdc, int iPixelFormat, CONST PIXELFORMATDESCRIPTOR *ppfd ) -{ - return TRUE; -} -/*===========================================================================*/ -/* See wglSetPixelFormat. */ -/*===========================================================================*/ -/* RETURN: TRUE, FALSE. */ -/*===========================================================================*/ -BOOL APIENTRY SetPixelFormat( HDC hdc, int iPixelFormat, CONST PIXELFORMATDESCRIPTOR *ppfd ) -{ - return wglSetPixelFormat(hdc,iPixelFormat,ppfd); -} -/*===========================================================================*/ -/* This is a wrapper function that is supported by my own internal function.*/ -/* that takes my own D3D Mesa context structure. This so I can reuse the */ -/* function (no need for speed). */ -/*===========================================================================*/ -/* RETURN: TRUE. */ -/*===========================================================================*/ -BOOL APIENTRY wglDeleteContext( HGLRC hglrc ) -{ - DestroyContext( (D3DMESACONTEXT *)hglrc ); - - return TRUE; -} -/*===========================================================================*/ -/* Simple getter function that uses a cast. */ -/*===========================================================================*/ -/* RETURN: casted pointer to the context, NULL. */ -/*===========================================================================*/ -HGLRC APIENTRY wglGetCurrentContext( VOID ) -{ - return (pD3DCurrent) ? (HGLRC)pD3DCurrent : (HGLRC)NULL; -} -/*===========================================================================*/ -/* No support. */ -/*===========================================================================*/ -/* RETURN: FALSE. */ -/*===========================================================================*/ -BOOL APIENTRY wglCopyContext( HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask ) -{ - SetLastError( 0 ); - return FALSE; -} -/*===========================================================================*/ -/* No support. */ -/*===========================================================================*/ -/* RETURN: NULL. */ -/*===========================================================================*/ -HGLRC APIENTRY wglCreateLayerContext( HDC hdc,int iLayerPlane ) -{ - SetLastError( 0 ); - return (HGLRC)NULL; -} -/*===========================================================================*/ -/* Simple getter function. */ -/*===========================================================================*/ -/* RETURN: FALSE. */ -/*===========================================================================*/ -HDC APIENTRY wglGetCurrentDC( VOID ) -{ - return (pD3DCurrent) ? pD3DCurrent->hdc : (HDC)NULL; -} -/*===========================================================================*/ -/* Simply call that searches the supported extensions for a match & returns */ -/* the pointer to the function that lends support. */ -/*===========================================================================*/ -/* RETURN: pointer to API call, NULL. */ -/*===========================================================================*/ -PROC APIENTRY wglGetProcAddress( LPCSTR lpszProc ) -{ - int index; - - for( index = 0; index < qt_ext; index++ ) - if( !strcmp(lpszProc,ext[index].name) ) - return ext[index].proc; - - SetLastError( 0 ); - return NULL; -} -/*===========================================================================*/ -/* No support. */ -/*===========================================================================*/ -/* RETURN: FALSE. */ -/*===========================================================================*/ -BOOL APIENTRY wglShareLists( HGLRC hglrc1, HGLRC hglrc2 ) -{ - SetLastError( 0 ); - return FALSE; -} -/*===========================================================================*/ -/* No support. */ -/*===========================================================================*/ -/* RETURN: FALSE. */ -/*===========================================================================*/ -BOOL APIENTRY wglUseFontBitmaps( HDC fontDevice, DWORD firstChar, DWORD numChars, DWORD listBase ) -{ - SetLastError( 0 ); - return FALSE; -} -/*===========================================================================*/ -/* No support. */ -/*===========================================================================*/ -/* RETURN: FALSE. */ -/*===========================================================================*/ -BOOL APIENTRY wglUseFontBitmapsW( HDC hdc,DWORD first,DWORD count,DWORD listBase ) -{ - SetLastError( 0 ); - return FALSE; -} -/*===========================================================================*/ -/* No support. */ -/*===========================================================================*/ -/* RETURN: FALSE. */ -/*===========================================================================*/ -BOOL APIENTRY wglUseFontOutlinesA( HDC hdc, DWORD first, DWORD count, DWORD listBase, FLOAT deviation, FLOAT extrusion, int format, LPGLYPHMETRICSFLOAT lpgmf ) -{ - SetLastError( 0 ); - return FALSE; -} -/*===========================================================================*/ -/* No support. */ -/*===========================================================================*/ -/* RETURN: FALSE. */ -/*===========================================================================*/ -BOOL APIENTRY wglUseFontOutlinesW( HDC hdc,DWORD first,DWORD count, DWORD listBase,FLOAT deviation, FLOAT extrusion,int format, LPGLYPHMETRICSFLOAT lpgmf ) -{ - SetLastError( 0 ); - return FALSE ; -} -/*===========================================================================*/ -/* No support. */ -/*===========================================================================*/ -/* RETURN: FALSE. */ -/*===========================================================================*/ -BOOL APIENTRY wglSwapLayerBuffers( HDC hdc, UINT fuPlanes ) -{ - SetLastError( 0 ); - return FALSE; -} -/*===========================================================================*/ -/* This function will be hooked into the window that has been bound. Right */ -/* now it is used to track the window size and position. Also the we clean */ -/* up the currrent context when the window is close/destroyed. */ -/* */ -/* TODO: there might be something wrong here as some games (Heretic II) don't*/ -/* track the window quit right. */ -/*===========================================================================*/ -/* RETURN: */ -/*===========================================================================*/ -LONG APIENTRY wglMonitorProc( HWND hwnd, UINT message, UINT wParam, LONG lParam ) -{ - WNDPROC hOldProc; - GLint width, - height; - - switch( message ) - { -// case WM_PAINT: -// break; -// case WM_ACTIVATE: -// break; -// case WM_SHOWWINDOW: -// break; - - case UM_FATALSHUTDOWN: - /* Support the API until we die... */ - MakeCurrent( pD3DDefault ); - break; - - case WM_MOVE: - case WM_DISPLAYCHANGE: - case WM_SIZE: - ResizeContext( pD3DCurrent->gl_ctx ); - break; - - case WM_CLOSE: - case WM_DESTROY: - /* Support the API until we die... */ - hOldProc = pD3DCurrent->hOldProc; - DestroyContext( pD3DCurrent ); - return (hOldProc)(hwnd,message,wParam,lParam); - } - - return (pD3DCurrent->hOldProc)(hwnd,message,wParam,lParam); -} - -/**********************************************************************/ -/***** Miscellaneous device driver funcs *****/ -/**********************************************************************/ - -/*===========================================================================*/ -/* Not reacting to this as I'm only supporting drawing to the back buffer */ -/* right now. */ -/*===========================================================================*/ -/* RETURN: TRUE. */ -/*===========================================================================*/ -static GLboolean SetBuffer( GLcontext *ctx, GLenum buffer ) -{ - if (buffer == GL_BACK_LEFT) - return GL_TRUE; - else - return GL_FALSE; -} -/*===========================================================================*/ -/* This proc will be called by Mesa when the viewport has been set. So if */ -/* we have a context and it isn't the default then we should let D3D know of */ -/* the change. */ -/*===========================================================================*/ -/* RETURN: */ -/*===========================================================================*/ -static void SetViewport( GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h ) -{ - D3DMESACONTEXT *pContext = (D3DMESACONTEXT *)ctx->DriverCtx; - RECT rect; - - /* Make sure we can set a viewport. */ - if ( pContext->pShared && (pContext != pD3DDefault) ) - { - // TODO: might be needed. - UpdateScreenPosHAL( pContext->pShared ); - rect.left = x; - rect.right = x + w; - rect.top = y; - rect.bottom = y + h; - - // TODO: shared struct should make this call smaller - SetViewportHAL( pContext->pShared, &rect, 0.0F, 1.0F ); - } -} -/*===========================================================================*/ -/* This function could be better I guess but I decided just to grab the four*/ -/* components and store then seperately. Makes it easier to use IMHO. */ -/*===========================================================================*/ -/* RETURN: */ -/*===========================================================================*/ -static void ClearColor( GLcontext *ctx, GLubyte r, GLubyte g, GLubyte b, GLubyte a ) -{ - D3DMESACONTEXT *pContext = (D3DMESACONTEXT *)ctx->DriverCtx; - - pContext->aClear = a; - pContext->bClear = b; - pContext->gClear = g; - pContext->rClear = r; -} -/*===========================================================================*/ -/* This function could be better I guess but I decided just to grab the four*/ -/* components and store then seperately. Makes it easier to use IMHO. */ -/* (is there an echo in here?) */ -/*===========================================================================*/ -/* RETURN: */ -/*===========================================================================*/ -static void SetColor( GLcontext *ctx, GLubyte r, GLubyte g, GLubyte b, GLubyte a ) -{ - D3DMESACONTEXT *pContext = (D3DMESACONTEXT *)ctx->DriverCtx; - - pContext->aCurrent = a; - pContext->bCurrent = b; - pContext->gCurrent = g; - pContext->rCurrent = r; -} -/*===========================================================================*/ -/* */ -/* */ -/*===========================================================================*/ -/* RETURN: */ -/*===========================================================================*/ -static const char *RendererString( void ) -{ - static char pszRender[64]; - - strcpy( pszRender, "altD3D " ); - - if ( pD3DCurrent->pShared->bHardware ) - strcat( pszRender, "(HW)"); - else - strcat( pszRender, "(SW)"); - - return (const char *)pszRender; -} -/*===========================================================================*/ -/* This function will choose which set of pointers Mesa will use based on */ -/* whether we hard using hardware or software. I have added another set of */ -/* pointers that will do nothing but stop the API from crashing. */ -/*===========================================================================*/ -/* RETURN: */ -/*===========================================================================*/ -static void SetupDDPointers( GLcontext *ctx ) -{ - D3DMESACONTEXT *pContext = (D3DMESACONTEXT *)ctx->DriverCtx; - - // TODO: write a generic NULL support for the span render. - if ( pContext->pShared && pContext->pShared->bHardware ) - { - ctx->Driver.UpdateState = SetupHWDDPointers; - } - else if ( pContext == pD3DDefault ) - { - ctx->Driver.UpdateState = SetupNULLDDPointers; - } - else - { - ctx->Driver.UpdateState = SetupSWDDPointers; - } -} -/*===========================================================================*/ -/* This function will populate all the Mesa driver hooks. This version of */ -/* hooks will do nothing but support the API when we don't have a valid */ -/* context bound. This is mostly for applications that don't behave right */ -/* and also to help exit as clean as possable when we have a FatalError. */ -/*===========================================================================*/ -/* RETURN: pointer to the specific function. */ -/*===========================================================================*/ -static void SetupNULLDDPointers( GLcontext *ctx ) -{ - D3DMESACONTEXT *pContext = (D3DMESACONTEXT *)ctx->DriverCtx; - - /* Initialize all the pointers in the DD struct. Do this whenever */ - /* a new context is made current or we change buffers via set_buffer! */ - ctx->Driver.UpdateState = SetupNULLDDPointers; - - /* State management hooks. */ - ctx->Driver.Color = NULLSetColor; - ctx->Driver.ClearColor = NULLClearColor; - ctx->Driver.Clear = NULLClearBuffers; - ctx->Driver.SetBuffer = NULLSetBuffer; - - /* Window management hooks. */ - ctx->Driver.GetBufferSize = NULLGetBufferSize; - - /* Primitive rendering hooks. */ - ctx->Driver.TriangleFunc = NULL; - ctx->Driver.RenderVB = NULL; - - /* Pixel/span writing functions: */ - ctx->Driver.WriteRGBASpan = NULLWrSpRGBA; - ctx->Driver.WriteRGBSpan = NULLWrSpRGB; - ctx->Driver.WriteMonoRGBASpan = NULLWrSpRGBAMono; - ctx->Driver.WriteRGBAPixels = NULLWrPiRGBA; - ctx->Driver.WriteMonoRGBAPixels = NULLWrPiRGBAMono; - - /* Pixel/span reading functions: */ - ctx->Driver.ReadRGBASpan = NULLReSpRGBA; - ctx->Driver.ReadRGBAPixels = NULLRePiRGBA; - - /* Misc. hooks. */ - ctx->Driver.RendererString = RendererString; -} -/*===========================================================================*/ -/* This function will populate all the Mesa driver hooks. There are two of */ -/* these functions. One if we have hardware support and one is there is only*/ -/* software. These functions will be called by Mesa and by the wgl.c when we*/ -/* have resized (or created) the buffers. The thing is that if a window gets*/ -/* resized we may loose hardware support or gain it... */ -/*===========================================================================*/ -/* RETURN: pointer to the specific function. */ -/*===========================================================================*/ -static void SetupSWDDPointers( GLcontext *ctx ) -{ - D3DMESACONTEXT *pContext = (D3DMESACONTEXT *)ctx->DriverCtx; - - /* Initialize all the pointers in the DD struct. Do this whenever */ - /* a new context is made current or we change buffers via set_buffer! */ - ctx->Driver.UpdateState = SetupSWDDPointers; - - /* State management hooks. */ - ctx->Driver.Color = SetColor; - ctx->Driver.ClearColor = ClearColor; - ctx->Driver.Clear = ClearBuffers; - ctx->Driver.SetBuffer = SetBuffer; - - /* Window management hooks. */ - ctx->Driver.GetBufferSize = GetBufferSize; - ctx->Driver.Viewport = SetViewport; - - /* Primitive rendering hooks. */ - ctx->Driver.TriangleFunc = NULL; - ctx->Driver.RenderVB = NULL; - - /* Texture management hooks. */ - - /* Pixel/span writing functions: */ - ctx->Driver.WriteRGBASpan = WSpanRGBA; - ctx->Driver.WriteRGBSpan = WSpanRGB; - ctx->Driver.WriteMonoRGBASpan = WSpanRGBAMono; - ctx->Driver.WriteRGBAPixels = WPixelsRGBA; - ctx->Driver.WriteMonoRGBAPixels = WPixelsRGBAMono; - - /* Pixel/span reading functions: */ - ctx->Driver.ReadRGBASpan = RSpanRGBA; - ctx->Driver.ReadRGBAPixels = RPixelsRGBA; - - /* Misc. hooks. */ - ctx->Driver.Flush = Flush; - ctx->Driver.RendererString = RendererString; -} -/*===========================================================================*/ -/* This function will populate all the Mesa driver hooks. There are two of */ -/* these functions. One if we have hardware support and one is there is only*/ -/* software. These functions will be called by Mesa and by the wgl.c when we*/ -/* have resized (or created) the buffers. The thing is that if a window gets*/ -/* resized we may loose hardware support or gain it... */ -/*===========================================================================*/ -/* RETURN: pointer to the specific function. */ -/*===========================================================================*/ -static void SetupHWDDPointers( GLcontext *ctx ) -{ - D3DMESACONTEXT *pContext = (D3DMESACONTEXT *)ctx->DriverCtx; - - /* Initialize all the pointers in the DD struct. Do this whenever */ - /* a new context is made current or we change buffers via set_buffer! */ - ctx->Driver.UpdateState = SetupHWDDPointers; - - /* State management hooks. */ - ctx->Driver.Color = SetColor; - ctx->Driver.ClearColor = ClearColor; - ctx->Driver.Clear = ClearBuffersD3D; - ctx->Driver.SetBuffer = SetBuffer; - - /* Window management hooks. */ - ctx->Driver.GetBufferSize = GetBufferSize; - ctx->Driver.Viewport = SetViewport; - - /* Primitive rendering hooks. */ - ctx->Driver.TriangleFunc = RenderOneTriangle; - ctx->Driver.LineFunc = RenderOneLine; - ctx->Driver.RenderVB = RenderVertexBuffer; - - /* Pixel/span writing functions: */ - ctx->Driver.WriteRGBASpan = WSpanRGBA; - ctx->Driver.WriteRGBSpan = WSpanRGB; - ctx->Driver.WriteMonoRGBASpan = WSpanRGBAMono; - ctx->Driver.WriteRGBAPixels = WPixelsRGBA; - ctx->Driver.WriteMonoRGBAPixels = WPixelsRGBAMono; - - /* Pixel/span reading functions: */ - ctx->Driver.ReadRGBASpan = RSpanRGBA; - ctx->Driver.ReadRGBAPixels = RPixelsRGBA; - - /* Texture management hooks. */ - // ctx->Driver.BindTexture = TextureBind; - ctx->Driver.TexImage = TextureLoad; - ctx->Driver.TexSubImage = TextureSubImage; - - /* Misc. hooks. */ - ctx->Driver.Flush = Flush; - ctx->Driver.RendererString = RendererString; -} -/*===========================================================================*/ -/* This function will release all resources used by the DLL. Every context */ -/* will be clobbered by releaseing all driver desources and then freeing the */ -/* context memory. Most all the work is done in DestroyContext. */ -/*===========================================================================*/ -/* RETURN: TRUE. */ -/*===========================================================================*/ -static BOOL TermOpenGL( HINSTANCE hInst ) -{ - D3DMESACONTEXT *pTmp, - *pNext; - - /* Just incase we are still getting paint msg. */ - MakeCurrent( pD3DDefault ); - - /* Walk the list until we get back to the default context. */ - for( pTmp = pD3DDefault->next; pTmp != pD3DDefault; pTmp = pNext ) - { - pNext = pTmp->next; - DestroyContext( pTmp ); - } - DestroyContext( pD3DDefault ); - - return TRUE; -} -/*===========================================================================*/ -/* This function is an internal function that will clean up all the Mesa */ -/* context bound to this D3D context. Also any D3D stuff that this context */ -/* uses will be unloaded. */ -/*===========================================================================*/ -/* RETURN: TRUE, FALSE. */ -/*===========================================================================*/ -static void DestroyContext( D3DMESACONTEXT *pContext ) -{ - D3DMESACONTEXT *pTmp; - - /* Walk the list until we find the context before this one. */ - for( pTmp = pD3DDefault; pTmp && (pTmp->next != pContext); pTmp = pTmp->next ) - if ( pTmp == pTmp->next ) - break; - - /* If we never found it it must already be deleted. */ - if ( pTmp->next != pContext ) - return; - - /* Make sure we are not using this context. */ - if ( pContext == pD3DCurrent ) - MakeCurrent( pD3DDefault ); - - /* Free the Mesa stuff. */ - if ( pContext->gl_visual ) - { - _mesa_destroy_visual( pContext->gl_visual ); - pContext->gl_visual = NULL; - } - if ( pContext->gl_buffer ) - { - _mesa_destroy_framebuffer( pContext->gl_buffer ); - pContext->gl_buffer = NULL; - } - if ( pContext->gl_ctx ) - { - _mesa_destroy_context( pContext->gl_ctx ); - pContext->gl_ctx = NULL; - } - - /* Now dump the D3D. */ - if ( pContext->pShared ) - TermHAL( pContext->pShared ); - - /* Update the previous context's link. */ - pTmp->next = pContext->next; - - /* Gonzo. */ - FREE( pContext ); -} -/*===========================================================================*/ -/* This function will pull the supplied context away from Win32. Basicly it*/ -/* will remove the hook from the window Proc. */ -/* */ -/* TODO: might want to serialize this stuff... */ -/*===========================================================================*/ -/* RETURN: TRUE, FALSE. */ -/*===========================================================================*/ -static BOOL UnBindWindow( D3DMESACONTEXT *pContext ) -{ - if ( pContext == NULL ) - return FALSE; - - if ( pContext == pD3DDefault ) - return TRUE; - - /* Make sure we always have a context bound. */ - if ( pContext == pD3DCurrent ) - pD3DCurrent = pD3DDefault; - - SetWindowLong( pContext->pShared->hwnd, GWL_WNDPROC, (LONG)pContext->hOldProc ); - pContext->hOldProc = NULL; - - return TRUE; -} -/*===========================================================================*/ -/* There are two cases that allow for a faster clear when we know that the */ -/* whole buffer is cleared and that there is no clipping. */ -/*===========================================================================*/ -/* RETURN: the original mask with the bits cleared that represents the buffer* -/* or buffers we just cleared. */ -/*===========================================================================*/ -GLbitfield ClearBuffersD3D( GLcontext *ctx, GLbitfield mask, GLboolean all, GLint x, GLint y, GLint width, GLint height ) -{ - D3DMESACONTEXT *pContext = (D3DMESACONTEXT *)ctx->DriverCtx; - DWORD dwFlags = 0; - - if ( mask & GL_COLOR_BUFFER_BIT ) - { - dwFlags |= D3DCLEAR_TARGET; - mask &= ~GL_COLOR_BUFFER_BIT; - } - if ( mask & GL_DEPTH_BUFFER_BIT ) - { - dwFlags |= D3DCLEAR_ZBUFFER; - mask &= ~GL_DEPTH_BUFFER_BIT; - } - if ( dwFlags == 0 ) - return mask; - - ClearHAL( pContext->pShared, - dwFlags, - all, - x, y, - width, height, - ((pContext->aClear<<24) | (pContext->rClear<<16) | (pContext->gClear<<8) | (pContext->bClear)), - ctx->Depth.Clear, - 0 ); - - return mask; -} - - - -/*===========================================================================*/ -/* TEXTURE MANAGER: ok here is how I did textures. Mesa-3.0 will keep track*/ -/* of all the textures for us. So this means that at anytime we can go to */ -/* the Mesa context and get the current texture. With this in mind this is */ -/* what I did. I really don't care about what textures get or are loaded */ -/* until I actually have to draw a tri that is textured. At this point I */ -/* must have the texture so I demand the texture by destorying all other */ -/* texture surfaces if need be and load the current one. This allows for the*/ -/* best preformance on low memory cards as time is not wasted loading and */ -/* unload textures. */ -/*===========================================================================*/ - - - - - -/*===========================================================================*/ -/* TextureLoad will try and create a D3D surface from the supplied texture */ -/* object if its level 0 (first). The surface will be fully filled with the */ -/* texture. */ -/*===========================================================================*/ -/* RETURN: */ -/*===========================================================================*/ -static void TextureLoad( GLcontext *ctx, GLenum target, struct gl_texture_object *tObj, GLint level, GLint internalFormat, const struct gl_texture_image *image ) -{ - D3DMESACONTEXT *pContext = (D3DMESACONTEXT *)ctx->DriverCtx; - - /* TODO: only doing first LOD. */ - if ( (ctx->DriverCtx == NULL) || (level != 0) ) - return; - - CreateTMgrHAL( pContext->pShared, - tObj->Name, - level, - tObj->Image[level]->Format, - (RECT *)NULL, - tObj->Image[level]->Width, - tObj->Image[level]->Height, - TM_ACTION_LOAD, - (void *)tObj->Image[level]->Data ); -} -/*===========================================================================*/ -/* TextureBind make sure that the texture is on the card. Thats it. */ -/*===========================================================================*/ -/* RETURN: */ -/*===========================================================================*/ -static void TextureBind( GLcontext *ctx, GLenum target, struct gl_texture_object *tObj ) -{ - D3DMESACONTEXT *pContext = (D3DMESACONTEXT *)ctx->DriverCtx; - - /* TODO: only doing first LOD. */ - if ( (tObj->Image[0] == NULL) || (ctx->DriverCtx == NULL) ) - return; - - CreateTMgrHAL( pContext->pShared, - tObj->Name, - 0, - tObj->Image[0]->Format, - (RECT *)NULL, - tObj->Image[0]->Width, - tObj->Image[0]->Height, - TM_ACTION_BIND, - (void *)tObj->Image[0]->Data ); -} -/*===========================================================================*/ -/* TextureSubImage will make sure that the texture being updated is updated */ -/* if its on the card. */ -/*===========================================================================*/ -/* RETURN: */ -/*===========================================================================*/ -static void TextureSubImage( GLcontext *ctx, GLenum target, struct gl_texture_object *tObj, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLint internalFormat, const struct gl_texture_image *image ) -{ - D3DMESACONTEXT *pContext = (D3DMESACONTEXT *)ctx->DriverCtx; - RECT rect; - - /* TODO: only doing first LOD. */ - if ( (ctx->DriverCtx == NULL) || (level > 0) ) - return; - - /* Create a dirty rectangle structure. */ - rect.left = xoffset; - rect.right = xoffset + width; - rect.top = yoffset; - rect.bottom = yoffset + height; - - CreateTMgrHAL( pContext->pShared, - tObj->Name, - 0, - tObj->Image[0]->Format, - &rect, - tObj->Image[0]->Width, - tObj->Image[0]->Height, - TM_ACTION_UPDATE, - (void *)tObj->Image[0]->Data ); -} - diff --git a/src/mesa/drivers/d3d/d3dText.h b/src/mesa/drivers/d3d/d3dText.h deleted file mode 100644 index 9ff0650518b..00000000000 --- a/src/mesa/drivers/d3d/d3dText.h +++ /dev/null @@ -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 |