/* Initializes the third party softwares * @param void * @return void */ void OBJLoader::devilStartUp() { ilutRenderer(ILUT_OPENGL); ilInit(); iluInit(); ilutInit(); ilutRenderer(ILUT_OPENGL); }
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(); }
//----------------------------------------------------------------------------- //Функция инициализации 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(); }
void initDebugDraw() { ilInit(); iluInit(); ilutInit(); ilutRenderer(ILUT_OPENGL); }
//----------------------------------------------------------------------------- // 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; }
// // Private members // void ilImage::iStartUp() { ilInit(); iluInit(); ilutInit(); return; }
void Application::initializeDevIL() { ilInit(); iluInit(); ilutInit(); ilutRenderer(ILUT_OPENGL); ilutEnable(ILUT_OPENGL_CONV); }
void devil_init() { ilInit(); iluInit(); ilutInit(); ilutRenderer(ILUT_OPENGL); ilutEnable(ILUT_OPENGL_CONV); }
void sceneLoader::initDevIL() { ilutRenderer(ILUT_OPENGL); ilInit(); iluInit(); ilutInit(); ilutRenderer(ILUT_OPENGL); }
void QtInterface::initializeGL() { qDebug("GL Init"); if ( ilGetInteger(IL_VERSION_NUM) < IL_VERSION || iluGetInteger(ILU_VERSION_NUM) < ILU_VERSION || ilutGetInteger(ILUT_VERSION_NUM) < ILUT_VERSION) { printf("DevIL version is different...exiting!\n"); Engine()->Stop(); } ilInit(); iluInit(); ilutInit(); ilutRenderer( ILUT_OPENGL ); // Enable alpha glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glAlphaFunc(GL_GREATER,0.1); glDisable(GL_ALPHA_TEST); glDisable( GL_DEPTH_TEST ); /* // By checking this, we can enable some more efficient ways of rendering sprites if ( glh_extension_supported("GL_NV_texture_rectangle") ) { qDebug("NV texture rectangle supported!"); //glEnable( GL_TEXTURE_RECTANGLE_NV ); } else if ( glh_extension_supported("GL_EXT_texture_rectangle") ) { qDebug("EXT texture rectangle supported!"); //glEnable( GL_TEXTURE_RECTANGLE_EXT ); } else { qDebug("No texture rectangle support"); } */ //TODO: Engine()->Precache(); /* int width=1020, height=768; glViewport(0,0, (GLsizei)width, (GLsizei)height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(60, (GLfloat)width / (GLfloat)height, 1.0f, 100.0f); glMatrixMode(GL_MODELVIEW); */ glClearColor(0,0,0,0); //glClearColor(1.0f, 0.0f, 0.0f, 1.0f); setFocusPolicy(Qt::StrongFocus); m_flFPS = 0.0f; m_flLastTime = 0.0f; }
bool CCLUDrawBase::Init() { float *pfCol = m_BGCol.Data(); glClearColor(pfCol[0], pfCol[1], pfCol[2], pfCol[3]); glEnable( GL_DEPTH_TEST ); glEnable( GL_CULL_FACE ); //glEnable( GL_POINT_SMOOTH ); //glEnable( GL_LINE_SMOOTH ); //glEnable( GL_POLYGON_SMOOTH ); /* #ifdef CLUDRAW_USE_VEX_ARRAY glEnableClientState( GL_VERTEX_ARRAY ); #endif */ glMatrixMode(GL_PROJECTION); glLoadIdentity(); m_sPer.fAspect = float(m_iSizeX) / float(m_iSizeY); m_sOrtho.fLeft = -float(m_iSizeX) * 0.5f * m_fOrthoFac; m_sOrtho.fRight = float(m_iSizeX) * 0.5f * m_fOrthoFac; m_sOrtho.fBottom = -float(m_iSizeY) * 0.5f * m_fOrthoFac; m_sOrtho.fTop = float(m_iSizeY) * 0.5f * m_fOrthoFac; m_sOrtho.fNear = -100.0f; m_sOrtho.fFar = 100.0f; gluPerspective(m_sPer.fAngle, m_sPer.fAspect, m_sPer.fNear, m_sPer.fFar); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glShadeModel(GL_SMOOTH); if (m_bUseLighting) { glEnable(GL_LIGHTING); m_StdMaterial.Face(GL_FRONT); m_StdMaterial.Ambient(0.5f, 0.5f, 0.5f, 1.0f); m_StdMaterial.Diffuse(1.0f, 1.0f, 1.0f, 1.0f); m_StdMaterial.Specular(0.8f, 0.8f, 0.8f, 1.0f); m_StdMaterial.Shininess(50.0f); m_StdMaterial.Apply(); ResetLights(); glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT, GL_AMBIENT); } //glBlendFunc(GL_SRC_ALPHA, GL_SRC_ALPHA); ilutInit(); glDisable(GL_TEXTURE_2D); return true; }
//================================================================================================// void Engine::InitDevil() { gLog.OutPut("\n[Initializing Devil]\n"); ilInit(); iluInit(); ilutInit(); ilutRenderer(ILUT_OPENGL); gLog.OutPut("Complete...\n\n"); }
//--------------------------------------------------------------------- // Function: Initialize // Description: Initialization like InitInstace // Parameters: . // Returns: TRUE, if successful //--------------------------------------------------------------------- BOOL CObjectTexture::Initialize() { CString tName; HINSTANCE appInst; CMDIFrameWnd *mainWnd; // Register the doc templates we provide to the app CWinApp* pApp = AfxGetApp(); ASSERT(pApp != NULL); if (pApp == NULL) { return FALSE; } mainWnd = DYNAMIC_DOWNCAST(CMDIFrameWnd, pApp->m_pMainWnd); // get the apps instance handle for loading resources appInst = AfxGetResourceHandle(); // now tell the application to look in dll for resources AfxSetResourceHandle(ObjectTextureDLL.hModule); // use my string / icon resources // *** note IDR_TEXTURE type needs to be unique ID even between // dlls m_DocTemplate = new CMultiDocTemplate(IDR_TEXTURETYPE, RUNTIME_CLASS(CTextureDoc), RUNTIME_CLASS(CMDIChildWnd), RUNTIME_CLASS(CTextureView)); pApp->AddDocTemplate(m_DocTemplate); VERIFY(MergeMenus(&m_DocTemplate->m_hMenuShared, *(m_ProgramInfo->curMenu), _T("&Window"))); VERIFY(MergeAccelerators(&m_DocTemplate->m_hAccelTable, *(m_ProgramInfo->curAccel))); // Initialze the image library ilInit(); iluInit(); ilutInit(); // construct resource info m_ObjInfo.name.LoadString(IDS_OBJECT_NAME); m_ObjInfo.pageIndex = &m_PageIndex; m_ObjInfo.icon = (HICON)LoadImage(ObjectTextureDLL.hModule, MAKEINTRESOURCE(IDR_TEXTURETYPE), IMAGE_ICON, 0, 0, LR_CREATEDIBSECTION); VERIFY(m_ObjInfo.icon != NULL); // value should be 1 - 1000 m_ObjInfo.priority = IDR_TEXTURETYPE; m_ObjInfo.objFlags = OBJFLAGS_EXPORTABLE | OBJFLAGS_IMPORTABLE | OBJFLAGS_THUMBNAIL; AfxSetResourceHandle(appInst); return TRUE; }
TextureManager::TextureManager(const std::string _presetURL): presetURL(_presetURL) { #ifdef USE_DEVIL ilInit(); iluInit(); ilutInit(); ilutRenderer(ILUT_OPENGL); #endif Preload(); loadTextureDir(); }
void InitializeTextureLoading() { #if !_ANGEL_DISABLE_DEVIL ilInit(); iluInit(); ilutInit(); glDisable(GL_TEXTURE_2D); // Convert any paletted images ilEnable(IL_CONV_PAL); // Allegedly gets rid of dithering on some nvidia cards. ilutEnable(ILUT_OPENGL_CONV); #endif }
void Renderer::init() { int c = 0; glutInit(&c, 0); glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGB); glutInitWindowSize(800, 600); glutInitWindowPosition(100, 100); glutCreateWindow("vxc"); glewInit(); prn("OpenGL version: %s\n", (char*)glGetString(GL_VERSION)); prn("OpenGL renderer: %s\n", (char*)glGetString(GL_RENDERER)); ilInit(); iluInit(); ilutInit(); }
int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); glutInitWindowSize(1280, 720); glutInitWindowPosition((glutGet(GLUT_SCREEN_WIDTH)-1280)/2, (glutGet(GLUT_SCREEN_HEIGHT)-720)/2); glutCreateWindow("Real Time Physics - Lab 3 - Broad Phase Collisions - AABB Sweep and Prune"); //glutGameModeString("1280x720@32"); //glutEnterGameMode(); glEnable(GL_DEPTH_TEST); //glEnable(GL_LINE_SMOOTH); //glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); //glEnable(GL_POINT_SMOOTH); //glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); //glEnable(GL_BLEND); //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //glEnable(GL_MULTISAMPLE); //glHint(GL_MULTISAMPLE_FILTER_HINT_NV, GL_NICEST); InitialiseCallbacks(); GLenum res = glewInit(); if (res != GLEW_OK) { fprintf(stderr, "Error: '%s'\n", glewGetErrorString(res)); return 1; } glClearColor(0.3f, 0.3f, 0.3f, 1.0f); ilInit(); iluInit(); ilutInit(); ilutRenderer(ILUT_OPENGL); InitialiseScene(); glutMainLoop(); return 0; }
int main(int argc, char *argv[]) { int retval; int image; ilInit(); iluInit(); ilutInit(); ilGenImages(1, &image); ilBindImage(image); ilOriginFunc(IL_ORIGIN_LOWER_LEFT); retval = MLMain(argc, argv); ilDeleteImages(1, &image); ilShutDown(); // Only need to shut down DevIL, not ILU or ILUT return retval; }
int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_MULTISAMPLE); glutInitWindowSize(1280, 720); glutInitWindowPosition((glutGet(GLUT_SCREEN_WIDTH)-1280)/2, (glutGet(GLUT_SCREEN_HEIGHT)-720)/2); glutCreateWindow("Real Time Physics - Lab 2 - Rigid Bodies & Springs"); glEnable(GL_DEPTH_TEST); glEnable(GL_LINE_SMOOTH); glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); glEnable(GL_POINT_SMOOTH); glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); glEnable(GL_MULTISAMPLE); glHint(GL_MULTISAMPLE_FILTER_HINT_NV, GL_NICEST); InitialiseCallbacks(); GLenum res = glewInit(); if (res != GLEW_OK) { fprintf(stderr, "Error: '%s'\n", glewGetErrorString(res)); return 1; } glClearColor(0.0f, 0.0f, 0.0f, 0.0f); ilInit(); iluInit(); ilutInit(); ilutRenderer(ILUT_OPENGL); InitialiseScene(); glutMainLoop(); return 0; }
//----------------------------------------------------------------------------- //Функция инициализации void init() { //Инициализация DevIL ilInit(); iluInit(); ilutInit(); Load_Tex_Image(); glEnable(GL_TEXTURE_2D); glViewport( 0, 0, WinWidth, WinHeight ); glClearColor(0.9f, 0.9f, 0.9f, 0.0f); glClearDepth(1.0); glDepthFunc(GL_LESS); glEnable(GL_DEPTH_TEST); glShadeModel(GL_SMOOTH); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective( 45.0f, (GLfloat)WinWidth/(GLfloat)WinHeight, 0.1f, 100.0f ); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // glPolygonMode( GL_BACK, GL_FILL ); // нижняя (задняя) сторона заполнена // glPolygonMode( GL_FRONT, GL_LINE ); // верхняя (передняя) сторона прорисована линиями for(int x=0; x<45; x++) { for(int y=0; y<45; y++) { // применим волну к нашей сетке points[x][y][0]=float((x/5.0f)-4.5f); points[x][y][1]=float((y/5.0f)-4.5f); points[x][y][2]=float(sin((((x/5.0f)*40.0f)/360.0f)*3.141592654*2.0f)); } } }
void Application::startDevIL() { TRACE("Initializing DevIL..."); TRACE("Linked against IL with IL_VERSION of " + itoa(IL_VERSION)); TRACE("Linked against ILU with ILU_VERSION of " + itoa(ILU_VERSION)); TRACE("Linked against ILUT with ILUT_VERSION of " + itoa(ILUT_VERSION)); // First, check the DevIL image library's version if(ilGetInteger(IL_VERSION_NUM) < IL_VERSION) { FAIL("IL_VERSION_NUM is different than expected!"); } if(ilGetInteger(ILU_VERSION_NUM) < ILU_VERSION) { FAIL("ILU_VERSION_NUM is different than expected!"); } if(ilGetInteger(ILUT_VERSION_NUM) < ILUT_VERSION) { FAIL("ILUT_VERSION_NUM is different than expected!"); } /* Then, Initialize the DevIL image library The docs say this step isn't necessary as long as we use a shared library when linking to DevIL. However, it suggests we do it anyway to ease a few sorts of particular problems. */ ilInit(); iluInit(); ilutInit(); TRACE("...DevIL initialized successfully"); }
int main() { //Init the game Game *Robopocalypse = new Game; //Open a window for the game Robopocalypse->OpenWindow(1280, 720); //Init GLEW glewExperimental = GL_TRUE; GLenum err = glewInit(); if (err != GLEW_OK) std::cout << "glewInit() Error\n"; //Init DevIL ilInit(); iluInit(); ilutInit(); ilutRenderer(ILUT_OPENGL); //Init OpenGL initOpenGL(); //Load a blank image into spot #1 using this for objects that dont have a normal map, there is probably a way better way of doing this... loadTexture("Resources/NormalMaps/blank.png"); //Robopocalypse->initGameplay(); Robopocalypse->initMainMenu(); //Set the time to zero before running the game loop so we know it starts from scratch. glfwSetTime(0.0f); float deltaTime = 0.0f; double timeOfLastUpdate = 0.0f; //While the window is open run the game while (Robopocalypse->GetIfRunning()) { //Update the deltaTime deltaTime = glfwGetTime() - timeOfLastUpdate; //Makes sure there has been enough time between updates before rendering to the screen. if (deltaTime >= FPS_REFRESH_CAP) { if (Robopocalypse->GetState() == STATE_GAMEPLAY) { Robopocalypse->Update(); Robopocalypse->Render(); } else if (Robopocalypse->GetState() == STATE_MAINMENU) { Robopocalypse->GetMenu()->Update(Robopocalypse); Robopocalypse->GetMenu()->Render(); } //Reset the time between updates deltaTime = 0.0f; timeOfLastUpdate = glfwGetTime(); } } //Shutdown gldw glfwTerminate(); //End the program return 0; }
int main(int argc, char** argv) { // No filename is specified on the command-line. if (argc < 2) { printf ("Please run as:\n\nDevIL_testGL image_filename\n"); return 1; } FileName = argv[1]; // Set filename equal to the first argument. // // Check if the shared lib's version matches the executable's version. // // // fixed to get the right numbers from the right library call... // if (ilGetInteger(IL_VERSION_NUM) < IL_VERSION || iluGetInteger(ILU_VERSION_NUM) < ILU_VERSION || ilutGetInteger(ILUT_VERSION_NUM) < ILUT_VERSION) { printf ("DevIL library is out of date! Please upgrade\n"); return 2; } // Needed to initialize DevIL. ilInit (); iluInit(); // GL cannot use palettes anyway, so convert early. ilEnable (IL_CONV_PAL); // Gets rid of dithering on some nVidia-based cards. ilutEnable (ILUT_OPENGL_CONV); // Generate the main image name to use. ilGenImages (1, &ImgId); // Bind this image name. ilBindImage (ImgId); // Loads the image specified by File into the ImgId image. if (!ilLoadImage(FileName)) { HandleDevILErrors (); } // Make sure the window is in the same proportions as the image. // Generate the appropriate width x height less than or equal to MAX_X x MAX_Y. // Instead of just clipping Width x Height to MAX_X x MAX_Y, we scale to // an appropriate size, so the image isn't stretched/squished. Width = ilGetInteger (IL_IMAGE_WIDTH); Height = ilGetInteger (IL_IMAGE_HEIGHT); if (Width > 0) { // Don't want a divide by 0... if (Width > MAX_X) { Width = MAX_X; Height = (ILuint)(MAX_X / (ILfloat)ilGetInteger(IL_IMAGE_WIDTH) * Height); } } if (Height > 0) { // Don't want a divide by 0... if (Height > MAX_Y) { Height = MAX_Y; Width = (ILuint)(MAX_Y / (ILfloat)ilGetInteger(IL_IMAGE_HEIGHT) * Width); } } HandleDevILErrors (); // Standard glut initializations. glutInit (&argc, argv); // Standard glut initialization. glutInitDisplayMode (GLUT_RGB | GLUT_DOUBLE); glutInitWindowPosition (100, 100); glutInitWindowSize (Width, Height); window = glutCreateWindow("Developer's Image Library (DevIL) Test"); ilutInit(); glutDisplayFunc (DisplayFunc); glutKeyboardFunc (KeyboardFunc); // Goes into our setup function. if (Setup() == IL_FALSE) return 1; // Enter the main (Free)GLUT processing loop glutMainLoop(); // Clean up any loose ends. CleanUp(); return 0; }
/* inicjuje * -oswietlenie * -cieniowanie * -biblioteke glut * -wspolprace z systemem okienkowym */ void init() { GLenum err = glewInit(); if (GLEW_OK != err) { std::cout << "GLEW initialisation error: " << glewGetErrorString(err) << std::endl; exit(-1); } std::cout << "GLEW intialised successfully. Using GLEW version: " << glewGetString(GLEW_VERSION) << std::endl; GLfloat mat_ambient[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat mat_diffuse[] = { 0.5, 0.5, 0.5, 1.0 }; GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat light1_position[] = { 10.0, 5.0, 10.0, 1.0 }; GLfloat light2_position[] = { -10.0, 10.0, -10.0, 1.0 }; GLfloat light3_position[] = { 10.0, 10.0, -10.0, 1.0 }; GLfloat light4_position[] = { -10.0, 10.0, 10.0, 1.0 }; GLfloat lm_ambient[] = { 0.2, 0.2, 0.2, 1.0 }; glMaterialfv( GL_FRONT, GL_AMBIENT, mat_ambient ); glMaterialfv( GL_FRONT, GL_SPECULAR, mat_specular ); glMaterialf( GL_FRONT, GL_SHININESS, 50.0 ); glLightfv( GL_LIGHT0, GL_POSITION, light1_position ); glLightfv( GL_LIGHT1, GL_POSITION, light2_position ); glLightfv(GL_LIGHT1, GL_DIFFUSE, mat_diffuse); glLightfv( GL_LIGHT2, GL_POSITION, light3_position ); glLightfv(GL_LIGHT2, GL_DIFFUSE, mat_diffuse); glLightfv( GL_LIGHT3, GL_POSITION, light4_position ); glLightfv(GL_LIGHT3, GL_DIFFUSE, mat_diffuse); glLightModelfv( GL_LIGHT_MODEL_AMBIENT, lm_ambient ); glEnable(GL_NORMALIZE); glShadeModel( GL_SMOOTH ); // obliczanie swiatla glEnable( GL_LIGHTING ); glEnable( GL_LIGHT0 ); glEnable( GL_LIGHT1 ); glEnable( GL_LIGHT2 ); glEnable( GL_LIGHT3 ); glDepthFunc( GL_LESS ); glEnable( GL_DEPTH_TEST ); //glBlendFunc (GL_SRC_ALPHA, GL_ONE); // DevIL sanity check if ( (iluGetInteger(IL_VERSION_NUM) < IL_VERSION) || (iluGetInteger(ILU_VERSION_NUM) < ILU_VERSION) || (ilutGetInteger(ILUT_VERSION_NUM) < ILUT_VERSION) ) { std::cout << "DevIL versions are different... Exiting." << std::endl; exit(-1); } // Initialise all DevIL functionality ilInit(); iluInit(); ilutInit(); ilutRenderer(ILUT_OPENGL); // Tell DevIL that we're using OpenGL for our rendering }
int main(int argc, char * argv[]) { glutInit(&argc , argv); glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE); glutInitWindowPosition(0 , 0); glutInitWindowSize(window_width, window_height); glutCreateWindow("Warp"); glutDisplayFunc(DisplayFunc); glutTimerFunc(1000 / 60, TimerFunc, 1000 / 60); glutReshapeFunc(ReshapeFunc); glutSpecialFunc(SpecialFunc); glutKeyboardFunc(KeyboardFunc); glutMouseFunc(MouseFunc); glutMotionFunc(MotionFunc); glutCloseFunc(CloseFunc); glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION); glEnable(GL_DEPTH_TEST); ilInit(); iluInit(); ilutInit(); ilutRenderer(ILUT_OPENGL); if (glewInit() != GLEW_OK) { cerr << "GLEW failed to initialize." << endl; return 0; } if (!shader.Initialize("stub.vert", "stub.frag")) { return 0; } if (!background.Initialize("back.vert", "back.frag")) { return 0; } image_1_handle = ilutGLLoadImage("lotr-scene.jpg"); image_1_w = ilGetInteger(IL_IMAGE_WIDTH); image_1_h = ilGetInteger(IL_IMAGE_HEIGHT); tex_handle = ilutGLLoadImage("Home-Theater.jpg"); tex_w = ilGetInteger(IL_IMAGE_WIDTH); tex_h = ilGetInteger(IL_IMAGE_HEIGHT); left_overlay_handle = ilutGLLoadImage("left-over.jpg"); right_overlay_handle = ilutGLLoadImage("right-over.jpg"); left_curtain_handle = ilutGLLoadImage("left-curtain.jpg"); cout << "Image 1: " << image_1_w << " x " << image_1_h << endl; cout << "Background: " << tex_w << " x " << tex_h << endl; if (!frame.Initialize(glm::ivec2(image_1_w, image_1_h), 1, true)) { cerr << "Frame buffer 1 failed to initialize." << endl; return 0; } cout << "Window Size: " << window_width << " x " << window_height << endl; cout << "Frame buffer 1 size: " << frame.size.x << " x " << frame.size.y << endl; glutMainLoop(); return 0; }
void EditorUI::Initialize () { optimizeOnLoad=true; archives.Load (); ilInit (); ilutInit(); ilutRenderer(ILUT_OPENGL); callback.ui = this; new BackupManager(&callback); objectViewer = new ObjectView (this, objectTree); uiIK = new IK_UI (&callback); uiTimeline = new TimelineUI (&callback); uiAnimTrackEditor = new AnimTrackEditorUI (&callback, uiTimeline); uiRotator = new RotatorUI; uiRotator->CreateUI(&callback); uiBackupViewer = new BackupViewerUI(&callback); tools.SetEditor (&callback); tools.camera->button = selectCameraTool; tools.move->button = selectMoveTool; tools.rotate->button = selectRotateTool; tools.scale->button = selectScaleTool; tools.texmap->button = selectTextureTool; tools.color->button = selectColorTool; tools.flip->button = selectFlipTool; tools.originMove->button = selectOriginMoveTool; tools.rotateTex->button = selectRotateTexTool; tools.toggleCurvedPoly->button = selectCurvedPolyTool; tools.LoadImages(); currentTool = tools.GetDefaultTool (); modelDrawer = new ModelDrawer; model = 0; SetModel (new Model); UpdateTitle(); textureHandler = new TextureHandler (); for (set<string>::iterator arch=archives.archives.begin();arch!=archives.archives.end();++arch) textureHandler->Load (arch->c_str()); textureGroupHandler = new TextureGroupHandler (textureHandler); textureGroupHandler->Load ((applicationPath + TextureGroupConfig).c_str()); UpdateTextureGroups(); InitTexBrowser(); uiMapping = new MappingUI (&callback); uiTexBuilder = new TexBuilderUI (0,0); LoadSettings(); // create 4 views if no views were specified in the config (ie: there was no config) if (!viewsGroup->children()) { viewsGroup->begin(); EditorViewWindow *views[4]; int vw = viewsGroup->w (); int vh = viewsGroup->h (); for (int a=0;a<4;a++) { int Xofs=(a&1)*vw/2; int Yofs=(a&2)*vh/4; int W=vw/2; int H=vh/2; if (Xofs) W = vw-Xofs; if (Yofs) H = vh-Yofs; views[a]=new EditorViewWindow (Xofs, Yofs, W,H, &callback); views[a]->SetMode(a); views[a]->bDrawRadius = false; } views[3]->rendermode = M3D_TEX; viewsGroup->end(); } BACKUP_POINT("New model"); }
/// render void view::render() { // Clear Screen And Depth Buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); if (!m_world) { return; } if(ortho_sh) { glClearColor(0,0,0,1); modifiedmesh_drawable->set_render_faces(true); modifiedmesh_drawable->set_render_edges(false); modifiedmesh_drawable->set_render_normals(false); modifiedmesh_drawable->set_render_vertices(false); modifiedmesh_drawable->render(); glFlush(); int size = w()*h()*3; unsigned char *data = new unsigned char[size]; glReadPixels(0,0, w(), h(),GL_RGB,GL_UNSIGNED_BYTE,data); ilInit(); iluInit(); ilutInit(); ILuint ImageName; ilGenImages(1, &ImageName); ilBindImage(ImageName); ilTexImage(w(),h(),1,3,IL_RGB,IL_UNSIGNED_BYTE,data); //iluFlipImage(); ilEnable(IL_FILE_OVERWRITE); #ifdef _WIN32 // Did not compile in linux: ilSaveImage(reinterpret_cast<const wchar_t *>(filename_screenshot.c_str())); #else ilSaveImage(filename_screenshot.c_str()); #endif delete[] data; glClearColor(0.80f, 0.80f, 0.90f, 1.0f); } else { // Reset Modelview: glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glEnable(GL_BLEND); glEnable(GL_DEPTH_TEST); // Set modelviewmatrix m = translate_44(0.0f, 0.0f, -cam_distance) * rotate_x_44(cam_polar) * rotate_y_44(cam_azimut) * translate_44(-cam_target.x(), -cam_target.y(), -cam_target.z() ); // Transpose (here: invert) matrix: Mat44f mat_trans = transpose(m); point3f camera_pos(0.0, 0.0, 0.0); camera_pos = invert(m) * camera_pos; glLoadMatrixf( &mat_trans(0,0) ); // Create light components GLfloat ambientLight[] = { 0.0f, 0.0f, 0.0f, 1.0f }; GLfloat diffuseLight[] = { 1.0f, 1.0f, 1.0f, 1.0f }; GLfloat specularLight[] = { 1.0f, 1.0f, 1.0f, 1.0f }; GLfloat position[] = { 1.0f, 1.0f, 1.0f, 0.0f }; GLfloat globalAmbient[] = { 0.2f, 0.2f, 0.2f, 1.0f}; glLightModelfv(GL_LIGHT_MODEL_AMBIENT, globalAmbient); // Assign created components to GL_LIGHT1 glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight); glLightfv(GL_LIGHT0, GL_SPECULAR, specularLight); glLightfv(GL_LIGHT0, GL_POSITION, position); Rendering::RenderingInfo info( camera_pos, m_noise_tex ); /* render the world */ m_world->render( info ); renderCoordinateSystem(); //render_noise_texture(); } }