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,240 @@
# Microsoft Developer Studio Project File - Name="OpenGL" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=OpenGL - Win32 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 "OpenGL.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 "OpenGL.mak" CFG="OpenGL - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "OpenGL - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "OpenGL - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "OpenGL - Win32 Retail" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP Scc_ProjName ""$/cpa/tempgrp/GliGlou/Drivers/OpenGL", MVPAAAAA"
# PROP Scc_LocalPath "."
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "OpenGL - 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 "temp\Release"
# PROP Intermediate_Dir "temp\Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MT /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" /I "x:\cpa\tempgrp\gliglou\multidrv\inc" /I "..\\" /I "t:\mssdk\include" /D "NDEBUG" /D "_WINDOWS" /D "USE_PROFILER" /D "WIN32" /D "GLI_OPENGL" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
# ADD BASE RSC /l 0x40c /d "NDEBUG"
# ADD RSC /l 0x40c /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib /nologo /subsystem:windows /dll /machine:I386 /out:"x:\cpa\exe\main\dll\GliOGLvr.dll"
!ELSEIF "$(CFG)" == "OpenGL - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "temp\Debug"
# PROP Intermediate_Dir "temp\Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "t:\3dFX\GLIDE\SRC\SST1\INCLUDE" /I "x:\cpa\public" /I "x:\cpa\public\gli" /I "x:\cpa\public\geo" /I "inc" /I "x:\cpa\tempgrp\gliglou\multidrv\inc" /I "..\\" /I "t:\mssdk\include" /D "_DEBUG" /D "VISUAL" /D "USE_PROFILER" /D "MTH_CHECK" /D "CPA_WANTS_EXPORT" /D "WIN32" /D "GLI_OPENGL" /U "t:\3dFX\GLIDE\SRC\SST1\INCLUDE" /U "x:\cpa\public" /U "x:\cpa\public\gli" /U "x:\cpa\public\geo" /U "inc" /U "x:\cpa\tempgrp\gliglou\multidrv\inc" /U "..\\" /U "t:\mssdk\include" /YX /FD /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
# ADD BASE RSC /l 0x40c /d "_DEBUG"
# ADD RSC /l 0x40c /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:"x:\cpa\exe\main\dll\GliOGLvd.dll" /pdbtype:sept
!ELSEIF "$(CFG)" == "OpenGL - Win32 Retail"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "temp\retail"
# PROP BASE Intermediate_Dir "temp\retail"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Temp\Retail"
# PROP Intermediate_Dir "Temp\Retail"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /MD /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" /I "x:\cpa\tempgrp\gliglou\multidrv\inc" /I "..\\" /D "NDEBUG" /D "_WINDOWS" /D "RETAIL" /D "WIN32" /D "GLI_OPENGL" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
# ADD BASE RSC /l 0x40c /d "NDEBUG"
# ADD RSC /l 0x40c /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib /nologo /subsystem:windows /dll /machine:I386 /out:"x:\cpa\exe\main\dll\GliOGLvf.dll"
!ENDIF
# Begin Target
# Name "OpenGL - Win32 Release"
# Name "OpenGL - Win32 Debug"
# Name "OpenGL - Win32 Retail"
# Begin Group "Src"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\Acces_ALL.c
!IF "$(CFG)" == "OpenGL - Win32 Release"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "OpenGL - Win32 Debug"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "OpenGL - Win32 Retail"
# PROP BASE Exclude_From_Build 1
# PROP Exclude_From_Build 1
!ENDIF
# End Source File
# Begin Source File
SOURCE=..\ClipTRIANGLES.c
# End Source File
# Begin Source File
SOURCE=..\DllCom.c
# End Source File
# Begin Source File
SOURCE=..\GliDLL.def
# End Source File
# Begin Source File
SOURCE=.\Src\OGL_Acces.c
!IF "$(CFG)" == "OpenGL - Win32 Release"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "OpenGL - Win32 Debug"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "OpenGL - Win32 Retail"
# PROP BASE Exclude_From_Build 1
# PROP Exclude_From_Build 1
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\Src\OGL_Dll.c
# End Source File
# Begin Source File
SOURCE=.\Src\OGL_Domat.c
# End Source File
# Begin Source File
SOURCE=.\Src\OGL_Errors.c
# End Source File
# Begin Source File
SOURCE=.\Src\OGL_Func.c
# PROP Exclude_From_Build 1
# End Source File
# Begin Source File
SOURCE=.\Src\OGL_HdwTx.c
# End Source File
# Begin Source File
SOURCE=.\Src\OGL_Init.c
# End Source File
# Begin Source File
SOURCE=.\Src\OGL_Lock.c
# PROP Exclude_From_Build 1
# End Source File
# Begin Source File
SOURCE=.\Src\OGL_Thread.c
# End Source File
# End Group
# Begin Group "inc"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\DllCom.h
# End Source File
# Begin Source File
SOURCE=.\Inc\OGL_Errors.h
# End Source File
# Begin Source File
SOURCE=.\Inc\OGL_Options.h
# End Source File
# Begin Source File
SOURCE=.\Inc\OGL_Thread.h
# End Source File
# End Group
# Begin Group "lib"
# PROP Default_Filter ""
# Begin Source File
SOURCE=T:\dxsdk\sdk\lib\ddraw.lib
# End Source File
# End Group
# Begin Source File
SOURCE=.\OpenGL.mak
# End Source File
# End Target
# End Project

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,446 @@
//#include <d3d.h>
#include <windows.h>
#include <gl/gl.h>
#include "PRF.h"
#include "OGL_Options.h"
#include "OGL_Errors.h"
#include "OGL_Thread.h"
/*
=======================================================================================
Globals
=======================================================================================
*/
void GLI_DRV_xSendSpriteToClip_TRIANGLES( GLI_tdstAligned2DVector *a4_st2DVertex, GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT);
GLI_tdScreenVertx ga_stVertexBuffer[ 3000 ];
GLI_tdScreenVertx *CurrentDestXYZ = ga_stVertexBuffer;
#define GLI_M_RestoreCW()
void GLI_BeforeDraw()
{
CurrentDestXYZ = ga_stVertexBuffer;
OGLThread_fn_vWaitForSynchro();
}
void GLI_AfterDraw()
{
//OGLThread_fn_vWaitForSynchro();
if (CurrentDestXYZ != ga_stVertexBuffer)
OGLThread_fn_vPostCmd_1Long(OGLT1_RENDER, (long)CurrentDestXYZ);
//OGLThread_fn_vWaitForSynchro();
}
GLI_FuncNodeBegin(GLI_vDrawTriangle)
{
CurrentDestXYZ += 3;
}
GLI_FuncNodeBegin(GLI_vDrawWiredTriangle)
{
}
GLI_FuncNodeBegin(GLI_vZSortTriangle)
{
/* draw */
float ZMax;
if ((unsigned long)GLI_BIG_GLOBALS -> p_TheZListe -> p_CurrentPoint > (unsigned long)GLI_BIG_GLOBALS -> p_TheZListe -> p_TableOfPoints + ((3L << GLI_MaxZListeTrianglesPO2)* sizeof (GLI_tdScreenVertx)) - 3L * sizeof(GLI_tdScreenVertx))
return;
/* 3DFX BUG */
memcpy(GLI_BIG_GLOBALS -> p_TheZListe -> p_CurrentPoint , CurrentDestXYZ , sizeof(GLI_tdScreenVertx) * 3L);
if (*(unsigned long *)&GetZ(CurrentDestXYZ[0]) < *(unsigned long *)&GetZ(CurrentDestXYZ[1]))
*(unsigned long *)&ZMax = *(unsigned long *)&GetZ(CurrentDestXYZ[0]);
else
*(unsigned long *)&ZMax = *(unsigned long *)&GetZ(CurrentDestXYZ[1]);
if (*(unsigned long *)&ZMax > *(unsigned long *)&GetZ(CurrentDestXYZ[2]))
*(unsigned long *)&ZMax = *(unsigned long *)&GetZ(CurrentDestXYZ[2]);
GLI_v_AddNodeInZList(ZMax);
(unsigned long)GLI_BIG_GLOBALS -> p_TheZListe -> p_CurrentPoint += sizeof(GLI_tdScreenVertx) * 3L;
}
/*
----------------------------------------------------------------------------------------
Description : draw a quad stored in CurrentDestXYZ array or add it in Z list
1-----0
| /| Send two triangle : 0 1 2 and 3 2 0
| / |
|/ |
2-----3
----------------------------------------------------------------------------------------
*/
void GLI_DrawQuad(void)
{
/* draw 2 triangles */
if ( GLI_BIG_GLOBALS -> lClippingModeMask & GLI_C_TrianglesMustBeSorted )
{
GLI_BIG_GLOBALS -> lCurrentDrawMask &= ~GLI_C_lIsGouraud;
if ((unsigned long)GLI_BIG_GLOBALS -> p_TheZListe -> p_CurrentPoint > (unsigned long)GLI_BIG_GLOBALS -> p_TheZListe -> p_TableOfPoints + ((3L << GLI_MaxZListeTrianglesPO2)* sizeof (GLI_tdScreenVertx)) - 4L * sizeof(GLI_tdScreenVertx))
return;
memcpy(GLI_BIG_GLOBALS -> p_TheZListe -> p_CurrentPoint , CurrentDestXYZ , sizeof(GLI_tdScreenVertx) * 4L);
GLI_v_AddNodeInZList(GetZ(CurrentDestXYZ[0]));
(unsigned long)GLI_BIG_GLOBALS -> p_TheZListe -> p_CurrentPoint += sizeof(GLI_tdScreenVertx) * 4L;
}
else
{
CurrentDestXYZ[4] = CurrentDestXYZ[0];
CurrentDestXYZ[5] = CurrentDestXYZ[2];
CurrentDestXYZ += 6;
}
}
/*
----------------------------------------------------------------------------------------
Description : Draw a line
----------------------------------------------------------------------------------------
*/
void GLI_DrawLine(void)
{
}
/*
----------------------------------------------------------------------------------------
Description : draw Zsorted triangle
----------------------------------------------------------------------------------------
*/
void GLI_vDrawZSortedTriangle(void *p_3Point)
{
memcpy( CurrentDestXYZ, p_3Point, 3 * sizeof(GLI_tdScreenVertx) );
CurrentDestXYZ += 3;
}
/*
----------------------------------------------------------------------------------------
Description : draw ZSorted quad
----------------------------------------------------------------------------------------
*/
void GLI_vDrawZSortedQuad(void *p_3Point)
{
memcpy( CurrentDestXYZ, p_3Point, 4 * sizeof(GLI_tdScreenVertx) );
CurrentDestXYZ[4] = *((GLI_tdScreenVertx *) p_3Point + 2);
CurrentDestXYZ[5] = *((GLI_tdScreenVertx *) p_3Point);
CurrentDestXYZ += 6;
}
/*
----------------------------------------------------------------------------------------
Description : choose good drawing function
----------------------------------------------------------------------------------------
*/
void GLI_vAddDrawFunc()
{
if (GLI_BIG_GLOBALS -> lClippingModeMask & GLI_C_TrianglesMustBeSorted)
GLI_M_AddFunc(GLI_vZSortTriangle);
// else if ( (GLI_BIG_GLOBALS->lCurrentDrawMask & GLI_C_lIsNotWired) == 0 )
// GLI_M_AddFunc(GLI_vDrawWiredTriangle);
else
GLI_M_AddFunc(GLI_vDrawTriangle);
}
/*
----------------------------------------------------------------------------------------
Description : compute clipping mask
----------------------------------------------------------------------------------------
*/
void GLI_ReComputeClippingMask()
{
*(float *)&fX_CMP_Optimize = GLI_BIG_GLOBALS->fXMaxClipping;
*(float *)&fY_CMP_Optimize = GLI_BIG_GLOBALS->fYMaxClipping;
*(float *)&fXMin_CLIP_Optimize = GLI_BIG_GLOBALS->fXMinClipping;
*(float *)&fYMin_CLIP_Optimize = GLI_BIG_GLOBALS->fYMinClipping;
*(float *)&fXMax_CLIP_Optimize = GLI_BIG_GLOBALS->fXMaxClipping; // - 1.0f;
*(float *)&fYMax_CLIP_Optimize = GLI_BIG_GLOBALS->fYMaxClipping; // - 1.0f;
GLI_BIG_GLOBALS -> lClippingModeMask |= (GLI_BIG_GLOBALS -> lClippingModeMask & GLI_C_lCLIP_ALL) << 4;
}
/*
----------------------------------------------------------------------------------------
Description : clip a sprite
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vSendSpriteToClip
(
GLI_tdstAligned2DVector *a4_st2DVertex ,
MTH_tdxReal xZ ,
GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT
)
{
float fClipYMax, fClipYMin, fClipXMax, fClipXMin;
GLI_BeforeDraw();
if (a4_st2DVertex[0].xY == a4_st2DVertex[1].xY) /* Aligned sprite */
{
GLI_ReComputeClippingMask();
if ( ( *(long *) &a4_st2DVertex[0].xY > fYMax_CLIP_Optimize) || (*(long *) &a4_st2DVertex[2].xY < fYMin_CLIP_Optimize) || (*(long *) &a4_st2DVertex[0].xX < fXMin_CLIP_Optimize) || (*(long *) &a4_st2DVertex[1].xX > fXMax_CLIP_Optimize) )
return;
/*
* clip xMax
*/
if ( *(long *) &a4_st2DVertex[0].xX > fXMax_CLIP_Optimize )
{
fClipXMax = (GLI_BIG_GLOBALS->fXMaxClipping - a4_st2DVertex[1].xX) / ( a4_st2DVertex[0].xX - a4_st2DVertex[1].xX );
a4_st2DVertex[0].xX = a4_st2DVertex[3].xX = GLI_BIG_GLOBALS->fXMaxClipping;
}
else
fClipXMax = 1.0f;
/*
* clip xMin
*/
if ( *(long *) &a4_st2DVertex[1].xX < fXMin_CLIP_Optimize )
{
fClipXMin = (fClipXMax * ( GLI_BIG_GLOBALS->fXMinClipping - a4_st2DVertex[1].xX) ) / ( a4_st2DVertex[0].xX - a4_st2DVertex[1].xX );
a4_st2DVertex[1].xX = a4_st2DVertex[2].xX = GLI_BIG_GLOBALS->fXMinClipping;
}
else
fClipXMin = 0.0f;
/*
* clip yMin
*/
if ( *(long *) &a4_st2DVertex[0].xY < fYMin_CLIP_Optimize )
{
fClipYMin = (GLI_BIG_GLOBALS->fYMinClipping - a4_st2DVertex[2].xY) / ( a4_st2DVertex[0].xY - a4_st2DVertex[2].xY );
a4_st2DVertex[0].xY = a4_st2DVertex[1].xY = GLI_BIG_GLOBALS->fYMinClipping;
}
else
fClipYMin = 1.0f;
/*
* clip yMax
*/
if ( *(long *) &a4_st2DVertex[2].xY > fYMax_CLIP_Optimize )
{
fClipYMax = (fClipYMin * ( GLI_BIG_GLOBALS->fYMaxClipping - a4_st2DVertex[2].xY ) ) / ( a4_st2DVertex[0].xY - a4_st2DVertex[2].xY );
a4_st2DVertex[2].xY = a4_st2DVertex[3].xY = GLI_BIG_GLOBALS->fYMaxClipping;
}
else
fClipYMax = 0.0f;
}
else
{
if ( *(long *) &GLI_BIG_GLOBALS->xWaterPlaneDistance != 0 );
{
GLI_DRV_xSendSpriteToClip_TRIANGLES( a4_st2DVertex, p_stGlobaleMT);
return;
}
if ( (a4_st2DVertex [0] . xY < 0.0f) || (a4_st2DVertex [1] . xY < 0.0f) || (a4_st2DVertex [2] . xY < 0.0f) || (a4_st2DVertex [3] . xY < 0.0f) ) return;
if ( (a4_st2DVertex [0] . xX < 0.0f) || (a4_st2DVertex [1] . xX < 0.0f) || (a4_st2DVertex [2] . xX < 0.0f) || (a4_st2DVertex [3] . xX < 0.0f) ) return;
if ( (a4_st2DVertex [0] . xY > 480.0f) || (a4_st2DVertex [1] . xY > 480.0f) || (a4_st2DVertex [2] . xY > 480.0f) || (a4_st2DVertex [3] . xY > 480.0f) ) return;
if ( (a4_st2DVertex [0] . xX > 640.0f) || (a4_st2DVertex [1] . xX > 640.0f) || (a4_st2DVertex [2] . xX > 640.0f) || (a4_st2DVertex [3] . xX > 640.0f) ) return;
fClipXMin = fClipYMax = 0.0f;
fClipYMin = fClipXMax = 1.0f;
}
GLI_M_InitSprite();
SetU(CurrentDestXYZ[0], fClipXMax );
SetV(CurrentDestXYZ[0], fClipYMin );
SetU(CurrentDestXYZ[1], fClipXMin );
SetV(CurrentDestXYZ[1], fClipYMin );
SetU(CurrentDestXYZ[2], fClipXMin );
SetV(CurrentDestXYZ[2], fClipYMax );
SetU(CurrentDestXYZ[3], fClipXMax );
SetV(CurrentDestXYZ[3], fClipYMax );
GLI_DrawQuad();
GLI_AfterDraw();
}
/*
----------------------------------------------------------------------------------------
Description : clip a sprite that have UV coordinates (it seems to be unused)
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vSendSpriteToClipWithUV
(
GLI_tdstAligned2DVector *a4_st2DVertex ,
MTH_tdxReal *a8_stUVVertex,
MTH_tdxReal xZ ,
GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT)
{
GLI_BeforeDraw();
GLI_M_InitSprite();
if (a4_st2DVertex [0] . xY < 0.0f) return;
if (a4_st2DVertex [1] . xY < 0.0f) return;
if (a4_st2DVertex [2] . xY < 0.0f) return;
if (a4_st2DVertex [3] . xY < 0.0f) return;
if (a4_st2DVertex [0] . xY > GLI_BIG_GLOBALS->fYMaxClipping) return;
if (a4_st2DVertex [1] . xY > GLI_BIG_GLOBALS->fYMaxClipping) return;
if (a4_st2DVertex [2] . xY > GLI_BIG_GLOBALS->fYMaxClipping) return;
if (a4_st2DVertex [3] . xY > GLI_BIG_GLOBALS->fYMaxClipping) return;
if ( p_stGlobaleMT->p_stCurrentTexture->lIncrementIsEnable )
{
float fAddU, fAddV;
fAddU = p_stGlobaleMT-> p_stCurrentTexture -> fAddU;
fAddV = p_stGlobaleMT-> p_stCurrentTexture -> fAddV;
SetU(CurrentDestXYZ[2], a8_stUVVertex[4] + fAddU );
SetV(CurrentDestXYZ[2], a8_stUVVertex[4 + 1] + fAddV);
SetU(CurrentDestXYZ[3], a8_stUVVertex[6] + fAddU);
SetV(CurrentDestXYZ[3], a8_stUVVertex[6 + 1] + fAddV);
SetU(CurrentDestXYZ[0], a8_stUVVertex[0] + fAddU);
SetV(CurrentDestXYZ[0], a8_stUVVertex[0 + 1] + fAddV);
SetU(CurrentDestXYZ[1], a8_stUVVertex[2] + fAddU);
SetV(CurrentDestXYZ[1], a8_stUVVertex[2 + 1] + fAddV);
}
else
{
SetU(CurrentDestXYZ[2], a8_stUVVertex[4]);
SetV(CurrentDestXYZ[2], a8_stUVVertex[4 + 1]);
SetU(CurrentDestXYZ[3], a8_stUVVertex[6]);
SetV(CurrentDestXYZ[3], a8_stUVVertex[6 + 1]);
SetU(CurrentDestXYZ[0], a8_stUVVertex[0]);
SetV(CurrentDestXYZ[0], a8_stUVVertex[0 + 1]);
SetU(CurrentDestXYZ[1], a8_stUVVertex[2]);
SetV(CurrentDestXYZ[1], a8_stUVVertex[2 + 1]);
}
GLI_DrawQuad();
GLI_AfterDraw();
}
/*
----------------------------------------------------------------------------------------
Description : clip a line (not implemented)
----------------------------------------------------------------------------------------
*/
void GLI_DRV_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
)
{
#ifdef _DEBUG
/*
GLI_tdstAligned2DVector *p_stP1, *p_stP2;
GLI_tdstAligned3DVector *p_st3DP1, *p_st3DP2;
*/
GLI_tdstAligned2DVector stP1, stP2;
GLI_tdstAligned3DVector st3DP1, st3DP2;
float fFactor;
p_st2DVertex1->ulPackedColor = 0xFFFFFFFF;
p_st2DVertex2->ulPackedColor = 0xFFFFFFFF;
/* xClipping */
if (p_st2DVertex1->xX < p_st2DVertex2->xX)
{
stP1 = *p_st2DVertex1;
st3DP1 = *p_stVertex1;
stP2 = *p_st2DVertex2;
st3DP2 = *p_stVertex2;
}
else
{
stP1 = *p_st2DVertex2;
st3DP1 = *p_stVertex2;
stP2 = *p_st2DVertex1;
st3DP2 = *p_stVertex1;
}
if (( stP2.xX < 0.0f) || ( stP1.xX > 640.0f ) )
return;
if ( stP1.xX < 0.0f )
{
fFactor = stP2.xX / (stP2.xX - stP1.xX );
stP1.xY = stP2.xY - ( stP2.xY - stP1.xY) * fFactor;
//(*p_stP1)->ulPackedColor = (unsigned long) ((*p_stP2)->ulPackedColor - ( (*p_stP2)->ulPackedColor - (*p_stP1)->ulPackedColor) * fFactor);
st3DP1.xZ = st3DP2.xZ - ( st3DP2.xY - st3DP1.xY) * fFactor;
stP1.xX = 0.0f;
}
if ( stP2.xX > 640.0f)
{
fFactor = (stP1.xX - 640.0f) / (stP2.xX - stP1.xX );
stP2.xY = stP1.xY - ( stP2.xY - stP1.xY) * fFactor;
//(*p_stP2)->ulPackedColor = (unsigned long) ((*p_stP1)->ulPackedColor - ( (*p_stP2)->ulPackedColor - (*p_stP1)->ulPackedColor) * fFactor);
st3DP2.xZ = st3DP1.xZ - ( st3DP2.xY - st3DP1.xY) * fFactor;
stP2.xX = 640.0f;
}
/* yClipping */
if ( stP1.xY < stP2.xY)
{
p_st2DVertex1 = &stP1;
p_stVertex1 = &st3DP1;
p_st2DVertex2 = &stP2;
p_stVertex2 = &st3DP2;
}
else
{
p_st2DVertex1 = &stP2;
p_stVertex1 = &st3DP2;
p_st2DVertex2 = &stP1;
p_stVertex2 = &st3DP1;
}
if (( p_st2DVertex2->xY < 0.0f) || ( p_st2DVertex1->xY > 480.0f ) )
return;
if ( p_st2DVertex1->xY < 0.0f )
{
fFactor = p_st2DVertex2->xY / (p_st2DVertex2->xY - p_st2DVertex1->xY );
p_st2DVertex1->xX = p_st2DVertex2->xX - ( p_st2DVertex2->xX - p_st2DVertex1->xX) * fFactor;
//(*p_st2DVertex1)->ulPackedColor = (unsigned long) ((*p_st2DVertex2)->ulPackedColor - ( (*p_st2DVertex2)->ulPackedColor - (*p_st2DVertex1)->ulPackedColor) * fFactor);
p_stVertex1->xZ = p_stVertex2->xZ - ( p_stVertex2->xZ - p_stVertex1->xZ) * fFactor;
p_st2DVertex1->xY = 0.0f;
}
if ( p_st2DVertex2->xY > 480.0f)
{
//fFactor = ( (*p_st2DVertex2)->xX - (*p_st2DVertex1)->xX) / ((*p_st2DVertex2)->xY - (*p_st2DVertex1)->xY );
fFactor = (p_st2DVertex1->xY - 480.0f) / (p_st2DVertex2->xY - p_st2DVertex1->xY );
p_st2DVertex2->xX = p_st2DVertex1->xX - ( p_st2DVertex2->xX - p_st2DVertex1->xX) * fFactor;
//(*p_st2DVertex2)->ulPackedColor = (unsigned long) ((*p_st2DVertex1)->ulPackedColor - ( (*p_st2DVertex2)->ulPackedColor - (*p_st2DVertex1)->ulPackedColor) * fFactor);
p_stVertex2->xZ = p_stVertex1->xZ - ( p_stVertex2->xZ - p_stVertex1->xZ) * fFactor;
p_st2DVertex2->xY = 480.0f;
}
#else
if (p_st2DVertex1->xX < 0) return;
if (p_st2DVertex1->xY < 0) return;
if (p_st2DVertex1->xX > 640.0f) return;
if (p_st2DVertex1->xY > 480.0f) return;
if (p_st2DVertex2->xX < 0) return;
if (p_st2DVertex2->xY < 0) return;
if (p_st2DVertex2->xX > 640.0f) return;
if (p_st2DVertex2->xY > 480.0f) return;
#endif
GLI_M_InitLine();
GLI_BeforeDraw();
GLI_DrawLine();
GLI_AfterDraw();
}

View File

@@ -0,0 +1,27 @@
/*
=======================================================================================
Name : Glide2_Dll.c
Author : vincent lhullier Date :16/09/98
Description : specific DLL fonction
=======================================================================================
*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include "init_gli.h"
#include "DLLCom.h"
#include "DLLCaps.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
tdstGliDriverIdentity stGlide2Id =
{
"OpenGL",
"Driver for OpenGL",
"1.0.0",
10
};
void fn_vInitDllIdentity( void )
{
memcpy( &g_stGliDrvId, &stGlide2Id, sizeof( tdstGliDriverIdentity ) );
}

View File

@@ -0,0 +1,793 @@
/******************************************************************************************
FILE : DoMat Glide2
Do render parameters settings for texture/material/fog
Dispay black triangles for window smaller than screen
*******************************************************************************************/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include "Gli_st.h"
#include "GLI_Defn.h"
#include "polygon.h"
#include "mater_st.h"
#include "light_st.h"
#include "PvObj_st.h"
#include "Liste.h"
#include "watrplan.h"
#include "proj.h"
#include "vpt3D.h"
#include "camera.h"
#include "material.h"
#include "texture.h"
#include "TEX.h"
#include "light.h"
#include "GliBench.h"
#include "DLLCom.h"
#include "PRF.h"
#include <gl/gl.h>
#include "OGL_Options.h"
#include "OGL_Errors.h"
#include "OGL_Thread.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#ifdef __cplusplus
extern "C"
{
#endif
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
=======================================================================================
Globals
=======================================================================================
*/
/*typedef struct _GLI_tdScreenVertx {
float sx;
float sy;
float sz;
//float rhw;
unsigned long color;
unsigned long specular;
float tu;
float tv;
} GLI_tdScreenVertx;
*/
/*
* render parameters
*/
static long bIsWriteEnable = 1;
static ACP_tdxIndex xSaveFogIsOn = 0;
static unsigned char ucSaveCyclingMode = -1;
static unsigned char ucSaveFunction = -1;
static unsigned long gs_ulDepthBufferTestEnabled = 0;
/*
* Fog table
*/
//GrFog_t Gli_C_xFogTable[ GR_FOG_TABLE_SIZE ];
//float GLI_ga_fFogDist[ GR_FOG_TABLE_SIZE ];
/*
* Black triangles
*/
GLI_tdScreenVertx g_stBlackTriangle[16];
long g_lNumberOfBlackTriangles = 0;
/*
* external
*/
//extern long g_lDestWidth, g_lDestHeight;
/*
=======================================================================================
Special function for displaying black polygon
it's for cinematic scene to hide non black for color
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : reinit list of black triangles
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vNoBlackPolygon()
{
g_lNumberOfBlackTriangles = 0;
}
/*
----------------------------------------------------------------------------------------
Description : Add a black triangles to list
Assume that list is large enough (no test)
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vAddBlackPolygon( long _lLeft, long _lTop, long _lRight, long _lBottom )
{
GLI_tdScreenVertx *p_stVertex;
p_stVertex = g_stBlackTriangle + g_lNumberOfBlackTriangles;
memset( p_stVertex, 0, 4 * sizeof( GLI_tdScreenVertx ) );
g_lNumberOfBlackTriangles += 4;
p_stVertex->sx = (float) _lLeft;
p_stVertex->sy = (float) _lBottom;
p_stVertex->sz = .8f;
p_stVertex++;
p_stVertex->sx = (float) _lLeft;
p_stVertex->sy = (float) _lTop;
p_stVertex->sz = .8f;
p_stVertex++;
p_stVertex->sx = (float) _lRight;
p_stVertex->sy = (float) _lTop;
p_stVertex->sz = .8f;
p_stVertex++;
p_stVertex->sx = (float) _lRight;
p_stVertex->sy = (float) _lBottom;
p_stVertex->sz = .8f;
}
/*
----------------------------------------------------------------------------------------
Description : Draw black triangles
----------------------------------------------------------------------------------------
*/
void GLI_vSendBlackPolygon()
{
if (g_lNumberOfBlackTriangles == 0)
return;
xSaveFogIsOn = 0;
OGLThread_fn_vPostCmd(OGLT0_BLACKPOLY);
}
/*
=======================================================================================
Function for Fog
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : Set render parameter for given fog parameters
----------------------------------------------------------------------------------------
*/
tdstFogParams* g_p_stFogParams;
void GLI_vSetFogParams( tdstFogParams *_p_stFogParams )
{
g_p_stFogParams = _p_stFogParams;
OGLThread_fn_vPostCmd(OGLT0_FOGPARAM);
}
/*
----------------------------------------------------------------------------------------
Description : compute fog effect on vertex color (nothing to do for Glide2)
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vComputeFogEffect(GLI_tdstInternalGlobalValuesFor3dEngine *p_stBG )
{
}
/*
=======================================================================================
ZBuffer function
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : To enable write to ZBuffer
----------------------------------------------------------------------------------------
*/
static void GLI_fn_vEnableWriteToZBuffer()
{
if (bIsWriteEnable)
return;
OGLThread_fn_vPostCmd_1Long(OGLT1_DEPTHMASK, (long)GL_TRUE);
bIsWriteEnable = 1;
}
/*
----------------------------------------------------------------------------------------
Description : To disable write to ZBuffer
----------------------------------------------------------------------------------------
*/
static void GLI_fn_vDisableWriteToZBuffer()
{
if (!bIsWriteEnable)
return;
OGLThread_fn_vPostCmd_1Long(OGLT1_DEPTHMASK, (long)GL_FALSE);
bIsWriteEnable = 0;
}
/*
----------------------------------------------------------------------------------------
Description : To manage use of ZBuffer
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vEnableDepthTest()
{
if( gs_ulDepthBufferTestEnabled )
return;
OGLThread_fn_vPostCmd_1Long( OGLT1_ENABLE, GL_DEPTH_TEST);
gs_ulDepthBufferTestEnabled = 1;
}
void GLI_DRV_vDisableDepthTest()
{
if( ! gs_ulDepthBufferTestEnabled )
return;
OGLThread_fn_vPostCmd_1Long( OGLT1_DISABLE, GL_DEPTH_TEST);
gs_ulDepthBufferTestEnabled = 0;
}
/*
=======================================================================================
Main render parameter setting functions
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : Macro to set chromakey
CB : La valeur de chromakey doit etre <20>gale <20> : 5 bits de poids fort, plus les 3 bits de poids fort copi<70>s dans les bits de poids faible.... !!!
VL : sauf pour la composante G : 6 bit de poids fort + 2 bit de poids fort copi<70>s dans les bits de poids faible !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
----------------------------------------------------------------------------------------
*/
#define M_vChromakey()\
if (p_stGlobaleMT -> p_stCurrentTexture -> lTextureCaps & GLI_C_lNZTexture)\
{\
unsigned long ulChromakey;\
grChromakeyMode( GR_CHROMAKEY_ENABLE );\
ulChromakey = (p_stGlobaleMT->p_stCurrentTexture->lChromakeyColorRGBA & 0x00F800F8) | ((p_stGlobaleMT->p_stCurrentTexture->lChromakeyColorRGBA & 0x00E000E0) >> 5);\
ulChromakey|= (p_stGlobaleMT->p_stCurrentTexture->lChromakeyColorRGBA & 0x0000FC00) | ((p_stGlobaleMT->p_stCurrentTexture->lChromakeyColorRGBA & 0x0000C000) >> 6);\
grChromakeyValue( ulChromakey );\
}\
else\
{\
grChromakeyMode( GR_CHROMAKEY_DISABLE );\
}
/*
----------------------------------------------------------------------------------------
Description : Macro to change fog rendering
----------------------------------------------------------------------------------------
*/
#define M_vFog()\
if (GLI_BIG_GLOBALS->xFogIsOn)\
{\
if ( GLI_BIG_GLOBALS->p_stLastComputedFog != GLI_BIG_GLOBALS->p_stActiveFog )\
{\
GLI_vSetFogParams( GLI_BIG_GLOBALS->p_stActiveFog );\
GLI_BIG_GLOBALS->p_stLastComputedFog = GLI_BIG_GLOBALS->p_stActiveFog;\
}\
if (!xSaveFogIsOn)\
{\
OGLThread_fn_vPostCmd_1Long( OGLT1_ENABLE, GL_FOG); /*grFogMode( GR_FOG_WITH_TABLE);*/\
xSaveFogIsOn = 1;\
}\
}\
else if (xSaveFogIsOn)\
{\
OGLThread_fn_vPostCmd_1Long( OGLT1_DISABLE, GL_FOG); /*grFogMode( GR_FOG_DISABLE);*/\
xSaveFogIsOn = 0;\
}
/*
----------------------------------------------------------------------------------------
Description : Set init parameter as none set
----------------------------------------------------------------------------------------
*/
void GLI_fn_vInitRenderParameters( void )
{
bIsWriteEnable = 1;
xSaveFogIsOn = 0;
// xSaveTmuNumber = -1;
ucSaveCyclingMode = -1;
ucSaveFunction = -1;
OGLThread_fn_vPostCmd_1Long( OGLT1_DISABLE, GL_ALPHA_TEST);
OGLThread_fn_vPostCmd_1Long( OGLT1_DISABLE, GL_FOG);
}
/*
----------------------------------------------------------------------------------------
Description : set render parameters that will work for all faces which are not
transparent
----------------------------------------------------------------------------------------
*/
void GLI_fn_vSetRenderParametersBeforeOpaqueFace( void ) {
//grAlphaCombine( GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_ONE,GR_COMBINE_LOCAL_NONE,GR_COMBINE_OTHER_TEXTURE,FXFALSE);
//grAlphaTestFunction( GR_CMP_ALWAYS );
//grAlphaTestReferenceValue( 0xC0 );
OGLThread_fn_vPostCmd_2Long( OGLT2_BLENDFUNC, GL_ONE, GL_ZERO); //grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO, GR_BLEND_ONE, GR_BLEND_ZERO);
OGLThread_fn_vPostCmd_1Long( OGLT1_TEXTUREENV, GL_MODULATE); // guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB);
ucSaveFunction = 4;
OGLThread_fn_vPostCmd_1Long( OGLT1_DISABLE, GL_ALPHA_TEST); // ?
GLI_fn_vEnableWriteToZBuffer();
}
/*
----------------------------------------------------------------------------------------
Description : called before the rendering of any triangle
----------------------------------------------------------------------------------------
*/
BOOL GLI_DRV_bBeginScene()
{
return TRUE;
}
/*
----------------------------------------------------------------------------------------
Description : called after the rendering of all triangles
----------------------------------------------------------------------------------------
*/
BOOL GLI_DRV_bEndScene()
{
return TRUE;
}
/*
----------------------------------------------------------------------------------------
Description : Called for all object before drawn.
Set some general parameters and set render parameter for opaque texture only
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vDoOpaqueTextureSelection(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT)
{
GLboolean bOK;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
// GLI_tdstTextureDFX *p_stSpecParam;
BOOL bTexture;
#if defined (TEX_TEST)
BOOL bTempOk;
unsigned int uiTextureId;
#endif //defined (TEX_TEST)
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
if (*GLD_p_lRenderingCounter != p_stGlobaleMT->GLD_RenderingCounter)
{
p_stGlobaleMT->GLD_RenderingCounter = *GLD_p_lRenderingCounter;
GLI_vSendBlackPolygon();
// GLI_fn_vSetRenderParametersBeforeOpaqueFace() :
/*
grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO, GR_BLEND_ONE, GR_BLEND_ZERO);
grAlphaCombine( GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_ONE,GR_COMBINE_LOCAL_NONE,GR_COMBINE_OTHER_TEXTURE,FXFALSE);
guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB);
grAlphaTestFunction( GR_CMP_ALWAYS );
grAlphaTestReferenceValue( 0xC0 );
*/
OGLThread_fn_vPostCmd_2Long( OGLT2_BLENDFUNC, GL_ONE, GL_ZERO);
OGLThread_fn_vPostCmd_1Long( OGLT1_TEXTUREENV, GL_MODULATE);
ucSaveFunction = 4;
OGLThread_fn_vPostCmd_1Long( OGLT1_DISABLE, GL_ALPHA_TEST);
}
GLI_fn_vEnableWriteToZBuffer();
if ( p_stGlobaleMT->lCurrentDrawMask & GLI_C_lIsEnableZSorting )
GLI_DRV_vEnableDepthTest();
else
GLI_DRV_vDisableDepthTest();
bTexture = (p_stGlobaleMT->p_stCurrentTexture != NULL) && (p_stGlobaleMT->p_stCurrentTexture->bIsAvailable);
/*
* test if triangle will be transparent if so do not set render parameters
*/
if (GLI_BIG_GLOBALS->lAMirrorIsDetected)
GLI_BIG_GLOBALS->lAMirrorIsDetected = 3;
if (
( !(GLI_BIG_GLOBALS->lAMirrorIsDetected) && bTexture && (p_stGlobaleMT -> p_stCurrentTexture -> lTextureCaps & (GLI_C_lAlphaTexture | GLI_C_lNZFilteredTexture | GLI_C_lAddTransparencyTexture) ) )
|| (!(p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lIsNotGrided) && (p_stGlobaleMT->xGlobalAlpha < 0.98f))
)
{
p_stGlobaleMT -> lClippingModeMask |= GLI_C_TrianglesMustBeSorted;
return;
}
p_stGlobaleMT -> lClippingModeMask &= 0xffffffff - GLI_C_TrianglesMustBeSorted;
/*
* fog
*/
#if !defined(NO_FOG)
M_vFog();
#endif
#ifdef TEX_TEST
if (bTexture) {
uiTextureId = (unsigned int) p_stGlobaleMT->p_stCurrentTexture->p_stSpecParam;
bTempOk = OGLThread_fn_bPostCmdAndWait(OGLT1_ISTEXTURE, (long)uiTextureId);
if (!bTempOk )
bTexture = FALSE;
if (bTexture) {
bTempOk = OGLThread_fn_bPostCmdAndWait(OGLT1_ISRESIDENT, (long)uiTextureId);
if (!bTempOk)
bTexture = FALSE;
}
// if not resident => delete it
if (!bTexture) {
bTempOk = OGLThread_fn_bPostCmdAndWait(OGLT1_ISTEXTURE, (long)uiTextureId);
if (bTempOk)
OGLThread_fn_vPostCmd_1Long(OGLT1_DELETETEXTURE, (long)uiTextureId);
}
}
#endif //defined (TEX_TEST)
if ( bTexture )
{
if (p_stGlobaleMT -> p_stCurrentTexture -> lTextureCaps & GLI_C_lAlphaTest)
{
if (ucSaveFunction != 5)
{
if ( ucSaveFunction == 2 )
GLI_fn_vSetRenderParametersBeforeOpaqueFace() ;
/*
grAlphaTestFunction( GR_CMP_GEQUAL );
guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB);
*/
OGLThread_fn_vPostCmd( OGLT0_ALPHATEST );
OGLThread_fn_vPostCmd_1Long( OGLT1_TEXTUREENV, GL_MODULATE);
ucSaveFunction = 5;
OGLThread_fn_vPostCmd_1Long( OGLT1_ENABLE, GL_ALPHA_TEST);
}
}
else if (GLI_BIG_GLOBALS->lAMirrorIsDetected & 2)
{
/*
grAlphaBlendFunction( GR_BLEND_SRC_ALPHA,GR_BLEND_ONE_MINUS_SRC_ALPHA,GR_BLEND_ONE ,GR_BLEND_ZERO );
guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB);
grAlphaCombine(GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_LOCAL,GR_COMBINE_LOCAL_ITERATED,GR_COMBINE_OTHER_TEXTURE,FXFALSE);
*/
OGLThread_fn_vPostCmd_2Long( OGLT2_BLENDFUNC, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
OGLThread_fn_vPostCmd_1Long( OGLT1_TEXTUREENV, GL_MODULATE);
ucSaveFunction = 2;
OGLThread_fn_vPostCmd_1Long( OGLT1_DISABLE, GL_ALPHA_TEST);
}
else
{
if (ucSaveFunction != 4)
{
if ( ucSaveFunction == 2 )
GLI_fn_vSetRenderParametersBeforeOpaqueFace() ;
/*
grAlphaTestFunction( GR_CMP_ALWAYS );
guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB);
*/
OGLThread_fn_vPostCmd_1Long( OGLT1_TEXTUREENV, GL_MODULATE);
ucSaveFunction = 4;
OGLThread_fn_vPostCmd_1Long( OGLT1_DISABLE, GL_ALPHA_TEST);
}
}
/*
* Chromakey
*/
/* M_vChromakey();*/
/*
* uv cycling mode => made when loading texture
*/
/*if (p_stGlobaleMT -> p_stCurrentTexture -> lTextureCaps & GLI_C_lNZTexture)
OGLThread_fn_vPostCmd_1Long( OGLT1_DISABLE, GL_TEXTURE_2D);
else*/
{
OGLThread_fn_vPostCmd_1Long( OGLT1_ENABLE, GL_TEXTURE_2D);
OGLThread_fn_vPostCmd_1Long( OGLT1_BINDTEXTURE, (long)p_stGlobaleMT->p_stCurrentTexture->p_stSpecParam );
}
}
else /* gouraud */
{
bOK = OGLThread_fn_bPostCmdAndWait(OGLT1_ISENABLED, GL_TEXTURE_2D);
if (bOK)
{
OGLThread_fn_vPostCmd_1Long( OGLT1_DISABLE, GL_TEXTURE_2D);
bOK = OGLThread_fn_bPostCmdAndWait(OGLT1_ISENABLED, GL_TEXTURE_2D);
}
if (bOK) // still Enabled !
OGLThread_fn_vPostCmd_1Long( OGLT1_BINDTEXTURE, 0L );
if (ucSaveFunction != 0)
{
/*
grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO, GR_BLEND_ONE, GR_BLEND_ZERO);
grAlphaCombine( GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_ONE,GR_COMBINE_LOCAL_NONE,GR_COMBINE_OTHER_TEXTURE,FXFALSE);
grAlphaTestFunction( GR_CMP_ALWAYS );
guColorCombineFunction( GR_COLORCOMBINE_ITRGB );
ucSaveFunction = 0;
*/
OGLThread_fn_vPostCmd_2Long( OGLT2_BLENDFUNC, GL_ONE, GL_ZERO);
OGLThread_fn_vPostCmd_1Long( OGLT1_TEXTUREENV, GL_MODULATE);
ucSaveFunction = 0;
OGLThread_fn_vPostCmd_1Long( OGLT1_DISABLE, GL_ALPHA_TEST);
}
}
}
/*
----------------------------------------------------------------------------------------
Description : set render parameters that will work for all transparency faces
----------------------------------------------------------------------------------------
*/
void GLI_fn_vSetRenderParametersBeforeTransparencyFace( void )
{
// grAlphaTestFunction( GR_CMP_ALWAYS );
GLI_fn_vDisableWriteToZBuffer();
}
/*
----------------------------------------------------------------------------------------
Description : set render parameters for transparent triangles
----------------------------------------------------------------------------------------
*/
void GLI_vDoTransparentTextureSelection(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT)
{
BOOL bTexture;
#ifdef TEX_TEST
BOOL bTempOk;
unsigned int uiTextureId;
#endif //defined (TEX_TEST)
//grAlphaTestFunction( GR_CMP_ALWAYS );
/*
* write to Z buffer ?
*/
/*
if (p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lIsWriteZBuffer)
GLI_fn_vEnableWriteToZBuffer();
else
GLI_fn_vDisableWriteToZBuffer();
*/
if ( p_stGlobaleMT->lCurrentDrawMask & GLI_C_lIsEnableZSorting )
GLI_DRV_vEnableDepthTest();
else
GLI_DRV_vDisableDepthTest();
/*
* fog
*/
#if !defined(NO_FOG)
M_vFog();
#endif
bTexture = (p_stGlobaleMT -> p_stCurrentTexture != NULL) && (p_stGlobaleMT -> p_stCurrentTexture -> bIsAvailable);
#ifdef TEX_TEST
if (bTexture) {
uiTextureId = (unsigned int) p_stGlobaleMT->p_stCurrentTexture->p_stSpecParam;
bTempOk = bOGLThread_fn_vPostCmd_WaitForBoolean(OGLT1_ISTEXTURE, (long)uiTextureId);
if (!bTempOk )
bTexture = FALSE;
if (bTexture) {
bTempOk = bOGLThread_fn_vPostCmd_WaitForBoolean(OGLT1_ISRESIDENT, (long)uiTextureId);
if (!bTempOk)
bTexture = FALSE;
}
// if not resident => delete it
if (!bTexture) {
bTempOk = bOGLThread_fn_vPostCmd_WaitForBoolean(OGLT1_ISTEXTURE, (long)uiTextureId);
if (bTempOk)
OGLThread_fn_vPostCmd_1Long(OGLT1_DELETETEXTURE, (long)uiTextureId);
}
}
#endif //defined (TEX_TEST)
if (bTexture) //((p_stGlobaleMT -> p_stCurrentTexture != NULL) && (p_stGlobaleMT -> p_stCurrentTexture -> bIsAvailable))
{
//glEnable(GL_TEXTURE_2D);
if (p_stGlobaleMT -> p_stCurrentTexture -> lTextureCaps & (GLI_C_lAlphaTest | GLI_C_lAlphaTexture | GLI_C_lNZFilteredTexture | GLI_C_lAddTransparencyTexture) )
{
if (p_stGlobaleMT -> p_stCurrentTexture -> lTextureCaps & GLI_C_lAddTransparencyTexture)
{
// Trans ADD
if (ucSaveFunction != 1)
{
/*
grAlphaBlendFunction( GR_BLEND_ONE,GR_BLEND_ONE,GR_BLEND_ZERO ,GR_BLEND_ZERO );
guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ALPHA);
grAlphaCombine(GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_LOCAL,GR_COMBINE_LOCAL_ITERATED,GR_COMBINE_OTHER_TEXTURE,FXFALSE);
*/
OGLThread_fn_vPostCmd_2Long( OGLT2_BLENDFUNC, GL_ONE, GL_ONE);
OGLThread_fn_vPostCmd_1Long( OGLT1_TEXTUREENV, GL_DECAL); // guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ALPHA);
ucSaveFunction = 1;
OGLThread_fn_vPostCmd_1Long( OGLT1_DISABLE, GL_ALPHA_TEST);
}
// No fog With This;
if (xSaveFogIsOn)
{
OGLThread_fn_vPostCmd_1Long( OGLT1_DISABLE, GL_FOG); //grFogMode( GR_FOG_DISABLE);
xSaveFogIsOn = 0;
}
}
else if (ucSaveFunction != 2)
{
// Trans ALPHA
/*
grAlphaBlendFunction( GR_BLEND_SRC_ALPHA,GR_BLEND_ONE_MINUS_SRC_ALPHA,GR_BLEND_ONE ,GR_BLEND_ZERO );
guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB);
grAlphaCombine(GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_LOCAL,GR_COMBINE_LOCAL_ITERATED,GR_COMBINE_OTHER_TEXTURE,FXFALSE);
*/
OGLThread_fn_vPostCmd_2Long( OGLT2_BLENDFUNC, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
OGLThread_fn_vPostCmd_1Long( OGLT1_TEXTUREENV, GL_MODULATE); // guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB);
ucSaveFunction = 2;
OGLThread_fn_vPostCmd_1Long( OGLT1_DISABLE, GL_ALPHA_TEST);
}
}
else //if ((!(p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lIsNotGrided)) && (xGlobaLAlpha < 0.98f))
{
// Trans ALPHA ITERATED
if (ucSaveFunction != 3)
{
/*
grAlphaBlendFunction( GR_BLEND_SRC_ALPHA,GR_BLEND_ONE_MINUS_SRC_ALPHA,GR_BLEND_ONE,GR_BLEND_ZERO );
grAlphaCombine(GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_ONE,GR_COMBINE_LOCAL_ITERATED,GR_COMBINE_OTHER_ITERATED,FXFALSE);
guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB);
*/
OGLThread_fn_vPostCmd_2Long( OGLT2_BLENDFUNC, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
OGLThread_fn_vPostCmd_1Long( OGLT1_TEXTUREENV, GL_MODULATE); // guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB);
ucSaveFunction = 3;
OGLThread_fn_vPostCmd_1Long( OGLT1_DISABLE, GL_ALPHA_TEST);
}
}
/*
* Chromakey
*/
/* M_vChromakey();*/
/*
* uv cycling mode => made when loading texture
*/
/*if (p_stGlobaleMT -> p_stCurrentTexture -> lTextureCaps & GLI_C_lNZTexture)
OGLThread_fn_vPostCmd_1Long( OGLT1_DISABLE, GL_TEXTURE_2D);
else*/
{
OGLThread_fn_vPostCmd_1Long( OGLT1_ENABLE, GL_TEXTURE_2D);
OGLThread_fn_vPostCmd_1Long( OGLT1_BINDTEXTURE, (long)p_stGlobaleMT->p_stCurrentTexture->p_stSpecParam );
}
}
else
{
// GOURAUD
OGLThread_fn_vPostCmd_1Long( OGLT1_DISABLE, GL_TEXTURE_2D);
//glBindTexture(GL_TEXTURE_2D, 0 );
if (((p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lIsNotGrided) == 0) && (p_stGlobaleMT->xGlobalAlpha < 0.98f) )
{
// alpha iterated transparency
/*
grAlphaBlendFunction( GR_BLEND_SRC_ALPHA,GR_BLEND_ONE_MINUS_SRC_ALPHA,GR_BLEND_ONE,GR_BLEND_ZERO );
grAlphaCombine(GR_COMBINE_FUNCTION_BLEND, GR_COMBINE_FACTOR_LOCAL_ALPHA,GR_COMBINE_LOCAL_ITERATED, GR_COMBINE_OTHER_NONE,FXFALSE);
guAlphaSource(GR_ALPHASOURCE_ITERATED_ALPHA);
*/
OGLThread_fn_vPostCmd_2Long( OGLT2_BLENDFUNC, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
p_stGlobaleMT -> lClippingModeMask |= GLI_C_TrianglesMustBeSorted;
}
else
{
/*
grAlphaCombine( GR_COMBINE_FUNCTION_SCALE_OTHER,GR_COMBINE_FACTOR_ONE,GR_COMBINE_LOCAL_ITERATED,GR_COMBINE_OTHER_ITERATED,FXFALSE);
grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO, GR_BLEND_ONE, GR_BLEND_ZERO);
*/
OGLThread_fn_vPostCmd_2Long( OGLT2_BLENDFUNC, GL_ONE, GL_ZERO);
}
OGLThread_fn_vPostCmd_1Long( OGLT1_TEXTUREENV, GL_MODULATE); //guColorCombineFunction( GR_COLORCOMBINE_ITRGB );
ucSaveFunction = 0;
OGLThread_fn_vPostCmd_1Long( OGLT1_DISABLE, GL_ALPHA_TEST);
}
}
/*
=======================================================================================
Write bitmap into backbuffer
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : write bitmap part into backbuffer
----------------------------------------------------------------------------------------
*/
/*
void GLI_fn_vWriteRegion3DFX(long X, long Y, long l, long h, unsigned char *p_ucSrc, long SrcPitch , GrLfbInfo_t *p_info)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/* long lPitch;
long *p_sourceptr , *p_sourceptrLast , *p_destptr ,lYCounterLocal;
short *p_Src;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/* p_Src = (unsigned short *)p_ucSrc;
lPitch = p_info->strideInBytes/4;
for (lYCounterLocal = 0; lYCounterLocal < h ; lYCounterLocal++)
{
p_destptr = ((unsigned long *)p_info->lfbPtr) + (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 : Write a 16 bit bitmap in the back buffer
_p_vSourceBuffer -> bitmap
_lWidth, _lHeight -> dimension of bitmap
_lDestX, _lDestY -> where the bitmap have to be copied in the backbuffer
----------------------------------------------------------------------------------------
*/
void* g_p_vSourceBuffer;
RECT g_DestBitmapRect;
void GLI_DRV_vWrite16bBitmapToBackBuffer( void *_p_vSourceBuffer, long _lWidth, long _lHeight, long _lDestLeft, long _lDestTop, long _lDestRight, long _lDestBottom )
{
g_p_vSourceBuffer = _p_vSourceBuffer;
g_DestBitmapRect.left = _lDestLeft;
g_DestBitmapRect.top = _lDestTop;
g_DestBitmapRect.right = _lDestRight;
g_DestBitmapRect.bottom = _lDestBottom;
OGLThread_fn_vPostCmd_2Long( OGLT2_WRITEBITMAP, _lWidth, _lHeight );
}
#ifdef __cplusplus
} //extern "C"
#endif

View File

@@ -0,0 +1,121 @@
/*
=======================================================================================
Name : OGL_Errors.c
Author : Bart
Description :
=======================================================================================
*/
/*
=======================================================================================
Include
=======================================================================================
*/
#include <windows.h>
#include <stdio.h>
#include <gl/gl.h>
#include "OGL_Options.h"
#include "OGL_Errors.h"
#include "OGL_Thread.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#ifdef __cplusplus
extern "C"
{
#endif
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/***** Errors Managment (ERROR_TEST) ******/
#if defined (ERROR_TEST)
void fn_vOutputLog(char* ErrorString)
{
static FILE *g_fErrorFile;
static BOOL g_bFirstTime = TRUE;
if (g_bFirstTime) {
g_bFirstTime = FALSE;
g_fErrorFile = fopen( "errors.log", "wt" );
}
if (g_fErrorFile != NULL) {
fprintf(g_fErrorFile, ErrorString);
fflush(g_fErrorFile);
}
}
void fn_vOglError(char* oglFunc)
{
GLenum oglError;
GLenum oglPrevError;
char oglErrorString[255];
int oglErrorCount;
oglError = glGetError();
while ( oglError != GL_NO_ERROR )
{
switch (oglError) {
case GL_INVALID_ENUM : sprintf(oglErrorString, "OpenGLError: INVALID_ENUM in %s ", oglFunc); break;
case GL_INVALID_VALUE : sprintf(oglErrorString, "OpenGLError: INVALID_VALUE in %s ", oglFunc); break;
case GL_INVALID_OPERATION : sprintf(oglErrorString, "OpenGLError: INVALID_OPERATION in %s ", oglFunc); break;
case GL_STACK_OVERFLOW : sprintf(oglErrorString, "OpenGLError: STACK_OVERFLOW in %s ", oglFunc); break;
case GL_STACK_UNDERFLOW : sprintf(oglErrorString, "OpenGLError: STACK_UNDERFLOW in %s ", oglFunc); break;
case GL_OUT_OF_MEMORY : sprintf(oglErrorString, "OpenGLError: OUT_OF_MEMORY in %s ", oglFunc); break;
default : sprintf(oglErrorString, "OpenGLError: !!UNKNOWN!! in %s ", oglFunc); break;
}
M_OUTPUT(oglErrorString);
oglErrorCount = 20;
oglPrevError = glGetError();
while ( (oglErrorCount>0) && ( oglPrevError == oglError ) )
{
M_OUTPUT(".");
oglErrorCount--;
oglPrevError = glGetError();
}
if ( (oglErrorCount == 0) && ( oglPrevError == oglError ) ) {
M_OUTPUT("\n\tError on glGetError(); ! ! !");
oglError = GL_NO_ERROR; /* to skip */
}
else
{
oglError = oglPrevError; /* error changed */
}
M_OUTPUT("\n");
}
}
void fn_vError()
{
LPVOID lpMsgBuf;
DWORD dwError;
dwError = GetLastError();
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL,
dwError/*GetLastError()*/,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0,
NULL
);
//MessageBox( NULL, lpMsgBuf, "GetLastError", MB_OK|MB_ICONINFORMATION );
M_OUTPUT(lpMsgBuf);
LocalFree( lpMsgBuf );
}
#endif //defined (ERROR_TEST)
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#ifdef __cplusplus
} //extern "C"
#endif
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

View File

@@ -0,0 +1,393 @@
/*
=======================================================================================
Name : OGL_Func.c
Author : Bart
Description : included in OGL_Thread.c
=======================================================================================
*/
#include "textu_st.h"
#include "texture.h"
#include "DLLCom.h"
#include "TEX.h" // for def of GLI_C_lCyling..
extern HWND gs_hWnd;
HGLRC gs_hRC;
extern HDC gs_hDC;
/* from OGL_Acces.c */
extern GLI_tdScreenVertx ga_stVertexBuffer[ 3000 ];
/* from OGL_HdwTx.c */
#if defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
extern short TEXTURETWIDDLED[1024L*1024L];
#else
extern long TEXTURETWIDDLED[1024L*1024L];
#endif //defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
/* from OGL_Init.c */
extern RECT g_rcViewportRect;
extern RECT g_rcScreenRect;
/* from OGL_Domat.c */
extern GLI_tdScreenVertx g_stBlackTriangle[ 16 ];
extern long g_lNumberOfBlackTriangles;
extern tdstFogParams* g_p_stFogParams;
/************************************ divers ************************************/
void fn_OGLThread_vCreate()
{
M_ASSERT( (gs_hRC = wglCreateContext(gs_hDC)) )
M_ASSERT( wglMakeCurrent(gs_hDC, gs_hRC) )
}
void fn_OGLThread_vResume()
{
M_ASSERT( wglMakeCurrent(gs_hDC, NULL) ) /* make our context 'un-'current */
M_ASSERT( ReleaseDC(gs_hWnd, gs_hDC) ) /* release handle to DC - already done by wglMakeCurrent(..., NULL) ! */
M_ASSERT( wglDeleteContext(gs_hRC) ) /* delete the rendering context */
gs_hRC = NULL;
gs_hDC = NULL;
}
void fn_OGLThread_vSwap()
{
SwapBuffers( gs_hDC );
//glFinish();
//SwapBuffers(wglGetCurrentDC());
}
/************************************ OGL_Acces.c ************************************/
void fn_OGLThread_vRender(GLI_tdScreenVertx* _p_CurrentDestXYZ)
{
GLI_tdScreenVertx *p_stEnumerate;
GLubyte* pBGRA;
M_OGL_ASSERT_FAKE(glBegin(GL_TRIANGLES);)
p_stEnumerate = ga_stVertexBuffer;
while (p_stEnumerate < _p_CurrentDestXYZ)
{
//glColor4ubv( (GLubyte *) &p_stEnumerate->color );
pBGRA = (GLubyte *) &p_stEnumerate->color;
M_OGL_ASSERT_FAKE( glColor4ub( pBGRA[2], pBGRA[1], pBGRA[0], pBGRA[3]); )
M_OGL_ASSERT_FAKE( glTexCoord2f( GetU((*p_stEnumerate)), GetV((*p_stEnumerate)) ); )
M_OGL_ASSERT_FAKE( M_glVertex( GetX((*p_stEnumerate)), GetY((*p_stEnumerate)), GetZ((*p_stEnumerate)) ); )
p_stEnumerate++;
}
M_OGL_ASSERT( glEnd(); )
}
/******************************** fin OGL_Acces.c ************************************/
/************************************ OGL_HdwTx.c ************************************/
void fn_OGLThread_vLoadTextures(GLI_tdstTexture* _p_stTexture)
{
unsigned int *p_uiTextureId;
long lNbLod;
unsigned short lWidth, lHeight;
long lCurrentDecalTextureForMipMapping;
GLint nInternalFormats;
GLenum PixelDataType;
p_uiTextureId = (unsigned int *) &_p_stTexture->p_stSpecParam;
M_OGL_ASSERT( glGenTextures(1, p_uiTextureId ); )
M_OGL_ASSERT( glBindTexture(GL_TEXTURE_2D, *p_uiTextureId); )/*texture is bound*/
#if !defined(IGNORE_TEXTUREWRAP)
/*
* uv cycling mode
*/
switch ( _p_stTexture -> ucCylingMode )
{
case 0:
/*NO CYCLING*/
M_OGL_ASSERT( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); )
M_OGL_ASSERT( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); )
break;
case GLI_C_lCylingUV:
/*CYCLING*/
M_OGL_ASSERT( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); )
M_OGL_ASSERT( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); )
break;
case GLI_C_lCylingU:
/*CYCLING V*/
M_OGL_ASSERT( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); )
M_OGL_ASSERT( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); )
break;
case GLI_C_lCylingV:
/*CYCLING U*/
M_OGL_ASSERT( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); )
M_OGL_ASSERT( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); )
break;
}
#endif //!defined(IGNORE_TEXTUREWRAP)
M_OGL_ASSERT( glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR /*GL_NEAREST*/); )
if (_p_stTexture->lNumberOfLod == 0)
M_OGL_ASSERT( glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); )
else
M_OGL_ASSERT( glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR /*GL_NEAREST_MIPMAP_LINEAR*/ /*GL_LINEAR_MIPMAP_NEAREST*/ /*GL_NEAREST_MIPMAP_NEAREST*/ /*GL_LINEAR*/); )
lCurrentDecalTextureForMipMapping = 0;
lWidth = _p_stTexture->lWidth;
lHeight = _p_stTexture->lHeight;
nInternalFormats = 4; // default : 8888
PixelDataType = GL_UNSIGNED_BYTE; // default (OpenGL ver 1.1, no EXT) : 32 bits !
if ( _p_stTexture->lTextureCaps & GLI_C_lAlphaTest )
{
nInternalFormats = GL_RGB5_A1; //5551
#if defined (OGL_VER2_2)
PixelDataType = GL_UNSIGNED_SHORT_5_5_5_1; //5551
#elif defined (GL_EXT_packed_pixels)
PixelDataType = GL_UNSIGNED_SHORT_5_5_5_1_EXT; //5551
#endif //defined (GL_EXT_packed_pixels)
}
else if ((!(_p_stTexture -> lTextureCaps & GLI_C_lAlphaTexture)) && (_p_stTexture -> lTextureCaps & GLI_C_lNZFilteredTexture))
{
nInternalFormats = GL_RGB5_A1; //5551
#if defined (OGL_VER2_2)
PixelDataType = GL_UNSIGNED_SHORT_5_5_5_1; //5551
#elif defined (GL_EXT_packed_pixels)
PixelDataType = GL_UNSIGNED_SHORT_5_5_5_1_EXT; //5551
#endif //defined (GL_EXT_packed_pixels)
}
else if (_p_stTexture -> lTextureCaps & GLI_C_lAlphaTexture)
{
nInternalFormats = GL_RGBA4; //4444
#if defined (OGL_VER2_2)
PixelDataType = GL_UNSIGNED_SHORT_4_4_4_4; //4444
#elif defined (GL_EXT_packed_pixels)
PixelDataType = GL_UNSIGNED_SHORT_4_4_4_4_EXT; //4444
#endif //defined (GL_EXT_packed_pixels)
}
else
{
nInternalFormats = GL_RGB5; //555 because no 565 !
#if defined (OGL_VER2_2)
PixelDataType = GL_UNSIGNED_SHORT_5_6_5; // 565 only in version 2.2 !
#elif defined (GL_EXT_packed_pixels)
PixelDataType = GL_UNSIGNED_SHORT_5_5_5_1_EXT; //? 5551 because no 565 !
#endif //defined (GL_EXT_packed_pixels)
}
for ( lNbLod=0 ; lNbLod <= _p_stTexture->lNumberOfLod ; lNbLod++ )
{
assert(lHeight>0);
assert(lWidth>0);
M_OGL_ASSERT( glTexImage2D(GL_TEXTURE_2D, lNbLod, nInternalFormats, lWidth, lHeight, 0, GL_RGBA, PixelDataType, TEXTURETWIDDLED+lCurrentDecalTextureForMipMapping ); )
lCurrentDecalTextureForMipMapping += lHeight * lWidth;
lHeight >>= 1;
lWidth >>= 1;
#if defined (MIPMAP_DOWN_TO_1x1)
if (lHeight == 0) lHeight = 1;
if (lWidth == 0) lWidth = 1;
#endif //defined (MIPMAP_DOWN_TO_1x1)
}
}
/******************************** fin OGL_HdwTx.c ************************************/
/************************************ OGL_Init.c ************************************/
#if defined (Z_BUFFER)
#define ZFAR 10000.0f
#define ZNEAR 0.0f //0.1667f
#define VIG_ZPOS 6.0f
#else //W_BUFFER
#define ZFAR 0.0001f
#if defined ACCURATE_DEPTH_BUFFER
#define ZNEAR 0.5f
#else
#define ZNEAR 6.0f
#endif
#define VIG_ZPOS ZNEAR
#endif
void fn_OGLThread_vInitOglFlags()
{
/*** GL_TEXTURE ***/
M_OGL_ASSERT( glMatrixMode(GL_TEXTURE); )
M_OGL_ASSERT( glLoadIdentity(); )
//glScalef( 1.0f, -1.0f, 0.0f ); // ?
/*** GL_PROJECTION ***/
M_OGL_ASSERT( glMatrixMode(GL_PROJECTION); )
M_OGL_ASSERT( glLoadIdentity(); )
/*** GL_MODELVIEW ***/
M_OGL_ASSERT( glMatrixMode(GL_MODELVIEW); )
M_OGL_ASSERT( glLoadIdentity(); )
M_OGL_ASSERT( glOrtho(0, (GLdouble)(g_rcViewportRect.right - g_rcViewportRect.left), (GLdouble)(g_rcViewportRect.bottom - g_rcViewportRect.top), 0, -ZFAR, -ZNEAR); )
M_OGL_ASSERT( glViewport(0, 0, g_rcScreenRect.right - g_rcScreenRect.left, g_rcScreenRect.bottom - g_rcScreenRect.top); )
{
M_OGL_ASSERT( glDisable(GL_ALPHA_TEST); )
//M_OGL_ASSERT( glDisable(GL_BLEND); )
//M_OGL_ASSERT( glDisable(GL_DEPTH_TEST); )
M_OGL_ASSERT( glDisable(GL_DITHER); )
M_OGL_ASSERT( glDisable(GL_LIGHTING); )
M_OGL_ASSERT( glDisable(GL_LOGIC_OP); )
M_OGL_ASSERT( glDisable(GL_STENCIL_TEST); )
M_OGL_ASSERT( glDisable(GL_TEXTURE_1D); )
M_OGL_ASSERT( glDisable(GL_TEXTURE_2D); )
M_OGL_ASSERT( glPixelTransferi(GL_MAP_COLOR, GL_FALSE); )
M_OGL_ASSERT( glPixelTransferi(GL_RED_SCALE, 1); )
M_OGL_ASSERT( glPixelTransferi(GL_RED_BIAS, 0); )
M_OGL_ASSERT( glPixelTransferi(GL_GREEN_SCALE, 1); )
M_OGL_ASSERT( glPixelTransferi(GL_GREEN_BIAS, 0); )
M_OGL_ASSERT( glPixelTransferi(GL_BLUE_SCALE, 1); )
M_OGL_ASSERT( glPixelTransferi(GL_BLUE_BIAS, 0); )
M_OGL_ASSERT( glPixelTransferi(GL_ALPHA_SCALE, 1); )
M_OGL_ASSERT( glPixelTransferi(GL_ALPHA_BIAS, 0); )
}
M_OGL_ASSERT( glEnable(GL_DEPTH_TEST); ) // Hidden surface removal
M_OGL_ASSERT( glDepthMask( GL_TRUE ); )
M_OGL_ASSERT( glDisable(GL_CULL_FACE); ) // Do not calculate inside of jet
//glEnable(GL_CULL_FACE); // Do not calculate inside of jet
M_OGL_ASSERT( glFrontFace(GL_CCW); ) // Counter clock-wise polygons face out
M_OGL_ASSERT( glEnable(GL_TEXTURE_2D); )
M_OGL_ASSERT( glEnable(GL_BLEND); )
M_OGL_ASSERT( glClearColor (0.0, 0.0, 0.0, 0.0); )
M_OGL_ASSERT( glClearDepth(0.0f); )
M_OGL_ASSERT( glDepthFunc( GL_GREATER ); )
//M_OGL_ASSERT( glClearDepth(1.0f); )
//M_OGL_ASSERT( glDepthFunc( GL_LESS ); )
//glDepthMask( GL_TRUE );
// fog
M_OGL_ASSERT( glDisable(GL_FOG); )
M_OGL_ASSERT( glFogi(GL_FOG_MODE, GL_LINEAR /*GL_EXP*/); ) //grFogTable( Gli_C_xFogTable );
// hint
M_OGL_ASSERT( glHint (GL_FOG_HINT, /*GL_NICEST*/ GL_FASTEST); ) /* per pixel */
M_OGL_ASSERT( glHint (GL_PERSPECTIVE_CORRECTION_HINT, /*GL_NICEST*/ GL_FASTEST); )
}
void fn_OGLThread_vClearDevice(BOOL ZBuffer, BOOL ColorBuffer, unsigned long Color)
{
char cR, cG, cB, cA;
char* pColor;
M_OGL_ASSERT( glDepthMask( GL_TRUE ); )
pColor = (char*) &Color;
cR = *pColor++;
cG = *pColor++;
cB = *pColor++;
cA = *pColor;
M_OGL_ASSERT( glClearColor ((float)cR/255.0f, (float)cG/255.0f, (float)cB/255.0f, (float)cA/255.0f); )
if ( ColorBuffer )
if (ZBuffer)
M_OGL_ASSERT( {glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); )}
else
M_OGL_ASSERT( {glClear(GL_COLOR_BUFFER_BIT ); )}
else if (ZBuffer)
M_OGL_ASSERT( {glClear( GL_DEPTH_BUFFER_BIT ); )}
}
/******************************** fin OGL_Init.c ************************************/
/******************************** OGL_Domat.c ************************************/
void fn_OGLThread_vSendBlackPolygon(void)
{
GLI_tdScreenVertx *p_stVertex, *p_stLastVertex;
M_OGL_ASSERT( glDisable(GL_TEXTURE_2D); )
M_OGL_ASSERT( glDisable(GL_FOG); )
M_OGL_ASSERT( glBlendFunc(GL_ONE, GL_ZERO); ) //grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO, GR_BLEND_ONE, GR_BLEND_ZERO);
M_OGL_ASSERT( glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE/*GL_DECAL*/ /*not yet implemented : GL_BLEND, GL_REPLACE*/ ); ) //guColorCombineFunction( GR_COLORCOMBINE_ITRGB);
M_OGL_ASSERT( glColor4ub( 0, 0, 0, 0 ); )
p_stVertex = g_stBlackTriangle;
p_stLastVertex = p_stVertex + g_lNumberOfBlackTriangles;
M_OGL_ASSERT_FAKE( glBegin(GL_QUADS); )
for ( ; p_stVertex < p_stLastVertex; p_stVertex++ )
M_OGL_ASSERT_FAKE( glVertex3f( p_stVertex->sx, p_stVertex->sy, p_stVertex->sz ); )
M_OGL_ASSERT( glEnd(); )
}
void fn_OGLThread_vSetFogParams(void)
{
GLfloat fogColor[4];
GLfloat fBlendFactor;
M_OGL_ASSERT( glFogf (GL_FOG_START, g_p_stFogParams->xDepthStart); )
M_OGL_ASSERT( glFogf (GL_FOG_END, g_p_stFogParams->xDepthEnd); )
//glFogf (GL_FOG_DENSITY, g_p_stFogParams->xBlendEnd); // ?
fBlendFactor = g_p_stFogParams->xBlendEnd / 255.0f;
fogColor[0] = (GLfloat)g_p_stFogParams->stColor.xR * fBlendFactor;
fogColor[1] = (GLfloat)g_p_stFogParams->stColor.xG * fBlendFactor;
fogColor[2] = (GLfloat)g_p_stFogParams->stColor.xB * fBlendFactor;
fogColor[3] = (GLfloat)g_p_stFogParams->stColor.xA * fBlendFactor;
M_OGL_ASSERT( glFogfv(GL_FOG_COLOR, fogColor); ) //grFogColorValue(GlideColor);
fBlendFactor = g_p_stFogParams->xBlendStart / 255.0f;
fogColor[0] = (GLfloat)g_p_stFogParams->stColor.xR * fBlendFactor;
fogColor[1] = (GLfloat)g_p_stFogParams->stColor.xG * fBlendFactor;
fogColor[2] = (GLfloat)g_p_stFogParams->stColor.xB * fBlendFactor;
fogColor[3] = (GLfloat)g_p_stFogParams->stColor.xA * fBlendFactor;
M_OGL_ASSERT( glTexEnvfv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, fogColor ); )
}
/******************************** fin OGL_Domat.c ************************************/
#include "OGL_Lock.c"

View File

@@ -0,0 +1,396 @@
#include <windows.h>
#include <gl/gl.h>
#include "GLD.h"
#include "GEO.h"
#include "TEX.h"
#include "gli_st.h"
#include "textu_st.h"
#include "texture.h"
#include "FIL.h"
#include "DLLCom.h"
#include "OGL_Options.h"
#include "OGL_Errors.h"
#include "OGL_Thread.h"
static long GLI_gs_lMaxTmuAvailable;
//GLI_tdstTexture *g_p_stTexture;
#if defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
short TEXTURETWIDDLED[1024L*1024L];
#else
long TEXTURETWIDDLED[1024L*1024L];
#endif //defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
/*
----------------------------------------------------------------------------------------
Description : get total memory size available for texture
----------------------------------------------------------------------------------------
*/
long GLI_fn_lGetTotalTextureMemorySize( void )
{
/*
long i,lSize;
GLI_gs_lMaxTmuAvailable = 2 ;
lSize = 0;
for (i = 0 ; i < GLI_gs_lMaxTmuAvailable ; i++)
lSize += grTexMaxAddress( i ) - grTexMinAddress( i );
return (lSize);
*/
return -1;
}
/*
----------------------------------------------------------------------------------------
Description : get video memory size taken by a given texture
----------------------------------------------------------------------------------------
*/
long GLI_DRV_lGetSizeOfTexture( GLI_tdstTexture *p_stTexture )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long lTextureSize;
long lRef, lSize;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
lTextureSize = p_stTexture->lHeight * p_stTexture->lWidth;
/*
* 8 bits
*/
if (!(p_stTexture->lTextureCaps & GLI_C_lPaletteTexture))
lTextureSize <<= 1;
/*
* mipmap
*/
if (p_stTexture ->lNumberOfLod)
{
lRef = (p_stTexture->lWidth > p_stTexture->lHeight) ? p_stTexture->lHeight : p_stTexture->lWidth;
lSize = lTextureSize;
while ( lRef )
{
lSize >>= 2;
lRef >>= 1;
lTextureSize += lSize;
}
}
/*
* alignment
*/
if ( lTextureSize & 0x7 )
{
lTextureSize += 8 - (lTextureSize & 0x7);
}
GLI_MDRV_TEXBENCH_vSetTextureSize( p_stTexture, TEXBENCH_C_cComputedSize, lTextureSize );
return lTextureSize;
}
/*
----------------------------------------------------------------------------------------
Description : Compress texture and compute mip map levels
----------------------------------------------------------------------------------------
*/
static void GLI_vCompressTex ( GLI_tdstTexture *p_stTexture, BOOL bReloading)
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long lCurrentDecalTextureForMipMapping, Verify;
#if defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
unsigned short *p_Destination;
#else
unsigned long *p_Destination;
#endif //defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
//unsigned char *p_ucDest;
//unsigned long *p_ulPalette;
long lNbLod;
unsigned short lWidth, lHeight;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
if (p_stTexture == NULL )
return;
lCurrentDecalTextureForMipMapping = 0;
p_Destination = TEXTURETWIDDLED;
p_stTexture->p_vBitMap = GLI_gs_p_ConvertBufferMipMapping;
/*
* load texture
*/
GLI_MDRV_xLoadTextureInTexelField(p_stTexture, GLI_gs_p_ConvertBufferMipMapping, bReloading/*TRUE*/);
/*
* check for alpha texture
*/
if ((p_stTexture -> lTextureCaps & GLI_C_lAlphaTexture) || (p_stTexture -> lTextureCaps & GLI_C_lNZFilteredTexture))
{
Verify = GLI_MDRV_vVerifyTextureIsRealyAlpha(p_stTexture);
if ((Verify & 0xE0000000) == 0xE0000000)
p_stTexture -> lTextureCaps &= 0xffffffff - GLI_C_lAlphaTexture;
if ((Verify & 0x80000000) == 0x80000000)
p_stTexture -> lTextureCaps &= 0xffffffff - GLI_C_lNZFilteredTexture;
}
#if defined (NO_MIPMAP_FOR_TRANSPARENT_TEX)
if (p_stTexture -> lTextureCaps & (/*GLI_C_lAlphaTest |*/ GLI_C_lAlphaTexture /*| GLI_C_lNZFilteredTexture */ /*| GLI_C_lAddTransparencyTexture*/) )
p_stTexture->lNumberOfLod = 0;
#endif //defined (NO_MIPMAP_FOR_TRANSPARENT_TEX)
#if defined (MIPMAP_DOWN_TO_1x1)
if ( (p_stTexture->lNumberOfLod >0) && (p_stTexture->lWidth != p_stTexture->lHeight) )
{
//recalc lNumberOfLod
lWidth = p_stTexture->lWidth;
lHeight = p_stTexture->lHeight;
while ( (lWidth>1) && (lHeight>1) ) {
lHeight >>= 1;
lWidth >>= 1;
}
while ( (lWidth>1) || (lHeight>1) ) {
p_stTexture->lNumberOfLod++;
lHeight >>= 1;
lWidth >>= 1;
}
}
#endif //defined MIPMAP_DOWN_TO_1x1
p_stTexture->p_vBitMap = GLI_gs_p_ConvertBufferMipMapping;
lNbLod = p_stTexture->lNumberOfLod;
lWidth = p_stTexture->lWidth;
lHeight = p_stTexture->lHeight;
/*if ( p_stTexture->lTextureCaps & GLI_C_lPaletteTexture )
{
p_ucDest = (char *) p_Destination;
p_ulPalette = (unsigned long *) p_stTexture->p_vColorTable;
//((GLI_tdstTextureDFX *) p_stTexture->p_stSpecParam)->stInfoBitmapGlide.format = GR_TEXFMT_P_8;
memcpy( p_ucDest, GLI_gs_p_ConvertBufferMipMapping, p_stTexture->lHeight * p_stTexture->lWidth );
lCurrentDecalTextureForMipMapping = p_stTexture->lHeight * p_stTexture->lWidth ;
while( lNbLod-- )
{
GLI_MDRV_vDivideBitmapSurfaceBy2Palette( (unsigned long *)GLI_gs_p_ConvertBufferMipMapping , p_ulPalette, p_stTexture->lHeight, p_stTexture->lWidth );
p_stTexture->lHeight >>= 1;
p_stTexture->lWidth >>= 1;
memcpy( p_ucDest + lCurrentDecalTextureForMipMapping, GLI_gs_p_ConvertBufferMipMapping, p_stTexture->lHeight * p_stTexture->lWidth );
lCurrentDecalTextureForMipMapping += p_stTexture->lHeight * p_stTexture->lWidth;
}
}
else */
// TEST sur nouveau traitement sur texture NZ : marche pas bien pour l'instant
if ( p_stTexture->lTextureCaps & GLI_C_lAlphaTest )
{
//((GLI_tdstTextureDFX *) p_stTexture->p_stSpecParam)->stInfoBitmapGlide.format = GR_TEXFMT_ARGB_1555;
#if defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
GLI_MDRV_vCompressTex1555( p_stTexture ,(void *)(p_Destination)) ;
#else
memcpy( p_Destination, GLI_gs_p_ConvertBufferMipMapping, p_stTexture->lHeight * p_stTexture->lWidth * sizeof(unsigned long) );
#endif //defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
lCurrentDecalTextureForMipMapping = p_stTexture->lHeight * p_stTexture->lWidth ;
while( lNbLod-- )
{
GLI_MDRV_vDivideBitmapSurfaceBy2NonZero((unsigned long *)GLI_gs_p_ConvertBufferMipMapping , (unsigned long *)GLI_gs_p_ConvertBufferMipMapping , p_stTexture->lHeight, p_stTexture->lWidth, p_stTexture->lChromakeyColorRGBA); /* G.CLEMENT 04/08/1999 : added chromakey */
p_stTexture->lHeight >>= 1;
p_stTexture->lWidth >>= 1;
#if defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
GLI_MDRV_vCompressTex1555( p_stTexture ,(void *)(p_Destination + lCurrentDecalTextureForMipMapping)) ;
#else
memcpy( p_Destination + lCurrentDecalTextureForMipMapping, GLI_gs_p_ConvertBufferMipMapping, p_stTexture->lHeight * p_stTexture->lWidth * sizeof(unsigned long) );
#endif //defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
lCurrentDecalTextureForMipMapping += p_stTexture->lHeight * p_stTexture->lWidth;
}
}
else if ((!(p_stTexture -> lTextureCaps & GLI_C_lAlphaTexture)) && (p_stTexture -> lTextureCaps & GLI_C_lNZFilteredTexture))
{
//((GLI_tdstTextureDFX *) p_stTexture->p_stSpecParam)->stInfoBitmapGlide.format = GR_TEXFMT_ARGB_1555;
#if defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
GLI_MDRV_vCompressTex1555( p_stTexture ,(void *)(p_Destination)) ;
#else
memcpy( p_Destination , GLI_gs_p_ConvertBufferMipMapping, p_stTexture->lHeight * p_stTexture->lWidth * sizeof(unsigned long) );
#endif //defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
lCurrentDecalTextureForMipMapping = p_stTexture->lHeight * p_stTexture->lWidth ;
while( lNbLod-- )
{
if (p_stTexture -> lTextureCaps & GLI_C_lNZTexture)
GLI_MDRV_vDivideBitmapSurfaceBy2NonZero((unsigned long *)GLI_gs_p_ConvertBufferMipMapping , (unsigned long *)GLI_gs_p_ConvertBufferMipMapping , p_stTexture -> lHeight, p_stTexture -> lWidth, p_stTexture->lChromakeyColorRGBA); /* G.CLEMENT 04/08/1999 : added chromakey */
else
GLI_MDRV_vDivideBitmapSurfaceBy2((unsigned long *)GLI_gs_p_ConvertBufferMipMapping , (unsigned long *)GLI_gs_p_ConvertBufferMipMapping , p_stTexture -> lHeight, p_stTexture -> lWidth);
p_stTexture->lHeight >>= 1;
p_stTexture->lWidth >>= 1;
#if defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
GLI_MDRV_vCompressTex1555( p_stTexture ,(void *)(p_Destination + lCurrentDecalTextureForMipMapping)) ;
#else
memcpy( p_Destination + lCurrentDecalTextureForMipMapping, GLI_gs_p_ConvertBufferMipMapping, p_stTexture->lHeight * p_stTexture->lWidth * sizeof(unsigned long) );
#endif //defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
lCurrentDecalTextureForMipMapping += p_stTexture->lHeight * p_stTexture->lWidth;
}
}
else if (p_stTexture -> lTextureCaps & GLI_C_lAlphaTexture)
{
//((GLI_tdstTextureDFX *) p_stTexture->p_stSpecParam)->stInfoBitmapGlide.format = GR_TEXFMT_ARGB_4444;
#if defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
GLI_MDRV_vCompressTex4444( p_stTexture , (void *)(p_Destination)) ;
#else
memcpy( p_Destination, GLI_gs_p_ConvertBufferMipMapping, p_stTexture->lHeight * p_stTexture->lWidth * sizeof(unsigned long) );
#endif //defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
lCurrentDecalTextureForMipMapping = p_stTexture->lHeight * p_stTexture->lWidth ;
while( lNbLod-- )
{
if (p_stTexture -> lTextureCaps & GLI_C_lNZTexture)
GLI_MDRV_vDivideBitmapSurfaceBy2NonZero((unsigned long *)GLI_gs_p_ConvertBufferMipMapping , (unsigned long *)GLI_gs_p_ConvertBufferMipMapping , p_stTexture -> lHeight , p_stTexture -> lWidth, p_stTexture->lChromakeyColorRGBA); /* G.CLEMENT 04/08/1999 : added chromakey */
else
GLI_MDRV_vDivideBitmapSurfaceBy2((unsigned long *)GLI_gs_p_ConvertBufferMipMapping , (unsigned long *)GLI_gs_p_ConvertBufferMipMapping , p_stTexture -> lHeight , p_stTexture -> lWidth );
p_stTexture->lHeight >>= 1;
p_stTexture->lWidth >>= 1;
#if defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
GLI_MDRV_vCompressTex4444( p_stTexture , (void *)(p_Destination + lCurrentDecalTextureForMipMapping)) ;
#else
memcpy( p_Destination + lCurrentDecalTextureForMipMapping, GLI_gs_p_ConvertBufferMipMapping, p_stTexture->lHeight * p_stTexture->lWidth * sizeof(unsigned long) );
#endif //defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
lCurrentDecalTextureForMipMapping += p_stTexture->lHeight * p_stTexture->lWidth;
}
}
else
{
//((GLI_tdstTextureDFX *) p_stTexture->p_stSpecParam)->stInfoBitmapGlide.format = GR_TEXFMT_RGB_565;
#if defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
GLI_MDRV_vCompressTex565( p_stTexture , (void *)(p_Destination)) ;
#else
memcpy( p_Destination, GLI_gs_p_ConvertBufferMipMapping, p_stTexture->lHeight * p_stTexture->lWidth * sizeof(unsigned long) );
#endif //defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
lCurrentDecalTextureForMipMapping = p_stTexture->lHeight * p_stTexture->lWidth ;
while( lNbLod-- )
{
if (p_stTexture -> lTextureCaps & GLI_C_lNZTexture)
GLI_MDRV_vDivideBitmapSurfaceBy2NonZero((unsigned long *)GLI_gs_p_ConvertBufferMipMapping , (unsigned long *)GLI_gs_p_ConvertBufferMipMapping , p_stTexture -> lHeight, p_stTexture -> lWidth, p_stTexture->lChromakeyColorRGBA); /* G.CLEMENT 04/08/1999 : added chromakey */
else
GLI_MDRV_vDivideBitmapSurfaceBy2((unsigned long *)GLI_gs_p_ConvertBufferMipMapping , (unsigned long *)GLI_gs_p_ConvertBufferMipMapping , p_stTexture -> lHeight, p_stTexture -> lWidth);
p_stTexture->lHeight >>= 1;
p_stTexture->lWidth >>= 1;
#if defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
GLI_MDRV_vCompressTex565 ( p_stTexture , (void *)(p_Destination + lCurrentDecalTextureForMipMapping)) ;
#else
memcpy( p_Destination + lCurrentDecalTextureForMipMapping, GLI_gs_p_ConvertBufferMipMapping, p_stTexture->lHeight * p_stTexture->lWidth * sizeof(unsigned long) );
#endif //defined (OGL_VER2_2) || defined (GL_EXT_packed_pixels)
lCurrentDecalTextureForMipMapping += p_stTexture->lHeight * p_stTexture->lWidth;
}
}
p_stTexture->lWidth = lWidth;
p_stTexture->lHeight = lHeight;
}
/*
----------------------------------------------------------------------------------------
Description : get total memory size available for texture
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vDownLoadTextures(long bRestore, long _lTextureMode, BOOL bReloading )
{
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
long lTextureCounter;
GLI_tdstTexture *p_stTexture;
/*#if defined (ERROR_TEST)
char sz255String[255];
#endif //defined (ERROR_TEST)*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
#if defined (ERROR_TEST)
p_uiTextureId = NULL;
#endif //defined (ERROR_TEST)
*/
for (lTextureCounter = 0; lTextureCounter < GLI_C_lNBMaxOfTextures ; lTextureCounter ++)
{
if (gs_aDEFTableOfTextureMemoryChannels[lTextureCounter] == GLI_TEXIsUnallocated )
continue;
p_stTexture = gs_aDEFTableOfTextureAlreadyRead[lTextureCounter];
if (p_stTexture == NULL)
continue;
OGLThread_fn_vWaitForSynchro(); // finishing
GLI_vCompressTex( p_stTexture, bReloading);
//GLI_MDRV_xLoadTextureInTexelField(p_stTexture, GLI_gs_p_ConvertBufferMipMapping, bReloading); //bart990224
p_stTexture -> bIsAvailable = 1;
OGLThread_fn_vWaitForSynchro(); // for TEXTURETWIDDLED
//grTexDownloadMipMap (p_stSpecParam -> xTmuNumber,p_stSpecParam -> xStartAddress ,p_stSpecParam -> xEvenOdd ,&p_stSpecParam -> stInfoBitmapGlide );
OGLThread_fn_vPostCmd_1Long(OGLT1_LOADTEXTURES, (long)p_stTexture);
}
/*
#if defined (ERROR_TEST)
if (p_uiTextureId == NULL) {
M_OUTPUT("No texture loaded ! ! !\n");
}
else {
sprintf(sz255String, "Last texture loaded : %d\n", *p_uiTextureId);
M_OUTPUT(sz255String);
}
#endif //defined (ERROR_TEST)
*/
/*#endif*/
}
/*
----------------------------------------------------------------------------------------
Description : get total memory size available for texture
----------------------------------------------------------------------------------------
*/
void GLI_DRV_vUnLoadTextures()
{
long lTextureCounter;
//unsigned int *p_uiTextureId;
GLI_tdstTexture *p_stTexture;
for ( lTextureCounter = 0 ; lTextureCounter < C_lMaxNumberOfTexture ;lTextureCounter ++)
{
if (
(gs_aDEFTableOfTextureMemoryChannels[lTextureCounter] != GLI_TEXIsUnallocated )
)
{
p_stTexture = gs_aDEFTableOfTextureAlreadyRead[lTextureCounter];
if (p_stTexture != NULL)
{
if (p_stTexture->bIsAvailable)
{
OGLThread_fn_vPostCmd_1Long(OGLT1_DELETETEXTURE, (long)p_stTexture->p_stSpecParam); //p_uiTextureId = (unsigned int *) &p_stTexture->p_stSpecParam;
p_stTexture->bIsAvailable = 0;
}
}
}
}
}
#ifdef __cplusplus
} /* extern "C" */
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,398 @@
/*
=======================================================================================
Name : OGL_Lock.c
Author : Bart
Description :
=======================================================================================
*/
/*
=======================================================================================
Lock / unlock backbuffer
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : Lock (return pointer on virtual screen and pitch value)
----------------------------------------------------------------------------------------
*/
#define MAX_TEX_WIDTH 1024 /*256*/
#define MAX_TEX_HEIGHT 512 /*128*/
//unsigned long g_aulTmpBuffer[ MAX_TEX_WIDTH * MAX_TEX_HEIGHT ]; // RGBA 8888
unsigned char g_a3ucTmpBuffer[ 3 * MAX_TEX_WIDTH * MAX_TEX_HEIGHT ]; // RGB 888
unsigned short g_auwBuffer[ MAX_TEX_WIDTH * MAX_TEX_HEIGHT ]; // RGB 565
void* g_p_vVirtualScreen;
long g_lPitch;
void vConvertBuffer888To565_InvY(unsigned short* _puwDst, unsigned char* _pucSrc, long _lWidth, long _lHeight, long _lYOffset)
{
int Xpos, Ypos;
unsigned char cR, cG, cB;
unsigned char* pucSrc;
unsigned char* pucDst;
for (Ypos = 0; Ypos<_lHeight-_lYOffset ; Ypos++)
{
pucSrc = (unsigned char*)(_pucSrc+3*(_lHeight-_lYOffset-Ypos-1)*_lWidth);
pucDst = (unsigned char*)(_puwDst+Ypos*_lWidth);
for (Xpos = 0; Xpos<_lWidth ; Xpos++)
{
cR = *pucSrc++;
cG = *pucSrc++;
cB = *pucSrc++;
*pucDst++ = ((cG&0x1C)<<3)+((cB&0xF8)>>3);
*pucDst++ = (cR&0xF8)+((cG&0xE0)>>5);
}
}
memset( _puwDst + (_lHeight-_lYOffset) * _lWidth , 0, _lYOffset*_lWidth*sizeof(unsigned short));
}
void vConvertBuffer565To888(unsigned char* _pucDst, unsigned short* _puwSrc, long _lWidth, long _lHeight)
{
int Xpos, Ypos;
unsigned char cR, cG, cB;
unsigned char* pucSrc;
unsigned char* pucDst;
for (Ypos = 0; Ypos<_lHeight ; Ypos++)
{
pucSrc = (unsigned char*)(_puwSrc+Ypos*_lWidth);
pucDst = (unsigned char*)(_pucDst+3*Ypos*_lWidth);
for (Xpos = 0; Xpos<_lWidth ; Xpos++)
{
cB = (*pucSrc & 0x1F)<<3;
cG = ((*pucSrc & 0xE0)>>3) + ((*(pucSrc+1) & 0x07)<<5);
cR = (*(pucSrc+1) & 0xF8);
pucSrc+=2;
*pucDst++ = cR;
*pucDst++ = cG;
*pucDst++ = cB;
}
}
}
long fn_lSmallestPowerOfTwoGreaterThan(long lNb, GLint _nMaxSize)
{
long lRet = 1;
while (lRet < _nMaxSize)
{
if (lNb <= lRet)
return lRet;
lRet <<= 1;
}
return _nMaxSize;
}
void fn_OGL_vDisplayTexture(long _lWScreen, long _lHScreen, long _lWTexture, long _lHTexture)
{
float fWRatio, fHRatio;
float fWTextureCoord, fHTextureCoord, fWVertexCoord, fHVertexCoord;
float fCoordLeft, fCoordRight, fCoordTop, fCoordBottom;
fWRatio = (float)_lWScreen / (float)_lWTexture;
fHRatio = (float)_lHScreen / (float)_lHTexture;
if (fWRatio < 1) {
fWTextureCoord = fWRatio;
fWVertexCoord = 1;
} else {
fWTextureCoord = 1;
fWVertexCoord = 1/fWRatio;
}
if (fHRatio < 1) {
fHTextureCoord = fHRatio;
fHVertexCoord = 1;
} else {
fHTextureCoord = 1;
fHVertexCoord = 1/fHRatio;
}
fCoordLeft = -1;
fCoordRight = -1 + 2*fWVertexCoord;
fCoordTop = -(-1);
fCoordBottom = -(-1 + 2*fHVertexCoord);
M_OGL_ASSERT( glEnable( GL_TEXTURE_2D); )
M_OGL_ASSERT( glDisable( GL_BLEND); )
M_OGL_ASSERT( glDisable(GL_DEPTH_TEST); )
M_OGL_ASSERT( glMatrixMode(GL_MODELVIEW); )
M_OGL_ASSERT( glPushMatrix(); )
M_OGL_ASSERT( glLoadIdentity(); )
//M_OGL_ASSERT( glRasterPos2f(-1.0f, -1.0f); )
M_OGL_ASSERT_FAKE( glBegin (GL_QUADS); )
M_OGL_ASSERT_FAKE( glColor4f( 1, 1, 1, 1); )
M_OGL_ASSERT_FAKE( glTexCoord2f(0, /*1*/fHTextureCoord); )
M_OGL_ASSERT_FAKE( glVertex3f(fCoordLeft, fCoordBottom, 0); )
M_OGL_ASSERT_FAKE( glTexCoord2f(0, /*1-fHTextureCoord*/0); )
M_OGL_ASSERT_FAKE( glVertex3f(fCoordLeft, fCoordTop, 0); )
M_OGL_ASSERT_FAKE( glTexCoord2f(fWTextureCoord, /*1-fHTextureCoord*/0); )
M_OGL_ASSERT_FAKE( glVertex3f(fCoordRight, fCoordTop, 0); )
M_OGL_ASSERT_FAKE( glTexCoord2f(fWTextureCoord, /*1*/fHTextureCoord); )
M_OGL_ASSERT_FAKE( glVertex3f(fCoordRight, fCoordBottom, 0); )
M_OGL_ASSERT( glEnd(); )
M_OGL_ASSERT( glPopMatrix(); )
M_OGL_ASSERT( glEnable(GL_DEPTH_TEST); )
M_OGL_ASSERT( glEnable(GL_BLEND); )
}
void fn_OGL_vDisplayTextureWithCoord(long _lWScreen, long _lHScreen, long _lWTexture, long _lHTexture, long _lCoordLeft, long _lCoordTop, long _lCoordRight, long _lCoordBottom)
{
float fWRatio, fHRatio;
fWRatio = (float)_lWScreen / (float)_lWTexture;
fHRatio = (float)_lHScreen / (float)_lHTexture;
assert (fWRatio < 1);
assert (fHRatio < 1);
M_OGL_ASSERT( glEnable( GL_TEXTURE_2D); )
M_OGL_ASSERT( glDisable( GL_BLEND); )
M_OGL_ASSERT( glDisable(GL_DEPTH_TEST); )
M_OGL_ASSERT( glMatrixMode(GL_MODELVIEW); )
/*
M_OGL_ASSERT( glPushMatrix(); )
M_OGL_ASSERT( glLoadIdentity(); )
M_OGL_ASSERT( glOrtho(0, (GLdouble)(_lCoordRight - _lCoordLeft), (GLdouble)(_lCoordBottom - _lCoordTop), 0, 0, -0.5); )
*/
M_OGL_ASSERT_FAKE( glBegin (GL_QUADS); )
M_OGL_ASSERT_FAKE( glColor4f( 1, 1, 1, 1); )
M_OGL_ASSERT_FAKE( glTexCoord2f(0, fHRatio); )
M_OGL_ASSERT_FAKE( glVertex3f((float)_lCoordLeft, (float)_lCoordBottom, VIG_ZPOS); )
M_OGL_ASSERT_FAKE( glTexCoord2f(0, 0); )
M_OGL_ASSERT_FAKE( glVertex3f((float)_lCoordLeft, (float)_lCoordTop, VIG_ZPOS); )
M_OGL_ASSERT_FAKE( glTexCoord2f(fWRatio, 0); )
M_OGL_ASSERT_FAKE( glVertex3f((float)_lCoordRight, (float)_lCoordTop, VIG_ZPOS); )
M_OGL_ASSERT_FAKE( glTexCoord2f(fWRatio, fHRatio); )
M_OGL_ASSERT_FAKE( glVertex3f((float)_lCoordRight, (float)_lCoordBottom, VIG_ZPOS); )
M_OGL_ASSERT( glEnd(); )
//M_OGL_ASSERT( glPopMatrix(); )
M_OGL_ASSERT( glEnable(GL_DEPTH_TEST); ) // Hidden surface removal
M_OGL_ASSERT( glEnable(GL_BLEND); )
}
long g_lScreenWidth, g_lScreenHeight, g_lTextureWidth, g_lTextureHeight;
void fn_OGLThread_vLockDevice(void)
{
GLuint uiTextureId;
RECT rcScreenRect;
GLint nMaxSize;
long lYPos;
GetClientRect( gs_hWnd, &rcScreenRect );
g_lScreenWidth = rcScreenRect.right - rcScreenRect.left;
g_lScreenHeight = rcScreenRect.bottom - rcScreenRect.top;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &nMaxSize);
g_lTextureWidth = fn_lSmallestPowerOfTwoGreaterThan(g_lScreenWidth, (nMaxSize>MAX_TEX_WIDTH) ? MAX_TEX_WIDTH : nMaxSize);
g_lTextureHeight = fn_lSmallestPowerOfTwoGreaterThan(g_lScreenHeight, (nMaxSize>MAX_TEX_HEIGHT) ? MAX_TEX_HEIGHT : nMaxSize);
//M_OGL_ASSERT( glEnable(GL_TEXTURE_2D); ) // don't need ? ! ! !
lYPos = g_lScreenHeight-g_lTextureHeight;
M_OGL_ASSERT( glGenTextures(1, &uiTextureId ); ) // to prevent from destroying an existing texture
M_OGL_ASSERT( glBindTexture(GL_TEXTURE_2D, uiTextureId); )
M_OGL_ASSERT( glCopyTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA/*GL_RGB5_A1*/, 0, (lYPos<0) ? 0 : lYPos, g_lTextureWidth, g_lTextureHeight, 0 ); )
//M_OGL_ASSERT( glCopyTexImage2D( GL_TEXTURE_2D, 0, GL_RGB/*GL_RGB5_A1*/, 0, lYPos, g_lTextureWidth, g_lTextureHeight, 0 ); )
//M_OGL_ASSERT( glGetTexImage( GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, g_aulTmpBuffer ); )
M_OGL_ASSERT( glGetTexImage( GL_TEXTURE_2D, 0, GL_RGB, GL_UNSIGNED_BYTE, g_a3ucTmpBuffer ); )
M_OGL_ASSERT( glDeleteTextures(1, &uiTextureId); )
//vConvertBuffer8888To565_InvY(g_auwBuffer, g_aulTmpBuffer, g_lTextureWidth, g_lTextureHeight, (lYPos<0) ? -lYPos : 0 );
vConvertBuffer888To565_InvY(g_auwBuffer, g_a3ucTmpBuffer, g_lTextureWidth, g_lTextureHeight, (lYPos<0) ? -lYPos : 0 );
g_p_vVirtualScreen = g_auwBuffer;
g_lPitch = g_lTextureWidth*2;
}
void fn_OGLThread_vUnlockDevice(void)
{
GLuint uiTextureId;
//vConvertBuffer565To8888(g_aulTmpBuffer, g_auwBuffer, g_lTextureWidth, g_lTextureHeight);
vConvertBuffer565To888(g_a3ucTmpBuffer, g_auwBuffer, g_lTextureWidth, g_lTextureHeight);
//M_OGL_ASSERT( glEnable(GL_TEXTURE_2D); ) // don't need ? ! ! !
M_OGL_ASSERT( glGenTextures(1, &uiTextureId ); )
M_OGL_ASSERT( glBindTexture(GL_TEXTURE_2D, uiTextureId); )
M_OGL_ASSERT( glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S, GL_CLAMP/*GL_REPEAT*/); )
M_OGL_ASSERT( glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T, GL_CLAMP/*GL_REPEAT*/); )
M_OGL_ASSERT( glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR); )
M_OGL_ASSERT( glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR); )
//M_OGL_ASSERT( glTexImage2D(GL_TEXTURE_2D, 0, 4/*GL_RGB5_A1*/, g_lTextureWidth, g_lTextureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, g_aulTmpBuffer); )
M_OGL_ASSERT( glTexImage2D(GL_TEXTURE_2D, 0, 3/*GL_RGB5_A1*/, g_lTextureWidth, g_lTextureHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, g_a3ucTmpBuffer); )
// display the texture all over the ScreenRect :
M_OGL_ASSERT( glBindTexture(GL_TEXTURE_2D, uiTextureId); )
fn_OGL_vDisplayTexture(g_lScreenWidth, g_lScreenHeight, g_lTextureWidth, g_lTextureHeight);
M_OGL_ASSERT( glDeleteTextures(1, &uiTextureId); )
}
/*
void vCopyBufferToTexture8888(unsigned long* _pulDst, unsigned long* _pulSrc, long _lWDst, long _lHDst, long _lWSrc, long _lHSrc)
{
long lYPos;
if ( (_lWSrc > _lWDst) || (_lHSrc > _lHDst) )
return;
for (lYPos = 0 ; lYPos<_lHSrc ; lYPos++) {
memcpy(_pulDst + lYPos*_lWDst, _pulSrc+lYPos*_lWSrc, _lWSrc*sizeof(unsigned long));
memset(_pulDst + lYPos*_lWDst + _lWSrc, 0, (_lWDst-_lWSrc)*sizeof(unsigned long));
}
//for (lYPos = _lHSrc ; lYPos<_lHDst ; lYPos++)
// memset(_pulDst + lYPos*_lWDst, 0, _lWDst*sizeof(unsigned long));
memset(_pulDst + _lHSrc*_lWDst, 0, (_lHDst-_lHSrc)*_lWDst*sizeof(unsigned long));
}
*/
void vCopyBufferToTexture16b(unsigned short* _pulDst, unsigned short* _pulSrc, long _lWDst, long _lHDst, long _lWSrc, long _lHSrc)
{
long lYPos;
if ( (_lWSrc > _lWDst) || (_lHSrc > _lHDst) )
return;
for (lYPos = 0 ; lYPos<_lHSrc ; lYPos++) {
memcpy(_pulDst + lYPos*_lWDst, _pulSrc+lYPos*_lWSrc, _lWSrc*sizeof(unsigned short));
memset(_pulDst + lYPos*_lWDst + _lWSrc, 0, (_lWDst-_lWSrc)*sizeof(unsigned short));
}
//for (lYPos = _lHSrc ; lYPos<_lHDst ; lYPos++)
// memset(_pulDst + lYPos*_lWDst, 0, _lWDst*sizeof(unsigned short));
memset(_pulDst + _lHSrc*_lWDst, 0, (_lHDst-_lHSrc)*_lWDst*sizeof(unsigned short));
}
void vStretchBufferToTexture8888(unsigned long* _pulDst, unsigned long* _pulSrc, long _lWDst, long _lHDst, long _lWSrc, long _lHSrc)
{
long lXPos, lYPos;
long lXStep, lYStep;
lXStep = 1;
lYStep = 1;
while (_lWSrc > _lWDst) {
lXStep <<= 1; // *2
_lWSrc >>= 1; // /2
}
while (_lHSrc > _lHDst) {
lYStep <<= 1; // *2
_lHSrc >>= 1; // /2
}
for (lYPos = 0 ; lYPos<_lHSrc ; lYPos+=lYStep) {
//memcpy(_pulDst + lYPos*_lWDst, _pulSrc+lYPos*_lWSrc, _lWSrc*sizeof(unsigned long));
for (lXPos = 0 ; lXPos<_lWSrc ; lXPos+=lXStep)
*(_pulDst + lYPos*_lWDst + lXPos) = *(_pulSrc + lYPos*_lWSrc + lXPos);
memset(_pulDst + lYPos*_lWDst + _lWSrc, 0, (_lWDst-_lWSrc)*sizeof(unsigned long));
}
//for (lYPos = _lHSrc ; lYPos<_lHDst ; lYPos++)
// memset(_pulDst + lYPos*_lWDst, 0, _lWDst*sizeof(unsigned long));
memset(_pulDst + _lHSrc*_lWDst, 0, (_lHDst-_lHSrc)*_lWDst*sizeof(unsigned long));
}
extern void *g_p_vSourceBuffer;
extern RECT g_DestBitmapRect;
void fn_OGLThread_vWrite16bBitmapToBackBuffer(long _lWidth, long _lHeight)
{
GLint nMaxSize;
long lTextureWidth, lTextureHeight;
GLuint uiTextureId;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &nMaxSize);
lTextureWidth = fn_lSmallestPowerOfTwoGreaterThan(_lWidth, (nMaxSize>MAX_TEX_WIDTH) ? MAX_TEX_WIDTH : nMaxSize);
lTextureHeight = fn_lSmallestPowerOfTwoGreaterThan(_lHeight, (nMaxSize>MAX_TEX_HEIGHT) ? MAX_TEX_HEIGHT : nMaxSize);
vCopyBufferToTexture16b(g_auwBuffer, (unsigned short*)g_p_vSourceBuffer, lTextureWidth, lTextureHeight, _lWidth, _lHeight);
//vConvertBuffer565To8888(g_aulTmpBuffer, g_auwBuffer, lTextureWidth, lTextureHeight);
vConvertBuffer565To888(g_a3ucTmpBuffer, g_auwBuffer, lTextureWidth, lTextureHeight);
//M_OGL_ASSERT( glEnable(GL_TEXTURE_2D); ) // don't need ? ! ! !
M_OGL_ASSERT( glGenTextures(1, &uiTextureId ); )
M_OGL_ASSERT( glBindTexture(GL_TEXTURE_2D, uiTextureId); )
M_OGL_ASSERT( glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S, GL_CLAMP/*GL_REPEAT*/); )
M_OGL_ASSERT( glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T, GL_CLAMP/*GL_REPEAT*/); )
M_OGL_ASSERT( glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR); )
M_OGL_ASSERT( glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR); )
//M_OGL_ASSERT( glTexImage2D(GL_TEXTURE_2D, 0, 4, lTextureWidth, lTextureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, g_aulTmpBuffer); )
M_OGL_ASSERT( glTexImage2D(GL_TEXTURE_2D, 0, 3, lTextureWidth, lTextureHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, g_a3ucTmpBuffer); )
M_OGL_ASSERT( glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); )
// display the texture all over the ScreenRect :
M_OGL_ASSERT( glBindTexture(GL_TEXTURE_2D, uiTextureId); )
//M_OGL_ASSERT( glDisable(GL_CULL_FACE); )
fn_OGL_vDisplayTextureWithCoord(_lWidth, _lHeight, lTextureWidth, lTextureHeight, g_DestBitmapRect.left, g_DestBitmapRect.top, g_DestBitmapRect.right, g_DestBitmapRect.bottom);
//fn_OGL_vDisplayTexture(_lWidth, _lHeight, lTextureWidth, lTextureHeight);
M_OGL_ASSERT( glDeleteTextures(1, &uiTextureId); )
}

View File

@@ -0,0 +1,399 @@
/*
=======================================================================================
Name : OGL_Thread.c
Author : Bart
Description :
=======================================================================================
*/
/*
=======================================================================================
Include
=======================================================================================
*/
#include <windows.h>
#include <gl/gl.h>
#include "OGL_Options.h"
#include "OGL_Errors.h"
#include "OGL_Thread.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#ifdef __cplusplus
extern "C"
{
#endif
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
// opengl thread
HANDLE g_h_OpenGLThread;
DWORD g_xThreadId;
#define M_h_GetOpenGLThread() (g_h_OpenGLThread)
#define M_v_SetOpenGLThread(_hThread) {g_h_OpenGLThread = _hThread;}
#define M_x_GetOpenGLThreadId() (g_xThreadId)
//events
#define C_sz_ThreadCreationEvtName "CREATETHREADEVT"
HANDLE hEvent_ThreadCreation = NULL; //, hEvent_ThreadCreation2;
#define C_sz_WaitingForBooleanEvtName "WAIT4BOOLEVT"
HANDLE hEvent_WaitingForBoolean = NULL; //, hEvent_WaitingForBoolean2;
#define C_sz_JustWaiting "JUSTWAIT"
HANDLE hEvent_WaitForSynchro = NULL; //, hEvent_Wait2;
/*
//mutexes
#define C_sz_CounterMutexName "FIFOCOUNT"
HANDLE hMutex_FIFOCount = NULL;
*/
/*
// FIFO
#define FIFO_MEM_SIZE 10
long* g_plFIFOStartPointer = NULL;
long g_lFIFOCurrentOffset;
long g_lFIFOCount;
#define M_GetParam(offset) g_plFIFOStartPointer[(offset)%FIFO_MEM_SIZE]
*/
/***** Called Functions *****/
#include "OGL_Func.c"
/*
long fn_lMallocNLong(int _nSize)
{
long lRet;
WaitForSingleObject( hMutex_FIFOCount, INFINITE ); //blocking on the mutex
if (g_lFIFOCount+_nSize > FIFO_MEM_SIZE) { // >= oder > ?
M_OUTPUT("Overflow\n");
ReleaseMutex( hMutex_FIFOCount );
OGLThread_fn_vWaitForSynchro();
WaitForSingleObject(hMutex_FIFOCount, INFINITE);
assert(g_lFIFOCount == 0);
}
assert (g_lFIFOCount >= 0);
g_lFIFOCount += _nSize;
lRet = g_lFIFOCurrentOffset;
g_lFIFOCurrentOffset = (g_lFIFOCurrentOffset + _nSize) % FIFO_MEM_SIZE;
ReleaseMutex( hMutex_FIFOCount );
return lRet;
}
void fn_vFreeNLong(int _nSize)
{
WaitForSingleObject( hMutex_FIFOCount, INFINITE );
g_lFIFOCount -= _nSize;
assert (g_lFIFOCount >= 0);
ReleaseMutex( hMutex_FIFOCount );
}
*/
/***** Treat Message *****/
BOOL fn_b_OpenGLThreadTreatMessage(UINT _message, WPARAM _wParam, LPARAM _lParam)
{
GLboolean bResidence; // for glAreTexturesResident
long* pParam = (long*)_wParam;
switch (_message)
{
case OGLT0_WAIT :
SetEvent(hEvent_WaitForSynchro);
break;
case OGLT0_CREATE :
fn_OGLThread_vCreate();
break;
case OGLT0_RESUME :
fn_OGLThread_vResume();
break;
case OGLT0_SWAP :
fn_OGLThread_vSwap();
break;
case OGLT0_INITFLAGS :
fn_OGLThread_vInitOglFlags();
break;
case OGLT0_FLUSH :
M_OGL_ASSERT( glFinish (); )
M_OGL_ASSERT( glFlush(); )
break;
case OGLT0_ALPHATEST :
M_OGL_ASSERT( glAlphaFunc( GL_GREATER, 0.5f ); )
break;
case OGLT0_LOCKDEVICE :
fn_OGLThread_vLockDevice();
break;
case OGLT0_UNLOCKDEVICE :
fn_OGLThread_vUnlockDevice();
break;
case OGLT0_BLACKPOLY :
fn_OGLThread_vSendBlackPolygon();
break;
case OGLT0_FOGPARAM :
fn_OGLThread_vSetFogParams();
break;
/* 1Long */
case OGLT1_ENABLE :
M_OGL_ASSERT( glEnable( (GLenum)_wParam ); )
break;
case OGLT1_DISABLE :
M_OGL_ASSERT( glDisable( (GLenum)_wParam ); )
break;
case OGLT1_DEPTHMASK :
M_OGL_ASSERT( glDepthMask( (GLboolean)_wParam ); )
break;
case OGLT1_DELETETEXTURE :
M_OGL_ASSERT( glDeleteTextures(1, (GLuint*) &_wParam ); )
break;
case OGLT1_BINDTEXTURE :
M_OGL_ASSERT( glBindTexture(GL_TEXTURE_2D, (GLuint) _wParam ); )
break;
case OGLT1_TEXTUREENV :
M_OGL_ASSERT( glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, (GLuint) _wParam ); )
break;
case OGLT1_RENDER :
fn_OGLThread_vRender((GLI_tdScreenVertx*) _wParam );
break;
case OGLT1_LOADTEXTURES :
fn_OGLThread_vLoadTextures((GLI_tdstTexture*) _wParam );
break;
/* 2Long */
case OGLT2_PIXELTRANSFER :
M_OGL_ASSERT( glPixelTransferi( (GLenum)_wParam, (GLint)_lParam ); )
break;
case OGLT2_BLENDFUNC :
M_OGL_ASSERT( glBlendFunc( (GLenum)_wParam, (GLenum)_lParam ); )
break;
case OGLT2_WRITEBITMAP :
fn_OGLThread_vWrite16bBitmapToBackBuffer(_wParam, _lParam );
break;
case OGLT2_CLEARDEVICE :
fn_OGLThread_vClearDevice((_wParam & 2), (_wParam & 1), (unsigned long) _lParam);
break;
/* 3Long */
/* case OGLT3_CLEARDEVICE :
fn_OGLThread_vClearDevice((BOOL) M_GetParam(_wParam+0), (BOOL) M_GetParam(_wParam+1), (unsigned long) M_GetParam(_wParam+2));
fn_vFreeNLong(3);
break;
*/
/* return boolean value */
case OGLT1_ISTEXTURE :
M_OGL_ASSERT( pParam[0] = (long)glIsTexture( (GLuint)pParam[1] ); )
SetEvent(hEvent_WaitingForBoolean);
break;
case OGLT1_ISENABLED :
M_OGL_ASSERT( pParam[0] = (long)glIsEnabled( (GLenum)pParam[1] ); )
SetEvent(hEvent_WaitingForBoolean);
break;
case OGLT1_ISRESIDENT :
M_OGL_ASSERT( pParam[0] = (long)glAreTexturesResident( 1, (GLuint*) &pParam[1], &bResidence ); )
SetEvent(hEvent_WaitingForBoolean);
break;
default : // OGLT0_EXIT or else ?
return FALSE;
}
return TRUE;
}
/***** Thread Loop *****/
DWORD WINAPI fn_x_OpenGLThreadEntryPoint(LPVOID _p_vParameter)
{
MSG stMsg;
BOOL bNoExit;
_p_vParameter = _p_vParameter;
PeekMessage(&stMsg, NULL, WM_USER, WM_USER, PM_NOREMOVE); // to force the system to create the message queue
SetEvent(hEvent_ThreadCreation);
// message loop
while (bNoExit)
{
GetMessage(&stMsg, NULL, WM_USER, WM_USER + OGLT0_NB_MSG_MAX);
assert(stMsg.message >= WM_USER);
assert(stMsg.message <= WM_USER + OGLT0_NB_MSG_MAX);
bNoExit = fn_b_OpenGLThreadTreatMessage( stMsg.message - WM_USER, stMsg.wParam, stMsg.lParam );
}
return 0;
}
/***** Calling Functions *****/
#define M_v_RequestToOpenGLThread(_uiMessage, _WParam, _LParam)\
{\
/*PostThreadMessage(M_x_GetOpenGLThreadId(), WM_USER+_uiMessage, (WPARAM)0, (LPARAM)_Param);*/\
PostThreadMessage(M_x_GetOpenGLThreadId(), WM_USER+_uiMessage, (WPARAM)_WParam, (LPARAM)_LParam);\
}
void OGLThread_fn_vPostCmd(int _nCommandId)
{
M_v_RequestToOpenGLThread(_nCommandId, 0, 0);
}
void OGLThread_fn_vPostCmd_1Long(int _nCommandId, long _lParam1)
{
M_v_RequestToOpenGLThread(_nCommandId, _lParam1, 0);
}
void OGLThread_fn_vPostCmd_2Long(int _nCommandId, long _lParam1, long _lParam2)
{
M_v_RequestToOpenGLThread(_nCommandId, _lParam1, _lParam2);
}
/*
void OGLThread_fn_vPostCmd_3Long(int _nCommandId, long _lParam1, long _lParam2, long _lParam3)
{
long lParam;
lParam = fn_lMallocNLong(3);
M_GetParam(lParam+0) = _lParam1;
M_GetParam(lParam+1) = _lParam2;
M_GetParam(lParam+2) = _lParam3;
M_v_RequestToOpenGLThread(_nCommandId, lParam, 0);
}
*/
/* send command to thread then wait for the returning boolean value */
BOOL OGLThread_fn_bPostCmdAndWait(int _nCommandId, long _lParam1)
{
long pParam[2];
pParam[1] = _lParam1;
M_v_RequestToOpenGLThread(_nCommandId, pParam, 0);
WaitForSingleObject(hEvent_WaitingForBoolean, INFINITE); // reset event when return
return pParam[0];
}
/***** Create / Resume context *****/
void OGLThread_fn_vCreateContext(BOOL _bReinitDevice)
{
if (_bReinitDevice)
{
/* Create the rendering context and make it current */
OGLThread_fn_vWaitForSynchro();
OGLThread_fn_vPostCmd(OGLT0_CREATE);
}
/* render initialization */
OGLThread_fn_vWaitForSynchro();
OGLThread_fn_vPostCmd(OGLT0_INITFLAGS); //GLI_fn_vInitOglFlags();
OGLThread_fn_vWaitForSynchro();
}
void OGLThread_fn_vResumeContext(BOOL _bReinitDevice)
{
if (!_bReinitDevice)
return;
OGLThread_fn_vWaitForSynchro();
OGLThread_fn_vPostCmd(OGLT0_RESUME);
OGLThread_fn_vWaitForSynchro();
}
/***** create / terminate thread, events & mutexes *****/
void OGLThread_fn_vCreateThread(void)
{
hEvent_ThreadCreation = CreateEvent(NULL, TRUE, FALSE, NULL /*C_sz_ThreadCreationEvtName*/); // create event (nonsignaled state)
M_v_SetOpenGLThread( CreateThread( NULL, 0, fn_x_OpenGLThreadEntryPoint, NULL, 0, &M_x_GetOpenGLThreadId() ) );
SetPriorityClass(M_h_GetOpenGLThread(), HIGH_PRIORITY_CLASS);
WaitForSingleObject(hEvent_ThreadCreation, INFINITE); // wait for the event to be signaled
if (hEvent_ThreadCreation)
CloseHandle(hEvent_ThreadCreation);
hEvent_WaitingForBoolean = CreateEvent(NULL, FALSE, FALSE, C_sz_WaitingForBooleanEvtName); // create event (no manual-reset)
hEvent_WaitForSynchro = CreateEvent(NULL, FALSE, FALSE, C_sz_JustWaiting); // create event (no manual-reset)
/*
hMutex_FIFOCount = CreateMutex(NULL, FALSE, C_sz_CounterMutexName);
g_plFIFOStartPointer = (long*)GLI_MDRV_p_vTmpMalloc(FIFO_MEM_SIZE*sizeof(long));
g_lFIFOCurrentOffset = 0;
g_lFIFOCount = 0;
*/
}
void OGLThread_fn_vTerminateThread()
{
OGLThread_fn_vWaitForSynchro();
if (hEvent_WaitingForBoolean)
CloseHandle(hEvent_WaitingForBoolean); // ?
hEvent_WaitingForBoolean = NULL;
if (hEvent_WaitForSynchro)
CloseHandle(hEvent_WaitForSynchro); // ?
hEvent_WaitForSynchro = NULL;
/*
if (hMutex_FIFOCount)
CloseHandle(hMutex_FIFOCount); // ?
hMutex_FIFOCount = NULL;
if (g_plFIFOStartPointer)
GLI_MDRV_vTmpFree(g_plFIFOStartPointer);
g_plFIFOStartPointer = NULL;
*/
OGLThread_fn_vPostCmd(OGLT0_EXIT);
}
/***** synkronizazion *****/
void OGLThread_fn_vWaitForSynchro()
{
OGLThread_fn_vPostCmd(OGLT0_WAIT);
WaitForSingleObject(hEvent_WaitForSynchro, INFINITE); // wait for the event to be signaled
}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#ifdef __cplusplus
} //extern "C"
#endif
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

View File

@@ -0,0 +1,54 @@
#if defined (ERROR_TEST)
/*
extern GLenum g_oglError;
extern GLenum g_oglPrevError;
extern char g_oglErrorString[255];
extern int g_oglErrorCount;
extern LPVOID g_lpMsgBuf;
*/
extern void fn_vOutputLog(char* ErrorString);
extern void fn_vOglError(char* oglFunc);
extern void fn_vError();
#define M_OUTPUT OutputDebugString
//#define M_OUTPUT fn_vOutputLog
#define M_OGL_ASSERT(oglFunc) \
{\
/*M_OUTPUT(#oglFunc);\
M_OUTPUT("\n");*/\
oglFunc\
fn_vOglError(#oglFunc);\
}
#define M_ASSERT(Func) \
{\
/*M_OUTPUT(#Func);\
M_OUTPUT("\n");*/\
if (!Func)\
{\
fn_vError();\
M_OUTPUT(#Func);\
M_OUTPUT("\n");\
}\
}
#define M_OGL_ASSERT_FAKE(oglFunc) \
{\
/*M_OUTPUT(#oglFunc);\
M_OUTPUT("\n");*/\
oglFunc\
}
//#define M_OGL_ASSERT_FAKE M_OGL_ASSERT
#else // ERROR_TEST
#define M_OGL_ASSERT_FAKE(oglFunc) oglFunc
#define M_OGL_ASSERT(oglFunc) oglFunc
#define M_ASSERT(Func) Func;
#define M_OUTPUT(str)
#endif // ERROR_TEST

View File

@@ -0,0 +1,62 @@
/* Testing Errors */
//#define OGL_VER2_2 // OpenGL version 2.2
#if defined (_DEBUG)
#define ERROR_TEST
#endif
//#define OPENGL_3DFX
#if defined (OPENGL_3DFX)
#define WORKAROUNDBUG //Work around bug in mini drivers
#endif //defined (OPENGL_3DFX)
/* Perspective */
//#define Z_BUFFER // if not defined => W_BUFFER
#define PERSP_CORRECTION
#if !defined (Z_BUFFER)
//#define ACCURATE_DEPTH_BUFFER // if defined in Rayman2 => nothing drawn in the "second viewport"
#endif
/* Texture test (fail if not in video memory) */
#if defined (_DEBUG)
//#define TEX_TEST
#endif
/* MIPMAP */
#if !defined (OGL_VER2_2)
#define MIPMAP_DOWN_TO_1x1
#endif
//#define REINIT_DEVICE_ONSIZE
//#define IGNORE_TEXTUREWRAP // to keep TexParameters GL_TEXTURE_WRAP_S & GL_TEXTURE_WRAP_T to GL_REPEAT value (because rastering GL_CLAMP'ed textures costs a lot !)
//#define NO_MIPMAP_FOR_TRANSPARENT_TEX // bug on the ATI RAGE PRO harware rasterization pipe : bilinear filtering is very ugly on transparent textures, so it looks better without Mipmaping these textures (on the software rasterization pipe, it is ok)
#define NO_FOG
/* window creation */
//#define USE_DEVMODE
//#define USE_DDRAW
#if defined (USE_DDRAW)
#define FULL_SCREEN
#endif //USE_DDRAW
#define SIZABLE
/* locking backbuffer*/
#define INVERT_Y
#define USE_ALPHA

View File

@@ -0,0 +1,139 @@
/*
=======================================================================================
Name : OGL_Thread.h
Author : Bart
Description :
=======================================================================================
*/
/*
=======================================================================================
Include
=======================================================================================
*/
/* 1->13 : no param */
#define OGLT0_CREATE 1
#define OGLT0_RESUME 2
#define OGLT0_SWAP 3
//#define OGLT0_RENDER 4
//#define OGLT0_LOADTEXTURES 5
#define OGLT0_INITFLAGS 6
#define OGLT0_FLUSH 7
#define OGLT0_ALPHATEST 8
#define OGLT0_LOCKDEVICE 9
#define OGLT0_UNLOCKDEVICE 10
#define OGLT0_BLACKPOLY 11
#define OGLT0_WAIT 12
#define OGLT0_FOGPARAM 13
/* 31->38 : 1 param */
#define OGLT1_ENABLE 31
#define OGLT1_DISABLE 32
#define OGLT1_DEPTHMASK 33
#define OGLT1_DELETETEXTURE 34
#define OGLT1_BINDTEXTURE 35
#define OGLT1_TEXTUREENV 36
#define OGLT1_RENDER 37
#define OGLT1_LOADTEXTURES 38
/* 51->54 : 2 params */
#define OGLT2_PIXELTRANSFER 51
#define OGLT2_BLENDFUNC 52
#define OGLT2_WRITEBITMAP 53
#define OGLT2_CLEARDEVICE 54
/* 71->71 : 3 params */
//#define OGLT3_CLEARDEVICE 71
/* 81->83 : 1 param + 1 returned (boolean) value */
#define OGLT1_ISTEXTURE 81
#define OGLT1_ISENABLED 82
#define OGLT1_ISRESIDENT 83
/* 98->99 : specific */
#define OGLT0_EXIT 98
#define OGLT0_NB_MSG_MAX 99
/* Post OGL Commands in the thread message queue */
void OGLThread_fn_vPostCmd(int _CommandId);
void OGLThread_fn_vPostCmd_1Long(int _nCommandId, long _lParam1);
void OGLThread_fn_vPostCmd_2Long(int _nCommandId, long _lParam1, long _lParam2);
//void OGLThread_fn_vPostCmd_3Long(int _nCommandId, long _lParam1, long _lParam2, long _lParam3);
BOOL OGLThread_fn_bPostCmdAndWait(int _nCommandId, long _lParam1);
void OGLThread_fn_vCreateThread(void);
void OGLThread_fn_vTerminateThread();
void OGLThread_fn_vCreateContext(BOOL _bReinitDevice);
void OGLThread_fn_vResumeContext(BOOL _bReinitDevice);
void OGLThread_fn_vWaitForSynchro();
/* from OGL_Acces.c */
#if defined (Z_BUFFER)
//#define M_glVertex(x, y, w) glVertex4f( x, y, 1.0f/w, 1.0f )
#if defined (PERSP_CORRECTION)
#define M_glVertex(x, y, w) glVertex4f( x/w, y/w, 1.0f/(w*w), 1.0f/w )
#else
#define M_glVertex(x, y, w) glVertex4f( x, y, 1.0f/w, 1.0f )
#endif
#else // W_BUFFER
//#define M_glVertex(x, y, w) glVertex4f( x, y, 1.0f, w )
#if defined (PERSP_CORRECTION)
#define M_glVertex(x, y, w) glVertex4f( x/w, y/w, 1.0f, 1.0f/w )
#else
#define M_glVertex(x, y, w) glVertex4f( x, y, w, 1.0f )
#endif
#endif
/*
=======================================================================================
Vertex Access Macros
=======================================================================================
*/
// GET
#define GetX(a) a.sx
#define GetY(a) a.sy
#define GetZ(a) a.sz //a.rhw
#define GetPackedColor(a) a.color
#define GetPackedSpecular(a) a.specular
#define GetU(a) a.tu
#define GetV(a) a.tv
// SET
#define SetX(a,b) a.sx = b
#define SetY(a,b) a.sy = b
#define SetZ(a,b) a.sz = b //a.rhw
#define SetPackedColor(a,b) a.color = b
#define SetPackedSpecular(a,b) a.specular = b
#define SetU(a,b) a.tu = b
#define SetV(a,b) a.tv = b
#define SetU_Cpy(a,b) a.tu = b
#define SetV_Cpy(a,b) a.tv = b
typedef struct _GLI_tdScreenVertx {
float sx;
float sy;
float sz;
//float rhw;
unsigned long color;
unsigned long specular;
float tu;
float tv;
} GLI_tdScreenVertx;
/* end of OGL_Acces.c */

View File

@@ -0,0 +1,9 @@
SCC = This is a Source Code Control file
[OpenGL.dsp]
SCC_Aux_Path = "\\srvprojets-ma\Rayman4_DS\Versions\Rayman4DS\Tools"
SCC_Project_Name = "$/CPA/tempgrp/GliGlou/Drivers/OpenGL", SGMAAAAA
[OpenGL.mak]
SCC_Aux_Path = "\\srvprojets-ma\Rayman4_DS\Versions\Rayman4DS\Tools"
SCC_Project_Name = "$/CPA/tempgrp/GliGlou/Drivers/OpenGL", SGMAAAAA