v3.0 use pointer to store window, and dynamically allocate memory