void icetGetIntegerv(IceTEnum pname, IceTInt *params) { struct IceTStateValue *value = icetGetState() + pname; int i; stateCheck(pname, icetGetState()); copyArray(IceTInt, params, value->type, value->data, value->num_entries); }
void icetGetEnumv(IceTEnum pname, IceTEnum *params) { struct IceTStateValue *value = icetGetState() + pname; int i; stateCheck(pname, icetGetState()); if ((value->type == ICET_FLOAT) || (value->type == ICET_DOUBLE)) { icetRaiseError("Floating point values cannot be enumerations.", ICET_BAD_CAST); } copyArray(IceTEnum, params, value->type, value->data, value->num_entries); }
static void *icetUnsafeStateGet(IceTEnum pname, IceTEnum type) { stateCheck(pname, icetGetState()); if (icetGetState()[pname].type != type) { icetRaiseError("Mismatched types in unsafe state get.", ICET_SANITY_CHECK_FAIL); return NULL; } return icetGetState()[pname].data; }
static void stateSet(IceTEnum pname, IceTSizeType num_entries, IceTEnum type, const IceTVoid *data) { IceTSizeType type_width = icetTypeWidth(type); void *datacopy = stateAllocate(pname, num_entries, type, icetGetState()); stateCheck(pname, icetGetState()); memcpy(datacopy, data, num_entries * type_width); stateCheck(pname, icetGetState()); }
void icetGetPointerv(IceTEnum pname, IceTVoid **params) { struct IceTStateValue *value = icetGetState() + pname; int i; stateCheck(pname, icetGetState()); if (value->type == ICET_NULL) { char msg[256]; sprintf(msg, "No such parameter, 0x%x.", (int)pname); icetRaiseError(msg, ICET_INVALID_ENUM); } if (value->type != ICET_POINTER) { char msg[256]; sprintf(msg, "Could not cast value for 0x%x.", (int)pname); icetRaiseError(msg, ICET_BAD_CAST); } copyArrayGivenCType(IceTVoid *, params, IceTVoid *, value->data, value->num_entries); }
void icetUnsafeStateSet(GLenum pname, GLint size, GLenum type, GLvoid *data) { IceTState state = icetGetState(); if (state[pname].type != ICET_NULL) { free(state[pname].data); } state[pname].type = type; state[pname].size = size; state[pname].mod_time = icetGetTimeStamp(); state[pname].data = data; }
void icetStateCheckMemory(void) { #ifdef ICET_STATE_CHECK_MEM IceTState state = icetGetState(); IceTEnum pname; for (pname = ICET_STATE_ENGINE_START; pname < ICET_STATE_ENGINE_END; pname++) { stateCheck(pname, state); } #endif }
void icetStateDump(void) { GLenum i; IceTState state; state = icetGetState(); printf("State dump:\n"); for (i = 0; i < ICET_STATE_SIZE; i++) { if (state->type != ICET_NULL) { printf("param = 0x%x\n", i); printf("type = 0x%x\n", (int)state->type); printf("size = %d\n", (int)state->size); printf("data = %p\n", state->data); printf("mod = %d\n", (int)state->mod_time); } state++; } }
static void stateSet(GLenum pname, GLint size, GLenum type, const GLvoid *data) { IceTState state; int type_width; void *datacopy; state = icetGetState(); type_width = typeWidth(type); if ((size == state[pname].size) && (type == state[pname].type)) { /* Save time by just copying data into pre-existing memory. */ memcpy(state[pname].data, data, size * type_width); state[pname].mod_time = icetGetTimeStamp(); } else { datacopy = malloc(size * type_width); memcpy(datacopy, data, size * type_width); icetUnsafeStateSet(pname, size, type, datacopy); } }
void icetStateDump(void) { IceTEnum pname; IceTState state; state = icetGetState(); printf("State dump:\n"); for (pname = ICET_STATE_ENGINE_START; pname < ICET_STATE_ENGINE_END; pname++) { stateCheck(pname, state); if (state->type != ICET_NULL) { printf("param = 0x%x\n", pname); printf("type = 0x%x\n", (int)state->type); printf("num_entries = %d\n", (int)state->num_entries); printf("data = %p\n", state->data); printf("mod = %d\n", (int)state->mod_time); } state++; } }
IceTVoid *icetGetStateBuffer(IceTEnum pname, IceTSizeType num_bytes) { if ( (icetStateGetType(pname) == ICET_VOID) && (icetStateGetNumEntries(pname) >= num_bytes) ) { /* A big enough buffer is already allocated. */ IceTVoid *buffer = icetUnsafeStateGet(pname, ICET_VOID); #ifdef ICET_STATE_CHECK_MEM memset(buffer, 0xDC, num_bytes); #endif return buffer; } /* Check to make sure this state variable has not been used for anything * besides a buffer. */ if ( (icetStateGetType(pname) != ICET_VOID) && (icetStateGetType(pname) != ICET_NULL) ) { icetRaiseWarning("A non-buffer state variable is being reallocated as" " a state variable. This is probably indicative of" " mixing up state variables.", ICET_SANITY_CHECK_FAIL); } return stateAllocate(pname, num_bytes, ICET_VOID, icetGetState()); }
IceTFloat *icetStateAllocateFloat(IceTEnum pname, IceTSizeType num_entries) { return stateAllocate(pname, num_entries, ICET_FLOAT, icetGetState()); }
IceTDouble *icetStateAllocateDouble(IceTEnum pname, IceTSizeType num_entries) { return stateAllocate(pname, num_entries, ICET_DOUBLE, icetGetState()); }
void icetGetDoublev(GLenum pname, GLdouble *params) { struct IceTStateValue *value = icetGetState() + pname; int i; copyArray(GLdouble, params, value->type, value->data, value->size); }
void icetGetBooleanv(GLenum pname, GLboolean *params) { struct IceTStateValue *value = icetGetState() + pname; int i; copyArray(GLboolean, params, value->type, value->data, value->size); }
void icetGetIntegerv(GLenum pname, GLint *params) { struct IceTStateValue *value = icetGetState() + pname; int i; copyArray(GLint, params, value->type, value->data, value->size); }
void *icetUnsafeStateGet(GLenum pname) { return icetGetState()[pname].data; }
GLenum icetStateType(GLenum pname) { return icetGetState()[pname].type; }
IceTTimeStamp icetStateGetTime(IceTEnum pname) { stateCheck(pname, icetGetState()); return icetGetState()[pname].mod_time; }
IceTTimeStamp icetStateGetTime(GLenum pname) { return icetGetState()[pname].mod_time; }
IceTInt *icetStateAllocateInteger(IceTEnum pname, IceTSizeType num_entries) { return stateAllocate(pname, num_entries, ICET_INT, icetGetState()); }
IceTBoolean *icetStateAllocateBoolean(IceTEnum pname, IceTSizeType num_entries) { return stateAllocate(pname, num_entries, ICET_BOOLEAN, icetGetState()); }
IceTEnum icetStateGetType(IceTEnum pname) { stateCheck(pname, icetGetState()); return icetGetState()[pname].type; }
IceTSizeType icetStateGetNumEntries(IceTEnum pname) { stateCheck(pname, icetGetState()); return icetGetState()[pname].num_entries; }
GLint icetStateGetSize(GLenum pname) { return icetGetState()[pname].size; }