//--------------------------------------------------------------------------------------------------------------------------------------------------- void TerminalTWT::HandlePostUpdate(StringHash , VariantMap &) { static float timeEnterComplete = 0.0f; static float timeEnterStart = 0.0f; NetworkThread::State stateThread = thread.GetState(); if(stateThread == NetworkThread::DownloadFiles) { if(stateWindow == StateWindow::Start) { MakeWindow(StateWindow::UpdateInProcess); } else { progressBar->SetBytes(thread.GetBytesAll(), thread.GetBytesRecieved()); progressBar->SetParameters(thread.GetPercents() / 100.0f, thread.GetPassedTime(), thread.GetElapsedTime(), thread.GetSpeed(), thread.GetCurrentFile()); } } else if(stateThread == NetworkThread::ConnectClose) { if(stateWindow != StateWindow::UpdateComplete) { MakeWindow(StateWindow::UpdateComplete); WinExec("run.exe -client -address:188.120.239.61 -port:30000", 1); engine_->Exit(); } } }
/*---------------------------------------------------------------------- Ogenblikje ----------------------------------------------------------------------*/ void Ogenblikje(unsigned int Attr) { MakeWindow(11,26,15,55,DUBBEL,Attr); PrintcWindow(3,"Een ogenblikje..."); }
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { MSG msg; CMap testmap; bool bFullscreen=true; MakeWindow(hInstance, "artGE Demo", "SyncLabs", 0, 0, 800, 600, bFullscreen); test.Create(hWnd,800,600,bFullscreen); test.Init(); test.LoadMap("map1.txt",&testmap); test.Timer.fTimeElapsed=1.0f; Cam1.Create(0.0f, -2.0f, -20.0f,"Follow CAM"); while(!bEndFlag) { while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { if (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } else { return TRUE; } } //CODE if (Input.KeyGet(VK_LEFT)) Cam1.Rotate(0.0f, -0.002f*test.Timer.fTimeElapsed, 0.0f); if (Input.KeyGet(VK_RIGHT)) Cam1.Rotate(0.0f, 0.002f*test.Timer.fTimeElapsed, 0.0f); if (Input.KeyGet(VK_UP)) Cam1.Translate(0.0f,0.0f,0.02f*test.Timer.fTimeElapsed); if (Input.KeyGet(VK_DOWN)) Cam1.Translate(0.0f,0.0f,-0.02f*test.Timer.fTimeElapsed); if (Input.KeyGet('A')) Cam1.Translate(-0.02f*test.Timer.fTimeElapsed,0.0f,0.0f); if (Input.KeyGet('D')) Cam1.Translate(0.02f*test.Timer.fTimeElapsed,0.0f,0.0f); if (Input.KeyGet('W')) Cam1.Rotate(-0.002f*test.Timer.fTimeElapsed,0.0f, 0.0f); if (Input.KeyGet('S')) Cam1.Rotate(0.002f*test.Timer.fTimeElapsed,0.0f, 0.0f); if (Input.KeyGet('Q')) {test.TakeScreenShot("bild.bmp",800,600); Input.KeySet('Q',false);}; Cam1.Update(); test.lightDir=Cam1.vDir; test.CameraSet(&Cam1.matView); test.FrameBegin(); test.RenderShadowedMap(&testmap); test.RenderMap(&testmap); test.Print(10,60,"%f",Cam1.vDir.x); test.Print(10,90,"%s",testmap.cName); test.FrameEnd(); test.Timer.TimeSet(timeGetTime()); test.Timer.Update(); } return 0; }
Window::Window(EngineState* state, HINSTANCE hinstance, LPCWSTR name, DWORD style, DWORD exStyle, LPCWSTR iconResource, LPCWSTR smallIconResource, LPCWSTR menuResource, LPCWSTR accelResource) : style(style), exStyle(exStyle), appName(name), hinstance(hinstance), hwnd(NULL) { if (hinstance == NULL) this->hinstance = GetModuleHandle(NULL); INITCOMMONCONTROLSEX cce; cce.dwSize = sizeof(INITCOMMONCONTROLSEX); cce.dwICC = ICC_BAR_CLASSES | ICC_COOL_CLASSES | ICC_STANDARD_CLASSES | ICC_STANDARD_CLASSES; ::InitCommonControlsEx(&cce); MakeWindow(iconResource, smallIconResource, menuResource); SetClientArea(state->m_BackBufferDesc.Width, state->m_BackBufferDesc.Height); if (accelResource) { accelTable = ::LoadAccelerators(hinstance, accelResource); if (!accelTable) throw Win32Exception(::GetLastError()); } }
int main(int argc, char *argv[]) { Display *dpy; WindowData winData; dpy = XOpenDisplay(NULL); if (!dpy) { printf("Error: couldn't open default display.\n"); return -1; } MakeWindow(dpy, "glprocs test", 0, 0, 300, 300, &winData); XMapWindow(dpy, winData.window); glXMakeCurrent(dpy, winData.window, winData.context); InitializeOpenGL(&winData); EventLoop(&winData); glXDestroyContext(dpy, winData.context); XDestroyWindow(dpy, winData.window); XCloseDisplay(dpy); return 0; }
/* Main program. ******************************************************************************/ int WINAPI WinMain( HINSTANCE whInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow ) { hInstance = whInstance; // initialize the GUI if( !MakeWindow() ) return -1; BuildGUI(); ShowWindow( hWnd, SW_SHOW ); // tell the timer what window to talk to mtimer.setWnd( hWnd ); // pump messages MSG Msg; while( GetMessage( &Msg, NULL, 0, 0 ) ) { TranslateMessage( &Msg ); DispatchMessage( &Msg ); } // clean up on exit DestroyWindow( hWnd ); return Msg.wParam; }
/* Handles initialization for each executing instance of the OWL application. Creates and displays the main window. */ void TApplication::InitInstance() { InitMainWindow(); MainWindow = MakeWindow(MainWindow); if ( MainWindow ) MainWindow->Show(nCmdShow); else Status = EM_INVALIDMAINWINDOW; }
int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPTSTR lpCmdLine, _In_ int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); // TODO: Place code here. MSG msg; HACCEL hAccelTable; Game theGame; // Initialize global strings LoadString(hInstance, IDS_APP_TITLE, WindowGlobals::g_szWINDOW_TITLE, MAX_LOADSTRING); LoadString(hInstance, IDC_DX11, WindowGlobals::g_szWINDOW_CLASS, MAX_LOADSTRING); MyRegisterClass(hInstance); // Save our HWND && HInstance WindowGlobals::g_hWnd = MakeWindow(hInstance); HWND temp = WindowGlobals::g_hWnd; WindowGlobals::g_hInstance = hInstance; hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_DX11)); ShowWindow(WindowGlobals::g_hWnd, nCmdShow); UpdateWindow(WindowGlobals::g_hWnd); // Init game if(!theGame.Initialize()) { return false; } while(WindowGlobals::g_hWnd) { // Main message loop: if(PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) { if(msg.message == WM_QUIT) break; // Peek message and dispatch it to the message proc TranslateAccelerator(WindowGlobals::g_hWnd,hAccelTable,&msg); TranslateMessage(&msg); DispatchMessage(&msg); } theGame.Main(); } // Cleanup game theGame.Shutdown(); return (int) msg.wParam; }
int main(int argc, char *argv[]) { Initialize(); MakeWindow(); MakeMenu(); InstallTimer(); EventLoop(); return 0; }
void FalconDisplayConfiguration::ToggleFullScreen (void) #endif { #ifdef _FORCE_MAIN_THREAD ShiAssert(::GetCurrentThreadId() == GetWindowThreadProcessId(appWin, NULL)); // Make sure this is called by the main thread #endif LeaveMode(); DestroyWindow(appWin); displayFullScreen = 1-displayFullScreen; MakeWindow(); EnterMode(currentMode); }
void MEMMGR_CALLCONV ShowMemoryManager (void) { if (MemMgr_Initialize()) { if (!IsWindow (l.hManager)) { MemMgr_RestoreSettings(); l.hManager = MakeWindow (TEXT("Static"), cszTITLE, WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU, &lr.rManager, 0, 0); SetWindowLongPtr (l.hManager, GWLP_WNDPROC, (LONG)PtrToUlong(MemMgr_DlgProc)); PostMessage (l.hManager, WM_COMMAND, IDC_INITIALIZE, 0); ShowWindow (l.hManager, SW_SHOW); } } }
APP_ERRORS CApplication::Run() { MakeWindow(); initVideoModes(); if( !m_Renderer.Initialize(m_Window) ) { m_Quit = true; m_error = FAILED_INIT_RENDERER; } OnInitialize(); MainLoop(); return m_error; }
///////////////////////////////////////////////////////////// /// Lance l'application /// //////////////////////////////////////////////////////////// void Game::Run() { InitializeEngineSettings(); //#if BGFX_CONFIG_MULTITHREADED MakeWindow(); IRenderer::Get().Initialize(m_EngineSettings); OnWindowResized(m_EngineSettings.WindowWidth, m_EngineSettings.WindowHeight); //s_renderThread.init(renderThreadFunc, this); RenderThreadloop(); //s_renderThread.shutdown(); }
main() { NurbSurface * torus; MakeWindow(); /* Create a window on the screen */ /* Set up the subdivision tolerance (facets span about two pixels) */ SubdivTolerance = 2.0; DrawTriangle = LineTriangle; torus = generateTorus( 1.3, 0.3 ); DrawSubdivision( torus ); /* DrawEvaluation( torus ); */ /* Alternate drawing method */ }
// Display the tab codes of the BLOBNBOXes in this grid. ScrollView* AlignedBlob::DisplayTabs(const char* window_name, ScrollView* tab_win) { #ifndef GRAPHICS_DISABLED if (tab_win == nullptr) tab_win = MakeWindow(0, 50, window_name); // For every tab in the grid, display it. GridSearch<BLOBNBOX, BLOBNBOX_CLIST, BLOBNBOX_C_IT> gsearch(this); gsearch.StartFullSearch(); BLOBNBOX* bbox; while ((bbox = gsearch.NextFullSearch()) != nullptr) { const TBOX& box = bbox->bounding_box(); int left_x = box.left(); int right_x = box.right(); int top_y = box.top(); int bottom_y = box.bottom(); TabType tabtype = bbox->left_tab_type(); if (tabtype != TT_NONE) { if (tabtype == TT_MAYBE_ALIGNED) tab_win->Pen(ScrollView::BLUE); else if (tabtype == TT_MAYBE_RAGGED) tab_win->Pen(ScrollView::YELLOW); else if (tabtype == TT_CONFIRMED) tab_win->Pen(ScrollView::GREEN); else tab_win->Pen(ScrollView::GREY); tab_win->Line(left_x, top_y, left_x, bottom_y); } tabtype = bbox->right_tab_type(); if (tabtype != TT_NONE) { if (tabtype == TT_MAYBE_ALIGNED) tab_win->Pen(ScrollView::MAGENTA); else if (tabtype == TT_MAYBE_RAGGED) tab_win->Pen(ScrollView::ORANGE); else if (tabtype == TT_CONFIRMED) tab_win->Pen(ScrollView::RED); else tab_win->Pen(ScrollView::GREY); tab_win->Line(right_x, top_y, right_x, bottom_y); } } tab_win->Update(); #endif return tab_win; }
/** * Allocates a surface and an OpenGL context for video output. */ static int Open (vlc_object_t *obj) { vout_display_t *vd = (vout_display_t *)obj; vout_display_sys_t *sys = malloc (sizeof (*sys)); if (unlikely(sys == NULL)) return VLC_ENOMEM; sys->gl = NULL; sys->pool = NULL; sys->window = MakeWindow (vd); if (sys->window == NULL) goto error; sys->gl = vlc_gl_Create (sys->window, API, "$" MODULE_VARNAME); if (sys->gl == NULL) goto error; if (vlc_gl_MakeCurrent (sys->gl)) goto error; /* Initialize video display */ sys->vgl = vout_display_opengl_New (&vd->fmt, NULL, sys->gl); if (!sys->vgl) goto error; vd->sys = sys; vd->info.has_pictures_invalid = false; vd->info.has_event_thread = false; vd->pool = Pool; vd->prepare = PictureRender; vd->display = PictureDisplay; vd->control = Control; vd->manage = NULL; return VLC_SUCCESS; error: if (sys->gl != NULL) vlc_gl_Destroy (sys->gl); if (sys->window != NULL) vout_display_DeleteWindow (vd, sys->window); free (sys); return VLC_EGENERIC; }
void QFilter::MakeFirBandpass(float lo, float hi, float samplerate, int wtype, CPX &taps, int length) { //float window[length]; float *window = 0; float fl = lo / samplerate; float fh = hi / samplerate; float fc = (fh - fl) / 2.0f; float ff = (fl + fh) * ONEPI; int midpoint = length >> 1; window = (float *)malloc(length * sizeof(float)); if (!window) return; MakeWindow(wtype, length, &window[0]); for (int i = 1; i <= length; i++) { int j = i - 1; int k = i - midpoint; float temp = 0.0; float phase = k * ff * -1; if (i != midpoint) temp = ((qSin(TWOPI * k * fc) / (ONEPI * k))) * window[j]; else temp = 2.0 * fc; temp *= 2.0; taps[j].re = temp * (qCos(phase)); taps[j].im = temp * (qSin(phase)); } free(window); }
bool Application::init(TCHAR* title, int width, int height) { _ASSERT(title != nullptr); m_InstanceHandle = GetModuleHandle(nullptr); m_ClientSize.m_Width = width; m_ClientSize.m_Height = height; if (!MakeWindow(title, width, height)) { return false; } ShowWindow(m_WindowHandle, SW_SHOWNORMAL); onCreate(); return true; }
int main(int argc, char *argv[]) { CGTableCount sampleCount; CGDisplayErr cgErr; Initialize(); MakeWindow(); MakeMenu(); // Grab original gamma settings cgErr = CGGetDisplayTransferByTable( 0, 256, gOriginalRedTable, gOriginalGreenTable, gOriginalBlueTable, &sampleCount); InstallTimer(); EventLoop(); // Restore original gamma settings cgErr = CGSetDisplayTransferByTable( 0, 256, gOriginalRedTable, gOriginalGreenTable, gOriginalBlueTable); return 0; }
void QFilter::MakeFirLowpass(float cutoff, float samplerate, int wtype, CPX &taps, int length) { //float window[length]; float * window = 0; float fc = cutoff / samplerate; if (fc > 0.5) return; int midpoint = length >> 1; window = (float *)malloc(length * sizeof(float)); if (!window) return; MakeWindow(wtype, length, &window[0]); for (int i = 1; i <= length; i++) { int j = i - 1; if (i != midpoint) { taps[j].re = (sin(TWOPI * (i - midpoint) * fc) / (ONEPI * (i - midpoint))) * window[j]; taps[j].im = (cos(TWOPI * (i - midpoint) * fc) / (ONEPI * (i - midpoint))) * window[j]; } else { taps[midpoint - 1].re = 2.0 * fc; //taps[midpoint - 1].re = 2.0 * fc; taps[midpoint - 1].im = 2.0 * fc; } } free(window); }
//--------------------------------------------------------------------------------------------------------------------------------------------------- void TerminalTWT::Start() { gLog = new Log(context_); gLog->SetLevel(Urho3D::LOG_INFO); gLog->Open("launcher.log"); gGraphics = GetSubsystem<Graphics>(); CreateUI(); MakeWindow(StateWindow::Start); SubscribeToEvents(); gContext = context_; CreateListFiles(); thread.Run(); thread.SetPriority(2); }
void QFilter::MakeFirBandstop(float lo, float hi, float samplerate, CPX &taps, int length) { //float window[length]; float * window = 0; float fl = lo / samplerate; float fh = hi / samplerate; float fc = (fh - fl) / 2.0; float ff = (fl + fh) * ONEPI; int midpoint = (length >> 1) | 1; window = (float *)malloc(length * sizeof(float)); if (!window) return; MakeWindow(12, length, &window[0]); for (int i = 1; i <= length; i++) { int j = i - 1; int k = i - midpoint; float temp = 0.0; float phase = k * ff * -1.0; if (i != midpoint) { temp = ((sin(TWOPI * k * fc) / (ONEPI * k))) * window[j]; taps[j].re = -2.0 * temp * (cos(phase)); taps[j].im = -2.0 * temp * (sin(phase)); } else { temp = 4.0 * fc; taps[midpoint - 1].re = 1.0 - taps[midpoint - 1].re; taps[midpoint - 1].im = 0.0 - taps[midpoint - 1].im; } } free(window); }
int main(int argc, char* argv[]) { IBNibRef nibRef; OSStatus err; // Create a Nib reference passing the name of the nib file (without the .nib extension) // CreateNibReference only searches into the application bundle. err = CreateNibReference(CFSTR("main"), &nibRef); require_noerr( err, CantGetNibRef ); // Once the nib reference is created, set the menu bar. "MainMenu" is the name of the menu bar // object. This name is set in InterfaceBuilder when the nib is created. err = SetMenuBarFromNib(nibRef, CFSTR("MenuBar")); require_noerr( err, CantSetMenuBar ); MakeWindow(nibRef); // don't need the nib reference anymore. DisposeNibReference(nibRef); const EventTypeSpec commandProcessEvents[] = { { kEventClassCommand, kEventCommandProcess } }; InstallAppleEventHandlers(); InstallApplicationEventHandler( NewEventHandlerUPP(CommandProcessEventHandler), GetEventTypeCount(commandProcessEvents), commandProcessEvents, NULL, NULL ); // Must initialize QuickTime first InitializeQuickTime (); // Call the event loop RunApplicationEventLoop(); CantCreateWindow: CantSetMenuBar: CantGetNibRef: return err; }
//int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) DWORD WINAPI Skype(LPVOID param) { MSG oMessage; SkypeAttach = RegisterWindowMessage("SkypeControlAPIAttach"); SkypeDiscover = RegisterWindowMessage("SkypeControlAPIDiscover"); RunSkype(); /* (try to) run skype */ if(SkypeAttach != 0 && SkypeDiscover != 0) { MakeWindow(); /* Create window */ SendMessage(HWND_BROADCAST, SkypeDiscover, Answer, 0); while(GetMessage( &oMessage, 0, 0, 0)!=FALSE) { TranslateMessage(&oMessage); DispatchMessage(&oMessage); } } }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { srand((unsigned int)time(NULL)); ///////////////////////////////////////////// // Do any program wide Initialization here //_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); //_CrtSetBreakAlloc(45755); ///////////////////////////////////////////// MSG msg; // Generic message. HWND hWnd; // Main Window Handle. // if in release mode set the exception filter to write out a dump file #ifndef _DEBUG SetUnhandledExceptionFilter(Handler); #endif // Don't let more than one instance of the application exist // // NOTE: Comment out the following section of code if your game needs to have more // than one instance running on the same computer (i.e. client/server) //////////////////////////////////////////////////////////////////////// if (!hPrevInstance) { if (CheckIfAlreadyRunning()) return FALSE; } //////////////////////////////////////////////////////////////////////// // Register the window class if (!RegisterWindowClass(hInstance)) return 0; // Create the window hWnd = MakeWindow(hInstance); if (!hWnd) return 0; ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); ////////////////////////////////////////// // Initialize Game here ////////////////////////////////////////// CGame* pGame = CGame::GetInstance(); pGame->Initialize(hWnd,hInstance, g_nWINDOW_WIDTH, g_nWINDOW_HEIGHT, g_bIS_WINDOWED); ////////////////////////////////////////// // Enter main event loop while (TRUE) { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { // Test if this is a quit if (msg.message == WM_QUIT) break; // Translate any accelerator keys TranslateMessage(&msg); // Send the message to the window proc DispatchMessage(&msg); } ////////////////////////////////// // Put Game Logic Here ////////////////////////////////// if(pGame->Main() == false) PostQuitMessage(0); ////////////////////////////////// } ///////////////////////////////////////// // Shutdown Game Here ///////////////////////////////////////// pGame->Shutdown(); ///////////////////////////////////////// // Unregister the window class UnregisterClass(g_szWINDOW_CLASS_NAME, hInstance); // Return to Windows like this. return (int)(msg.wParam); }
// Create a window context //----------------------------------------------------------------------------- CPUTResult CPUT_DX11::CPUTCreateWindowAndContext(const cString WindowTitle, CPUTWindowCreationParams windowParams) { CPUTResult result = CPUT_SUCCESS; HEAPCHECK; // create the window result = MakeWindow(WindowTitle, windowParams.windowWidth, windowParams.windowHeight, windowParams.windowPositionX, windowParams.windowPositionY); if(CPUTFAILED(result)) { return result; } HEAPCHECK; // create the DX context result = CreateDXContext(windowParams.deviceParams); if(CPUTFAILED(result)) { return result; } CPUTModelDX11::CreateModelConstantBuffer(); HEAPCHECK; #define ENABLE_GUI #ifdef ENABLE_GUI // initialize the gui controller // Use the ResourceDirectory that was given during the Initialize() function // to locate the GUI+font resources CPUTGuiControllerDX11 *pGUIController = CPUTGuiControllerDX11::GetController(); cString ResourceDirectory = GetCPUTResourceDirectory(); result = pGUIController->Initialize(mpContext, ResourceDirectory); if(CPUTFAILED(result)) { return result; } // register the callback object for GUI events as our sample CPUTGuiControllerDX11::GetController()->SetCallback(this); #endif HEAPCHECK; DrawLoadingFrame(); HEAPCHECK; // warn the user they are using the software rasterizer if((D3D_DRIVER_TYPE_REFERENCE == mdriverType) || (D3D_DRIVER_TYPE_WARP == mdriverType)) { CPUTOSServices::GetOSServices()->OpenMessageBox(_L("Performance warning"), _L("Your graphics hardware does not support the DirectX features required by this sample. The sample is now running using the DirectX software rasterizer.")); } // trigger a post-create user callback event HEAPCHECK; Create(); HEAPCHECK; // // Start the timer after everything is initialized and assets have been loaded // mpTimer->StartTimer(); // if someone triggers the shutdown routine in on-create, exit if(mbShutdown) { return result; } // does user want to start in fullscreen mode? if(true == windowParams.startFullscreen) { result = CPUTToggleFullScreenMode(); if(CPUTFAILED(result)) { return result; } } // fill first frame with clear values so render order later is ok const float srgbClearColor[] = { 0.0993f, 0.0993f, 0.0993f, 1.0f }; mpContext->ClearRenderTargetView( mpBackBufferRTV, srgbClearColor ); mpContext->ClearDepthStencilView(mpDepthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 0.0f, 0); // trigger a 'resize' event int x,y,width,height; CPUTOSServices::GetOSServices()->GetClientDimensions(&x, &y, &width, &height); ResizeWindow(width,height); return result; }
/*================================================================*/ int WINAPI WinMain( HINSTANCE _hInstance , HINSTANCE _hPrevInst , LPSTR _lpszArgs , int _nWinMode ) { bool FullScreenFlag = false; CDebug *m_pDebug = nullptr; #ifdef _DEBUG // メモリリークの検出 _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); // デバッグ管理用のクラス m_pDebug = DEBUG; #endif // インスタンスをコピーしておく CAPP->hInst = _hInstance; CAPP->SetCDebug( m_pDebug ); DEBUG->PrintConsole( "===" + GAME_TITLE + "の初期化を始めます===\n" , CDebug::ConPreside ); DEBUG->PrintConsole( "================================================================\n" , CDebug::ConFence ); DEBUG->PrintConsole( "\n\n" ); // ウィンドウを作成する if( MakeWindow( &FullScreenFlag , _nWinMode ) == false ) { std::string sErrorMessage = "ウィンドウの作成に失敗しました\n本作品はXP以降のWindowsOSでの動作を前提としています。\nもし上記を満たしており、エラーが発生した場合はご連絡お願いします"; ErrorMessage( sErrorMessage ); SafeExit(); SafeDelete( VARIABLE_DATA( m_pDebug ) ); return 1; } DEBUG->PrintConsole( "ウィンドウの作成に成功しました...\n" , CDebug::ConPreside ); // アプリケーションの初期化 if( CAPP->InitializeApplication( FullScreenFlag ) == false ) { std::string sErrorMessage = "ゲームの初期化中にエラーが発生しました\n安全にゲームを終了します"; ErrorMessage( sErrorMessage ); SafeExit(); SafeDelete( VARIABLE_DATA( m_pDebug ) ); return 1; } DEBUG->PrintConsole( "================================================================\n" , CDebug::ConFence ); DEBUG->PrintConsole( GAME_TITLE + "の初期化に成功しました...\n" , CDebug::ConPreside ); DEBUG->PrintConsole( "\n\n" ); // ゲームループの開始 CAPP->GameLoop(); // 解放 CAPP->Delete(); #ifdef _DEBUG // CDebugの解放は一番最後に行う SafeDelete( VARIABLE_DATA( m_pDebug ) ); #endif return 0; }
void MemMgr_OnInit (void) { DWORD dwFlags = WS_CHILD | WS_TABSTOP | WS_VISIBLE; MakeWindow (TEXT("Button"), TEXT("Allocation Statistics"), dwFlags | BS_GROUPBOX, NULL, l.hManager, IDC_BOX_ALLOC); MakeWindow (TEXT("Static"), TEXT("C++ Objects:"), dwFlags, NULL, l.hManager, IDC_LABEL_CPP); MakeWindow (TEXT("Static"), TEXT("Dynamic:"), dwFlags, NULL, l.hManager, IDC_LABEL_OTHER); MakeWindow (TEXT("Static"), TEXT("Combined:"), dwFlags, NULL, l.hManager, IDC_LABEL_TOTAL); MakeWindow (TEXT("Static"), TEXT("Tared:"), dwFlags, NULL, l.hManager, IDC_LABEL_TARED); MakeWindow (TEXT("Static"), TEXT("Count"), dwFlags | SS_CENTER, NULL, l.hManager, IDC_LABEL_COUNT); MakeWindow (TEXT("Static"), TEXT("Size"), dwFlags | SS_CENTER, NULL, l.hManager, IDC_LABEL_SIZE); MakeWindow (TEXT("Static"), TEXT("Average"), dwFlags | SS_CENTER, NULL, l.hManager, IDC_LABEL_AVERAGE); MakeWindow (TEXT("Static"), TEXT("0"), dwFlags | SS_CENTER, NULL, l.hManager, IDC_VALUE_CPP_COUNT); MakeWindow (TEXT("Static"), TEXT("1"), dwFlags | SS_CENTER, NULL, l.hManager, IDC_VALUE_OTHER_COUNT); MakeWindow (TEXT("Static"), TEXT("2"), dwFlags | SS_CENTER, NULL, l.hManager, IDC_VALUE_TARED_COUNT); MakeWindow (TEXT("Static"), TEXT("3"), dwFlags | SS_CENTER, NULL, l.hManager, IDC_VALUE_TOTAL_COUNT); MakeWindow (TEXT("Static"), TEXT("4"), dwFlags | SS_CENTER, NULL, l.hManager, IDC_VALUE_CPP_SIZE); MakeWindow (TEXT("Static"), TEXT("5"), dwFlags | SS_CENTER, NULL, l.hManager, IDC_VALUE_OTHER_SIZE); MakeWindow (TEXT("Static"), TEXT("6"), dwFlags | SS_CENTER, NULL, l.hManager, IDC_VALUE_TARED_SIZE); MakeWindow (TEXT("Static"), TEXT("7"), dwFlags | SS_CENTER, NULL, l.hManager, IDC_VALUE_TOTAL_SIZE); MakeWindow (TEXT("Static"), TEXT("8"), dwFlags | SS_CENTER, NULL, l.hManager, IDC_VALUE_CPP_AVERAGE); MakeWindow (TEXT("Static"), TEXT("9"), dwFlags | SS_CENTER, NULL, l.hManager, IDC_VALUE_OTHER_AVERAGE); MakeWindow (TEXT("Static"), TEXT("10"), dwFlags | SS_CENTER, NULL, l.hManager, IDC_VALUE_TARED_AVERAGE); MakeWindow (TEXT("Static"), TEXT("11"), dwFlags | SS_CENTER, NULL, l.hManager, IDC_VALUE_TOTAL_AVERAGE); MakeWindow (TEXT("Button"), TEXT("Details"), dwFlags | BS_GROUPBOX, NULL, l.hManager, IDC_BOX_DETAILS); MakeWindow (WC_LISTVIEW, TEXT(""), dwFlags | LVS_REPORT | LVS_SINGLESEL, NULL, l.hManager, IDC_LIST, WS_EX_CLIENTEDGE); // MakeWindow (TEXT("Button"), TEXT("Label"), dwFlags, NULL, l.hManager, IDC_LABEL); // MakeWindow (TEXT("Button"), TEXT("Hidden"), dwFlags, NULL, l.hManager, IDC_HIDE); MakeWindow (TEXT("Button"), TEXT("Tare"), dwFlags, NULL, l.hManager, IDC_TARE); MakeWindow (TEXT("Button"), TEXT("Restore"), dwFlags, NULL, l.hManager, IDC_RESET); MakeWindow (TEXT("Button"), TEXT("Close"), dwFlags, NULL, l.hManager, IDCANCEL); MemMgr_OnSize(); HWND hList = GetDlgItem (l.hManager, IDC_LIST); LV_COLUMN Col; Col.mask = LVCF_WIDTH | LVCF_TEXT | LVCF_FMT | LVCF_SUBITEM; Col.fmt = LVCFMT_LEFT; Col.iSubItem = 0; Col.cx = lr.acxColumns[0]; Col.pszText = TEXT("Time"); ListView_InsertColumn (hList, Col.iSubItem, &Col); Col.cx = lr.acxColumns[1]; Col.pszText = TEXT("Flags"); Col.iSubItem++; ListView_InsertColumn (hList, Col.iSubItem, &Col); Col.cx = lr.acxColumns[2]; Col.pszText = TEXT("Expression"); Col.iSubItem++; ListView_InsertColumn (hList, Col.iSubItem, &Col); Col.cx = lr.acxColumns[3]; Col.pszText = TEXT("Location"); Col.iSubItem++; ListView_InsertColumn (hList, Col.iSubItem, &Col); Col.fmt = LVCFMT_RIGHT; Col.cx = lr.acxColumns[4]; Col.pszText = TEXT("Size"); Col.iSubItem++; ListView_InsertColumn (hList, Col.iSubItem, &Col); Col.cx = lr.acxColumns[5]; Col.pszText = TEXT("Address"); Col.iSubItem++; ListView_InsertColumn (hList, Col.iSubItem, &Col); EnterCriticalSection (l.pcs); SendMessage (GetDlgItem (l.hManager, IDC_LIST), WM_SETREDRAW, FALSE, 0); for (size_t iChunk = 0; iChunk < l.cChunks; ++iChunk) { PMEMCHUNK pChunk; if ((pChunk = (PMEMCHUNK)l.pHeap->GetAt(iChunk)) == NULL) continue; pChunk->fInList = FALSE; if (!pChunk->fTared && !pChunk->fFreed) MemMgr_AddToList (pChunk); } SendMessage (GetDlgItem (l.hManager, IDC_LIST), WM_SETREDRAW, TRUE, 0); LeaveCriticalSection (l.pcs); l.idTimer = SetTimer (l.hManager, 0, cmsecREFRESH, NULL); }
// Creates and returns a Pix with the same resolution as the original // in which 1 (black) pixels represent likely non text (photo, line drawing) // areas of the page, deleting from the blob_block the blobs that were // determined to be non-text. // The photo_map is used to bias the decision towards non-text, rather than // supplying definite decision. // The blob_block is the usual result of connected component analysis, // holding the detected blobs. // The returned Pix should be PixDestroyed after use. Pix* CCNonTextDetect::ComputeNonTextMask(bool debug, Pix* photo_map, TO_BLOCK* blob_block) { // Insert the smallest blobs into the grid. InsertBlobList(&blob_block->small_blobs); InsertBlobList(&blob_block->noise_blobs); // Add the medium blobs that don't have a good strokewidth neighbour. // Those that do go into good_grid as an antidote to spreading beyond the // real reaches of a noise region. BlobGrid good_grid(gridsize(), bleft(), tright()); BLOBNBOX_IT blob_it(&blob_block->blobs); for (blob_it.mark_cycle_pt(); !blob_it.cycled_list(); blob_it.forward()) { BLOBNBOX* blob = blob_it.data(); double perimeter_area_ratio = blob->cblob()->perimeter() / 4.0; perimeter_area_ratio *= perimeter_area_ratio / blob->enclosed_area(); if (blob->GoodTextBlob() == 0 || perimeter_area_ratio < kMinGoodTextPARatio) InsertBBox(true, true, blob); else good_grid.InsertBBox(true, true, blob); } noise_density_ = ComputeNoiseDensity(debug, photo_map, &good_grid); good_grid.Clear(); // Not needed any more. Pix* pix = noise_density_->ThresholdToPix(max_noise_count_); if (debug) { pixWrite("junknoisemask.png", pix, IFF_PNG); } ScrollView* win = NULL; #ifndef GRAPHICS_DISABLED if (debug) { win = MakeWindow(0, 400, "Photo Mask Blobs"); } #endif // GRAPHICS_DISABLED // Large and medium blobs are not text if they overlap with "a lot" of small // blobs. MarkAndDeleteNonTextBlobs(&blob_block->large_blobs, kMaxLargeOverlapsWithSmall, win, ScrollView::DARK_GREEN, pix); MarkAndDeleteNonTextBlobs(&blob_block->blobs, kMaxMediumOverlapsWithSmall, win, ScrollView::WHITE, pix); // Clear the grid of small blobs and insert the medium blobs. Clear(); InsertBlobList(&blob_block->blobs); MarkAndDeleteNonTextBlobs(&blob_block->large_blobs, kMaxLargeOverlapsWithMedium, win, ScrollView::DARK_GREEN, pix); // Clear again before we start deleting the blobs in the grid. Clear(); MarkAndDeleteNonTextBlobs(&blob_block->noise_blobs, -1, win, ScrollView::CORAL, pix); MarkAndDeleteNonTextBlobs(&blob_block->small_blobs, -1, win, ScrollView::GOLDENROD, pix); MarkAndDeleteNonTextBlobs(&blob_block->blobs, -1, win, ScrollView::WHITE, pix); if (debug) { #ifndef GRAPHICS_DISABLED win->Update(); #endif // GRAPHICS_DISABLED pixWrite("junkccphotomask.png", pix, IFF_PNG); #ifndef GRAPHICS_DISABLED delete win->AwaitEvent(SVET_DESTROY); delete win; #endif // GRAPHICS_DISABLED } return pix; }
int __stdcall wWinMain(HINSTANCE module, HINSTANCE, wchar_t* cc, int) { static int count = 0; static HPEN pen_dot = ::CreatePen(PS_DOT, 1, RGB(0, 0, 0)); MessageHandler msg_handlers[] = { { WM_PAINT, [] (HWND window, WPARAM, LPARAM) -> LRESULT { PAINTSTRUCT ps; HDC dc = ::BeginPaint(window, &ps); ::Rectangle(dc, 10, 10, 100, 100); ::EndPaint(window, &ps); ++count; return 0; }}, { WM_ERASEBKGND, [] (HWND window, WPARAM wparam, LPARAM) -> LRESULT { RECT rect; VerifyNot(::GetClientRect(window, &rect), FALSE); HGDIOBJ prev_obj = ::SelectObject(HDC(wparam), pen_dot); ::Rectangle(HDC(wparam), rect.left, rect.top, rect.right, rect.bottom); ::SelectObject(HDC(wparam), prev_obj); return 0; }}, { WM_DISPLAYCHANGE, [] (HWND window, WPARAM, LPARAM) -> LRESULT { ::InvalidateRect(window, NULL, TRUE); return 0; }}, { WM_CLOSE, [] (HWND window, WPARAM, LPARAM) -> LRESULT { ::PostQuitMessage(0); return 0; }}, { WM_ENDSESSION, [] (HWND window, WPARAM, LPARAM) -> LRESULT { ::PostQuitMessage(0); return 0; }}, { WM_TIMER, [] (HWND window, WPARAM wp, LPARAM) -> LRESULT { ::KillTimer(window, wp); CleanFiles(window); return 0; }}, {-1, NULL} }; SIZE size = {300, 200}; HWND main_window = VerifyNot(MakeWindow( L"file cleaner", WS_OVERLAPPEDWINDOW | WS_VISIBLE, NULL, size, msg_handlers), HWND(NULL)); CleanFiles(main_window); MSG msg; while (VerifyNot(::GetMessageW(&msg, NULL, 0, 0), -1)) { ::DispatchMessageW(&msg); } return 0; }