website logo
Auteur
avatar
thellier

Forum » » Création-Développement » » MiniGL


Posté : 30-11-2012 10:48 icone du post

A la limite le plus radical c'est de reprendre du code de Wazp3D

exemple sur W3D_SetState() :
mais y a plein d'autres fonctions w3d qui changent WC->state.Changed

Tout est écrit au fur et à mesure dans une structure state (WC->state)
et quand on trace on le compare au final (encore) avec le state courant SC->state

Oui je sais c Top


/*==========================================================================* /
BOOL SetState(W3D_Context *context,ULONG state,BOOL set)
{
struct WAZP3D_context *WC=context->driver;
ULONG newstate;
/* simpler W3D_SetState used internally */

if(set)
if(context->EnableMask & state)
{
newstate=context->state | state;
if(context->state!=newstate)
WC->state.Changed=TRUE;
context->state=newstate;
return(TRUE);
}

if(!set)
if(context->DisableMask & state)
{
newstate=context->state & ~state;
if(context->state!=newstate)
WC->state.Changed=TRUE;
context->state=newstate;
return(TRUE);
}
return(FALSE);
}
/*==========================================================================* /
ULONG W3D_SetState(W3D_Context *context, ULONG state, ULONG action)
{
void W3D_SetFrontFace(W3D_Context* context, ULONG direction);
struct WAZP3D_context *WC=context->driver;

WAZP3DFUNCTION(5);
PrintState(state,action);

/* set state if possible */
if(SetState(context,state,(action==W3D_ENABLE)) == FALSE)
WRETURN(W3D_UNSUPPORTEDSTATE);

if( state==W3D_ZBUFFERUPDATE)
if(action==W3D_ENABLE)
SetState(context,W3D_ZBUFFER,W3D_ENABLE); /*patch: for MiniGL/OS4 that forgot to enable zbuffer*/

if(state==W3D_BLENDING)
WC->CallSetBlending=TRUE;
if(state==W3D_CULLFACE)
W3D_SetFrontFace(context,context->FrontFaceOrder);

WRETURN(W3D_SUCCESS);
}


/*==================================================================*/
struct state3D /* v52: now all is described in a drawing state */
{
unsigned char Changed;
unsigned char ZMode;
unsigned char BlendMode;
unsigned char TexEnvMode;

unsigned char PerspMode;
unsigned char CullingMode;
unsigned char FogMode;
unsigned char UseGouraud;

unsigned char UseTex;
unsigned char UseFog;
unsigned char pad3;
unsigned char pad4;

unsigned char CurrentRGBA[4];
unsigned char EnvRGBA[4];
unsigned char FogRGBA[4];
unsigned char BackRGBA[4];

unsigned long PointSize;
unsigned long LineSize;
unsigned long primitive;
float FogZmin;
float FogZmax;
float FogDensity;
void* ST;
unsigned long gltex; /* GL texture */
};
*/*=============================================================*/
void SOFT3D_SetDrawState(APTR sc,APTR sta)
{
struct state3D *state=sta;
struct SOFT3D_context *SC=sc;
struct SOFT3D_texture *ST=state->ST;


if(!Wazp3D->PrefsIsOpened) /* if the user dont changing debug states */
LibDebug=Wazp3D->DebugWazp3D.ON; /* synchronize soft3d's LibDebug with global debug value "DebugWazp3D" setted with Wazp3-Prefs */
SFUNCTION(SOFT3D_SetDrawState)
if(Wazp3D->DebugSOFT3D.ON)
{
Libprintf(" state:Changed%ld UseTex%ld ST%ld ZMode%ld TexEnvMode%ld BlendMode%ld UseGouraud%ld UseFog%ld\n",(ULONG)state->Changed,(ULONG)state->UseTex,(ULONG)state->ST,(ULONG )state->ZMode,(ULONG)state->TexEnvMode,(ULONG)state->BlendMode,(ULONG)state->Us eGouraud,(ULONG)state->UseFog);
PrintST(state->ST);
Libprintf(" CurrentRGBA: %ld %ld %ld %ld\n",(ULONG)state->CurrentRGBA[0],(ULONG)state->CurrentRGBA[1],(ULONG)state-> CurrentRGBA[2],(ULONG)state->CurrentRGBA[3]);
}

if(!state->Changed)
{
SREM( state unchanged) /* not changed ==> do nothing */
return;
}

if(Wazp3D->UseStateTracker.ON)
if(!Wazp3D->PrefsIsOpened) /* if the user dont change states */
if(SC->state.ST ==state->ST)
if(SC->state.ZMode ==state->ZMode)
if(SC->state.BlendMode ==state->BlendMode)
if(SC->state.TexEnvMode ==state->TexEnvMode)
if(SC->state.PerspMode ==state->PerspMode)
if(SC->state.CullingMode==state->CullingMode)
if(SC->state.FogMode ==state->FogMode)
if(SC->state.UseGouraud ==state->UseGouraud)
if(SC->state.UseTex ==state->UseTex)
if(SC->state.UseFog ==state->UseFog)
if(SAMERGBA(SC->state.FogRGBA ,state->FogRGBA))
if(SAMERGBA(SC->state.CurrentRGBA ,state->CurrentRGBA))
if(SAMERGBA(SC->state.EnvRGBA ,state->EnvRGBA))
if(SC->state.PointSize ==state->PointSize)
if(SC->state.LineSize ==state->LineSize)
if(SC->state.FogZmin ==state->FogZmin)
if(SC->state.FogZmax ==state->FogZmax)
if(SC->state.FogDensity ==state->FogDensity)
{
SREM( all same states) /* if nothing truly changed ==> do nothing */
SC->state.Changed=state->Changed=FALSE;
return;
}


SC->state.ZMode =state->ZMode;
SC->state.BlendMode =state->BlendMode;
SC->state.TexEnvMode =state->TexEnvMode;
SC->state.PerspMode =state->PerspMode;
SC->state.CullingMode =state->CullingMode;
SC->state.FogMode =state->FogMode;
SC->state.UseGouraud =state->UseGouraud;
SC->state.UseTex =state->UseTex;
SC->state.UseFog =state->UseFog;
COPYRGBA(SC->state.FogRGBA ,state->FogRGBA);
COPYRGBA(SC->state.CurrentRGBA ,state->CurrentRGBA);
COPYRGBA(SC->state.EnvRGBA ,state->EnvRGBA);
COPYRGBA(SC->state.BackRGBA ,state->BackRGBA);
SC->state.PointSize =state->PointSize;
SC->state.LineSize =state->LineSize;
SC->state.FogZmin =state->FogZmin;
SC->state.FogZmax =state->FogZmax;
SC->state.FogDensity =state->FogDensity;
SC->state.ST =state->ST;
/*hard stuffs */
SC->state.gltex =0;
if(ST!=NULL)
SC->state.gltex =ST->HT.gltex; /*direct access to gltex value */
SC->HC.state=&SC->state; /*direct access to state */


/* flush remaining pixels before any changes */
SOFT3D_Flush(SC);

/* Now change hardware/software drawing functions */
#ifdef USEOPENGL
if(SC->UseHard) HARD3D_SetDrawFunctions(&SC->HC);
#endif
if(!SC->UseHard) SOFT3D_SetDrawFunctions(sc);

SC->state.Changed=state->Changed=FALSE; /* change treated */
}
/*=============================================================*/


Cet article provient de Le site des utilisateurs francophones actuels et futurs d'AmigaOS 4.x
https://amiga-ng.org/viewtopic.php?topic=965&forum=14