//int openMeshViewer(int argc, char* argv[]) void openMeshViewerAnim(VectListCTriangle3d input, VectCPoint3d points) { inputMeshes = input; inputPoints = points; //readAndInitMesh("C:\\Users\\Iaia\\Downloads\\dragon_recon\\dragon_recon\\dragon_vrip_res4.ply"); int argc = 1; char *argv[1]; argv[0]="test.exe"; glutInit(&argc, argv); glutInitWindowSize(1024,700); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutCreateWindow("Simple Mesh Viewer :: Larmor"); InitRenderer(); glutDisplayFunc(Draw); glutReshapeFunc(ReshapeWindow); glutMouseFunc(HandleMouseState); glutMotionFunc(HandleMouseMove); glutSpecialFunc(processSpecialKeys); glutKeyboardFunc(HandleKeyboard); glutIdleFunc(animate); glutMainLoop(); }
void PlotDefC::BasicFullDraw() { InitRenderer(); SetupDataView(); DrawAllObjects(); CloseRenderer(); }
void GraphicsRenderer::Init(std::string title, int width, int height) { width_ = width; height_ = height; InitWindow(title); InitRenderer(); }
int IApp::Run(void) { SLOG(App_Run,SeverityInfo) << std::endl; // First set our Running flag to true mRunning = true; // Register our App pointer with our StatManager mStatManager.RegisterApp(this); // Register our App pointer with our StateManager mStateManager.RegisterApp(this); // First register the IAssetHandler derived classes in the GQE Core library mAssetManager.RegisterHandler(new(std::nothrow) ConfigHandler()); mAssetManager.RegisterHandler(new(std::nothrow) FontHandler()); mAssetManager.RegisterHandler(new(std::nothrow) ImageHandler()); mAssetManager.RegisterHandler(new(std::nothrow) MusicHandler()); mAssetManager.RegisterHandler(new(std::nothrow) SoundHandler()); // Give derived class a time to register custom IAssetHandler classes InitAssetHandlers(); // Attempt to open the application wide settings.cfg file as a ConfigAsset // registered under the ID of "resources/settings.cfg" InitSettingsConfig(); // Try to open the Renderer window to display graphics InitRenderer(); // Give the derived application a chance to register a IScreenFactory class // to provide IScreen derived classes (previously known as IState derived // classes) as requested. InitScreenFactory(); // Give the StatManager a chance to initialize mStatManager.DoInit(); // GameLoop if Running flag is still true GameLoop(); // Cleanup our application HandleCleanup(); // Perform our own internal Cleanup Cleanup(); // Make sure our Running flag is set to false before exiting mRunning = false; if(mExitCode < 0) SLOGR(App_Run,SeverityError) << "exitCode=" << mExitCode << std::endl; else SLOGR(App_Run,SeverityInfo) << "exitCode=" << mExitCode << std::endl; // Return the Exit Code specified by Quit or 0 of Quit was never called return mExitCode; }
bool CSnowboard::InitModule( HWND hWnd ) { LOGGER.Init(NULL , NULL , NULL , NULL ); FRAMEMEMORY.Init( 1024 * 1024 ); LOG_WARNING( "Init FrameMemory = %d Byte" , FRAMEMEMORY.GetSize() ); InitRenderer( hWnd ); InitResource( m_pRenderer->GetDevice() ); TestFunc(); return true; }
bool Game::Init( void ) { //Profiler::Init(); //Profiler::Begin("Game"); Logger::WriteLine( "SYS | Initializing Iris...." ); InitRenderer( Config::GetMulPath() ); pCamera.Reset(); pTextManager = new cTextManager(); CreateSinTable(); pDynamicObjectList.Clear(); pDynamicObjectList.OnAdd( OnAddDynamic ); pDynamicObjectList.OnDelete( OnDeleteDynamic ); pCharacterList.Clear(); pCharacterList.OnAdd( OnAddCharacter ); pCharacterList.OnDelete( OnDeleteCharacter ); Logger::WriteLine( "\t| -> loading particles" ); pParticleLoader.Init( "xml/particles.xml" ); Logger::WriteLine( "\t| -> renderer" ); m_kRenderer = new Renderer3D(); if ( !m_kRenderer->Init() ) { return false; } SetPosition( Config::GetStartX(), Config::GetStartY(), Config::GetStartZ() ); SetPause( true ); m_click_mode = CLICK_NORMAL; //Profiler::End(); //Profiler::Output(); return true; }
void CWindow::CreateRenderWindow(const char* title, int posX, int posY, const int &C_WIDTH, const int &C_HEIGHT, VSYNC syncState, Uint32 flags) { InitSDL(); mWindowWidth = C_WIDTH; mWindowHeight = C_HEIGHT; //Set texture filtering to linear if (!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1")) { std::cout << "Warning: Linear texture filtering not enabled." << std::endl; } mWindow = SDL_CreateWindow(title, posX, posY, mWindowWidth, mWindowHeight, SDL_WINDOW_OPENGL); if (mWindow == nullptr) { std::cout << "Could not create window! SDL Error: " << SDL_GetError() << std::endl; } InitRenderer(syncState); std::cout << "Render window successfully created." << std::endl; }
static int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { AllocConsole(); //create a console freopen( "conin$","r",stdin ); freopen( "conout$","w",stdout ); freopen( "conout$","w",stderr ); printf( "Program Started, console initialized\n" ); appInfo.appInstance = hInstance; const char WindowName[] = "Wet Clay"; appInfo.running = true; appInfo.isFullScreen = false; appInfo.mSecsPerFrame = 16; //60FPS appInfo.wc.cbSize = sizeof(WNDCLASSEX); appInfo.wc.style = CS_OWNDC; appInfo.wc.lpfnWndProc = WndProc; appInfo.wc.cbClsExtra = 0; appInfo.wc.cbWndExtra = 0; appInfo.wc.hInstance = appInfo.appInstance; appInfo.wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); appInfo.wc.hCursor = LoadCursor(NULL, IDC_ARROW); appInfo.wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); appInfo.wc.lpszMenuName = NULL; appInfo.wc.lpszClassName = WindowName; appInfo.wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); if( !RegisterClassEx( &appInfo.wc ) ) { printf( "Failed to register class\n" ); appInfo.running = false; return -1; } // center position of the window appInfo.windowPosX = (GetSystemMetrics(SM_CXSCREEN) / 2) - (SCREEN_WIDTH / 2); appInfo.windowPosY = (GetSystemMetrics(SM_CYSCREEN) / 2) - (SCREEN_HEIGHT / 2); // set up the window for a windowed application by default //long wndStyle = WS_OVERLAPPEDWINDOW; if( appInfo.isFullScreen ) { appInfo.windowPosX = 0; appInfo.windowPosY = 0; //change resolution before the window is created //SysSetDisplayMode(width, height, SCRDEPTH); //TODO: implement } // at this point WM_CREATE message is sent/received // the WM_CREATE branch inside WinProc function will execute here appInfo.hwnd = CreateWindowEx(0, WindowName, "Wet Clay App", WS_BORDER, appInfo.windowPosX, appInfo.windowPosY, SCREEN_WIDTH, SCREEN_HEIGHT, NULL, NULL, appInfo.appInstance, NULL); GetClientRect( appInfo.hwnd, appInfo.windowRect ); PIXELFORMATDESCRIPTOR pfd = { sizeof( PIXELFORMATDESCRIPTOR ), 1, PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, //Flags PFD_TYPE_RGBA, //The kind of framebuffer. RGBA or palette. 32, //Colordepth of the framebuffer. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, //Number of bits for the depthbuffer 0, //Number of bits for the stencilbuffer 0, //Number of Aux buffers in the framebuffer. 0, 0, 0, 0, 0 }; appInfo.deviceContext = GetDC( appInfo.hwnd ); int letWindowsChooseThisPixelFormat; letWindowsChooseThisPixelFormat = ChoosePixelFormat( appInfo.deviceContext, &pfd ); SetPixelFormat( appInfo.deviceContext, letWindowsChooseThisPixelFormat, &pfd ); appInfo.openglRenderContext = wglCreateContext( appInfo.deviceContext ); if( wglMakeCurrent ( appInfo.deviceContext, appInfo.openglRenderContext ) == false ) { printf( "Couldn't make GL context current.\n" ); return -1; } printf("Size of double:%d\n", sizeof( double ) ); glewInit(); MemorySlab gameSlab; gameSlab.slabSize = MEGABYTES( RESERVED_SPACE ); gameSlab.slabStart = VirtualAlloc( NULL, gameSlab.slabSize, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE ); assert( gameSlab.slabStart != NULL ); gameSlab.current = gameSlab.slabStart; SlabSubsection_Stack systemsMemory = CarveNewSubsection( &gameSlab, KILOBYTES( 12 ) ); SlabSubsection_Stack gameMemoryStack = CarveNewSubsection( &gameSlab, sizeof( GameMemory ) * 2 ); void* gMemPtr = AllocOnSubStack_Aligned( &gameMemoryStack, sizeof( GameMemory ) ); SoundSystemStorage* soundSystemStorage = Win32InitSound( appInfo.hwnd, 60, &systemsMemory ); RendererStorage* renderSystemStorage = InitRenderer( SCREEN_WIDTH, SCREEN_HEIGHT, &systemsMemory ); SetWindowLong( appInfo.hwnd, GWL_STYLE, 0 ); ShowWindow ( appInfo.hwnd, SW_SHOWNORMAL ); UpdateWindow( appInfo.hwnd ); BOOL canSupportHiResTimer = QueryPerformanceFrequency( &appInfo.timerResolution ); assert( canSupportHiResTimer ); GameInit( &gameSlab, gMemPtr, renderSystemStorage ); MSG Msg; do { while( PeekMessage( &Msg, NULL, 0, 0, PM_REMOVE ) ) { TranslateMessage( &Msg ); DispatchMessage( &Msg ); } static LARGE_INTEGER startTime; LARGE_INTEGER lastTime = startTime; QueryPerformanceCounter( &startTime ); //GAME LOOP if(appInfo.running) { XINPUT_STATE state; DWORD queryResult; memset( &state, 0, sizeof( XINPUT_STATE ) ) ; queryResult = XInputGetState( 0, &state ); if( queryResult == ERROR_SUCCESS ) { //Note: polling of the sticks results in the range not quite reaching 1.0 in the positive direction //it is like this to avoid branching on greater or less than 0.0 appInfo.controllerState.leftStick_x = ((float)state.Gamepad.sThumbLX / 32768.0f ); appInfo.controllerState.leftStick_y = ((float)state.Gamepad.sThumbLY / 32768.0f ); appInfo.controllerState.rightStick_x = ((float)state.Gamepad.sThumbRX / 32768.0f ); appInfo.controllerState.rightStick_y = ((float)state.Gamepad.sThumbRY / 32768.0f ); appInfo.controllerState.leftTrigger = ((float)state.Gamepad.bLeftTrigger / 255.0f ); appInfo.controllerState.rightTrigger = ((float)state.Gamepad.bRightTrigger / 255.0f ); appInfo.controllerState.leftBumper = state.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_SHOULDER; appInfo.controllerState.rightBumper = state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_SHOULDER; appInfo.controllerState.button1 = state.Gamepad.wButtons & XINPUT_GAMEPAD_A; appInfo.controllerState.button2 = state.Gamepad.wButtons & XINPUT_GAMEPAD_B; appInfo.controllerState.button3 = state.Gamepad.wButtons & XINPUT_GAMEPAD_X; appInfo.controllerState.button4 = state.Gamepad.wButtons & XINPUT_GAMEPAD_Y; appInfo.controllerState.specialButtonLeft = state.Gamepad.wButtons & XINPUT_GAMEPAD_BACK; appInfo.controllerState.specialButtonRight = state.Gamepad.wButtons & XINPUT_GAMEPAD_START; } else { appInfo.controllerState = { }; } LARGE_INTEGER elapsedTime; elapsedTime.QuadPart = startTime.QuadPart - lastTime.QuadPart; elapsedTime.QuadPart *= 1000; elapsedTime.QuadPart /= appInfo.timerResolution.QuadPart; appInfo.running = Update( gMemPtr, (float)elapsedTime.QuadPart, &soundSystemStorage->srb, soundSystemStorage->activeSounds ); Render( gMemPtr, renderSystemStorage ); PushAudioToSoundCard( soundSystemStorage ); SwapBuffers( appInfo.deviceContext ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); } LARGE_INTEGER endTime, computeTime; QueryPerformanceCounter( &endTime ); computeTime.QuadPart = endTime.QuadPart - startTime.QuadPart; computeTime.QuadPart *= 1000; computeTime.QuadPart /= appInfo.timerResolution.QuadPart; if( computeTime.QuadPart <= appInfo.mSecsPerFrame ) { Sleep(appInfo.mSecsPerFrame - computeTime.QuadPart ); } else { printf("Didn't sleep, compute was %ld\n", computeTime.QuadPart ); } } while( appInfo.running ); FreeConsole(); return Msg.wParam; }
void InitGraphics(const CmdLineArgs& args, int flags) { const bool setup_vmode = (flags & INIT_HAVE_VMODE) == 0; if(setup_vmode) { InitSDL(); if (!g_VideoMode.InitSDL()) throw PSERROR_System_VmodeFailed(); // abort startup #if !SDL_VERSION_ATLEAST(2, 0, 0) SDL_WM_SetCaption("0 A.D.", "0 A.D."); #endif } RunHardwareDetection(); const int quality = SANE_TEX_QUALITY_DEFAULT; // TODO: set value from config file SetTextureQuality(quality); ogl_WarnIfError(); // Optionally start profiler GPU timings automatically // (By default it's only enabled by a hotkey, for performance/compatibility) bool profilerGPUEnable = false; CFG_GET_VAL("profiler2.autoenable", profilerGPUEnable); if (profilerGPUEnable) g_Profiler2.EnableGPU(); if(!g_Quickstart) { WriteSystemInfo(); // note: no longer vfs_display here. it's dog-slow due to unbuffered // file output and very rarely needed. } if(g_DisableAudio) ISoundManager::SetEnabled(false); g_GUI = new CGUIManager(); // (must come after SetVideoMode, since it calls ogl_Init) if (ogl_HaveExtensions(0, "GL_ARB_vertex_program", "GL_ARB_fragment_program", NULL) != 0 // ARB && ogl_HaveExtensions(0, "GL_ARB_vertex_shader", "GL_ARB_fragment_shader", NULL) != 0) // GLSL { DEBUG_DISPLAY_ERROR( L"Your graphics card doesn't appear to be fully compatible with OpenGL shaders." L" In the future, the game will not support pre-shader graphics cards." L" You are advised to try installing newer drivers and/or upgrade your graphics card." L" For more information, please see http://www.wildfiregames.com/forum/index.php?showtopic=16734" ); // TODO: actually quit once fixed function support is dropped } const char* missing = ogl_HaveExtensions(0, "GL_ARB_multitexture", "GL_EXT_draw_range_elements", "GL_ARB_texture_env_combine", "GL_ARB_texture_env_dot3", NULL); if(missing) { wchar_t buf[500]; swprintf_s(buf, ARRAY_SIZE(buf), L"The %hs extension doesn't appear to be available on your computer." L" The game may still work, though - you are welcome to try at your own risk." L" If not or it doesn't look right, upgrade your graphics card.", missing ); DEBUG_DISPLAY_ERROR(buf); // TODO: i18n } if (!ogl_HaveExtension("GL_ARB_texture_env_crossbar")) { DEBUG_DISPLAY_ERROR( L"The GL_ARB_texture_env_crossbar extension doesn't appear to be available on your computer." L" Shadows are not available and overall graphics quality might suffer." L" You are advised to try installing newer drivers and/or upgrade your graphics card."); g_Shadows = false; } ogl_WarnIfError(); InitRenderer(); InitInput(); ogl_WarnIfError(); try { if (!Autostart(args)) { const bool setup_gui = ((flags & INIT_NO_GUI) == 0); // We only want to display the splash screen at startup shared_ptr<ScriptInterface> scriptInterface = g_GUI->GetScriptInterface(); JSContext* cx = scriptInterface->GetContext(); JSAutoRequest rq(cx); JS::RootedValue data(cx); if (g_GUI) { scriptInterface->Eval("({})", &data); scriptInterface->SetProperty(data, "isStartup", true); } InitPs(setup_gui, L"page_pregame.xml", g_GUI->GetScriptInterface().get(), data); } } catch (PSERROR_Game_World_MapLoadFailed& e) { // Map Loading failed // Start the engine so we have a GUI InitPs(true, L"page_pregame.xml", NULL, JS::UndefinedHandleValue); // Call script function to do the actual work // (delete game data, switch GUI page, show error, etc.) CancelLoad(CStr(e.what()).FromUTF8()); } }
void InitGraphics(const CmdLineArgs& args, int flags) { const bool setup_vmode = (flags & INIT_HAVE_VMODE) == 0; if(setup_vmode) { InitSDL(); if (!g_VideoMode.InitSDL()) throw PSERROR_System_VmodeFailed(); // abort startup #if !SDL_VERSION_ATLEAST(2, 0, 0) SDL_WM_SetCaption("0 A.D.", "0 A.D."); #endif } RunHardwareDetection(); tex_codec_register_all(); const int quality = SANE_TEX_QUALITY_DEFAULT; // TODO: set value from config file SetTextureQuality(quality); ogl_WarnIfError(); // Optionally start profiler GPU timings automatically // (By default it's only enabled by a hotkey, for performance/compatibility) bool profilerGPUEnable = false; CFG_GET_VAL("profiler2.gpu.autoenable", Bool, profilerGPUEnable); if (profilerGPUEnable) g_Profiler2.EnableGPU(); if(!g_Quickstart) { WriteSystemInfo(); // note: no longer vfs_display here. it's dog-slow due to unbuffered // file output and very rarely needed. } if(g_DisableAudio) { // speed up startup by disabling all sound // (OpenAL init will be skipped). // must be called before first snd_open. #if CONFIG2_AUDIO CSoundManager::SetEnabled(false); #endif } g_GUI = new CGUIManager(g_ScriptingHost.GetScriptInterface()); // (must come after SetVideoMode, since it calls ogl_Init) const char* missing = ogl_HaveExtensions(0, "GL_ARB_multitexture", "GL_EXT_draw_range_elements", "GL_ARB_texture_env_combine", "GL_ARB_texture_env_dot3", NULL); if(missing) { wchar_t buf[500]; swprintf_s(buf, ARRAY_SIZE(buf), L"The %hs extension doesn't appear to be available on your computer." L" The game may still work, though - you are welcome to try at your own risk." L" If not or it doesn't look right, upgrade your graphics card.", missing ); DEBUG_DISPLAY_ERROR(buf); // TODO: i18n } if (!ogl_HaveExtension("GL_ARB_texture_env_crossbar")) { DEBUG_DISPLAY_ERROR( L"The GL_ARB_texture_env_crossbar extension doesn't appear to be available on your computer." L" Shadows are not available and overall graphics quality might suffer." L" You are advised to try installing newer drivers and/or upgrade your graphics card."); g_Shadows = false; } ogl_WarnIfError(); InitRenderer(); InitInput(); ogl_WarnIfError(); try { if (!Autostart(args)) { const bool setup_gui = ((flags & INIT_NO_GUI) == 0); // We only want to display the splash screen at startup CScriptValRooted data; if (g_GUI) { ScriptInterface& scriptInterface = g_GUI->GetScriptInterface(); scriptInterface.Eval("({})", data); scriptInterface.SetProperty(data.get(), "isStartup", true); } InitPs(setup_gui, L"page_pregame.xml", data.get()); } } catch (PSERROR_Game_World_MapLoadFailed e) { // Map Loading failed // Start the engine so we have a GUI InitPs(true, L"page_pregame.xml", JSVAL_VOID); // Call script function to do the actual work // (delete game data, switch GUI page, show error, etc.) CancelLoad(CStr(e.what()).FromUTF8()); } }
void Application::Initialize() { m_ElapsedTime = m_LastElapsedTime = 0.0f; g_Application = this; m_Log = new LogManager(this); m_Log->AddLogType("Info" ); m_Log->AddLogType("Warning"); m_Log->AddLogType("Error" ); m_Log->SetTypeConsoleOutput(HW_INFORMATION,true); m_Log->SetTypeConsoleOutput(HW_WARNING ,true); m_Log->SetTypeConsoleOutput(HW_ERROR ,true); m_Log->SetOutputsTime (true ); m_Log->SetOutputsType (true ); m_Log->SetOutputsFile (false); m_Log->SetOutputsLine (false); m_Log->SetOutputsFunction(false); HW_INFO("Initializing...\n"); m_Window = new Window(); if(m_Window->Create(Vec2(800,600),"HelloWorld",true)) { FreeImage_Initialise(); m_Rasterizer = m_Window->GetRasterizer(); ((OpenGLRasterizer*)m_Rasterizer)->SetClearBuffers(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); m_Window->PollEvents(); m_TaskManager = new TaskManager(); m_Renderer = new DeferredRenderer(m_Rasterizer,m_TaskManager); m_Rasterizer->SetRenderer(m_Renderer); m_Renderer->Init(); m_AssetAllocator = new HWAssetAllocator(m_Renderer); m_AssetManager = new AssetManager(m_AssetAllocator); m_AssetAllocator->SetAssetManager(m_AssetManager); HWInitializeAssetManager(m_AssetManager); InitRenderer(); m_InputManager = new InputManager(m_Renderer); m_InputManager->Initialize(BTN_COUNT); m_InputManager->SetMouseButtonIDs(BTN_LEFT_MOUSE,BTN_RIGHT_MOUSE); m_ShaderGenerator = m_Renderer->GetShaderGenerator(); Scalar Aspect = m_Rasterizer->GetContext()->GetResolution().y / m_Rasterizer->GetContext()->GetResolution().x; m_Camera = new Camera(Vec2(60.0f,60.0f * Aspect),0.001f,2000.0f); m_Renderer->GetScene()->SetActiveCamera(m_Camera); m_Renderer->GetScene()->SetCullingAlgorithm(new BruteForceCullingAlgorithm(m_Renderer->GetScene(),m_TaskManager)); m_ElapsedTime = m_LastElapsedTime = m_Window->GetElapsedTime(); m_DeltaTime = 1.0f / 60.0f; m_Rasterizer->SetClearColor(Vec4(0.1f,0.1f,0.1f,1.0f)); m_Window->PollEvents(); m_Rasterizer->ClearActiveFramebuffer(); m_DoShutdown = false; m_UIManager = 0; m_Cursor = 0; InitGUI(); m_SSAO = 0; //InitSSAO(); m_DebugDraw = 0; InitDebugDisplay(); m_Game = new GameManager(this); m_Game->Initialize(); } else { m_DoShutdown = true; m_Rasterizer = 0; m_Renderer = 0; m_ShaderGenerator = 0; delete m_Window; delete m_TaskManager; m_Window = 0; } }
//-------------------------------------------------------------------------- void VeEngine::Init() noexcept { InitRenderer(); }