#Why doesn't this work?
I modified BOX.C in order to test some of the gfx functions….the code
compiles OK but doesn't work. The purpose is to erase the screen, wait for a
key and then redraw…that's it. Any ideas?
/////////////////////////////////////
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "pxp.h"
#include "exprtn.h"
/* Variable definitions */
#define COLOR 1
/************************/
/* Dialog description */
DlgEntry cdialog[]=
{
/* Text strings to be displayed in dialog box */
0, "TITLE=\"Test\"",
0, "TITLE=\"by John Doe, Version 1.0\"",
/* Setup for 'radio-button' and associated variable */
COLOR, "RADIO=\"AXP Color:\", \"Default\", \"From Object\"",
0, NULL
};
/* Version test value */
/* Every external process must have a unique version number */
#define VERSION 0x71FF
/* State Structure definition */
/* Any variables whose values are set via dialog interface must be
declared within the 'State' struct. */
typedef struct
{
ulong version;
int obj_color;
} State;
static State init_state = { VERSION, 1 }; /* initial state settings */
static State state = { VERSION, 1 }; /* default settings */
static int ix, thismtl;
static float minx, miny, minz, maxx, maxy, maxz;
/*—————————————————————-*/
/* Following function sets the appropriate 'State' variables based on the
input from the dialog */
void ClientSetStateVar(int id, void *ptr)
{
OVL o; /* Union of possible values that the dialog can return */
ulong *ul;
char *s;
ul=(ulong *)ptr;
s=(char *)ptr;
o.ul = *ul;
switch(id)
{
case COLOR: state.obj_color=o.i; break; /* State variables set here based
on Union variable */
}
}
/* Following function sets the appropriate value of the Union 'OVL' variable
to return values stored in the 'State' variable */
ulong ClientGetStateVar(int id)
{
OVL o; /* Union of the values which can be requested by 3D Studio from the
'State' structure */
switch(id)
{
case COLOR: o.i=state.obj_color; break; /* Union variable set to
appropriate value from 'state'
variable */
}
return(o.ul); /* The variable requested by 3D Studio is returned to 3D
Studio via the 'ulong' field of the 'Union' structure
'OVL'. */
}
/* Following function allows 3D Studio to determine the size of any variable
in the dialog */
int ClientVarSize(int id)
{
return(1);
}
/* Following function allows 3D Studio to determine the size of the 'State'
structure and returns a pointer to the 'State' struct */
char *ClientGetState(int *size)
{
*size = sizeof(State);
return((char *)&state);
}
/* Following function allows 3D Studio to reset the state of the external
process */
void ClientResetState()
{
state = init_state;
}
/* Following function performs any calculations or packet-commands necessary
before the EXP can begin */
void ClientStartup(EXPbuf *buf)
{
buf->opcode=EXP_NOP; /* Packet command sent to 3D Studio */
buf->usercode=0x0200;
buf->status=1;
}
/* Following function contains user codes which process data */
void ClientUserCode(EXPbuf *buf) {
switch(buf->usercode) {
case 0x0200:
gfx_clearscreen();
gfx_key_wait(ix);
gfx_redraw();
buf->opcode=buf->usercode=EXP_TERMINATE;
buf->status=0;
break;
}
}
void ClientTerminate(void)
{
/* free any data structures, etc. */
}
DlgEntry *ClientDialog(int n)
{
return(&cdialog[n]);
}