Conitec 3d gamestudio-source development Manuale Utente
3D Gamestudio Programmer's Manual
© Conitec July 2002
11
A4_ENTITY *a5dll_entnext(A4_ENTITY *entity);
This function enumerates local entities, and can be used to access all entities in a level. If called
with NULL, it returns a pointer to the first entity in the level. If called with a level entity
pointer, it returns a pointer to the next level entity. If called with a pointer to the last entity or
no entity at all, it returns NULL.
with NULL, it returns a pointer to the first entity in the level. If called with a level entity
pointer, it returns a pointer to the next level entity. If called with a pointer to the last entity or
no entity at all, it returns NULL.
Example for a function that uses DirectX for painting all local model, sprite and terrain entities
red:
red:
DLLFUNC fixed PaintEntitiesRed(void)
{
// find the first entity in the level
{
// find the first entity in the level
A4_ENTITY *ent = a5dll_entnext(NULL);
while (ent) {
while (ent) {
A4_TEX *tex = a5dll_tex4ent(ent,0,0);
if (tex) {
if (tex) {
// lock the surface and retrieve a pointer to it
DDSURFACEDESC2 ddsd2;
ddsd2.dwSize = sizeof(DDSURFACEDESC2);
IDirectDrawSurface7 *psurf = (IDirectDrawSurface7 *) tex->pd3dsurf;
if (psurf->Lock(NULL,&ddsd2,DDLOCK_WAIT,NULL) == DD_OK) {
ddsd2.dwSize = sizeof(DDSURFACEDESC2);
IDirectDrawSurface7 *psurf = (IDirectDrawSurface7 *) tex->pd3dsurf;
if (psurf->Lock(NULL,&ddsd2,DDLOCK_WAIT,NULL) == DD_OK) {
// get a pointer to surface memory (assume 16 bit)
WORD *dest = (WORD *)ddsd2.lpSurface;
if (dest) {
if (dest) {
// paint all non-transparent pixels red (assume pitch == width)
const WORD red = 0xF800;
for (DWORD i=0; i<ddsd2.dwHeight*ddsd2.dwWidth; i++,dest++)
for (DWORD i=0; i<ddsd2.dwHeight*ddsd2.dwWidth; i++,dest++)
if (*dest) *dest = red;
}
// Unlock the surface again
psurf->Unlock(NULL);
}
}
// find the next entity
ent = a5dll_entnext(ent);
}
a5dll_errormessage("Entities are now red!");
return 0;
a5dll_errormessage("Entities are now red!");
return 0;
}
void a5dll_errormessage(char *text);
This function pops up an Error #1527 message requester with the given text. It can be used to
display diagnostic messages, or notify the user of wrong DLL calls, like with an invalid entity
pointer.
display diagnostic messages, or notify the user of wrong DLL calls, like with an invalid entity
pointer.