Add rayman2 source files

This commit is contained in:
2024-09-18 02:33:44 +08:00
parent bcc093f8ed
commit fb036c54fd
14339 changed files with 2596224 additions and 0 deletions

View File

@@ -0,0 +1,567 @@
# Microsoft Developer Studio Project File - Name="GLIGLOU" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Static Library" 0x0104
CFG=GLIGLOU - Win32 Exgeom debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "GliGlou.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "GliGlou.mak" CFG="GLIGLOU - Win32 Exgeom debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "GLIGLOU - Win32 Release" (based on "Win32 (x86) Static Library")
!MESSAGE "GLIGLOU - Win32 Debug" (based on "Win32 (x86) Static Library")
!MESSAGE "GLIGLOU - Win32 Retail" (based on "Win32 (x86) Static Library")
!MESSAGE "GLIGLOU - Win32 Exgeom debug" (based on "Win32 (x86) Static Library")
!MESSAGE
# Begin Project
# PROP Scc_ProjName ""$/cpa/tempgrp/GliGlou/MultiDRV", KWPAAAAA"
# PROP Scc_LocalPath "."
CPP=cl.exe
!IF "$(CFG)" == "GLIGLOU - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Tmp\Release"
# PROP Intermediate_Dir "Tmp\Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /G6 /W3 /GX /Z7 /O2 /I "x:\cpa\public" /I "x:\cpa\public\gli" /I "x:\cpa\public\geo" /I "inc" /D "NDEBUG" /D "USE_PROFILER" /D "VISUAL" /D "WIN32" /YX /FD /c
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo /out:"x:\cpa\lib\GLIGLOUR.lib"
!ELSEIF "$(CFG)" == "GLIGLOU - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "GLIGLOU_"
# PROP BASE Intermediate_Dir "GLIGLOU_"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Temp\Debug"
# PROP Intermediate_Dir "Temp\Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /G5 /MDd /W3 /GX /Z7 /Od /I "t:\3dFX\GLIDE\SRC\SST1\INCLUDE" /I "..\PC" /I "x:\cpa\public" /I ".\\" /I "x:\cpa\public\gli" /I "x:\cpa\public\geo" /I "x:\cpa\tempgrp\gli\PC" /D "_DEBUG" /D "VISUAL" /D "WIN32" /D "USE_PROFILER" /D "MTH_CHECK" /D "GLIDE2" /D "GLI_RAYMAN2" /D "CPA_WANTS_EXPORT" /FR /YX /FD /c
# ADD CPP /nologo /G5 /MDd /W3 /GX /Z7 /Od /I "x:\cpa\public" /I "x:\cpa\public\gli" /I "x:\cpa\public\geo" /I "inc" /D "_DEBUG" /D "USE_PROFILER" /D "MTH_CHECK" /D "CPA_WANTS_EXPORT" /D "VISUAL" /D "WIN32" /FR /YX /FD /c
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo /out:"x:\cpa\lib\GLIVD1vD.lib"
# ADD LIB32 /nologo /out:"x:\cpa\lib\GLIGLOUD.lib"
!ELSEIF "$(CFG)" == "GLIGLOU - Win32 Retail"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "GLIGLOU0"
# PROP BASE Intermediate_Dir "GLIGLOU0"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Temp\Retail"
# PROP Intermediate_Dir "Temp\Retail"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /G6 /W3 /GX /O2 /I "t:\3dFX\GLIDE\SRC\SST1\INCLUDE" /I "..\PC" /I "x:\cpa\public" /I ".\\" /I "x:\cpa\public\gli" /I "x:\cpa\public\geo" /I "x:\cpa\tempgrp\gli\PC" /D "NDEBUG" /D "VISUAL" /D "WIN32" /D "RETAIL" /D "GLIDE2" /D "GLI_RAYMAN2" /YX /FD /c
# ADD CPP /nologo /G6 /W3 /GX /O2 /I "t:\3dFX\GLIDE\SRC\SST1\INCLUDE" /I "x:\cpa\public" /I "x:\cpa\public\gli" /I "x:\cpa\public\geo" /I "inc" /D "NDEBUG" /D "RETAIL" /D "VISUAL" /D "WIN32" /YX /FD /c
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo /out:"x:\cpa\lib\GLIVD1vf.lib"
# ADD LIB32 /nologo /out:"x:\cpa\lib\GLIGLOUF.lib"
!ELSEIF "$(CFG)" == "GLIGLOU - Win32 Exgeom debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "GLIGLOU_"
# PROP BASE Intermediate_Dir "GLIGLOU_"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "GLIGLOU_"
# PROP Intermediate_Dir "GLIGLOU_"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /G5 /MDd /W3 /GX /Z7 /Od /I "x:\cpa\public" /I "x:\cpa\public\gli" /I "x:\cpa\public\geo" /I "inc" /D "_DEBUG" /D "VISUAL" /D "WIN32" /D "USE_PROFILER" /D "MTH_CHECK" /D "CPA_WANTS_EXPORT" /FR /YX /FD /c
# ADD CPP /nologo /G5 /MDd /W3 /GX /Z7 /Od /I "x:\cpa\public" /I "x:\cpa\public\gli" /I "x:\cpa\public\geo" /I "inc" /I "x:\cpa\appli\exgeom" /D "_DEBUG" /D "MTH_CHECK" /D "CPA_WANTS_EXPORT" /D "EXGEOM_APPLI" /D "USE_PROFILER" /D "MULTI_TEXTURE" /D "PROCEDURAL_TEXTURE" /D "VISUAL" /D "WIN32" /FR /YX /FD /c
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo /out:"x:\cpa\lib\GLIGLOUD.lib"
# ADD LIB32 /nologo /out:"x:\cpa\lib\Exgeom_GLIGLOUD.lib"
!ENDIF
# Begin Target
# Name "GLIGLOU - Win32 Release"
# Name "GLIGLOU - Win32 Debug"
# Name "GLIGLOU - Win32 Retail"
# Name "GLIGLOU - Win32 Exgeom debug"
# Begin Group "GLI Source"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\Src\Camera.c
# End Source File
# Begin Source File
SOURCE=.\Src\camera.cxx
!IF "$(CFG)" == "GLIGLOU - Win32 Release"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "GLIGLOU - Win32 Debug"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "GLIGLOU - Win32 Retail"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "GLIGLOU - Win32 Exgeom debug"
# PROP BASE Exclude_From_Build 1
# PROP Exclude_From_Build 1
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\Src\DispMode.c
# End Source File
# Begin Source File
SOURCE=.\Src\DLLCaps.c
# End Source File
# Begin Source File
SOURCE=.\Src\DLLInter.c
# End Source File
# Begin Source File
SOURCE=.\Src\Fog.c
# End Source File
# Begin Source File
SOURCE=.\Src\GLI_Menu.c
# End Source File
# Begin Source File
SOURCE=.\Src\GLI_Util.c
# PROP Exclude_From_Build 1
# End Source File
# Begin Source File
SOURCE=.\Src\GLIText.c
# End Source File
# Begin Source File
SOURCE=.\Src\Init_Gli.c
# End Source File
# Begin Source File
SOURCE=.\Src\LgtLoad.c
# End Source File
# Begin Source File
SOURCE=.\Src\Light.c
# End Source File
# Begin Source File
SOURCE=.\Src\Linear.c
# End Source File
# Begin Source File
SOURCE=.\Src\Lines.c
# End Source File
# Begin Source File
SOURCE=.\Src\LinkTab.c
# End Source File
# Begin Source File
SOURCE=.\Src\load.c
# End Source File
# Begin Source File
SOURCE=.\Src\MATBench.c
# End Source File
# Begin Source File
SOURCE=.\Src\Material.c
# End Source File
# Begin Source File
SOURCE=.\Src\Matstack.c
# End Source File
# Begin Source File
SOURCE=.\Src\Object.c
# End Source File
# Begin Source File
SOURCE=.\Src\PrCoVert.c
# End Source File
# Begin Source File
SOURCE=.\Src\Proj.c
# End Source File
# Begin Source File
SOURCE=.\Src\sprite.c
# End Source File
# Begin Source File
SOURCE=.\Src\VisuaSet.c
# End Source File
# Begin Source File
SOURCE=.\Src\WatrPlan.c
# End Source File
# End Group
# Begin Group "GLD Source"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\Gld\DevVp1.c
!IF "$(CFG)" == "GLIGLOU - Win32 Release"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "GLIGLOU - Win32 Debug"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "GLIGLOU - Win32 Retail"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "GLIGLOU - Win32 Exgeom debug"
# PROP BASE Exclude_From_Build 1
# PROP Exclude_From_Build 1
!ENDIF
# End Source File
# Begin Source File
SOURCE=..\Gld\DevVpt.c
# End Source File
# Begin Source File
SOURCE=..\Gld\PixFmt.c
# End Source File
# End Group
# Begin Group "GLI header"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\..\public\GLI\camera.h
# End Source File
# Begin Source File
SOURCE=.\Inc\DispMode.h
# End Source File
# Begin Source File
SOURCE=.\Inc\DLLCaps.h
# End Source File
# Begin Source File
SOURCE=.\Inc\DLLInter.h
# End Source File
# Begin Source File
SOURCE=.\Inc\DrawFlags.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\ErrGLI.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\GLI_Defn.h
# End Source File
# Begin Source File
SOURCE=.\Inc\GLI_Menu.h
# End Source File
# Begin Source File
SOURCE=.\Inc\Gli_st.h
# End Source File
# Begin Source File
SOURCE=.\Inc\GLI_Util.h
# PROP Exclude_From_Build 1
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\Gli_Vig.h
# End Source File
# Begin Source File
SOURCE=.\Inc\GliBench.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\glierr.h
# End Source File
# Begin Source File
SOURCE=.\Inc\GliText.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\Init_Gli.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\LgtLoad.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\light.h
# End Source File
# Begin Source File
SOURCE=.\Inc\Light_st.h
# End Source File
# Begin Source File
SOURCE=.\Inc\linear.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\lines.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\LinkTab.h
# End Source File
# Begin Source File
SOURCE=.\Inc\liste.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\load.h
# End Source File
# Begin Source File
SOURCE=.\Inc\MATBench.h
# End Source File
# Begin Source File
SOURCE=.\Inc\Mater_st.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\material.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\matstack.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\object.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\polygon.h
# End Source File
# Begin Source File
SOURCE=.\Inc\PrCoVert.h
# End Source File
# Begin Source File
SOURCE=.\Inc\Priv_Obj.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\proj.h
# End Source File
# Begin Source File
SOURCE=.\Inc\PvObj_st.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\send.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\sprite.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\util.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\vertex.h
# End Source File
# Begin Source File
SOURCE=.\Inc\VisuS_st.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\VisuSet.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\Vpt3D.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\watrplan.h
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\ZBuffer.h
# End Source File
# End Group
# Begin Group "GLD Header"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\Gld\DevVpt.h
# End Source File
# Begin Source File
SOURCE=..\Gld\GldInc.h
# End Source File
# Begin Source File
SOURCE=..\Gld\GLDUtil.h
# End Source File
# Begin Source File
SOURCE=..\Gld\MacroGLD.h
# End Source File
# End Group
# Begin Group "Textures files"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\Src\Tex.c
# End Source File
# Begin Source File
SOURCE=.\Src\TexArray.c
# End Source File
# Begin Source File
SOURCE=.\Inc\TexArray.h
# End Source File
# Begin Source File
SOURCE=.\Src\TexBench.c
# End Source File
# Begin Source File
SOURCE=.\Inc\TexBench.h
# End Source File
# Begin Source File
SOURCE=.\Src\TexCompress.c
# End Source File
# Begin Source File
SOURCE=.\Inc\TexCompress.h
# End Source File
# Begin Source File
SOURCE=.\Src\TexConvert.c
# End Source File
# Begin Source File
SOURCE=.\Src\TexName.c
# End Source File
# Begin Source File
SOURCE=.\Inc\TexName.h
# End Source File
# Begin Source File
SOURCE=.\Src\TexProcedural.c
# End Source File
# Begin Source File
SOURCE=.\Inc\TexProcedural.h
# End Source File
# Begin Source File
SOURCE=.\Src\TexSna.c
!IF "$(CFG)" == "GLIGLOU - Win32 Release"
!ELSEIF "$(CFG)" == "GLIGLOU - Win32 Debug"
!ELSEIF "$(CFG)" == "GLIGLOU - Win32 Retail"
!ELSEIF "$(CFG)" == "GLIGLOU - Win32 Exgeom debug"
# PROP Exclude_From_Build 1
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\Inc\Textu_st.h
# End Source File
# Begin Source File
SOURCE=.\Src\Texture.c
# End Source File
# Begin Source File
SOURCE=..\..\..\public\GLI\texture.h
# End Source File
# End Group
# Begin Source File
SOURCE=.\GliGlou.mak
# End Source File
# Begin Source File
SOURCE=.\help.txt
# End Source File
# End Target
# End Project

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,80 @@
/*
=======================================================================================
Name : DLLCaps.h
Author : vincent lhullier Date :23/09/98
Description : Constant for DLL capabilities
=======================================================================================
*/
#ifndef __DLLCAPS_H__
#define __DLLCAPS_H__
/*
=======================================================================================
Constant for Caps1
=======================================================================================
*/
#ifdef __cplusplus
extern "C"
{
#endif
/*
=======================================================================================
Constants
=======================================================================================
*/
#define GLICAPS_DRV_C_ulIsHardware 0x00000001
#define GLICAPS_DRV_C_ulCanUseAGP 0x00000002
#define GLICAPS_DRV_C_ulCanUseSystemMemory 0x00000004
#define GLICAPS_DRV_C_ulCanBeWindowed 0x00000008
#define GLICAPS_DRV_C_ulSupportAlphaTest 0x00000010
#define GLICAPS_DRV_C_ulReadjustViewport 0x00000020
#define GLICAPS_TEX_C_ulSupport8P 0x00000001
#define GLICAPS_TEX_C_ulSupportNonSquare 0x00000002
#define GLICAPS_TEX_C_ulSupportMipmap 0x00000004
#define GLICAPS_TEX_C_ulSupportMirror 0x00000008
/*
* constant for request to DLL
*/
#define GLIDLL_Request_ReloadTexture 1
/*
=======================================================================================
Structures
=======================================================================================
*/
typedef struct tdstGliCaps_
{
unsigned long ulSize;
unsigned long ulDriverCaps;
unsigned long ulTextureCaps;
unsigned long ulSurfaceCaps;
unsigned long ulMemoryCaps;
unsigned long ulTextureMaxSize;
unsigned long ulTotalTextureMemory;
unsigned long ulTotalVideoMemory;
unsigned long ulTotalAGPMemory;
unsigned char ucPrimarySurfacePixelFormat;
float fRefreshRate;
} tdstGliCaps;
/*
=======================================================================================
Globals
=======================================================================================
*/
extern tdstGliCaps GLI_g_stCaps;
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*__DLLCAPS_H__*/

View File

@@ -0,0 +1,148 @@
/*
=======================================================================================
Name : DLLInter.h
Author : vincent lhullier Date :14/09/98
Description : initialize Specific driver DLL
=======================================================================================
*/
#ifndef __DLLINTER_H__
#define __DLLINTER_H__
#include "GLD.h"
#include "PvObj_st.h"
/*
=======================================================================================
DLL Function prototypes
=======================================================================================
*/
/* General */
extern long (*GLI_DRV_lSendDataToDll)(char *, void *);
/* DOMATxxx.C */
extern void (* GLI_DRV_vDoOpaqueTextureSelection)( GLI_tdstInternalGlobalValuesFor3dEngine * );
extern void (* GLI_DRV_vWrite16bBitmapToBackBuffer) ( void *,long ,long ,long ,long, long, long );
extern void (* GLI_DRV_vAddBlackPolygon)( long , long , long , long );
extern void (* GLI_DRV_vNoBlackPolygon)( void );
extern void (* GLI_DRV_vComputeFogEffect)(GLI_tdstInternalGlobalValuesFor3dEngine *);
extern BOOL (* GLI_DRV_bBeginScene)(void);
extern BOOL (* GLI_DRV_bEndScene)(void);
/* ACCES_XXXX.C */
extern void (* GLI_DRV_vSendSpriteToClip)(GLI_tdstAligned2DVector *,MTH_tdxReal ,GLI_tdstInternalGlobalValuesFor3dEngine *);
extern void (* GLI_DRV_vSendSpriteToClipWithUV)( GLI_tdstAligned2DVector *, MTH_tdxReal *, MTH_tdxReal , GLI_tdstInternalGlobalValuesFor3dEngine *);
/* ACCES_ALL.C */
extern void (* GLI_DRV_vSendSingleLineToClip)( GLD_tdstViewportAttributes *, GLI_tdstAligned3DVector *, GLI_tdstAligned2DVector *, GLI_tdstAligned3DVector *, GLI_tdstAligned2DVector *, GLI_tdstInternalGlobalValuesFor3dEngine *, long , GEO_tdstColor *);
/* HDWTex_xxx.C */
extern void (* GLI_DRV_vDownLoadTextures)(long, long, BOOL);
extern void (* GLI_DRV_vUnLoadTextures)(void);
extern long (* GLI_DRV_lGetTextureSize)( GLI_tdstTexture *);
/* init_XXX.c */
extern void (* GLI_DRV_vFlipDevice)(long );
extern void (* GLI_DRV_vFlipDeviceWithSyncro)(void);
extern void (* GLI_DRV_vClearDevice)(BOOL, BOOL , unsigned long );
extern void (* GLI_DRV_xInitDriver) ( HWND, BOOL, long, long, long );
extern void (* GLI_DRV_vCloseDriver) (void);
extern void (* GLI_DRV_vClearZBufferRegion)(long ,long ,long ,long );
//extern long (* GLI_DRV_fn_lEnumerateDisplayMode)(void);
extern long (* GLI_DRV_fnl_EnumModes)(char *, char *);
extern HRESULT (* GLI_DRV_hChangeMode)( BOOL, long, long, long );
extern BOOL (* GLI_DRV_bLockDevice)( void **, long *);
extern BOOL (* GLI_DRV_bUnlockDevice)( void );
extern BOOL (* GLI_DRV_bPrepareForGliWindowed)(HWND);
extern void (* GLI_DRV_vPrepareForGliFullScreen)(HWND);
extern void (* GLI_DRV_vActivateGli)(HWND, BOOL);
extern void (* GLI_DRV_vReadaptDisplay)(void);
extern BOOL (* GLI_DRV_bWindowedModeIsOptimized)( void );
extern void (* GLI_DRV_vOptimizedWindowedMode)( void );
extern void (* GLI_DRV_vNonOptimizedWindowedMode)( void );
extern void (* GLI_DRV_vSetMainWindowForRender)(HWND);
extern void (* GLI_DRV_vRecomputeViewportToMaximizeDisplay)(int);
/* ClipTriangles */
extern void (* GLI_DRV_xClearViewingList)( void );
extern void (* GLI_DRV_xSendListToViewport)( GLD_tdstViewportAttributes * );
extern void (* GLI_DRV_vSetZClip)(float ,GLI_tdstInternalGlobalValuesFor3dEngine *);
extern void (* GLI_DRV_vSetClipWindow)(float ,float ,float ,float ,GLI_tdstInternalGlobalValuesFor3dEngine *);
extern void (* GLI_DRV_xSendElementTIToClip_TRIANGLES)( GEO_tdstElementIndexedTriangles *, GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT);
extern void (* GLI_DRV_xSendSingleTriangleToClip_TRIANGLES)( GLI_tdstAligned2DVector *a3_st2DVertex, ACP_tdst2DUVValues *a3_stUV, GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT);
/* misc request (see request type n dllcaps.h file) */
extern long (* GLI_DRV_lRequest)( long, long, long );
extern void GLI_fn_vDrawMirror(BOOL);
#ifndef RETAIL
extern void (*GLI_DRV_vGetStats)(unsigned long *, unsigned long *);
#else
#define GLI_DRV_vGetStats( a, b)
#endif
extern void (*GLI_DRV_vWaitRetrace)(void);
/*
=======================================================================================
Structures
=======================================================================================
*/
typedef struct GLI_tdst_DllInfos_
{
HINSTANCE h_Module;
char sz_Name[64];
char sz_Desc[256];
char sz_Version[16];
unsigned long ul_Code;
char sz_FileName[ _MAX_PATH ];
char sz_DriverName[ 32 ];
char sz_DeviceName[ 32 ];
long l_InitWidth;
long l_InitHeight;
long l_InitFullScreen;
long l_InitBpp;
long l_RealWidth;
long l_RealHeight;
float f_WidthRatio;
float f_HeightRatio;
} GLI_tdst_DllInfos;
/*
=======================================================================================
globals
=======================================================================================
*/
extern GLI_tdst_DllInfos GLI_gst_DllInfo;
/*
=======================================================================================
Functions
=======================================================================================
*/
long GLI_fnl_InitDll( void );
long GLI_fn_lCloseGliDriver( void );
void GLI_fnv_SetDllFileName( char *_sz_Name );
void GLI_fnv_SetDllName( char *_sz_Name );
void GLI_fnv_SetDriverName( char *_sz_Name );
void GLI_fnv_SetDeviceName( char *_sz_Name );
void GLI_fnv_SetMode( long _l_FullScreen, long _l_Width, long _l_Height, long _l_Bpp );
void GLI_fnv_SetModeByString( char *_sz_Line );
#endif /* __DLLINTER_H__ */

View File

@@ -0,0 +1,113 @@
/*
=======================================================================================
Name : DispMode.h
Author : vincent lhullier Date :04/09/98
Description : Manage the different display mode available
=======================================================================================
*/
#ifndef __DISPMODE_H__
#define __DISPMODE_H__
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <stdio.h>
#include "GLI_util.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#ifdef __cplusplus
extern "C"
{
#endif
/*
=======================================================================================
Structure
=======================================================================================
*/
/*
* to store display mode
*/
typedef struct GLI_tdstDisplayMode_
{
long lFullScreen;
long lWidth;
long lHeight;
long lBpp;
} GLI_tdstDisplayMode;
/*
=======================================================================================
Constants
=======================================================================================
*/
#define GLI_C_lMaxDisplayMode 32
/*
=======================================================================================
Globals
=======================================================================================
*/
extern GLI_tdstDisplayMode GLI_gs_a_stDisplayMode[ GLI_C_lMaxDisplayMode ];
extern long GLI_gs_lNumberOfDisplayModes;
extern long GLI_gs_lCurrentDisplayMode;
extern long GLI_gs_lRequestedDisplayMode;
/*
=======================================================================================
Access function
=======================================================================================
*/
/*
* for display mode
*/
long GLI_fn_lIsFullScreenMode( void );
long GLI_fn_lDisplayModeWidth( void );
long GLI_fn_lDisplayModeHeight( void );
long GLI_fn_lDisplayModeBPP( void );
long GLI_fn_lGetDisplayMode( void );
long GLI_fn_lAddDisplayMode( long _lFullScreen, long _lWidth, long _lHeight, long _lBpp );
long GLI_fn_lGetNumberOfDisplayModes( void );
long GLI_fn_lGetCurrentDisplayMode( void );
long GLI_fn_lGetDisplayModeParameters( long _lDisplayMode, long *_p_lWidth, long *_p_lHeight );
long GLI_fn_lGetDisplayModeDescription( long _lDisplayMode, char *_szDesc );
void GLI_fn_lRequestNewDisplayMode( long _lDisplayMode );
long GLI_fn_lChangeDisplayMode( void );
/*
=======================================================================================
Function
=======================================================================================
*/
/*
* choose / select
*/
long GLI_fn_lSelectDisplayModeByIndex( long _lIndex );
long GLI_fn_lSelectDisplayModeByDimension( long _lWidth, long _lHeight, long _lBpp );
/*
* init
*/
void GLI_fn_vLoadDisplayMode( void );
/*
*
*/
void GLI_fn_vSetBrightness( long _lValue );
long GLI_fn_lGetBrightness();
#ifdef __cplusplus
}
#endif
#endif /*__DISPMODE_H__*/

View File

@@ -0,0 +1,53 @@
/* File: DrawFlags.h*/
/* Author: Steve McCalla*/
/* Date: 9 Sept 1998*/
/* these flags tell us which functions are called.*/
/* This allows us to find the common sets of functions and group them, saving thousands of*/
/* function calls and helping out our poor little 8k DCache on the Pentium.*/
/* When you want to find out which functions are called, just print the flag out */
/* to the error.log before calling the first func. Attention: ca va ramer quand tu le fais!*/
/**/
#ifndef DRAW_FLAGS_H
#define DRAW_FLAGS_H
#define Flag_GLI_vSetSpecular (1<<0)
#define Flag_GLI_vComputeXYZ (1<<1)
#define Flag_GLI_FastZCull (1<<3)
#define Flag_GLI_FastMirrorCulling (1<<4)
#define Flag_GLI_bCullingXYALL (1<<5)
#define Flag_GLI_bCullingXMin (1<<6)
#define Flag_GLI_bCullingXMax (1<<7)
#define Flag_GLI_bCullingXMax_XMin (1<<8)
#define Flag_GLI_bCullingYMin (1<<9)
#define Flag_GLI_bCullingYMax (1<<10)
#define Flag_GLI_bCullingYMax_YMin (1<<11)
#define Flag_GLI_FastWaterCLipping (1<<12)
#define Flag_GLI_FastMirrorCLipping (1<<13)
#define Flag_GLI_vZClipping (1<<14)
#define Flag_GLI_TestBackfaceClockwise (1<<15)
#define Flag_GLI_TestBackfaceCounterClockwize (1<<16)
#define Flag_GLI_XMaxCLipping (1<<17)
#define Flag_GLI_XMinCLipping (1<<18)
#define Flag_GLI_YMinCLipping (1<<20)
#define Flag_GLI_YMaxCLipping (1<<21)
#define Flag_GLI_vComputeMirrorUVW (1<<23)
#define Flag_GLI_vComputeMovingUVW (1<<24)
#define Flag_GLI_vComputeNormalUVW (1<<25)
#define Flag_GLI_vZSortTriangle (1<<26)
#define Flag_GLI_vDrawWiredTriangle (1<<27)
#define Flag_GLI_vDrawTriangle (1<<28)
#define Flag_GLI_vCorrect3DFXBug1 (1<<29)
/* These values were determined experimentally - they may change as the maps change*/
#define MaskBigFunc1 (Flag_GLI_vSetSpecular|Flag_GLI_vComputeXYZ|Flag_GLI_TestBackfaceClockwise|Flag_GLI_vComputeNormalUVW|Flag_GLI_vDrawTriangle|Flag_GLI_vCorrect3DFXBug1)
/* this variable is defined in ClipTriangles.c*/
extern unsigned long ulFuncMask;
#endif /*DRAW_FLAGS_H*/

View File

@@ -0,0 +1,44 @@
/*
=======================================================================================
Name : GLI_Menu.h
Author : vincent lhullier Date :10/03/99
Description : function to display gli menu
=======================================================================================
=======================================================================================
!!!! Warning : In retail version this file define only empty symbols !!!!
=======================================================================================
=======================================================================================
*/
#if defined(RETAIL) || defined(PRESS_DEMO)
#define GLI_fnv_ManageMenu()
#define GLI_fn_vAddDisplayedVisualMaterial( _hVisualMaterial )
#define GLI_M_vAddDisplayedVisualMaterialForSprite( p_stEltSprite )
#define GLI_M_vAddDisplayedVisualMaterialForEltIndexedTriangle( p_stEltIndexedTriangle )
#else
void GLI_fnv_ManageMenu( void );
void GLI_fn_vAddDisplayedVisualMaterial( ACP_tdxHandleOfMaterial _hVisualMaterial );
#define GLI_M_vAddDisplayedVisualMaterialForSprite( p_stEltSprite ) \
{ \
if( p_stEltSprite -> d_stListOfSprites[lSpriteIndex].hSprite -> d_hMaterial[0] \
&& p_stEltSprite -> d_stListOfSprites[lSpriteIndex].hSprite -> d_hMaterial[0] -> hVisualMaterial ) \
{ \
GLI_fn_vAddDisplayedVisualMaterial( p_stEltSprite -> d_stListOfSprites[lSpriteIndex].hSprite -> d_hMaterial[0] -> hVisualMaterial ); \
} \
}
#define GLI_M_vAddDisplayedVisualMaterialForEltIndexedTriangle( p_stEltIndexedTriangle ) \
{ \
if( p_stEltIndexedTriangle -> hMaterial \
&& p_stEltIndexedTriangle -> hMaterial -> hVisualMaterial ) \
{ \
GLI_fn_vAddDisplayedVisualMaterial( p_stEltIndexedTriangle -> hMaterial -> hVisualMaterial ); \
} \
}
#endif /* RETAIL */

View File

@@ -0,0 +1,19 @@
/*
=======================================================================================
Name : GLI_UTIL.h
Author : vincent lhullier Date :03/09/98
Description : Utility for GLI
=======================================================================================
*/
#ifndef __GLI_UTIL_H__
#define __GLI_UTIL_H__
/*
=======================================================================================
Function
=======================================================================================
*/
DLGTEMPLATE *fn_p_stPrepareDialogBox_LB( char *szTitle );
#endif /*__GLI_UTIL_H__*/

View File

@@ -0,0 +1,78 @@
/*
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Name : GliBench.h Author : vincent lhullier Date :12/10/98 Description : Bench Data
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*/
#ifndef __GLIBENCH_H__
#define __GLIBENCH_H__
/* BENCH ACTIVE */
#ifdef GLI_BENCH
/*
---------------------------------------------------------------------------------------------------
Structure
---------------------------------------------------------------------------------------------------
*/
typedef struct tdstGliBench_
{
long lNumberOfElementsSended;
long lNumberOfObjectsSended;
long lNumberOfPolygonsSended;
long lNumberOfLinesSended;
long lNumberOfPolygonsBackfaces;
long lNumberOfPolygonsZculled;
long lNumberOfPolygonsZClipped;
long lNumberOfPolygonsXYCulled;
long lNumberOfPolygonsXYClipped;
long lNumberOfPolygonsXYUnClipped;
long lRateInPolygons;
long lRateInPixels;
long lPolycounter;
long lPolyTransparentcounter;
long lPolyOpaquecounter;
/* Light */
long lNumberOfHotSpotLightedVertices;
long lNumberOfSpecularLightedVertices;
long lNumberOfParallelLightedVertices;
/* triangle surface */
long lTrianglePerSurface[ 1024 ];
} tdstGliBench;
/*
===================================================================================================
Macros to be used by m<>ain appli (not by DLL)
===================================================================================================
*/
#define GLI_M_vBenchInc(a) GLI_g_stBench.##a++;
#define GLI_M_vBenchAdd(a, b) GLI_g_stBench.##a += b;
#define GLI_M_vBenchReset() memset(&GLI_g_stBench, 0, sizeof(tdstGliBench));
/*
===================================================================================================
Macros to be used by DLL
===================================================================================================
*/
#define GLI_MDRV_M_vBenchInc(a) GLI_MDRV_g_p_stBench->##a++;
#define GLI_MDRV_M_vBenchAdd(a, b) GLI_MDRV_g_p_stBench->##a += b;
/* Globals */
extern tdstGliBench GLI_g_stBench;
extern tdstGliBench *GLI_MDRV_g_p_stBench;
/* BENCH NOT ACTIVE */
#else /* GLI_BENCH */
#define GLI_M_vBenchInc(a)
#define GLI_M_vBenchAdd(a, b)
#define GLI_M_vBenchReset()
#define GLI_MDRV_M_vBenchInc(a)
#define GLI_MDRV_M_vBenchAdd(a, b)
#endif
#endif /* __GLIBENCH_H */

View File

@@ -0,0 +1,36 @@
/*
=======================================================================================
Name : GLIText.h
Author : vincent lhullier Date :12/10/98
Description : function to display text on screen
=======================================================================================
=======================================================================================
!!!! Warning : In retail version this file is empty !!!!
=======================================================================================
=======================================================================================
*/
#ifndef __GLITEXT_H__
#define __GLITEXT_H__
#ifndef RETAIL
void GLITEXT_fnv_Init( void );
void GLITEXT_fnv_Close( void );
void GLI_vDisplayPolices(unsigned char *d_ucFileName, long lX, long lY);
void GLITEXT_fnv_SetProportionalMode( long _l_Mode );
long GLITEXT_fnl_GetProportionalMode( void );
#else
#define GLITEXT_fnv_Init()
#define GLITEXT_fnv_Close()
#define GLI_vDisplayPolices(a,b,c)
#define GLITEXT_fnv_SetProportionalMode( a )
#define GLITEXT_fnl_GetProportionalMode( b ) 0
#endif
#endif /*__GLITEXT_H__*/

View File

@@ -0,0 +1,43 @@
#ifndef GLI_ST_H
#define GLI_ST_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#ifdef EXTERN_GLI
#undef EXTERN_GLI
#endif
#ifdef MAIN_GLI
#define EXTERN_GLI
#else
#define EXTERN_GLI extern
#endif
#ifdef U64
#define NO_ASSEMBLY_IN_GLI /* Julien Merceron */
#else
#define NO_ASSEMBLY_IN_GLI
#endif
#ifdef NO_ASSEMBLY_IN_GLI
#define ASM_CAST
#else
#define ASM_CAST (long)
#pragma message("Compile l'assembleur dans GLI..")
#endif
#include "Acp_Base.h"
#include "cpa_std.h"
#ifdef VISUAL
#define GLI_INTERNAL_FAST_CALLING_CONV __fastcall
#else
#define GLI_INTERNAL_FAST_CALLING_CONV
#endif
#ifdef __cplusplus
};
#endif /* __cplusplus */
#endif

View File

@@ -0,0 +1,59 @@
#ifndef LIGHT_ST_H
#define LIGHT_ST_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include "GEO.h"
/* For DLL using these function :*/
#include "cpa_expt.h"
#include "POS.h"
typedef struct GLI_tdstZBufferForLight_
{
long lSizeX;
long lSizeY;
/* Projection x = X * coefX / Z . y = Y * CoefY / Z;*/
float fCoefX;
float fCoefY;
float *p_stZBufferMap;
float *p_stMiddleZBufferMap;
} GLI_tdstZBufferForLight;
typedef struct GLI_tdstLight_
{
long b_lOnOff ;
long bThisLightIsZBuffered;
long lTypeOfLight ;
MTH_tdxReal xFar,xNear;
/* for hotspot.*/
MTH_tdxReal xLittleAlpha,xBigAlpha;
MTH_tdxReal xLittleTangent,xBigTangent;
POS_tdstCompletePosition stMatrix ;
GLI_tdstZBufferForLight stZBuffer;
GEO_tdstColor stColor ;
unsigned char bValid;
unsigned char ucObjectLighted;
unsigned char bIsPainting;
unsigned char ucIsAlpha; /* 0: Normal (RGB&A) 1: A Only 2: RGB Only */
MTH3D_tdstVector xInter_Min_Pos;
MTH3D_tdstVector xExter_Min_Pos;
MTH3D_tdstVector xInter_Max_Pos;
MTH3D_tdstVector xExter_Max_Pos;
MTH3D_tdstVector xCenterBox;
MTH_tdxReal xRadius;
MTH_tdxReal xIntensity_Min;
MTH_tdxReal xIntensity_Max;
GEO_tdstColor stBackgroundColor;
}
GLI_tdstLight;
#ifdef __cplusplus
};
#endif /* __cplusplus */
#endif /* LIGHT_H*/

View File

@@ -0,0 +1,22 @@
#ifndef __MATBENCH_H__
#define __MATBENCH_H__
/*#define BENCH_MATERIAL*/
#ifdef BENCH_MATERIAL
#include "mater_st.h"
void MATBENCH_fn_vAddMaterialRef( GLI_tdstMaterial *_pst_Material );
void MATBENCH_fn_vDeleteMaterialRef( GLI_tdstMaterial *_pst_Material );
void MATBENCH_fn_vWriteMaterialInfoInFile( char *_szTitle );
#else
#define MATBENCH_fn_vAddMaterialRef(a)
#define MATBENCH_fn_vDeleteMaterialRef(a)
#define MATBENCH_fn_vWriteMaterialInfoInFile(a);
#endif
#endif /*__MATBENCH_H__*/

View File

@@ -0,0 +1,142 @@
/*
=======================================================================================
Name : Mater_st.h
Description : structure for material
=======================================================================================
*/
#ifndef GLI_MATERIAL_ST_H
#define GLI_MATERIAL_ST_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include "GEO.h"
#include "textu_st.h"
/*
=======================================================================================
Multi texture material structure
=======================================================================================
*/
#ifdef MULTI_TEXTURE
#define C_MTMF_cUVStaticTransEnable 0x01
#define C_MTMF_cUVDynamicTransEnable 0x02
#define C_MTMF_cUVStaticMatEnable 0x04
#define C_MTMF_cUVDynamicMatEnable 0x08
#define C_MTMF_cIsNotLastTexture 0x10
#define C_MTMCO_cDisable 0
#define C_MTMCO_cSpecular 1
#define C_MTMCO_cDiffuse 2
#define C_MTMCO_cConstant 3
#define C_MTMCO_cSpecularAlpha 4
#define C_MTMCO_cDiffuseAlpha 5
#define C_MTMCO_cConstantAlpha 6
#define C_MTMCO_cSpecularColor 7
#define C_MTMCO_cDiffuseColor 8
#define C_MTMCO_cConstantColor 9
#define C_MTMOP_cMul 0
#define C_MTMOP_cAdd 1
#define C_MTMOP_cCopy 2
#define C_MTMOP_cAlphaTrans 3
#define C_MTMOP_cAlphaPremult 4
#define C_MTMOP_cMul2X 5
#define C_MTMOP_cInvert 6
#define C_MTMOP_cAddSmooth 7
#define C_MTMUV_cNoSource 0
#define C_MTMUV_cObject1 1
#define C_MTMUV_cObject2 2
#define C_MTMUV_cChrome 3
#define C_MTMUV_cScreen 4
#define C_MTMUV_cCartoon 5
#define C_MTMUV_cSolarPhong 6
typedef struct
{
float stMat[2][2];
float stTrans[2];
} GLI_tdstUVTransformation;
typedef struct
{
GLI_tdstTexture *pst_Texture;
char c_Operator;
char c_ColorOperator;
char c_UVSource;
char c_Flags;
GLI_tdstUVTransformation st_UVStaticPos;
GLI_tdstUVTransformation st_UVDynamicPos;
} GLI_tdstMultiTextureMaterial;
#endif /*MULTI_TEXTURE*/
/*
=======================================================================================
Standard structure
=======================================================================================
*/
/*
* Animated texture node
*/
typedef struct GLI_tdstAnimatedTextureNode_
{
GLI_tdstTexture *p_stTexture;
MTH_tdxReal xDisplayTime;
struct GLI_tdstAnimatedTextureNode_ *p_stNextDisplayNode;
} GLI_tdstAnimatedTextureNode;
/*
* Material structure
*/
typedef struct GLI_tdstMaterial_
{
unsigned long xMaterialType;
GEO_tdstColor stAmbient;
GEO_tdstColor stDiffuse;
GEO_tdstColor stSpecular;
GEO_tdstColor stColor;
long lSpecularExponent;
GLI_tdstTexture *p_stTexture;
/*
* scrolling material
*/
float fAddU;
float fAddV;
float fConstantAddU;
float fConstantAddV;
long lIncrementIsEnable;
/*
* for Animated textures.
*/
unsigned long lActualRefreshNumber;
GLI_tdstAnimatedTextureNode *p_stFistAnimatedTExtureNode;
GLI_tdstAnimatedTextureNode *p_stActualAnimatedTExtureNode;
long lNumberOfDisplayNode;
MTH_tdxReal xActualDisplayTimeSinceStartOfLastTexture;
ACP_tdxBool xIsLocked;
#ifdef MULTI_TEXTURE
GLI_tdstMultiTextureMaterial a_stMultiMaterial[8];
#endif /*MULTI_TEXTURE*/
} GLI_tdstMaterial ;
#ifdef __cplusplus
};
#endif /* __cplusplus */
#endif /* GLI_MATERIAL_H*/

View File

@@ -0,0 +1,19 @@
/*
=======================================================================================
Name : PrCoVert.h
Author : Date :24/07/98
Description : function prototype for vertex serail colorisation
=======================================================================================
Modification -> Author : Date :
Description :
=======================================================================================
*/
#ifndef __PRCOVERT_H__
#define __PRCOVERT_H__
void GLI_vSerialComputeVertexColorIndexedAlpha(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGP, ACP_tdxIndex xNumber,ACP_tdxIndex *p_ListOfIndexes);
void GLI_vSerialComputeVertexColorIndexedNoAlpha(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGP, ACP_tdxIndex xNumber,ACP_tdxIndex *p_ListOfIndexes);
void GLI_vSerialComputeVertexColor2(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGP, ACP_tdxIndex xNumber);
#endif

View File

@@ -0,0 +1,53 @@
#ifndef PRIVATEOBJECTH
#define PRIVATEOBJECTH
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* For DLL using these function :*/
#include "cpa_expt.h"
/*#ifdef USE_EXECUTE_BUFFER
void GLI_INTERNAL_FAST_CALLING_CONV
GLI_vResetAnExecuteBuffer(GLI_tdstExecuteBuffer *p_stExecuteBuffer);
void GLI_INTERNAL_FAST_CALLING_CONV
GLI_vAddOneTriangleToAnExecuteBuffer(GLI_tdstExecuteBuffer *p_stExecuteBuffer,GLI_tdstScreenVertex *p_FirstPoint,long lLenght);
GLI_tdstScreenVertex * GLI_INTERNAL_FAST_CALLING_CONV
GLI_vGetNewScreenVerticesOfExecuteBuffer(GLI_tdstExecuteBuffer *p_stExecuteBuffer,long lNbVertices);
void GLI_INTERNAL_FAST_CALLING_CONV
GLI_vFreeScreenVerticesOfExecuteBuffer(GLI_tdstExecuteBuffer *p_stExecuteBuffer,long lNbVertices);
void GLI_INTERNAL_FAST_CALLING_CONV
GLI_vAddOneMaterialToAnExecuteBuffer(GLI_tdstExecuteBuffer *p_stExecuteBuffer,ACP_tdxHandleOfMaterial hMaterial,long lDrawMask);
void GLI_INTERNAL_FAST_CALLING_CONV
GLI_vDrawAnExecuteBuffer(GLD_tdstViewportAttributes *p_stVpt ,
GLI_tdstExecuteBuffer *p_stExecuteBuffer);
void GLI_INTERNAL_FAST_CALLING_CONV
GLI_vInitExecutesBuffers();
void GLI_INTERNAL_FAST_CALLING_CONV
GLI_vEndExecuteBufferDraw();
#endif*/
/**********************************************************************************************/
/* Name: GLI_vInitModuleObject 1.0*/
/* Goal: Creates threads, reserve memory for all, init buffers...*/
/* Code: Philippe Vimont */
/* OPTIMMIZED : */
/**********************************************************************************************/
void
GLI_vInitModuleObject();
#ifdef __cplusplus
};
#endif /* __cplusplus */
#endif /* PRIVATEOBJECTH*/

View File

@@ -0,0 +1,155 @@
#ifndef PRIVATEOBJECTST
#define PRIVATEOBJECTST
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* For DLL using these function :*/
#include "cpa_expt.h"
#include "cpa_expt.h"
#include "textu_st.h"
#include "GLD.h"
#include "light.h"
typedef struct GLI_tdstAligned3DVector_
{
MTH_tdxReal xX,xY,xZ;
MTH_tdxReal ALIGN;
} GLI_tdstAligned3DVector;
typedef struct GLI_tdstAligned2DVector_
{
float xX ;
float xY ;
float xOoZ ;
unsigned long ulPackedColor;
} GLI_tdstAligned2DVector;
/* ------------------------- ZLISTE ----------------------------*/
typedef struct GLI_tdstOneNodeOfZListe_
{
void *p_ThreePoints;
GLI_tdstTexture *p_TextureOfTheTriangle;
struct GLI_tdstOneNodeOfZListe_ *p_NextNode;
unsigned long lCurrentDrawMask;
tdstFogParams *p_stFogParams;
ACP_tdxHandleOfMaterial p_stMaterial;
} GLI_tdstOneNodeOfZListe;
#define GLI_MaxZEntryPO2 12 /* == 4096 entries * n tables */
#define GLI_MaxZListeTrianglesPO2 11
#define GLI_NumberOfZListes 1
typedef struct GLI_tdstZListe_
{
long lMinValue[GLI_NumberOfZListes];
long lMaxValue[GLI_NumberOfZListes];
GLI_tdstOneNodeOfZListe *aDEF_p_tdstTableOfZentryNearestOfWaterPlane[GLI_NumberOfZListes<<GLI_MaxZEntryPO2];
GLI_tdstOneNodeOfZListe *p_stCurrentZNode;
GLI_tdstOneNodeOfZListe aDEF_tdstZListeNodes[1<<GLI_MaxZListeTrianglesPO2];
long lPointCounters;
void *p_CurrentPoint;
void *p_TableOfPoints;
} GLI_tdstZListe;
/* ----------------------- END ZLISTE --------------------------*/
#define GLI_C_ClipMaskXMin 0x00000001
#define GLI_C_ClipMaskXMax 0x00000002
#define GLI_C_ClipMaskYMin 0x00000004
#define GLI_C_ClipMaskYMax 0x00000008
#define GLI_C_CutMaskXMin 0x00000010
#define GLI_C_CutMaskXMax 0x00000020
#define GLI_C_CutMaskYMin 0x00000040
#define GLI_C_CutMaskYMax 0x00000080
#define GLI_C_ClipMaskZ 0x00000100
#define GLI_C_ClipMaskWater 0x00000200
#define GLI_C_IsCameraInBoundingVolume 0x00000400
#define GLI_C_IsObjectMatrixAlreadyInverted 0x00000800
#define GLI_C_AtLeastOneNegativeColorWasDetected 0x00001000
#define GLI_C_TrianglesMustBeSorted 0x00008000
#define GLI_C_ClipMaskAllDirection (GLI_C_ClipMaskXMin | GLI_C_ClipMaskXMax | GLI_C_ClipMaskYMin | GLI_C_ClipMaskYMax | GLI_C_ClipMaskZ)
typedef struct GLI_tdstInternalGlobalValuesFor3dEngine_
{
GLD_tdstViewportAttributes *p_stVpt ;
GEO_tdstGeometricObject *p_stObj ;
long lDrawModeMask;
long lHierachDrawMask;
long lCurrentDrawMask;
long GLD_RenderingCounter;
long lClippingModeMask;
MTH3D_tdstVector stCenterOfCurrentBoundingSphere;
MTH_tdxReal stRadiusOfCurrentBoundingSphere;
/* BIG TABLES*/
GLI_tdstAligned3DVector GLI_TurnedScaledDisplecedPoint [C_lMaxVertexPerObject] ;
GLI_tdstAligned2DVector GLI_ScreenPoint [C_lMaxVertexPerObject] ;
MTH_tdxReal GLI_aDEF_xWaterPlaneDepth [(C_lMaxVertexPerObject>>1)-8] ;
GEO_tdstColor GLI_aDEF_stColorsRLID [C_lMaxVertexPerObject] ;
GEO_tdstColor GLI_aDEF_stColorsRLIS [C_lMaxVertexPerObject] ;
GEO_tdstColor GLI_aDEF_stColorsRLIA;
ACP_tdst2DUVValues GLI_aDEF_stEnvUV [C_lMaxVertexPerObject] ; /*used for environment UV (chromed)*/
GEO_tdstColor GLI_stColorsAdd;
GEO_tdstColor GLI_stColorsMul;
POS_tdstCompletePosition *gs_st_CameraMatrix;
POS_tdstCompletePosition *gs_st_CurrentMatrix;
POS_tdstCompletePosition gs_st_CurrentMatrixInverted;
POS_tdstCompletePosition gs_st_CurrentMatrixMultiplyedWithCameraMatrix;
float fZClipping;
float fWClipping;
float fXMinClipping;
float fXMaxClipping;
float fYMinClipping;
float fYMaxClipping;
GLI_tdstTexture *p_stCurrentTexture;
ACP_tdxHandleOfMaterial hCurrentMaterial;
struct GLI_tdstCamera_ *p_stCurrentCamera;
MTH_tdxReal xWaterPlaneDistance;
GLI_tdstAligned3DVector stWaterPlanNormale;
unsigned long ulColorInitForSprite;
unsigned long ulSpecularColorForSprite;
float fMulU;
float fMulV;
GLI_tdstZListe *p_TheZListe;
unsigned long ulCurrentZTable;
/*For fog*/
tdstFogParams *p_stActiveFog;
tdstFogParams *p_stLastComputedFog;
long xFogIsOn;
long xTextureDontAcceptFog;
/*For mirror*/
long lAMirrorIsDetected;
BOOL bDrawMirrorSymetric;
long lDisplayMenuIsDetected;
/*For alpha*/
float xGlobalAlpha;
} GLI_tdstInternalGlobalValuesFor3dEngine;
/* This must be a power of two.*/
void GLI_vSerialComputeVerticesPositions(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobalsParrameters,long xStart,long xNumber);
void GLI_vSerialComputeVertexColor(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobalsParrameters,long xStart,long xNumber,void *p_VertexScreen);
#ifdef __cplusplus
};
#endif /* __cplusplus */
#endif /* PRIVATEOBJECTST*/

View File

@@ -0,0 +1,43 @@
/*
=======================================================================================
Name : TexArray.h
Author : Gliglou corporation
Description : manage array of texture data
=======================================================================================
*/
#ifndef __TEXARRAY_H__
#define __TEXARRAY_H__
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include "texture.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
=======================================================================================
Globals
=======================================================================================
*/
/*
* array of texture / texture state
*/
extern GLI_tdstTexture *gs_aDEFTableOfTextureAlreadyRead [ GLI_C_lNBMaxOfTextures ];
extern long gs_aDEFTableOfTextureMemoryChannels[ GLI_C_lNBMaxOfTextures ];
extern unsigned long GLI_g_ulNumberOfLoadedTexture;
/*
=======================================================================================
Functions
=======================================================================================
*/
void GLI_fn_vUnallocTextureInChannel( unsigned char _ucChannel );
void GLI_fn_vUnallocAllTextures( void );
long GLI_lComputeTexturesSize( void );
long GLI_lGetBigestSizeOfTexture( void );
void GLI_vUnCompressExistantTexture(void);
GLI_tdstTexture *TEX_fnpst_DoesTextureExist( char *_szFileName );
void TEX_fnv_MakeItExisting( GLI_tdstTexture *_pst_TextureCreated );
#endif /*__TEXARRAY_H__*/

View File

@@ -0,0 +1,47 @@
#ifndef __TEXBENCH_H__
#define __TEXBENCH_H__
/*#define BENCH_TEXTURE*/
#ifdef BENCH_TEXTURE
#include "textu_st.h"
#define TEXBENCH_C_cComputedSize 0
#define TEXBENCH_C_cRealSize 1
#define TEXBENCH_C_cBeginUnload 0
#define TEXBENCH_C_cEndUnload 1
#define TEXBENCH_C_cBeginUncompress 2
#define TEXBENCH_C_cEndUncompress 3
#define TEXBENCH_C_cBeginCompression 4
#define TEXBENCH_C_cEndcompression 5
#define TEXBENCH_C_cBeginComputeLod 6
#define TEXBENCH_C_cEndComputeLod 7
#define TEXBENCH_C_cBeginDownload 8
#define TEXBENCH_C_cEndDownload 9
#define TEXBENCH_C_cBeginDownload1 10
#define TEXBENCH_C_cEndDownload1 11
#define TEXBENCH_C_cBeginDownload2 12
#define TEXBENCH_C_cEndDownload2 13
#define TEXBENCH_C_cBeginDownload3 14
#define TEXBENCH_C_cEndDownload3 15
void TEXBENCH_fn_vInitTextureSize( void );
void TEXBENCH_fn_vSetTextureSizeWithIndex( long _lTextureIndex, char _cSizeType, long _lSize );
void TEXBENCH_fn_vSetTextureSize( GLI_tdstTexture *_p_stTexture, char _cSizeType, long _lSize );
void TEXBENCH_fn_vWriteSizeInFile( void );
void TEXBENCH_fn_vSetTime( char _cFor );
#else
#define TEXBENCH_fn_vInitTextureSize()
#define TEXBENCH_fn_vSetTextureSizeWithIndex( a, b, c)
#define TEXBENCH_fn_vSetTextureSize( a, b, c )
#define TEXBENCH_fn_vWriteSizeInFile()
#define TEXBENCH_fn_vSetTime( a )
#endif
#endif /*__TEXBENCH_H__*/

View File

@@ -0,0 +1,19 @@
/*
=======================================================================================
Name : TexArray.h
Author : Gliglou corporation
Description : texture compression
=======================================================================================
*/
#ifndef __TEXCOMPRESS_H__
#define __TEXCOMPRESS_H__
/*
=======================================================================================
FUNCTIONS
=======================================================================================
*/
long TEX_lComputeCompression( void );
#endif /*__TEXCOMPRESS_H__*/

View File

@@ -0,0 +1,31 @@
/*
=======================================================================================
Name : TexName.h
Author : GLIGLOU corporation
Description : Fonction for texture name analysis / storage
=======================================================================================
*/
#ifndef __TEXNAME_H__
#define __TEXNAME_H__
#include "texture.h"
#ifdef __cplusplus
extern "C"
{
#endif
/*
* Analyse name of texture
*/
long GLI_fn_lAnalyseTextureName( char *_szFileName, long *_p_lTextureCaps, unsigned char *_p_ucCyclingMode );
void TEX_fnv_FixTextureName(char *_pszOut, char *_pszIn);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,54 @@
/*
=======================================================================================
Name : TexProcedural.c
Author : vincent lhullier Date :01/02/99
Description : function for procedural texture
=======================================================================================
*/
#ifdef PROCEDURAL_TEXTURE
#ifndef __TEX_PROCEDURAL_H__
#define __TEX_PROCEDURAL_H__
#include "textu_st.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*
=======================================================================================
Structure
=======================================================================================
*/
/*
typedef struct
{
long lFlags;
GLI_tdstTexture *pst_Texture;
} TEX_tdstProceduralData;
*/
long TEXPRO_fnl_InitProceduralTexture( GLI_tdstTexture *_pst_Texture, long _l_Type, long _l_Width, long _l_Height, long _l_RefreshRate );
long TEXPRO_fnl_InitProceduralTextureWithName( GLI_tdstTexture *_pst_Texture, char *_sz_ProcName, long _l_Width, long _l_Height, long _l_RefreshRate );
void TEXPRO_fnv_RefreshProceduralTexture( GLI_tdstTexture *_pst_Texture, long _l_ActualRefreshNumber );
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /*__TEX_PROCEDURAL_H__*/
#else /*PROCEDURAL_TEXTURE*/
#define TEXPRO_fnl_InitProceduralTexture(a,b,c,d,e)
#define TEXPRO_fnl_InitProceduralTextureWithName(a,b,c,d,e)
#define TEXPRO_fnv_RefreshProceduralTexture(a,b)
#endif /*PROCEDURAL_TEXTURE*/

View File

@@ -0,0 +1,81 @@
/*
=======================================================================================
Name : Textu_st.h
Description : Device indepent Texture structure
=======================================================================================
*/
#ifndef GLI_TEXTURE_ST_H
#define GLI_TEXTURE_ST_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*
* Texture structure
*/
typedef struct GLI_tdstTexture_
{
long bIsAvailable;
long lTextureQuality;
/* texture data */
void *p_vBitMap;
void *p_vColorTable;
/* Parameter specific for card. */
void *p_stSpecParam;
/* texture capabilies */
long lTextureCaps;
/* texture size (after compression) */
unsigned short lHeight;
unsigned short lWidth;
/* Real size (before compreesion). */
unsigned short lRealHeight;
unsigned short lRealWidth;
/* data for scrolling texture */
float fAddU;
float fAddV;
long lIncrementIsEnable;
/* chromakey data */
unsigned long lChromakeyColorRGBA;
/* MipMapping */
long lNumberOfLod;
unsigned long lCompressionCounter;
unsigned long lTypeOfCompression;
unsigned long lTypeOfMipMapping;
//struct GLI_tdstTexture_ *p_NextLodOfTexture;
//struct GLI_tdstTexture_ *p_PrevLodOfTexture;
struct GLI_tdstTexture_ *p_TextureOfSubstitution;
unsigned char ucBilinearMode;
unsigned char ucCylingMode;
char a255_cFileName[ 128 ];
//char *szName;
#ifdef PROCEDURAL_TEXTURE
long l_Type;
void *pv_Bitmap2;
long l_RefreshRate;
long l_RefreshCounter;
long l_RenderingCounter;
#endif
} GLI_tdstTexture;
#ifdef __cplusplus
};
#endif /* __cplusplus */
#endif /* GLI_TEXTURE_H*/

View File

@@ -0,0 +1,28 @@
#ifndef VISUALSET_ST_H
#define VISUALSET_ST_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef struct GEO_tdstVisualSet_
{
MTH_tdxReal xLastDistance ; /*/hysteresys. Works with only one viewport.*/
ACP_tdxIndex xNbLodDefinitions;
MTH_tdxReal *d_xThresholdsTable;
struct GEO_tdstGeometricObject_ **d_p_stLodDefinitions;
/*ANNECY JMD 17/02/98{*/
ACP_tdxHandleToRadiosity *d_hRLI ; /* array of RLI use by perso */
long lNumberOfRLI ; /* number of RLI in the array */
/*END ANNECY JMD }*/
}
GEO_tdstVisualSet ;
#ifdef __cplusplus
};
#endif /* __cplusplus */
#endif

View File

@@ -0,0 +1,94 @@
#ifndef LINEAR_H
#define LINEAR_H
#ifdef __cplusplus
extern "C" {
#endif
/* For DLL using these function :*/
#include "cpa_expt.h"
#include "vertex.h"
extern CPA_EXPORT void GLI_xSerialLinearOp( long lNbOfVertex , MTH3D_tdstVector *p_stSource , struct GLI_tdstAligned3DVector_ *p_stDest , POS_tdstCompletePosition *p_stMatrix) ;
extern CPA_EXPORT void GLI_xSerialDotProductAligned ( long lNbOfVertex, struct GLI_tdstAligned3DVector_ *p_stSource , float *p_stDest , MTH3D_tdstVector *p_stMultiplicator, long lIncrement) ;
/**********************************************************************************************/
/* Name: GLI_xSerialDotProduct*/
/* Goal: Compute (input 3d vector table)(a 3d Vector) -> (Dest scalar table)*/
/* Code: Philippe Vimont / 1.0*/
/**********************************************************************************************/
/* C function*/
#ifdef NO_ASSEMBLY_IN_GLI
extern CPA_EXPORT void GLI_xSerialDotProduct ( long lNbOfVertex, MTH3D_tdstVector *p_stSource , float *p_stDest, MTH3D_tdstVector *p_stMultiplicator, long lIncrement);
#else /*NO_ASSEMBLY_IN_GLI*/
#define GLI_xSerialDotProduct _GLI_xSerialDotProduct
CALLING_ASM_5_0(GLI_xSerialDotProduct, ecx, esi, edi, eax ,ebx );
#ifdef WATCOM
#pragma aux _GLI_xSerialDotProduct parm [ecx] [esi] [edi] [eax] [ebx] [edx]\
modify [ecx esi edi eax ebx edx];
#endif
/**********************************************************************************************/
/* Name: GLI_xSerialTouch*/
/* Goal: Read for cache (test)*/
/* Code: Philippe Vimont / 1.0*/
/* OPTIMMIZED : Assembly (serial.msm)*/
/**********************************************************************************************/
#define GLI_xSerialTouch _GLI_xSerialTouch
CALLING_ASM_2_0(GLI_xSerialTouch, ecx, edi);
#ifdef WATCOM
#pragma aux _GLI_xSerialTouch parm [ecx] [edi] \
modify [ecx edi];
#endif
/**********************************************************************************************/
/* Name: GLI_xSerialMula9MatrixVertex_*/
/* Goal: Read for cache (test)*/
/* Code: Philippe Vimont / 1.0*/
/* OPTIMMIZED : Assembly (serial.msm)*/
/**********************************************************************************************/
#define GLI_xSerialMula9MatrixVertex _GLI_xSerialMula9MatrixVertex
CALLING_ASM_5_0(GLI_xSerialMula9MatrixVertex, ecx, esi, edi, edx, eax );
#ifdef WATCOM
#pragma aux _GLI_xSerialMula9MatrixVertex parm [ecx] [esi] [edi] [edx] [eax] \
modify [ecx esi edi eax ebx edx];
#endif
/**********************************************************************************************/
/* Name: GLI_xSerialAddVertex */
/* Goal: Compute (Dest 3d vector table) + (a 3d Vector) -> (Dest 3d vector table)*/
/* Code: Philippe Vimont / 1.0*/
/* OPTIMMIZED : Assembly (serial.msm)*/
/**********************************************************************************************/
#define GLI_xSerialAdd3DVertex _GLI_xSerialAdd3DVertex
CALLING_ASM_3_0(GLI_xSerialAdd3DVertex, ecx, edi, eax );
#ifdef WATCOM
#pragma aux _GLI_xSerialAdd3DVertex parm [ecx] [edi] [eax] modify [ecx edi eax];
#endif /* WATCOM */
#endif /* NO_ASSEMBLY_IN_GLI */
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#ifdef __cplusplus
}; /* extern"c"*/
#endif
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#endif /* LINEAR_H*/

View File

@@ -0,0 +1,34 @@
#ifndef GLI_LISTE_H
#define GLI_LISTE_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* For DLL using these function :*/
#include "cpa_expt.h"
typedef struct GLI_tdst_Z_List_
{
unsigned char *g_d_ucFreeDisplayRooms ;
long g_lFreeDisplayRoomsCounter ;
long g_lFreeDisplayRoomsCounterMax ;
long g_lDisplayCounterMin ;
long g_lDisplayCounterMax ;
struct GLI_tdstElementInList_ *g_d_pstFreeElements ;
struct GLI_tdstElementInList_ *g_aDEF_pstViewingList[C_lMaxIndexInViewingList] ;
}
GLI_tdst_Z_List;
#define GLI_C_lFirstZIndexForDraw C_lMaxIndexInViewingList-1
EXTERN_GLI GLI_tdst_Z_List GLI_g_a2_stZ_List[1];
EXTERN_GLI GLI_tdst_Z_List *GLI_gp_CurrentZ_ListForBuild;
#ifdef __cplusplus
};
#endif /* __cplusplus */
#endif /* GLI_LISTE_H*/

View File

@@ -0,0 +1,282 @@
/*
=======================================================================================
Name : Camera.c
Description : Camera function
=======================================================================================
*/
/*
Tested with LINT
*/
#include "gli_st.h"
#include "GLI_Defn.h"
#include "light_st.h"
#ifndef U64
#include "PvObj_st.h"
#include "Liste.h"
#include "vpt3D.h"
#endif
#include "camera.h"
#include "Init_Gli.h"
#ifdef __cplusplus
extern "C"
{
#endif
#include "camera.cxx"
/*
=======================================================================================
a special camera to correct some bug (anti bug)
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : Create a camera
----------------------------------------------------------------------------------------
*/
/*
----------------------------------------------------------------------------------------
Description : Copy a camera
----------------------------------------------------------------------------------------
*/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC 07/06/99 */
void GLI_vCopyCamera ( GLI_tdstCamera *p_stCamDest ,GLI_tdstCamera *p_stCamSource )
{
*p_stCamDest = *p_stCamSource ;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC 07/06/99 */
/*
----------------------------------------------------------------------------------------
Description : Duplicate a camera
----------------------------------------------------------------------------------------
*/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC 04/06/99 */
GLI_tdstCamera *GLI_xDuplicateCamera ( GLI_tdstCamera *p_stCamSource )
{
GLI_tdstCamera *xReturnValue;
GLI_xCreateCamera ( &xReturnValue, p_stCamSource->lCameraMode);
GLI_vCopyCamera ( xReturnValue,p_stCamSource );
return (xReturnValue);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC 04/06/99 */
/*
----------------------------------------------------------------------------------------
Description : Access function to camera mode
----------------------------------------------------------------------------------------
*/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC 04/06/99 */
void GLI_xGetCameraMode ( GLI_tdstCamera *p_stCam , long *p_lMode)
{
*p_lMode = p_stCam -> lCameraMode;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC 04/06/99 */
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC 04/06/99 */
void GLI_xSetCameraMode ( GLI_tdstCamera *p_stCam , long lMode)
{
p_stCam -> lCameraMode = lMode;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC 04/06/99 */
/*
----------------------------------------------------------------------------------------
Description : return the lenght in pixels of 1.0 unity in the 3D worl at a Z distance
----------------------------------------------------------------------------------------
*/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC 04/06/99 */
MTH_tdxReal GLI_xGetCameraFocalizationPlane( GLI_tdstCamera *p_stCam )
{
return ( p_stCam->xScreen );
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC 04/06/99 */
/*
----------------------------------------------------------------------------------------
Description : Access function to camera near & far plane
----------------------------------------------------------------------------------------
*/
void GLI_xSetCameraNearFar( GLI_tdstCamera *p_stCam, GLI_tdxValue xNear , GLI_tdxValue xFar )
{
p_stCam->xNear = GLI_C_xZClippingNear; /*xNear;*/
if ( xFar == GLI_M_FloatToValue( 0.0 ) )
p_stCam -> xFar = GLI_M_FloatToValue( 100000.0 );
else
p_stCam -> xFar = xFar;
}
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC 04/06/99 */
void GLI_xGetCameraNearFar ( GLI_tdstCamera *p_stCam , GLI_tdxValue *p_xNear , GLI_tdxValue *p_xFar )
{
*p_xNear = p_stCam -> xNear;
*p_xFar = p_stCam -> xFar;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC 04/06/99 */
/*
----------------------------------------------------------------------------------------
Description : Access function to camera position matrix
----------------------------------------------------------------------------------------
*/
void GLI_xGetCameraMatrix ( GLI_tdstCamera *p_stCam, POS_tdstCompletePosition *p_stMatrix )
{
*p_stMatrix = p_stCam -> stMatrix ;
}
void GLI_xSetCameraMatrix( GLI_tdstCamera *p_stCam , POS_tdstCompletePosition *p_stMatrix )
{
p_stCam -> stMatrix = *p_stMatrix ;
}
/*
----------------------------------------------------------------------------------------
Description : Access function to camera aspect and ratio
----------------------------------------------------------------------------------------
*/
void GLI_xSetCameraAspectAndRatio ( GLI_tdstCamera *p_stCam, MTH_tdxReal xAlphaX, GLI_tdxValue xRatio )
{
p_stCam->xAlphaX = xAlphaX ;
p_stCam->xRatio = xRatio ;
p_stCam->xAlphaY = GLI_M_Mul ( xAlphaX , xRatio ) ;
}
void GLI_xGetCameraAspectAndRatio ( GLI_tdstCamera *p_stCam, MTH_tdxReal *p_xAlphaX , GLI_tdxValue *p_xRatio )
{
*p_xAlphaX = p_stCam -> xAlphaX ;
*p_xRatio = p_stCam->xRatio;
}
void GLI_xSetCameraRatio ( GLI_tdstCamera *p_stCam , GLI_tdxValue xRatio )
{
p_stCam->xRatio = xRatio ;
p_stCam->xAlphaY = GLI_M_Mul ( p_stCam->xAlphaX , xRatio ) ;
}
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC 04/06/99 */
void GLI_xGetCameraRatio ( GLI_tdstCamera *p_stCam , GLI_tdxValue *p_xRatio )
{
*p_xRatio = p_stCam->xRatio ;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC 04/06/99 */
/*
----------------------------------------------------------------------------------------
Description : Access function to viewport camera
----------------------------------------------------------------------------------------
*/
#ifdef U64
extern char g_bWeirdWaterEffect;
extern char g_bWeirdFireEffect;
extern int bChangedFarClippingSettings;
#endif
void GLI_xSetViewportCamera ( GLD_tdhDevice hDevice, GLD_tdhViewport hViewport, GLI_tdstCamera *p_stCam )
{
GLD_tdstViewportAttributes stViewAttrib;
GLI_tdstSpecificAttributesFor3D *p_stSpecAttrib3D;
if ( !GLD_bGetViewportAttributes( hDevice, hViewport, &stViewAttrib ) )
return;
p_stSpecAttrib3D = (GLI_tdstSpecificAttributesFor3D *)stViewAttrib.p_vSpecificToXD;
#ifdef U64
/* if ((g_bWeirdWaterEffect || g_bWeirdFireEffect) || ( p_stCam != p_stSpecAttrib3D->p_stCam ) || (bChangedFarClippingSettings)) */
#else
if ( p_stCam != p_stSpecAttrib3D->p_stCam )
#endif
{
p_stSpecAttrib3D->p_stCam = p_stCam;
GLI_xAdjustCameraToViewport ( hDevice, hViewport, p_stCam );
}
}
void GLI_xGetViewportCamera ( GLD_tdhDevice hDevice, GLD_tdhViewport hViewport, GLI_tdstCamera **p_stCam )
{
GLD_tdstViewportAttributes stViewAttrib;
GLI_tdstSpecificAttributesFor3D *p_stSpecAttrib3D;
if ( !GLD_bGetViewportAttributes( hDevice, hViewport, &stViewAttrib ) )
return ;
p_stSpecAttrib3D = (GLI_tdstSpecificAttributesFor3D *)stViewAttrib.p_vSpecificToXD;
(*p_stCam) = p_stSpecAttrib3D->p_stCam ;
}
/*
----------------------------------------------------------------------------------------
Description : Change le z dans le rep<65>re de la cam<61>ra d'un vertex dont les coordon<6F>es
sont dans le rep<65>re du monde, Tout en conservant les coordonn<6E>es x et y
<20> l'<27>cran.
Author : Yann Le Tensorer
Date : 07/01/97
----------------------------------------------------------------------------------------
*/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC 04/06/99 */
void fn_vSetZCamera(GLD_tdhDevice hDev, GLD_tdhViewport hVp, MTH3D_tdstVector *p_stSrcVertex, MTH3D_tdstVector *p_stDstVertex, MTH_tdxReal z)
{
GLI_tdstSpecificAttributesFor3D *p_stSpecAttrib3D;
GLD_tdstViewportAttributes stViewAttrib;
POS_tdstCompletePosition stMatrix, stInvMatrix ;
GLI_tdstCamera *p_stCam;
MTH3D_tdstVector stTmpVertex;
MTH_tdxReal z1;
if ( !GLD_bGetViewportAttributes( hDev, hVp, &stViewAttrib ) )
return;
p_stSpecAttrib3D = (GLI_tdstSpecificAttributesFor3D *)stViewAttrib.p_vSpecificToXD;
p_stCam = p_stSpecAttrib3D->p_stCam;
/* passe dans le rep<65>re de la camera*/
GLI_xGetCameraMatrix ( p_stCam , &stMatrix );
POS_fn_vMulMatrixVertex ( &stTmpVertex , &stMatrix , p_stSrcVertex );
/* z1 est le z du point initial dans le repere de la camera*/
z1=stTmpVertex.xZ;
/* z est le nouveau z dans le repere de la camera*/
stTmpVertex.xZ=z;
/* ajuste les coordonn<6E>es x et y pour que le point ait la m<>me projection <20> l'<27>cran*/
stTmpVertex.xX=z*stTmpVertex.xX/z1;
stTmpVertex.xY=z*stTmpVertex.xY/z1;
/* Repasse dans le rep<65>re du monde*/
POS_fn_vInvertMatrix ( &stInvMatrix , &stMatrix );
POS_fn_vMulMatrixVertex ( p_stDstVertex , &stInvMatrix , &stTmpVertex );
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC 04/06/99 */
#ifdef __cplusplus
} /* extern "C" */
#endif

View File

@@ -0,0 +1,28 @@
/*
=======================================================================================
Name : DLLInter.c
Author : vincent lhullier Date :14/09/98
Description : initialize Specific driver DLL
=======================================================================================
*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <windows.h>
#include "DLLCaps.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
=======================================================================================
Globals
=======================================================================================
*/
tdstGliCaps GLI_g_stCaps;
/*
=======================================================================================
Function
=======================================================================================
*/

View File

@@ -0,0 +1,557 @@
/*
=======================================================================================
Name : DLLInter.c
Author : vincent lhullier Date :14/09/98
Description : initialize Specific driver DLL
=======================================================================================
*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include "windows.h"
#include "GLI_util.h"
#include "DLLInter.h"
#include "DLLCaps.h"
#include "vertex.h"
#include "PvObj_st.h"
#include "Camera.h"
#include "GliBench.h"
#include "TexBench.h"
#include "GLD.h"
#include "PRF.h"
#include "Init_Gli.h"
#include "DispMode.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
=======================================================================================
Structure
=======================================================================================
*/
GLI_tdst_DllInfos GLI_gst_DllInfo;
/*
=======================================================================================
Constants
=======================================================================================
*/
#ifdef _DEBUG
#define C_szVersionSuffix "vd"
#elif RETAIL
#define C_szVersionSuffix "vf"
#elif NDEBUG
#define C_szVersionSuffix "vr"
#else
#error "Bad version"
#endif
/*
=======================================================================================
External
=======================================================================================
*/
extern GLI_tdstInternalGlobalValuesFor3dEngine *GLI_BIG_GLOBALS;
extern long gs_aDEFTableOfTextureMemoryChannels[];
extern GLI_tdstTexture *gs_aDEFTableOfTextureAlreadyRead [];
extern void *GLI_gs_p_ConvertBufferMipMapping;
extern long GLD_RenderingCounter;
extern void GLI_vSetGlobalAlpha(float );
extern void GLI_xSerialProjection ( GLI_tdstCamera *,long ,GLI_tdstAligned3DVector *,GLI_tdstAligned2DVector *);
extern long GLI_xIsGliInit(void);
extern void * GLI_fn_p_vTmpMalloc( unsigned long );
extern void GLI_fn_vTmpFree( void *);
extern long GLI_lComputeTexturesSize();
extern void GLI_vCompressTex565 ( GLI_tdstTexture *, void *);
extern void GLI_vCompressTex4444( GLI_tdstTexture *, void *);
extern void GLI_vCompressTex1555( GLI_tdstTexture *, void *);
extern void GLI_xLoadTextureInTexelField(GLI_tdstTexture *, long *, BOOL);
extern void GLI_vReloadTextures(void);
extern void GLI_vDivideBitmapSurfaceBy2NonZero (unsigned long *,unsigned long *,long , long );
extern void GLI_vDivideBitmapSurfaceBy2Palette (unsigned long *,unsigned long *,long , long );
extern void GLI_vDivideBitmapSurfaceBy2 (unsigned long *,unsigned long *,long , long );
extern unsigned long GLI_vVerifyTextureIsRealyAlpha ( GLI_tdstTexture *);
extern long GLI_fn_lAddDisplayMode( long , long , long , long );
extern void GLD_fn_vBlitStretched16b ( long , long , unsigned short *, long , long , long , unsigned short *);
extern long GLD_fn_lAddDefinedPixelFormat( GLD_tdstPixelFormat * );
extern GLD_tdstPixelFormat *GLD_fn_p_stGetDefinedPixelFormat( long );
extern long GLD_fn_lComputeWaitFrameForSmoothSynchro();
extern void Erm_fn_v_PrintErrMsg(char *, char *);
extern void GAM_fn_vReadStringInUbiIniFile( char *, char *, long , char *);
extern void GAM_fn_vWriteStringInUbiIniFile( char *, char *, char *);
extern void * fn_hGetDrawSemaphore( void );
extern void GLI_vUsePreCalculatedMipMaps ( GLI_tdstTexture *, void **, unsigned char *);
#if !defined(RETAIL)
extern void MMG_fn_vAddMemoryInfo (long , long , void *);
#endif
#if !defined(RETAIL) && !defined(PRESS_DEMO)
extern void GAM_fn_vShowRasters(void);
extern long PRF_fn_lGetIndependantVariable(unsigned long );
extern void PRF_fn_vSetIndependantVariable(unsigned long , long );
extern long PRF_fn_lIncIndependantVariable(unsigned long , long );
extern void GLI_fn_vPRFIncreaseVariable (unsigned long , void *, unsigned long );
extern void GLI_fn_vPRFStartChrono (unsigned long , void *);
extern void GLI_fn_vPRFStopChrono (unsigned long , void *);
#endif
extern HINSTANCE fn_hGetApplicationInstance(void);
extern u_long fn_ulTimerTickPerSecond(short wTimerType);
extern void fn_vTimerGetCounter(short wTimerType, stTimerCount* p_stValue);
/*
=======================================================================================
Globals
=======================================================================================
*/
/* General */
long (*GLI_DRV_lSendDataToDll)(char *, void *);
/* DOMATxxx.C */
void (* GLI_DRV_vDoOpaqueTextureSelection)( GLI_tdstInternalGlobalValuesFor3dEngine * );
void (* GLI_DRV_vWrite16bBitmapToBackBuffer) ( void *,long ,long ,long ,long, long, long );
void (* GLI_DRV_vAddBlackPolygon)( long , long , long , long );
void (* GLI_DRV_vNoBlackPolygon)( void );
void (* GLI_DRV_vComputeFogEffect)(GLI_tdstInternalGlobalValuesFor3dEngine *);
BOOL (* GLI_DRV_bBeginScene)(void);
BOOL (* GLI_DRV_bEndScene)(void);
/* ACCES_XXXX.C */
void (* GLI_DRV_vSendSpriteToClip)(GLI_tdstAligned2DVector *,MTH_tdxReal ,GLI_tdstInternalGlobalValuesFor3dEngine *);
void (* GLI_DRV_vSendSpriteToClipWithUV)( GLI_tdstAligned2DVector *, MTH_tdxReal *, MTH_tdxReal , GLI_tdstInternalGlobalValuesFor3dEngine *);
/* ACCES_ALL.C */
void (* GLI_DRV_vSendSingleLineToClip)( GLD_tdstViewportAttributes *, GLI_tdstAligned3DVector *, GLI_tdstAligned2DVector *, GLI_tdstAligned3DVector *, GLI_tdstAligned2DVector *, GLI_tdstInternalGlobalValuesFor3dEngine *, long , GEO_tdstColor *);
/* HDWTex_xxx.C */
void (* GLI_DRV_vDownLoadTextures)(long, long, BOOL);
void (* GLI_DRV_vUnLoadTextures)(void);
long (* GLI_DRV_lGetTextureSize)( GLI_tdstTexture *);
/* init_XXX.c */
void (* GLI_DRV_vFlipDevice)(long );
void (* GLI_DRV_vFlipDeviceWithSyncro)(void);
void (* GLI_DRV_vClearDevice)(BOOL, BOOL , unsigned long );
void (* GLI_DRV_xInitDriver) (HWND, BOOL, long, long, long );
void (* GLI_DRV_vCloseDriver) (void);
void (* GLI_DRV_vClearZBufferRegion)(long ,long ,long ,long );
//long (* GLI_DRV_fn_lEnumerateDisplayMode)(void);
long (* GLI_DRV_fnl_EnumModes)(char *, char *);
HRESULT (* GLI_DRV_hChangeMode)( BOOL, long, long, long );
BOOL (* GLI_DRV_bLockDevice)( void **, long *);
BOOL (* GLI_DRV_bUnlockDevice)( void );
BOOL (* GLI_DRV_bPrepareForGliWindowed)(HWND);
void (* GLI_DRV_vPrepareForGliFullScreen)(HWND);
void (* GLI_DRV_vActivateGli)(HWND, BOOL);
void (* GLI_DRV_vReadaptDisplay)(void);
BOOL (* GLI_DRV_bWindowedModeIsOptimized)( void );
void (* GLI_DRV_vOptimizedWindowedMode)( void );
void (* GLI_DRV_vNonOptimizedWindowedMode)( void );
void (* GLI_DRV_vSetMainWindowForRender)(HWND);
void (* GLI_DRV_vRecomputeViewportToMaximizeDisplay)(int);
/* ClipTriangles */
void (* GLI_DRV_xClearViewingList)( void );
void (* GLI_DRV_xSendListToViewport)( GLD_tdstViewportAttributes * );
void (* GLI_DRV_vSetZClip)(float ,GLI_tdstInternalGlobalValuesFor3dEngine *);
void (* GLI_DRV_vSetClipWindow)(float ,float ,float ,float ,GLI_tdstInternalGlobalValuesFor3dEngine *);
void (* GLI_DRV_xSendElementTIToClip_TRIANGLES)( GEO_tdstElementIndexedTriangles *, GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT);
void (* GLI_DRV_xSendSingleTriangleToClip_TRIANGLES)( GLI_tdstAligned2DVector *a3_st2DVertex, ACP_tdst2DUVValues *a3_stUV, GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT);
/* misc request (see request type n dllcaps.h file) */
long (* GLI_DRV_lRequest)( long, long, long );
#ifndef RETAIL
void (*GLI_DRV_vGetStats)(unsigned long *, unsigned long *);
#endif
void (*GLI_DRV_vWaitRetrace)(void);
/*
=======================================================================================
Public function
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : Load Driver DLL
----------------------------------------------------------------------------------------
*/
long GLI_fnl_InitDll( void )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long (*SendFunctionToDll)(char *, FARPROC );
long (*pfnGetDllInfo)(char *, void *);
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
GLI_gst_DllInfo.h_Module = LoadLibrary( GLI_gst_DllInfo.sz_FileName );
if (GLI_gst_DllInfo.h_Module == NULL)
return 0;
/*
* Get Info
*/
pfnGetDllInfo = (long (__cdecl *)(char *, void *) ) GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_lGetDllInfo" );
if (pfnGetDllInfo == NULL)
return 0;
pfnGetDllInfo( "Name", (void *) GLI_gst_DllInfo.sz_Desc );
if (strcmp( GLI_gst_DllInfo.sz_Desc, GLI_gst_DllInfo.sz_Name ) != 0)
return 0;
pfnGetDllInfo( "Description",(void *) GLI_gst_DllInfo.sz_Desc );
pfnGetDllInfo( "Version", (void *) GLI_gst_DllInfo.sz_Version );
pfnGetDllInfo( "Code", (void *) &GLI_gst_DllInfo.ul_Code );
/*
* Send data pointer to DLL (all data cannot be send now, some initialized later are send later)
*/
GLI_DRV_lSendDataToDll = (long (__cdecl *)(char *, void *) ) GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_lSetCommonData" );
GLI_DRV_lSendDataToDll("GliDllInfo", &GLI_gst_DllInfo);//chbani
GLI_DRV_lSendDataToDll("GliBigGlobals", GLI_BIG_GLOBALS);
GLI_DRV_lSendDataToDll("TextureMemoryChannels", gs_aDEFTableOfTextureMemoryChannels);
GLI_DRV_lSendDataToDll("TextureAlreadyRead", gs_aDEFTableOfTextureAlreadyRead );
GLI_DRV_lSendDataToDll("ConvertBufferMipMapping", GLI_gs_p_ConvertBufferMipMapping);
GLI_DRV_lSendDataToDll("RenderingCounterPointer", &GLD_RenderingCounter );
GLI_DRV_lSendDataToDll("DrawSem", fn_hGetDrawSemaphore() );
GLI_DRV_lSendDataToDll("GliCaps", &GLI_g_stCaps );
#ifdef GLI_BENCH
GLI_DRV_lSendDataToDll("GliBench", &GLI_g_stBench );
#endif
/*
* send function pointer to DLL (all needed are sended here)
*/
SendFunctionToDll = (long (__cdecl *)(char *, FARPROC) ) GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_lSetCommonFct" );
SendFunctionToDll("SetGlobalAlpha", (FARPROC) GLI_vSetGlobalAlpha);
SendFunctionToDll("SerialProjection", (FARPROC) GLI_xSerialProjection);
SendFunctionToDll("IsGliInit", (FARPROC) GLI_xIsGliInit);
SendFunctionToDll("TmpMalloc", (FARPROC) GLI_fn_p_vTmpMalloc);
SendFunctionToDll("TmpFree", (FARPROC) GLI_fn_vTmpFree);
SendFunctionToDll("ErmPrintMessage", (FARPROC) Erm_fn_v_PrintErrMsg );
SendFunctionToDll("ComputeTextureSize", (FARPROC) GLI_lComputeTexturesSize);
SendFunctionToDll("CompressTex565", (FARPROC) GLI_vCompressTex565);
SendFunctionToDll("CompressTex4444", (FARPROC) GLI_vCompressTex4444);
SendFunctionToDll("CompressTex1555", (FARPROC) GLI_vCompressTex1555);
SendFunctionToDll("DivideBitmapSurfaceBy2", (FARPROC) GLI_vDivideBitmapSurfaceBy2);
SendFunctionToDll("DivideBitmapSurfaceBy2NonZero", (FARPROC) GLI_vDivideBitmapSurfaceBy2NonZero);
SendFunctionToDll("DivideBitmapSurfaceBy2Palette", (FARPROC) GLI_vDivideBitmapSurfaceBy2Palette);
SendFunctionToDll("VerifyTextureIsReallyAlpha", (FARPROC) GLI_vVerifyTextureIsRealyAlpha );
SendFunctionToDll("LoadTextureInTexelField", (FARPROC) GLI_xLoadTextureInTexelField);
SendFunctionToDll("ReloadTextures", (FARPROC) GLI_vReloadTextures);
SendFunctionToDll("AddDisplayMode", (FARPROC) GLI_fn_lAddDisplayMode );
SendFunctionToDll("BlitStretched16b", (FARPROC) GLD_fn_vBlitStretched16b );
SendFunctionToDll("GetDefinedPixelFormat", (FARPROC) GLD_fn_p_stGetDefinedPixelFormat );
SendFunctionToDll("AddDefinedPixelFormat", (FARPROC) GLD_fn_lAddDefinedPixelFormat );
SendFunctionToDll("ComputeWaitFrameForSmoothSynchro",(FARPROC) GLD_fn_lComputeWaitFrameForSmoothSynchro );
SendFunctionToDll("ReadIniString", (FARPROC) GAM_fn_vReadStringInUbiIniFile );
SendFunctionToDll("WriteIniString", (FARPROC) GAM_fn_vWriteStringInUbiIniFile );
#if !defined(RETAIL)
SendFunctionToDll("AddMemoryInfo", (FARPROC) MMG_fn_vAddMemoryInfo );
#endif
#if !defined(RETAIL) && !defined(PRESS_DEMO)
SendFunctionToDll("ShowRasters", (FARPROC) GAM_fn_vShowRasters);
SendFunctionToDll("IncIndependantVariable", (FARPROC) PRF_fn_lIncIndependantVariable);
SendFunctionToDll("SetIndependantVariable", (FARPROC) PRF_fn_vSetIndependantVariable);
SendFunctionToDll("GetIndependantVariable", (FARPROC) PRF_fn_lGetIndependantVariable);
SendFunctionToDll("IncreaseVariable", (FARPROC) GLI_fn_vPRFIncreaseVariable );
SendFunctionToDll("ResetVariable", (FARPROC) PRF_fn_vResetVariable );
SendFunctionToDll("StopChrono", (FARPROC) GLI_fn_vPRFStopChrono );
SendFunctionToDll("StartChrono", (FARPROC) GLI_fn_vPRFStartChrono );
#endif
#ifdef BENCH_TEXTURE
SendFunctionToDll("TexBenchSetTextureSize", (FARPROC) TEXBENCH_fn_vSetTextureSize );
#endif
SendFunctionToDll("TimerGetCounter", (FARPROC) fn_vTimerGetCounter );
SendFunctionToDll("TimerTickPerSecond", (FARPROC) fn_ulTimerTickPerSecond );
/* DOMATxxx.C */
GLI_DRV_vDoOpaqueTextureSelection = ( void (__cdecl *) (GLI_tdstInternalGlobalValuesFor3dEngine *) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_vDoOpaqueTextureSelection" );
GLI_DRV_vWrite16bBitmapToBackBuffer = ( void (__cdecl *) (void *,long ,long ,long ,long, long, long) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_vWrite16bBitmapToBackBuffer" );
GLI_DRV_vAddBlackPolygon = ( void (__cdecl *) (long , long , long , long) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_vAddBlackPolygon" );
GLI_DRV_vNoBlackPolygon = ( void (__cdecl *) (void) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_vNoBlackPolygon" );
GLI_DRV_vComputeFogEffect = ( void (__cdecl *) (GLI_tdstInternalGlobalValuesFor3dEngine *) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_vComputeFogEffect" );
GLI_DRV_bBeginScene = ( BOOL (__cdecl *) (void) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_bBeginScene" );
GLI_DRV_bEndScene = ( BOOL (__cdecl *) (void) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_bEndScene" );
/* ACCES_XXXX.C */
GLI_DRV_vSendSpriteToClip = ( void (__cdecl *) (GLI_tdstAligned2DVector *,MTH_tdxReal ,GLI_tdstInternalGlobalValuesFor3dEngine *) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_vSendSpriteToClip" );
GLI_DRV_vSendSpriteToClipWithUV = ( void (__cdecl *) (GLI_tdstAligned2DVector *, MTH_tdxReal *, MTH_tdxReal , GLI_tdstInternalGlobalValuesFor3dEngine *) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_vSendSpriteToClipWithUV" );
/* ACCES_ALL.C */
GLI_DRV_vSendSingleLineToClip = ( void (__cdecl *) (GLD_tdstViewportAttributes *, GLI_tdstAligned3DVector *, GLI_tdstAligned2DVector *, GLI_tdstAligned3DVector *, GLI_tdstAligned2DVector *, GLI_tdstInternalGlobalValuesFor3dEngine *, long , GEO_tdstColor *) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_vSendSingleLineToClip" );
/* HDWTex_xxx.C */
GLI_DRV_vDownLoadTextures = ( void (__cdecl *) (long, long, BOOL) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_vDownLoadTextures" );
GLI_DRV_vUnLoadTextures = ( void (__cdecl *) (void) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_vUnLoadTextures" );
GLI_DRV_lGetTextureSize = ( long (__cdecl *) ( GLI_tdstTexture *) ) GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_lGetSizeOfTexture" );
/* init_XXX.c */
GLI_DRV_vFlipDevice = ( void (__cdecl *) (long) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_vFlipDevice" );
GLI_DRV_vFlipDeviceWithSyncro = ( void (__cdecl *) (void) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_vFlipDeviceWithSyncro" );
GLI_DRV_vClearDevice = ( void (__cdecl *) (BOOL, BOOL , unsigned long) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_vClearDevice" );
GLI_DRV_xInitDriver = ( void (__cdecl *) (HWND, BOOL, long, long, long ) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_xInitDriver" );
GLI_DRV_vCloseDriver = ( void (__cdecl *) (void) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_vCloseDriver" );
GLI_DRV_vClearZBufferRegion = ( void (__cdecl *) (long, long, long, long) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_vClearZBufferRegion" );
// GLI_DRV_fn_lEnumerateDisplayMode = ( long (__cdecl *) (void))GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_fn_lEnumerateDisplayMode" );
GLI_DRV_fnl_EnumModes = ( long (__cdecl *) (char*, char* ) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_fnl_EnumModes" );
GLI_DRV_hChangeMode = ( HRESULT (__cdecl *) (BOOL, long, long, long ) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_hChangeMode" );
GLI_DRV_bLockDevice = ( BOOL (__cdecl *) (void **, long *) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_bLockDevice" );
GLI_DRV_bUnlockDevice = ( BOOL (__cdecl *) (void) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_bUnlockDevice" );
GLI_DRV_bPrepareForGliWindowed = ( BOOL (__cdecl *) (HWND) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_bPrepareForGliWindowed" );
GLI_DRV_vPrepareForGliFullScreen = ( void (__cdecl *) (HWND) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_vPrepareForGliFullScreen" );
GLI_DRV_vActivateGli = ( void (__cdecl *) (HWND, BOOL) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_vActivateGli" );
GLI_DRV_vReadaptDisplay = ( void (__cdecl *) (void) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_vReadaptDisplay" );
GLI_DRV_bWindowedModeIsOptimized = ( BOOL (__cdecl *) (void) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_bWindowedModeIsOptimized" );
GLI_DRV_vOptimizedWindowedMode = ( void (__cdecl *) (void) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_vOptimizedWindowedMode" );
GLI_DRV_vNonOptimizedWindowedMode = ( void (__cdecl *) (void) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_vNonOptimizedWindowedMode" );
GLI_DRV_vSetMainWindowForRender = ( void (__cdecl *) (void) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_vSetMainWindowForRender" );//chbani
GLI_DRV_vRecomputeViewportToMaximizeDisplay = ( void (__cdecl *) (int) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_vRecomputeViewportToMaximizeDisplay" );//chbani
/* ClipTriangles */
GLI_DRV_xClearViewingList = ( void (__cdecl *) (void) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_xClearViewingList" );
GLI_DRV_xSendListToViewport = ( void (__cdecl *) (GLD_tdstViewportAttributes *) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_xSendListToViewport" );
GLI_DRV_vSetZClip = ( void (__cdecl *) (float ,GLI_tdstInternalGlobalValuesFor3dEngine *) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_vSetZClip" );
GLI_DRV_vSetClipWindow = ( void (__cdecl *) (float ,float ,float ,float ,GLI_tdstInternalGlobalValuesFor3dEngine *) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_vSetClipWindow" );
GLI_DRV_xSendElementTIToClip_TRIANGLES = ( void (__cdecl *) (GEO_tdstElementIndexedTriangles *, GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_xSendElementTIToClip_TRIANGLES" );
GLI_DRV_xSendSingleTriangleToClip_TRIANGLES = ( void (__cdecl *) (GLI_tdstAligned2DVector *a3_st2DVertex, ACP_tdst2DUVValues *a3_stUV, GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_xSendSingleTriangleToClip_TRIANGLES" );
/* misc request (see request type n dllcaps.h file) */
GLI_DRV_lRequest = ( long (__cdecl *) ( long, long, long ) ) GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_lRequest" );
#ifndef RETAIL
GLI_DRV_vGetStats = ( void (__cdecl *) (unsigned long *, unsigned long *) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_vGetStats" );
#endif
GLI_DRV_vWaitRetrace = ( void (__cdecl *) (void ) )GetProcAddress( GLI_gst_DllInfo.h_Module, "GLI_DRV_vWaitRetrace" );
return 1;
}
/*
----------------------------------------------------------------------------------------
Description : Close driver
----------------------------------------------------------------------------------------
*/
long GLI_fn_lCloseGliDriver( void )
{
FreeLibrary( GLI_gst_DllInfo.h_Module );
return 0;
}
/*
----------------------------------------------------------------------------------------
Description : Set Dll filename
----------------------------------------------------------------------------------------
*/
void GLI_fnv_SetDllFileName( char *_sz_Name )
{
sprintf( GLI_gst_DllInfo.sz_FileName, "dll/%s%s.dll", _sz_Name, C_szVersionSuffix );
}
/*
----------------------------------------------------------------------------------------
Description : set dll name
----------------------------------------------------------------------------------------
*/
void GLI_fnv_SetDllName( char *_sz_Name )
{
strcpy( GLI_gst_DllInfo.sz_Name, _sz_Name );
}
/*
----------------------------------------------------------------------------------------
Description : set driver name
----------------------------------------------------------------------------------------
*/
void GLI_fnv_SetDriverName( char *_sz_Name )
{
strcpy( GLI_gst_DllInfo.sz_DriverName, _sz_Name );
}
/*
----------------------------------------------------------------------------------------
Description : set device name
----------------------------------------------------------------------------------------
*/
void GLI_fnv_SetDeviceName( char *_sz_Name )
{
strcpy( GLI_gst_DllInfo.sz_DeviceName, _sz_Name );
}
/*
----------------------------------------------------------------------------------------
Description : set display mode
----------------------------------------------------------------------------------------
*/
void GLI_fnv_SetMode( long _l_FullScreen, long _l_Width, long _l_Height, long _l_Bpp )
{
GLI_gst_DllInfo.l_InitWidth = _l_Width;
GLI_gst_DllInfo.l_InitHeight = _l_Height;
GLI_gst_DllInfo.l_InitFullScreen = _l_FullScreen;
GLI_gst_DllInfo.l_InitBpp = _l_Bpp;
}
/*
----------------------------------------------------------------------------------------
Description : set display mode (parameters are in a string )
----------------------------------------------------------------------------------------
*/
void GLI_fnv_SetModeByString( char *_sz_Line )
{
GLI_gst_DllInfo.l_InitFullScreen = (*_sz_Line = '1') ? 1 : 0;
if ( ( _sz_Line = strchr( _sz_Line, '-' ) ) == NULL)
return;
GLI_gst_DllInfo.l_InitWidth = atoi( _sz_Line + 1 );
if ( ( _sz_Line = strchr( _sz_Line + 1, 'x' ) ) == NULL)
return;
GLI_gst_DllInfo.l_InitHeight = atoi( _sz_Line + 1 );
if ( ( _sz_Line = strchr( _sz_Line + 1, 'x' ) ) == NULL)
return;
GLI_gst_DllInfo.l_InitBpp = atoi( _sz_Line + 1 );
}
/*
=======================================================================================
Functions to make gateway between other modules (GAM, AI...) and GLI specific
=======================================================================================
*/
void GLI_xClearViewingList ( void )
{
GLI_DRV_xClearViewingList();
}
void GLI_xSendListToViewport( GLD_tdstViewportAttributes *p_stVpt )
{
GLI_DRV_xSendListToViewport( p_stVpt );
}
void GLI_ClearZBufferRegion(long lXStart,long lXEnd,long lYStart,long lYEnd)
{
GLI_DRV_vClearZBufferRegion(lXStart, lXEnd, lYStart, lYEnd);
}
void GLI_vWrite16bBitmapToBackBuffer( void *_p_vSourceBuffer, long _lWidth, long _lHeight, long _lDestLeft, long _lDestTop, long _lDestRight, long _lDestBottom )
{
GLI_DRV_vWrite16bBitmapToBackBuffer( _p_vSourceBuffer, _lWidth, _lHeight, _lDestLeft, _lDestTop, _lDestRight, _lDestBottom );
}
void GLI_fn_vGetStats( unsigned long *_p_ulPixelsSent, unsigned long *_p_ulPixelsDisplayed )
{
GLI_DRV_vGetStats( _p_ulPixelsSent, _p_ulPixelsDisplayed );
}
void GLI_fn_vWaitRetrace(void )
{
GLI_DRV_vWaitRetrace( );
}
void GLI_fn_vDrawMirror( BOOL _bStart )
{
GLI_BIG_GLOBALS->lAMirrorIsDetected = _bStart ? 3 : 0;
}
char GLI_fn_cWindowedModeIsOptimized(void)
{
return (GLI_DRV_bWindowedModeIsOptimized())?1:0;
}
void GLI_fn_vOptimizedWindowedMode(void)
{
GLI_DRV_vOptimizedWindowedMode();
}
void GLI_fn_vNonOptimizedWindowedMode(void)
{
GLI_DRV_vNonOptimizedWindowedMode();
}
void GLI_fn_vRecomputeViewportToMaximizeDisplay(int _arg)
{
GLI_DRV_vRecomputeViewportToMaximizeDisplay(_arg);
}
void GLI_fn_vSetMainWindowForRender(void * _hWnd)
{
GLI_DRV_vSetMainWindowForRender((HWND)_hWnd);
}
/*
=======================================================================================
Access to DLL data
=======================================================================================
*/
long GLI_lWhatIsGLI(void)
{
//return GLI_C_VersionGlide;
return (long) GLI_gst_DllInfo.ul_Code;
}
/*
=======================================================================================
Functions to make gateway between Gli specific and other module (inline functions)
=======================================================================================
*/
void GLI_fn_vPRFIncreaseVariable (unsigned long ulVar, void *p_vUser, unsigned long ulInc)
{
PRF_fn_vIncreaseVariable(ulVar, p_vUser, ulInc );
}
void GLI_fn_vPRFStartChrono (unsigned long _ulVar, void *_p_vUser)
{
PRF_fn_vStartChrono ( _ulVar, _p_vUser);
}
void GLI_fn_vPRFStopChrono (unsigned long _ulVar, void *_p_vUser)
{
PRF_fn_vStopChrono( _ulVar, _p_vUser );
}
/*
=======================================================================================
Functions for memory
=======================================================================================
*/
void *GLI_fn_p_vTmpMalloc( unsigned long _ulSize )
{
void *p_vPointer;
p_vPointer = TMP_M_p_Malloc( _ulSize );
return p_vPointer;
}
void GLI_fn_vTmpFree( void *_p_vPointer )
{
TMP_M_Free(_p_vPointer);
}

View File

@@ -0,0 +1,366 @@
/*
=======================================================================================
Name : DispMode.c
Author : vincent lhullier Date :04/09/98
Description : Manage the different display mode available
=======================================================================================
*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <windows.h>
#include <stdio.h>
#include "Init_Gli.h"
#include "GLI_util.h"
#include "DllInter.h"
#include "DispMode.h"
#include "Tex.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
=======================================================================================
Extern (globals and function prototypes)
=======================================================================================
*/
extern HINSTANCE fn_hGetApplicationInstance(void);
extern HWND fn_hGetApplicationWindow(void);
/* Defined in project main2_0 */
extern void fn_vChangeDeviceResolution(void);
/* Defined in Gliglou\Gld */
extern BOOL GLD_fn_bChangeDeviceDisplayMode( GLD_tdhDevice hDev );
/* Defined if GAM\Basic.c */
extern void GAM_fn_vActualizeAllGameViewportSize(void);
/*
=======================================================================================
Globals
=======================================================================================
*/
/*
* to store display mode
*/
GLI_tdstDisplayMode GLI_gs_a_stDisplayMode[ GLI_C_lMaxDisplayMode ];
long GLI_gs_lNumberOfDisplayModes = 0;
long GLI_gs_lCurrentDisplayMode;
long GLI_gs_lRequestedDisplayMode = -1;
/*
* Brightness value
*/
float GLI_g_xBrightness = 0.5f;
/*
=======================================================================================
Access function
=======================================================================================
*/
/*
* for display mode
*/
long GLI_fn_lIsFullScreenMode( void )
{
return (GLI_gs_a_stDisplayMode[GLI_gs_lCurrentDisplayMode].lFullScreen);
}
long GLI_fn_lDisplayModeWidth( void )
{
/*if (GLI_fn_lIsFullScreenMode() )*/
return GLI_gs_a_stDisplayMode[GLI_gs_lCurrentDisplayMode].lWidth;
/*
* windowed
*/
/*return 640;*/
}
long GLI_fn_lDisplayModeHeight( void )
{
/*if (GLI_fn_lIsFullScreenMode() )*/
return GLI_gs_a_stDisplayMode[GLI_gs_lCurrentDisplayMode].lHeight;
/*
* windowed
*/
/*return 480;*/
}
long GLI_fn_lDisplayModeBPP( void )
{
return GLI_gs_a_stDisplayMode[GLI_gs_lCurrentDisplayMode].lBpp;
}
long GLI_fn_lGetDisplayMode( void )
{
return GLI_gs_lCurrentDisplayMode;
}
/*
=======================================================================================
function for list of display modes
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : Add a display mode in list (no check if already exist are done)
----------------------------------------------------------------------------------------
*/
long GLI_fn_lAddDisplayMode( long _lFullScreen, long _lWidth, long _lHeight, long _lBpp )
{
GLI_gs_a_stDisplayMode[ GLI_gs_lNumberOfDisplayModes ].lFullScreen = _lFullScreen;
GLI_gs_a_stDisplayMode[ GLI_gs_lNumberOfDisplayModes ].lWidth = _lWidth;
GLI_gs_a_stDisplayMode[ GLI_gs_lNumberOfDisplayModes ].lHeight = _lHeight;
GLI_gs_a_stDisplayMode[ GLI_gs_lNumberOfDisplayModes ].lBpp = _lBpp;
GLI_gs_lNumberOfDisplayModes++;
return TRUE;
}
/*
----------------------------------------------------------------------------------------
Description : return number of display modes
----------------------------------------------------------------------------------------
*/
long GLI_fn_lGetNumberOfDisplayModes( void )
{
return GLI_gs_lNumberOfDisplayModes;
}
/*
----------------------------------------------------------------------------------------
Description : return index of current dsplay mode
----------------------------------------------------------------------------------------
*/
long GLI_fn_lGetCurrentDisplayMode( void )
{
return GLI_gs_lCurrentDisplayMode;
}
/*
----------------------------------------------------------------------------------------
Description : return current display mode width and height
----------------------------------------------------------------------------------------
*/
long GLI_fn_lGetDisplayModeParameters( long _lDisplayMode, long *_p_lWidth, long *_p_lHeight )
{
if ( (_lDisplayMode < 0) || (_lDisplayMode >= GLI_gs_lNumberOfDisplayModes) )
return 0;
*_p_lWidth = GLI_gs_a_stDisplayMode[ _lDisplayMode ].lWidth;
*_p_lHeight= GLI_gs_a_stDisplayMode[ _lDisplayMode ].lHeight;
return 1;
}
/*
----------------------------------------------------------------------------------------
Description : return a string with display description (640x480 for example)
----------------------------------------------------------------------------------------
*/
long GLI_fn_lGetDisplayModeDescription( long _lDisplayMode, char *_szDesc )
{
long lWidth, lHeight;
if ( !GLI_fn_lGetDisplayModeParameters( _lDisplayMode, &lWidth, &lHeight ) )
return 0;
sprintf( _szDesc, "%dx%d", lWidth, lHeight );
return 1;
}
/*
----------------------------------------------------------------------------------------
Description : to do a request to change display mode
----------------------------------------------------------------------------------------
*/
void GLI_fn_lRequestNewDisplayMode( long _lDisplayMode )
{
/* check is there is not already a request */
if (GLI_gs_lRequestedDisplayMode != -1)
return;
/* check if mode requested is not equal to current */
if (_lDisplayMode == GLI_gs_lCurrentDisplayMode)
return;
/* make the request */
GLI_gs_lRequestedDisplayMode = _lDisplayMode;
fn_vChangeDeviceResolution();
}
/*
----------------------------------------------------------------------------------------
Description : change really display mode (have to be called by win app
----------------------------------------------------------------------------------------
*/
long GLI_fn_lChangeDisplayMode( void )
{
long lOldDisplayMode;
if (GLI_gs_lRequestedDisplayMode == -1)
return 0;
lOldDisplayMode = GLI_gs_lCurrentDisplayMode;
GLI_gs_lCurrentDisplayMode = GLI_gs_lRequestedDisplayMode;
GLI_vCloseGli();
GLI_xInitGli();
GLI_vComputeTextures();
GLD_fn_bChangeDeviceDisplayMode( 0 );
GAM_fn_vActualizeAllGameViewportSize();
GLI_gs_lRequestedDisplayMode = -1;
return 1;
}
/*
----------------------------------------------------------------------------------------
Description : Readapt display (called by win app when window is windowed and is moved
or resized )
----------------------------------------------------------------------------------------
*/
void GLI_fn_vReadaptDisplay( void )
{
if ( !GLI_DRV_vReadaptDisplay )
return ;
GLI_DRV_vReadaptDisplay();
GLD_bAdjustDeviceToWindow( 0 );
}
/*
=======================================================================================
choose / select
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : select display mode by index
----------------------------------------------------------------------------------------
*/
long GLI_fn_lSelectDisplayModeByIndex( long _lIndex )
{
if ( (_lIndex < 0) || (_lIndex >= GLI_gs_lNumberOfDisplayModes) )
return -1;
GLI_gs_lCurrentDisplayMode = _lIndex;
return GLI_gs_lCurrentDisplayMode;
}
/*
----------------------------------------------------------------------------------------
Description : select display mode by dimension
----------------------------------------------------------------------------------------
*/
long GLI_fn_lSelectDisplayModeByDimension( long _lWidth, long _lHeight, long _lBpp )
{
long lIndex;
for (lIndex = 0; lIndex < GLI_gs_lNumberOfDisplayModes; lIndex++)
{
if (
(_lWidth == GLI_gs_a_stDisplayMode[ lIndex ].lWidth) &&
(_lHeight == GLI_gs_a_stDisplayMode[ lIndex ].lHeight) &&
(_lBpp == GLI_gs_a_stDisplayMode[ lIndex ].lBpp)
)
{
GLI_gs_lCurrentDisplayMode = lIndex;
return lIndex;
}
}
return -1;
}
/*
----------------------------------------------------------------------------------------
Description : choose display mode
----------------------------------------------------------------------------------------
*/
long GLI_fn_lChooseDisplayMode( void )
{
GLI_gs_lCurrentDisplayMode = -1;
/* no resolution available */
if (GLI_gs_lNumberOfDisplayModes == 0)
{
Erm_fn_iMessageBox( "No available resolution", "FatalError", MB_OK | MB_ICONSTOP );
return FALSE;
}
/* try default resolution */
GLI_gs_lCurrentDisplayMode = GLI_fn_lSelectDisplayModeByDimension( GLI_gst_DllInfo.l_InitWidth, GLI_gst_DllInfo.l_InitHeight, GLI_gst_DllInfo.l_InitBpp );
/* try 640x480 resolution */
if (GLI_gs_lCurrentDisplayMode == -1)
{
HDC hDC = GetDC(NULL);
long lBPP = GetDeviceCaps(hDC, PLANES) * GetDeviceCaps(hDC, BITSPIXEL);
ReleaseDC(NULL, hDC);
GLI_gs_lCurrentDisplayMode = GLI_fn_lSelectDisplayModeByDimension( 640, 480, lBPP );
}
/* first resolution */
if (GLI_gs_lCurrentDisplayMode == -1)
GLI_gs_lCurrentDisplayMode = 0;
return TRUE;
}
/*
=======================================================================================
Main functions
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : Ask driver to enumerate available display modes
----------------------------------------------------------------------------------------
*/
void GLI_fn_vLoadDisplayMode( void )
{
GLI_gs_lNumberOfDisplayModes = 0;
#if 0
GLI_gs_lNumberOfDisplayModes = 1;
GLI_gs_a_stDisplayMode[0].lWidth = 640;
GLI_gs_a_stDisplayMode[0].lHeight = 480;
HDC hDC = GetDC(NULL);
GLI_gs_a_stDisplayMode[0].lBpp = GetDeviceCaps(hDC, PLANES) * GetDeviceCaps(hDC, BITSPIXEL);
ReleaseDC(NULL, hDC);
GLI_gs_a_stDisplayMode[0].lFullScreen = 0;
#else
GLI_DRV_fnl_EnumModes( GLI_gst_DllInfo.sz_DriverName, GLI_gst_DllInfo.sz_DeviceName );
#endif
}
/*
=======================================================================================
Brightness
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : change brightness value (_lValue is from 0 to 100)
----------------------------------------------------------------------------------------
*/
void GLI_fn_vSetBrightness( long _lValue )
{
if (_lValue < 0)
_lValue = 0;
else if (_lValue >= 100)
_lValue = 100;
GLI_g_xBrightness = ((float) _lValue) / 100.0f;
}
long GLI_fn_lGetBrightness()
{
return (long)(GLI_g_xBrightness * 100.0f);
}

View File

@@ -0,0 +1,187 @@
/*
=======================================================================================
Name : Fog.c
Description : Fog high level functions
=======================================================================================
*/
/*
Tested with LINT
*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#define MTH_LOW
#include "gli_st.h"
#include "GLI_Defn.h"
#include "light_st.h"
#include "PvObj_st.h"
#include "Liste.h"
#include "vpt3D.h"
#include "camera.h"
#include "light.h"
#include "PRF.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
extern GLI_tdstInternalGlobalValuesFor3dEngine *GLI_BIG_GLOBALS;
/*
=======================================================================================
Globals
=======================================================================================
*/
/* Global variables for a global fog */
tdstFogParams GLI_g_stSaveFog;
ACP_tdxBool GLI_g_bSaveFog;
char GLI_cGlobalFogIsOn = 0;
MTH_tdxReal GLI_xFogNear, GLI_xFogFar, GLI_xFogInfinite;
MTH_tdxReal GLI_xFogBlendNear, GLI_xFogBlendFar;
GEO_tdstColor GLI_stFogColor;
tdstFogParams GLI_ga_stFogTable[ GLI_C_lMaxFog ];
tdstFogParams *GLI_gp_stCurrentFog = GLI_ga_stFogTable;
tdstFogParams *GLI_gp_stLastFog = GLI_ga_stFogTable + GLI_C_lMaxFog;
/*
=======================================================================================
Functions
=======================================================================================
*/
#ifdef __cplusplus
extern "C"
{
#endif
#ifndef RETAIL
/*
----------------------------------------------------------------------------------------
Description : Set the Fog (old function kept for compatibility )
used only by editors
----------------------------------------------------------------------------------------
*/
void GLI_vSetFog(GLI_tdxValue xDepthStart, GLI_tdxValue xDepthEnd, GLI_tdxValue xInfinite, GEO_tdstColor *p_stFogColor)
{
long xDepthStartCOR, xDepthEndCOR ;
float xChange;
/*
* check params
*/
if (xDepthEnd < xDepthStart)
{
xChange = xDepthStart;
xDepthStart = xDepthEnd ;
xDepthEnd = xChange;
}
if (xInfinite < xDepthEnd)
xInfinite = xDepthEnd;
/* This is for correct a bug*/
if ( xInfinite != 0 )
{
xDepthStartCOR = (long)(xDepthStart*64.f / xInfinite) ;
xDepthEndCOR = (long)(xDepthEnd*64.f / xInfinite) ;
xDepthStart = (float)(pow(2.0f,3.0 + (double)(xDepthStartCOR>>2)) / (float)(8 - (xDepthStartCOR & 3)) * GLI_C_xZClippingNear);
xDepthEnd = (float)(pow(2.0f,3.0 + (double)(xDepthEndCOR>>2)) / (float)(8 - (xDepthEndCOR & 3)) * GLI_C_xZClippingNear);
}
GLI_vSetFog2(0.0f, xDepthStart / 4.0f, 255.0f, xDepthEnd / 4.0f, 0.0f,p_stFogColor);
}
#endif
/*
----------------------------------------------------------------------------------------
Description : Set the Fog (old function kept for compatibility )
----------------------------------------------------------------------------------------
*/
void GLI_vSetFog2( GLI_tdxValue xBlendStart, GLI_tdxValue xDepthStart, GLI_tdxValue xBlendEnd, GLI_tdxValue xDepthEnd, GLI_tdxValue xInfinite, GEO_tdstColor *p_stFogColor)
{
tdstFogParams *GLI_ga_stFogStart;
/*
* check params
*/
if (xDepthEnd < xDepthStart)
{
GLI_gp_stCurrentFog->xDepthStart = xDepthEnd;
GLI_gp_stCurrentFog->xDepthEnd = xDepthStart;
}
else
{
GLI_gp_stCurrentFog->xDepthStart = xDepthStart;
GLI_gp_stCurrentFog->xDepthEnd = xDepthEnd;
}
if (xInfinite < GLI_gp_stCurrentFog->xDepthEnd)
GLI_gp_stCurrentFog->xInfinite = xDepthEnd;
else
GLI_gp_stCurrentFog->xInfinite = xInfinite;
if (xBlendStart < 0.0f)
xBlendStart = 0.0f;
else if (xBlendStart > 255.0f)
xBlendStart = 255.0f;
if (xBlendEnd < 0.0f)
xBlendEnd = 0.0f;
else if (xBlendEnd > 255.0f)
xBlendEnd = 255.0f;
GLI_gp_stCurrentFog->xBlendStart = xBlendStart;
GLI_gp_stCurrentFog->xBlendEnd = xBlendEnd;
GLI_gp_stCurrentFog->stColor = *p_stFogColor;
for ( GLI_ga_stFogStart = GLI_ga_stFogTable; GLI_ga_stFogStart < GLI_gp_stCurrentFog; GLI_ga_stFogStart++ )
{
if (memcmp( GLI_gp_stCurrentFog, GLI_ga_stFogStart, sizeof(tdstFogParams) ) == 0)
{
GLI_BIG_GLOBALS->p_stActiveFog = GLI_ga_stFogStart;
return;
}
}
GLI_BIG_GLOBALS->p_stActiveFog = GLI_gp_stCurrentFog++;
if (GLI_gp_stCurrentFog == GLI_gp_stLastFog)
GLI_gp_stCurrentFog = GLI_ga_stFogTable;
}
/*
----------------------------------------------------------------------------------------
Description : Get the Fog (old function kept for compatibility )
----------------------------------------------------------------------------------------
*/
void GLI_vGetFog(GLI_tdxValue *p_xDepthStart, GLI_tdxValue *p_xDepthEnd, GEO_tdstColor *p_stFogColor)
{
*p_xDepthStart = GLI_BIG_GLOBALS->p_stActiveFog->xDepthStart;
*p_xDepthEnd = GLI_BIG_GLOBALS->p_stActiveFog->xDepthEnd;
*p_stFogColor = GLI_BIG_GLOBALS->p_stActiveFog->stColor;
}
/*
----------------------------------------------------------------------------------------
Description : set fog flag to indicate that fog is on
----------------------------------------------------------------------------------------
*/
void GLI_vFogOn(void)
{
GLI_BIG_GLOBALS->xFogIsOn = 1;
}
/*
----------------------------------------------------------------------------------------
Description : set fog flag for no fog
----------------------------------------------------------------------------------------
*/
void GLI_vFogOff(void)
{
GLI_BIG_GLOBALS->p_stLastComputedFog = NULL;
GLI_BIG_GLOBALS->p_stActiveFog = NULL;
GLI_BIG_GLOBALS->xFogIsOn = 0;
}
#ifdef __cplusplus
} /* extern "C" */
#endif

View File

@@ -0,0 +1,303 @@
/*
=======================================================================================
Name : GLIText.c
Author : vincent lhullier Date :12/10/98
Description : function to display text on screen
=======================================================================================
=======================================================================================
!!!! Warning : In retail version this file is empty !!!!
=======================================================================================
=======================================================================================
*/
#ifndef RETAIL
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <string.h>
#include <malloc.h>
#include "DllInter.h"
#include "FIL.h"
#include "TEX.h"
#include "..\..\gld\devvpt.h"
#include "mater_st.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
=======================================================================================
Structures
=======================================================================================
*/
typedef struct tdstLetterPosition_
{
short wX;
short wY;
} tdstLetterPosition;
/*
=======================================================================================
Globals
=======================================================================================
*/
unsigned char *GLI_g_pvPoliceBitmap = NULL;
long GLI_g_lPolicePitch = 0;
//ACP_tdxHandleOfMaterial gh_PoliceMaterial;
GLI_tdstMaterial GLITEXT_st_PoliceMaterial;
ACP_tdxHandleOfTexture GLITEXT_gh_PoliceTexture = NULL;
long GLITEXT_l_ProportionalMode = 1;
long GLITEXT_l_AlreadyInit = 0;
tdstLetterPosition GLI_ga_stLetterPos[ 128 ] =
{
{ -1, -1},{ -1, -1},{ -1, -1},{ -1, -1},{ -1, -1},{ -1, -1},{ -1, -1},{ -1, -1},
{ -1, -1},{ -1, -1},{ -1, -1},{ -1, -1},{ -1, -1},{ -1, -1},{ -1, -1},{ -1, -1},
{ -1, -1},{ -1, -1},{ -1, -1},{ -1, -1},{ -1, -1},{ -1, -1},{ -1, -1},{ -1, -1},
{ -1, -1},{ -1, -1},{ -1, -1},{ -1, -1},{ -1, -1},{ -1, -1},{ -1, -1},{ -1, -1},
{ 320, 14},{ -1, -1},{ -1, -1},{ -1, -1},{ -1, -1},{ 176, 47},{ -1, -1},{ -1, -1},
{ 288, 47},{ 304, 47},{ 96, 47},{ 112, 47},{ 48, 47},{ 128, 47},{ 32, 47},{ 80, 47},
{ 0, 14},{ 16, 14},{ 32, 14},{ 48, 14},{ 64, 14},{ 80, 14},{ 96, 14},{ 112, 14},
{ 128, 14},{ 144, 14},{ 144, 47},{ 64, 47},{ 240, 47},{ -1, -1},{ 256, 47},{ -1, -1},
{ -1, -1},{ 2, 0},{ 18, 0},{ 34, 0},{ 50, 0},{ 66, 0},{ 82, 0},{ 98, 0},
{ 114, 0},{ 130, 0},{ 146, 0},{ 162, 0},{ 178, 0},{ 194, 0},{ 210, 0},{ 226, 0},
{ 242, 0},{ 258, 0},{ 274, 0},{ 290, 0},{ 306, 0},{ 322, 0},{ 338, 0},{ 354, 0},
{ 370, 0},{ 386, 0},{ 402, 0},{ -1, -1},{ -1, -1},{ -1, -1},{ -1, -1},{ 320, 47},
{ -1, -1},{ 0, 31},{ 16, 31},{ 32, 31},{ 48, 31},{ 64, 31},{ 80, 31},{ 96, 31},
{ 112, 31},{ 128, 31},{ 144, 31},{ 160, 31},{ 176, 31},{ 192, 31},{ 208, 31},{ 224, 31},
{ 240, 31},{ 256, 31},{ 272, 31},{ 288, 31},{ 304, 31},{ 320, 31},{ 336, 31},{ 352, 31},
{ 368, 31},{ 384, 31},{ 400, 31},{ -1, -1},{ -1, -1},{ -1, -1},{ -1, -1},{ -1, -1}
};
/*
=======================================================================================
Function
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : Load Police bitmap
----------------------------------------------------------------------------------------
*/
void GLI_fn_vLoadPolice( void )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
struct FIL_tdstGF_ stHeader;
unsigned char *p_ucTgaBitmap;
unsigned short *p_uwPoliceBitmap, *p_uwLast;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
* load TGA file
*/
FIL_fn_vTGALoadFromFileWithInvertPicture( "", "polices.tga", &stHeader );
if (stHeader.stFileHeader.ucBpp == 0)
return;
/*
* convert data
*/
MMG_fn_vAddMemoryInfo(MMG_C_lTypeGLI , MMG_C_lSubTypePolice , NULL);
GEO_M_CPAMalloc(GLI_g_pvPoliceBitmap,unsigned char *,stHeader.stFileHeader.ulWidth * stHeader.stFileHeader.ulHeight * 2, E_uwGEONotEnoughtMemory );
p_ucTgaBitmap = stHeader.p_ucBitMap;
p_uwPoliceBitmap = (unsigned short *) GLI_g_pvPoliceBitmap;
p_uwLast = p_uwPoliceBitmap + stHeader.stFileHeader.ulWidth * stHeader.stFileHeader.ulHeight;
GLI_g_lPolicePitch = stHeader.stFileHeader.ulWidth * 2;
for ( ; p_uwPoliceBitmap < p_uwLast ; p_uwPoliceBitmap++, p_ucTgaBitmap += 3)
{
*(p_uwPoliceBitmap) = (((unsigned short)(*(p_ucTgaBitmap) & 0xF8) )<<8 ) + (((unsigned short)(*(p_ucTgaBitmap + 1) & 0xF8) )<<3 ) + (((unsigned short)(*(p_ucTgaBitmap + 2) & 0xF8) )>>3);
}
FIL_fn_vTGAFree( &stHeader.p_ucBitMap );
}
/*
----------------------------------------------------------------------------------------
Description : init text data
----------------------------------------------------------------------------------------
*/
void GLITEXT_fnv_Init( void )
{
if (GLITEXT_l_AlreadyInit)
return;
GLITEXT_l_AlreadyInit = 1;
if (GLI_g_pvPoliceBitmap == NULL)
GLI_fn_vLoadPolice();
/*
GLI_xLoadTexture( &GLITEXT_gh_PoliceTexture, NULL, "polices.tga", 0, 0);
if ( GLITEXT_gh_PoliceTexture )
TEX_vSetTextureQualityLevel(GLITEXT_gh_PoliceTexture, (char)TEX_C_QHIGH);
else
*/
GLITEXT_l_ProportionalMode = 0;
//GLI_xSetMaterialTexture( &GLITEXT_st_PoliceMaterial, GLITEXT_gh_PoliceTexture);
}
/*
----------------------------------------------------------------------------------------
Description : init text data
----------------------------------------------------------------------------------------
*/
void GLITEXT_fnv_Close( void )
{
GLITEXT_l_AlreadyInit = 0;
GLITEXT_gh_PoliceTexture = NULL;
}
/*
----------------------------------------------------------------------------------------
Description : write letter bitmap into backbuffer
----------------------------------------------------------------------------------------
*/
void GLI_fn_vWriteLetterInBackBuffer(long X, long Y, long l, long h, unsigned char *p_ucSrc, long SrcPitch , void *_p_cBackBuffer, long _lPitch )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long *p_sourceptr , *p_sourceptrLast , *p_destptr ,lYCounterLocal;
short *p_Src;
unsigned long *p_ulDest;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
//chbani platange si on depasse la taille du viewport
if( (Y+h)>480 )
Y =480-h-1;
if( (X+l)>640 )
X =640-l-1;
p_Src = (unsigned short *)p_ucSrc;
_lPitch = _lPitch/4;
p_ulDest = (unsigned long *) _p_cBackBuffer;
for (lYCounterLocal = 0; lYCounterLocal < h ; lYCounterLocal++)
{
p_destptr = (p_ulDest) + (X>>1) + _lPitch * (Y + lYCounterLocal);
p_sourceptr = ((unsigned long *)p_Src + lYCounterLocal * (SrcPitch >>2)) ;
p_sourceptrLast = p_sourceptr + (l>>1);
for (;p_sourceptr < p_sourceptrLast ;p_sourceptr ++,p_destptr ++)
*p_destptr = *p_sourceptr ;
}
}
/*
----------------------------------------------------------------------------------------
Description : display a string in screen
----------------------------------------------------------------------------------------
*/
void GLI_fn_vDisplayPolices(unsigned char *d_ucFileName, long lX, long lY, void *_p_cBuffer, long _lPitch )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long lPosInTexture;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
if (GLI_g_pvPoliceBitmap == NULL)
return;
while ((*d_ucFileName) != 0)
{
if ( (*d_ucFileName < 128) && (GLI_ga_stLetterPos[*d_ucFileName].wY != -1) )
{
lPosInTexture = ((long) GLI_ga_stLetterPos[*d_ucFileName].wY) * GLI_g_lPolicePitch + ((long) GLI_ga_stLetterPos[*d_ucFileName].wX);
GLI_fn_vWriteLetterInBackBuffer( lX, lY, 8, 16, GLI_g_pvPoliceBitmap + lPosInTexture, GLI_g_lPolicePitch, _p_cBuffer, _lPitch);
}
d_ucFileName++;
lX+=8;
}
}
/*
----------------------------------------------------------------------------------------
Description : new function to display a string in screen
----------------------------------------------------------------------------------------
*/
extern GLD_tdpstDevice g_pstGLDDevices[ C_NB_MAX_DEVICES ];
extern void GLI_vDraw2DSpriteWithUV( GLD_tdstViewportAttributes *p_stVpt, MTH_tdxReal xXMin, MTH_tdxReal xXMax, MTH_tdxReal xYMin, MTH_tdxReal xYMax, MTH_tdxReal xUMin, MTH_tdxReal xUMax, MTH_tdxReal xVMin, MTH_tdxReal xVMax, ACP_tdxHandleOfMaterial hMaterial );
void GLITEXT_DisplayString( unsigned char *_sz_String, long lX, long lY )
{
float x, dx, y1, y2;
float u, v;
GLD_tdstViewportAttributes *pst_VptAttrib;
pst_VptAttrib = &g_pstGLDDevices[ 0 ]->pstViewports[ 0 ]->stViewAttrib;
if (pst_VptAttrib == NULL)
return;
y1 = ( (float) lY / 480.0f) * pst_VptAttrib->dwHeight;
y2 = y1 + ( (16.0f / 480.0f) * pst_VptAttrib->dwHeight );
x = ( (float) lX / 640.0f) * pst_VptAttrib->dwWidth;
dx = (8.0f / 640.0f) * pst_VptAttrib->dwWidth;
while ( ( *_sz_String ) != 0)
{
if ( (*_sz_String < 128) && (GLI_ga_stLetterPos[*_sz_String].wY != -1) )
{
u = ((float) (GLI_ga_stLetterPos[*_sz_String].wX >> 1) + 1.0f) / 256.0f;
v = 1.0f - (((float) (GLI_ga_stLetterPos[*_sz_String].wY ) +1.0f) / 64.0f);
GLI_vDraw2DSpriteWithUV( pst_VptAttrib, x, x + dx, y1, y2, u, u + 0.03125f, v, v - 0.25f, &GLITEXT_st_PoliceMaterial );
}
_sz_String++;
x += dx;
}
}
/*
----------------------------------------------------------------------------------------
Description : Main function -> lock device, display police in virtual screen and
unlock buffer
----------------------------------------------------------------------------------------
*/
void GLI_vDisplayPolices(unsigned char *d_ucFileName, long lX, long lY)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long lPitch;
void *p_cBackBuffer;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
if (GLITEXT_l_ProportionalMode)
{
if (GLITEXT_gh_PoliceTexture)
GLITEXT_DisplayString( d_ucFileName, lX, lY );
}
else
{
if ( GLI_DRV_bLockDevice( &p_cBackBuffer, &lPitch ) )
{
GLI_fn_vDisplayPolices( d_ucFileName, lX, lY, p_cBackBuffer, lPitch );
GLI_DRV_bUnlockDevice();
}
}
}
/*
----------------------------------------------------------------------------------------
Description : access function to display mode var
----------------------------------------------------------------------------------------
*/
void GLITEXT_fnv_SetProportionalMode( long _l_Mode )
{
GLITEXT_l_ProportionalMode = _l_Mode;
}
long GLITEXT_fnl_GetProportionalMode( void )
{
return (GLITEXT_l_ProportionalMode);
}
#endif

View File

@@ -0,0 +1,706 @@
/*
=======================================================================================
Name : GLI_Menu.c
Author : vincent lhullier Date :10/03/99
Description : function to display gli menu
=======================================================================================
=======================================================================================
!!!! Warning : In retail version this file is empty !!!!
=======================================================================================
=======================================================================================
*/
#if !defined(RETAIL) && !defined(PRESS_DEMO)
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <string.h>
#include <malloc.h>
#include "GLI.h"
#include "DllInter.h"
#include "DispMode.h"
#include "GLIText.h"
#include "mater_st.h"
#include "Tex.h"
#include "Texture.h"
#include "TexArray.h"
#include "FIL.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
=======================================================================================
Macro definition
=======================================================================================
*/
#ifdef EXGEOM_APPLI
#define M_bKeyJustPressed(code) ( KBD_fnb_IsKeyJustPressed( code ) )
#define M_bKeyPressed(code) ( KBD_fnb_IsKeyPressed( code ) )
#define C_GliMenu_Activate VK_DELETE
#define C_GliMenu_Next VK_END
#define C_GliMenu_Prev VK_HOME
#define C_GliMenu_Select VK_NEXT
#define C_GliMenu_Zoom VK_PRIOR
#define C_GliMenu_Goto VK_INSERT
#else
#include "ipt.h"
#include "gam/structur/input_s.h"
#define M_bKeyPressed( code ) ( IPT_fn_bIsValidated ( code ) == IPT_C_TRUE )
#define M_bKeyJustPressed( code ) ( IPT_fn_bIsJustValidated( code ) == IPT_C_TRUE )
#define C_GliMenu_Activate (g_st_3DOS_EntryActions.hGliMenu_Activate)
#define C_GliMenu_Next (g_st_3DOS_EntryActions.hGliMenu_Next)
#define C_GliMenu_Prev (g_st_3DOS_EntryActions.hGliMenu_Prev)
#define C_GliMenu_Select (g_st_3DOS_EntryActions.hGliMenu_Select)
#define C_GliMenu_Zoom (g_st_3DOS_EntryActions.hGliMenu_Zoom)
#define C_GliMenu_Goto (g_st_3DOS_EntryActions.hGliMenu_Goto)
#endif
/*
=======================================================================================
Structures
=======================================================================================
*/
typedef struct GLI_tdst_Menu_
{
char cDisplay;
char a_szString[1024][50];
long alValue[ 1024 ];
long lNumberOfString;
long lMaxString;
long lFirstStringIndex;
long lCurrent;
long lWidth;
long lHeight;
void (* pfnv_Validate)(void);
void (* pfnv_DisplayAdditionalString)(void);
void (* pfnv_DisplayAdditional)(void);
void *p_cBackBuffer;
long lPitch;
} GLI_tdst_Menu;
/*
=======================================================================================
Globals
=======================================================================================
*/
static GLI_tdst_Menu GLI_gsst_Menu;
static char GLI_gsasz_MenuString[ 32 ][ 50 ];
static char GLI_gc_MenuInit = 0;
unsigned long GLIMENU_aul_Palette[ 7 ] = { 0x00000000, 0x00FFFFFF, 0x00D7AF4B, 0x005F3B0F, 0x00472B0B, 0x00C38B2F, 0x002F0F07};
unsigned short GLIMENU_auw_Palette[ 7 ] = { 0x0000, 0xFFFF, 0xD569, 0x59C1, 0x4141, 0xC445, 0x2860};
unsigned char GLIMENU_aauc_Letter[ 26 ][ 40 ] =
{
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0},
{ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0},
{ 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0},
{ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0},
{ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0},
{ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0},
{ 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0}
};
unsigned char GLIMENU_aauc_Digit[ 10 ][ 40 ] =
{
{ 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0},
{ 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0},
{ 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0},
{ 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0},
{ 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0},
{ 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0},
{ 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0},
{ 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0}
};
unsigned char GLIMENU_aauc_Cursor[ 9 ][ 10 ] =
{
{ 2, 3, 4, 3, 5, 0, 0, 0, 0, 0},
{ 2, 3, 4, 3, 5, 5, 0, 0, 0, 0},
{ 2, 3, 4, 4, 3, 3, 5, 0, 0, 0},
{ 2, 3, 4, 4, 4, 4, 3, 5, 5, 0},
{ 2, 3, 4, 4, 4, 4, 4, 3, 3, 5},
{ 2, 3, 4, 4, 4, 4, 4, 3, 3, 5},
{ 2, 3, 4, 4, 4, 4, 3, 5, 5, 0},
{ 2, 3, 4, 4, 3, 3, 5, 0, 0, 0},
{ 2, 3, 4, 3, 5, 5, 0, 0, 0, 0}
};
extern ACP_tdxHandleOfMaterial gs_hDefaultMaterial;
extern void GLI_vDraw2DSprite( GLD_tdstViewportAttributes *p_stVpt ,MTH_tdxReal xXMin,MTH_tdxReal xXMax,MTH_tdxReal xYMin,MTH_tdxReal xYMax,ACP_tdxHandleOfMaterial hMaterial);
GLI_tdstTexture *GLIMENU_gap_stTexturesCurrentlyDisplayed[ C_lMaxNumberOfTexture ];
int g_iTexturesCurrentlyDisplayedCounter = 0;
float fSizeFactorForTextureDisplay = 1.0f;
/*
=======================================================================================
Functions
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : display a string
----------------------------------------------------------------------------------------
*/
static void GLI_fnv_Menu_DisplayString( char *_sz_String, long _lX, long _lY )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long lX2, lY2;
unsigned short *p_uwStart, *p_uwCurrent;
char *pc_Char;
unsigned char *puc_Copy;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
pc_Char = _sz_String;
p_uwStart = (unsigned short *) GLI_gsst_Menu.p_cBackBuffer + _lY * GLI_gsst_Menu.lPitch + _lX;
while( *pc_Char != 0 )
{
p_uwCurrent = p_uwStart;
if ( (tolower( *pc_Char ) >= 'a') && (tolower( *pc_Char ) <= 'z') )
puc_Copy = GLIMENU_aauc_Letter[ tolower( *pc_Char ) - 'a' ];
else if ( (*pc_Char >= '0') && (*pc_Char <= '9') )
puc_Copy = GLIMENU_aauc_Digit[*pc_Char - '0' ];
else
{
p_uwStart += 6;
pc_Char++;
continue;
}
pc_Char++;
for (lY2 = 0; lY2 < 8; lY2 ++ )
{
for (lX2 = 0; lX2 < 5; lX2++)
{
*p_uwCurrent++ = GLIMENU_auw_Palette[ *puc_Copy++ ];
}
p_uwCurrent += GLI_gsst_Menu.lPitch - 5;
}
p_uwStart += 6;
}
}
/*
----------------------------------------------------------------------------------------
Description : compute size needed to display menu
----------------------------------------------------------------------------------------
*/
static void GLI_fnv_Menu_ComputeSize( void )
{
long i;
long lWidth;
GLI_gsst_Menu.lWidth = 0;
for (i = 0; i < GLI_gsst_Menu.lNumberOfString; i++ )
{
lWidth = strlen( GLI_gsst_Menu.a_szString[i] );
if (lWidth > GLI_gsst_Menu.lWidth)
GLI_gsst_Menu.lWidth = lWidth;
}
GLI_gsst_Menu.lWidth = GLI_gsst_Menu.lWidth * 6 + 15;
GLI_gsst_Menu.lHeight = GLI_gsst_Menu.lMaxString * 9 + 10;
}
/*
----------------------------------------------------------------------------------------
Description : resolution menu
----------------------------------------------------------------------------------------
*/
static void GLI_fnv_Menu_ResolutionValidate( void )
{
GLI_gsst_Menu.cDisplay = 0;
GLI_fn_lRequestNewDisplayMode( GLI_gsst_Menu.lCurrent );
}
static void GLI_fnv_Menu_Resolution( void )
{
long lMode;
for ( lMode = 0; lMode < GLI_gs_lNumberOfDisplayModes && lMode < 1024; lMode++ )
{
GLI_fn_lGetDisplayModeDescription( lMode, GLI_gsst_Menu.a_szString[lMode] );
}
GLI_gsst_Menu.lNumberOfString = lMode;
GLI_gsst_Menu.lMaxString = (lMode < 5) ? GLI_gs_lNumberOfDisplayModes : 5;
GLI_gsst_Menu.lCurrent = GLI_gs_lCurrentDisplayMode;
GLI_fnv_Menu_ComputeSize();
GLI_gsst_Menu.lFirstStringIndex = GLI_gsst_Menu.lCurrent;
if (GLI_gsst_Menu.lFirstStringIndex + GLI_gsst_Menu.lMaxString > GLI_gsst_Menu.lNumberOfString )
GLI_gsst_Menu.lFirstStringIndex = GLI_gsst_Menu.lNumberOfString - GLI_gsst_Menu.lMaxString;
GLI_gsst_Menu.pfnv_Validate = GLI_fnv_Menu_ResolutionValidate;
GLI_gsst_Menu.pfnv_DisplayAdditionalString = NULL;
GLI_gsst_Menu.pfnv_DisplayAdditional = NULL;
}
/*
----------------------------------------------------------------------------------------
Function for changing texture sample display size
----------------------------------------------------------------------------------------
*/
void fn_vCheckForTextureDisplaySize()
{
/* Key 'PageUp' to change texture size for displayed sample */
if( M_bKeyJustPressed( C_GliMenu_Zoom ) )
{
if( fSizeFactorForTextureDisplay > 3.9f )
fSizeFactorForTextureDisplay = 0.5f;
else
fSizeFactorForTextureDisplay *= 2.0f;
}
}
/*
----------------------------------------------------------------------------------------
Description : init display text menu
----------------------------------------------------------------------------------------
*/
static void GLI_fnv_Menu_TextureValidate( void )
{
GLI_gsst_Menu.cDisplay = 0;
}
static void GLI_fnv_Menu_TextureAdditionalString( void )
{
long lX, lY;
long lTexture;
GLI_tdstTexture *p_stTexture;
char szText[100];
fn_vCheckForTextureDisplaySize();
lTexture = GLI_gsst_Menu.alValue[ GLI_gsst_Menu.lCurrent ];
p_stTexture = gs_aDEFTableOfTextureAlreadyRead[ lTexture ];
sprintf(
szText,
"in memory %dx%d original %dx%d sample %dx%d",
p_stTexture->lWidth, p_stTexture->lHeight,
p_stTexture->lRealWidth, p_stTexture->lRealHeight,
(unsigned long)(p_stTexture->lWidth*fSizeFactorForTextureDisplay),
(unsigned long)(p_stTexture->lHeight*fSizeFactorForTextureDisplay) );
lX = 20 + GLI_gsst_Menu.lWidth;
lY = 10;
GLI_fnv_Menu_DisplayString( szText, lX, lY );
}
static void GLI_fnv_Menu_TextureAdditional( void )
{
long lX, lY;
long lTexture;
GLI_tdstTexture *p_stTexture;
lTexture = GLI_gsst_Menu.alValue[ GLI_gsst_Menu.lCurrent ];
p_stTexture = gs_aDEFTableOfTextureAlreadyRead[ lTexture ];
lX = 20 + GLI_gsst_Menu.lWidth;
lY = 20;
gs_hDefaultMaterial->stAmbient.xR = gs_hDefaultMaterial->stAmbient.xG = gs_hDefaultMaterial->stAmbient.xB = 1.0f;
gs_hDefaultMaterial->p_stTexture = p_stTexture;
GLI_vDraw2DSprite( NULL, (float) lX + p_stTexture->lWidth*fSizeFactorForTextureDisplay, (float) lX, (float) lY, (float) lY + p_stTexture->lHeight*fSizeFactorForTextureDisplay,gs_hDefaultMaterial);
gs_hDefaultMaterial->p_stTexture = NULL;
}
static void GLI_fnv_Menu_Texture( void )
{
long lTextureCounter;
long lIndex;
char *p_cTextureName;
for (lIndex = 0, lTextureCounter = 0 ; lTextureCounter < GLI_C_lNBMaxOfTextures ; lTextureCounter ++ )
{
if ( (gs_aDEFTableOfTextureMemoryChannels[lTextureCounter] != GLI_TEXIsUnallocated) && (gs_aDEFTableOfTextureAlreadyRead[lTextureCounter] != NULL))
{
p_cTextureName = 1 + strrchr( gs_aDEFTableOfTextureAlreadyRead [lTextureCounter]->a255_cFileName, '\\' );
if( p_cTextureName == 1+(char*)NULL )
p_cTextureName = gs_aDEFTableOfTextureAlreadyRead [lTextureCounter]->a255_cFileName;
sprintf( GLI_gsst_Menu.a_szString[ lIndex ], " %i %s", lTextureCounter, p_cTextureName );
GLI_gsst_Menu.alValue[ lIndex ] = lTextureCounter;
lIndex++;
}
}
GLI_gsst_Menu.lNumberOfString = lIndex;
GLI_gsst_Menu.lMaxString = 20;
GLI_gsst_Menu.lCurrent = 0;
GLI_gsst_Menu.lFirstStringIndex = 0;
GLI_fnv_Menu_ComputeSize();
GLI_gsst_Menu.pfnv_Validate = GLI_fnv_Menu_TextureValidate;
GLI_gsst_Menu.pfnv_DisplayAdditionalString = GLI_fnv_Menu_TextureAdditionalString;
GLI_gsst_Menu.pfnv_DisplayAdditional = GLI_fnv_Menu_TextureAdditional;
}
/* * * * * * * Menu for currently displayed textures * * * * * * */
static void GLI_fnv_Menu_DisplayedTextureAdditionalString( void )
{
long lX, lY;
GLI_tdstTexture *p_stTexture;
char szText[100];
p_stTexture = (GLI_tdstTexture *)GLI_gsst_Menu.alValue[ GLI_gsst_Menu.lCurrent ];
fn_vCheckForTextureDisplaySize();
sprintf(
szText,
"in memory %dx%d original %dx%d sample %dx%d",
p_stTexture->lWidth, p_stTexture->lHeight,
p_stTexture->lRealWidth, p_stTexture->lRealHeight,
(unsigned long)(p_stTexture->lWidth*fSizeFactorForTextureDisplay),
(unsigned long)(p_stTexture->lHeight*fSizeFactorForTextureDisplay) );
lX = 20 + GLI_gsst_Menu.lWidth;
lY = 10;
GLI_fnv_Menu_DisplayString( szText, lX, lY );
}
static void GLI_fnv_Menu_DisplayedTextureAdditional( void )
{
long lX, lY;
GLI_tdstTexture *p_stTexture;
p_stTexture = (GLI_tdstTexture *)GLI_gsst_Menu.alValue[ GLI_gsst_Menu.lCurrent ];
lX = 20 + GLI_gsst_Menu.lWidth;
lY = 20;
gs_hDefaultMaterial->stAmbient.xR = gs_hDefaultMaterial->stAmbient.xG = gs_hDefaultMaterial->stAmbient.xB = 1.0f;
gs_hDefaultMaterial->p_stTexture = p_stTexture;
GLI_vDraw2DSprite( NULL, (float) lX + p_stTexture->lWidth*fSizeFactorForTextureDisplay, (float) lX, (float) lY, (float) lY + p_stTexture->lHeight*fSizeFactorForTextureDisplay,gs_hDefaultMaterial);
gs_hDefaultMaterial->p_stTexture = NULL;
}
static void GLI_fnv_Menu_DisplayedTexture( void )
{
long lTextureCounter;
long lIndex;
char *p_cTextureName;
for (lIndex = 0, lTextureCounter = 0 ; lTextureCounter < g_iTexturesCurrentlyDisplayedCounter ; lTextureCounter ++ )
{
if ( GLIMENU_gap_stTexturesCurrentlyDisplayed[lTextureCounter] != NULL )
{
p_cTextureName = 1+strrchr( GLIMENU_gap_stTexturesCurrentlyDisplayed [lTextureCounter]->a255_cFileName, '\\' );
if( p_cTextureName == 1+(char *)NULL )
p_cTextureName = GLIMENU_gap_stTexturesCurrentlyDisplayed [lTextureCounter]->a255_cFileName;
sprintf( GLI_gsst_Menu.a_szString[ lIndex ], " %i %s", lTextureCounter, p_cTextureName );
GLI_gsst_Menu.alValue[ lIndex ] = (long)GLIMENU_gap_stTexturesCurrentlyDisplayed[lTextureCounter];
lIndex++;
}
}
GLI_gsst_Menu.lNumberOfString = lIndex;
GLI_gsst_Menu.lMaxString = 20;
GLI_gsst_Menu.lCurrent = 0;
GLI_gsst_Menu.lFirstStringIndex = 0;
GLI_fnv_Menu_ComputeSize();
GLI_gsst_Menu.pfnv_Validate = GLI_fnv_Menu_TextureValidate;
GLI_gsst_Menu.pfnv_DisplayAdditionalString = GLI_fnv_Menu_DisplayedTextureAdditionalString;
GLI_gsst_Menu.pfnv_DisplayAdditional = GLI_fnv_Menu_DisplayedTextureAdditional;
}
void GLI_fn_vAddDisplayedVisualMaterial( ACP_tdxHandleOfMaterial _hVisualMaterial )
{
GLIMENU_gap_stTexturesCurrentlyDisplayed[g_iTexturesCurrentlyDisplayedCounter] = _hVisualMaterial -> p_stTexture;
if ( g_iTexturesCurrentlyDisplayedCounter < C_lMaxNumberOfTexture - 1 )
g_iTexturesCurrentlyDisplayedCounter ++ ;
}
/*
----------------------------------------------------------------------------------------
Description : init start menu
----------------------------------------------------------------------------------------
*/
static void GLI_fnv_Menu_StartValidate( void )
{
switch( GLI_gsst_Menu.lCurrent )
{
case 0: GLI_fnv_Menu_Resolution(); break;
case 1: GLI_fnv_Menu_Texture(); break;
case 2: GLI_fnv_Menu_DisplayedTexture(); break;
}
}
static void GLI_fnv_Menu_Start( void )
{
strcpy( GLI_gsst_Menu.a_szString[0], "resolution" );
strcpy( GLI_gsst_Menu.a_szString[1], "textures" );
strcpy( GLI_gsst_Menu.a_szString[2], "displayed textures" );
GLI_gsst_Menu.lNumberOfString = 3;
GLI_gsst_Menu.lMaxString = 3;
GLI_gsst_Menu.lCurrent = 0;
GLI_gsst_Menu.lFirstStringIndex = 0;
GLI_fnv_Menu_ComputeSize();
GLI_gsst_Menu.pfnv_Validate = GLI_fnv_Menu_StartValidate;
GLI_gsst_Menu.pfnv_DisplayAdditionalString = NULL;
GLI_gsst_Menu.pfnv_DisplayAdditional = NULL;
}
/*
----------------------------------------------------------------------------------------
Description : Main function -> lock device, display police in virtual screen and
unlock buffer
----------------------------------------------------------------------------------------
*/
void GLI_fnv_DisplayMenuWindow(long _lX, long _lY )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long lX, lY, lX2, lY2;
unsigned short *p_uwStart, *p_uwEnd;
long lString;
unsigned char *puc_Copy;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
if ( !GLI_DRV_bLockDevice( &GLI_gsst_Menu.p_cBackBuffer, &GLI_gsst_Menu.lPitch ) )
return;
GLI_gsst_Menu.lPitch >>= 1;
p_uwEnd = p_uwStart = (unsigned short *) GLI_gsst_Menu.p_cBackBuffer;
p_uwStart += _lY * GLI_gsst_Menu.lPitch + _lX;
*p_uwStart++ = 0;
*p_uwStart++ = GLIMENU_auw_Palette[ GLIMENU_aauc_Cursor[0][0] ];
*p_uwStart++ = GLIMENU_auw_Palette[ GLIMENU_aauc_Cursor[0][0] ];
*p_uwStart++ = GLIMENU_auw_Palette[ GLIMENU_aauc_Cursor[0][0] ];
*p_uwStart++ = 0;
lX = GLI_gsst_Menu.lWidth - 5;
while (lX)
{
*p_uwStart++ = 0;
lX--;
}
p_uwStart += GLI_gsst_Menu.lPitch - GLI_gsst_Menu.lWidth;
p_uwEnd += (_lY + GLI_gsst_Menu.lHeight - 2) * GLI_gsst_Menu.lPitch + ( _lX + GLI_gsst_Menu.lWidth - 1);
while ( p_uwStart < p_uwEnd )
{
for ( lX2 = 0; lX2 < 5; lX2 ++)
*p_uwStart++ = GLIMENU_auw_Palette[ GLIMENU_aauc_Cursor[ 0 ][ lX2 ] ];
lX = GLI_gsst_Menu.lWidth - 5;
while (lX)
{
*p_uwStart++ = 0;
lX--;
}
p_uwStart += GLI_gsst_Menu.lPitch - GLI_gsst_Menu.lWidth;
}
*p_uwStart++ = 0;
*p_uwStart++ = GLIMENU_auw_Palette[ GLIMENU_aauc_Cursor[0][0] ];
*p_uwStart++ = GLIMENU_auw_Palette[ GLIMENU_aauc_Cursor[0][0] ];
*p_uwStart++ = GLIMENU_auw_Palette[ GLIMENU_aauc_Cursor[0][0] ];
*p_uwStart++ = 0;
lX = GLI_gsst_Menu.lWidth - 5;
while (lX)
{
*p_uwStart++ = 0;
lX--;
}
lX = _lX + 10;
lY = _lY + 5;
for ( lString = GLI_gsst_Menu.lFirstStringIndex; lString < GLI_gsst_Menu.lFirstStringIndex + GLI_gsst_Menu.lMaxString; lString++ )
{
if (lString >= GLI_gsst_Menu.lNumberOfString )
break;
if ( lString == GLI_gsst_Menu.lCurrent )
{
puc_Copy = GLIMENU_aauc_Cursor[ 1 ];
p_uwStart = (unsigned short *) GLI_gsst_Menu.p_cBackBuffer + lY * GLI_gsst_Menu.lPitch + _lX;
for ( lY2 = 0; lY2 < 8; lY2 ++)
{
for ( lX2 = 0; lX2 < 10; lX2++)
{
*p_uwStart++ = GLIMENU_auw_Palette[ *puc_Copy++ ];
}
p_uwStart += GLI_gsst_Menu.lPitch - 10;
}
}
GLI_fnv_Menu_DisplayString( GLI_gsst_Menu.a_szString[ lString ], lX, lY );
lY += 9;
}
if (GLI_gsst_Menu.pfnv_DisplayAdditionalString)
GLI_gsst_Menu.pfnv_DisplayAdditionalString();
GLI_DRV_bUnlockDevice();
if (GLI_gsst_Menu.pfnv_DisplayAdditional)
GLI_gsst_Menu.pfnv_DisplayAdditional();
GLI_xSendListToViewport(NULL);
}
/*
----------------------------------------------------------------------------------------
Description : Manage with GLI_Menu
----------------------------------------------------------------------------------------
*/
void GLI_fnv_ManageMenu( void )
{
static long lMaxCountInit = 7;
static long lCount;
static long lCountInit;
if ( !GLI_gc_MenuInit )
{
memset( &GLI_gsst_Menu, 0, sizeof( GLI_tdst_Menu ) );
GLI_gc_MenuInit = 1;
}
if ( M_bKeyJustPressed( C_GliMenu_Activate ) )
{
if ( !GLI_gsst_Menu.cDisplay )
GLI_fnv_Menu_Start();
GLI_gsst_Menu.cDisplay = ~GLI_gsst_Menu.cDisplay;
}
if ( !GLI_gsst_Menu.cDisplay )
{
g_iTexturesCurrentlyDisplayedCounter = 0;
return;
}
if (M_bKeyPressed( C_GliMenu_Next ) )
{
if (M_bKeyJustPressed( C_GliMenu_Next ) )
{
lCountInit = lMaxCountInit;
lCount = 0;
}
else
{
lCount--;
}
if (lCount == 0)
{
if (GLI_gsst_Menu.lCurrent + 1 < GLI_gsst_Menu.lNumberOfString )
{
GLI_gsst_Menu.lCurrent += 1;
if (GLI_gsst_Menu.lCurrent - GLI_gsst_Menu.lFirstStringIndex >= GLI_gsst_Menu.lMaxString )
{
GLI_gsst_Menu.lFirstStringIndex++;
}
}
if (lCountInit > 1)
lCountInit--;
lCount = lCountInit;
}
}
else if (M_bKeyPressed( C_GliMenu_Prev ) )
{
if (M_bKeyJustPressed( C_GliMenu_Prev ) )
{
lCountInit = lMaxCountInit;
lCount = 0;
}
else
{
lCount--;
}
if (lCount == 0)
{
if (GLI_gsst_Menu.lCurrent > 0)
{
GLI_gsst_Menu.lCurrent -= 1;
if (GLI_gsst_Menu.lCurrent < GLI_gsst_Menu.lFirstStringIndex)
GLI_gsst_Menu.lFirstStringIndex--;
}
if (lCountInit > 1 )
lCountInit--;
lCount = lCountInit;
}
}
else if( M_bKeyJustPressed( C_GliMenu_Goto ) )
{
if( GLI_gsst_Menu.lCurrent > 0 )
{
GLI_gsst_Menu.lCurrent = 0;
GLI_gsst_Menu.lFirstStringIndex = 0;
}
else
{
GLI_gsst_Menu.lCurrent = GLI_gsst_Menu.lNumberOfString - 1;
GLI_gsst_Menu.lFirstStringIndex = GLI_gsst_Menu.lNumberOfString - GLI_gsst_Menu.lMaxString;
if( GLI_gsst_Menu.lFirstStringIndex < 0 )
GLI_gsst_Menu.lFirstStringIndex = 0;
}
}
if (M_bKeyJustPressed( C_GliMenu_Select ) )
{
if (GLI_gsst_Menu.pfnv_Validate)
GLI_gsst_Menu.pfnv_Validate();
}
GLI_fnv_DisplayMenuWindow( 10, 10 );
g_iTexturesCurrentlyDisplayedCounter = 0;
}
#endif /* RETAIL && PRESS_DEMO */

View File

@@ -0,0 +1,142 @@
/*
=======================================================================================
Name : GLI_UTIL.c
Author : vincent lhullier Date :03/09/98
Description : Utility for GLI (not used in retail version)
=======================================================================================
*/
#ifndef RETAIL
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <windows.h>
#include "TMP.h"
#include "GLD.h"
#include "GEO.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
=======================================================================================
Extern (globals and function prototypes)
=======================================================================================
*/
HINSTANCE fn_hGetApplicationInstance(void);
/*
=======================================================================================
Globals
=======================================================================================
*/
/*
* for dialog
*/
static DLGTEMPLATE gs_a_stDialogTemplate[20];
/*
=======================================================================================
Functions for dialog
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : copy char string into multibyte string
----------------------------------------------------------------------------------------
*/
static void CopyToWideChar( WCHAR** pstrOut, LPTSTR strIn )
{
long lLength = lstrlen( strIn );
WCHAR* strOut = *pstrOut;
lLength = MultiByteToWideChar( CP_ACP, 0, strIn, lLength, strOut, lLength );
strOut[lLength++] = L'\0'; /* Add the null terminator*/
*pstrOut += lLength;
}
/*
----------------------------------------------------------------------------------------
Description : add a dialog item in a Dialogtemplate
----------------------------------------------------------------------------------------
*/
static void AddDialogControl( WORD** pp, DWORD dwStyle, SHORT x, SHORT y, SHORT cx, SHORT cy, WORD id, LPTSTR strClassName, LPTSTR strTitle )
{
/* DWORD align the current ptr*/
DLGITEMTEMPLATE* p = (DLGITEMTEMPLATE*)(((((ULONG)(*pp))+3)>>2)<<2);
p->style = dwStyle | WS_CHILD | WS_VISIBLE;
p->dwExtendedStyle = 0L;
p->x = x;
p->y = y;
p->cx = cx;
p->cy = cy;
p->id = id;
*pp = (WORD*)(++p); /* Advance ptr*/
CopyToWideChar( (WCHAR**)pp, strClassName ); /* Set Class name*/
CopyToWideChar( (WCHAR**)pp, strTitle ); /* Set Title*/
(*pp)++; /* Skip Extra Stuff*/
}
/*
----------------------------------------------------------------------------------------
Description : build simple dialog box with one list
----------------------------------------------------------------------------------------
*/
DLGTEMPLATE *fn_p_stPrepareDialogBox_LB( char *szTitle )
{
DLGTEMPLATE *pdt;
WORD *pw;
/* Allocate ample memory for building the template*/
memset( gs_a_stDialogTemplate, 0, 20*sizeof(DLGTEMPLATE) );
/* Fill in the DLGTEMPLATE info*/
pdt = gs_a_stDialogTemplate;
pdt->style = DS_MODALFRAME | DS_NOIDLEMSG | DS_SETFOREGROUND | DS_3DLOOK | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU ;
pdt->dwExtendedStyle = 0L;
pdt->cdit = 2;
pdt->x = 0;
pdt->y = 0;
pdt->cx = 310;
pdt->cy = 110;
/* Add menu array, class array, dlg title, font size and font name*/
pw = (WORD*)(++pdt);
*pw++ = 0; /* Set Menu array to nothing*/
*pw++ = 0; /* Set Class array to nothing*/
CopyToWideChar( (WCHAR**)&pw, szTitle ); /* Dlg title*/
/*
*pw++ = 8; // Font Size
CopyToWideChar( (WCHAR**)&pw, "Arial" ); // Font Name
*/
AddDialogControl( &pw, BS_PUSHBUTTON | WS_TABSTOP, 130, 90, 50, 15, IDOK, "BUTTON", "OK" );
AddDialogControl( &pw, (LBS_STANDARD - LBS_SORT) | WS_VSCROLL | WS_TABSTOP, 5, 5, 300, 80, 1000, "LISTBOX", "");
return gs_a_stDialogTemplate;
}
/*
=======================================================================================
Function to manage a dialog box with a single list box
=======================================================================================
*/
long GLI_fn_lDoDialogBox_LB( char *_szTitle, DLGPROC _DlgProc, LPARAM _lParam )
{
DLGTEMPLATE *p_stDlgTemplate;
p_stDlgTemplate = fn_p_stPrepareDialogBox_LB( _szTitle );
return DialogBoxIndirectParam( fn_hGetApplicationInstance(), p_stDlgTemplate, NULL, (DLGPROC)_DlgProc, _lParam );
}
#endif

View File

@@ -0,0 +1,66 @@
#ifdef GLI_IS_MULTIDRIVER
typedef struct GLI_TheInterface_
{
/* DOMATxxx.C */
void (* GLI_vDoTextureSelection)(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT);
void (* GLI_DRV_vWrite16bBitmapToBackBuffer) ( GLD_tdhDevice _hGLDDevice,GLD_tdhViewport _hGLDViewport,void *_p_vSourceBuffer,long _lWidth,long _lHeight,long _lDestX,long _lDestY );
void (* GLI_vSetFogParams)( tdstFogParams *_p_stFogParams );
/* ACCES_XXXX.C */
void (* GLI_vDrawTriangle)(void);
void (* GLI_vDrawZSortedTriangle)(void *p_3Point);
void (* GLI_DRV_vSendSpriteToClip)(GLI_tdstAligned2DVector *a4_st2DVertex ,MTH_tdxReal xZ ,GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT);
void (* GLI_DRV_vSendSpriteToClipWithUV)( GLI_tdstAligned2DVector *a4_st2DVertex , MTH_tdxReal *a8_stUVVertex, MTH_tdxReal xZ , GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT);
/* ACCES_ALL.C */
void (* GLI_TestBackfaceClockwise)(void);
void (* GLI_TestBackfaceCounterClockwize)(void);
void (* GLI_vComputeMovingUVW)(void);
void (* GLI_vComputeNormalUVW)(void);
void (* GLI_vComputeMirrorUVW)(void);
void (* GLI_vComputeXYZ)(void);
void (* GLI_FastMirrorCulling)(void);
void (* GLI_FastZCull)(void);
void (* GLI_bCullingXMax_XMin)(void);
void (* GLI_bCullingXMax)(void);
void (* GLI_bCullingXMin)(void);
void (* GLI_bCullingYMax_YMin)(void);
void (* GLI_bCullingYMax)(void);
void (* GLI_bCullingYMin)(void);
void (* GLI_bCullingXYALL)(void);
void (* GLI_XMinCLipping)(void);
void (* GLI_YMinCLipping)(void);
void (* GLI_XMaxCLipping)(void);
void (* GLI_YMaxCLipping)(void);
void (* GLI_vZClipping)(void);
void (* GLI_FastMirrorCLipping)(void);
void (* GLI_FastWaterCLipping)(void);
/* HDWTex_xxx.C */
void (* GLI_DRV_vDownLoadTextures)(long , long, BOOL);
long (* GLI_DRV_lGetHardwareTotalTextureMemorySize)(long);
long (* GLI_DRV_lGetHardwareMaxTextureSize)(void);
long (* GLI_DRV_lIsHardwareAcceptNonSquaredTextures)(void);
void (* GLI_DRV_vUnLoadTextures)(void);
/* init_XXX.c */
void (* GLI_DRV_vFlipDevice)(long lNbFrames);
void (* GLI_DRV_vClearDevice)(BOOL ZBuffer, BOOL ColorBuffer, unsigned long Color);
void (* GLI_vBeginDrawingTexturedMirrors)(void);
void (* GLI_vBeginDrawingTexturedMirrorsSurfaces)(void);
void (* GLI_vEndDrawingTexturedMirrors)(void);
void (* GLI_DRV_xInitDriver) (void);
void (* GLI_DRV_vCloseDriver) (void);
long (* GLI_DRV_lWhatIsGli)(void);
long (* GLI_lGetNumOfVersion)(void);
unsigned char *(* GLI_ucGetTextOfVersion)(void);
void (* GLI_DRV_vClearZBufferRegion)(long lXStart,long lXEnd,long lYStart,long lYEnd);
} GLI_TheInterface;
#define GLI_INTERFACE_FUNC(a) a##GLI_DRIVER
#else
#define GLI_INTERFACE_FUNC(a) a
#endif

View File

@@ -0,0 +1,249 @@
/*
=======================================================================================
Name : Init_Gli.c
Author : Philippe Vimont
Description : Init/close Gli + misc functions
=======================================================================================
Modification -> Author : Date :
Description :
=======================================================================================
*/
#define MAIN_GLI
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include "init_gli.h"
#include "gli_st.h"
#include "GLI_Defn.h"
#include "light_st.h"
#include "PvObj_st.h"
#include "material.h"
#include "linktab.h"
#include "Liste.h"
#include "watrplan.h"
#include "Priv_Obj.h"
#include "matstack.h"
#include "light.h"
#include "Object.h"
#include "texture.h"
#include "TMR.h"
#include "PRF.h"
#include "DLLInter.h"
#include "DispMode.h"
#include "GliText.h"
#include "DLLCaps.h"
#include "Tex.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
=======================================================================================
Constants
=======================================================================================
*/
/* Defined in TMR\Timer.cxx */
extern u_long fn_ulTimerTickPerSecond(short wTimerType);
extern ACP_tdxHandleOfMaterial gs_hDefaultMaterial;
static long GLI_gsIsInit = 0;
//float gs_xConstantFor3dfxBugFloat;
/*
=======================================================================================
External
=======================================================================================
*/
extern HWND fn_hGetApplicationWindow(void);
extern void GLI_vInitLensFlare(void) ;
extern void TEX_vSaveGlobales();
extern void TEX_vLoadGlobales();
extern void TEX_vSaveGlobalesFix();
extern void TEX_vLoadGlobalesFix();
#ifdef EXGEOM_APPLI
#define fn_vInitFrameLenght()
#else
void fn_vInitFrameLenght (void);
#endif
extern unsigned char g_ucMemorySnapshot;
extern char g_bSaveLoadFix;
extern unsigned long GLI_g_ulFrameLength;
extern GLI_tdstInternalGlobalValuesFor3dEngine * GLI_BIG_GLOBALS;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#ifdef __cplusplus
extern "C"
{
#endif
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/* End of turn engine.*/
/*
void GLI_vEndOfTurnEngine(void)
{
}
*/
/*
=======================================================================================
Gli initialisation function
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : initialize gli data
----------------------------------------------------------------------------------------
*/
void GLI_xInitGli (void)
{
static long lFirst = 1;
if (lFirst)
{
lFirst = 0;
/*
GLI_g_ulFrameLength = (long) ( ((float) fn_ulTimerTickPerSecond( C_wTimerFrequencyHigh )) / 60.0f );
*/
MMG_fn_vAddMemoryInfo (MMG_C_lTypeGLI , MMG_C_lSubTypeGlobal , NULL);
GLI_BIG_GLOBALS = (GLI_tdstInternalGlobalValuesFor3dEngine *)TMP_M_p_Malloc(sizeof(GLI_tdstInternalGlobalValuesFor3dEngine));
GLI_BIG_GLOBALS->GLD_RenderingCounter = -1;
GLI_BIG_GLOBALS->p_stActiveFog = NULL;
GLI_BIG_GLOBALS->p_stLastComputedFog = NULL;
GLI_BIG_GLOBALS->xFogIsOn = 0;
GLI_BIG_GLOBALS->lAMirrorIsDetected = 0;
GLI_BIG_GLOBALS->bDrawMirrorSymetric = 0;
GLI_BIG_GLOBALS->lDisplayMenuIsDetected = 0;
GLI_BIG_GLOBALS->xGlobalAlpha = 0.0f;
GLI_DRV_lSendDataToDll("GliBigGlobals", GLI_BIG_GLOBALS);
GLI_xCreateMaterial( &gs_hDefaultMaterial); /* little bug.*/
GLI_vIniTextRead();
GLI_vCreateObjectsReference();/* create collision visual objects.*/
//GLI_fn_vInitText();
GLI_vInitWaterplaneModule();
GLI_vSpecularOff();
GLI_vInitLensFlare() ;
GLI_xInitMatrixStack();
}
GLI_BIG_GLOBALS -> p_TheZListe = NULL;
GLI_g_stCaps.fRefreshRate = 0.0f;
GLI_DRV_xInitDriver( fn_hGetApplicationWindow(), GLI_fn_lIsFullScreenMode(), GLI_fn_lDisplayModeWidth(), GLI_fn_lDisplayModeHeight(), GLI_fn_lDisplayModeBPP() );
if ( (GLI_g_stCaps.fRefreshRate < 40.0f) || (GLI_g_stCaps.fRefreshRate >= 210.0f ) )
GLI_g_stCaps.fRefreshRate = 60.0f;
/* compute video frame length (for flip with synchro and meca) */
GLI_g_ulFrameLength = (long) ( (float) fn_ulTimerTickPerSecond( C_wTimerFrequencyMedium ) / GLI_g_stCaps.fRefreshRate );
/*GLI_g_ulFrameLength = (long) ( ((float) fn_ulTimerTickPerSecond( C_wTimerFrequencyMedium )) / 60.0f );*/
fn_vInitFrameLenght();
PRF_fn_vUpdateMonitorFrequency( (unsigned long)GLI_g_stCaps.fRefreshRate );
GLI_gsIsInit = 1;
}
/*
----------------------------------------------------------------------------------------
Description : close driver
----------------------------------------------------------------------------------------
*/
void GLI_vCloseGli( void )
{
GLI_gsIsInit = 0;
GLI_DRV_vCloseDriver();
}
/*
----------------------------------------------------------------------------------------
Description : return non zero if gli is initialized
----------------------------------------------------------------------------------------
*/
long GLI_xIsGliInit()
{
return GLI_gsIsInit;
}
/*
=======================================================================================
Other functions
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : called after all graphic data are loaded
----------------------------------------------------------------------------------------
*/
void GLI_vEndofGeometricLoad()
{
if (g_ucMemorySnapshot == 2)
{
if(!g_bSaveLoadFix)
{
TEX_vSaveGlobales(); /* Save binary data's*/
}
else
{
TEX_vSaveGlobalesFix();
}
}
if (g_ucMemorySnapshot == 1)
{
if(!g_bSaveLoadFix)
{
TEX_vLoadGlobales(); /* Load binary data's*/
}
else
{
TEX_vLoadGlobalesFix();
}
}
/*
* load textures
*/
GLI_vComputeTextures ();
}
/*
----------------------------------------------------------------------------------------
Description : memory signal (to change memory channel)
----------------------------------------------------------------------------------------
*/
void GLI_vSignalCurrentMemoryChannel(unsigned char ucCurrentChannel)
{
GLI_TEX_vSignalCurrentMemoryChannel(ucCurrentChannel);
}
/*
----------------------------------------------------------------------------------------
Description : memory signal (to free memory channel)
----------------------------------------------------------------------------------------
*/
void GLI_vKillMemoryChannel(unsigned char ucCurrentChannel)
{
GLI_TEX_vKillMemoryChannel(ucCurrentChannel);
}
/*
----------------------------------------------------------------------------------------
Description : draw a bar (not implemented : called by rasters display)
----------------------------------------------------------------------------------------
*/
void GLI_vDrawBar (long _lX0, long _lY0, long _lLength, long _lHeight)
{
}
#ifdef __cplusplus
} /*extern "C"*/
#endif

View File

@@ -0,0 +1,204 @@
/*
=======================================================================================
Name : LgtLoad.c
Description : fonction to load light (in script file)
=======================================================================================
*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include "acp_base.h"
#include "MTH.h"
#include "SCR.h"
#include "POS.h"
#include "GEO.h"
#include "util.h"
#include "color.h"
#include "gld.h"
#include "GLI_defn.h"
#include "light.h"
#include "LgtLoad.h"
#include "DPT.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*these lines are to be removed*/
typedef struct GLI_tdstLight_* LGT_tdxHandleToLight;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
=======================================================================================
Function to access light link table
=======================================================================================
*/
SCR_tdst_Link_Table gs_stLightLinkTable;
SCR_tdst_Link_Table *LGT_fn_p_stGetLightLinkTable()
{
return &gs_stLightLinkTable;
}
/*
=======================================================================================
Init/End the light loading
=======================================================================================
*/
SCR_tde_Anl_ReturnValue LGT_fn_xLoadLight(SCR_tdst_File_Description *p_fFile, char *szAction, char *szParams[], SCR_tde_Anl_Action cType);
BOOL LGT_fn_bInitLGTLoading()
{
SCR_fn_v_RdL0_RegisterCallback("Light",LGT_fn_xLoadLight, SCR_CRC_c_RdL0_ForSection);
SCR_fn_v_Link_InitTable(LGT_fn_p_stGetLightLinkTable());
return TRUE;
}
BOOL LGT_fn_bStopLGTLoading()
{
SCR_fn_v_Link_CloseTable(LGT_fn_p_stGetLightLinkTable());
return TRUE;
}
/*
=======================================================================================
script callback function to load a ligth (analyse a ligth script section)
=======================================================================================
*/
SCR_tde_Anl_ReturnValue LGT_fn_xLoadLight(SCR_tdst_File_Description *p_fFile, char *szAction, char *szParams[], SCR_tde_Anl_Action cType)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
LGT_tdxHandleToLight hLight,hNewLight;
POS_tdstCompletePosition *p_stMatrix;
long lOnOff;
GEO_tdstColor stColor;
long lTypeOfLight;
char a255_cLongName[255];
MTH3D_tdstVector myGetVector;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
switch (cType)
{
case SCR_EA_Anl_BeginSection:
if(strcmp(szParams[0],"Parallel")==0) lTypeOfLight = GLI_C_lParallelLight;
else if(strcmp(szParams[0],"Spherical")==0) lTypeOfLight = GLI_C_lSphericalLight;
else if(strcmp(szParams[0],"HotSpot")==0) lTypeOfLight = GLI_C_lHotSpotLight;
else if(strcmp(szParams[0],"Ambient")==0) lTypeOfLight = GLI_C_lAmbientLight;
else if(strcmp(szParams[0],"ParallelBox")==0) lTypeOfLight = GLI_C_lParallelLight_With_Limit;
else if(strcmp(szParams[0],"Fog")==0) lTypeOfLight = GLI_C_lFogLight;
GLI_xCreateLight(&hNewLight, lTypeOfLight);
/* add new light in link table*/
SCR_M_RdL0_ComputeOpenSectionNameR(0,a255_cLongName);
SCR_M_v_Link_SetAdditionalLong(SCR_fnp_st_Link_SetValue(LGT_fn_p_stGetLightLinkTable(), a255_cLongName, (unsigned long)hNewLight), 1, strlen(a255_cLongName)-strlen(SCR_M_RdL0_GetCompleteSectionNameR(0)));
/* store new created ligth in section and context */
SCR_M_RdL0_SetSectionLong(0,0,hNewLight);
SCR_M_RdL0_SetContextLong(0,0,hNewLight);
break;
case SCR_EA_Anl_Entry:
/* retrieve created ligth in context*/
SCR_M_RdL0_GetContextLong(0,0,LGT_tdxHandleToLight,hLight);
if (strcmp(szAction,"SetState")==0)
{
lOnOff=atoi(szParams[0]);
GLI_xSetLightState(hLight, lOnOff);
}
else if (strcmp(szAction,"SetColor")==0)
{
stColor.xR=(GEO_tdxColorValue)atof(szParams[0]);
stColor.xG=(GEO_tdxColorValue)atof(szParams[1]);
stColor.xB=(GEO_tdxColorValue)atof(szParams[2]);
stColor.xA=(GEO_tdxColorValue)atof(szParams[3]);
GLI_xSetLightColor(hLight,&stColor);
}
else if (strcmp(szAction,"SetNearFar")==0)
{
GLI_vSetLightNearFar( hLight, MTH_M_xFloatToReal((float)atof(szParams[0])), MTH_M_xFloatToReal((float)atof(szParams[1])));
}
else if (strcmp(szAction,"SetAlphas")==0)
{
GLI_vSetLightAlphas( hLight, MTH_M_xFloatToReal((float)atof(szParams[0])), MTH_M_xFloatToReal((float)atof(szParams[1])));
}
else if (strcmp(szAction,"SetMatrix")==0)
{
SCR_tdst_Cxt_Values *p_stVal;
p_stVal = SCR_fnp_st_RdL0_AnalyseSection(szParams[0], SCR_CDF_uw_Anl_Normal);
p_stMatrix = (POS_tdstCompletePosition *)SCR_M_ul_RdL0_ExtractLongValue(p_stVal,0);
GLI_xSetLightMatrix(hLight,p_stMatrix);
/* ATTENTION : dans light il y a une matrix et non un pointeur sur matrix*/
/* La matrice est donc (sauvagement) recopi<70>e.*/
/* En toute rigueur je devrais lib<69>rer p_stMatrix, mais, <20> terme,*/
/* je pense que light contiendra un pointeur (sigh...)*/
}
else if (strcmp(szAction,"ObjectLighted")==0)
{
GLI_vSetObjectLighted(hLight,(unsigned char)atoi(szParams[0]));
}
else if (strcmp(szAction,"PaintLight")==0)
{
GLI_vSetPaintLight(hLight);
}
else if (strcmp(szAction,"NoAlphaLight")==0)
{
GLI_vSetAlphaLightFlag (hLight, 2);
}
else if (strcmp(szAction,"AlphaLight")==0)
{
GLI_vSetAlphaLight(hLight);
}
else if (strcmp(szAction, "SetInterMinPos")==0)
{
myGetVector.xX = MTH_M_xFloatToReal((float)atof(szParams[0]));
myGetVector.xY = MTH_M_xFloatToReal((float)atof(szParams[1]));
myGetVector.xZ = MTH_M_xFloatToReal((float)atof(szParams[2]));
GLI_vSetLight_Inter_Min_Pos( hLight,myGetVector );
}
else if (strcmp(szAction, "SetInterMaxPos")==0)
{
myGetVector.xX = MTH_M_xFloatToReal((float)atof(szParams[0]));
myGetVector.xY = MTH_M_xFloatToReal((float)atof(szParams[1]));
myGetVector.xZ = MTH_M_xFloatToReal((float)atof(szParams[2]));
GLI_vSetLight_Inter_Max_Pos( hLight,myGetVector );
}
else if (strcmp(szAction, "SetExterMinPos")==0)
{
myGetVector.xX = MTH_M_xFloatToReal((float)atof(szParams[0]));
myGetVector.xY = MTH_M_xFloatToReal((float)atof(szParams[1]));
myGetVector.xZ = MTH_M_xFloatToReal((float)atof(szParams[2]));
GLI_vSetLight_Exter_Min_Pos( hLight,myGetVector );
}
else if (strcmp(szAction, "SetExterMaxPos")==0)
{
myGetVector.xX = MTH_M_xFloatToReal((float)atof(szParams[0]));
myGetVector.xY = MTH_M_xFloatToReal((float)atof(szParams[1]));
myGetVector.xZ = MTH_M_xFloatToReal((float)atof(szParams[2]));
GLI_vSetLight_Exter_Max_Pos( hLight,myGetVector );
}
else if (strcmp(szAction, "SetIntensityMinMax")==0)
{
GLI_vSetLight_Intensity_Min_Max( hLight, MTH_M_xFloatToReal((float)atof(szParams[0])), MTH_M_xFloatToReal((float)atof(szParams[1])));
}
else if (strcmp(szAction,"BackgroundColor")==0)
{
stColor.xR=(GEO_tdxColorValue)atof(szParams[0]);
stColor.xG=(GEO_tdxColorValue)atof(szParams[1]);
stColor.xB=(GEO_tdxColorValue)atof(szParams[2]);
stColor.xA=(GEO_tdxColorValue)atof(szParams[3]);
GLI_xSetLightBackgroundColor(hLight,&stColor);
}
break;
case C_SCRIPT_EndSection:
break;
}
return R_SCRIPT_NormalReturn;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,411 @@
/*
=======================================================================================
Name : Linear.c
Description : compute serial operation on verticex
=======================================================================================
*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#define MTH_LOW
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include"gli_st.h"
#include "GLI_Defn.h"
#include "vertex.h"
#include "light_st.h"
#include "PvObj_st.h"
#include "camera.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#ifdef __cplusplus
extern "C"
{
#endif
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
=======================================================================================
Globals & Externals & Protos
=======================================================================================
*/
extern void GLI_vSinusEffetOn3DVertex( MTH3D_tdstVector * p_stVertex3D );
/*
=======================================================================================
Macros
=======================================================================================
*/
#define GLI_M_SWAP(a,b)\
{\
fSwapValue = (a);\
(a) = (b);\
(b) = fSwapValue ;\
}\
/*
=======================================================================================
Functions
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : serial dot product : do a dot product for a list of source point
source point are MTH3D_tdstVector (ie 3 float)
----------------------------------------------------------------------------------------
*/
void GLI_xSerialDotProduct(long lNbOfVertex, MTH3D_tdstVector *p_stSource, float *p_stDest, MTH3D_tdstVector *p_stMultiplicator, long lIncrement)
{
float *p_stLastResult;
p_stLastResult = p_stDest + lNbOfVertex;
for ( ; p_stDest < p_stLastResult; p_stSource++ )
*p_stDest++ = MTH_M_xRealToFloat( MTH3D_M_xDotProductVector( p_stSource,p_stMultiplicator) ) ;
}
/*
----------------------------------------------------------------------------------------
Description : serial dot product : do a dot product for a list of point
source point are Aligned3DVector (ie 4 float)
----------------------------------------------------------------------------------------
*/
void GLI_xSerialDotProductAligned ( long lNbOfVertex, GLI_tdstAligned3DVector *p_stSource, float *p_stDest, MTH3D_tdstVector *p_stMultiplicator, long lIncrement)
{
float *p_stLastResult;
p_stLastResult = p_stDest + lNbOfVertex;
for ( ; p_stDest < p_stLastResult; p_stSource++ )
*p_stDest++ = MTH_M_xRealToFloat ( MTH3D_M_xDotProductVector( (MTH3D_tdstVector *)p_stSource, p_stMultiplicator) ) ;
}
/*
----------------------------------------------------------------------------------------
Description : multiply a list of vertex with a matrix
source vertices are MTH3D_tdstVector (ie 3 float)
target vertices are Aligned3DVector (ie 4 float)
----------------------------------------------------------------------------------------
*/
void GLI_xSerialLinearOp( long lNbOfVertex, MTH3D_tdstVector *p_stSource, GLI_tdstAligned3DVector *p_stDest, POS_tdstCompletePosition *p_stMatrix)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
MTH3D_tdstVector stX,stY,stZ,stTrans;
GLI_tdstAligned3DVector *p_stLastDest ;
float fSwapValue;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
POS_fn_vGetTransformMatrix ( p_stMatrix,&stX,&stY,&stZ);
GLI_M_SWAP (stX.xY,stY.xX);
GLI_M_SWAP (stX.xZ,stZ.xX);
GLI_M_SWAP (stY.xZ,stZ.xY);
POS_fn_vGetTranslationVector( p_stMatrix,&stTrans);
p_stLastDest = p_stDest + lNbOfVertex;
for ( ; p_stDest < p_stLastDest; p_stDest++, p_stSource++)
{
p_stDest->xX = MTH3D_M_xDotProductVector ( &stX , p_stSource ) + stTrans.xX;
p_stDest->xY = MTH3D_M_xDotProductVector ( &stY , p_stSource ) + stTrans.xY;
p_stDest->xZ = MTH3D_M_xDotProductVector ( &stZ , p_stSource ) + stTrans.xZ;
}
}
/*
----------------------------------------------------------------------------------------
Description : new version of above function, parameters are in big structure
----------------------------------------------------------------------------------------
*/
void GLI_xNewSerialLinearOp ( GLI_tdstInternalGlobalValuesFor3dEngine *GLI_BG )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
GLI_tdstAligned3DVector *p_stDest;
GLI_tdstAligned3DVector *p_stLastDest;
MTH3D_tdstVector *p_stSource ;
float fSwapValue;
MTH3D_tdstVector stX,stY,stZ,stTrans;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
POS_fn_vGetTransformMatrix ( &GLI_BG->gs_st_CurrentMatrixMultiplyedWithCameraMatrix, &stX, &stY, &stZ);
GLI_M_SWAP (stX.xY,stY.xX);
GLI_M_SWAP (stX.xZ,stZ.xX);
GLI_M_SWAP (stY.xZ,stZ.xY);
POS_fn_vGetTranslationVector( &GLI_BG->gs_st_CurrentMatrixMultiplyedWithCameraMatrix , &stTrans);
p_stDest = GLI_BG->GLI_TurnedScaledDisplecedPoint;
p_stSource = GLI_BG->p_stObj->d_stListOfPoints ;
p_stLastDest = p_stDest + GLI_BG->p_stObj->xNbPoints;
for ( ; p_stDest < p_stLastDest ; p_stDest++ , p_stSource++ )
{
p_stDest->xX = MTH3D_M_xDotProductVector( &stX, p_stSource ) + stTrans.xX;
p_stDest->xY = MTH3D_M_xDotProductVector( &stY, p_stSource ) + stTrans.xY;
p_stDest->xZ = MTH3D_M_xDotProductVector( &stZ, p_stSource ) + stTrans.xZ;
}
}
/*
----------------------------------------------------------------------------------------
Description : projection of 3D point that are in camera system axis
----------------------------------------------------------------------------------------
*/
void GLI_xNewSerialProjOp ( GLI_tdstInternalGlobalValuesFor3dEngine *GLI_BG )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
GLI_tdstAligned3DVector *p_stDest;
GLI_tdstAligned3DVector *p_stLastDest;
GLI_tdstAligned2DVector *p_st2DDest;
float fScaleX,fScaleY;
long lNewX;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
*(float * )&lNewX = 8000.0f;
fScaleX = GLI_BG->p_stCurrentCamera->xScreen * GLI_BG->p_stCurrentCamera->stScale.xX ;
fScaleY = GLI_BG->p_stCurrentCamera->xScreen * GLI_BG->p_stCurrentCamera->stScale.xY ;
p_stDest = GLI_BG->GLI_TurnedScaledDisplecedPoint;
p_st2DDest = GLI_BG->GLI_ScreenPoint;
p_stLastDest = p_stDest + GLI_BG->p_stObj->xNbPoints;
if (GLI_BG -> lClippingModeMask & GLI_C_ClipMaskZ)
{
for ( ; p_stDest < p_stLastDest ; p_stDest ++ , p_st2DDest++ )
{
if ( *(long *)&p_stDest->xZ < *(long *)&GLI_BG->p_stCurrentCamera->xNear)
{
*(long *)&p_st2DDest -> xOoZ |= 0x80000000;
*((unsigned long *)&p_st2DDest->xX) = lNewX | ((*((unsigned long *)&p_stDest->xX) & 0x80000000) ^ 0x80000000);
*((unsigned long *)&p_st2DDest->xY) = lNewX | ((*((unsigned long *)&p_stDest->xY) & 0x80000000) ^ 0x80000000);
continue ;
}
p_st2DDest->xOoZ = MTH_M_xInvLow(p_stDest->xZ ) ;
p_st2DDest->xX = GLI_BG->p_stCurrentCamera->stTrans.xX + p_stDest->xX * fScaleX * p_st2DDest->xOoZ ;
p_st2DDest->xY = GLI_BG->p_stCurrentCamera->stTrans.xY + p_stDest->xY * fScaleY * p_st2DDest->xOoZ ;
p_st2DDest->xOoZ *= GLI_C_xZClippingNear;
}
}
else
{
for ( ; p_stDest < p_stLastDest ; p_stDest ++ , p_st2DDest++ )
{
p_st2DDest->xOoZ = MTH_M_xInvLow(p_stDest->xZ ) ;
p_st2DDest->xX = GLI_BG->p_stCurrentCamera->stTrans.xX + p_stDest->xX * fScaleX * p_st2DDest->xOoZ ;
p_st2DDest->xY = GLI_BG->p_stCurrentCamera->stTrans.xY + p_stDest->xY * fScaleY * p_st2DDest->xOoZ ;
p_st2DDest->xOoZ *= GLI_C_xZClippingNear;
}
}
}
/*
----------------------------------------------------------------------------------------
Description : turned and project object vertex to get 2D coords
----------------------------------------------------------------------------------------
*/
void GLI_xNewSerialLinearProjOpZClip ( GLI_tdstInternalGlobalValuesFor3dEngine *GLI_BG )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
GLI_tdstAligned3DVector *p_stDest;
GLI_tdstAligned3DVector *p_stLastDest;
GLI_tdstAligned2DVector *p_st2DDest;
MTH3D_tdstVector *p_stSource ;
MTH3D_tdstVector stX, stY, stZ, stTrans;
float fSwapValue, fScaleX, fScaleY, fTmpZ;
long lNewX;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
*(float * )&lNewX = 8000.0f;
fScaleX = GLI_BG->p_stCurrentCamera->xScreen * GLI_BG->p_stCurrentCamera->stScale.xX;
fScaleY = GLI_BG->p_stCurrentCamera->xScreen * GLI_BG->p_stCurrentCamera->stScale.xY;
POS_fn_vGetTransformMatrix ( &GLI_BG->gs_st_CurrentMatrixMultiplyedWithCameraMatrix, &stX, &stY, &stZ);
GLI_M_SWAP (stX.xY,stY.xX);
GLI_M_SWAP (stX.xZ,stZ.xX);
GLI_M_SWAP (stY.xZ,stZ.xY);
POS_fn_vGetTranslationVector( &GLI_BG -> gs_st_CurrentMatrixMultiplyedWithCameraMatrix , &stTrans);
p_stDest = GLI_BG->GLI_TurnedScaledDisplecedPoint;
p_st2DDest = GLI_BG->GLI_ScreenPoint;
p_stSource = GLI_BG->p_stObj->d_stListOfPoints ;
p_stLastDest = p_stDest + GLI_BG->p_stObj->xNbPoints;
for ( ; p_stDest < p_stLastDest ; p_stDest ++ , p_stSource++ , p_st2DDest++ )
{
p_stDest->xX = MTH3D_M_xDotProductVector( &stX , p_stSource ) + stTrans.xX;
p_stDest->xY = MTH3D_M_xDotProductVector( &stY , p_stSource ) + stTrans.xY;
p_stDest->xZ = MTH3D_M_xDotProductVector( &stZ , p_stSource ) + stTrans.xZ;
if ( *(long *)&p_stDest->xZ < *(long *)&GLI_BG -> p_stCurrentCamera -> xNear)
{
/* point is before the near plane, so */
/* turn OoZ into negative value */
*(long *)&p_st2DDest -> xOoZ |= 0x80000000;
/* and put X and Y to +/- 8000.0f according to the sign of the 3dPoint coordinates*/
*((unsigned long *)&p_st2DDest ->xX) = lNewX | ((*((unsigned long *)&p_stDest->xX) & 0x80000000) ^ 0x80000000);
*((unsigned long *)&p_st2DDest ->xY) = lNewX | ((*((unsigned long *)&p_stDest->xY) & 0x80000000) ^ 0x80000000);
continue ;
}
fTmpZ = MTH_M_xInvLow(p_stDest->xZ);
p_st2DDest->xX = GLI_BG->p_stCurrentCamera->stTrans.xX + p_stDest->xX * fScaleX * fTmpZ;
p_st2DDest->xY = GLI_BG->p_stCurrentCamera->stTrans.xY + p_stDest->xY * fScaleY * fTmpZ;
p_st2DDest->xOoZ = fTmpZ * GLI_C_xZClippingNear;
}
}
/*
----------------------------------------------------------------------------------------
Description : turned and project object vertex to get 2D coords
apply sinus effect on 3D transformed vertices
----------------------------------------------------------------------------------------
*/
void GLI_xSerialLinearProjOpZClipWithEffect ( GLI_tdstInternalGlobalValuesFor3dEngine *GLI_BG )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
GLI_tdstAligned3DVector *p_stDest;
GLI_tdstAligned3DVector *p_stLastDest;
GLI_tdstAligned2DVector *p_st2DDest;
MTH3D_tdstVector *p_stSource ;
MTH3D_tdstVector stX,stY,stZ,stTrans;
float fSwapValue,fScaleX,fScaleY, fTmpZ;
long lNewX;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
*(float * )&lNewX = 8000.0f;
fScaleX = GLI_BG->p_stCurrentCamera->xScreen * GLI_BG->p_stCurrentCamera->stScale.xX;
fScaleY = GLI_BG->p_stCurrentCamera->xScreen * GLI_BG->p_stCurrentCamera->stScale.xY;
POS_fn_vGetTransformMatrix ( &GLI_BG->gs_st_CurrentMatrixMultiplyedWithCameraMatrix, &stX, &stY, &stZ);
GLI_M_SWAP (stX.xY,stY.xX);
GLI_M_SWAP (stX.xZ,stZ.xX);
GLI_M_SWAP (stY.xZ,stZ.xY);
POS_fn_vGetTranslationVector( &GLI_BG -> gs_st_CurrentMatrixMultiplyedWithCameraMatrix , &stTrans);
p_stDest = GLI_BG->GLI_TurnedScaledDisplecedPoint;
p_st2DDest = GLI_BG->GLI_ScreenPoint;
p_stSource = GLI_BG->p_stObj->d_stListOfPoints ;
p_stLastDest = p_stDest + GLI_BG->p_stObj->xNbPoints;
for ( ; p_stDest < p_stLastDest ; p_stDest ++ , p_stSource++ , p_st2DDest++ )
{
p_stDest->xX = MTH3D_M_xDotProductVector( &stX , p_stSource ) + stTrans.xX;
p_stDest->xY = MTH3D_M_xDotProductVector( &stY , p_stSource ) + stTrans.xY;
p_stDest->xZ = MTH3D_M_xDotProductVector( &stZ , p_stSource ) + stTrans.xZ;
GLI_vSinusEffetOn3DVertex((MTH3D_tdstVector *)p_stDest) ;
if ( *(long *)&p_stDest->xZ < *(long *)&GLI_BG -> p_stCurrentCamera -> xNear)
{
*(long *)&p_st2DDest -> xOoZ |= 0x80000000;
*((unsigned long *)&p_st2DDest ->xX) = lNewX | ((*((unsigned long *)&p_stDest->xX) & 0x80000000) ^ 0x80000000);
*((unsigned long *)&p_st2DDest ->xY) = lNewX | ((*((unsigned long *)&p_stDest->xY) & 0x80000000) ^ 0x80000000);
continue ;
}
fTmpZ = MTH_M_xInvLow(p_stDest->xZ);
p_st2DDest->xX = GLI_BG->p_stCurrentCamera->stTrans.xX + p_stDest->xX * fScaleX * fTmpZ;
p_st2DDest->xY = GLI_BG->p_stCurrentCamera->stTrans.xY + p_stDest->xY * fScaleY * fTmpZ;
p_st2DDest->xOoZ = fTmpZ * GLI_C_xZClippingNear;
}
}
/*
----------------------------------------------------------------------------------------
Description : turned and project object vertex to get 2D coords
object is not Z clipped so do no test on Z
----------------------------------------------------------------------------------------
*/
void GLI_xNewSerialLinearProjOpNoZClip ( GLI_tdstInternalGlobalValuesFor3dEngine *GLI_BG )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
GLI_tdstAligned3DVector *p_stDest;
GLI_tdstAligned3DVector *p_stLastDest;
GLI_tdstAligned2DVector *p_st2DDest;
MTH3D_tdstVector *p_stSource ;
MTH3D_tdstVector stX, stY, stZ, stTrans;
float fSwapValue, fScaleX, fScaleY, fTmpZ;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
fScaleX = GLI_BG->p_stCurrentCamera->xScreen * GLI_BG->p_stCurrentCamera->stScale.xX ;
fScaleY = GLI_BG->p_stCurrentCamera->xScreen * GLI_BG->p_stCurrentCamera->stScale.xY ;
POS_fn_vGetTransformMatrix ( &GLI_BG->gs_st_CurrentMatrixMultiplyedWithCameraMatrix , &stX , &stY , &stZ);
GLI_M_SWAP (stX.xY,stY.xX);
GLI_M_SWAP (stX.xZ,stZ.xX);
GLI_M_SWAP (stY.xZ,stZ.xY);
/* here, stX contains the first line of the matrix */
/* stY the second, and stz the third */
POS_fn_vGetTranslationVector( &GLI_BG->gs_st_CurrentMatrixMultiplyedWithCameraMatrix , &stTrans);
p_stDest = GLI_BG->GLI_TurnedScaledDisplecedPoint;
p_st2DDest = GLI_BG->GLI_ScreenPoint;
p_stSource = GLI_BG->p_stObj->d_stListOfPoints ;
p_stLastDest = p_stDest + GLI_BG->p_stObj->xNbPoints;
for ( ; p_stDest < p_stLastDest ; p_stDest ++ , p_stSource++ , p_st2DDest++ )
{
/* compute object's points in camera coordinates */
/* this is a faster version of the mullmatrixvertex*/
/* note that it uses the specially-computed stX, stY and stZ */
p_stDest->xZ = MTH3D_M_xDotProductVector( &stZ , p_stSource ) + stTrans.xZ;
p_stDest->xX = MTH3D_M_xDotProductVector( &stX , p_stSource ) + stTrans.xX;
p_stDest->xY = MTH3D_M_xDotProductVector( &stY , p_stSource ) + stTrans.xY;
/* and scale the coordinates to let them fit in the viewport, with perspective correction */
fTmpZ = MTH_M_xInvLow(p_stDest->xZ);
p_st2DDest->xX = GLI_BG->p_stCurrentCamera->stTrans.xX + p_stDest->xX * fScaleX * fTmpZ;
p_st2DDest->xY = GLI_BG->p_stCurrentCamera->stTrans.xY + p_stDest->xY * fScaleY * fTmpZ;
p_st2DDest->xOoZ = fTmpZ * GLI_C_xZClippingNear;
}
}
/*
----------------------------------------------------------------------------------------
Description : turned and project object vertex to get 2D coords
object is not Z clipped so do no test on Z
apply sinus effect on transformed vertices
----------------------------------------------------------------------------------------
*/
void GLI_xSerialLinearProjOpNoZClipWithEffect ( GLI_tdstInternalGlobalValuesFor3dEngine *GLI_BG )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
GLI_tdstAligned3DVector *p_stDest;
GLI_tdstAligned3DVector *p_stLastDest;
GLI_tdstAligned2DVector *p_st2DDest;
MTH3D_tdstVector *p_stSource ;
MTH3D_tdstVector stX,stY,stZ,stTrans;
float fSwapValue,fScaleX,fScaleY, fTmpZ;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
fScaleX = GLI_BG->p_stCurrentCamera->xScreen * GLI_BG->p_stCurrentCamera->stScale.xX ;
fScaleY = GLI_BG->p_stCurrentCamera->xScreen * GLI_BG->p_stCurrentCamera->stScale.xY ;
POS_fn_vGetTransformMatrix ( &GLI_BG -> gs_st_CurrentMatrixMultiplyedWithCameraMatrix , &stX , &stY , &stZ);
GLI_M_SWAP (stX.xY,stY.xX);
GLI_M_SWAP (stX.xZ,stZ.xX);
GLI_M_SWAP (stY.xZ,stZ.xY);
POS_fn_vGetTranslationVector( &GLI_BG -> gs_st_CurrentMatrixMultiplyedWithCameraMatrix , &stTrans);
p_stDest = GLI_BG->GLI_TurnedScaledDisplecedPoint;
p_st2DDest = GLI_BG->GLI_ScreenPoint;
p_stSource = GLI_BG->p_stObj->d_stListOfPoints ;
p_stLastDest = p_stDest + GLI_BG -> p_stObj -> xNbPoints;
for ( ; p_stDest < p_stLastDest ; p_stDest ++ , p_stSource++ , p_st2DDest++ )
{
p_stDest->xZ = MTH3D_M_xDotProductVector ( &stZ , p_stSource ) + stTrans . xZ;
p_stDest->xX = MTH3D_M_xDotProductVector ( &stX , p_stSource ) + stTrans . xX;
p_stDest->xY = MTH3D_M_xDotProductVector ( &stY , p_stSource ) + stTrans . xY;
GLI_vSinusEffetOn3DVertex((MTH3D_tdstVector *)p_stDest) ;
fTmpZ = MTH_M_xInvLow(p_stDest->xZ);
p_st2DDest -> xX = GLI_BG->p_stCurrentCamera->stTrans.xX + p_stDest -> xX * fScaleX * fTmpZ;
p_st2DDest -> xY = GLI_BG->p_stCurrentCamera->stTrans.xY + p_stDest -> xY * fScaleY * fTmpZ;
p_st2DDest -> xOoZ = fTmpZ * GLI_BG->p_stCurrentCamera->xNear ;
}
}
#ifdef __cplusplus
} /*extern "C"*/
#endif

View File

@@ -0,0 +1,165 @@
/*
Tested with LINT
*/
#include "Gli_st.h"
#include "GLI_Defn.h"
#include "light_st.h"
#include "PvObj_st.h"
#include "lines.h"
#include "proj.h"
#include "linear.h"
#include "matstack.h"
#include "vpt3D.h"
#include "camera.h"
#include "DLLInter.h"
#include "Object.h"
#include "acp_driver.h"
extern GLI_tdstInternalGlobalValuesFor3dEngine *GLI_BIG_GLOBALS;
#ifdef __cplusplus
extern "C"
{
#endif
/**********************************************************************************************/
/* Name: GLI_xDraw3DLine16 1.0*/
/* Goal: Draw 3d line unclipped and unprojected in 16b*/
/* Code: Philippe Vimont*/
/**********************************************************************************************/
/*void GLI_vSetZClip(float ZClip,GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT);*/
/*void GLI_NJA_vSendSingleLineToClip( GLD_tdstViewportAttributes *p_stVpt , GLI_tdstAligned3DVector *p_stVertex1 , GLI_tdstAligned2DVector *p_st2DVertex1 , GLI_tdstAligned3DVector *p_stVertex2 , GLI_tdstAligned2DVector *p_st2DVertex2 , GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT, long lDrawModeMask, GEO_tdstColor *p_stColor );*/
void GLI_xDraw3DLine16 ( GLD_tdstViewportAttributes *p_stVpt, MTH3D_tdstVector *p_stFirstPoint , MTH3D_tdstVector *p_stLastPoint , long lColor)
{
#ifdef _DEBUG
GLI_tdstAligned2DVector a2_st2DVertex[4];
GLI_tdstSpecificAttributesFor3D *p_st3DAtributes;
GLI_tdstAligned3DVector a2_stVertex[4];
GEO_tdstColor stColor;
p_st3DAtributes = (GLI_tdstSpecificAttributesFor3D*) (p_stVpt->p_vSpecificToXD);
GLI_DRV_vSetZClip( (float)p_st3DAtributes -> p_stCam -> xNear, GLI_BIG_GLOBALS);
/*turn points*/
GLI_xSerialLinearOp(1,p_stFirstPoint,&a2_stVertex[0],g_p_stCurrentMatrix);
GLI_xSerialLinearOp(1,p_stLastPoint,&a2_stVertex[1],g_p_stCurrentMatrix);
/* project points */
GLI_xSerialProjection(p_st3DAtributes->p_stCam,2,a2_stVertex,a2_st2DVertex);
#ifdef USE_DIRECTX
a2_st2DVertex[0].ulPackedColor = a2_st2DVertex[1].ulPackedColor = (0xFF000000 | lColor) ;
#else
a2_st2DVertex[0].ulPackedColor = a2_st2DVertex[1].ulPackedColor = lColor;
#endif
stColor.xR = (float)((lColor & 0x00FF0000)>>16) * 1.0f;
stColor.xG = (float)((lColor & 0x0000FF00)>>8) * 1.0f;
stColor.xB = (float)((lColor & 0x000000FF)>>0) * 1.0f;
GLI_BIG_GLOBALS->lCurrentDrawMask = 0xFFFFFFFF;
GLI_BIG_GLOBALS->lHierachDrawMask = 0xFFFFFFFF;
GLI_BIG_GLOBALS->hCurrentMaterial = NULL;
GLI_BIG_GLOBALS->gs_st_CurrentMatrix = g_p_stCurrentMatrix;
GLI_BIG_GLOBALS->gs_st_CameraMatrix = &p_st3DAtributes->p_stCam->stMatrix;
GLI_BIG_GLOBALS->p_stCurrentCamera = p_st3DAtributes->p_stCam;
GLI_DRV_vSetZClip( GLI_BIG_GLOBALS->p_stCurrentCamera->xNear, GLI_BIG_GLOBALS);
#ifdef TEST
{
static float x0=0;
static float y0=0;
static float z0=0.2;
static float x1=220;
static float y1=333;
static float z1=0.2;
a2_st2DVertex[0].xX = x0;
a2_st2DVertex[0].xY = y0;
//a2_stVertex[0].xZ = z0;
a2_st2DVertex[0].xOoZ = z0;
a2_st2DVertex[1].xX = x1;
a2_st2DVertex[1].xY = y1;
//a2_stVertex[1].xZ = z1;
a2_st2DVertex[1].xOoZ = z1;
}
#endif
GLI_DRV_vSendSingleLineToClip
(
p_stVpt ,
&a2_stVertex[0],
&a2_st2DVertex[0],
&a2_stVertex[1],
&a2_st2DVertex[1],
GLI_BIG_GLOBALS,
C_lGouraudLineElement,& stColor
);
#endif
}
void GLI_fnv_Draw2DLine( GLD_tdstViewportAttributes *p_stVpt, MTH3D_tdstVector *p_stFirstPoint, MTH3D_tdstVector *p_stLastPoint, long lColor )
{
GEO_tdstColor stColor;
GLI_tdstAligned3DVector a2_stVertex[2];
GLI_tdstAligned2DVector a2_st2DVertex[2];
GLI_BIG_GLOBALS->hCurrentMaterial = NULL;
GLI_BIG_GLOBALS->lCurrentDrawMask = 0xFFFFFFFF;
GLI_BIG_GLOBALS->lHierachDrawMask = 0xFFFFFFFF;
GLI_vDoMaterialSelection( GLI_BIG_GLOBALS );
a2_st2DVertex[0].ulPackedColor = a2_st2DVertex[1].ulPackedColor = lColor;
stColor.xR = (float)((lColor & 0x00FF0000)>>16) * 1.0f;
stColor.xG = (float)((lColor & 0x0000FF00)>>8) * 1.0f;
stColor.xB = (float)((lColor & 0x000000FF)>>0) * 1.0f;
a2_st2DVertex[0].xX = p_stFirstPoint->xX * p_stVpt->dwWidth;
a2_st2DVertex[0].xY = p_stFirstPoint->xY * p_stVpt->dwHeight;
a2_stVertex[0].xZ = a2_st2DVertex[0].xOoZ = 1000000.0f;
a2_st2DVertex[1].xX = p_stLastPoint->xX * p_stVpt->dwWidth;
a2_st2DVertex[1].xY = p_stLastPoint->xY * p_stVpt->dwHeight;
a2_stVertex[1].xZ = a2_st2DVertex[1].xOoZ = 1000000.0f;
GLI_DRV_vSendSingleLineToClip
(
p_stVpt ,
&a2_stVertex[0],
&a2_st2DVertex[0],
&a2_stVertex[1],
&a2_st2DVertex[1],
GLI_BIG_GLOBALS,
C_lGouraudLineElement,
&stColor
);
}
void GLI_fnv_DrawRectangle( GLD_tdstViewportAttributes *p_stVpt, MTH3D_tdstVector *p_stFirstPoint, MTH3D_tdstVector *p_stLastPoint, long lColor )
{
MTH3D_tdstVector stIntermediate;
stIntermediate.xX = p_stFirstPoint->xX;
stIntermediate.xY = p_stLastPoint->xY;
GLI_fnv_Draw2DLine( p_stVpt, p_stFirstPoint, &stIntermediate, lColor );
GLI_fnv_Draw2DLine( p_stVpt, &stIntermediate, p_stLastPoint, lColor );
stIntermediate.xX = p_stLastPoint->xX;
stIntermediate.xY = p_stFirstPoint->xY;
GLI_fnv_Draw2DLine( p_stVpt, p_stFirstPoint, &stIntermediate, lColor );
GLI_fnv_Draw2DLine( p_stVpt, &stIntermediate, p_stLastPoint, lColor );
}
#ifdef __cplusplus
} /* extern "C" */
#endif

View File

@@ -0,0 +1,142 @@
#include "cpa_std.h"
#include "SCR.h"
#include "linktab.h"
SCR_tdst_Link_Table stLinkTableOfGeometric;
SCR_tdst_Link_Table stLinkTableOfElementIndexedTriangle;
SCR_tdst_Link_Table stLinkTableOfElementTMeshe;
SCR_tdst_Link_Table stLinkTableOfElementFaceMapDescriptor;
SCR_tdst_Link_Table stLinkTableOfElementSprite;
SCR_tdst_Link_Table stLinkTableOfElementLine;
SCR_tdst_Link_Table stLinkTableOfElementSphere;
SCR_tdst_Link_Table stLinkTableOfElementAlignedBoxe;
SCR_tdst_Link_Table stLinkTableOfElementPoint;
SCR_tdst_Link_Table stLinkTableOfElementCone;
SCR_tdst_Link_Table stLinkTableOfFaceMapDescriptor;
SCR_tdst_Link_Table stLinkTableOfSprite;
SCR_tdst_Link_Table stLinkTableOfTexture;
SCR_tdst_Link_Table stLinkTableOfVisualMaterial;
SCR_tdst_Link_Table stLinkTableOfFrontierElement;
SCR_tdst_Link_Table stLinkTableOfTextureSection;
SCR_tdst_Link_Table *GLI_p_stGetLinkTableOfGeometric()
{
return &stLinkTableOfGeometric;
}
SCR_tdst_Link_Table *GLI_p_stGetLinkTableOfElementIndexedTriangle()
{
return &stLinkTableOfElementIndexedTriangle;
}
SCR_tdst_Link_Table *GLI_p_stGetLinkTableOfElementTMeshe()
{
return &stLinkTableOfElementTMeshe;
}
SCR_tdst_Link_Table *GLI_p_stGetLinkTableOfElementFaceMapDescriptor()
{
return &stLinkTableOfElementFaceMapDescriptor;
}
SCR_tdst_Link_Table *GLI_p_stGetLinkTableOfElementSprite()
{
return &stLinkTableOfElementSprite;
}
SCR_tdst_Link_Table *GLI_p_stGetLinkTableOfElementLine()
{
return &stLinkTableOfElementLine;
}
SCR_tdst_Link_Table *GLI_p_stGetLinkTableOfElementSphere()
{
return &stLinkTableOfElementSphere;
}
SCR_tdst_Link_Table *GLI_p_stGetLinkTableOfElementAlignedBoxe()
{
return &stLinkTableOfElementAlignedBoxe;
}
SCR_tdst_Link_Table *GLI_p_stGetLinkTableOfElementPoint()
{
return &stLinkTableOfElementPoint;
}
SCR_tdst_Link_Table *GLI_p_stGetLinkTableOfElementCone()
{
return &stLinkTableOfElementCone;
}
SCR_tdst_Link_Table *GLI_p_stGetLinkTableOfFaceMapDescriptor()
{
return &stLinkTableOfFaceMapDescriptor;
}
SCR_tdst_Link_Table *GLI_p_stGetLinkTableOfSprite()
{
return &stLinkTableOfSprite;
}
SCR_tdst_Link_Table *GLI_p_stGetLinkTableOfTexture()
{
return &stLinkTableOfTexture;
}
SCR_tdst_Link_Table *GLI_p_stGetLinkTableOfVisualMaterial()
{
return &stLinkTableOfVisualMaterial;
}
SCR_tdst_Link_Table *GLI_p_stGetLinkTableOfFrontierElement()
{
return &stLinkTableOfFrontierElement;
}
SCR_tdst_Link_Table *GLI_p_stGetLinkTableOfTextureSection()
{
return &stLinkTableOfTextureSection;
}
void GLI_vInitLinkTableOfGeometric()
{
SCR_fn_v_Link_InitTable(&stLinkTableOfTextureSection);
SCR_fn_v_Link_InitTable(&stLinkTableOfGeometric);
SCR_fn_v_Link_InitTable(&stLinkTableOfElementIndexedTriangle);
SCR_fn_v_Link_InitTable(&stLinkTableOfElementTMeshe);
SCR_fn_v_Link_InitTable(&stLinkTableOfElementFaceMapDescriptor);
SCR_fn_v_Link_InitTable(&stLinkTableOfElementSprite);
SCR_fn_v_Link_InitTable(&stLinkTableOfElementLine);
SCR_fn_v_Link_InitTable(&stLinkTableOfElementSphere);
SCR_fn_v_Link_InitTable(&stLinkTableOfElementAlignedBoxe);
SCR_fn_v_Link_InitTable(&stLinkTableOfElementPoint);
SCR_fn_v_Link_InitTable(&stLinkTableOfElementCone);
SCR_fn_v_Link_InitTable(&stLinkTableOfFaceMapDescriptor);
SCR_fn_v_Link_InitTable(&stLinkTableOfSprite);
SCR_fn_v_Link_InitTable(&stLinkTableOfTexture);
SCR_fn_v_Link_InitTable(&stLinkTableOfVisualMaterial);
SCR_fn_v_Link_InitTable(&stLinkTableOfFrontierElement);
}
void GLI_vCloseLinkTableOfGeometric()
{
SCR_fn_v_Link_CloseTable(&stLinkTableOfTextureSection);
SCR_fn_v_Link_CloseTable(&stLinkTableOfGeometric);
SCR_fn_v_Link_CloseTable(&stLinkTableOfElementIndexedTriangle);
SCR_fn_v_Link_CloseTable(&stLinkTableOfElementTMeshe);
SCR_fn_v_Link_CloseTable(&stLinkTableOfElementFaceMapDescriptor);
SCR_fn_v_Link_CloseTable(&stLinkTableOfElementSprite);
SCR_fn_v_Link_CloseTable(&stLinkTableOfElementLine);
SCR_fn_v_Link_CloseTable(&stLinkTableOfElementSphere);
SCR_fn_v_Link_CloseTable(&stLinkTableOfElementAlignedBoxe);
SCR_fn_v_Link_CloseTable(&stLinkTableOfElementPoint);
SCR_fn_v_Link_CloseTable(&stLinkTableOfElementCone);
SCR_fn_v_Link_CloseTable(&stLinkTableOfFaceMapDescriptor);
SCR_fn_v_Link_CloseTable(&stLinkTableOfSprite);
SCR_fn_v_Link_CloseTable(&stLinkTableOfTexture);
SCR_fn_v_Link_CloseTable(&stLinkTableOfVisualMaterial);
SCR_fn_v_Link_CloseTable(&stLinkTableOfFrontierElement);
}
void GLI_vSetValueInLinkTableOfGeometric( char *_p_szKey,unsigned long _ulValue)
{
SCR_fnp_st_Link_SetValue(&stLinkTableOfGeometric,_p_szKey,_ulValue);
}
unsigned long GLI_ulSearchKeyInLinkTableOfGeometric( char *_p_szKey)
{
return SCR_M_ul_Link_GetValue(SCR_fnp_st_Link_SearchKey(&stLinkTableOfGeometric,_p_szKey));
}
char * GLI_p_cSearchValueInLinkTableOfGeometric( unsigned long _ulValue)
{
return SCR_M_p_sz_Link_GetKey(SCR_fnp_st_Link_SearchValue(&stLinkTableOfGeometric,_ulValue));
}

View File

@@ -0,0 +1,103 @@
/*
=======================================================================================
Name : MATBench.c
Author : vincent lhullier Date :27/01/99
Description : Bench function for materials
=======================================================================================
*/
#include "gli_st.h"
#include "MATBench.h"
#ifdef BENCH_MATERIAL
/*
=======================================================================================
Globals
=======================================================================================
*/
static GLI_tdstMaterial *gapst_Material[ 1024 ];
static long gl_NumberOfMaterials = 0;
/*
=======================================================================================
Function
=======================================================================================
*/
void MATBENCH_fn_vAddMaterialRef( GLI_tdstMaterial *_pst_Material )
{
gapst_Material[ gl_NumberOfMaterials++ ] = _pst_Material;
}
void MATBENCH_fn_vDeleteMaterialRef( GLI_tdstMaterial *_pst_Material )
{
long i;
for (i = 0; i < gl_NumberOfMaterials; i++)
{
if ( _pst_Material == gapst_Material[ i ] )
{
memmove( gapst_Material[ i ], gapst_Material[ i + 1 ], (gl_NumberOfMaterials - (i + 1)) * sizeof( GLI_tdstMaterial *) );
gl_NumberOfMaterials--;
return;
}
}
}
void MATBENCH_fn_vWriteMaterialInfoInFile( char *_szTitle )
{
FILE *hpFile;
long i;
char szFileName[ 20 ];
long lScroll, lAnimate;
i = 0;
while(1)
{
sprintf( szFileName, "MatBench%03d.log", i );
if (_access( szFileName, 0 ) != 0)
break;
if (i++ == 1000)
return;
}
if ( (hpFile = fopen( szFileName, "wt" )) == NULL )
return;
fprintf(hpFile, "Material stats : %s, %d materials\r\n\r\n", _szTitle, gl_NumberOfMaterials );
lScroll = lAnimate = 0;
for (i = 0; i < gl_NumberOfMaterials; i++ )
{
fprintf( hpFile, "%08X, %08X, %2d, %2d , %08X %s\r\n",
gapst_Material[i],
gapst_Material[i]->xMaterialType,
gapst_Material[i]->lIncrementIsEnable,
gapst_Material[i]->lNumberOfDisplayNode,
gapst_Material[i]->p_stTexture,
gapst_Material[i]->p_stTexture ? gapst_Material[i]->p_stTexture->a255_cFileName :""
);
if (gapst_Material[i]->lIncrementIsEnable)
lScroll++;
if (gapst_Material[i]->lNumberOfDisplayNode)
lAnimate++;
}
fprintf( hpFile, "\r\n" );
fprintf( hpFile, "Material structure size : %d => %d \r\n", sizeof ( GLI_tdstMaterial ), gl_NumberOfMaterials * sizeof( GLI_tdstMaterial ) );
fprintf( hpFile, "Optimized size = %d\r\n", gl_NumberOfMaterials * 84 + lScroll * 20 + lAnimate * 24 );
gl_NumberOfMaterials = 0;
fclose( hpFile );
}
#endif /* BENCH_MATERIAL */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,132 @@
/*
Tested with LINT
*/
#include "gli_st.h"
#include "matstack.h"
#ifdef __cplusplus
extern "C"
{
#endif
void
GLI_xInitMatrixStack ( void ) /*marc*/
{
ACP_tdxIndex xI;
g_lNbMatrixInStack = 0;
/* POS_fn_vSetIdentityMatrix(&g_aDEF_stMatrixStack [ g_lNbMatrixInStack ]);*/
/* MTH3D_M_vNullVector(&(g_aDEF_stMatrixStack [ g_lNbMatrixInStack ].stTranslationVector));
MTH3D_M_vSetIdentityMatrix(&(g_aDEF_stMatrixStack [ g_lNbMatrixInStack ].stRotationMatrix));
MTH3D_M_vSetIdentityMatrix(&(g_aDEF_stMatrixStack [ g_lNbMatrixInStack ].stTransformMatrix));
g_aDEF_stMatrixStack [ g_lNbMatrixInStack ].ulType = POS_C_ulIdentityMatrixFlag;
*/
/* Initialise all the matrix of the matrix stack before using them*/
for(xI=0;xI<GLI_C_lMaxMatrixInStack;++xI)
{
MTH3D_M_vNullVector(&(g_aDEF_stMatrixStack [ xI ].stTranslationVector));
MTH3D_M_vSetIdentityMatrix(&(g_aDEF_stMatrixStack [ xI ].stRotationMatrix));
MTH3D_M_vSetIdentityMatrix(&(g_aDEF_stMatrixStack [ xI ].stTransformMatrix));
g_aDEF_stMatrixStack [ xI ].ulType = POS_C_ulIdentityMatrixFlag;
/* POS_fn_vSetIdentityMatrix(&g_aDEF_stMatrixStack[xI]);*/
}
g_p_stCurrentMatrix = &g_aDEF_stMatrixStack [ g_lNbMatrixInStack ] ;
g_lNbMatrixInStack ++;
return ;
}
void
GLI_xPushMatrix ( POS_tdstCompletePosition *p_stMatrix )
{
if ( g_lNbMatrixInStack == GLI_C_lMaxMatrixInStack )
return ;
POS_fn_vMulMatrixMatrix ( &g_aDEF_stMatrixStack [ g_lNbMatrixInStack ] ,
&g_aDEF_stMatrixStack [ g_lNbMatrixInStack - 1 ] ,
p_stMatrix ) ;
g_p_stCurrentMatrix = &g_aDEF_stMatrixStack [ g_lNbMatrixInStack ] ;
g_lNbMatrixInStack ++ ;
return ;
}
void
GLI_xPrePushMatrix ( POS_tdstCompletePosition *p_stMatrix )/*NZO*/
{
if ( g_lNbMatrixInStack == GLI_C_lMaxMatrixInStack )
return ;
POS_fn_vMulMatrixMatrix ( &g_aDEF_stMatrixStack [ g_lNbMatrixInStack ] ,
p_stMatrix ,
&g_aDEF_stMatrixStack [ g_lNbMatrixInStack - 1 ] );
g_p_stCurrentMatrix = &g_aDEF_stMatrixStack [ g_lNbMatrixInStack ] ;
g_lNbMatrixInStack ++ ;
return ;
}
void
GLI_xPopMatrix ( void )
{
if ( g_lNbMatrixInStack == 0 )
return ;
g_lNbMatrixInStack -- ;
g_p_stCurrentMatrix = &g_aDEF_stMatrixStack [ g_lNbMatrixInStack ] ;
return ;
}
void
GLI_xLoadMatrix ( POS_tdstCompletePosition *p_stMatrix )
{
if ( g_lNbMatrixInStack == GLI_C_lMaxMatrixInStack )
return ;
g_aDEF_stMatrixStack [ g_lNbMatrixInStack ] = *p_stMatrix ;
g_p_stCurrentMatrix = &g_aDEF_stMatrixStack [ g_lNbMatrixInStack ] ;
g_lNbMatrixInStack ++ ;
return ;
}
void
GLI_xResetMatrixStack ( void )
{
g_lNbMatrixInStack = 0 ;
g_p_stCurrentMatrix = NULL ;
return ;
}
void
GLI_xLoadAndResetMatrix ( POS_tdstCompletePosition *p_stMatrix )
{
GLI_xResetMatrixStack ( ) ;
GLI_xLoadMatrix ( p_stMatrix ) ;
return ;
}
#ifdef __cplusplus
} /*extern "C"*/
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,229 @@
/*
Tested with LINT
*/
#include"gli_st.h"
#include "GLI_Defn.h"
#include "light_st.h"
#include "PvObj_st.h"
#include "PRF.h"
#ifdef __cplusplus
extern "C"
{
#endif
#define GLI_C_fMagicNumber (16384.0f + 8192.0f)
#define M_vComputeMagicColor()\
stTempColor.xR = p_stGP->GLI_stColorsAdd.xR + GLI_C_fMagicNumber;\
stTempColor.xG = p_stGP->GLI_stColorsAdd.xG + GLI_C_fMagicNumber;\
stTempColor.xB = p_stGP->GLI_stColorsAdd.xB + GLI_C_fMagicNumber;\
stTempColor.xA = p_stGP->GLI_stColorsAdd.xA + GLI_C_fMagicNumber;
/*
----------------------------------------------------------------------------------------
Description : compute screen color (not alpha) for some vertices (index of vertices are in list)
Author : Steve McCalla
Optimized : Yes - got rid of almost all branches
----------------------------------------------------------------------------------------
*/
void GLI_vSerialComputeVertexColorIndexedNoAlpha(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGP, ACP_tdxIndex xNumber, ACP_tdxIndex *p_ListOfIndexes)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
unsigned long *p_ulFirstColor;
unsigned long Alpha;
unsigned long ulRed, ulGreen, ulBlue;
GEO_tdstColor stComputedColor,*p_SRCColors;
GEO_tdstColor stTempColor;
ACP_tdxIndex *p_ListOfIndexesLast;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
M_vComputeMagicColor()
p_ListOfIndexesLast = p_ListOfIndexes + xNumber;
p_ulFirstColor = &p_stGP->GLI_ScreenPoint->ulPackedColor;
Alpha = (*((unsigned long *)&stTempColor.xA) & 0x00400000) ? ( (*((unsigned long *)&stTempColor.xA) & 0x0000FF00) ? 0xFF : (*((unsigned long *)&stTempColor.xA) & 0x000000FF) ) : 0;
Alpha <<= 24;
while (p_ListOfIndexes < p_ListOfIndexesLast)
{
p_SRCColors = p_stGP->GLI_aDEF_stColorsRLID + *p_ListOfIndexes;
stComputedColor.xR = p_SRCColors->xR * p_stGP->GLI_stColorsMul.xR + stTempColor.xR ;
stComputedColor.xG = p_SRCColors->xG * p_stGP->GLI_stColorsMul.xG + stTempColor.xG ;
stComputedColor.xB = p_SRCColors->xB * p_stGP->GLI_stColorsMul.xB + stTempColor.xB ;
ulRed = (*((unsigned long *)&stComputedColor.xR) & 0x00400000) ? ( (*((unsigned long *)&stComputedColor.xR) & 0x0000FF00) ? 0xFF0000 : (*((unsigned long *)&stComputedColor.xR) & 0x000000FF)<<16 ) : 0;
ulGreen = (*((unsigned long *)&stComputedColor.xG) & 0x00400000) ? ( (*((unsigned long *)&stComputedColor.xG) & 0x0000FF00) ? 0xFF00 : (*((unsigned long *)&stComputedColor.xG) & 0x000000FF)<<8 ) : 0;
ulBlue = (*((unsigned long *)&stComputedColor.xB) & 0x00400000) ? ( (*((unsigned long *)&stComputedColor.xB) & 0x0000FF00) ? 0xFF : (*((unsigned long *)&stComputedColor.xB) & 0x000000FF) ) : 0;
/* p_ulFirstColor + 4 * index because size of GLI_tdstAligned2DVector is 4*/
*(p_ulFirstColor + ((*p_ListOfIndexes++) << 2)) = Alpha | ulRed | ulGreen | ulBlue;
}
}
/*
----------------------------------------------------------------------------------------
Description : compute screen color (but not alpha) for a number of sequential vertices
Author : Steve McCalla
Optimized : Yes
----------------------------------------------------------------------------------------
*/
void GLI_vSerialComputeVertexColor2NoAlpha(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGP, ACP_tdxIndex xNumber)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
GLI_tdstAligned2DVector *p_Baseu32Colors;
GEO_tdstColor stComputedColor,*p_SRCColors;
GEO_tdstColor stTempColor;
unsigned long ulRed, ulGreen, ulBlue;
unsigned long Alpha;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
M_vComputeMagicColor();
p_Baseu32Colors = (GLI_tdstAligned2DVector *) &p_stGP->GLI_ScreenPoint->ulPackedColor;
p_SRCColors = p_stGP -> GLI_aDEF_stColorsRLID;
Alpha = (*((unsigned long *)&stTempColor.xA) & 0x00400000) ? ( (*((unsigned long *)&stTempColor.xA) & 0x0000FF00) ? 0xFF : (*((unsigned long *)&stTempColor.xA) & 0x000000FF) ) : 0;
Alpha <<= 24;
while (xNumber--)
{
stComputedColor.xR = p_SRCColors->xR * p_stGP->GLI_stColorsMul.xR + stTempColor.xR ;
stComputedColor.xG = p_SRCColors->xG * p_stGP->GLI_stColorsMul.xG + stTempColor.xG ;
stComputedColor.xB = p_SRCColors->xB * p_stGP->GLI_stColorsMul.xB + stTempColor.xB ;
ulBlue = (*((unsigned long *)&stComputedColor.xB) & 0x00400000) ? ( (*((unsigned long *)&stComputedColor.xB) & 0x0000FF00) ? 0xFF : (*((unsigned long *)&stComputedColor.xB) & 0x000000FF) ) : 0;
ulRed = (*((unsigned long *)&stComputedColor.xR) & 0x00400000) ? ( (*((unsigned long *)&stComputedColor.xR) & 0x0000FF00) ? 0xFF0000 : (*((unsigned long *)&stComputedColor.xR) & 0x000000FF)<<16 ) : 0;
ulGreen = (*((unsigned long *)&stComputedColor.xG) & 0x00400000) ? ( (*((unsigned long *)&stComputedColor.xG) & 0x0000FF00) ? 0xFF00 : (*((unsigned long *)&stComputedColor.xG) & 0x000000FF)<<8 ) : 0;
*(long *) p_Baseu32Colors++ = Alpha | ulRed | ulGreen | ulBlue;
p_SRCColors++;
}
}
/*
----------------------------------------------------------------------------------------
Description : compute screen color for all vertex when Light is alpha sensitive
Author : Steve McCalla
Optimized : Yes
----------------------------------------------------------------------------------------
*/
void GLI_vSerialComputeVertexColorIndexedAlpha(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGP, ACP_tdxIndex xNumber, ACP_tdxIndex *p_ListOfIndexes)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
unsigned long *p_Baseu32Colors;
GEO_tdstColor stTempColor, stComputedColor;
unsigned long ulTmpColor;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
M_vComputeMagicColor();
while (xNumber--)
{
p_Baseu32Colors = &(p_stGP->GLI_ScreenPoint + *p_ListOfIndexes)->ulPackedColor;
ulTmpColor = 0;
stComputedColor.xR = (p_stGP -> GLI_aDEF_stColorsRLID + (*p_ListOfIndexes)) -> xR * p_stGP -> GLI_stColorsMul . xR + stTempColor.xR;
stComputedColor.xG = (p_stGP -> GLI_aDEF_stColorsRLID + (*p_ListOfIndexes)) -> xG * p_stGP -> GLI_stColorsMul . xG + stTempColor.xG ;
stComputedColor.xB = (p_stGP -> GLI_aDEF_stColorsRLID + (*p_ListOfIndexes)) -> xB * p_stGP -> GLI_stColorsMul . xB + stTempColor.xB;
stComputedColor.xA = (p_stGP -> GLI_aDEF_stColorsRLID + (*p_ListOfIndexes)) -> xA * p_stGP -> GLI_stColorsMul . xA + stTempColor.xA ;
if (*((long *)&stComputedColor.xR) & 0x00400000)
{
if (*((unsigned long *)&stComputedColor.xR) & 0x0000FF00)
ulTmpColor |= 0x00FF0000;
else
ulTmpColor |= (*((unsigned long *)&stComputedColor.xR) & 0x000000FF) << 16;
}
if (*((long *)&stComputedColor.xG) & 0x00400000)
{
if (*((unsigned long *)&stComputedColor.xG) & 0x0000FF00)
ulTmpColor |= 0x0000FF00;
else
ulTmpColor |= (*((unsigned long *)&stComputedColor.xG) & 0x000000FF) << 8;
}
if (*((long *)&stComputedColor.xB) & 0x00400000)
{
if (*((unsigned long *)&stComputedColor.xB) & 0x0000FF00)
ulTmpColor |= 0x000000FF;
else
ulTmpColor |= (*((unsigned long *)&stComputedColor.xB) & 0x000000FF) ;
}
if (*((long *)&stComputedColor.xA) & 0x00400000)
{
if (*((unsigned long *)&stComputedColor.xA) & 0x0000FF00)
ulTmpColor |= 0xFF000000;
else
ulTmpColor |= (*((unsigned long *)&stComputedColor.xA) & 0x000000FF) << 24;
}
*p_Baseu32Colors = ulTmpColor;
p_ListOfIndexes++;
}
}
/*
----------------------------------------------------------------------------------------
Description : compute screen color for all vertex when Light is alpha sensitive
Author : Steve McCalla
Optimized : No (not called very often)
----------------------------------------------------------------------------------------
*/
void GLI_vSerialComputeVertexColor2Alpha(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGP, ACP_tdxIndex xNumber)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
GLI_tdstAligned2DVector *p_Baseu32Colors;
GEO_tdstColor stTempColor ,stComputedColor,*p_SRCColors;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
M_vComputeMagicColor();
p_Baseu32Colors = p_stGP->GLI_ScreenPoint;
p_SRCColors = p_stGP -> GLI_aDEF_stColorsRLID;
while (xNumber--)
{
p_Baseu32Colors->ulPackedColor = 0;
stComputedColor.xR = (p_SRCColors) ->xR * p_stGP->GLI_stColorsMul.xR + stTempColor.xR;
stComputedColor.xG = (p_SRCColors) ->xG * p_stGP->GLI_stColorsMul.xG + stTempColor.xG;
stComputedColor.xB = (p_SRCColors) ->xB * p_stGP->GLI_stColorsMul.xB + stTempColor.xB;
stComputedColor.xA = (p_SRCColors++)->xA * p_stGP->GLI_stColorsMul.xA + stTempColor.xA;
if (*((long *)&stComputedColor.xR) & 0x00400000)
{
if (*((unsigned long *)&stComputedColor.xR) & 0x0000FF00)
p_Baseu32Colors->ulPackedColor |= 0x00FF0000;
else
p_Baseu32Colors->ulPackedColor |= (*((unsigned long *)&stComputedColor.xR) & 0x000000FF) << 16;
}
if (*((long *)&stComputedColor.xG) & 0x00400000)
{
if (*((unsigned long *)&stComputedColor.xG) & 0x0000FF00)
p_Baseu32Colors->ulPackedColor |= 0x0000FF00;
else
p_Baseu32Colors->ulPackedColor |= (*((unsigned long *)&stComputedColor.xG) & 0x000000FF) << 8;
}
if (*((long *)&stComputedColor.xB) & 0x00400000)
{
if (*((unsigned long *)&stComputedColor.xB) & 0x0000FF00)
p_Baseu32Colors->ulPackedColor |= 0x000000FF;
else
p_Baseu32Colors->ulPackedColor |= (*((unsigned long *)&stComputedColor.xB) & 0x000000FF) ;
}
if (*((long *)&stComputedColor.xA) & 0x00400000)
{
if (*((unsigned long *)&stComputedColor.xA) & 0x0000FF00)
p_Baseu32Colors->ulPackedColor |= 0xFF000000;
else
p_Baseu32Colors->ulPackedColor |= (*((unsigned long *)&stComputedColor.xA) & 0x000000FF) << 24;
}
p_Baseu32Colors++;
}
}
#ifdef __cplusplus
}/* extern "C" */
#endif

View File

@@ -0,0 +1,211 @@
/*
Tested with LINT
*/
#include"gli_st.h"
#include "GLI_Defn.h"
#include "light_st.h"
#include "PvObj_st.h"
#include "proj.h"
#include "camera.h"
tdstGlobalsProjection stProjGlobs;
#ifdef __cplusplus
extern "C"
{
#endif
/**********************************************************************************************/
/* Name: GLI_xSerialProjectionNoTrans 1.1 */
/* Goal: Perspective Project a list of 3d vertex with no translation - for sprites*/
/* Code: Elie Khoury / 1.0*/
/* Philippe Vimont / 1.1 -> ASSEMBLY CODE*/
/* Steve McCalla / 1.2 -> No Trans, no isometric cameras*/
/* OPTIMMIZED : */
/**********************************************************************************************/
void
GLI_xSerialProjectionNoTrans ( GLI_tdstCamera *p_stCam ,
long lNbOfVertex ,
GLI_tdstAligned3DVector *p_stSource ,
GLI_tdstAligned2DVector *p_stDest )
{
GLI_tdxValue xInterm ;
long lNewX;
GLI_tdstAligned2DVector *p_stDestLast;
p_stDestLast = p_stDest + lNbOfVertex;
*(float * )&lNewX = 8000.0f;
assert(p_stCam -> lCameraMode == GLI_C_lPersCamWithoutDistorsion
|| p_stCam -> lCameraMode == GLI_C_lPersCamWithDistorsion);
for ( ; p_stDest < p_stDestLast ; p_stSource++ ,p_stDest++)
{
if ( *(long *)&p_stSource->xZ < *(long *)&p_stCam -> xNear )
{
*(long *)&p_stDest -> xOoZ |= 0x80000000;
*((unsigned long *)&p_stDest->xX) = lNewX | ((*((unsigned long *)&p_stSource->xX) & 0x80000000) ^ 0x80000000);
*((unsigned long *)&p_stDest->xY) = lNewX | ((*((unsigned long *)&p_stSource->xY) & 0x80000000) ^ 0x80000000);
continue ;
}
p_stDest -> xOoZ = MTH_M_xInvLow((float)p_stSource -> xZ ) ;
xInterm = p_stCam -> xScreen * p_stDest -> xOoZ ;
p_stDest -> xOoZ *= GLI_C_xZClippingNear /*(float)p_stCam -> xNear*/ ;
p_stDest -> xX = p_stSource -> xX * p_stCam -> stScale . xX * xInterm ;
p_stDest -> xY = p_stSource -> xY * p_stCam -> stScale . xY * xInterm ;
}
return;
}
/**********************************************************************************************/
/* Name: GLI_xSerialProjection 1.1 */
/* Goal: Project a list of 3d vertex*/
/* Code: Elie Khoury / 1.0*/
/* Philippe Vimont / 1.1 -> ASSEMBLY CODE*/
/* OPTIMMIZED : */
/**********************************************************************************************/
void
GLI_xSerialProjection ( GLI_tdstCamera *p_stCam ,
long lNbOfVertex ,
GLI_tdstAligned3DVector *p_stSource ,
GLI_tdstAligned2DVector *p_stDest )
{
GLI_tdxValue xInterm ;
long lVertexIndex , lNewX;
GLI_tdstAligned2DVector *p_stDestLast;
p_stDestLast = p_stDest + lNbOfVertex;
*(float * )&lNewX = 8000.0f;
switch ( p_stCam -> lCameraMode )
{
case GLI_C_lPersCamWithDistorsion :
case GLI_C_lPersCamWithoutDistorsion :
for ( ; p_stDest < p_stDestLast ; p_stSource++ ,p_stDest++)
{
if ( *(long *)&p_stSource->xZ < *(long *)&p_stCam->xNear )
{
*(long *)&p_stDest -> xOoZ |= 0x80000000;
*((unsigned long *)&p_stDest->xX) = lNewX | ((*((unsigned long *)&p_stSource->xX) & 0x80000000) ^ 0x80000000);
*((unsigned long *)&p_stDest->xY) = lNewX | ((*((unsigned long *)&p_stSource->xY) & 0x80000000) ^ 0x80000000);
continue ;
}
p_stDest -> xOoZ = MTH_M_xInvLow((float)p_stSource -> xZ ) ;
xInterm = p_stCam -> xScreen * p_stDest -> xOoZ ;
p_stDest -> xOoZ *= GLI_C_xZClippingNear /*(float)p_stCam -> xNear*/ ;
p_stDest -> xX = p_stCam -> stTrans . xX + p_stSource -> xX * p_stCam -> stScale . xX * xInterm ;
p_stDest -> xY = p_stCam -> stTrans . xY + p_stSource -> xY * p_stCam -> stScale . xY * xInterm ;
} /* */
break ;
case GLI_C_lIsoCamWithDistorsion :
case GLI_C_lIsoCamWithoutDistorsion :
for ( lVertexIndex = 0 ; lVertexIndex < lNbOfVertex ; lVertexIndex ++ )
{
/**** NO PROJECTION IF THE POINT IS BEFORE NEAR PLAN ****/
if ( p_stSource[lVertexIndex].xZ < p_stCam -> xNear )
continue ;
p_stDest[lVertexIndex].xOoZ =1.0f;
p_stDest[lVertexIndex].xX =
MTH_M_xRealToFloat(
GLI_M_Add ( p_stCam -> stTrans . xX ,
GLI_M_Mul ( p_stSource[lVertexIndex] . xX ,
p_stCam -> stScale . xX ) ) ) ;
p_stDest[lVertexIndex].xY =
MTH_M_xRealToFloat(
GLI_M_Add ( p_stCam -> stTrans . xY ,
GLI_M_Mul ( p_stSource[lVertexIndex] . xY ,
p_stCam -> stScale . xY ) ) ) ;
}
break ;
}
return ;
}
/**********************************************************************************************/
/* Name: GLI_xProjection 1.0*/
/* Goal: Project a 3d vertex*/
/* Code: Elie Khoury / 1.0*/
/* OPTIMMIZED : unused*/
/**********************************************************************************************/
void
GLI_xProjection ( GLI_tdstCamera *p_stCam ,
MTH3D_tdstVector *p_stSource ,
GLI_tdst2DVertex *p_stDest )
{
float xInterm ;
switch ( p_stCam -> lCameraMode )
{
case GLI_C_lPersCamWithDistorsion :
case GLI_C_lPersCamWithoutDistorsion :
/**** NO PROJECTION IF THE POINT IS BEFORE NEAR PLAN ****/
if ( p_stSource -> xZ < p_stCam -> xNear )
return ;
p_stDest -> xOoZ = MTH_M_xInvLow((float) p_stSource -> xZ ) ;
xInterm = p_stCam -> xScreen * p_stDest -> xOoZ ;
p_stDest -> xOoZ *= GLI_C_xZClippingNear /*(float)p_stCam -> xNear*/ ;
p_stDest -> xX = p_stCam -> stTrans . xX + p_stSource -> xX * p_stCam -> stScale . xX * xInterm ;
p_stDest -> xY = p_stCam -> stTrans . xY + p_stSource -> xY * p_stCam -> stScale . xY * xInterm ;
break ;
case GLI_C_lIsoCamWithDistorsion :
case GLI_C_lIsoCamWithoutDistorsion :
/**** NO PROJECTION IF THE POINT IS BEFORE NEAR PLAN ****/
if ( p_stSource -> xZ < p_stCam -> xNear )
return ;
p_stDest -> xOoZ = 1.0f;
p_stDest -> xX
=
MTH_M_xRealToFloat(
GLI_M_Add ( p_stCam -> stTrans . xX ,
GLI_M_Mul ( p_stSource -> xX ,
p_stCam -> stScale . xX ) ) ) ;
p_stDest -> xY
=
MTH_M_xRealToFloat(
GLI_M_Add ( p_stCam -> stTrans . xY ,
GLI_M_Mul ( p_stSource -> xY ,
p_stCam -> stScale . xY ) ) ) ;
break ;
}
return ;
}
/**********************************************************************************************/
/* Name: GLI_vInit_Projections*/
/* Goal: Init a table for f(x) = 1/x;*/
/* Code: Philippe Vimont / 1.0*/
/* OPTIMMIZED : No*/
/**********************************************************************************************/
void
GLI_vInit_Projections()
{
ACP_tdxIndex xZcounter;
long *p_lZAdjust;
for (xZcounter = 0 ; xZcounter < 1024 ; xZcounter ++)
{
stProjGlobs.xOoXTable[xZcounter] =(1.0f) / ((float)( xZcounter +1024 ) * 1024.0f );
}
p_lZAdjust = (long *) stProjGlobs.xOoXTable;
for (xZcounter = 0 ; xZcounter < 1024 ; xZcounter++, p_lZAdjust++ )
{
*(p_lZAdjust) = *(p_lZAdjust) + 0x49800000;
}
}
#ifdef __cplusplus
}/* extern "C" */
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,204 @@
/*
=======================================================================================
Name : TexArray.c
Author : Gliglou corporation
Description : manage array of texture data
=======================================================================================
*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include "PvObj_st.h"
#include "texture.h"
#include "TEX.h"
#include "DLLInter.h"
#include "TexArray.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
=======================================================================================
Globals
=======================================================================================
*/
/*
* memory
*/
extern unsigned long GLI_gsCurrentMemoryChannel;
/*
* array of texture / texture state
*/
GLI_tdstTexture * gs_aDEFTableOfTextureAlreadyRead [ GLI_C_lNBMaxOfTextures ];
long gs_aDEFTableOfTextureMemoryChannels[ GLI_C_lNBMaxOfTextures ];
unsigned long GLI_g_ulNumberOfLoadedTexture;
long gs_lNumberOfTextureToCreate;
/*
=======================================================================================
functions
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : set all texture in given channel as unallocated
(called when memory block is freed )
----------------------------------------------------------------------------------------
*/
void GLI_fn_vUnallocTextureInChannel( unsigned char _ucChannel )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long lTextureCounter;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
for (lTextureCounter=0;lTextureCounter<GLI_C_lNBMaxOfTextures;lTextureCounter++)
{
if (gs_aDEFTableOfTextureMemoryChannels[lTextureCounter] == (long)_ucChannel )
{
gs_aDEFTableOfTextureMemoryChannels[lTextureCounter] = GLI_TEXIsUnallocated;
gs_aDEFTableOfTextureAlreadyRead[lTextureCounter] = NULL;
}
}
}
/*
----------------------------------------------------------------------------------------
Description : set all texture as unallocated
----------------------------------------------------------------------------------------
*/
void GLI_fn_vUnallocAllTextures( void )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long lTextureCounter;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
for (lTextureCounter=0;lTextureCounter<GLI_C_lNBMaxOfTextures;lTextureCounter++)
{
gs_aDEFTableOfTextureMemoryChannels[lTextureCounter] = GLI_TEXIsUnallocated;
gs_aDEFTableOfTextureAlreadyRead[lTextureCounter] = NULL;
}
}
/*
----------------------------------------------------------------------------------------
Description : compute total of memory taken by texture allocated in array
----------------------------------------------------------------------------------------
*/
long GLI_lComputeTexturesSize()
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long lTotalSize,lTextureCounter;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
lTotalSize = 0;
for (lTextureCounter = 0 ; lTextureCounter < GLI_C_lNBMaxOfTextures ; lTextureCounter ++ )
{
if ((gs_aDEFTableOfTextureMemoryChannels[lTextureCounter] != GLI_TEXIsUnallocated) && (gs_aDEFTableOfTextureAlreadyRead[lTextureCounter] != NULL))
/*lTotalSize += GLI_lGetSizeOfTexture (gs_aDEFTableOfTextureAlreadyRead [lTextureCounter]);*/
lTotalSize += GLI_DRV_lGetTextureSize( gs_aDEFTableOfTextureAlreadyRead [lTextureCounter] );
}
return lTotalSize ;
}
/*
----------------------------------------------------------------------------------------
Description : Get larger texture
----------------------------------------------------------------------------------------
*/
long GLI_lGetBigestSizeOfTexture()
{
long lBigestSize,lSizeLocal;
long lTextureCounter;
for (lTextureCounter=0,lBigestSize = 0; lTextureCounter < GLI_C_lNBMaxOfTextures; lTextureCounter++)
{
if ( (gs_aDEFTableOfTextureMemoryChannels[lTextureCounter] != GLI_TEXIsUnallocated) && (gs_aDEFTableOfTextureAlreadyRead [lTextureCounter]) )
{
lSizeLocal = gs_aDEFTableOfTextureAlreadyRead [lTextureCounter] -> lRealHeight * gs_aDEFTableOfTextureAlreadyRead [lTextureCounter] -> lRealWidth * 6L;
/* Special for texture maa: they have double height */
if( gs_aDEFTableOfTextureAlreadyRead [lTextureCounter] -> lTextureCaps & GLI_C_lMAATexture )
lSizeLocal *= 2;
if (lBigestSize < lSizeLocal) lBigestSize = lSizeLocal;
}
}
return (lBigestSize);
}
/*
----------------------------------------------------------------------------------------
Description : uncompress textures
void ->
Returns (void )
----------------------------------------------------------------------------------------
*/
void GLI_vUnCompressExistantTexture(void)
{
long lTextureCounter ;
for (lTextureCounter =0 ; lTextureCounter < GLI_C_lNBMaxOfTextures ; lTextureCounter ++)
{
if ( (gs_aDEFTableOfTextureMemoryChannels[lTextureCounter] != GLI_TEXIsUnallocated) && (gs_aDEFTableOfTextureAlreadyRead[lTextureCounter] != NULL))
{
gs_aDEFTableOfTextureAlreadyRead [ lTextureCounter ] -> lHeight = gs_aDEFTableOfTextureAlreadyRead [ lTextureCounter ] -> lRealHeight ;
gs_aDEFTableOfTextureAlreadyRead [ lTextureCounter ] -> lWidth = gs_aDEFTableOfTextureAlreadyRead [ lTextureCounter ] -> lRealWidth ;
gs_aDEFTableOfTextureAlreadyRead [ lTextureCounter ] -> lCompressionCounter = 0;
}
}
}
/*
----------------------------------------------------------------------------------------
Description : look throught the table to know if a texture alreqdy exist
----------------------------------------------------------------------------------------
*/
GLI_tdstTexture *TEX_fnpst_DoesTextureExist( char *_szFileName )
{
long lTextureCounter;
GLI_tdstTexture *pst_Texture;
for (lTextureCounter =0 ; lTextureCounter < GLI_C_lNBMaxOfTextures; lTextureCounter ++)
{
if (gs_aDEFTableOfTextureMemoryChannels[ lTextureCounter ] != GLI_TEXIsUnallocated)
{
pst_Texture = gs_aDEFTableOfTextureAlreadyRead [lTextureCounter];
if (strcmp( pst_Texture->a255_cFileName, _szFileName ) == 0)
return pst_Texture;
}
}
return NULL;
};
/*
----------------------------------------------------------------------------------------
Description : add the picture name in the tree
----------------------------------------------------------------------------------------
*/
void TEX_fnv_MakeItExisting( GLI_tdstTexture *_pst_TextureCreated )
{
/* add texture in array */
gs_aDEFTableOfTextureAlreadyRead [ gs_lNumberOfTextureToCreate ] = _pst_TextureCreated;
gs_aDEFTableOfTextureMemoryChannels[ gs_lNumberOfTextureToCreate ] = GLI_gsCurrentMemoryChannel;
gs_lNumberOfTextureToCreate++;
while (
(gs_aDEFTableOfTextureMemoryChannels[gs_lNumberOfTextureToCreate] != GLI_TEXIsUnallocated) &&
(gs_lNumberOfTextureToCreate < GLI_C_lNBMaxOfTextures -1 )
)
gs_lNumberOfTextureToCreate++;
/* we are in the end of arrays, come back to beginning to fill hole */
if (gs_lNumberOfTextureToCreate == GLI_C_lNBMaxOfTextures -1 )
{
gs_lNumberOfTextureToCreate = 0;
while (
( gs_aDEFTableOfTextureMemoryChannels[gs_lNumberOfTextureToCreate] != GLI_TEXIsUnallocated) &&
( gs_lNumberOfTextureToCreate < GLI_C_lNBMaxOfTextures - 1 )
)
gs_lNumberOfTextureToCreate++;
}
}

View File

@@ -0,0 +1,317 @@
/*
=======================================================================================
Name : TexBench.c
Author : vincent lhullier Date :25/11/98
Description : Bench function for texture
=======================================================================================
*/
#include "texbench.h"
#ifdef BENCH_TEXTURE
#include "gli_st.h"
#include "GLI_Defn.h"
#include "light_st.h"
#include "PvObj_st.h"
#include "texture.h"
#include "TEX.h"
#include "texbench.h"
#include "texarray.h"
/*
=======================================================================================
Structure and timer functions
=======================================================================================
*/
typedef struct TEXBENCH_st_Timer_
{
u_long ulLow;
u_long ulHigh;
} TEXBENCH_st_Timer;
#define RDTSC __asm _emit 0x0F __asm _emit 0x31
void TEXBENCH_fnv_ReadPentiumCounter( TEXBENCH_st_Timer *p_stTimerCount)
{
__asm
{
RDTSC
mov ebx,dword ptr p_stTimerCount
mov [ebx],eax
mov [ebx+4],edx
}
}
/*
----------------------------------------------------------------------------------------
Description : substract two timer
tr -> result = t1 - t2 (t1 > t2)
----------------------------------------------------------------------------------------
*/
void TEXBENCH_fnv_Diff( TEXBENCH_st_Timer *tr, TEXBENCH_st_Timer *t1, TEXBENCH_st_Timer *t2 )
{
tr->ulHigh = t1->ulHigh - t2->ulHigh;
if (t1->ulLow >= t2->ulLow )
{
tr->ulLow = t1->ulLow - t2->ulLow;
}
else
{
tr->ulHigh--;
tr->ulLow = 0xFFFFFFFF - (t2->ulLow - t1->ulLow - 1);
}
}
/*
=======================================================================================
Globals
=======================================================================================
*/
#define TEXBENCH_C_cComputedSize 0
#define TEXBENCH_C_cRealSize 1
#define TEXBENCH_C_cSizeLogFileName "TextureSize"
/*
* array of texture size
*/
long g_a_lTextureSize[2][ GLI_C_lNBMaxOfTextures ];
/*
* Timer
*/
TEXBENCH_st_Timer TEXBENCH_gast_Timer[ 16 ];
TEXBENCH_st_Timer TEXBENCH_gaast_TextureTimer[ 8 ][ GLI_C_lNBMaxOfTextures ];
/*
=======================================================================================
Functions
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : Init
----------------------------------------------------------------------------------------
*/
void TEXBENCH_fn_vSetTime( char _cFor )
{
TEXBENCH_fnv_ReadPentiumCounter( &TEXBENCH_gast_Timer[ _cFor ] );
}
/*
----------------------------------------------------------------------------------------
Description : Init
----------------------------------------------------------------------------------------
*/
void TEXBENCH_fn_vInitTextureSize( void )
{
memset( g_a_lTextureSize, 0, sizeof (g_a_lTextureSize) );
memset( TEXBENCH_gast_Timer, 0, sizeof (TEXBENCH_gast_Timer) );
}
/*
----------------------------------------------------------------------------------------
Description : Set size of a texture given by it's index
----------------------------------------------------------------------------------------
*/
void TEXBENCH_fn_vSetTextureSizeWithIndex( long _lTextureIndex, char _cSizeType, long _lSize )
{
g_a_lTextureSize[ _cSizeType ][ _lTextureIndex ] = _lSize;
}
/*
----------------------------------------------------------------------------------------
Description : Set size of a texture given by data pointer
----------------------------------------------------------------------------------------
*/
void TEXBENCH_fn_vSetTextureSize( GLI_tdstTexture *_p_stTexture, char _cSizeType, long _lSize )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long lTexture;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
* special for timer set calling from DLL
*/
if (_p_stTexture == NULL)
{
TEXBENCH_fnv_ReadPentiumCounter( &TEXBENCH_gaast_TextureTimer[ _cSizeType ][ _lSize ] );
return;
}
for (lTexture = 0; lTexture < GLI_C_lNBMaxOfTextures; lTexture++)
{
if (_p_stTexture == gs_aDEFTableOfTextureAlreadyRead[ lTexture ] )
{
TEXBENCH_fn_vSetTextureSizeWithIndex( lTexture, _cSizeType, _lSize );
return;
}
}
}
/*
----------------------------------------------------------------------------------------
Description : write info in log file
----------------------------------------------------------------------------------------
*/
void TEXBENCH_fn_vWriteSizeInFile( void )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
char szFileName[ _MAX_PATH ];
long lFileIndex = 0;
FILE *hpFile;
long lTexture;
GLI_tdstTexture **pp_stTexture;
long a_lTotal[2];
long lDiff, lTotalDiff;
long lBitmapSize, lSize, lLod;
long lNumberOfStructureAllocated;
BOOL bTwice;
long lStringSize = 0;
TEXBENCH_st_Timer stDiff;
unsigned long a_ulTimeTotal[ 7 ];
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
while(1)
{
CreateDirectory( "log", NULL );
sprintf( szFileName, "log\\%s%03d.log", TEXBENCH_C_cSizeLogFileName, lFileIndex );
if (_access( szFileName, 0 ) != 0)
break;
lFileIndex++;
if (lFileIndex == 1000)
return;
}
hpFile = fopen( szFileName, "wt" );
fprintf(hpFile, "Texture size result\n\n" );
pp_stTexture = gs_aDEFTableOfTextureAlreadyRead;
lTotalDiff = a_lTotal[0] = a_lTotal[1] = 0;
lNumberOfStructureAllocated = 0;
for (lTexture = 0; lTexture < GLI_C_lNBMaxOfTextures; lTexture++, pp_stTexture++)
{
if (*pp_stTexture == NULL)
continue;
{
long lT2;
GLI_tdstTexture **pp_stT2;
bTwice = 0;
pp_stT2 = gs_aDEFTableOfTextureAlreadyRead;
for (lT2 = 0; lT2 < GLI_C_lNBMaxOfTextures; lT2++, pp_stT2++)
{
if (*pp_stT2 == NULL)
continue;
if (*pp_stT2 == *pp_stTexture)
continue;
if (strcmp( (*pp_stT2)->a255_cFileName, (*pp_stTexture)->a255_cFileName) == 0 )
{
bTwice = 1;
break;
}
}
}
lDiff = g_a_lTextureSize[0][lTexture] - g_a_lTextureSize[1][lTexture];
lTotalDiff += lDiff;
lBitmapSize = (*pp_stTexture)->lWidth * (*pp_stTexture)->lHeight;
if ( !( (*pp_stTexture)->lTextureCaps & GLI_C_lPaletteTexture ) )
lBitmapSize <<= 1;
lSize = lBitmapSize;
for (lLod = 0; lLod < (*pp_stTexture)->lNumberOfLod; lLod++)
{
lBitmapSize >>= 2;
lSize += lBitmapSize;
}
fprintf( hpFile, "%4d - %6d - %6d - %4d - %6d (%3d-%3d %8X %d) %s %s\n",
lTexture, g_a_lTextureSize[0][lTexture], g_a_lTextureSize[1][lTexture], lDiff, lSize,
(*pp_stTexture)->lWidth, (*pp_stTexture)->lHeight, (*pp_stTexture)->lTextureCaps, (*pp_stTexture)->lNumberOfLod,
bTwice ? "*" : " ", (*pp_stTexture)->a255_cFileName );
a_lTotal[0] += g_a_lTextureSize[0][lTexture];
a_lTotal[1] += g_a_lTextureSize[1][lTexture];
lNumberOfStructureAllocated++;
lStringSize += strlen((*pp_stTexture)->a255_cFileName) + 1;
/*
for ( pTextureLod = (*pp_stTexture)->p_NextLodOfTexture; pTextureLod != NULL; pTextureLod = pTextureLod->p_NextLodOfTexture )
lNumberOfStructureAllocated++;
*/
}
fprintf( hpFile,"\ntotal : %d - %d - %d\n", a_lTotal[0], a_lTotal[1], lTotalDiff );
fprintf( hpFile,"\nNumber of texture structure allocated : %d (size of one is %d => total size = %d)", lNumberOfStructureAllocated, sizeof( GLI_tdstTexture ), lNumberOfStructureAllocated * sizeof( GLI_tdstTexture ) );
fprintf( hpFile,"\nSize of memory taken by texture name : %d", lStringSize );
fprintf( hpFile,"\n\nTime taken (in cycles)\n" );
TEXBENCH_fnv_Diff( &stDiff, &TEXBENCH_gast_Timer[1], &TEXBENCH_gast_Timer[0] );
fprintf( hpFile,"Unload -> (%d,%d)\n",stDiff.ulHigh, stDiff.ulLow);
TEXBENCH_fnv_Diff( &stDiff, &TEXBENCH_gast_Timer[3], &TEXBENCH_gast_Timer[2] );
fprintf( hpFile,"Uncompress -> (%d,%d)\n",stDiff.ulHigh, stDiff.ulLow);
TEXBENCH_fnv_Diff( &stDiff, &TEXBENCH_gast_Timer[5], &TEXBENCH_gast_Timer[4] );
fprintf( hpFile,"Compression -> (%d,%d)\n",stDiff.ulHigh, stDiff.ulLow);
TEXBENCH_fnv_Diff( &stDiff, &TEXBENCH_gast_Timer[7], &TEXBENCH_gast_Timer[6] );
fprintf( hpFile,"Compute lod -> (%d,%d)\n",stDiff.ulHigh, stDiff.ulLow);
TEXBENCH_fnv_Diff( &stDiff, &TEXBENCH_gast_Timer[9], &TEXBENCH_gast_Timer[8] );
fprintf( hpFile,"Download -> (%d,%d)\n",stDiff.ulHigh, stDiff.ulLow);
TEXBENCH_fnv_Diff( &stDiff, &TEXBENCH_gast_Timer[11], &TEXBENCH_gast_Timer[10] );
fprintf( hpFile," part1 -> (%d,%d)\n",stDiff.ulHigh, stDiff.ulLow);
TEXBENCH_fnv_Diff( &stDiff, &TEXBENCH_gast_Timer[13], &TEXBENCH_gast_Timer[12] );
fprintf( hpFile," part2 -> (%d,%d)\n",stDiff.ulHigh, stDiff.ulLow);
TEXBENCH_fnv_Diff( &stDiff, &TEXBENCH_gast_Timer[15], &TEXBENCH_gast_Timer[14] );
fprintf( hpFile," part3 -> (%d,%d)\n",stDiff.ulHigh, stDiff.ulLow);
/*
* time for each texture
*/
fprintf( hpFile,"\n\nTime taken by each texture for download (in cycles)\n" );
pp_stTexture = gs_aDEFTableOfTextureAlreadyRead;
memset( a_ulTimeTotal, 0, sizeof(a_ulTimeTotal) );
for (lTexture = 0; lTexture < GLI_C_lNBMaxOfTextures; lTexture++, pp_stTexture++)
{
if (*pp_stTexture == NULL)
continue;
fprintf( hpFile,"%4d ", lTexture );
TEXBENCH_fnv_Diff( &stDiff, &TEXBENCH_gaast_TextureTimer[1][lTexture], &TEXBENCH_gaast_TextureTimer[0][lTexture] );
a_ulTimeTotal[ 0 ] += stDiff.ulLow;
fprintf( hpFile,"%10d ", stDiff.ulLow);
TEXBENCH_fnv_Diff( &stDiff, &TEXBENCH_gaast_TextureTimer[2][lTexture], &TEXBENCH_gaast_TextureTimer[1][lTexture] );
a_ulTimeTotal[ 1 ] += stDiff.ulLow;
fprintf( hpFile,"%10d ", stDiff.ulLow);
TEXBENCH_fnv_Diff( &stDiff, &TEXBENCH_gaast_TextureTimer[3][lTexture], &TEXBENCH_gaast_TextureTimer[2][lTexture] );
a_ulTimeTotal[ 2 ] += stDiff.ulLow;
fprintf( hpFile,"%10d ", stDiff.ulLow);
TEXBENCH_fnv_Diff( &stDiff, &TEXBENCH_gaast_TextureTimer[4][lTexture], &TEXBENCH_gaast_TextureTimer[3][lTexture] );
a_ulTimeTotal[ 3 ] += stDiff.ulLow;
fprintf( hpFile,"%10d ", stDiff.ulLow);
TEXBENCH_fnv_Diff( &stDiff, &TEXBENCH_gaast_TextureTimer[5][lTexture], &TEXBENCH_gaast_TextureTimer[4][lTexture] );
a_ulTimeTotal[ 4 ] += stDiff.ulLow;
fprintf( hpFile,"%10d", stDiff.ulLow);
TEXBENCH_fnv_Diff( &stDiff, &TEXBENCH_gaast_TextureTimer[6][lTexture], &TEXBENCH_gaast_TextureTimer[5][lTexture] );
a_ulTimeTotal[ 5 ] += stDiff.ulLow;
fprintf( hpFile,"%10d", stDiff.ulLow);
TEXBENCH_fnv_Diff( &stDiff, &TEXBENCH_gaast_TextureTimer[7][lTexture], &TEXBENCH_gaast_TextureTimer[6][lTexture] );
a_ulTimeTotal[ 6 ] += stDiff.ulLow;
fprintf( hpFile,"%10d\n", stDiff.ulLow);
}
fprintf( hpFile, "\nsum = %10d %10d %10d %10d %10d %10d %10d\n", a_ulTimeTotal[ 0 ], a_ulTimeTotal[ 1 ], a_ulTimeTotal[ 2 ], a_ulTimeTotal[ 3 ], a_ulTimeTotal[ 4 ], a_ulTimeTotal[ 5 ], a_ulTimeTotal[ 6 ] );
fclose( hpFile );
}
#endif

View File

@@ -0,0 +1,186 @@
/*
=======================================================================================
Name : TexCompress.c
Author : Gliglou Corporation
Description : compression of textures
=======================================================================================
*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include "PvObj_st.h"
#include "texture.h"
#include "TEX.h"
#include "DLLInter.h"
#include "DLLCaps.h"
#include "TexArray.h"
#include "prf.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
----------------------------------------------------------------------------------------
Description : compress texture width
----------------------------------------------------------------------------------------
*/
long GLI_lCompressTexturesSizeInX(struct GLI_tdstTexture_ *p_stTexture)
{
long lTextureSizeBefore;
lTextureSizeBefore = GLI_DRV_lGetTextureSize(p_stTexture);
p_stTexture -> lWidth >>= 1;
return ( lTextureSizeBefore - GLI_DRV_lGetTextureSize(p_stTexture));
}
/*
----------------------------------------------------------------------------------------
Description : compress texture height
----------------------------------------------------------------------------------------
*/
long GLI_lCompressTexturesSizeInY(struct GLI_tdstTexture_ *p_stTexture)
{
long lTextureSizeBefore;
lTextureSizeBefore = GLI_DRV_lGetTextureSize(p_stTexture);
p_stTexture -> lHeight >>= 1;
return ( lTextureSizeBefore - GLI_DRV_lGetTextureSize(p_stTexture));
}
/*
----------------------------------------------------------------------------------------
Description : compress texture size
----------------------------------------------------------------------------------------
*/
long GLI_lCompressTextureSize(GLI_tdstTexture *p_stTexture)
{
long lTextureSizeBefore;
if ( (p_stTexture -> lHeight <= 4) || (p_stTexture -> lWidth <= 4) )
return 0;
lTextureSizeBefore = GLI_DRV_lGetTextureSize(p_stTexture);
p_stTexture -> lCompressionCounter ++;
p_stTexture -> lHeight >>= 1;
p_stTexture -> lWidth >>= 1;
return ( lTextureSizeBefore - GLI_DRV_lGetTextureSize(p_stTexture));
}
/*
----------------------------------------------------------------------------------------
Description : compute texture compression
----------------------------------------------------------------------------------------
*/
long TEX_lComputeCompression()
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long lSizeOfLevel,lSizeAvailable, lTextureCounter;
long lCounterAntiInfinite, lNbTexLowQuality;
unsigned long lMaxTextureSize,lIsAcceptNonSquaredTextures;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
lSizeOfLevel = GLI_lComputeTexturesSize();
/*
lSizeAvailable = GLI_DRV_lGetHardwareTotalTextureMemorySize( GLI_lGetTextureMode() );
lMaxTextureSize = GLI_DRV_lGetHardwareMaxTextureSize() ;
lIsAcceptNonSquaredTextures = GLI_DRV_lIsHardwareAcceptNonSquaredTextures();
*/
lSizeAvailable = GLI_g_stCaps.ulTotalTextureMemory;
lMaxTextureSize = GLI_g_stCaps.ulTextureMaxSize;;
lIsAcceptNonSquaredTextures = GLI_g_stCaps.ulTextureCaps & GLICAPS_TEX_C_ulSupportNonSquare;
PRF_fn_vSetIndependantVariable( PRF_C_ulIdpTextureSize, lSizeOfLevel );
PRF_fn_vSetIndependantVariable( PRF_C_ulIdpTextureMemorySize, lSizeAvailable );
/*
* if hardware doesn't accept non-squared textures squared them
* and compress texture if hardware size is smaller than texture
*/
if (lIsAcceptNonSquaredTextures == 0)
{
for (lTextureCounter = 0 ; lTextureCounter < GLI_C_lNBMaxOfTextures; lTextureCounter ++)
{
if (gs_aDEFTableOfTextureMemoryChannels[lTextureCounter] == GLI_TEXIsUnallocated)
continue;
/* Make them squared */
while (gs_aDEFTableOfTextureAlreadyRead[lTextureCounter]->lWidth > gs_aDEFTableOfTextureAlreadyRead[lTextureCounter]->lHeight)
lSizeOfLevel -= GLI_lCompressTexturesSizeInX(gs_aDEFTableOfTextureAlreadyRead [lTextureCounter]);
while (gs_aDEFTableOfTextureAlreadyRead[lTextureCounter]->lWidth < gs_aDEFTableOfTextureAlreadyRead[lTextureCounter]->lHeight)
lSizeOfLevel -= GLI_lCompressTexturesSizeInY(gs_aDEFTableOfTextureAlreadyRead [lTextureCounter]);
/* then compress too large textures */
while ( gs_aDEFTableOfTextureAlreadyRead[lTextureCounter]->lWidth > lMaxTextureSize )
{
lSizeOfLevel -= GLI_lCompressTexturesSizeInX(gs_aDEFTableOfTextureAlreadyRead [lTextureCounter]);
lSizeOfLevel -= GLI_lCompressTexturesSizeInY(gs_aDEFTableOfTextureAlreadyRead [lTextureCounter]);
}
}
}
else
{
/* Compress Height */
for (lTextureCounter = 0 ; lTextureCounter < GLI_C_lNBMaxOfTextures; lTextureCounter ++)
{
if (gs_aDEFTableOfTextureMemoryChannels[lTextureCounter] == GLI_TEXIsUnallocated)
continue;
while (gs_aDEFTableOfTextureAlreadyRead[lTextureCounter]->lWidth > lMaxTextureSize)
lSizeOfLevel -= GLI_lCompressTexturesSizeInX(gs_aDEFTableOfTextureAlreadyRead [lTextureCounter]);
}
/* Compress Width */
for (lTextureCounter = 0 ; lTextureCounter < GLI_C_lNBMaxOfTextures; lTextureCounter ++)
{
if (gs_aDEFTableOfTextureMemoryChannels[lTextureCounter] == GLI_TEXIsUnallocated)
continue;
while (gs_aDEFTableOfTextureAlreadyRead[lTextureCounter]->lHeight > lMaxTextureSize)
lSizeOfLevel -= GLI_lCompressTexturesSizeInY(gs_aDEFTableOfTextureAlreadyRead [lTextureCounter]);
}
}
if (lSizeAvailable == -1) /* Case of the reality engine */
return 0;
lCounterAntiInfinite = 10;
lNbTexLowQuality = 1;
while ((lSizeOfLevel > lSizeAvailable) && (lCounterAntiInfinite-- > 0))
{
if( lNbTexLowQuality )
{
lNbTexLowQuality--;
/* First compress the low textures */
for (lTextureCounter =GLI_C_lNBMaxOfTextures - 1 ; (lTextureCounter >= 0) && (lSizeOfLevel > lSizeAvailable); lTextureCounter --)
{
if (gs_aDEFTableOfTextureMemoryChannels[lTextureCounter] == GLI_TEXIsUnallocated)
continue;
if (TEX_ucGetTextureQualityLevel(gs_aDEFTableOfTextureAlreadyRead[lTextureCounter]) != TEX_C_QNORMAL)
{
if (TEX_ucGetTextureQualityLevel(gs_aDEFTableOfTextureAlreadyRead[lTextureCounter]) != TEX_C_QHIGH) /* = LOW quality*/
/*if (GLI_M_bNotAnLODLevel(gs_aDEFTableOfTextureMemoryChannels[lTextureCounter]))*/
{
lNbTexLowQuality++;
lSizeOfLevel -= GLI_lCompressTextureSize(gs_aDEFTableOfTextureAlreadyRead [ lTextureCounter ]);
if (lSizeOfLevel < lSizeAvailable)
continue;
lSizeOfLevel -= GLI_lCompressTextureSize(gs_aDEFTableOfTextureAlreadyRead [ lTextureCounter ]);
}
}
}
}
/* then compress Normal textures;*/
for (lTextureCounter =0 ; (lTextureCounter < GLI_C_lNBMaxOfTextures) && (lSizeOfLevel > lSizeAvailable); lTextureCounter ++)
{
if (gs_aDEFTableOfTextureMemoryChannels[lTextureCounter] == GLI_TEXIsUnallocated)
continue;
if (TEX_ucGetTextureQualityLevel(gs_aDEFTableOfTextureAlreadyRead[lTextureCounter]) == TEX_C_QNORMAL)
lSizeOfLevel -= GLI_lCompressTextureSize(gs_aDEFTableOfTextureAlreadyRead [ lTextureCounter ]);
}
}
return 0;
}

View File

@@ -0,0 +1,189 @@
/*
=======================================================================================
Name : TexConvert.c
Author : GLIGLOU corporation
Description : function to convert bitmap
=======================================================================================
*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include "textu_st.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
----------------------------------------------------------------------------------------
Description : invert alpha fiels
----------------------------------------------------------------------------------------
*/
void GLI_vInvertAlphaField(long *pDest, long lSize)
{
long *pLast = pDest + lSize;
for (;pDest<pLast;pDest++)
*pDest ^= 0xff000000;
}
/*
----------------------------------------------------------------------------------------
Description : verify alpha field
----------------------------------------------------------------------------------------
*/
unsigned long GLI_vVerifyTextureIsRealyAlpha ( GLI_tdstTexture *p_stTexture )
{
unsigned long ulBitmapCounter,ulOriginValue;
ulOriginValue = 0xFF000000;
for (ulBitmapCounter = 0; ulBitmapCounter < (unsigned long) ((p_stTexture -> lWidth * p_stTexture -> lHeight)); ulBitmapCounter ++)
ulOriginValue &= *(((long *)p_stTexture -> p_vBitMap) + ulBitmapCounter ) ;
return ulOriginValue;
}
/*
----------------------------------------------------------------------------------------
Description : convert 8888 bitmap to 565 bitmap
----------------------------------------------------------------------------------------
*/
#include "texture.h"
void GLI_vCompressNZTex565 ( GLI_tdstTexture *p_stTexture , void *GLI_gs_p_ConvertBuffer);
void GLI_vCompressTex565 ( GLI_tdstTexture *p_stTexture , void *GLI_gs_p_ConvertBuffer)
{
unsigned long lBitmapCounter,lCompressValue,lOriginValue,*p_vConvertBufferCount;
p_vConvertBufferCount = (long *)GLI_gs_p_ConvertBuffer ;
/* Begin G.CLEMENT 28/07/1999 */
if(p_stTexture->lTextureCaps & GLI_C_lNZTexture) {
GLI_vCompressNZTex565(p_stTexture, GLI_gs_p_ConvertBuffer);
return;
}
/* End G.CLEMENT */
if ((p_stTexture -> lWidth == 1) && (p_stTexture -> lHeight == 1))
{
lOriginValue = *((long *)p_stTexture -> p_vBitMap) ;
lCompressValue = ((lOriginValue & 0x00f80000)>>3) + ((lOriginValue & 0x0000fC00)<<11) + ((lOriginValue & 0x000000f8)<<24);
lCompressValue >>= 16;
*((long *)p_vConvertBufferCount) = lCompressValue;
return;
}
for (lBitmapCounter = 0; lBitmapCounter < (unsigned long) ((p_stTexture -> lHeight * p_stTexture -> lWidth)>>1); lBitmapCounter ++)
{
lOriginValue = *(((long *)p_stTexture -> p_vBitMap) + lBitmapCounter*2 ) ;
lCompressValue = ((lOriginValue & 0x00f80000)>>3) + ((lOriginValue & 0x0000fC00)<<11) + ((lOriginValue & 0x000000f8)<<24);
lCompressValue >>= 16;
lOriginValue = *(((long *)p_stTexture -> p_vBitMap) + lBitmapCounter*2 + 1 ) ;
lCompressValue += ((lOriginValue & 0x00f80000)>>3) + ((lOriginValue & 0x0000fC00)<<11) + ((lOriginValue & 0x000000f8)<<24);
*(p_vConvertBufferCount) = lCompressValue;
p_vConvertBufferCount ++;
}
}
/* Begin G.CLEMENT 27/07/1999 : OK now the same converter for NZ textures, so as not to mess the chromakeyed pixels */
/* Besides I shall add some comments. Nice idea, huh ? */
void GLI_vCompressNZTex565 ( GLI_tdstTexture *p_stTexture , void *GLI_gs_p_ConvertBuffer)
{
/* Basic idea : everything works quite like the original version except that when a non-chromakey pixel
is converted to a chromakey pixel, we slightly change its color to get its 'non-chromakey-ness' back. */
unsigned long lBitmapCounter,lCompressValue,lOriginValue,*p_vConvertBufferCount;
unsigned long lOriginalKey ; /* The original Chroma Key color, needed for comparison */
unsigned long lConvertedKey; /* The corresponding 16-bit value, so as not to recalculate it endlessly */
unsigned long lCompressValueTemp;
p_vConvertBufferCount = (long *)GLI_gs_p_ConvertBuffer ;
/* I guess this part is rather useless */
if ((p_stTexture -> lWidth == 1) && (p_stTexture -> lHeight == 1))
{
lOriginValue = *((long *)p_stTexture -> p_vBitMap) ;
lCompressValue = ((lOriginValue & 0x00f80000)>>3) + ((lOriginValue & 0x0000fC00)<<11) + ((lOriginValue & 0x000000f8)<<24);
lCompressValue >>= 16;
*((long *)p_vConvertBufferCount) = lCompressValue;
return;
}
/* First of all let's convert the chromakey */
lOriginalKey = p_stTexture->lChromakeyColorRGBA;
lConvertedKey = ((lOriginalKey & 0x00f80000)>>3) + ((lOriginalKey & 0x0000fC00)<<11) + ((lOriginalKey & 0x000000f8)<<24);
/* Now we do as before BUT we compare the converted value to the chromakey */
for (lBitmapCounter = 0; lBitmapCounter < (unsigned long) ((p_stTexture -> lHeight * p_stTexture -> lWidth)>>1); lBitmapCounter ++)
{
lOriginValue = *(((long *)p_stTexture -> p_vBitMap) + lBitmapCounter*2 ) ;
lCompressValue = ((lOriginValue & 0x00f80000)>>3) + ((lOriginValue & 0x0000fC00)<<11) + ((lOriginValue & 0x000000f8)<<24);
if ((lCompressValue == lConvertedKey) && (lOriginValue != lOriginalKey)) {
/* Color was converted to chromakey but should not ! */
lCompressValue ^= 0x00200000; /* We revert the least significant Green bit */
}
lCompressValue >>= 16;
lOriginValue = *(((long *)p_stTexture -> p_vBitMap) + lBitmapCounter*2 + 1 ) ;
lCompressValueTemp = ((lOriginValue & 0x00f80000)>>3) + ((lOriginValue & 0x0000fC00)<<11) + ((lOriginValue & 0x000000f8)<<24);
if ((lCompressValueTemp == lConvertedKey) && (lOriginValue != lOriginalKey)) {
/* Color was converted to chromakey but should not ! */
lCompressValueTemp ^= 0x00200000; /* We revert the least significant Green bit */
}
lCompressValue += lCompressValueTemp;
*(p_vConvertBufferCount) = lCompressValue;
p_vConvertBufferCount ++;
}
}
/* End G.CLEMENT 27/07/1999 */
/*
----------------------------------------------------------------------------------------
Description : convert 8888 bitmap to 4444 bitmap
----------------------------------------------------------------------------------------
*/
void GLI_vCompressTex4444( GLI_tdstTexture *p_stTexture , void *GLI_gs_p_ConvertBuffer)
{
unsigned long lBitmapCounter,lCompressValue,lOriginValue,p_vConvertBufferCount;
p_vConvertBufferCount = (long)GLI_gs_p_ConvertBuffer ;
for (lBitmapCounter = 0; lBitmapCounter < (unsigned long) ((p_stTexture -> lWidth* p_stTexture -> lHeight)>>1); lBitmapCounter ++)
{
lOriginValue = *(((long *)p_stTexture -> p_vBitMap) + lBitmapCounter*2 ) ;
lCompressValue = ((lOriginValue & 0xf0000000)>>0) + ((lOriginValue & 0x00f00000)>>4) + ((lOriginValue & 0x0000f000)<<8) + ((lOriginValue & 0x000000f0)<<20);
lCompressValue >>= 16;
lOriginValue = *(((long *)p_stTexture -> p_vBitMap) + lBitmapCounter*2 + 1 ) ;
lCompressValue +=((lOriginValue & 0xf0000000)>>0) + ((lOriginValue & 0x00f00000)>>4) +((lOriginValue & 0x0000f000)<<8) + ((lOriginValue & 0x000000f0)<<20);
*((long *)p_vConvertBufferCount) = lCompressValue;
p_vConvertBufferCount += 4;
}
}
/*
----------------------------------------------------------------------------------------
Description : convert 8888 bitmap to 1555 bitmap
----------------------------------------------------------------------------------------
*/
void GLI_vCompressTex1555 ( GLI_tdstTexture *p_stTexture , void *GLI_gs_p_ConvertBuffer)
{
unsigned long lBitmapCounter,lCompressValue,lOriginValue,p_vConvertBufferCount;
p_vConvertBufferCount = (long)GLI_gs_p_ConvertBuffer ;
if ((p_stTexture -> lWidth == 1) && (p_stTexture -> lHeight == 1))
{
lOriginValue = *((long *)p_stTexture -> p_vBitMap) ;
lCompressValue = ((lOriginValue & 0x80000000)>>0) + ((lOriginValue & 0x00f80000)>>3) + ((lOriginValue & 0x0000f800)<<10) + ((lOriginValue & 0x000000f8)<<23);
lCompressValue >>= 16;
*((long *)p_vConvertBufferCount) = lCompressValue;
return;
}
for (lBitmapCounter = 0;lBitmapCounter < (unsigned long) ((p_stTexture -> lHeight * p_stTexture -> lWidth)>>1);lBitmapCounter ++)
{
lOriginValue = *(((long *)p_stTexture -> p_vBitMap) + lBitmapCounter*2 ) ;
lCompressValue = ((lOriginValue & 0x80000000)>>0) + ((lOriginValue & 0x00f80000)>>3) + ((lOriginValue & 0x0000f800)<<10) + ((lOriginValue & 0x000000f8)<<23);
lCompressValue >>= 16;
lOriginValue = *(((long *)p_stTexture -> p_vBitMap) + lBitmapCounter*2 + 1 ) ;
lCompressValue += ((lOriginValue & 0x80000000)>>0) + ((lOriginValue & 0x00f80000)>>3) + ((lOriginValue & 0x0000f800)<<10) + ((lOriginValue & 0x000000f8)<<23);
*((long *)p_vConvertBufferCount) = lCompressValue;
p_vConvertBufferCount += 4;
}
}

View File

@@ -0,0 +1,227 @@
/*
=======================================================================================
Name : TexName.c
Author : GLIGLOU corporation
Description : Fonction for texture name analysis / storage
=======================================================================================
*/
#define MTH_LOW
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include "PvObj_st.h"
#include "texture.h"
#include "TEX.h"
#include "dpt.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#ifdef __cplusplus
extern "C"
{
#endif
/*
=======================================================================================
Analyse name of texture
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : find on the name of texture if it cycling on X,Y or XY
----------------------------------------------------------------------------------------
*/
long TEX_fnl_GetCyclingTextNameKey( char *d_ucFileName, char **_ppc_BeforeAnalysed )
{
long lReturnValue = 0;
if ( *((*_ppc_BeforeAnalysed) - 2) == 't' )
{
if ( *((*_ppc_BeforeAnalysed) - 1) == 'x' )
{
lReturnValue = GLI_C_lCylingU;
*_ppc_BeforeAnalysed -= 2;
}
else if ( *((*_ppc_BeforeAnalysed) - 1) == 'y' )
{
lReturnValue = GLI_C_lCylingV;
*_ppc_BeforeAnalysed -= 2;
}
}
else if ( *((*_ppc_BeforeAnalysed) - 3) == 't' )
{
if ( strncmp( ((*_ppc_BeforeAnalysed) - 2), "xy", 2) == 0)
{
lReturnValue = GLI_C_lCylingUV;
*_ppc_BeforeAnalysed -= 3;
}
}
if (lReturnValue == 0)
{
if (strstr( d_ucFileName, "_txy") != NULL) lReturnValue = GLI_C_lCylingUV;
if (strstr( d_ucFileName, "_tx" ) != NULL) lReturnValue = GLI_C_lCylingU;
if (strstr( d_ucFileName, "_ty" ) != NULL) lReturnValue = GLI_C_lCylingV;
}
if (strstr( d_ucFileName, "_mxy" ) != NULL ) lReturnValue |= GLI_C_lMirrorUV;
if (strstr( d_ucFileName, "_mx" ) != NULL ) lReturnValue |= GLI_C_lMirrorV;
if (strstr( d_ucFileName, "_my" ) != NULL ) lReturnValue |= GLI_C_lMirrorU;
return lReturnValue;
}
/*
----------------------------------------------------------------------------------------
Description : find a key in texture name. return 1 if Yes
----------------------------------------------------------------------------------------
*/
long TEX_fnl_GetTextureKey( char *_szFileName, char *_szKey )
{
return (strstr(_szFileName, _szKey) != NULL) ? 1 : 0;
}
/*
----------------------------------------------------------------------------------------
Description : find "NZW" key in texture name. return 1 if Yes
----------------------------------------------------------------------------------------
*/
long TEX_fnl_NoZWriteTextNameKey( char *d_ucFileName, char **_ppc_BeforeAnalysed )
{
if (strncmp((*_ppc_BeforeAnalysed - 3),"_ad", 3) == 0)
{
*_ppc_BeforeAnalysed -= 3;
}
if (strncmp( (*_ppc_BeforeAnalysed - 3), "nzw", 3) == 0)
{
*_ppc_BeforeAnalysed -= 3;
return 1;
}
if (strstr(d_ucFileName,"_nzw") != NULL)
return 1;
return 0;
}
/*
----------------------------------------------------------------------------------------
Description : Test if there's NZ code in texture name
----------------------------------------------------------------------------------------
*/
ACP_tdxBool TEX_fnb_TestIfNonZero(char *d_ucFileName)
{
char *cRes;
cRes = strstr(d_ucFileName, "_nz" );
if (cRes == NULL)
return FALSE;
if ( cRes[3] != 'w' )
return TRUE;
if ( strstr( (cRes + 3), "_nz" ) == NULL)
return FALSE;
return TRUE;
}
/*
----------------------------------------------------------------------------------------
Description : Main function : analyse name and set some data
----------------------------------------------------------------------------------------
*/
long GLI_fn_lAnalyseTextureName( char *_szFileName, long *_p_lTextureCaps, unsigned char *_p_ucCyclingMode )
{
char *pc_BeforeAnalysed;
char *pc_ShortFileName;
/* swap dir names to analyse only texture name */
pc_ShortFileName = strrchr( _szFileName, '\\' );
if (pc_ShortFileName == NULL)
pc_ShortFileName = _szFileName;
else
pc_ShortFileName++;
/* search dos extension */
pc_BeforeAnalysed = strrchr( pc_ShortFileName, '.' );
if (pc_BeforeAnalysed == NULL)
return 0;
if (strcmp(pc_BeforeAnalysed + 1, "bmp" ) == 0)
*_p_lTextureCaps |= GLI_C_lBMPTexture;
else if (strcmp(pc_BeforeAnalysed + 1, "tga" ) == 0)
*_p_lTextureCaps |= GLI_C_lTGATexture;
else
return 0;
/* search nz key */
if ( strncmp(pc_BeforeAnalysed - 2, "nz", 2) == 0 )
{
pc_BeforeAnalysed -= 2;
*_p_lTextureCaps |= GLI_C_lNZTexture + GLI_C_lNZFilteredTexture;
}
else if ( TEX_fnb_TestIfNonZero( _szFileName ) )
{
*_p_lTextureCaps |= GLI_C_lNZTexture + GLI_C_lNZFilteredTexture;
}
*_p_ucCyclingMode = (unsigned char ) TEX_fnl_GetCyclingTextNameKey( pc_ShortFileName, &pc_BeforeAnalysed );
if ( TEX_fnl_GetTextureKey( pc_ShortFileName, "_ad" ) )
*_p_lTextureCaps |= GLI_C_lAddTransparencyTexture;
if ( TEX_fnl_GetTextureKey( pc_ShortFileName, "_aaa" ) )
*_p_lTextureCaps |= GLI_C_lAAATexture;
if ( TEX_fnl_GetTextureKey( pc_ShortFileName, "_maa" ) )
*_p_lTextureCaps |= GLI_C_lMAATexture;
if ( TEX_fnl_NoZWriteTextNameKey( pc_ShortFileName, &pc_BeforeAnalysed ) )
*_p_lTextureCaps |= GLI_C_lNoZBufferWriteTexture;
return 1;
}
/*
=======================================================================================
Manage list of textures
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : harmonize texture name
----------------------------------------------------------------------------------------
*/
void TEX_fnv_FixTextureName(char *_pszOut, char *_pszIn)
{
/*remove the base path if it does not start from the game data's directory*/
char *pszGameDataPath = fn_szGetGameDataPath();
char *pszBase = strstr(_pszIn, pszGameDataPath);
short wOffset = 0;
if ( pszBase != NULL )
wOffset = strlen(pszGameDataPath) + (pszBase - _pszIn) + 1;
/*copy the file name, not including the game data path*/
strcpy(_pszOut, _pszIn + wOffset);
/*now replace '/' by '\'*/
do
{
if ( *_pszOut == '/' )
*_pszOut = '\\';
else
*_pszOut = tolower(*_pszOut);
} while ( *(++ _pszOut) );
}
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,263 @@
/*
=======================================================================================
Name : TexProcedural.c
Author : vincent lhullier Date :01/02/99
Description : implementation of function for procedural texture
=======================================================================================
*/
#ifdef PROCEDURAL_TEXTURE
#include "cpa_expt.h"
#include "GLD.h"
#include "DllCaps.h"
#include "DLLInter.h"
#include "TexProcedural.h"
#include "Texture.h"
#include "TexName.h"
/*
=======================================================================================
Internal function to compute procedural texture surface
=======================================================================================
*/
#define FREQ 0.2f
#define AMPL 200.f
void TEXPRO_fnv_DisruptSurface_Water( GLI_tdstTexture *_pst_Texture )
{
unsigned char *S1, *S2, N;
static long sl_K;
unsigned long ul_X, ul_Y , ul_Add;
static long lRate = 10;
static long lCount = 0;
static long lNRate = 2;
if (lCount)
{
lCount--;
return;
}
lCount = lRate;
sl_K++;
S1 = ((unsigned char *) _pst_Texture->p_vBitMap);
S2 = ((unsigned char *) _pst_Texture->pv_Bitmap2);
N = lNRate;
while (N--)
{
ul_X = rand() % (_pst_Texture->lWidth - 8) + 4;
ul_Y = rand() % (_pst_Texture->lHeight - 8) + 4;
ul_Add = (unsigned long) (fabs(sin(sl_K * FREQ)) * AMPL);
*(S1 + ul_X + ( (ul_Y + 1) *_pst_Texture->lWidth )) += (unsigned char) ul_Add;
*(S1 + ul_X + 1 + ( ul_Y *_pst_Texture->lWidth )) += (unsigned char) ul_Add;
*(S1 + ul_X + 1 + ( (ul_Y + 1) *_pst_Texture->lWidth )) += (unsigned char) ul_Add;
*(S1 + ul_X + ( ul_Y *_pst_Texture->lWidth )) += (unsigned char) ul_Add;
*(S2 + ul_X + ( (ul_Y + 1) *_pst_Texture->lWidth )) += (unsigned char) ul_Add;
*(S2 + ul_X + 1 + ( ul_Y *_pst_Texture->lWidth )) += (unsigned char) ul_Add;
*(S2 + ul_X + 1 + ( (ul_Y + 1) *_pst_Texture->lWidth )) += (unsigned char) ul_Add;
*(S2 + ul_X + ( ul_Y *_pst_Texture->lWidth )) += (unsigned char) ul_Add;
}
}
void TEXPRO_fnv_ComputeSurface_Water( GLI_tdstTexture *_pst_Texture )
{
char *S1, *S2;
unsigned long Size;
unsigned long X, Y, DX;
unsigned long ulValue;
DX = _pst_Texture->lWidth;
S1 = ((char *) _pst_Texture->p_vBitMap) + _pst_Texture->lWidth + 1;
S2 = ((char *) _pst_Texture->pv_Bitmap2) + _pst_Texture->lWidth + 1;
Y = _pst_Texture->lHeight - 2;
while (Y--)
{
X = _pst_Texture->lWidth - 2;
while (X--)
{
ulValue = ((((unsigned long) *(S2 + 1)) + ((unsigned long) *(S2 - 1)) + ((unsigned long) *(S2 + DX)) + ((unsigned long) *(S2 - DX)))>> 1) - ((unsigned long) *(S1));
/*ulValue = ( (
((unsigned long) *(S2 + 1)) +
((unsigned long) *(S2 - 1)) +
((unsigned long) *(S2 + DX)) +
((unsigned long) *(S2 - DX)) +
((unsigned long) *(S2 + 1 + DX)) +
((unsigned long) *(S2 - 1 + DX)) +
((unsigned long) *(S2 - DX + 1)) +
((unsigned long) *(S2 - DX -1 ))
) >> 2 ) - ((unsigned long) *(S1));
*/
*S1 = (char) (ulValue - (ulValue>>5) );
S1++;
S2++;
}
S1 += 2;
S2 += 2;
}
S1 = ((char *) _pst_Texture->p_vBitMap) + DX;
S2 = ((char *) _pst_Texture->pv_Bitmap2) + DX;
Y = _pst_Texture->lHeight - 2;
while (Y--)
{
ulValue = ((((unsigned long) *(S2 + 1)) + ((unsigned long) *(S2 + DX - 1)) + ((unsigned long) *(S2 + DX)) + ((unsigned long) *(S2 - DX))) >> 1) - ((unsigned long) *(S1));
*S1 = (char) (ulValue - (ulValue>>5) );
S1 += DX - 1;
S2 += DX - 1;
ulValue = ((((unsigned long) *(S2 - DX + 1)) + ((unsigned long) *(S2 - 1)) + ((unsigned long) *(S2 + DX)) + ((unsigned long) *(S2 - DX))) >> 1) - ((unsigned long) *(S1));
*S1 = (char) (ulValue - (ulValue>>5) );
S1++;
S2++;
}
S1 = ((char *) _pst_Texture->p_vBitMap) + 1;
S2 = ((char *) _pst_Texture->pv_Bitmap2) + 1;
X = DX - 2;
Size = DX * (_pst_Texture->lHeight - 1) ;
while (X--)
{
ulValue = ((((unsigned long) *(S2 + 1)) + ((unsigned long) *(S2 - 1)) + ((unsigned long) *(S2 + DX)) + ((unsigned long) *(S2 + Size))) >> 1) - ((unsigned long) *(S1));
*S1 = (char) (ulValue - (ulValue>>5) );
S1 += Size;
S2 += Size;
ulValue = ((((unsigned long) *(S2 + 1)) + ((unsigned long) *(S2 - 1)) + ((unsigned long) *(S2 - Size)) + ((unsigned long) *(S2 - DX))) >> 1) - ((unsigned long) *(S1));
*S1 = (char) (ulValue - (ulValue>>5) );
S1 -= Size - 1;
S2 -= Size - 1;
}
S1 = (char *) _pst_Texture->p_vBitMap;
_pst_Texture->p_vBitMap = _pst_Texture->pv_Bitmap2;
_pst_Texture->pv_Bitmap2 = (void *) S1;
}
/*
----------------------------------------------------------------------------------------
Description : init texture structure for procedural texture
----------------------------------------------------------------------------------------
*/
long TEXPRO_fnl_InitProceduralTexture( GLI_tdstTexture *_pst_Texture, long _l_Type, long _l_Width, long _l_Height, long _l_RefreshRate )
{
long i, j;
unsigned short *puw_Palette;
_pst_Texture->lTextureCaps |= GLI_C_lProceduralTexture;
_pst_Texture->lHeight = _pst_Texture->lRealHeight = (unsigned short) _l_Height;
_pst_Texture->lWidth = _pst_Texture->lRealWidth = (unsigned short) _l_Width;
_pst_Texture->lTextureCaps |= GLI_C_lAlphaTexture;
_pst_Texture->l_Type = _l_Type;
_pst_Texture->l_RefreshRate = _pst_Texture->l_RefreshCounter = _l_RefreshRate;
_pst_Texture->l_RenderingCounter = 0;
MMG_fn_vAddMemoryInfo (MMG_C_lTypeGLI , MMG_C_lSubTypeTexture , NULL);
GEO_M_CPAMalloc(_pst_Texture->p_vBitMap, void *, _l_Width * _l_Height, E_uwGEONotEnoughtMemory );
MMG_fn_vAddMemoryInfo (MMG_C_lTypeGLI , MMG_C_lSubTypeTexture , NULL);
GEO_M_CPAMalloc(_pst_Texture->pv_Bitmap2, void *, _l_Width * _l_Height, E_uwGEONotEnoughtMemory );
MMG_fn_vAddMemoryInfo (MMG_C_lTypeGLI , MMG_C_lSubTypeTexture , NULL);
GEO_M_CPAMalloc(_pst_Texture->p_vColorTable, void *, 512, E_uwGEONotEnoughtMemory );
puw_Palette = (unsigned short *) _pst_Texture->p_vColorTable;
for (i = 0; i < 256; i++, puw_Palette++ )
{
/**pul_Palette = i | (i<<8) | (i<<16) | ((i < 128) ? (i<<25) : 0xFF000000);*/
j = i>>4;
*puw_Palette = j | (j<<4) | (j<<8) | ((i < 128) ? (j<<13) : 0xF000);
}
strcpy( _pst_Texture->a255_cFileName, "Proc" );
TEX_fnv_MakeItExisting( _pst_Texture );
return 1;
}
/*
----------------------------------------------------------------------------------------
Description : init texture structure for procedural texture
(texture type is given by its name, used by script callback)
Returns (long ) 0 if failed
----------------------------------------------------------------------------------------
*/
long TEXPRO_fnl_InitProceduralTextureWithName( GLI_tdstTexture *_pst_Texture, char *_sz_ProcName, long _l_Width, long _l_Height, long _l_RefreshRate )
{
long l_Type;
if (stricmp( _sz_ProcName, "Water") == 0)
l_Type = TEXPRO_C_lWater;
else if (stricmp( _sz_ProcName, "Fire") == 0)
l_Type = TEXPRO_C_lFire;
else
return 0;
return TEXPRO_fnl_InitProceduralTexture( _pst_Texture, l_Type, _l_Width, _l_Height, _l_RefreshRate );
}
/*
----------------------------------------------------------------------------------------
Description : refresh procedural texture
----------------------------------------------------------------------------------------
*/
void TEXPRO_fnv_RefreshProceduralTexture( GLI_tdstTexture *_pst_Texture, long _l_ActualRefreshNumber )
{
if (!( _pst_Texture->lTextureCaps & GLI_C_lProceduralTexture))
return;
if ( _pst_Texture->l_RenderingCounter == _l_ActualRefreshNumber )
return;
_pst_Texture->l_RenderingCounter = _l_ActualRefreshNumber;
_pst_Texture->l_RefreshCounter--;
if (_pst_Texture->l_RefreshCounter >= 0 )
return;
_pst_Texture->l_RefreshCounter = _pst_Texture->l_RefreshRate;
switch (_pst_Texture->l_Type)
{
case TEXPRO_C_lWater:
TEXPRO_fnv_DisruptSurface_Water( _pst_Texture );
TEXPRO_fnv_ComputeSurface_Water( _pst_Texture );
break;
case TEXPRO_C_lFire:
break;
}
/*
{
static file = 0;
FILE *hpFile;
char szFile[64];
if (file < 100)
{
sprintf(szFile, "snapshot/proc%04d.raw", file++ );
hpFile = fopen( szFile, "wb" );
fwrite( _pst_Texture->p_vBitMap, 128*128,1, hpFile);
fclose( hpFile );
}
}
*/
GLI_DRV_lRequest( GLIDLL_Request_ReloadTexture, (long) _pst_Texture, 0 );
}
#endif /*PROCEDURAL_TEXTURE*/

View File

@@ -0,0 +1,208 @@
#define MTH_LOW
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include "gli_st.h"
#include "GLI_Defn.h"
#include "light_st.h"
#include "PvObj_st.h"
#include "texture.h"
#include "TEX.h"
#include "load.h"
#include "TMP.h"
#include "VIG.h"
#include "FIL.h"
#include "acp_opfi.h"
#include "texture.h"
#include "DLLInter.h"
#include "DLLCaps.h"
#include "TexName.h"
#include "TexArray.h"
#include "TexCompress.h"
#include "sna.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
extern void SNA_fn_vRelocateTexturePointer(unsigned long **);
extern void SNA_fn_xReadOpenGlobalTextureFile(char *szFileName);
extern void SNA_fn_vCloseGlobalTextureFile();
*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
extern unsigned long GLI_gsCurrentMemoryChannel;
extern long gs_lNumberOfTextureToCreate;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/**********************************************************************************************/
/* Name: TEX_GetNameOfBinaryFile() 1.0*/
/* Goal: save the globales variables for fast binarisation*/
/* Code: Philippe Vimont */
/* OPTIMMIZED : No*/
/**********************************************************************************************/
static char gs_ucFilenameForBinaryGlobals[256] = "BINARY_TEX_GLOBALS.BIN";
void TEX_SetNameOfBinaryFile(unsigned char *p_ucBinaryFile)
{
strcpy( gs_ucFilenameForBinaryGlobals , p_ucBinaryFile ) ;
}
void TEX_vInitGlobalForLevel()
{
/*long i;*/
/* release all the texture's surfaces*/
GLI_DRV_vUnLoadTextures();
/* erase the texture's structures of the levels*/
GLI_fn_vUnallocTextureInChannel( 2 );
}
/**********************************************************************************************/
/* Name: TEX_vSaveGlobales() 1.0*/
/* Goal: save the globales variables for fast binarisation*/
/* Code: Philippe Vimont */
/* OPTIMMIZED : No*/
/**********************************************************************************************/
void TEX_vSaveGlobales()
{
FILE *p_stBinaryFile;
unsigned long ulNbText, ulNbMaxText;
long i;
p_stBinaryFile = fopen(gs_ucFilenameForBinaryGlobals,"wb");
i=0;
while(gs_aDEFTableOfTextureMemoryChannels[i] == 1) i++;
ulNbText = GLI_C_lNBMaxOfTextures-i;
ulNbMaxText = GLI_C_lNBMaxOfTextures;
fwrite ( &ulNbMaxText ,4 , 1, p_stBinaryFile );
fwrite ( &ulNbText ,4 , 1, p_stBinaryFile );
fwrite ( gs_aDEFTableOfTextureAlreadyRead+i , ulNbText , sizeof ( GLI_tdstTexture * ) , p_stBinaryFile );
fwrite ( &gs_lNumberOfTextureToCreate , 1 , sizeof ( long ) , p_stBinaryFile );
fwrite ( gs_aDEFTableOfTextureMemoryChannels , ulNbMaxText , sizeof ( long ) , p_stBinaryFile );
fwrite ( &GLI_gsCurrentMemoryChannel , 1 , sizeof ( long ) , p_stBinaryFile );
fclose(p_stBinaryFile);
}
/**********************************************************************************************/
/* Name: TEX_vLoadGlobales() 1.0*/
/* Goal: Load the globales variables for fast binarisation*/
/* Code: Philippe Vimont */
/* OPTIMMIZED : No*/
/**********************************************************************************************/
void TEX_vLoadGlobales()
{
FILE *p_stBinaryFile;
unsigned long ulNbText, ulNbMaxText;
unsigned long ulDummy;
/*
char szFile[255];
*/
ACP_M_OPENFILE(fopen,p_stBinaryFile,NULL,gs_ucFilenameForBinaryGlobals,(gs_ucFilenameForBinaryGlobals,"rb"));
fread ( &ulNbMaxText,4 ,1 ,p_stBinaryFile );
fread ( &ulNbText,4 ,1 ,p_stBinaryFile );
fread ( gs_aDEFTableOfTextureAlreadyRead+ulNbMaxText-ulNbText , ulNbText , sizeof ( GLI_tdstTexture * ) , p_stBinaryFile );
fread ( &gs_lNumberOfTextureToCreate , 1 , sizeof ( long ) , p_stBinaryFile );
fread ( gs_aDEFTableOfTextureMemoryChannels , ulNbMaxText , sizeof ( long ) , p_stBinaryFile );
fread ( &GLI_gsCurrentMemoryChannel , 1 , sizeof ( long ) , p_stBinaryFile );
fclose(p_stBinaryFile);
/*
strcpy(szFile,gs_ucFilenameForBinaryGlobals);
szFile[strlen(szFile)-3]=0;
strcat(szFile,"rtt");
SNA_fn_xReadOpenGlobalTextureFile(szFile);
*/
/* ANNECY OA - 12/07/99 { */
/* Load dummy datas : for protections */
SNA_M_LoadUnusedRelocationTable();
/* END ANNECY OA } */
SNA_fn_xReadOpenGlobalTextureFile();
for(ulDummy=ulNbMaxText-ulNbText ; ulDummy<ulNbMaxText ; ulDummy++)
{
SNA_fn_vRelocateTexturePointer(&((unsigned long *)gs_aDEFTableOfTextureAlreadyRead[ulDummy]));
}
SNA_fn_vCloseGlobalTextureFile();
/* ANNECY OA - 12/07/99 { */
/* Load dummy datas : for protections */
SNA_M_LoadUnusedRelocationTable();
/* END ANNECY OA } */
}
/**********************************************************************************************/
/* Name: TEX_vSaveGlobales() 1.0*/
/* Goal: save the globales variables for fast binarisation*/
/* Code: Philippe Vimont */
/* OPTIMMIZED : No*/
/**********************************************************************************************/
void TEX_vSaveGlobalesFix()
{
FILE *p_stBinaryFile;
unsigned long ulNbText, ulNbMaxText;
long i;
p_stBinaryFile = fopen(gs_ucFilenameForBinaryGlobals,"wb");
i=0;
while(gs_aDEFTableOfTextureMemoryChannels [i] == 1) i++;
ulNbText = i;
ulNbMaxText = GLI_C_lNBMaxOfTextures;
fwrite ( &ulNbMaxText ,4 , 1, p_stBinaryFile );
fwrite ( &ulNbText ,4 , 1, p_stBinaryFile );
fwrite ( gs_aDEFTableOfTextureAlreadyRead , ulNbText , sizeof ( GLI_tdstTexture * ) , p_stBinaryFile );
fwrite ( &gs_lNumberOfTextureToCreate , 1 , sizeof ( long ) , p_stBinaryFile );
fwrite ( gs_aDEFTableOfTextureMemoryChannels , ulNbText , sizeof ( long ) , p_stBinaryFile );
fwrite ( &GLI_gsCurrentMemoryChannel , 1 , sizeof ( long ) , p_stBinaryFile );
fclose(p_stBinaryFile);
}
/**********************************************************************************************/
/* Name: TEX_vLoadGlobales() 1.0*/
/* Goal: Load the globales variables for fast binarisation*/
/* Code: Philippe Vimont */
/* OPTIMMIZED : No*/
/**********************************************************************************************/
void TEX_vLoadGlobalesFix()
{
FILE *p_stBinaryFile;
unsigned long ulNbText, ulNbMaxText;
unsigned long ulDummy;
// char szFile[255];
GLI_fn_vUnallocAllTextures();
ACP_M_OPENFILE(fopen,p_stBinaryFile,NULL,gs_ucFilenameForBinaryGlobals,(gs_ucFilenameForBinaryGlobals,"rb"));
fread ( &ulNbMaxText,4 ,1 ,p_stBinaryFile );
fread ( &ulNbText,4 ,1 ,p_stBinaryFile );
fread ( gs_aDEFTableOfTextureAlreadyRead , ulNbText , sizeof ( GLI_tdstTexture * ) , p_stBinaryFile );
fread ( &gs_lNumberOfTextureToCreate , 1 , sizeof ( long ) , p_stBinaryFile );
fread ( gs_aDEFTableOfTextureMemoryChannels , ulNbText , sizeof ( long ) , p_stBinaryFile );
fread ( &GLI_gsCurrentMemoryChannel , 1 , sizeof ( long ) , p_stBinaryFile );
fclose(p_stBinaryFile);
/*
strcpy(szFile,gs_ucFilenameForBinaryGlobals);
szFile[strlen(szFile)-3]=0;
strcat(szFile,"rtt");
SNA_fn_xReadOpenGlobalTextureFile(szFile);
*/
/* ANNECY OA - 12/07/99 { */
/* Load dummy datas : for protections */
SNA_M_LoadUnusedRelocationTable();
/* END ANNECY OA } */
SNA_fn_xReadOpenGlobalTextureFile();
for(ulDummy=0 ; ulDummy<ulNbMaxText ; ulDummy++)
{
SNA_fn_vRelocateTexturePointer(&((unsigned long *)gs_aDEFTableOfTextureAlreadyRead[ulDummy]));
}
SNA_fn_vCloseGlobalTextureFile();
/* ANNECY OA - 12/07/99 { */
/* Load dummy datas : for protections */
SNA_M_LoadUnusedRelocationTable();
/* END ANNECY OA } */
}

View File

@@ -0,0 +1,229 @@
/*
Tested with LINT
*/
/**************
TEXTURE.C
Ver 1.0
***************/
#include "GLD.h"
#include "GEO.h"
#include "TEX.h"
#include "gli_st.h"
#include "textu_st.h"
#include "texture.h"
#include "pvobj_st.h"
#include "texbench.h"
/*
=======================================================================================
Access functions to texture structure
=======================================================================================
*/
/*
* texture size
*/
void TEX_vGetTextureSize (struct GLI_tdstTexture_ *p_stTexture ,long *p_lSizeX, long *p_lSizeY)
{
*p_lSizeY = p_stTexture->lHeight;
*p_lSizeX = p_stTexture->lWidth;
}
/*
* Tiling mode
*/
void TEX_vSetTextureTilingMode( GLI_tdstTexture *p_stTexture, BOOL bTilingX , BOOL bTilingY )
{
p_stTexture->ucCylingMode &= ~GLI_C_lCylingUV;
if (bTilingX)
if (bTilingY)
p_stTexture->ucCylingMode |= GLI_C_lCylingUV;
else
p_stTexture->ucCylingMode |= GLI_C_lCylingU;
else
if (bTilingY)
p_stTexture->ucCylingMode |= GLI_C_lCylingV;
else
p_stTexture->ucCylingMode |= 0;
}
void TEX_vGetTextureTilingMode( struct GLI_tdstTexture_ *p_stTexture, BOOL *p_bTilingX , BOOL *p_bTilingY )
{
*p_bTilingX = (p_stTexture->ucCylingMode & GLI_C_lCylingU) ? 1 : 0;
*p_bTilingY = (p_stTexture->ucCylingMode & GLI_C_lCylingV) ? 1 : 0;
}
void TEX_vSetTextureCyclingMode( GLI_tdstTexture *_p_stTexture, unsigned char _ucNewCyclingMode )
{
_p_stTexture->ucCylingMode = _ucNewCyclingMode;
}
unsigned char TEX_ucGetTextureCyclingMode( GLI_tdstTexture *_p_stTexture )
{
return _p_stTexture->ucCylingMode;
}
/*
* Bilinear mode
*/
void TEX_vSetTextureBilinearMode( GLI_tdstTexture *p_stTexture, BOOL bTilingX , BOOL bTilingY)
{
if (bTilingX)
if (bTilingY)
p_stTexture->ucBilinearMode = GLI_C_lCylingUV;
else
p_stTexture->ucBilinearMode = GLI_C_lCylingU;
else
if (bTilingY)
p_stTexture->ucBilinearMode = GLI_C_lCylingV;
else
p_stTexture->ucBilinearMode = 0;
}
void TEX_vGetTextureBilinearMode( GLI_tdstTexture *p_stTexture, BOOL *p_bTilingX , BOOL *p_bTilingY )
{
*p_bTilingX = (p_stTexture->ucBilinearMode & GLI_C_lCylingU) ? 1 : 0;
*p_bTilingY = (p_stTexture->ucBilinearMode & GLI_C_lCylingV) ? 1 : 0;
}
/*
* ZWrite mode
*/
void TEX_vSetTextureZWriteMode( GLI_tdstTexture *p_Texture , long lOnOff)
{
if (lOnOff)
p_Texture->lTextureCaps &= ~GLI_C_lNoZBufferWriteTexture;
else
p_Texture->lTextureCaps |= GLI_C_lNoZBufferWriteTexture;
}
long TEX_vGetTextureZWriteMode( struct GLI_tdstTexture_ *p_Texture )
{
return (p_Texture->lTextureCaps & GLI_C_lNoZBufferWriteTexture);
}
/*
* texture quality level
*/
void TEX_vSetTextureQualityLevel(struct GLI_tdstTexture_ *p_stTexture , char ucTextQuality)
{
p_stTexture->lTextureQuality = (unsigned long) ucTextQuality;
}
unsigned char TEX_ucGetTextureQualityLevel(struct GLI_tdstTexture_ *p_stTexture)
{
return ((unsigned char) (p_stTexture->lTextureQuality & 0x000000FF));
}
/*
* Nonzero texture
*/
long TEX_bIsTextureNZ (struct GLI_tdstTexture_ *p_stTexture)
{
return ( p_stTexture->lTextureCaps & GLI_C_lNZTexture );
}
void TEX_vSetTextureChromakey (struct GLI_tdstTexture_ *p_stTexture , BOOL bSwitchOnOff , BOOL bFilteringOnOff , unsigned char ucR , unsigned char ucG , unsigned char ucB , unsigned char ucA )
{
/*p_stTexture -> lChromakeyColorRGBA = ( ((long)ucR) << 24 ) | (((long)ucG) << 16) | (((long)ucB) << 8) | (ucA ) ;*/
p_stTexture -> lChromakeyColorRGBA = ( ((long)ucA) << 24 ) | (((long)ucB) << 16) | (((long)ucG) << 8) | (ucR ) ;
if (bSwitchOnOff )
p_stTexture -> lTextureCaps |= GLI_C_lNZTexture;
else
p_stTexture -> lTextureCaps &= ~GLI_C_lNZTexture;
if (bFilteringOnOff)
p_stTexture -> lTextureCaps |= GLI_C_lNZFilteredTexture;
else
p_stTexture -> lTextureCaps &= ~GLI_C_lNZFilteredTexture;
}
void TEX_vGetTextureChromakey (struct GLI_tdstTexture_ *p_stTexture , BOOL *bSwitchOnOff, BOOL *bFilteringOnOff, unsigned char *ucR , unsigned char *ucG , unsigned char *ucB , unsigned char *ucA)
{
*ucA = (unsigned char)(( p_stTexture -> lChromakeyColorRGBA & 0xFF000000 ) >> 24);
*ucB = (unsigned char)(( p_stTexture -> lChromakeyColorRGBA & 0xFF0000 ) >> 16);
*ucG = (unsigned char)(( p_stTexture -> lChromakeyColorRGBA & 0xFF00 ) >> 8);
*ucR = (unsigned char)(( p_stTexture -> lChromakeyColorRGBA & 0xFF) );
*bSwitchOnOff = p_stTexture->lTextureCaps & GLI_C_lNZTexture;
*bFilteringOnOff = p_stTexture->lTextureCaps & GLI_C_lNZFilteredTexture;
}
/*
* palette
*/
void TEX_vSetPaletteOfTexture ( struct GLI_tdstTexture_ *p_stTexture,TEX_tdstPalette *p_Palette)
{
(TEX_tdstPalette *) p_stTexture->p_vColorTable = p_Palette;
}
TEX_tdstPalette *TEX_vGetPaletteOfTexture ( struct GLI_tdstTexture_ *p_stTexture)
{
return ((TEX_tdstPalette *)p_stTexture -> p_vColorTable );
}
/*
* compression mode
*/
void TEX_vSetTextureCompressionMode ( struct GLI_tdstTexture_ *p_stTexture,long typeOfCompression)
{
p_stTexture->lTypeOfCompression = typeOfCompression;
}
long TEX_vGetTextureCompressionMode ( struct GLI_tdstTexture_ *p_stTexture)
{
return (p_stTexture->lTypeOfCompression );
}
/*
* mipmapping mode
*/
void TEX_vSetTextureMipMappingMode( struct GLI_tdstTexture_ *p_stTexture, long lTypeOfMipMapping)
{
p_stTexture->lTypeOfMipMapping = lTypeOfMipMapping;
}
long TEX_lGetTextureMipMappingMode( struct GLI_tdstTexture_ *p_stTexture)
{
return ( p_stTexture->lTypeOfMipMapping ) ;
}
/*
* texture name
*/
void GLI_vSetTextureName( GLI_tdstTexture *p_stTexture , char *p_cName )
{
//VLNEWTEXNAME
strcpy(p_stTexture->a255_cFileName, p_cName) ;
//strcpy(p_stTexture->szName, p_cName) ;
}
void GLI_vGetTextureName( GLI_tdstTexture *p_stTexture, char *p_cName )
{
//VLNEWTEXNAME
strcpy(p_cName, p_stTexture->a255_cFileName) ;
//strcpy(p_cName, p_stTexture->szName ) ;
}
/*
* texture substitution
*/
long TEX_bIsTextureSubstituedAfterCompression(struct GLI_tdstTexture_ *p_stTexture)
{
return ( (p_stTexture->lCompressionCounter != 0 ) && (p_stTexture->p_TextureOfSubstitution != NULL) );
}
void TEX_vSetSupplyTexture ( struct GLI_tdstTexture_ *p_stTexture, struct GLI_tdstTexture_ *p_stSupplyTexture)
{
p_stTexture->p_TextureOfSubstitution = p_stSupplyTexture;
}
struct GLI_tdstTexture_ *TEX_p_tdstGetSupplyTexture ( struct GLI_tdstTexture_ *p_stTexture)
{
return(p_stTexture -> p_TextureOfSubstitution );
}

View File

@@ -0,0 +1,430 @@
/*
=======================================================================================
Name : VisuaSet.c
Author : philippe vimont
Description : manage visual set structure
=======================================================================================
*/
#include "Gli_st.h"
#include "GLI_Defn.h"
#include "VisuS_st.h"
#include "light_st.h"
#include "PvObj_st.h"
#include "matstack.h"
#include "VisuSet.h"
#include "proj.h"
#include "linear.h"
#include "vpt3D.h"
#include "camera.h"
#include "Object.h"
#include "pvobj_st.h"
#include "PCS.h"
#include "PO.h"
#include "IPO.h"
#include "ISI.h"
//#include "light.h"
/* See "ACP_Visualsets.DOC" for more */
#ifdef __cplusplus
extern "C"
{
#endif
/*
=======================================================================================
externals
=======================================================================================
*/
extern GLI_tdstInternalGlobalValuesFor3dEngine *GLI_BIG_GLOBALS;
/*
=======================================================================================
Creation
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : create a visual set
lNbLOD -> number of Level Of Detail
----------------------------------------------------------------------------------------
*/
GEO_tdstVisualSet *GLI_p_stCreateVisualSet( long lNbLOD )
{
GEO_tdstVisualSet *p_stLocalVS;
ACP_tdxIndex xLodCounter;
MMG_fn_vAddMemoryInfo (MMG_C_lTypeGLI , MMG_C_lSubTypeVisualSet , NULL);
GEO_M_CPAMalloc(p_stLocalVS ,GEO_tdstVisualSet * ,sizeof ( GEO_tdstVisualSet ) ,E_uwGEONotEnoughtMemory );
if ( p_stLocalVS == NULL)
return NULL;
MMG_fn_vAddMemoryInfo (MMG_C_lTypeGLI , MMG_C_lSubTypeVisualSet , NULL);
GEO_M_CPAMalloc(p_stLocalVS -> d_xThresholdsTable ,MTH_tdxReal *,sizeof ( MTH_tdxReal ) * lNbLOD,E_uwGEONotEnoughtMemory );
if ( p_stLocalVS -> d_xThresholdsTable == NULL)
return NULL;
MMG_fn_vAddMemoryInfo (MMG_C_lTypeGLI , MMG_C_lSubTypeVisualSet , NULL);
GEO_M_CPAMalloc(p_stLocalVS -> d_p_stLodDefinitions ,GEO_tdstGeometricObject ** ,sizeof ( GEO_tdstGeometricObject * ) * lNbLOD,E_uwGEONotEnoughtMemory );
if ( p_stLocalVS -> d_p_stLodDefinitions == NULL)
return NULL;
p_stLocalVS -> xNbLodDefinitions = (ACP_tdxIndex)lNbLOD;
for (xLodCounter = 0; xLodCounter < lNbLOD; xLodCounter ++)
{
p_stLocalVS -> d_xThresholdsTable[xLodCounter] = 0.0;
p_stLocalVS -> d_p_stLodDefinitions[xLodCounter] = NULL;
}
return (p_stLocalVS);
};
/*
----------------------------------------------------------------------------------------
Description : create a visual set in the TMP memory block
lNbLOD -> number of Level Of Detail
----------------------------------------------------------------------------------------
*/
GEO_tdstVisualSet *GLI_p_stCreateTMPVisualSet ( long lNbLOD)
{
GEO_tdstVisualSet *p_stLocalVS;
ACP_tdxIndex xLodCounter;
MMG_fn_vAddMemoryInfo (MMG_C_lTypeGLI , MMG_C_lSubTypeVisualSet , NULL);
GEO_M_TMPMalloc(p_stLocalVS ,GEO_tdstVisualSet * ,sizeof ( GEO_tdstVisualSet ) );
if ( p_stLocalVS == NULL)
return(NULL);
MMG_fn_vAddMemoryInfo (MMG_C_lTypeGLI , MMG_C_lSubTypeVisualSet , NULL);
GEO_M_TMPMalloc(p_stLocalVS -> d_xThresholdsTable ,MTH_tdxReal *,sizeof ( MTH_tdxReal ) * lNbLOD );
if ( p_stLocalVS -> d_xThresholdsTable == NULL)
return(NULL);
MMG_fn_vAddMemoryInfo (MMG_C_lTypeGLI , MMG_C_lSubTypeVisualSet , NULL);
GEO_M_TMPMalloc(p_stLocalVS -> d_p_stLodDefinitions ,GEO_tdstGeometricObject ** ,sizeof ( GEO_tdstGeometricObject * ) * lNbLOD );
if ( p_stLocalVS -> d_p_stLodDefinitions == NULL)
return(NULL);
p_stLocalVS -> xNbLodDefinitions = (ACP_tdxIndex)lNbLOD;
for (xLodCounter = 0; xLodCounter < lNbLOD; xLodCounter ++)
{
p_stLocalVS -> d_xThresholdsTable[xLodCounter] = 0.0;
p_stLocalVS -> d_p_stLodDefinitions[xLodCounter] = NULL;
}
return (p_stLocalVS);
};
/*
=======================================================================================
Access functions
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : set / get a LOD of a visual set object
----------------------------------------------------------------------------------------
*/
void GLI_vSetVisualSetLOD ( GEO_tdstVisualSet *p_stVisualSet, long lNumberOfLodToSet, MTH_tdxReal xThreshold, GEO_tdstGeometricObject *p_stObject)
{
if (lNumberOfLodToSet < p_stVisualSet->xNbLodDefinitions)
{
p_stVisualSet -> d_xThresholdsTable[lNumberOfLodToSet] = xThreshold;
p_stVisualSet -> d_p_stLodDefinitions[lNumberOfLodToSet] = p_stObject;
}
}
void GLI_vGetVisualSetLOD ( GEO_tdstVisualSet *p_stVisualSet, long lNumberOfLodToGet, MTH_tdxReal *p_xThreshold, GEO_tdstGeometricObject **h_stObject )
{
if (lNumberOfLodToGet < p_stVisualSet -> xNbLodDefinitions)
{
*p_xThreshold = p_stVisualSet -> d_xThresholdsTable[lNumberOfLodToGet] ;
*h_stObject = p_stVisualSet -> d_p_stLodDefinitions[lNumberOfLodToGet] ;
}
}
GEO_tdstGeometricObject *GLI_hGetVisualSetGeometricForADistance( GEO_tdstVisualSet *p_stVSE, MTH_tdxReal xThreshold )
{
long lLod;
for (lLod = 0; lLod < p_stVSE->xNbLodDefinitions - 1; lLod ++)
{
if (p_stVSE->d_xThresholdsTable[ lLod + 1 ] > xThreshold)
break;
}
return (p_stVSE->d_p_stLodDefinitions[lLod]);
}
/*
----------------------------------------------------------------------------------------
Description : get number of LOD
----------------------------------------------------------------------------------------
*/
long GLI_lGetVisualSetNumbertOfLOD ( GEO_tdstVisualSet *p_stVisualSet )
{
return (p_stVisualSet->xNbLodDefinitions);
}
/*
=======================================================================================
Display
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : send object to display, with distance to camera computation, choice of LOD,
fog check, and RLI
----------------------------------------------------------------------------------------
*/
void GLI_lSendVisualSetToViewportWithRLI2
(
struct GLD_tdstViewportAttributes_ *p_stVpt ,
GEO_tdstVisualSet *p_stVisualSet,
MTH3D_tdstVector *p_xCenter,
long lDrawModeMask,
ACP_tdxHandleToRadiosity hISI
)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
ACP_tdxIndex lNumberOfLodToSend;
MTH_tdxReal xDistance;
MTH3D_tdstVector stLocal;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
GLI_xSetRLIForNextObjectToDraw ( NULL , NULL );
/* if visualset has only one LOD, and no fog or infinite fog distance, then display the LOD 0 */
if (p_stVisualSet -> xNbLodDefinitions == 1 && ( GLI_BIG_GLOBALS->xFogIsOn == 0 || GLI_BIG_GLOBALS->p_stActiveFog->xInfinite >= 50000.0f ) )
{
lNumberOfLodToSend = 0;
}
else
{
/*
* compute distance from camera to center of object
*/
POS_fn_vMulMatrixVertex ( &stLocal, g_p_stCurrentMatrix,p_xCenter );
POS_fn_vMulMatrixVertex ( &stLocal, &(( GLI_tdstSpecificAttributesFor3D *)p_stVpt->p_vSpecificToXD)->p_stCam->stMatrix , &stLocal);
xDistance = MTH3D_M_xNormVector( &stLocal ) ;
/* if fog is on and object is hidden by fog, then no display */
if (GLI_BIG_GLOBALS->xFogIsOn && xDistance >= GLI_BIG_GLOBALS->p_stActiveFog->xInfinite)
return;
/* find number of LOD to use according to distance */
for (lNumberOfLodToSend = 0; lNumberOfLodToSend < p_stVisualSet -> xNbLodDefinitions - 1; lNumberOfLodToSend ++)
{
if (p_stVisualSet -> d_xThresholdsTable [ lNumberOfLodToSend+1 ] > xDistance)
break;
}
}
/* look if it exist a RLI for the chosen LOD, if yes, set it */
if ((hISI) && (lNumberOfLodToSend<=ISI_fn_xGetNbLOD(hISI)))
{
GLI_xSetRLIForNextObjectToDraw (ISI_fn_dGetVertexRLILOD(hISI,lNumberOfLodToSend), p_stVisualSet -> d_p_stLodDefinitions[lNumberOfLodToSend]);
}
/* look if it exist a Geometric Object for the chosen LOD (???), if yes, send it to display */
if (p_stVisualSet -> d_p_stLodDefinitions[lNumberOfLodToSend] != NULL)
{
GLI_xSendObjectToViewportWithLights ( p_stVpt ,p_stVisualSet -> d_p_stLodDefinitions[lNumberOfLodToSend],lDrawModeMask);
}
}
/*
----------------------------------------------------------------------------------------
Description : send object to display, with distance to camera computation, choice of LOD,
fog check, but no RLI
----------------------------------------------------------------------------------------
*/
void GLI_lSendVisualSetToViewportBV2( struct GLD_tdstViewportAttributes_ *p_stVpt, GEO_tdstVisualSet *p_stVisualSet, MTH3D_tdstVector *p_xCenter, MTH_tdxReal xRadiusOfSphere, long lDrawModeMask)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long lNumberOfLodToSend;
MTH3D_tdstVector stLocal;
MTH_tdxReal xDistance;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
GLI_xSetRLIForNextObjectToDraw ( NULL , NULL );
/* if visualset has only one LOD, and no fog or infinite fog distance, then display the LOD 0 */
if (p_stVisualSet -> xNbLodDefinitions == 1 && ( GLI_BIG_GLOBALS->xFogIsOn == 0 || GLI_BIG_GLOBALS->p_stActiveFog->xInfinite >= 50000.0f ) )
{
lNumberOfLodToSend = 0;
}
else
{
/*
* compute distance from camera to center of object
*/
POS_fn_vMulMatrixVertex ( &stLocal, g_p_stCurrentMatrix,p_xCenter );
POS_fn_vMulMatrixVertex ( &stLocal, &(( GLI_tdstSpecificAttributesFor3D *)p_stVpt->p_vSpecificToXD)->p_stCam->stMatrix , &stLocal);
xDistance = MTH3D_M_xNormVector( &stLocal ) ;
/* if fog is on and object is hidden by fog, then no display */
if (GLI_BIG_GLOBALS->xFogIsOn && xDistance >= GLI_BIG_GLOBALS->p_stActiveFog->xInfinite)
return;
/* find number of LOD to use according to distance */
for (lNumberOfLodToSend = 0; lNumberOfLodToSend < p_stVisualSet -> xNbLodDefinitions - 1; lNumberOfLodToSend ++)
{
if (p_stVisualSet -> d_xThresholdsTable [ lNumberOfLodToSend+1 ] > xDistance)
break;
}
}
/* look if it exist a Geometric Object for the chosen LOD (???), if yes, send it to display */
if (p_stVisualSet -> d_p_stLodDefinitions[lNumberOfLodToSend] != NULL)
{
GLI_xSendObjectToViewportWithLights (p_stVpt, p_stVisualSet->d_p_stLodDefinitions[lNumberOfLodToSend], lDrawModeMask);
}
}
/*
----------------------------------------------------------------------------------------
Description : send object to display, with absolute distance, choice of LOD
----------------------------------------------------------------------------------------
*/
void GLI_lSendVisualSetToViewport( struct GLD_tdstViewportAttributes_ *p_stVpt, GEO_tdstVisualSet *p_stVisualSet, MTH_tdxReal xDistance, long lDrawModeMask)
{
long lNumberOfLodToSend;
/* reset RLI : no RLI for this function */
GLI_xSetRLIForNextObjectToDraw ( NULL , NULL );
/* find the right LOD for the given dstance */
for (lNumberOfLodToSend = 0; lNumberOfLodToSend < p_stVisualSet -> xNbLodDefinitions - 1; lNumberOfLodToSend ++)
{
if (p_stVisualSet -> d_xThresholdsTable [ lNumberOfLodToSend+1 ] > xDistance)
break;
}
/* LOD found, check if exist and send to drawing */
if (p_stVisualSet -> d_p_stLodDefinitions[lNumberOfLodToSend] != NULL)
{
GLI_xSendObjectToViewportWithLights ( p_stVpt, p_stVisualSet -> d_p_stLodDefinitions[lNumberOfLodToSend], lDrawModeMask);
}
}
/*
----------------------------------------------------------------------------------------
Description : send object to display, with distance to camera computation, choice of LOD
----------------------------------------------------------------------------------------
*/
void GLI_lSendVisualSetToViewport2( struct GLD_tdstViewportAttributes_ *p_stVpt, GEO_tdstVisualSet *p_stVisualSet, MTH3D_tdstVector *p_xCenter, long lDrawModeMask)
{
MTH3D_tdstVector stLocal;
GLI_tdstSpecificAttributesFor3D *p_stSpecifAttrib3D;
/* put object center in camera axis system (p_xCenter is in local coordinates system */
p_stSpecifAttrib3D = ( GLI_tdstSpecificAttributesFor3D *)p_stVpt->p_vSpecificToXD;
/* put center in world axis system */
POS_fn_vMulMatrixVertex ( &stLocal, g_p_stCurrentMatrix,p_xCenter );
/* and in camera axis system */
POS_fn_vMulMatrixVertex ( &stLocal, &(( GLI_tdstSpecificAttributesFor3D *)p_stVpt->p_vSpecificToXD)->p_stCam->stMatrix , &stLocal);
/* and call display function with right distance */
GLI_lSendVisualSetToViewport( p_stVpt ,p_stVisualSet ,MTH3D_M_xNormVector( &stLocal ) ,lDrawModeMask);
}
/*
=======================================================================================
RLI
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : return one of RLI Table
----------------------------------------------------------------------------------------
*/
ACP_tdxHandleToRadiosity GLI_hGetRLI ( GEO_tdxHandleToVisualSet hVisualSet, unsigned char ucIndex )
{
if ( ucIndex < hVisualSet->lNumberOfRLI )
return hVisualSet->d_hRLI[ucIndex] ;
return NULL;
}
/*
----------------------------------------------------------------------------------------
Description : compute a new RLI table that is a blend of two other table
----------------------------------------------------------------------------------------
*/
ACP_tdxHandleToRadiosity GLI_hComputeBlendRLI (GEO_tdxHandleToVisualSet hVisualSet, unsigned char ucIndex1, unsigned char ucIndex2, ACP_tdxIndex xNumISILOD, MTH_tdxReal xPercent)
{
if ( ucIndex1 < hVisualSet->lNumberOfRLI && ucIndex2 < hVisualSet->lNumberOfRLI )
{
return ISI_hComputeBlendRLI ( hVisualSet->d_hRLI[ucIndex1], hVisualSet->d_hRLI[ucIndex2], xNumISILOD, xPercent );
}
return NULL;
}
/*
----------------------------------------------------------------------------------------
Description : Set RLI table of a visual set
----------------------------------------------------------------------------------------
*/
void GLI_vVisualSetSetRLITable (GEO_tdxHandleToVisualSet hVisualSet, ACP_tdxHandleToRadiosity *d_hRLI, long lNumberOfTable)
{
if ( d_hRLI )
{
hVisualSet->d_hRLI = d_hRLI ;
hVisualSet->lNumberOfRLI = lNumberOfTable ;
}
}
/*
----------------------------------------------------------------------------------------
Description : Load the RLI section of the VSE of a charactere
----------------------------------------------------------------------------------------
*/
ACP_tdxHandleToRadiosity *GLI_vVisualSetLoadRLI (char *szSection, long *lNumberOfTable)
{
ACP_tdxHandleToRadiosity *d_hRLI ;
SCR_tdst_Cxt_Values *p_stVal=NULL;
p_stVal = SCR_fnp_st_RdL0_AnalyseSection(szSection, SCR_CDF_uw_Anl_Normal);
d_hRLI = (ACP_tdxHandleToRadiosity *)SCR_M_ul_RdL0_ExtractLongValue(p_stVal,0);
*lNumberOfTable = SCR_M_ul_RdL0_ExtractLongValue(p_stVal,1);
return (d_hRLI);
}
/*
----------------------------------------------------------------------------------------
Description : script callback for RLI section
----------------------------------------------------------------------------------------
*/
SCR_tde_Anl_ReturnValue GLI_fn_xLoadRLI(SCR_tdst_File_Description *p_fFile, char *szAction, char *szParams[], SCR_tde_Anl_Action cType)
{
long lNumberOfRLI ;
ACP_tdxHandleToRadiosity *d_hRLI;
switch (cType)
{
case SCR_EA_Anl_BeginSection:
lNumberOfRLI = atol(szParams[1]) ;
MMG_fn_vAddMemoryInfo (MMG_C_lTypeGLI , MMG_C_lSubTypeRLI , NULL);
GEO_M_CPAMalloc(d_hRLI ,ACP_tdxHandleToRadiosity * ,sizeof ( ACP_tdxHandleToRadiosity ) ,E_uwGEONotEnoughtMemory );
SCR_M_RdL0_SetSectionLong(0,0,(long)d_hRLI);
SCR_M_RdL0_SetSectionLong(0,1,lNumberOfRLI);
SCR_M_RdL0_SetContextLong(0,0,(long)d_hRLI);
break;
}
return SCR_ERV_Anl_NormalReturn;
}
#ifdef __cplusplus
} /*extern "C"*/
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,565 @@
#include "watrplan.h"
#include "linear.h"
#include "proj.h"
void GLI_vSinusEffetOn3DVertex ( MTH3D_tdstVector * p_stVertex3D ) ;
/*
=======================================================================================
Name : Camera.cxx
Description : Camera function -- PC specific version
=======================================================================================
*/
static GLI_tdstCamera *p_stCamAntiBug;
void GLI_xAdjustCameraToViewport2 (GLD_tdstDeviceAttributes *p_stDev, GLD_tdstViewportAttributes *p_stVpt, GLI_tdstCamera *p_stCam ) ;
void GLI_xCreateCamera ( GLI_tdstCamera **h_stCam , long lCameraMode )
{
MMG_fn_vAddMemoryInfo (MMG_C_lTypeGLI , MMG_C_lSubTypeCamera , NULL);
GEO_M_CPAMalloc(*h_stCam,GLI_tdstCamera *,sizeof ( GLI_tdstCamera),E_uwGEONotEnoughtMemory );
if ( (*h_stCam) == NULL)
return;
(*h_stCam)->lCameraMode = lCameraMode ;
switch ( (*h_stCam) -> lCameraMode )
{
case GLI_C_lIsoCamWithDistorsion :
case GLI_C_lIsoCamWithoutDistorsion :
(*h_stCam)->xAlphaX = GLI_M_LongToValue ( 1 ) ;
(*h_stCam)->xAlphaY = GLI_M_LongToValue ( 1 ) ;
break ;
case GLI_C_lPersCamWithDistorsion :
case GLI_C_lPersCamWithoutDistorsion :
(*h_stCam)-> xAlphaX = GLI_M_PIO4 ;
(*h_stCam)-> xAlphaY = GLI_M_PIO4 ;
break;
default:
break;
}
(*h_stCam)-> xNear = GLI_C_xZClippingNear ;
(*h_stCam)-> xFar = GLI_M_FloatToValue( 10000.0 ) ;
(*h_stCam)-> xRatio = GLI_M_Div ((*h_stCam)->xAlphaY , (*h_stCam)->xAlphaX );
return;
}
/*
----------------------------------------------------------------------------------------
Description : Adjust camera parameters to fit with viewport parameters
----------------------------------------------------------------------------------------
*/
void GLI_xAdjustCameraToViewport ( GLD_tdhDevice hDevice, GLD_tdhViewport hViewport, GLI_tdstCamera *p_stCam )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
GLD_tdstDeviceAttributes stDevAttrib;
GLD_tdstViewportAttributes stViewAttrib;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
if ( !GLD_bGetDeviceAttributes( hDevice, &stDevAttrib ) )
return ;
if ( !GLD_bGetViewportAttributes( hDevice, hViewport, &stViewAttrib ) )
return;
/* ANTI BUG ------------------------------------------- */
if (p_stCam == NULL)
p_stCam = p_stCamAntiBug;
else
p_stCamAntiBug = p_stCam;/* */
/* ANTI BUG ------------------------------------------- */
GLI_xAdjustCameraToViewport2 (&stDevAttrib, &stViewAttrib, p_stCam) ;
return;
}
/*
----------------------------------------------------------------------------------------
Description : transform 2D position to 3D position
----------------------------------------------------------------------------------------
*/
void GLI_vGet3DVertexFromScreenPos
(
GLD_tdstViewportAttributes *p_stVpt,
MTH3D_tdstVector *p_stPos3D,
MTH_tdxReal xRatioX,
MTH_tdxReal xRatioY,
MTH_tdxReal xSize
)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
GLI_tdst2DVertex stPos2D, stTrans ;
GLI_tdstSpecificAttributesFor3D *p_stSpecAttrib3D;
GLI_tdstCamera *p_stCam;
MTH_tdxReal xScreen;
MTH3D_tdstVector stTemp ;
POS_tdstCompletePosition stMatrix, stInvMatrix ;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
stPos2D.xX = p_stVpt->dwWidth * xRatioX ;
stPos2D.xY = p_stVpt->dwHeight * xRatioY;
p_stSpecAttrib3D = (GLI_tdstSpecificAttributesFor3D *)p_stVpt->p_vSpecificToXD;
p_stCam = p_stSpecAttrib3D->p_stCam ;
switch(p_stCam->lCameraMode)
{
case GLI_C_lIsoCamWithDistorsion :
case GLI_C_lIsoCamWithoutDistorsion :
xScreen = MTH_M_xFloatToReal(0.1f);
break;
case GLI_C_lPersCamWithDistorsion :
case GLI_C_lPersCamWithoutDistorsion :
xScreen = p_stCam->xScreen;
break ;
default:
p_stPos3D->xX = p_stPos3D->xY = p_stPos3D->xZ = MTH_M_xFloatToReal(0.0f);
return;
}
stTrans.xX = p_stCam->stTrans.xX;
stTrans.xY = p_stCam->stTrans.xY;
if ( xSize != 0.0 )
{
stTemp.xX = MTH_M_xDiv( MTH_M_xDiv( MTH_M_xSub( MTH_M_xLongToReal(stPos2D.xX), MTH_M_xLongToReal(stTrans.xX)), MTH_M_xFloatToReal(p_stCam->stScale.xX)), MTH_M_xFloatToReal(xSize) );
stTemp.xY = MTH_M_xDiv( MTH_M_xDiv( MTH_M_xSub( MTH_M_xLongToReal(stPos2D.xY), MTH_M_xLongToReal(stTrans.xY)),MTH_M_xFloatToReal(p_stCam->stScale.xY) ), MTH_M_xFloatToReal(xSize) );
stTemp.xZ = MTH_M_xMul( xScreen, MTH_M_xDiv( MTH_M_xAdd( MTH_M_xFloatToReal(1.0f), xSize ), xSize) );
}
else
{
stTemp.xX = MTH_M_xDiv( MTH_M_xSub( MTH_M_xLongToReal(stPos2D.xX), MTH_M_xLongToReal(stTrans.xX)),MTH_M_xFloatToReal(p_stCam->stScale.xX) ) ;
stTemp.xY = MTH_M_xDiv( MTH_M_xSub( MTH_M_xLongToReal(stPos2D.xY), MTH_M_xLongToReal(stTrans.xY)),MTH_M_xFloatToReal(p_stCam->stScale.xY) ) ;
stTemp.xZ = MTH_M_xFloatToReal(0.0f);
}
/*
* Convertion dans le repere du monde
*/
GLI_xGetCameraMatrix ( p_stCam , &stMatrix );
POS_fn_vInvertMatrix ( &stInvMatrix , &stMatrix );
POS_fn_vMulMatrixVertex ( p_stPos3D , &stInvMatrix , &stTemp );
}
/*
----------------------------------------------------------------------------------------
Description : Adjust camera parameters to fit with viewport parameters
----------------------------------------------------------------------------------------
*/
void GLI_xAdjustCameraToViewport2 (GLD_tdstDeviceAttributes *p_stDev, GLD_tdstViewportAttributes *p_stVpt, GLI_tdstCamera *p_stCam ) {
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
GLI_tdxValue xHeightForAlphaY ;
GLI_tdxValue xVptWidthInPix , xVptHeightInPix ;
GLI_tdxValue xVptWidthInMeters , xVptHeightInMeters ;
GLI_tdxValue xVptRatio , xOOScale;
GLI_tdstSpecificAttributesFor3D *p_stSpecAttrib3D;
float fZ, fOoL, fH;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
p_stSpecAttrib3D = (GLI_tdstSpecificAttributesFor3D *) p_stVpt->p_vSpecificToXD;
xVptWidthInPix = GLI_M_LongToValue ( p_stVpt->dwWidth ) ;
xVptWidthInMeters = GLI_M_Mul ( xVptWidthInPix , p_stDev->xPixelDimensionX ) ;
xVptHeightInPix = GLI_M_LongToValue ( p_stVpt->dwHeight ) ;
xVptHeightInMeters = GLI_M_Mul ( xVptHeightInPix , p_stDev->xPixelDimensionY ) ;
xVptRatio = GLI_M_Div ( xVptHeightInMeters , xVptWidthInMeters ) ;
p_stCam->stTrans.xX = (int) p_stVpt->iOffsetPosX + MTH_M_xRealToFloat( GLI_M_Mul ( xVptWidthInPix , GLI_M_FloatToValue ( 0.5f ) ) ) ;
p_stCam->stTrans.xY = (int) p_stVpt->iOffsetPosY + MTH_M_xRealToFloat( GLI_M_Mul ( xVptHeightInPix, GLI_M_FloatToValue ( 0.5f ) ) ) ;
switch ( p_stCam -> lCameraMode )
{
case GLI_C_lIsoCamWithoutDistorsion :
p_stCam->xScreen = GLI_M_LongToValue ( 0 ) ;
p_stCam->xAlphaY = p_stCam -> xAlphaX ;
p_stCam->stScale.xX = MTH_M_xRealToFloat( GLI_M_Neg ( GLI_M_Inv ( GLI_M_Mul ( p_stCam -> xAlphaX , p_stDev->xPixelDimensionX ) ) ) ) ;
p_stCam->stScale.xY = MTH_M_xRealToFloat( GLI_M_Neg ( GLI_M_Inv ( GLI_M_Mul ( p_stCam -> xAlphaY , p_stDev->xPixelDimensionY ) ) ) ) ;
p_stCam->stNormPlaneUp .xX = p_stCam->stNormPlaneDown.xX =
p_stCam->stNormPlaneRight .xY = p_stCam->stNormPlaneLeft.xY =
p_stCam->stNormPlaneRight .xZ = p_stCam->stNormPlaneLeft.xZ =
p_stCam->stNormPlaneDown .xZ = p_stCam->stNormPlaneUp .xZ = 0.0f;
p_stCam->stNormPlaneLeft .xX = -1.0f;
p_stCam->stNormPlaneRight .xX = +1.0f;
p_stCam->stNormPlaneUp .xY = -1.0f;
p_stCam->stNormPlaneDown .xY = +1.0f;
xOOScale = -GLI_M_Div ( xVptWidthInPix , p_stCam -> stScale . xX);
xOOScale = GLI_M_Mul ( xOOScale , GLI_M_FloatToValue ( 0.5f ) );
p_stCam -> xDistPlaneRight = xOOScale ;
p_stCam -> xDistPlaneLeft = xOOScale ;
xOOScale = -GLI_M_Div ( xVptHeightInPix , p_stCam -> stScale . xY);
xOOScale = GLI_M_Mul ( xOOScale , GLI_M_FloatToValue ( 0.5f ) );
p_stCam -> xDistPlaneUp = xOOScale ;
p_stCam -> xDistPlaneDown = xOOScale ;
break;
case GLI_C_lIsoCamWithDistorsion :
p_stCam->xScreen = GLI_M_LongToValue ( 0 ) ;
p_stCam->stScale.xX = MTH_M_xRealToFloat( GLI_M_Neg ( GLI_M_Div ( xVptWidthInPix , GLI_M_Mul ( GLI_M_Mul ( p_stCam -> xAlphaX , GLI_M_LongToValue ( p_stVpt->dwWidth ) ) , p_stDev->xPixelDimensionX ) ) ) );
p_stCam->stScale.xY = MTH_M_xRealToFloat( GLI_M_Neg ( GLI_M_Div ( xVptHeightInPix ,GLI_M_Mul ( GLI_M_Mul ( p_stCam -> xAlphaY , GLI_M_LongToValue ( p_stVpt->dwHeight ) ) , p_stDev->xPixelDimensionY ) ) ) ) ;
p_stCam -> stNormPlaneUp .xX = p_stCam -> stNormPlaneDown .xX =
p_stCam -> stNormPlaneRight .xY = p_stCam -> stNormPlaneLeft .xY =
p_stCam -> stNormPlaneRight .xZ = p_stCam -> stNormPlaneLeft .xZ =
p_stCam -> stNormPlaneDown .xZ = p_stCam -> stNormPlaneUp .xZ = 0.0f;
p_stCam -> stNormPlaneLeft .xX = -1.0f;
p_stCam -> stNormPlaneRight .xX = +1.0f;
p_stCam -> stNormPlaneUp .xY = -1.0f;
p_stCam -> stNormPlaneDown .xY = +1.0f;
xOOScale = -GLI_M_Div ( xVptWidthInPix , p_stCam -> stScale . xX);
xOOScale = GLI_M_Mul ( xOOScale , GLI_M_FloatToValue ( 0.5f ) );
p_stCam -> xDistPlaneRight = xOOScale ;
p_stCam -> xDistPlaneLeft = xOOScale ;
xOOScale = -GLI_M_Div ( xVptHeightInPix , p_stCam -> stScale . xY);
xOOScale = GLI_M_Mul ( xOOScale , GLI_M_FloatToValue ( 0.5f ) );
p_stCam -> xDistPlaneUp = xOOScale ;
p_stCam -> xDistPlaneDown = xOOScale ;
break ;
case GLI_C_lPersCamWithoutDistorsion :
p_stCam -> xScreen = GLI_M_Mul
(
GLI_M_Mul
(
GLI_M_Mul ( GLI_M_LongToValue ( p_stVpt->dwWidth ) ,p_stDev->xPixelDimensionX ) ,
GLI_M_FloatToValue ( 0.5f )
) ,
GLI_M_Cotan ( GLI_M_Mul ( p_stCam -> xAlphaX , GLI_M_FloatToValue ( 0.5f ) ) )
) ;
p_stCam -> stScale . xX = MTH_M_xRealToFloat
(
GLI_M_Mul
(
GLI_M_Neg ( GLI_M_Inv ( p_stDev->xPixelDimensionX ) ) ,
GLI_M_Div ( GLI_M_LongToValue(xVptWidthInPix) , GLI_M_LongToValue(p_stVpt->dwWidth) )
)
);
xHeightForAlphaY = MTH_M_xRealToFloat
(
GLI_M_Mul
(
GLI_M_Mul ( GLI_M_LongToValue ( 2 ) , p_stCam -> xScreen ) ,
GLI_M_Tan ( GLI_M_Mul ( GLI_M_FloatToValue ( 0.5f ) , p_stCam -> xAlphaY ) )
)
);
p_stCam->stScale.xY = MTH_M_xRealToFloat( GLI_M_Neg ( GLI_M_Div ( xVptHeightInPix , xHeightForAlphaY ) ) ) ;
{
fH = (float)((long)(p_stVpt->dwClipRightInPix - p_stVpt->iOffsetPosX) - (long)(p_stVpt->dwWidth / 2));
fZ = (p_stVpt->dwWidth / 2) / MTH_M_xTan( MTH_M_xMul( p_stCam->xAlphaX , 0.5f));
fOoL = fZ * fZ + fH * fH;
fOoL = MTH_M_xInvSqrt( fOoL );
p_stCam->stNormPlaneLeft.xX = -fZ * fOoL;
p_stCam->stNormPlaneLeft.xY = 0.0f;
p_stCam->stNormPlaneLeft.xZ = -fH * fOoL;
fH = (float)((long)(p_stVpt->dwWidth / 2) - (long)(p_stVpt->dwClipLeftInPix - p_stVpt->iOffsetPosY) );
fOoL = fZ * fZ + fH * fH;
fOoL = MTH_M_xInvSqrt( fOoL );
p_stCam->stNormPlaneRight.xX = fZ * fOoL;
p_stCam->stNormPlaneRight.xY = 0.0f;
p_stCam->stNormPlaneRight.xZ = -fH * fOoL;
}
{
fH = (float)((long)(p_stVpt->dwClipBottomInPix - p_stVpt->iOffsetPosY) - (long)(p_stVpt->dwHeight / 2)) ;
fZ = (p_stVpt->dwHeight / 2) / MTH_M_xTan( MTH_M_xMul( p_stCam->xAlphaY , 0.5f));
fOoL = fZ * fZ + fH * fH;
fOoL = MTH_M_xInvSqrt( fOoL );
p_stCam->stNormPlaneDown.xX = 0.0f;
p_stCam->stNormPlaneDown.xY = -fZ * fOoL;
p_stCam->stNormPlaneDown.xZ = -fH * fOoL;
fH = (float)((long)(p_stVpt->dwHeight / 2) - ((long)p_stVpt->dwClipTopInPix - p_stVpt->iOffsetPosY) ) ;
fOoL = fZ * fZ + fH * fH;
fOoL = MTH_M_xInvSqrt( fOoL );
p_stCam->stNormPlaneUp.xX = 0.0f;
p_stCam->stNormPlaneUp.xY = fZ * fOoL;
p_stCam->stNormPlaneUp.xZ = -fH * fOoL;
}
p_stCam -> xDistPlaneUp = 0.0f;
p_stCam -> xDistPlaneDown = 0.0f;
p_stCam -> xDistPlaneRight = 0.0f;
p_stCam -> xDistPlaneLeft = 0.0f;
break;
case GLI_C_lPersCamWithDistorsion :
p_stCam -> xScreen = GLI_M_Mul ( GLI_M_Mul ( xVptWidthInMeters , GLI_M_FloatToValue ( 0.5f ) ) , GLI_M_Cotan ( GLI_M_Mul ( p_stCam -> xAlphaX , GLI_M_FloatToValue ( 0.5f ) ) ) ) ;
p_stCam -> xAlphaY = GLI_M_Mul ( GLI_M_LongToValue ( 2 ) , GLI_M_Atan ( GLI_M_Div ( xVptHeightInMeters , GLI_M_Mul ( GLI_M_LongToValue ( 2 ) , p_stCam -> xScreen ) ) ) ) ;
p_stCam -> stScale . xX = MTH_M_xRealToFloat( GLI_M_Neg ( GLI_M_Inv ( p_stDev->xPixelDimensionX ) ) );
p_stCam -> stScale . xY = MTH_M_xRealToFloat( GLI_M_Neg ( GLI_M_Inv ( p_stDev->xPixelDimensionY ) ) ) ;
/* compute norme & disytances of 4 planes of camera*/
p_stCam -> stNormPlaneLeft .xZ = -MTH_M_xSin( MTH_M_xMul( p_stCam -> xAlphaX , 0.5f));
p_stCam -> stNormPlaneRight .xZ = p_stCam -> stNormPlaneLeft .xZ;
p_stCam -> stNormPlaneLeft .xX = -MTH_M_xCos( MTH_M_xMul( p_stCam -> xAlphaX , 0.5f));
p_stCam -> stNormPlaneRight .xX = -p_stCam -> stNormPlaneLeft .xX;
p_stCam -> stNormPlaneRight .xY = p_stCam -> stNormPlaneLeft .xY = 0.0f;
p_stCam -> stNormPlaneUp .xZ = -MTH_M_xSin( MTH_M_xMul( p_stCam -> xAlphaY , 0.65f));
p_stCam -> stNormPlaneDown .xZ = p_stCam -> stNormPlaneUp .xZ ;
p_stCam -> stNormPlaneUp .xY = MTH_M_xCos( MTH_M_xMul( p_stCam -> xAlphaY , 0.65f));
p_stCam -> stNormPlaneDown .xY = -p_stCam -> stNormPlaneUp .xY;
p_stCam -> stNormPlaneUp .xX = p_stCam -> stNormPlaneDown .xX = 0.0f;
MTH3D_M_vNormalizeVector(&p_stCam -> stNormPlaneDown , &p_stCam -> stNormPlaneDown );
p_stCam -> xDistPlaneUp = 0.0f;
p_stCam -> xDistPlaneDown = 0.0f;
p_stCam -> xDistPlaneRight = 0.0f;
p_stCam -> xDistPlaneLeft = 0.0f;
break ;
}
return;
}
/*
----------------------------------------------------------------------------------------
Description : Adjust the camera to the mirror for an optimized clipping
----------------------------------------------------------------------------------------
*/
ACP_tdxBool GLI_vAdjustCameraToMirror( ACP_tdxHandleOfObject hHandleOfGometricMirror, GEO_tdxHandleToMatrix hGlobalMatrixOfMirror, GEO_tdxHandleToMatrix hMatrixOfCamera, struct GLI_tdstCamera_ *pstCamera, GLD_tdstViewportAttributes *p_stVpt,long lDrawModeMask)
{
MTH3D_tdstVector pstPointOfRectangleMirror[4];
GLI_tdstAligned3DVector pstAligned3DPointOfRectangleMirror[4];
GLI_tdstAligned3DVector pstAligned3DCorrectedPointOfRectangleMirror[5];
GLI_tdstAligned2DVector pstAligned2DProjectedPointOfRectangleMirror[5];
short i,j;
ACP_tdxIndex xTempIndexForRectangle;
float fXMin,fXMax,fYMin,fYMax;
float fXMin1,fXMax1,fYMin1,fYMax1;
float xConstantMinForZ;
float xConstantDivForZ;
POS_tdstCompletePosition stMatrixFromSuperObjectToCamera;
ACP_tdxBool bIDrawTheMirrorNormally=TRUE;
ACP_tdxBool p_bPointOfMirrorIsBehindCamera[4];
float fNear;
fXMin1=(float)p_stVpt->dwClipLeftInPix;
fXMax1=(float)p_stVpt->dwClipRightInPix;
fYMin1=(float)p_stVpt->dwClipTopInPix;
fYMax1=(float)p_stVpt->dwClipBottomInPix;
xTempIndexForRectangle=hHandleOfGometricMirror->xNbPoints;
for (j=0;j<4;j++)
{
xTempIndexForRectangle--;
GEO_vGetPointOfObject(hHandleOfGometricMirror,&pstPointOfRectangleMirror[j],xTempIndexForRectangle);
}
POS_fn_vSetIdentityMatrix(&stMatrixFromSuperObjectToCamera);
POS_fn_vMulMatrixMatrix(&stMatrixFromSuperObjectToCamera,hMatrixOfCamera,hGlobalMatrixOfMirror);
GLI_xSerialLinearOp (4 ,pstPointOfRectangleMirror,
pstAligned3DPointOfRectangleMirror ,
&stMatrixFromSuperObjectToCamera);
fNear = pstCamera->xFar;
for (j=0;j<4;j++) {
/* check if There is a Sinus Effect*/
if ( ( (g_cSinusEffectState == 1) && ((lDrawModeMask & GLI_C_lHasNotSinusEffect) == 0) ) ||
( (g_cSinusEffectState == 2) && (lDrawModeMask & GLI_C_lHasNotSinusEffect) ) ||
(g_cSinusEffectState == 3) )
GLI_vSinusEffetOn3DVertex((MTH3D_tdstVector *)&pstAligned3DPointOfRectangleMirror[j]) ;
fNear = MTH_M_xMin(fNear,pstAligned3DPointOfRectangleMirror[j].xZ);
if (MTH_M_bLess(pstAligned3DPointOfRectangleMirror[j].xZ,pstCamera->xNear))
p_bPointOfMirrorIsBehindCamera[j]=TRUE;
else p_bPointOfMirrorIsBehindCamera[j]=FALSE;
}
xConstantMinForZ = pstCamera->xNear = MTH_M_xMax(fNear,pstCamera->xNear);
if ((p_bPointOfMirrorIsBehindCamera[0])||
(p_bPointOfMirrorIsBehindCamera[1])||
(p_bPointOfMirrorIsBehindCamera[2])||
(p_bPointOfMirrorIsBehindCamera[3])) bIDrawTheMirrorNormally=FALSE;
if (bIDrawTheMirrorNormally)
{
GLI_xSerialProjection (pstCamera ,4 ,
pstAligned3DPointOfRectangleMirror ,
pstAligned2DProjectedPointOfRectangleMirror ) ;
fXMin=fXMax1;
fXMax=fXMin1;
fYMin=fYMax1;
fYMax=fXMin1;
for (j=0;j<4;j++)
{
if (MTH_M_bLess(pstAligned2DProjectedPointOfRectangleMirror[j].xX,fXMin)) fXMin=pstAligned2DProjectedPointOfRectangleMirror[j].xX;
if (MTH_M_bGreater(pstAligned2DProjectedPointOfRectangleMirror[j].xX,fXMax)) fXMax=pstAligned2DProjectedPointOfRectangleMirror[j].xX;
if (MTH_M_bLess(pstAligned2DProjectedPointOfRectangleMirror[j].xY,fYMin)) fYMin=pstAligned2DProjectedPointOfRectangleMirror[j].xY;
if (MTH_M_bGreater(pstAligned2DProjectedPointOfRectangleMirror[j].xY,fYMax)) fYMax=pstAligned2DProjectedPointOfRectangleMirror[j].xY;
}
if (MTH_M_bGreater(fXMin,fXMax)) return FALSE;
if (MTH_M_bGreater(fYMin,fYMax)) return FALSE;
fXMin=MTH_M_xSub(fXMin,MTH_C_ONE);
fXMax=MTH_M_xAdd(fXMax,MTH_C_ONE);
fYMin=MTH_M_xSub(fYMin,MTH_C_ONE);
fYMax=MTH_M_xAdd(fYMax,MTH_C_ONE);
if (MTH_M_bLess(fXMin,fXMin1)) fXMin=fXMin1;
if (MTH_M_bGreater(fXMax,fXMax1)) fXMax=fXMax1;
if (MTH_M_bLess(fYMin,fYMin1)) fYMin=fYMin1;
if (MTH_M_bGreater(fYMax,fYMax1)) fYMax=fYMax1;
p_stVpt->dwClipLeftInPix=((long)fXMin);
p_stVpt->dwClipRightInPix=((long)fXMax);
p_stVpt->dwClipTopInPix=((long)fYMin);
p_stVpt->dwClipBottomInPix=((long)fYMax);
return TRUE;
}
else
{
if ((p_bPointOfMirrorIsBehindCamera[0])&&
(p_bPointOfMirrorIsBehindCamera[1])&&
(p_bPointOfMirrorIsBehindCamera[2])&&
(p_bPointOfMirrorIsBehindCamera[3])) return FALSE;
else
{
short xNewNbPoints=0;
for (i=0;i<4;i++)
{
if (!p_bPointOfMirrorIsBehindCamera[i])
{
pstAligned3DCorrectedPointOfRectangleMirror[xNewNbPoints].xX=pstAligned3DPointOfRectangleMirror[i].xX;
pstAligned3DCorrectedPointOfRectangleMirror[xNewNbPoints].xY=pstAligned3DPointOfRectangleMirror[i].xY;
pstAligned3DCorrectedPointOfRectangleMirror[xNewNbPoints].xZ=pstAligned3DPointOfRectangleMirror[i].xZ;
xNewNbPoints++;
}
else
{
short xIPlusTemp=(i+1)%4;
if (!p_bPointOfMirrorIsBehindCamera[xIPlusTemp])
{
xConstantDivForZ=
MTH_M_xDiv(MTH_M_xSub(xConstantMinForZ,pstAligned3DPointOfRectangleMirror[i].xZ),
pstAligned3DPointOfRectangleMirror[xIPlusTemp].xZ);
pstAligned3DCorrectedPointOfRectangleMirror[xNewNbPoints].xX=
MTH_M_xAdd(pstAligned3DPointOfRectangleMirror[i].xX,MTH_M_xMul(xConstantDivForZ,
pstAligned3DPointOfRectangleMirror[xIPlusTemp].xX));
pstAligned3DCorrectedPointOfRectangleMirror[xNewNbPoints].xY=
MTH_M_xAdd(pstAligned3DPointOfRectangleMirror[i].xY,MTH_M_xMul(xConstantDivForZ,
pstAligned3DPointOfRectangleMirror[xIPlusTemp].xY));
pstAligned3DCorrectedPointOfRectangleMirror[xNewNbPoints].xZ=xConstantMinForZ;
xNewNbPoints++;
}
xIPlusTemp=(i+3)%4;
if (!p_bPointOfMirrorIsBehindCamera[xIPlusTemp])
{
xConstantDivForZ=
MTH_M_xDiv(MTH_M_xSub(xConstantMinForZ,pstAligned3DPointOfRectangleMirror[i].xZ),
pstAligned3DPointOfRectangleMirror[xIPlusTemp].xZ);
pstAligned3DCorrectedPointOfRectangleMirror[xNewNbPoints].xX=
MTH_M_xAdd(pstAligned3DPointOfRectangleMirror[i].xX,MTH_M_xMul(xConstantDivForZ,
pstAligned3DPointOfRectangleMirror[xIPlusTemp].xX));
pstAligned3DCorrectedPointOfRectangleMirror[xNewNbPoints].xY=
MTH_M_xAdd(pstAligned3DPointOfRectangleMirror[i].xY,MTH_M_xMul(xConstantDivForZ,
pstAligned3DPointOfRectangleMirror[xIPlusTemp].xY));
pstAligned3DCorrectedPointOfRectangleMirror[xNewNbPoints].xZ=xConstantMinForZ;
xNewNbPoints++;
}
}/* End of if point is behind */
}/*End of for i*/
GLI_xSerialProjection (pstCamera ,xNewNbPoints ,
pstAligned3DCorrectedPointOfRectangleMirror ,
pstAligned2DProjectedPointOfRectangleMirror ) ;
/* g_stCurLLInterface.p_fnSerialSnap2DVertices (pstAligned2DProjectedPointOfRectangleMirror,xNewNbPoints);*/
fXMin=fXMax1;
fXMax=fXMin1;
fYMin=fYMax1;
fYMax=fXMin1;
for (j=0;j<xNewNbPoints;j++)
{
if (MTH_M_bLess(pstAligned2DProjectedPointOfRectangleMirror[j].xX,fXMin)) fXMin=pstAligned2DProjectedPointOfRectangleMirror[j].xX;
if (MTH_M_bGreater(pstAligned2DProjectedPointOfRectangleMirror[j].xX,fXMax)) fXMax=pstAligned2DProjectedPointOfRectangleMirror[j].xX;
if (MTH_M_bLess(pstAligned2DProjectedPointOfRectangleMirror[j].xY,fYMin)) fYMin=pstAligned2DProjectedPointOfRectangleMirror[j].xY;
if (MTH_M_bGreater(pstAligned2DProjectedPointOfRectangleMirror[j].xY,fYMax)) fYMax=pstAligned2DProjectedPointOfRectangleMirror[j].xY;
}
if (MTH_M_bGreater(fXMin,fXMax)) return FALSE;
if (MTH_M_bGreater(fYMin,fYMax)) return FALSE;
fXMin=MTH_M_xSub(fXMin,MTH_C_ONE);
fXMax=MTH_M_xAdd(fXMax,MTH_C_ONE);
fYMin=MTH_M_xSub(fYMin,MTH_C_ONE);
fYMax=MTH_M_xAdd(fYMax,MTH_C_ONE);
if (MTH_M_bLess(fXMin,fXMin1)) fXMin=fXMin1;
if (MTH_M_bGreater(fXMax,fXMax1)) fXMax=fXMax1;
if (MTH_M_bLess(fYMin,fYMin1)) fYMin=fYMin1;
if (MTH_M_bGreater(fYMax,fYMax1)) fYMax=fYMax1;
p_stVpt->dwClipLeftInPix=((long)fXMin);
p_stVpt->dwClipRightInPix=((long)fXMax);
p_stVpt->dwClipTopInPix=((long)fYMin);
p_stVpt->dwClipBottomInPix=((long)fYMax);
return TRUE;
}/*End of not all points behind*/
}/*End of not draw normally */
return FALSE;
}

View File

@@ -0,0 +1,201 @@
#include "ldt.h"
HREF g_hRefLight;
void fn_vPostProcessLight ( HREF hRef )
{
LDT_tdst_Link *pObject;
LDT_tdst_Link *pGetFrom;
int iType;
short xCount;
long *pVal;
while( LDT_GetRefFromTable( hRef, &pObject, &pGetFrom, &iType, &xCount, &pVal )==0 )
{
POS_tdstCompletePosition * p_stMatrix = (POS_tdstCompletePosition *)pGetFrom->pObject;
LGT_tdxHandleToLight hLight=(LGT_tdxHandleToLight)pObject->pObject;
GLI_xSetLightMatrix(hLight,p_stMatrix);
/* ATTENTION : dans light il y a une matrix et non un pointeur sur matrix*/
/* La matrice est donc (sauvagement) recopi<70>e.*/
/* En toute rigueur je devrais lib<69>rer p_stMatrix, mais, <20> terme,*/
/* je pense que light contiendra un pointeur (sigh...)*/
}
}
/*****************************************************************
Name:
Description: Create callback for LDT
Author: Mircea Petrescu
Date: 8/25/98
Modified:
*****************************************************************/
int fn_iCreateLight( LDT_tdst_Link *pLink )
{
LGT_tdxHandleToLight hLight;
GLI_xCreateLight(&hLight, 0);
pLink->pObject=(void *)hLight;
return 0;
}
/*****************************************************************
Name:
Description: Load callback for LDT
Author: Mircea Petrescu
Date: 8/26/98
Modified:
*****************************************************************/
int fn_iLoadLight( LDT_tdst_Link *pLink )
{
LDT_tdeParseResult result=ParseResult_BeginSection;
LGT_tdxHandleToLight hLight=(LGT_tdxHandleToLight)pLink->pObject;
POS_tdstCompletePosition *p_stMatrix;
long lOnOff;
GEO_tdstColor stColor;
long lTypeOfLight;
char a255_cLongName[255];
MTH3D_tdstVector myGetVector;
char *szName=LDT_szGetParam(1);
int iLen;
if(stricmp(szName,"Parallel")==0) lTypeOfLight=GLI_C_lParallelLight;
else if(stricmp(szName,"Spherical")==0) lTypeOfLight=GLI_C_lSphericalLight;
else if(stricmp(szName,"HotSpot")==0) lTypeOfLight=GLI_C_lHotSpotLight;
else if(stricmp(szName,"Ambient")==0) lTypeOfLight=GLI_C_lAmbientLight;
else if(stricmp(szName,"ParallelBox")==0) lTypeOfLight=GLI_C_lParallelLight_With_Limit;
else if(stricmp(szName,"Fog")==0) lTypeOfLight=GLI_C_lFogLight;
GLI_vSetLightType( hLight, lTypeOfLight );
iLen=LDT_ComputeSectionName(pLink,a255_cLongName);
SCR_M_v_Link_SetAdditionalLong(SCR_fnp_st_Link_SetValue(LGT_fn_p_stGetLightLinkTable(), a255_cLongName, (unsigned long)hLight), 1, iLen);
while( result!=ParseResult_EndSection )
{
result=LDT_GetNextEntry();
switch( result )
{
case ParseResult_Entry: /* an entry */
{
char *szEntry=LDT_szGetEntryName();
switch (*(long*)szEntry)
{
case 'SteS' : /* SetState */
{
lOnOff=atoi( LDT_szGetParam( 1 ) );
GLI_xSetLightState(hLight, lOnOff);
}
break;
case 'CteS' : /* SetColor */
{
stColor.xR=(GEO_tdxColorValue)atof( LDT_szGetParam( 1 ) );
stColor.xG=(GEO_tdxColorValue)atof( LDT_szGetParam( 2 ) );
stColor.xB=(GEO_tdxColorValue)atof( LDT_szGetParam( 3 ) );
stColor.xA=(GEO_tdxColorValue)atof( LDT_szGetParam( 4 ) );
GLI_xSetLightColor(hLight,&stColor);
}
break;
case 'NteS' : /* SetNearFar */
{
GLI_vSetLightNearFar( hLight, MTH_M_xFloatToReal((float)atof( LDT_szGetParam( 1 ) )), MTH_M_xFloatToReal((float)atof( LDT_szGetParam( 2 ) )));
}
break;
case 'AteS' : /* SetAlphas */
{
GLI_vSetLightAlphas( hLight, MTH_M_xFloatToReal((float)atof( LDT_szGetParam( 1 ) )), MTH_M_xFloatToReal((float)atof( LDT_szGetParam( 2 ) )));
}
break;
case 'MteS' : /* SetMatrix */
{
p_stMatrix = (POS_tdstCompletePosition *)LDT_LoadSection( LDT_szGetParam(1) );
LDT_AddToRefsTable( g_hRefLight, pLink, 0, 0 );
}
break;
case 'ejbO' : /* ObjectLighted */
{
GLI_vSetObjectLighted(hLight,(unsigned char)atoi( LDT_szGetParam( 1 ) ));
}
break;
case 'niaP' : /* PaintLight */
{
GLI_vSetPaintLight(hLight);
}
break;
case 'lAoN' : /* NoAlphaLight */
{
GLI_vSetAlphaLightFlag (hLight, 2);
}
break;
case 'hplA' : /* AlphaLight */
{
GLI_vSetAlphaLight(hLight);
}
break;
case 'IteS' :
switch( *(long *)(szEntry+8) )
{
case 'PniM' : /* SetInterMinPos */
{
myGetVector.xX = MTH_M_xFloatToReal((float)atof( LDT_szGetParam( 1 ) ));
myGetVector.xY = MTH_M_xFloatToReal((float)atof( LDT_szGetParam( 2 ) ));
myGetVector.xZ = MTH_M_xFloatToReal((float)atof( LDT_szGetParam( 3 ) ));
GLI_vSetLight_Inter_Min_Pos( hLight,myGetVector );
}
break;
case 'PxaM' : /* SetInterMaxPos */
{
myGetVector.xX = MTH_M_xFloatToReal((float)atof( LDT_szGetParam( 1 ) ));
myGetVector.xY = MTH_M_xFloatToReal((float)atof( LDT_szGetParam( 2 ) ));
myGetVector.xZ = MTH_M_xFloatToReal((float)atof( LDT_szGetParam( 3 ) ));
GLI_vSetLight_Inter_Max_Pos( hLight,myGetVector );
}
break;
case 'ytis' : /* SetIntensityMinMax */
{
GLI_vSetLight_Intensity_Min_Max( hLight, MTH_M_xFloatToReal((float)atof( LDT_szGetParam( 1 ) )), MTH_M_xFloatToReal((float)atof( LDT_szGetParam( 2 ) )));
}
break;
}
break;
case 'EteS' :
if( szEntry[9]=='i' ) /* SetExterMinPos */
{
myGetVector.xX = MTH_M_xFloatToReal((float)atof( LDT_szGetParam( 1 ) ));
myGetVector.xY = MTH_M_xFloatToReal((float)atof( LDT_szGetParam( 2 ) ));
myGetVector.xZ = MTH_M_xFloatToReal((float)atof( LDT_szGetParam( 3 ) ));
GLI_vSetLight_Exter_Min_Pos( hLight,myGetVector );
}
else /* SetExterMaxPos */
{
myGetVector.xX = MTH_M_xFloatToReal((float)atof( LDT_szGetParam( 1 ) ));
myGetVector.xY = MTH_M_xFloatToReal((float)atof( LDT_szGetParam( 2 ) ));
myGetVector.xZ = MTH_M_xFloatToReal((float)atof( LDT_szGetParam( 3 ) ));
GLI_vSetLight_Exter_Max_Pos( hLight,myGetVector );
}
break;
case 'kcaB' : /* BackgroundColor */
{
stColor.xR=(GEO_tdxColorValue)atof( LDT_szGetParam( 1 ) );
stColor.xG=(GEO_tdxColorValue)atof( LDT_szGetParam( 2 ) );
stColor.xB=(GEO_tdxColorValue)atof( LDT_szGetParam( 3 ) );
stColor.xA=(GEO_tdxColorValue)atof( LDT_szGetParam( 4 ) );
GLI_xSetLightBackgroundColor(hLight,&stColor);
}
break;
}
}
}
}
return 0;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,5 @@
SCC = This is a source code control file
[GliGlou.vcproj]
SCC_Aux_Path = "P4SCC#srvperforce-ma:1666##raymandata##Editor"
SCC_Project_Name = Perforce Project