We can print the memorization pointer, so, it works well.
The below is if lines[i] equals 0 ( which means lost the address of pointer), the program print memories and exit(-1) as an error.
// int hDisplayControls_wmpaint_display_threeD_proc ( HWND hWnd, HDC hDC, PAINTSTRUCT* ps, UINT uMsg, WPARAM wParam, LPARAM lParam ) { int flg_axes = 0; int flg_object = 0; printf("hDisplayControls_wmpaint_display_threeD_proc: starts.\r\n"); // ID: 001001012 if ( lines == nullptr ) { lines = (vLine**) malloc ( sizeof ( vLine* ) * MAX_LINE ); } if ( lines_2D == nullptr ) { lines_2D = (vLine**) malloc ( sizeof ( vLine* ) * MAX_LINE ); } for( int i =0; i< MAX_LINE ; i++) { lines[i] = nullptr; lines_2D[i] = nullptr; } if ( init_lines == 0 ) { lines[0] = (vLine*) new vLine ( memorizevPoint( 0.0f, 0.0f, 0.0f ), memorizevPoint( 500.0f, 0.0f, 0.0f ) ); lines[1] = (vLine*) new vLine ( memorizevPoint( 0.0f, 0.0f, 0.0f ), memorizevPoint( 0.0f, 500.0f, 0.0f ) ); lines[2] = (vLine*) new vLine ( memorizevPoint( 0.0f, 0.0f, 0.0f ), memorizevPoint( 0.0f, 0.0f, 500.0f ) ); init_lines = 1; // ID: 001001012 line_index = 3; printf("01: line_index = %d\ returned from create_model_lines.\r\n", line_index); for ( int i=0; i<3; i++ ) { printf("init: lines[%d] |%p|\r\n", i, lines[i]); } // exit(-1); } /* for ( int i=0; i<3; i++ ) { printf("lines[%d] |%p|\r\n", i, lines[i]); if ( lines[i] == 0 ) { int a = print_lines (); } }*/ printf("02: line_index = %d lines |%p| lines2D |%p|\r\n", line_index, lines, lines_2D ); int b = convert_model_lines( lines, lines_2D, 0, line_index ); printf("03: line_index = %d lines |%p| lines2D |%p|\r\n", line_index, lines, lines_2D ); // Display axes from 0 to 3 for ( int i = 0; i<3; i++ ) { GamePaint_011( hDC, lines_2D[i] ); } printf("hDisplayControls_wmpaint_display_threeD_proc: ends.\r\n"); return 0; }
The above part is only print on the console and it is not necessary for work of well.
If you put the part, it works well.
download : https://github.com/WaitrudWeber/source_zip/blob/master/display-20210718.zip
If you comment out the part and press the button like the down arrow, it doesn't work and we can recognise memories work lost the address of the pointer.
download : https://github.com/WaitrudWeber/source_zip/blob/master/display-20210718-001.zip