35 #include "../vrml_parser/Structs.h"
36 #include "../vrml_parser/CRoutes.h"
37 #include "../main/headers.h"
39 #include "../input/EAIHeaders.h"
40 #include "../input/EAIHelpers.h"
41 #include "../opengl/Frustum.h"
42 #include "../opengl/Textures.h"
44 #include "Component_Networking.h"
47 #include <libFreeWRL.h>
50 #include "../scenegraph/ringbuf.h"
63 buffer -> noOfElements = FORCE_GUARD_ELEMENT+elCount ;
64 buffer -> data = data ;
66 #ifdef TRACK_RINGBUFFER_MSG
67 printf(
"NewRingBuffer at %p , data at %p , %d elements\n",buffer, buffer->data , buffer->noOfElements);
75 if(buffer->data == NULL)
return 0;
77 if (buffer->tail >= buffer->head) {
78 return buffer->tail - buffer->head;
80 return (buffer->tail + buffer->noOfElements) - buffer->head;
86 if(buffer->data == NULL)
return 0;
87 int used = RingBuffer_qLen(buffer) ;
88 return (buffer->noOfElements-FORCE_GUARD_ELEMENT) - used ;
91 int RingBuffer_testEmpty(
RingBuffer * buffer) {
92 if(buffer->data == NULL)
return 1;
93 return (buffer->tail == buffer->head)? 1:0;
97 if(buffer->data == NULL)
return 1;
98 int qlen = RingBuffer_qLen(buffer) ;
99 return (qlen < (buffer->noOfElements-FORCE_GUARD_ELEMENT))? 0:1;
102 int RingBuffer_pushInt(
RingBuffer * buffer,
int newInt) {
104 if(buffer->data == NULL)
return -1;
106 if(!RingBuffer_testFull(buffer)) {
107 rbItem * data = buffer->data ;
108 (data+buffer->tail)->i = newInt;
110 buffer->tail = buffer->tail % buffer->noOfElements;
116 int RingBuffer_pushFloat(
RingBuffer * buffer,
float newFloat) {
118 if(buffer->data == NULL)
return -1;
120 if(!RingBuffer_testFull(buffer)) {
121 rbItem * data = buffer->data ;
122 (data+buffer->tail)->f = newFloat;
124 buffer->tail = buffer->tail % buffer->noOfElements;
130 int RingBuffer_pushPointer(
RingBuffer * buffer,
void *newPointer) {
132 if(buffer->data == NULL)
return -1;
134 if(!RingBuffer_testFull(buffer)) {
135 rbItem * data = buffer->data ;
136 (data+buffer->tail)->p = newPointer;
138 buffer->tail = buffer->tail % buffer->noOfElements;
146 if(buffer->data == NULL)
return NULL;
148 if(!RingBuffer_testEmpty(buffer)) {
150 rbItem * data = buffer->data ;
151 xyz=(data+buffer->head);
153 buffer->head = buffer->head % buffer->noOfElements;
163 if(buffer->data == NULL)
return NULL;
165 if(!RingBuffer_testEmpty(buffer)) {
167 rbItem * data = buffer->data ;
168 xyz=(data+buffer->head);
175 void RingBuffer_makeEmpty(
RingBuffer * buffer) {
180 void RingBuffer_freeDataArea(
RingBuffer * buffer) {
181 if(buffer->data == NULL) return ;