int main(int argc, char * argv[]) { int a = 1, b = 2, z1 = 3, z2 = 4, z3 = 5; void *handle0, *handle1; char *error; if (argc == 3) { a = atoi(argv[1]); b = atoi(argv[2]); } DynamicLoader load0("./closure_callee0"); DynamicLoader load1("./closure_callee1"); DynamicLoader load2("./closure_callee2"); DynamicLoader load3("./closure_callee3"); std::function<int (int)> init_0 = load0.load<int (int)>("callee_init"); std::function<int (int, int&, int*)> init_1 = load1.load<int (int, int&, int*)>("callee_init"); std::function<int (int, int&, int*)> init_3 = load3.load<int (int, int&, int*)>("create_callee"); std::function<int (void)> del_3 = load3.load<int (void)>("destroy_callee"); std::function<int (int, int)> callee_0 = load0.load<int (int, int)>("callee"); std::function<int (int, int)> callee_1 = load1.load<int (int, int)>("callee"); std::function<int (int, int)> callee_3 = load3.load<int (int, int)>("lam"); typedef std::function<int (int, int)> T_lam; std::function<int (T_lam, int, int)> callee_2 = load2.load<int (T_lam, int, int)>("callee"); init_0(z1); init_1(z1, z2, &z3); printf("<%s:%d> : z1 = %d, z2 = %d, z3 = %d\n", __FUNCTION__, __LINE__, z1, z2, z3); init_3(z1, z2, &z3); printf("<%s:%d> : z1 = %d, z2 = %d, z3 = %d\n", __FUNCTION__, __LINE__, z1, z2, z3); callee_0(a, b); callee_1(a, b); // callee_3(a, b); callee_2(callee_0, a, b); callee_2(callee_1, a, b); printf("<%s:%d> : z1 = %d, z2 = %d, z3 = %d\n", __FUNCTION__, __LINE__, z1, z2, z3); callee_2(callee_3, a, b); printf("<%s:%d> : z1 = %d, z2 = %d, z3 = %d\n", __FUNCTION__, __LINE__, z1, z2, z3); del_3(); load0.close(); load1.close(); load2.close(); load3.close(); return 0; }
Matrix(int v) { init_0(); for (int i = 0; i < 2; ++i) mt[i][i] = v; }
Matrix() {init_0();}
void init(int v) { init_0(); for (int i = 0; i < 2; ++i) mt[i][i] = v; }
//----------------------------------------------------------------------------- // Name: WinMain() // Desc: The application's entry point //----------------------------------------------------------------------------- int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { WNDCLASSEX winClass; MSG uMsg; bool deviceReset = FALSE; memset(&uMsg,0,sizeof(uMsg)); winClass.lpszClassName = "MY_WINDOWS_CLASS"; winClass.cbSize = sizeof(WNDCLASSEX); winClass.style = CS_HREDRAW | CS_VREDRAW; winClass.lpfnWndProc = WindowProc; winClass.hInstance = hInstance; winClass.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_DIRECTX_ICON); winClass.hIconSm = LoadIcon(hInstance, (LPCTSTR)IDI_DIRECTX_ICON); winClass.hCursor = LoadCursor(NULL, IDC_ARROW); winClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); winClass.lpszMenuName = NULL; winClass.cbClsExtra = 0; winClass.cbWndExtra = 0; if(!RegisterClassEx( &winClass) ) return E_FAIL; // // Create window #0... // g_hWnd_0 = CreateWindowEx( NULL, "MY_WINDOWS_CLASS", "Direct3D (DX9) - Multiple Devices (Window #0)", WS_EX_TOPMOST | WS_POPUP, // fullscreen values /* WS_OVERLAPPEDWINDOW | WS_VISIBLE,*/ 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, NULL, NULL, hInstance, NULL ); if( g_hWnd_0 == NULL ) return E_FAIL; ShowWindow( g_hWnd_0, nCmdShow ); UpdateWindow( g_hWnd_0 ); #ifdef TWO // // Create window #1... // g_hWnd_1 = CreateWindowEx( NULL, "MY_WINDOWS_CLASS", "Direct3D (DX9) - Multiple Devices (Window #1)", WS_EX_TOPMOST | WS_POPUP, // fullscreen values /* WS_OVERLAPPEDWINDOW | WS_VISIBLE,*/ 1920, 0, SCREEN_WIDTH, SCREEN_HEIGHT, NULL, NULL, hInstance, NULL ); if( g_hWnd_1 == NULL ) return E_FAIL; ShowWindow( g_hWnd_1, nCmdShow ); UpdateWindow( g_hWnd_1 ); #endif // // Init Direct3D usage on both windows... // init_0(); #ifdef TWO init_1(); #endif ResetDevice(); // Important !!! LoadModels(); while( uMsg.message != WM_QUIT ) { if( PeekMessage( &uMsg, NULL, 0, 0, PM_REMOVE ) ) { TranslateMessage( &uMsg ); DispatchMessage( &uMsg ); } else { g_dCurrentTime = timeGetTime(); g_dElpasedFrameTime = g_dCurrentTime - g_dLastTime; // How much time has passed since the last frame? g_dElpasedAppTime += g_dElpasedFrameTime; // How much time has passed overall for the application? g_dLastTime = g_dCurrentTime; render_0(); #ifdef TWO render_1(); #endif } } // // Cleanup Direct3D usage on both windows... // #ifdef TWO shutDown_1(); #endif shutDown_0(); UnregisterClass( "MY_WINDOWS_CLASS", winClass.hInstance ); return uMsg.wParam; }