void SimpleDeviceWindow::Play() { CreateNativeWindow(); CreateInterface(); CreateDevice(); Init3D(); m_timer.Reset(); while(!m_exit) { m_timer.Set(); MessageLoop(); Render(m_timer.m_elapsed); } Dispose(); }
bool CEGLNativeTypeIMX::SetNativeResolution(const RESOLUTION_INFO &res) { if (m_readonly) return false; std::string mode; SysfsUtils::GetString("/sys/class/graphics/fb0/mode", mode); if (res.strId == mode) return false; DestroyNativeWindow(); DestroyNativeDisplay(); ShowWindow(false); SysfsUtils::SetString("/sys/class/graphics/fb0/mode", res.strId + "\n"); CreateNativeDisplay(); CreateNativeWindow(); CLog::Log(LOGDEBUG, "%s: %s",__FUNCTION__, res.strId.c_str()); return true; }
/*!***************************************************************************************************************************************** @Function main @Input argc Number of arguments passed to the application, ignored. @Input argv Command line strings passed to the application, ignored. @Return Result code to send to the Operating System @Description Main function of the program, executes other functions. *******************************************************************************************************************************************/ int main(int /*argc*/, char **/*argv*/) { // X11 variables Display* nativeDisplay = NULL; Window nativeWindow = 0; // EGL variables EGLDisplay eglDisplay = NULL; EGLConfig eglConfig = NULL; EGLSurface eglSurface = NULL; EGLContext eglContext = NULL; // A vertex buffer object to store our model data. GLuint vertexBuffer = 0; // Get access to a native display if (!CreateNativeDisplay(&nativeDisplay)) { goto cleanup; } // Setup the windowing system, create a window if (!CreateNativeWindow(nativeDisplay, &nativeWindow)) { goto cleanup; } // Create and Initialise an EGLDisplay from the native display if (!CreateEGLDisplay(nativeDisplay, eglDisplay)) { goto cleanup; } // Choose an EGLConfig for the application, used when setting up the rendering surface and EGLContext if (!ChooseEGLConfig(eglDisplay, eglConfig)) { goto cleanup; } // Create an EGLSurface for rendering from the native window if (!CreateEGLSurface(nativeWindow, eglDisplay, eglConfig, eglSurface)) { goto cleanup; } // Setup the EGL Context from the other EGL constructs created so far, so that the application is ready to submit OpenGL ES commands if (!SetupEGLContext(eglDisplay, eglConfig, eglSurface, eglContext)) { goto cleanup; } // Initialise the vertex data in the application if (!InitialiseBuffer(vertexBuffer)) { goto cleanup; } // Renders a triangle for 800 frames using the state setup in the previous function for (int i = 0; i < 800; ++i) { if (!RenderScene(eglDisplay, eglSurface, nativeDisplay)) { break; } } // Release any resources we created in the Initialise functions DeInitialiseBuffer(vertexBuffer); cleanup: // Release the EGL State ReleaseEGLState(eglDisplay); // Release the windowing system resources ReleaseNativeResources(nativeDisplay, nativeWindow); // Destroy the eglWindow return 0; }
//-------------------------------------------------------------------------------------- // Name: Run() // Desc: Create the framework, initialize the application, and render frames. //-------------------------------------------------------------------------------------- BOOL CFrmAppContainer::Run() { m_pApplication = FrmCreateApplicationInstance(); if( NULL == m_pApplication ) return FALSE; // Create the application window if( FALSE == CreateNativeWindow( &m_hWindow, &m_hDisplay ) ) return FALSE; // Create the render context if( FALSE == m_pApplication->CreateRenderContext( m_hWindow, m_hDisplay ) ) { MessageBox( NULL, L"Application failed to create render context!\n" L"\n" L"Please debug accordingly.", NULL, MB_ICONERROR ); return FALSE; } //if(strcmp(_CRT_STRINGIZE(PLATFORM), "OPENGLES") == 0) //{ // eglBindAPI( EGL_OPENGL_ES_API ); // eglMakeCurrent( m_pApplication->m_eglDisplay, m_pApplication->m_eglSurface, m_pApplication->m_eglSurface, m_pApplication->m_eglContextGL ); //} //else //{ // eglBindAPI( EGL_OPENVG_API ); // eglMakeCurrent( m_pApplication->m_eglDisplay, m_pApplication->m_eglSurface, m_pApplication->m_eglSurface, m_pApplication->m_eglContextVG ); //} if( ( FALSE == m_pApplication->Initialize() ) || ( FALSE == m_pApplication->Resize() ) ) { MessageBox( NULL, L"Application failed during scene initialization!\n" L"\n" L"Please debug accordingly.", NULL, MB_ICONERROR ); return FALSE; } // Re-register the VK_SNAPSHOT hotkey so we can trap the PrtScn key for screen captures UnregisterHotKey( GetParent( (HWND)m_hWindow ), IDHOT_SNAPWINDOW ); RegisterHotKey( GetParent( (HWND)m_hWindow ), IDHOT_SNAPWINDOW, 0, VK_SNAPSHOT ); // Show the parent window ShowWindow( GetParent( (HWND)m_hWindow ), TRUE ); ShowWindow( (HWND)m_hWindow, SW_SHOW ); SetForegroundWindow( (HWND)m_hWindow ); SetFocus( (HWND)m_hWindow ); // Run the main loop while( HandleEvents() ) { // Update and render the application m_pApplication->Update(); m_pApplication->Render(); // Present the scene m_pApplication->SwapDrawBuffers(); } return TRUE; }