HMDState::HMDState(const OVR::HMDInfo& hmdInfo, Profile* profile) : pProfile(profile), pHmdDesc(0), pWindow(0), pClient(0), NetId(InvalidVirtualHmdId), NetInfo(), OurHMDInfo(hmdInfo), pLastError(NULL), EnabledHmdCaps(0), EnabledServiceHmdCaps(0), SharedStateReader(), TheSensorStateReader(), TheLatencyTestStateReader(), LatencyTestActive(false), //LatencyTestDrawColor(), LatencyTest2Active(false), //LatencyTest2DrawColor(), TimeManager(true), RenderState(), pRenderer(), pHSWDisplay(), LastFrameTimeSeconds(0.), LastGetFrameTimeSeconds(0.), //LastGetStringValue(), RenderingConfigured(false), BeginFrameCalled(false), BeginFrameThreadId(), RenderAPIThreadChecker(), BeginFrameTimingCalled(false) { sharedInit(profile); }
void DeadState::Init(FSMState * stateOwner) { // Attach the handle to the state owner FSMState::Init(stateOwner); sharedInit(); }
/* ==================== Sphere::Sphere Takes in the input stream and creates a Sphere object from the parsed input ==================== */ Sphere::Sphere(ifstream &f) { string textureName; while(!f.eof()) { string line; getline(f,line); queue<string> lineContents; explode(line," ",&lineContents); if(lineContents.size() == 0) continue; string word = lineContents.front(); lineContents.pop(); if(word[0] == '#' || line[0] == '\n' || line[0] == '\r') continue; //words with three string arguments if(word == "origin" || word == "color") { double num1 = 0; double num2 = 0; double num3 = 0; if(lineContents.size() < 3) break; num1 = atof(lineContents.front().c_str()); lineContents.pop(); num2 = atof(lineContents.front().c_str()); lineContents.pop(); num3 = atof(lineContents.front().c_str()); lineContents.pop(); if(word == "origin") this->origin = Point(num1,num2,num3); else if(word == "color") this->material.color = Color(num1,num2,num3); } //words with one argument else if(word == "radius" || word == "reflect" || word == "transparency") { double num1 = 0; if(lineContents.size() < 1) break; num1 = atof(lineContents.front().c_str()); lineContents.pop(); if(word == "radius") this->radius = num1; else if(word == "reflect") this->material.reflection = num1; else if(word == "transparency") this->material.transparency = num1; } //words with one string argument else if(word == "texture") { //TODO: attempt load texture from local directory first if(lineContents.size() < 1) break; textureName = lineContents.front(); lineContents.pop(); } else break; } sharedInit(origin,material,radius,textureName); }
void BinaryDeserializationContext_initWithBytes(BinaryDeserializationContext * self, const void * bytes, size_t length) { void * bytesMutable; bytesMutable = malloc(length); memcpy(bytesMutable, bytes, length); self->bytes = bytesMutable; self->length = length; sharedInit(self); }
/* ==================== Tube::Tube Takes in the input stream and creates a Tube object from the parsed input ==================== */ Tube::Tube(ifstream &f) { while(!f.eof()) { string line; getline(f,line); queue<string> lineContents; explode(line," ",&lineContents); if(lineContents.size() == 0) continue; string word = lineContents.front(); lineContents.pop(); if(word[0] == '#' || line[0] == '\n' || line[0] == '\r') continue; //words with three string arguments if(word == "origin" || word == "color" || word == "up") { double num1 = 0; double num2 = 0; double num3 = 0; if(lineContents.size() < 3) break; num1 = atof(lineContents.front().c_str()); lineContents.pop(); num2 = atof(lineContents.front().c_str()); lineContents.pop(); num3 = atof(lineContents.front().c_str()); lineContents.pop(); if(word == "origin") this->origin = Point(num1,num2,num3); else if(word == "color") this->material.color = Color(num1,num2,num3); else if(word == "up") { this->up = Vector(num1,num2,num3); } } //words with one argument else if(word == "radius" || word == "reflect" || word == "transparency" || word == "height") { double num1 = 0; if(lineContents.size() < 1) break; num1 = atof(lineContents.front().c_str()); lineContents.pop(); if(word == "radius") this->radius = num1; else if(word == "reflect") this->material.reflection = num1; else if(word == "transparency") this->material.transparency = num1; else if(word == "height") this->height = num1; } else break; } sharedInit(material,radius,height,up,origin); }
bool BitmapImage_init(BitmapImage * self, enum BitmapPixelFormat pixelFormat, unsigned int width, unsigned int height, unsigned int bytesPerRow) { sharedInit(self, pixelFormat, width, height, bytesPerRow); self->pixels = malloc(width * height * BitmapImage_pixelFormatBytes(pixelFormat)); self->private_ivar(freePixelsOnDispose) = false; return true; }
void GLBitmapFont_init(GLBitmapFont * self, struct GLBitmapFont_charEntry characters[GLBITMAPFONT_NUM_CHARS]) { unsigned int charIndex; sharedInit(self); memcpy(self->characters, characters, sizeof(struct GLBitmapFont_charEntry) * GLBITMAPFONT_NUM_CHARS); for (charIndex = 0; charIndex < GLBITMAPFONT_NUM_CHARS; charIndex++) { if (characters[charIndex].kernChars != NULL) { self->characters[charIndex].kernChars = malloc(sizeof(struct GLBitmapFont_kernEntry) * characters[charIndex].kernCharCount); memcpy(self->characters[charIndex].kernChars, characters[charIndex].kernChars, sizeof(struct GLBitmapFont_kernEntry) * characters[charIndex].kernCharCount); } } }
bool BitmapImage_initWithPixelsNoCopy(BitmapImage * self, enum BitmapPixelFormat pixelFormat, unsigned int width, unsigned int height, unsigned int bytesPerRow, unsigned char * pixels, bool takeOwnership) { sharedInit(self, pixelFormat, width, height, bytesPerRow); self->pixels = pixels; self->private_ivar(freePixelsOnDispose) = takeOwnership; return true; }
void iniciar_mundo () { int i, x, y; /* Criar a memória partilhada para o mundo */ mundo = sharedInit ("shm.pesca-mundo", sizeof (Mundo)); /* Inicializar a memória partilhada do mundo */ mundo->estado_capitao = C_PLANEAR; for (x = 0; x < DIMENSAO_MAR; x++) { for (y = 0; y < DIMENSAO_MAR; y++) { mundo->mar [x][y].barco = VAZIO; mundo->mar [x][y].cardume = VAZIO; } } mundo->hora_regressar = 0; fifoInit (&mundo->espera_barcos); mundo->barcos_cais = num_barcos; mundo->peixes_cais = 0; mundo->jornadas_pesca = num_jornadas_pesca; /* Criar e inicializar os semáforos */ char *nome; int max_digitos; /* ... semáforos dos barcos... */ max_digitos = log (num_barcos) / log (10) + 1; nome = malloc (strlen ("pesca-barco") + max_digitos + 1); sem_barcos = semInit (*nome, max_digitos); free (nome); /* .. semáforos dos cardumes... */ max_digitos = log (num_cardumes) / log (10) + 1; nome = malloc (strlen ("pesca-cardume") + max_digitos + 1); sem_cardumes = semInit (*nome, max_digitos); free (nome); /* .. semaforos do mutex .. */ nome = malloc (strlen ("pesca-mutex")); sem_cardumes = semInit (*nome, 0); free (nome); }
bool BitmapImage_initWithPixels(BitmapImage * self, enum BitmapPixelFormat pixelFormat, unsigned int width, unsigned int height, unsigned int bytesPerRow, const unsigned char * pixels) { unsigned int bytesPerPixel; sharedInit(self, pixelFormat, width, height, bytesPerRow); bytesPerPixel = BitmapImage_pixelFormatBytes(pixelFormat); self->pixels = malloc(bytesPerRow * height * bytesPerPixel); memcpy(self->pixels, pixels, bytesPerRow * height); self->private_ivar(freePixelsOnDispose) = true; return true; }
/* ==================== Light::Light Takes in the input stream and creates a Light object from the parsed input ==================== */ Light::Light(ifstream &f) { this->material = Material(); while(!f.eof()) { string line; getline(f,line); queue<string> lineContents; explode(line," ",&lineContents); if(lineContents.size() == 0) continue; string word = lineContents.front(); lineContents.pop(); if(word[0] == '#' || line[0] == '\n' || line[0] == '\r') continue; double num1 = 0; double num2 = 0; double num3 = 0; if(lineContents.size() < 3) break; num1 = atof(lineContents.front().c_str()); lineContents.pop(); num2 = atof(lineContents.front().c_str()); lineContents.pop(); num3 = atof(lineContents.front().c_str()); lineContents.pop(); if(word == "origin") this->origin = Point(num1,num2,num3); else if(word == "color") this->material.color = Color(num1,num2,num3); else break; } sharedInit(origin,material); }
void DeadState::Init(NPC * FSMOwner) { FSMState::Init(FSMOwner); sharedInit(); }
/* ==================== Tube::Tube Takes information for creation from parameters instead of input stream so that it can be created by a complex object ==================== */ Tube::Tube(Material m, double radius, double height, Vector up, Point origin) { sharedInit(m,radius,height,up,origin); }
/* ==================== Light::Light Takes in variables and creates a Light object ==================== */ Light::Light(Point origin, Material material) { sharedInit(origin,material); }
bool BinaryDeserializationContext_initWithFile(BinaryDeserializationContext * self, const char * filePath) { self->bytes = readFileSimple(filePath, &self->length); sharedInit(self); return true; }
/* ==================== Sphere::Sphere Takes in arguments and creates a Sphere object ==================== */ Sphere::Sphere(Point origin, Material material, double radius, string textureName) { sharedInit(origin,material,radius,textureName); }
bool GLBitmapFont_loadSerializedData(GLBitmapFont * self, DeserializationContext * context) { size_t kernCharIndex, kernCharIndex2, nchars; unsigned int charIndex; const char * key, * key2; const char * textureName; sharedInit(self); memset(self->characters, 0x00, sizeof(self->characters)); context->beginStructure(context, "glbitmapfont"); textureName = context->readString(context, "texture_name"); nchars = context->beginDictionary(context, "characters"); if (nchars != GLBITMAPFONT_NUM_CHARS) { self->dispose(self); return false; } for (charIndex = 0; charIndex < GLBITMAPFONT_NUM_CHARS; charIndex++) { key = context->readNextDictionaryKey(context); if (key[0] < GLBITMAPFONT_PRINTABLE_MIN || key[0] > GLBITMAPFONT_PRINTABLE_MAX || strlen(key) > 1) { self->dispose(self); return false; } context->beginStructure(context, key); self->characters[key[0] - GLBITMAPFONT_PRINTABLE_MIN].advance = context->readFloat(context, "advance"); self->characters[key[0] - GLBITMAPFONT_PRINTABLE_MIN].glyphOffset = context->readFloat(context, "glyph_offset"); self->characters[key[0] - GLBITMAPFONT_PRINTABLE_MIN].glyphWidth = context->readFloat(context, "glyph_width"); context->beginArray(context, "texture_bounds"); self->characters[key[0] - GLBITMAPFONT_PRINTABLE_MIN].textureLeft = context->readFloat(context, NULL); self->characters[key[0] - GLBITMAPFONT_PRINTABLE_MIN].textureRight = context->readFloat(context, NULL); self->characters[key[0] - GLBITMAPFONT_PRINTABLE_MIN].textureBottom = context->readFloat(context, NULL); self->characters[key[0] - GLBITMAPFONT_PRINTABLE_MIN].textureTop = context->readFloat(context, NULL); context->endArray(context); self->characters[key[0] - GLBITMAPFONT_PRINTABLE_MIN].kernCharCount = context->beginDictionary(context, "kerning_table"); if (self->characters[key[0] - GLBITMAPFONT_PRINTABLE_MIN].kernCharCount == 0) { self->characters[key[0] - GLBITMAPFONT_PRINTABLE_MIN].kernChars = NULL; } else { self->characters[key[0] - GLBITMAPFONT_PRINTABLE_MIN].kernChars = malloc(sizeof(struct GLBitmapFont_kernEntry) * self->characters[key[0] - GLBITMAPFONT_PRINTABLE_MIN].kernCharCount); } for (kernCharIndex = 0; kernCharIndex < self->characters[key[0] - GLBITMAPFONT_PRINTABLE_MIN].kernCharCount; kernCharIndex++) { key2 = context->readNextDictionaryKey(context); for (kernCharIndex2 = 0; kernCharIndex2 < kernCharIndex; kernCharIndex2++) { if (self->characters[key[0] - GLBITMAPFONT_PRINTABLE_MIN].kernChars[kernCharIndex2].previous == key2[0]) { self->dispose(self); return false; } } self->characters[key[0] - GLBITMAPFONT_PRINTABLE_MIN].kernChars[kernCharIndex].previous = key2[0]; self->characters[key[0] - GLBITMAPFONT_PRINTABLE_MIN].kernChars[kernCharIndex].offset = context->readFloat(context, key2); } context->endDictionary(context); context->endStructure(context); } context->endDictionary(context); context->endStructure(context); if (context->status != SERIALIZATION_ERROR_OK) { self->dispose(self); return false; } self->textureName = malloc(strlen(textureName) + 1); strcpy(self->textureName, textureName); self->textureNameOwned = true; return true; }