website logo
Auteur
avatar
thellier

Forum » » Logiciels » » Cows 3D pour Warp3D et Nova


Posté : 16-01-2017 19:10 icone du post

Soir'

Merci des retours
Je suis comme vous : je n'ai pas toutes les réponses
On m'a demandé de faire un Cow3D pour la sortie de Nova: le voilà donc...
Mais ça m'a gavé de me remettre dans CoW3D qui est pas un programme si bien écrit que ça

Aussi Nova (tout comme les versions d'OpenGL avec shaders...) est un peu trop compliqué pour rien : cad que quand on veut pas faire grand choses il faut quand meme écrire beaucoup de code
Bref c'étais chiant...

>Nova est supposé reposer au maximum sur le GPU, je trouve l'écart de performances un peu faible.
Cow3D fait pas grand chose donc c'est un programme idéal pour Warp3D qui est donc favorisé
Par contre si il y avait eu de l'éclairage ou d'autres effets alors Nova aurait repris le dessus: enfin je suppose

@Crisot
>Je suppose que c'est du VBO static?

Oui voici comment la vache est mise dans le vbo une fois pour toute

/*==================================================================*/
BOOL ObjectToVboNova(struct object3D *O)
{
ULONG Anb=3+1;
ULONG Asize = O->Pnb * sizeof(NOVAPOINT) + O->PInb * sizeof(ULONG);

O->vbo = C.ncontext->CreateVertexBufferObject(&C.error, Asize, W3DN_STATIC_DRAW, Anb, TAG_DONE);
NCHECK(O->vbo,CreateVertexBufferObject);
NERROR(CreateVertexBufferObject)

// Set the VBO's layout
NOVAPOINT *point = NULL;
O->Vid = 0;
O->Nid = 1;
O->UVid = 2;
// O->Cid = 3;

O->PIid = 3;
// O->PIid = 4;

uint32 Vcount = sizeof(point->position) / sizeof(point->position.x);
uint32 Ncount = sizeof(point->normal) / sizeof(point->normal.x);
uint32 UVcount = sizeof(point->texCoord) / sizeof(point->texCoord.x);
// uint32 Ccount = sizeof(point->color) / sizeof(point->color.x);

uint32 Voffset = offsetof(NOVAPOINT, position);
uint32 Noffset = offsetof(NOVAPOINT, normal);
uint32 UVoffset = offsetof(NOVAPOINT, texCoord);
// uint32 Coffset = offsetof(NOVAPOINT, color);

uint32 Psize = sizeof(NOVAPOINT);
uint32 PIsize = sizeof(ULONG);
uint32 PIoffset = O->Pnb * Psize;

strcpy(O->Vname ,"vertPosition");
strcpy(O->Nname ,"vertNormal");
strcpy(O->UVname,"vertTexCoord");
// strcpy(O->Cname ,"vertColor");

C.ncontext->VBOSetArray(O->vbo, O->Vid, W3DNEF_FLOAT, FALSE, Vcount, Psize, Voffset, O->Pnb);
C.ncontext->VBOSetArray(O->vbo, O->Nid, W3DNEF_FLOAT, FALSE, Ncount, Psize, Noffset, O->Pnb);
C.ncontext->VBOSetArray(O->vbo, O->UVid,W3DNEF_FLOAT, FALSE, UVcount,Psize, UVoffset,O->Pnb);
// C.ncontext->VBOSetArray(O->vbo, O->Cid ,W3DNEF_FLOAT, FALSE, Ccount,Psize, Coffset, O->Pnb);

C.ncontext->VBOSetArray(O->vbo, O->PIid,W3DNEF_UINT32, FALSE, 1, PIsize, PIoffset, O->PInb);

/* not known yet */
O->Vattrib=0;
O->Nattrib=0;
O->UVattrib=0;
O->Cattrib=0;

// Generate the vertices
W3DN_BufferLock *bufferLock = C.ncontext->VBOLock(&C.error, O->vbo, 0, 0);
NCHECK(bufferLock,VBOLock);
NERROR(VBOLock)

APTR NP = (NOVAPOINT*)bufferLock->buffer;
memcpy(NP,O->P,O->Pnb*sizeof(NOVAPOINT));

APTR NPI = (uint32*)((uint8*)bufferLock->buffer + PIoffset);
memcpy(NPI,O->PI,O->PInb*sizeof(ULONG));

C.ncontext->BufferUnlock(bufferLock, 0, bufferLock->size);

return(TRUE);
panic:
REM(panic!!!)
return(FALSE);
}
Sam440 - Sam460 - X5000 - PowerBookG4 - WinUAE - MiniMig

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