int InitGL() // All Setup For OpenGL goes here { glShadeModel(GL_SMOOTH); // Enables Smooth Shading glClearColor(0.0, 0.0, 0.0, 1.0); glClearDepth(1.0f); // Depth Buffer Setup glEnable(GL_DEPTH_TEST); // Enables Depth Testing glDepthFunc(GL_LEQUAL); // The Type Of Depth Test To Do glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculation glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); // Uses default lighting parameters glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); glEnable(GL_NORMALIZE); glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); glLightfv(GL_LIGHT1, GL_POSITION, LightPosition); glEnable(GL_LIGHT1); glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); // and now some init I need to do for other stuff ilInit(); /* Initialization of DevIL */ // mouse stuff pointer = toGLTexture("./dati/models/textures/mirino.png"); lastx = middleX; lasty = middleY; relativeX = 0.0; relativeY = 0.0; glutWarpPointer(middleX, middleY); // put the cursor in the middle of the screen //for the menu InitMenu(); // for the text t3dInit(); // for the skybox initSkybox(); // for the blend initAssets(); // for the sounds if (!sound_hit.loadFromFile("./dati/audio/hit.wav")) return -1; if (!sound_miss.loadFromFile("./dati/audio/miss.wav")) return -1; if (!sound_youreempty.loadFromFile("./dati/audio/youreempty.wav")) return -1; if (!sound_ohno.loadFromFile("./dati/audio/ohno.wav")) return -1; music.setLoop(true); if (!music.openFromFile("./dati/audio/Rango_Theme.ogg")) return -1; music.play(); return TRUE; // Initialization Went OK }
void test_ilLoad(wchar_t* sourceFN, wchar_t* targetFN) { testHeap(); ilInit(); testHeap(); ILuint handle = ilGenImage(); testHeap(); ilBindImage(handle); testHeap(); //printf("Loading " PathCharMod "\n", sourceFN); ilResetRead(); ILenum sourceType = ilDetermineType(sourceFN); if (!ilLoad(sourceType, sourceFN)) { printf("test_ilLoad: Failed to load %S\n", sourceFN); ++errors; return; } testHeap(); //ilConvertImage(IL_BGR, IL_UNSIGNED_BYTE); //ilConvertImage(IL_LUMINANCE, IL_UNSIGNED_BYTE); //iluScale(150, 150, 1); testHeap(); DeleteFile(targetFN); //printf("Saving " PathCharMod "\n", targetFN); if (!ilSaveImage(targetFN)) { printf("test_ilLoad: Failed to save " PathCharMod "\n", targetFN); ++errors; } testHeap(); ilDeleteImage(handle); }
void init(InitFeature::Features featureset, LogLevel logLevel) { if (featureset & InitFeature::SHADER_MANAGER) { featureset = (InitFeature::Features) (featureset | InitFeature::GPU_PROPERTIES | InitFeature::FILE_SYSTEM); } if (featureset & InitFeature::TEXTURE_MANAGER) { featureset = (InitFeature::Features) (featureset | InitFeature::GPU_PROPERTIES | InitFeature::FILE_SYSTEM); } if (featureset & InitFeature::LOG_MANAGER) { LogManager::init(); if (featureset & InitFeature::LOG_TO_CONSOLE) { ConsoleLog* log = new ConsoleLog(); log->addCat("", true, logLevel); LogMgr.addLog(log); } // LogMgr disposes all its logs } if (featureset & InitFeature::FILE_SYSTEM) FileSystem::init(); #ifdef CGT_HAS_DEVIL ilInit(); iluInit(); #endif }
bool il_init() { // init DevIL. This needs to be done only once per application ilInit(); return true; }
// // Private members // void ilImage::iStartUp() { ilInit(); iluInit(); ilutInit(); return; }
int main(int argc, char** argv) { ilInit(); iluInit(); for(int i=0; i<=133; ++i) { // export graphic LBA_MAP_GL map(i, 0); map.ExportMapOSG(); //export physic LBA_MAP_PHYS mapp(i, 0); } for(int i=1; i<=138; ++i) { // export graphic LBA_MAP_GL map(i, 1); map.ExportMapOSG(); //export physic LBA_MAP_PHYS mapp(i, 1); } return 0; }
void Image::save_to_file(const string& filename) { if (!devil_initialized) { ilInit(); devil_initialized = true; } ILuint il_image; ilGenImages(1, &il_image); ilTexImage(_width, _height, 0, _bpp, _format, _type, _data); ILboolean success = ilSaveImage(filename.c_str()); if (!success) { cerr << "Image::Image " << "Failed to save to image file " << filename << endl; _data = NULL; return; } ilBindImage(0); ilDeleteImages(1, &il_image); }
void DevILInit(void) { ilInit(); ilEnable(IL_CONV_PAL); ilEnable(IL_ORIGIN_SET); ilOriginFunc(IL_ORIGIN_UPPER_LEFT); }
//----------------------------------------------------------------------------- // Name: InitDeviceObjects() // Desc: Initialize scene objects. //----------------------------------------------------------------------------- HRESULT CMyD3DApplication::InitDeviceObjects() { HRESULT hr; m_pFont->InitDeviceObjects( m_pd3dDevice ); ilInit(); iluInit(); ilutInit(); ilutD3D8TexFromFile(m_pd3dDevice, __argv[1], &m_pTexture); //D3DXCreateTextureFromFile(m_pd3dDevice, __argv[1], &m_pTexture); // Create a vertex buffer { if( FAILED( hr = m_pd3dDevice->CreateVertexBuffer( 4*sizeof(VERTEX), D3DUSAGE_WRITEONLY, D3DFVF_VERTEX, D3DPOOL_MANAGED, &m_pVB ) ) ) return hr; VERTEX* pVertices; m_pVB->Lock( 0, 4*sizeof(VERTEX), (BYTE**)&pVertices, 0 ); memcpy( pVertices, g_vVertices, sizeof(VERTEX)*4 ); m_pVB->Unlock(); } return S_OK; }
GLPresenter::GLPresenter(DeckLinkCapture &capture, int w, int h, int hz) : data_size(w*h*2), capture(capture), running(true), fullscreen(false), useVsync(false), rgbFull(false), texId(0), displayList(0), convertUYVY(NULL), buffer(NULL), buffer2(NULL), reqW(w), reqH(h), reqHz(hz), frameIndex(0), drawnFrameIndex(0), aspect(16.0/9.0), oneToNScaleFactor(-1.0) { self = this; sprintf(prepend, "#define FRAME_WIDTH %d\n#define FRAME_HEIGHT %d\n", reqW, reqH); RT_ASSERT(glfwInit() == GL_TRUE, "Failed to initalize GLFW."); RT_ASSERT(glfwOpenWindow(w, h, 0, 0, 0, 0, 0, 0, GLFW_WINDOW) == GL_TRUE, "Failed to open GLFW window."); string title("PtBi "); title += VER_STRING; glfwSetWindowTitle(title.c_str()); glfwSetWindowPos(10, 10); dataPointers[0] = malloc(data_size); dataPointers[1] = malloc(data_size); glewInit(); checkExtensions(); ilInit(); glfwDisable(GLFW_AUTO_POLL_EVENTS); glfwSwapInterval(0); glfwSetWindowCloseCallback(closeCallback); glfwSetWindowSizeCallback(resizeCallback); glfwSetMousePosCallback(mousePosCallback); glfwSetKeyCallback(keyCallback); hdc = wglGetCurrentDC(); hrc = wglGetCurrentContext(); initGL(); convertUYVY = new GLFragmentProgram("shaders/uyvy_to_rgb_smooth.glsl", getShaderPrependString()); buffer = new GLRenderTexture(getW(), getH(), GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE); buffer->setFilterMode(GL_LINEAR); buffer2 = new GLRenderTexture(getW(), getH(), GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE); buffer2->setFilterMode(GL_LINEAR); scalingManager = new ScalingManager(*this); aaManager = new AAManager(*this); ipManager = new IPManager(*this); keyBinding = new KeyBinding(this); capture.registerDisplayListener(this); hwnd = GetForegroundWindow(); RT_GL_ASSERT("Error during GL initialization."); reshape(reqW, reqH); }
void SDLHandler::Init(Uint32 flags) { ilInit(); iluInit(); SDLErrCheck(SDL_Init(flags)); SDLErrCheck(SDL_SetRelativeMouseMode(SDL_TRUE)); }
int main(int argc, char *argv[]) { ilInit(); int from = 0, to = -1; if(argc == 3) from = atoi(argv[1]), to = atoi(argv[2]); if(argc == 4) from = atoi(argv[2]), to = atoi(argv[3]); LDataset *dataset = new LMsrcDataset(); // LDataset *dataset = new LVOCDataset(); // LDataset *dataset = new LCamVidDataset(); // LDataset *dataset = new LCorelDataset(); // LDataset *dataset = new LSowerbyDataset(); // LDataset *dataset = new LLeuvenDataset(); LCrf *crf = new LCrf(dataset); dataset->SetCRFStructure(crf); crf->Segment(dataset->allImageFiles, from, to); crf->TrainFeatures(dataset->trainImageFiles); crf->EvaluateFeatures(dataset->allImageFiles, from, to); crf->TrainPotentials(dataset->trainImageFiles); crf->EvaluatePotentials(dataset->testImageFiles, from, to); crf->Solve(dataset->testImageFiles, from, to); crf->Confusion(dataset->testImageFiles, "results.txt"); delete crf; delete dataset; return(0); }
const ImageData Texture::loadFile(const std::string &path, const ImageFormat &format) { ilInit(); ILuint image; ilGenImages(1, &image); ilBindImage(image); ilEnable(IL_ORIGIN_SET); ilOriginFunc(IL_ORIGIN_LOWER_LEFT); ImageData imageData; ILboolean result = ilLoadImage(path.c_str()); if (result) { //ilConvertImage(IL_RGBA, IL_UNSIGNED_BYTE); imageData.format = format; imageData.width = ilGetInteger(IL_IMAGE_WIDTH); imageData.height = ilGetInteger(IL_IMAGE_HEIGHT); imageData.sizeInBytes = imageData.width * imageData.height * imageData.format.numberOfChannels * imageData.format.bytesPerChannel; imageData.data = new uint8_t[imageData.sizeInBytes]; memcpy(imageData.data, ilGetData(), imageData.sizeInBytes); } else { std::cout << "Failed to load image from file: " << path << std::endl; } ilDeleteImages(1, &image); return imageData; }
void init_texture_loading() { glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); ilInit(); }
int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_ALPHA); glutInitWindowSize(900, 600); glutInitWindowPosition(250, 100); glDisable(GL_ALL_ATTRIB_BITS); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_GREATER); glEnable(GL_NORMALIZE); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); glEnableClientState(GL_COLOR_ARRAY); glutCreateWindow("Snake3D"); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable( GL_BLEND ); ilInit(); ilClearColour(255, 255, 255, 000); GameStateManager::init(); GameStateManager::startIntroState(); glutMainLoop(); GameStateManager::close(); return 0; }
float* getImage(const wchar_t* fileName, int* height, int* width, int* imgFormat) { ilInit(); ILuint img; ilGenImages(1, &img); ilBindImage(1); ilLoadImage(fileName); ILenum error; error = ilGetError(); *height = ilGetInteger(IL_IMAGE_HEIGHT); *width = ilGetInteger(IL_IMAGE_WIDTH); *imgFormat = ilGetInteger(IL_IMAGE_FORMAT); ILubyte* imgData = ilGetData(); float* texImg = new float[*height * *width * 3]; for(int i = 0; i < *height * *width * 3; i++) { texImg[i] = imgData[i] / 255.0f; } ilDeleteImages(1, &img); std::cout << "Textures loaded!" << std::endl; return texImg; }
DevILImageCodec::DevILImageCodec() : ImageCodec("DevILImageCodec - Official DevIL based image codec") { // init DevIL libs we use ilInit(); iluInit(); }
/* Initializes the third party softwares * @param void * @return void */ void OBJLoader::devilStartUp() { ilutRenderer(ILUT_OPENGL); ilInit(); iluInit(); ilutInit(); ilutRenderer(ILUT_OPENGL); }
GLuint ReadTexture() { GLuint tex; glGenTextures(1, &tex); glBindTexture(GL_TEXTURE_2D, tex); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); ILuint img; ilInit(); ilGenImages(1, &img); ilBindImage(img); ILboolean success = ilLoadImage((const ILstring)"gv2.png"); if(success) { success = ilConvertImage(IL_RGBA,IL_UNSIGNED_BYTE); glTexImage2D(GL_TEXTURE_2D, 0, ilGetInteger(IL_IMAGE_BPP), ilGetInteger(IL_IMAGE_WIDTH), ilGetInteger(IL_IMAGE_HEIGHT),0, ilGetInteger(IL_IMAGE_FORMAT), GL_UNSIGNED_BYTE, ilGetData()); } ilDeleteImages(1, &img); return tex; }
System::System(int argc, char** argv) { glutInit(&argc, argv); m_window.Init(); glewInit(); Drawer::Init(); ilInit(); iluInit(); ilutInit(); ilutRenderer(ILUT_OPENGL); Drawer::AddModel( std::vector<float>{-1.0, -1.0 ,0.5, 1.0, -1.0, 0.99, -1.0, 1.0, 0.99, 1.0, -1.0, 0.99, 1.0, 1.0, 0.99, -1.0, 1.0, 0.99}, CONF_GET("g1")); Drawer::AddModel(CONF_GET("fish_obj"), CONF_GET("fish_texture")); Drawer::AddDrawable(1, 1500, -2000, -6000); Drawer::AddDrawable(1, 1500, -2000, -6000); Drawer::AddDrawable(0, 0, 0, 0); Drawer::MoveCamera(0, 0.05, 0.5); glutDisplayFunc(Drawer::Draw); glutKeyboardFunc(Keyboard); glutMainLoop(); }
// ensure that init is called exactly once int ilImage::ilStartUp() { ilInit(); //iluInit(); //ilutInit(); return true; }
/* function initImageLibrary() * Description: * - initialize the DevIL library properly */ void initImageLibrary() { glEnable(GL_TEXTURE_2D); ilInit(); iluInit(); ilutRenderer(ILUT_OPENGL); }
void initDebugDraw() { ilInit(); iluInit(); ilutInit(); ilutRenderer(ILUT_OPENGL); }
//----------------------------------------------------------------------------- //Функция инициализации void init() { //Инициализация DevIL ilInit(); iluInit(); ilutInit(); Load_Tex_Image(); glColor4f(1.0f,1.0f,1.0f,0.5f); // Полная яркость, 50% альфа glBlendFunc(GL_SRC_ALPHA,GL_ONE); // Функция смешивания для непрозрачности, // базирующаяся на значении альфы glEnable(GL_TEXTURE_2D); // Разрешить наложение текстуры glViewport( 0, 0, WinWidth, WinHeight ); glClearColor(0.5f, 0.6f, 0.4f, 0.0f); glClearDepth(1.0); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glShadeModel(GL_SMOOTH); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective( 45.0f, (GLfloat)WinWidth/(GLfloat)WinHeight, 0.1f, 100.0f ); glMatrixMode(GL_MODELVIEW); glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); // Установка Фонового Света glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); // Установка Диффузного Света glLightfv(GL_LIGHT1, GL_POSITION, LightPosition); // Позиция света glEnable(GL_LIGHT1); // Разрешение источника света номер один glLoadIdentity(); }
image::image(char* file) { ilInit(); ilGenImages(1, &ID); /* Generation of one image name */ ilBindImage(ID); /* Binding of image name */ if(!ilLoadImage(file)) { img = new unsigned char[2]; return; } width = ilGetInteger(IL_IMAGE_WIDTH); height = ilGetInteger(IL_IMAGE_HEIGHT); type = ilGetInteger(IL_IMAGE_FORMAT); if(type == IL_RGB) size = 3; else size = 4; img = new unsigned char[width * height * size]; ilCopyPixels(0, 0, 0, width, height, 1, type, IL_UNSIGNED_BYTE, img); ilDeleteImages(1, &ID); ID = 0; }
void texture_init( void ) { if(devil_initialized) return; ilInit(); devil_initialized = 1; }
void Texture2D::loadFromFile(std::string fileName) { ilInit(); ILuint devilError = ilGetError(); if (IL_NO_ERROR != devilError) { std::cout << iluErrorString(devilError) << std::endl; } ILuint imageHandle; ilGenImages(1, &imageHandle); ilBindImage(imageHandle); ilLoadImage(fileName.c_str()); if (IL_NO_ERROR != devilError) { std::cout << iluErrorString(devilError) << std::endl; } width = (unsigned int) ilGetInteger(IL_IMAGE_WIDTH); height = (unsigned int) ilGetInteger(IL_IMAGE_HEIGHT); bpp = (unsigned int) ilGetInteger(IL_IMAGE_BITS_PER_PIXEL); ILuint dataSize = ilGetInteger(IL_IMAGE_SIZE_OF_DATA); float* buffer = new float[width * height * 4]; ilCopyPixels(0, 0, 0, width, height, 1, IL_RGBA, IL_FLOAT, buffer); initialize(width, height, bpp); setData(buffer); ilDeleteImages(1, &imageHandle); }
BundlerMatcher::BundlerMatcher(float matchThreshold, int firstOctave, bool binaryWritingEnabled, bool sequenceMatching, int sequenceMatchingLength) { mBinaryKeyFileWritingEnabled = binaryWritingEnabled; mSequenceMatchingEnabled = sequenceMatching; mSequenceMatchingLength = sequenceMatchingLength; //DevIL init ilInit(); ilOriginFunc(IL_ORIGIN_UPPER_LEFT); ilEnable(IL_ORIGIN_SET); std::cout << "[BundlerMatcher]"<<std::endl; std::cout << "[Initialization]"; mIsInitialized = true; mMatchThreshold = matchThreshold; //0.0 means few match and 1.0 many match char fo[10]; sprintf(fo, "%d", firstOctave); char* args[] = {"-fo", fo}; mSift = new SiftGPU; mSift->ParseParam(2, args); mSift->SetVerbose(-2); int support = mSift->CreateContextGL(); if (support != SiftGPU::SIFTGPU_FULL_SUPPORTED) mIsInitialized = false; if (mIsInitialized) mSift->AllocatePyramid(1600, 1600); mMatcher = new SiftMatchGPU(4096); }
TextureReaderDevil::TextureReaderDevil() { name_ = "DevIL Reader"; extensions_.push_back("bmp"); extensions_.push_back("cut"); extensions_.push_back("dcx"); extensions_.push_back("dds"); extensions_.push_back("ico"); extensions_.push_back("gif"); extensions_.push_back("jpg"); extensions_.push_back("jpeg"); extensions_.push_back("lbm"); extensions_.push_back("lif"); extensions_.push_back("mdl"); extensions_.push_back("pcd"); extensions_.push_back("pcx"); extensions_.push_back("pic"); extensions_.push_back("png"); extensions_.push_back("pnm"); extensions_.push_back("psd"); extensions_.push_back("psp"); extensions_.push_back("raw"); extensions_.push_back("sgi"); extensions_.push_back("tga"); extensions_.push_back("tif"); extensions_.push_back("wal"); extensions_.push_back("act"); extensions_.push_back("pal"); extensions_.push_back("hdr"); // Initialize DevIL ilInit(); ilOriginFunc(IL_ORIGIN_LOWER_LEFT); ilEnable(IL_ORIGIN_SET); // Flip images }
//Bind a 2D texture to OpenGL. GLuint Utils::bind2DTexture(std::string filename) { ILuint ilTextureID; ILboolean success; GLuint glTextureID; if(ilGetInteger(IL_VERSION_NUM) < IL_VERSION) return -1; ilInit(); ilGenImages(1, &ilTextureID); ilBindImage(ilTextureID); success = ilLoadImage((const ILstring)(std::string(TEXTURE_FILE_PATH) + filename).c_str()); if(success) { glGenTextures(1, &glTextureID); glBindTexture(GL_TEXTURE_2D, glTextureID); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexImage2D(GL_TEXTURE_2D, 0, ilGetInteger(IL_IMAGE_FORMAT), ilGetInteger(IL_IMAGE_WIDTH), ilGetInteger(IL_IMAGE_HEIGHT), 0, ilGetInteger(IL_IMAGE_FORMAT), GL_UNSIGNED_BYTE, ilGetData()); glGenerateMipmap(GL_TEXTURE_2D); ilDeleteImages(1, &ilTextureID); } else return -1; return glTextureID; }