Map::Map(GLuint program, const GraphicsObjectManager& graphics) : HUDobject_Animated(program, graphics) { EventHandler::addCursorPosHook(this); EventHandler::addScrollHook(this); GLenum format; unsigned char* imageData = extractImageFrom7zFile("../../Source/map.7z", &m_originalWidth, &m_originalHeight, &format); glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, m_originalWidth, m_originalHeight); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_originalWidth, m_originalHeight, format, GL_UNSIGNED_BYTE, imageData); freeImageData(imageData); //glGenerateMipmap(GL_TEXTURE_2D); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); this->setCoords({ 0.0f, 0.0f }, (GLfloat)m_originalWidth, (GLfloat)m_originalHeight, 0); m_arrows.push_back(new Arrow(graphics, *this, { 0.03f, 0.06f }, { 0.03f, 0.2f })); float mapAspectRatio = 3712.0f / 3333; m_arrows.push_back(new Arrow(graphics, *this, { 0.06f, 0.06f * mapAspectRatio }, { 0.15f, 0.15f * mapAspectRatio })); m_arrows.push_back(new Arrow(graphics, *this, { 0.06f, 0.03f }, { 0.27f, 0.03f })); }
void freeImage(Image * const imageP) { assertGoodImage(imageP); freeImageData(imageP); imageP->type = IBAD; free(imageP); }
void endControlFlow(SPConfig config, SPImageData image, bool isCurrentImageFeaturesArrayAllocated, SPKDTreeNode kdTree, SPBPQueue bpq, int returnValue) { if (returnValue < 0) { printf(MAIN_RETURNED_ERROR); } printf("%s", EXITING); spConfigDestroy(config); freeImageData(image, !isCurrentImageFeaturesArrayAllocated, true); spKDTreeDestroy(kdTree, true); spBPQueueDestroy(bpq); spLoggerDestroy(); }
void freeAllImagesData(SPImageData* imagesData, int size, bool freeInternalFeatures){ assert(size>=0); int i; if (imagesData != NULL){ for (i = 0 ; i < size ; i++){ freeImageData(imagesData[i], false, freeInternalFeatures); } free(imagesData); imagesData = NULL; } else { spLoggerSafePrintWarning(WARNING_IMAGES_DATA_NULL, __FILE__,__FUNCTION__, __LINE__); } }
bool ImageLoader::loadImage(const char* image) { freeImageData(); // Create the final path... char filePath[260]; sprintf(filePath, "%s%s", m_path, image); // Now let's switch over to using devIL... ILuint handle; // In the next section, we load one image ilGenImages(1, &handle); ilBindImage(handle); const ILboolean loaded = ilLoadImage(filePath); if (loaded == IL_FALSE) { ILenum error = ilGetError(); return false; // Error encountered during loading } // Let’s spy on it a little bit m_width = (u32)ilGetInteger(IL_IMAGE_WIDTH); // getting image width m_height = (u32)ilGetInteger(IL_IMAGE_HEIGHT); // and height // Make sure our buffer is big enough. assert( m_width <= MAX_IMAGE_WIDTH && m_height <= MAX_IMAGE_WIDTH ); // Finally get the image data ilCopyPixels(0, 0, 0, m_width, m_height, 1, IL_RGBA, IL_UNSIGNED_BYTE, m_imageData_Work); // (Now flip the image for OpenGL... does not seem to be necessary so just copy for now) memcpy( m_imageData, m_imageData_Work, 4*m_width*m_height ); // Finally, clean the mess! ilDeleteImages(1, &handle); return true; }