Add rayman2 source files
This commit is contained in:
162
Rayman_X/cpa/tempgrp/GliGlou/Drivers/SGL2/Acces_SGL2.c
Normal file
162
Rayman_X/cpa/tempgrp/GliGlou/Drivers/SGL2/Acces_SGL2.c
Normal file
@@ -0,0 +1,162 @@
|
||||
// GET
|
||||
#define GetX(a) a.fX
|
||||
#define GetY(a) a.fY
|
||||
#define GetZ(a) a.fInvW
|
||||
#define GetPackedColor(a) a.u32Colour
|
||||
#define GetU(a) a.fUOverW
|
||||
#define GetV(a) a.fVOverW
|
||||
// SET
|
||||
#define SetX(a,b) a.fX = b
|
||||
#define SetY(a,b) a.fY = b
|
||||
#define SetZ(a,b) a.fInvW = b
|
||||
#define SetPackedColor(a,b) a.u32Colour = b
|
||||
#define SetPackedSpecular(a,b) a.u32Specular = b
|
||||
#define SetU(a,b) a.fUOverW = b
|
||||
#define SetV(a,b) a.fVOverW = b
|
||||
#define SetU_Cpy(a,b) *(unsigned long *)&a.fUOverW = *(unsigned long *)&b
|
||||
#define SetV_Cpy(a,b) *(unsigned long *)&a.fVOverW = *(unsigned long *)&b
|
||||
|
||||
// Fond de roulement SGL2
|
||||
#define GLI_C_SGL2lMaxTriBuffer 512
|
||||
#define GLI_C_SGL2lMaxVertBuffer GLI_C_SGL2lMaxTriBuffer * 3L
|
||||
long GLI_glActualSizeOfVertex;
|
||||
#define GLI_tdScreenVertx SGLVERTEX
|
||||
SGLVERTEX aDEFCurrentDestXYZ[GLI_C_SGL2lMaxVertBuffer];
|
||||
SGLVERTEX *CurrentDestXYZ;
|
||||
extern SGLCONTEXT SGLContext;
|
||||
extern SGLCONTEXT2 SGLContext2;
|
||||
|
||||
#define GLI_M_RestoreCW()
|
||||
|
||||
void GLI_BeforeDraw()
|
||||
{
|
||||
CurrentDestXYZ = aDEFCurrentDestXYZ;
|
||||
GLI_glActualSizeOfVertex = 0;
|
||||
};
|
||||
|
||||
void GLI_AfterDraw()
|
||||
{
|
||||
CurrentDestXYZ = aDEFCurrentDestXYZ;
|
||||
if (GLI_glActualSizeOfVertex != 0)
|
||||
sgltri_triangles(&SGLContext , GLI_glActualSizeOfVertex , NULL , CurrentDestXYZ);
|
||||
GLI_glActualSizeOfVertex = 0;
|
||||
}
|
||||
|
||||
void GLI_DrawQuad(void)
|
||||
{
|
||||
/* add 2 triangles */
|
||||
CurrentDestXYZ[5] = CurrentDestXYZ[3];
|
||||
CurrentDestXYZ[4] = CurrentDestXYZ[2];
|
||||
CurrentDestXYZ[3] = CurrentDestXYZ[0];
|
||||
if (GLI_glActualSizeOfVertex > GLI_C_SGL2lMaxTriBuffer - 4)
|
||||
{
|
||||
CurrentDestXYZ = aDEFCurrentDestXYZ;
|
||||
sgltri_triangles(&SGLContext , GLI_glActualSizeOfVertex + 2, NULL , CurrentDestXYZ);
|
||||
GLI_glActualSizeOfVertex = 0;
|
||||
} else
|
||||
{
|
||||
CurrentDestXYZ += 6;
|
||||
GLI_glActualSizeOfVertex+=2;
|
||||
}
|
||||
}
|
||||
|
||||
// Draw
|
||||
GLI_FuncNodeBegin(GLI_vDrawTriangle)
|
||||
{
|
||||
/* draw */
|
||||
if (GLI_glActualSizeOfVertex > GLI_C_SGL2lMaxTriBuffer - 4)
|
||||
{
|
||||
CurrentDestXYZ = aDEFCurrentDestXYZ;
|
||||
sgltri_triangles(&SGLContext , GLI_glActualSizeOfVertex + 1, NULL , CurrentDestXYZ);
|
||||
GLI_glActualSizeOfVertex = 0;
|
||||
} else
|
||||
{
|
||||
CurrentDestXYZ += 3;
|
||||
GLI_glActualSizeOfVertex++;
|
||||
}
|
||||
}
|
||||
|
||||
void GLI_vDrawZSortedTriangle(void *p_3Point)
|
||||
{
|
||||
}
|
||||
void GLI_vDrawZSortedQuad(void *p_3Point)
|
||||
{
|
||||
}
|
||||
|
||||
void GLI_vAddDrawFunc()
|
||||
{
|
||||
GLI_M_AddFunc(GLI_vDrawTriangle);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// GLI_BIG_GLOBALS -> lClippingModeMask
|
||||
void GLI_ReComputeClippingMask()
|
||||
{
|
||||
*(float *)&fX_CMP_Optimize = 640.0f;
|
||||
*(float *)&fY_CMP_Optimize = 480.0f;
|
||||
*(float *)&fXMin_CLIP_Optimize = 100.0f;
|
||||
*(float *)&fYMin_CLIP_Optimize = 50.0f;
|
||||
*(float *)&fXMax_CLIP_Optimize = 540.0f;
|
||||
*(float *)&fYMax_CLIP_Optimize = 430.0f;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//********************************************************************************************
|
||||
// Name: GLI_DRV_vSendSpriteToClip
|
||||
// Goal: draw a sprite
|
||||
// Code: Philippe Vimont
|
||||
// OPTIMMIZED : No
|
||||
//********************************************************************************************
|
||||
|
||||
void GLI_DRV_vSendSpriteToClip
|
||||
(
|
||||
GLI_tdstAligned2DVector *a4_st2DVertex ,
|
||||
MTH_tdxReal xZ ,
|
||||
GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT)
|
||||
{
|
||||
GLI_BeforeDraw();
|
||||
GLI_M_InitSprite();
|
||||
SetU(CurrentDestXYZ[0],0.0f);
|
||||
SetV(CurrentDestXYZ[0],1.0f);
|
||||
SetU(CurrentDestXYZ[1],1.0f);
|
||||
SetV(CurrentDestXYZ[1],1.0f);
|
||||
SetU(CurrentDestXYZ[2],1.0f);
|
||||
SetV(CurrentDestXYZ[2],0.0f);
|
||||
SetU(CurrentDestXYZ[3],0.0f);
|
||||
SetV(CurrentDestXYZ[3],0.0f);
|
||||
GLI_DrawQuad();
|
||||
GLI_AfterDraw();
|
||||
}
|
||||
|
||||
//********************************************************************************************
|
||||
// Name: GLI_DRV_vSendSpriteToClipWithUV 1.0
|
||||
// Goal:
|
||||
// Code: Philippe Vimont / 1.0
|
||||
// REM:
|
||||
// OPTIMMIZED : No
|
||||
//********************************************************************************************
|
||||
void GLI_DRV_vSendSpriteToClipWithUV
|
||||
(
|
||||
GLI_tdstAligned2DVector *a4_st2DVertex ,
|
||||
MTH_tdxReal *a8_stUVVertex,
|
||||
MTH_tdxReal xZ ,
|
||||
GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT)
|
||||
{
|
||||
GLI_BeforeDraw();
|
||||
GLI_M_InitSprite();
|
||||
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();
|
||||
}
|
||||
|
336
Rayman_X/cpa/tempgrp/GliGlou/Drivers/SGL2/Domat_SGL2.c
Normal file
336
Rayman_X/cpa/tempgrp/GliGlou/Drivers/SGL2/Domat_SGL2.c
Normal file
@@ -0,0 +1,336 @@
|
||||
/******************************************************************************************
|
||||
FILE : CLIPDomat.C
|
||||
|
||||
VERS : 1.00 \ Marc Villemain - version directX5
|
||||
0.00 \ Philippe Vimont
|
||||
|
||||
DATE : 15.05.97
|
||||
Select materials
|
||||
|
||||
*******************************************************************************************/
|
||||
#include <SGL2.h>
|
||||
#include "Gli_st.h"
|
||||
#include "GLI_Defn.h"
|
||||
#include "polygon.h"
|
||||
#include "mater_st.h"
|
||||
#include "light_st.h"
|
||||
#include "PvObj_st.h"
|
||||
#include "ScrVert.h"
|
||||
#include "Liste.h"
|
||||
#include "SelecTex.h"
|
||||
#include "watrplan.h"
|
||||
#include "proj.h"
|
||||
#include "vpt3D.h"
|
||||
#include "camera.h"
|
||||
#include "material.h"
|
||||
#include "texture.h"
|
||||
#include "GLI_interface.h"
|
||||
#include "GliBench.h"
|
||||
|
||||
extern SGLCONTEXT SGLContext;
|
||||
extern SGLCONTEXT2 SGLContext2;
|
||||
extern SGLVERTEX aDEFCurrentDestXYZ[];
|
||||
extern SGLVERTEX *CurrentDestXYZ;
|
||||
extern sgl_intermediate_map SGL2_IM_sPecialtexture;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
#ifdef ZARMA
|
||||
}
|
||||
#endif
|
||||
//extern long GLD_RenderingCounter;
|
||||
|
||||
extern int stSpecialTexture;
|
||||
|
||||
//********************************************************************************************
|
||||
// Name: GLI_vDoTextureSelection
|
||||
// Goal:
|
||||
// Code: Philippe Vimont
|
||||
// OPTIMMIZED : No
|
||||
//********************************************************************************************
|
||||
//KMSURFACEDESC stSpecialTexture;
|
||||
short VignetteBuffer[1024L * 1024L];
|
||||
|
||||
#define SGL2_ChangeRenderingParrametter(a,b,c)\
|
||||
{\
|
||||
if (SGLContext.a != b)\
|
||||
{\
|
||||
SGLContext.a = b;\
|
||||
SGLContext.u32Flags |= c;\
|
||||
}\
|
||||
}\
|
||||
|
||||
// if (SGLContext2.a != b)
|
||||
#define SGL2_ChangeRenderingParrametterC2(a,b,c)\
|
||||
{\
|
||||
{\
|
||||
SGLContext.u32Flags |= SGLTT_DIRECT_EXTENSIONS;\
|
||||
SGLContext2.a = b;\
|
||||
SGLContext2.u32Flags |= c;\
|
||||
}\
|
||||
}\
|
||||
|
||||
|
||||
void GLI_BigInitSGL2Rendering(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT)
|
||||
{
|
||||
SGLContext2.u32Flags = 0;
|
||||
SGLContext2.n32DeviceName = 0;
|
||||
SGLContext2.u32BlendCntl = 0;
|
||||
SGLContext2.eDepthCntl = sgl_zcomp_lessequal;
|
||||
SGLContext2.fShadowScaling = 0.0f;
|
||||
SGLContext2.fVertexFogR = 1.0f;
|
||||
SGLContext2.fVertexFogG = 1.0f;
|
||||
SGLContext2.fVertexFogB = 1.0f;
|
||||
SGLContext.pSGLContext2 = &SGLContext2;
|
||||
SGLContext.bFogOn = FALSE;
|
||||
SGLContext.bCullBackfacing = FALSE;
|
||||
SGLContext.bDoClipping = TRUE;
|
||||
SGLContext.cBackgroundColour[0] = 0.0f;
|
||||
SGLContext.cBackgroundColour[1] = 0.0f;
|
||||
SGLContext.cBackgroundColour[2] = 0.0f;
|
||||
SGLContext.eShadowLightVolMode = NO_SHADOWS_OR_LIGHTVOLS;
|
||||
SGLContext.bFlipU = FALSE;
|
||||
SGLContext.bFlipV = FALSE;
|
||||
SGLContext.bDoUVTimesInvW = TRUE;
|
||||
SGLContext.RenderRegions = 0;
|
||||
SGLContext.n32MipmapOffset = -1;
|
||||
SGLContext.u32GlobalTrans = 0x000000;
|
||||
SGLContext.eFilterType = sgl_tf_bilinear;
|
||||
SGLContext.u32Flags = SGLTT_TEXTURE | SGLTT_GOURAUD | SGLTT_DIRECT_EXTENSIONS;
|
||||
SGL2_ChangeRenderingParrametterC2(eTextureBlend,sgl_stb_texascale,SGLTT2_TEXTUREBLEND);
|
||||
}
|
||||
|
||||
void GLI_INTERFACE_FUNC(GLI_vDoTextureSelection)(GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT)
|
||||
{
|
||||
static bFirst = 1;
|
||||
|
||||
if (*GLD_p_lRenderingCounter != p_stGlobaleMT->GLD_RenderingCounter)
|
||||
{
|
||||
p_stGlobaleMT->GLD_RenderingCounter = *GLD_p_lRenderingCounter;
|
||||
}
|
||||
if (bFirst)
|
||||
{
|
||||
GLI_BigInitSGL2Rendering(p_stGlobaleMT);
|
||||
}
|
||||
bFirst = 0;
|
||||
SGLContext.u32Flags = SGLTT_DIRECT_EXTENSIONS;
|
||||
SGLContext2.u32Flags = 0;
|
||||
|
||||
if (GLI_BIG_GLOBALS->xFogIsOn)
|
||||
{
|
||||
// FOG ON
|
||||
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;
|
||||
}
|
||||
SGLContext.bFogOn = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
// FOG OFF
|
||||
SGLContext.bFogOn = FALSE;
|
||||
}
|
||||
|
||||
|
||||
if (p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lIsTestingBackface)
|
||||
{
|
||||
if (p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lNotInvertBackfaces)
|
||||
{
|
||||
// Backface Clock wize
|
||||
}
|
||||
else
|
||||
{
|
||||
// Backface CCW
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//no backface
|
||||
}
|
||||
|
||||
/* if (GLI_BIG_GLOBALS->lAMirrorIsDetected & 2)
|
||||
{
|
||||
// Use computed texture.
|
||||
}
|
||||
else*/
|
||||
{
|
||||
if ((p_stGlobaleMT -> p_stCurrentTexture != NULL) && (p_stGlobaleMT -> p_stCurrentTexture -> bIsAvailable))
|
||||
{
|
||||
// texture gouraud Rendering ww
|
||||
SGLContext.u32Flags |= SGLTT_TEXTURE | SGLTT_GOURAUD | SGLTT_MIPMAPOFFSET;
|
||||
SGLContext2.u32Flags = 0;
|
||||
SGLContext.nTextureName = *(int *)&p_stGlobaleMT -> p_stCurrentTexture -> p_stSpecParam;
|
||||
if ((!(p_stGlobaleMT->lAMirrorIsDetected & 2)) &&
|
||||
((p_stGlobaleMT -> p_stCurrentTexture -> lTextureCaps & (GLI_C_lAlphaTexture | GLI_C_lNZTexture | GLI_C_lAddTransparencyTexture) )
|
||||
|| ((!(p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lIsNotGrided)) && (p_stGlobaleMT->xGlobalAlpha < 0.98f))))
|
||||
{
|
||||
// Transparent polygone
|
||||
if (p_stGlobaleMT -> p_stCurrentTexture -> lTextureCaps & GLI_C_lAddTransparencyTexture)
|
||||
{
|
||||
// Blendig ADD
|
||||
// SGL2_ChangeRenderingParrametterC2(eTextureBlend,sgl_stb_texascale,SGLTT2_TEXTUREBLEND);
|
||||
SGL2_ChangeRenderingParrametterC2(
|
||||
u32BlendCntl,
|
||||
sgl_blend_cntl(sgl_blend_one,sgl_blend_one,sgl_accum2_notused),
|
||||
SGLTT2_BLENDCNTL);
|
||||
// SGLContext2.u32Flags = SGLTT2_BLENDCNTL | SGLTT2_TEXTUREBLEND;
|
||||
} else {
|
||||
// Blending texture alpha
|
||||
SGL2_ChangeRenderingParrametterC2(
|
||||
u32BlendCntl,
|
||||
sgl_blend_cntl(sgl_blend_srca,sgl_blend_invsrca,sgl_accum2_notused),
|
||||
SGLTT2_BLENDCNTL);
|
||||
}
|
||||
} else
|
||||
{
|
||||
// No blending
|
||||
SGL2_ChangeRenderingParrametterC2(
|
||||
u32BlendCntl,
|
||||
sgl_blend_cntl(sgl_blend_one,sgl_blend_zero,sgl_accum2_notused),
|
||||
SGLTT2_BLENDCNTL);
|
||||
}
|
||||
|
||||
SGLContext2.u32Flags &= 0xffffffff - SGLTT2_CLAMPU - SGLTT2_CLAMPV;
|
||||
switch (p_stGlobaleMT -> p_stCurrentTexture -> ucCylingMode)
|
||||
{
|
||||
case GLI_C_lCylingUV:
|
||||
// No Cycling
|
||||
break;
|
||||
case 0:
|
||||
// Cycling UV
|
||||
SGLContext.u32Flags |= SGLTT_DIRECT_EXTENSIONS;
|
||||
SGLContext2.u32Flags |= SGLTT2_CLAMPU | SGLTT2_CLAMPV;
|
||||
break;
|
||||
case GLI_C_lCylingV:
|
||||
// Cycling V (yes, V , a little mistake)
|
||||
SGLContext.u32Flags |= SGLTT_DIRECT_EXTENSIONS;
|
||||
SGLContext2.u32Flags |= SGLTT2_CLAMPV ;
|
||||
break;
|
||||
case GLI_C_lCylingU:
|
||||
// Cycling U
|
||||
SGLContext.u32Flags |= SGLTT_DIRECT_EXTENSIONS;
|
||||
SGLContext2.u32Flags |= SGLTT2_CLAMPU;
|
||||
break;
|
||||
}
|
||||
} else //*/
|
||||
{
|
||||
// Gouraud rendering
|
||||
SGLContext.u32Flags = SGLTT_GOURAUD /*| SGLTT_DIRECT_EXTENSIONS*/;
|
||||
SGLContext2.u32Flags = 0;
|
||||
}
|
||||
}
|
||||
// This value is ignored if the SGLTT_GLOBALTRANS
|
||||
// flag is not set.
|
||||
if ((!(p_stGlobaleMT -> lCurrentDrawMask & GLI_C_lIsNotGrided)) && (p_stGlobaleMT->xGlobalAlpha < 0.98f))
|
||||
{
|
||||
// Alpha blending
|
||||
SGL2_ChangeRenderingParrametter(u32GlobalTrans,(unsigned long)(p_stGlobaleMT->xGlobalAlpha * 255.0f),SGLTT_GLOBALTRANS);
|
||||
|
||||
} else {
|
||||
// No blending
|
||||
}
|
||||
// SGLContext.u32Flags |= SGLTT_HIGHLIGHT;
|
||||
/* SGLContext.u32Flags |= SGLTT_DIRECT_EXTENSIONS;
|
||||
SGLContext.u32Flags |= SGLTT_VERTEXFOG;
|
||||
SGLContext2.u32Flags |= SGLTT2_VERTEXFOGCOLOUR;
|
||||
SGLContext2.fVertexFogR = 0.0f;
|
||||
SGLContext2.fVertexFogG = 1.0f;
|
||||
SGLContext2.fVertexFogB = 0.0f;*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
extern GLI_tdstInternalGlobalValuesFor3dEngine *GLI_BIG_GLOBALS;
|
||||
extern void GLI_fnSwitchTwiddled(short *p_Texture , long size );
|
||||
|
||||
//extern KMVERTEXBUFFDESC VertexBufferDesc;
|
||||
void GLI_vWaitEndOfRendering();
|
||||
void GLI_vWaitEndOfVertexTransfert();
|
||||
void GLI_vWaitEndOfVSync();
|
||||
short VigDifferences[4];
|
||||
void GLI_DRV_vWrite16bBitmapToBackBuffer( void *_p_vSourceBuffer, long _lWidth, long _lHeight, long _lDestLeft, long _lDestTop, long _lDestRight, long _lDestBottom )
|
||||
{
|
||||
SGLVERTEX gld_CurrentDestXYZ[4];
|
||||
static bFirst = 0;
|
||||
GLI_tdstInternalGlobalValuesFor3dEngine *p_stGlobaleMT;
|
||||
|
||||
p_stGlobaleMT = GLI_BIG_GLOBALS;
|
||||
|
||||
if (!bFirst)
|
||||
{
|
||||
GLI_BigInitSGL2Rendering(p_stGlobaleMT);
|
||||
}
|
||||
bFirst++;
|
||||
|
||||
// if ((bFirst & 0x1F)== 0 ) // == QUADRUPLE SPEED!!
|
||||
{
|
||||
// sgl_intermediate_map SGL2_IM;
|
||||
/* GLI_vWaitEndOfVSync();
|
||||
GLI_vWaitEndOfRendering();*/
|
||||
memset(&SGL2_IM_sPecialtexture , 0 , sizeof (sgl_intermediate_map));
|
||||
GLD_MDRV_vBlitStretched16b( 512,480,VignetteBuffer ,512,_lWidth,_lHeight,_p_vSourceBuffer);
|
||||
SGL2_IM_sPecialtexture . pixels = (void *)VignetteBuffer;
|
||||
GLI_fnSwitchTwiddled(VignetteBuffer , 512 );
|
||||
// sgl_preprocess_texture( sgl_map_rgb_565 , sgl_map_512x512 ,0,0,&SGL2_IM_sPecialtexture ,NULL ,&SGL2_IM);
|
||||
|
||||
sgl_set_texture( stSpecialTexture,FALSE,FALSE,&SGL2_IM_sPecialtexture,NULL);
|
||||
}//*/
|
||||
// GLI_vWaitEndOfVSync();
|
||||
SGLContext.u32Flags |= SGLTT_TEXTURE | SGLTT_GOURAUD;
|
||||
SGLContext2.u32Flags = 0;
|
||||
SGLContext.nTextureName = stSpecialTexture;
|
||||
SGL2_ChangeRenderingParrametterC2(
|
||||
u32BlendCntl,
|
||||
sgl_blend_cntl(sgl_blend_one,sgl_blend_zero,sgl_accum2_notused),
|
||||
SGLTT2_BLENDCNTL);
|
||||
|
||||
// return;
|
||||
/* ------------------------ BEURK ---------------------------------*/
|
||||
/* ------------------------ End BEURK ------------------------------*/
|
||||
gld_CurrentDestXYZ[0] . fX = 0.0f;
|
||||
gld_CurrentDestXYZ[0] . fY = 0.0f;
|
||||
gld_CurrentDestXYZ[1] . fX = 0.0f;
|
||||
gld_CurrentDestXYZ[1] . fY = 480.0f;
|
||||
gld_CurrentDestXYZ[2] . fX = 640.0f;
|
||||
gld_CurrentDestXYZ[2] . fY = 480.0f;
|
||||
gld_CurrentDestXYZ[3] . fX = 640.0f;
|
||||
gld_CurrentDestXYZ[3] . fY = 0.0f;
|
||||
gld_CurrentDestXYZ[0] . fUOverW = 0.0f;
|
||||
gld_CurrentDestXYZ[0] . fVOverW = 0.0f;
|
||||
gld_CurrentDestXYZ[1] . fUOverW = 0.0f;
|
||||
gld_CurrentDestXYZ[1] . fVOverW = 0.9375f;
|
||||
gld_CurrentDestXYZ[2] . fUOverW = 1.0f;
|
||||
gld_CurrentDestXYZ[2] . fVOverW = 0.9375f;
|
||||
gld_CurrentDestXYZ[3] . fUOverW = 1.0f;
|
||||
gld_CurrentDestXYZ[3] . fVOverW = 0.0f;
|
||||
gld_CurrentDestXYZ[0].u32Colour =
|
||||
gld_CurrentDestXYZ[1].u32Colour =
|
||||
gld_CurrentDestXYZ[2].u32Colour =
|
||||
gld_CurrentDestXYZ[3].u32Colour = 0xffffffff;
|
||||
gld_CurrentDestXYZ[0] . fInvW =
|
||||
gld_CurrentDestXYZ[1] . fInvW =
|
||||
gld_CurrentDestXYZ[2] . fInvW =
|
||||
gld_CurrentDestXYZ[3] . fInvW = 0.01f;
|
||||
sgltri_quads ( &SGLContext , 1 , NULL , gld_CurrentDestXYZ );
|
||||
}
|
||||
|
||||
|
||||
void GLI_INTERFACE_FUNC(GLI_vSetFogParams) ( tdstFogParams *_p_stFogParams )
|
||||
{
|
||||
SGL_FOG GLI_SGLFog;
|
||||
|
||||
GLI_SGLFog.w_start = 0.5f * GLI_C_xZClippingNear / _p_stFogParams->xDepthStart;
|
||||
GLI_SGLFog.w_end = 0.5f * GLI_C_xZClippingNear / _p_stFogParams->xDepthEnd;
|
||||
GLI_SGLFog.fog_density = _p_stFogParams->xBlendEnd / 255.0f;
|
||||
SGLContext.fFogR = _p_stFogParams->stColor.xR;
|
||||
SGLContext.fFogG = _p_stFogParams->stColor.xG;
|
||||
SGLContext.fFogB = _p_stFogParams->stColor.xB;
|
||||
|
||||
sgl_linear_fog(&GLI_SGLFog);
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
} //extern "C"
|
||||
#endif
|
248
Rayman_X/cpa/tempgrp/GliGlou/Drivers/SGL2/HdwTx_SG2.c
Normal file
248
Rayman_X/cpa/tempgrp/GliGlou/Drivers/SGL2/HdwTx_SG2.c
Normal file
@@ -0,0 +1,248 @@
|
||||
|
||||
/*
|
||||
Tested with LINT
|
||||
*/
|
||||
|
||||
/**************
|
||||
TEXTURE.C
|
||||
Ver 1.0
|
||||
***************/
|
||||
#include "GLD.h"
|
||||
#include "GEO.h"
|
||||
#include "TEX.h"
|
||||
#include "gli_st.h"
|
||||
#include "textu_st.h"
|
||||
#include "texture.h"
|
||||
#include <string.h>
|
||||
#ifdef SGL2
|
||||
#include <SGL2.h>
|
||||
#endif
|
||||
#include "GLI_interface.h"
|
||||
|
||||
|
||||
unsigned long ulTotalUsedMemory;
|
||||
unsigned long ulAgpUsedMemory;
|
||||
|
||||
static long GLI_gs_lMaxTmuAvailable;
|
||||
|
||||
extern unsigned long GLI_gsCurrentMemoryChannel;
|
||||
extern unsigned long gs_lRGBBitCount;
|
||||
extern long gs_lTreeOfNamesNumberOfLastLetter;
|
||||
extern long gs_lNumberOfTextureToCreate;
|
||||
extern long gs_lLastIdxInDEFTableOfTextures;
|
||||
extern long lNbTextureFormat;
|
||||
extern long lCurrentTextureFormat;
|
||||
|
||||
//extern long gs_aDEFTableOfTextureMemoryChannels[ C_lMaxNumberOfTexture ];
|
||||
extern unsigned char *gs_aCurrentTextures;
|
||||
//extern GLI_tdstTexture *gs_aDEFTableOfTextureAlreadyRead [ C_lMaxNumberOfTexture ];
|
||||
extern unsigned char g_ucGliModuleId;
|
||||
//extern void *GLI_gs_p_ConvertBufferMipMapping;
|
||||
|
||||
short TEXTURETWIDDLED[1024L*1024L];
|
||||
|
||||
static unsigned long GLI_a256FastTwiddledTable[256];
|
||||
|
||||
long GLI_fnLinear2CasseTete(unsigned long lLinear , long lPitch)
|
||||
{
|
||||
unsigned long lreturnvalue = 0;
|
||||
unsigned long CMPX = 1;
|
||||
while (lLinear != 0)
|
||||
{
|
||||
if (lLinear & 128) lreturnvalue += CMPX<<3;
|
||||
if (lLinear & 64) lreturnvalue += lPitch<<3;
|
||||
if (lLinear & 32) lreturnvalue += CMPX<<2;
|
||||
if (lLinear & 16) lreturnvalue += lPitch<<2;
|
||||
if (lLinear & 8) lreturnvalue += CMPX<<1;
|
||||
if (lLinear & 4) lreturnvalue += lPitch<<1;
|
||||
if (lLinear & 2) lreturnvalue += CMPX;
|
||||
if (lLinear & 1) lreturnvalue += lPitch;
|
||||
CMPX<<=4;
|
||||
lPitch<<=4;
|
||||
lLinear >>= 8;
|
||||
}
|
||||
return lreturnvalue;
|
||||
}
|
||||
|
||||
void GLI_InitTwiddlingTable(long largeur)
|
||||
{
|
||||
long i;
|
||||
for (i = 0 ; i < 256 ; i++ )
|
||||
GLI_a256FastTwiddledTable[i] = GLI_fnLinear2CasseTete(i, largeur);
|
||||
}
|
||||
|
||||
void GLI_fnSwitchTwiddled(short *p_Texture , long size )
|
||||
{
|
||||
unsigned long xcounter, SizeXSize , SizeXSizeD8;
|
||||
short *Pdest ;
|
||||
unsigned long *GLI_a256FastTwiddledTableLocal;
|
||||
static long largeur = 0;
|
||||
short *p_TextureLocal,*p_DestLast;
|
||||
Pdest = TEXTURETWIDDLED;
|
||||
if (size != largeur)
|
||||
{
|
||||
GLI_InitTwiddlingTable(size);
|
||||
largeur = size;
|
||||
}
|
||||
SizeXSize = size * size;
|
||||
if (!(SizeXSize & 0xFF))
|
||||
{
|
||||
SizeXSizeD8 = SizeXSize >> 8;
|
||||
for (xcounter = 0 ; xcounter < SizeXSizeD8 ; xcounter ++ )
|
||||
{
|
||||
p_TextureLocal = p_Texture + (GLI_a256FastTwiddledTable[xcounter & 0xFF]<<4);
|
||||
p_TextureLocal += GLI_a256FastTwiddledTable[(xcounter>>8) & 0xFF]<<8;
|
||||
p_DestLast = Pdest + 256;
|
||||
GLI_a256FastTwiddledTableLocal = GLI_a256FastTwiddledTable;
|
||||
while (Pdest < p_DestLast)
|
||||
*(Pdest++)= *(p_TextureLocal + *(GLI_a256FastTwiddledTableLocal++));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
xcounter = SizeXSize ;
|
||||
for ( xcounter = 0 ; xcounter < SizeXSize ; xcounter++ )
|
||||
*(Pdest++)= *(p_Texture +
|
||||
GLI_a256FastTwiddledTable[xcounter & 0xFF] +
|
||||
(GLI_a256FastTwiddledTable[(xcounter>>8) & 0xFF]<<4) +
|
||||
(GLI_a256FastTwiddledTable[(xcounter>>16) & 0xFF]<<8));
|
||||
}
|
||||
memcpy( p_Texture, TEXTURETWIDDLED , SizeXSize<<1);
|
||||
}
|
||||
|
||||
#ifdef SGL2
|
||||
sgl_map_sizes GLI_GetSGL2EnumSize(unsigned long lSize)
|
||||
{
|
||||
switch (lSize)
|
||||
{
|
||||
case 8:return (sgl_map_8x8);
|
||||
case 16:return (sgl_map_16x16);
|
||||
case 32:return (sgl_map_32x32);
|
||||
case 64:return (sgl_map_64x64);
|
||||
case 128:return (sgl_map_128x128);
|
||||
case 256:return (sgl_map_256x256);
|
||||
case 512:return (sgl_map_512x512);
|
||||
case 1024:return (sgl_map_1024x1024);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SGL2
|
||||
void GLI_DRV_vDownLoadTextures(long bRestore, long _lTextureMode, BOOL bReloading )
|
||||
{
|
||||
long lTextureCounter;
|
||||
GLI_tdstTexture *p_stTexture;
|
||||
sgl_mipmap_generation_options MipMapping;
|
||||
long AddValue;
|
||||
sgl_intermediate_map SGL2_IM;
|
||||
memset(&SGL2_IM , 0 , sizeof (sgl_intermediate_map));
|
||||
SGL2_IM . id[0] = 'I';
|
||||
SGL2_IM . id[1] = 'M';
|
||||
SGL2_IM . id[2] = 'A';
|
||||
SGL2_IM . id[3] = 'P';
|
||||
for (lTextureCounter = 0; lTextureCounter < GLI_C_lNBMaxOfTextures ; lTextureCounter ++)
|
||||
if (gs_aDEFTableOfTextureMemoryChannels[lTextureCounter] != GLI_TEXIsUnallocated )
|
||||
{
|
||||
p_stTexture = gs_aDEFTableOfTextureAlreadyRead[lTextureCounter];
|
||||
while (p_stTexture != NULL)
|
||||
{
|
||||
p_stTexture -> bIsAvailable = 0;
|
||||
GLI_MDRV_xLoadTextureInTexelField(p_stTexture, GLI_gs_p_ConvertBufferMipMapping);
|
||||
AddValue = 0;
|
||||
if (p_stTexture ->lNumberOfLod)
|
||||
{
|
||||
AddValue = sgl_map_mipmap_shift;
|
||||
MipMapping = sgl_mipmap_generate_2x2;
|
||||
}
|
||||
else
|
||||
MipMapping = sgl_mipmap_generate_none;
|
||||
if (p_stTexture -> lTextureCaps & GLI_C_lNZTexture)
|
||||
{
|
||||
GLI_vInvertAlphaField(GLI_gs_p_ConvertBufferMipMapping , p_stTexture->lHeight * p_stTexture->lHeight);
|
||||
SGL2_IM . pixels = GLI_gs_p_ConvertBufferMipMapping ;
|
||||
SGL2_IM . y_dim = SGL2_IM . x_dim = p_stTexture->lHeight;
|
||||
*(int *)&p_stTexture -> p_stSpecParam =
|
||||
sgl_create_texture( sgl_map_argb_1555 + AddValue, GLI_GetSGL2EnumSize(p_stTexture->lHeight), MipMapping, FALSE , &SGL2_IM , NULL);
|
||||
} else
|
||||
{
|
||||
if ((p_stTexture -> lTextureCaps & GLI_C_lAlphaTexture) == 0)
|
||||
{
|
||||
SGL2_IM . pixels = GLI_gs_p_ConvertBufferMipMapping ;
|
||||
SGL2_IM . y_dim = SGL2_IM . x_dim = p_stTexture->lHeight;
|
||||
*(int *)&p_stTexture -> p_stSpecParam=
|
||||
sgl_create_texture( sgl_map_rgb_565 + AddValue, GLI_GetSGL2EnumSize(p_stTexture->lHeight), MipMapping, FALSE , &SGL2_IM , NULL);
|
||||
} else
|
||||
{
|
||||
GLI_vInvertAlphaField(GLI_gs_p_ConvertBufferMipMapping , p_stTexture->lHeight * p_stTexture->lHeight);
|
||||
SGL2_IM . pixels = GLI_gs_p_ConvertBufferMipMapping ;
|
||||
SGL2_IM . y_dim = SGL2_IM . x_dim = p_stTexture->lHeight;
|
||||
*(int *)&p_stTexture -> p_stSpecParam=
|
||||
sgl_create_texture( sgl_map_argb_4444 + AddValue, GLI_GetSGL2EnumSize(p_stTexture->lHeight), MipMapping ,FALSE, &SGL2_IM , NULL);
|
||||
}
|
||||
}
|
||||
if (*(int *)&p_stTexture -> p_stSpecParam > 0)
|
||||
{
|
||||
p_stTexture->bIsAvailable = 1 ;
|
||||
}
|
||||
p_stTexture = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
----------------------------------------------------------------------------------------
|
||||
Description : get total memory size available for texture
|
||||
----------------------------------------------------------------------------------------
|
||||
*/
|
||||
long GLI_DRV_lGetHardwareTotalTextureMemorySize(long _lTextureMode)
|
||||
{
|
||||
return (6388608L);
|
||||
}
|
||||
|
||||
//********************************************************************************************
|
||||
// Name: GLI_DRV_lGetHardwareMaxTextureSize() 1.0
|
||||
// OPTIMMIZED : No
|
||||
//********************************************************************************************
|
||||
long GLI_DRV_lGetHardwareMaxTextureSize(void)
|
||||
{
|
||||
return (1024);
|
||||
}
|
||||
|
||||
//********************************************************************************************
|
||||
// Name: GLI_DRV_lIsHardwareAcceptNonSquaredTextures() 1.0
|
||||
// OPTIMMIZED : No
|
||||
//********************************************************************************************
|
||||
long GLI_DRV_lIsHardwareAcceptNonSquaredTextures(void)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
void GLI_DRV_vUnLoadTextures()
|
||||
{
|
||||
long lTextureCounter;
|
||||
|
||||
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)
|
||||
{
|
||||
sgl_delete_texture(*(int *)&p_stTexture -> p_stSpecParam);
|
||||
p_stTexture->bIsAvailable = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
108
Rayman_X/cpa/tempgrp/GliGlou/Drivers/SGL2/Init_SGL2.c
Normal file
108
Rayman_X/cpa/tempgrp/GliGlou/Drivers/SGL2/Init_SGL2.c
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
Tested with LINT
|
||||
*/
|
||||
#include <SGL2.H>
|
||||
#include "init_gli.h"
|
||||
#include "gli_st.h"
|
||||
#include "GLI_Defn.h"
|
||||
#include "light_st.h"
|
||||
#include "PvObj_st.h"
|
||||
#include "GLI_interface.h"
|
||||
|
||||
int Device = 0;
|
||||
SGLCONTEXT SGLContext;
|
||||
SGLCONTEXT2 SGLContext2;
|
||||
int stSpecialTexture;
|
||||
sgl_intermediate_map SGL2_IM_sPecialtexture;
|
||||
|
||||
extern short TEXTURETWIDDLED[];
|
||||
|
||||
extern GLI_tdstInternalGlobalValuesFor3dEngine *GLI_BIG_GLOBALS;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
// Global initialisation.
|
||||
void GLI_DRV_xInitDriver( HWND _hWnd, BOOL _bFullScreen, long _lWidth, long _lHeight, long _lBpp )
|
||||
{
|
||||
memset(&SGL2_IM_sPecialtexture , 0 , sizeof (sgl_intermediate_map));
|
||||
SGL2_IM_sPecialtexture . id[0] = 'I';
|
||||
SGL2_IM_sPecialtexture . id[1] = 'M';
|
||||
SGL2_IM_sPecialtexture . id[2] = 'A';
|
||||
SGL2_IM_sPecialtexture . id[3] = 'P';
|
||||
SGL2_IM_sPecialtexture . pixels = TEXTURETWIDDLED;
|
||||
SGL2_IM_sPecialtexture . y_dim = SGL2_IM_sPecialtexture . x_dim = 512;
|
||||
Device = sgl_create_screen_device (0, 640, 480, sgl_device_16bit, sgl_double_buffer);
|
||||
stSpecialTexture =
|
||||
sgl_create_texture( sgl_map_rgb_565 , sgl_map_512x512 , FALSE , FALSE , &SGL2_IM_sPecialtexture , NULL);
|
||||
}
|
||||
|
||||
// Temporary function.
|
||||
/*
|
||||
long GLI_INTERFACE_FUNC(GLI_DRV_lWhatIsGli)(void)
|
||||
{
|
||||
return GLI_C_VersionGlide;
|
||||
}
|
||||
*/
|
||||
|
||||
void GLI_DRV_vCloseDriver ()
|
||||
{
|
||||
}
|
||||
|
||||
// Return version number.
|
||||
/*
|
||||
long GLI_INTERFACE_FUNC(GLI_lGetNumOfVersion)(void)
|
||||
{
|
||||
return 0;//g_stCurLLInterface.iMode;
|
||||
}
|
||||
*/
|
||||
// Return a pointer on the text version of GLI engine.
|
||||
/*unsigned char *GLI_INTERFACE_FUNC(GLI_ucGetTextOfVersion)(void)
|
||||
{
|
||||
return NULL;//g_stCurLLInterface.ucTextMode;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
// Erase a rectangular region of Z buffer.
|
||||
void GLI_INTERFACE_FUNC(GLI_DRV_vClearZBufferRegion)(long lXStart,long lXEnd,long lYStart,long lYEnd)
|
||||
{
|
||||
if (!bDrawMirrorSymetric)
|
||||
GLI_BIG_GLOBALS->lDisplayMenuIsDetected = 1;
|
||||
}
|
||||
|
||||
void GLI_INTERFACE_FUNC(GLI_vBeginDrawingTexturedMirrors)(void)
|
||||
{
|
||||
GLI_BIG_GLOBALS->bDrawMirrorSymetric = 1;
|
||||
}
|
||||
void GLI_INTERFACE_FUNC(GLI_vBeginDrawingTexturedMirrorsSurfaces)()
|
||||
{
|
||||
GLI_BIG_GLOBALS->lAMirrorIsDetected = 3;
|
||||
}
|
||||
void GLI_INTERFACE_FUNC(GLI_vEndDrawingTexturedMirrors)()
|
||||
{
|
||||
GLI_BIG_GLOBALS->lAMirrorIsDetected &= 1;
|
||||
GLI_BIG_GLOBALS->bDrawMirrorSymetric = 0;
|
||||
}
|
||||
|
||||
//extern long GLI_xIsGliInit();
|
||||
void GLI_INTERFACE_FUNC(GLI_DRV_vFlipDevice)(long lNbFrames)
|
||||
{
|
||||
if (!GLI_MDRV_xIsGliInit())
|
||||
return;
|
||||
|
||||
GLI_BIG_GLOBALS->lDisplayMenuIsDetected = 0;
|
||||
GLI_BIG_GLOBALS->lAMirrorIsDetected = 0;
|
||||
sgltri_render (&SGLContext);
|
||||
sgltri_startofframe (&SGLContext);
|
||||
}
|
||||
void GLI_INTERFACE_FUNC(GLI_DRV_vClearDevice)(BOOL ZBuffer, BOOL ColorBuffer, unsigned long Color)
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} //extern "C"
|
||||
#endif
|
Reference in New Issue
Block a user