Skip to content

Commit

Permalink
add with/without console option
Browse files Browse the repository at this point in the history
  • Loading branch information
LiangliangNan committed Sep 28, 2022
1 parent bcaaade commit ecc6030
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
16 changes: 8 additions & 8 deletions tutorials/Tutorial_203_Viewer_wxWidgets/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ set(SRC_FILES
)

if (WIN32 OR MSVC)
option(EASY3D_wxWidget_Viewer_with_console "Build the wxWidget viewer with a console window" ON)
option(WIN32_wxWidget_Viewer_No_Console "Build the wxWidget viewer without a console window" ON)

list(APPEND SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/Resources/sample.rc) # Include a RC file for windows
if (EASY3D_wxWidget_Viewer_with_console)
add_executable(${PROJECT_NAME} ${SRC_FILES})
target_compile_definitions(${PROJECT_NAME} PRIVATE VIEWER_WITH_CONSOLE_WINDOW)
message(STATUS "Creating the wxWidgets viewer with a console window")
else ()
add_executable(${PROJECT_NAME} WIN32 ${SRC_FILES})
message(STATUS "Creating the wxWidgets viewer without a console window")
if (WIN32_wxWidget_Viewer_No_Console)
add_executable(${PROJECT_NAME} WIN32 ${SRC_FILES})
message(STATUS "Creating the wxWidgets viewer without a console window")
else ()
add_executable(${PROJECT_NAME} ${SRC_FILES})
target_compile_definitions(${PROJECT_NAME} PRIVATE WIN32_VIEWER_WITHOUT_CONSOLE)
message(STATUS "Creating the wxWidgets viewer with a console window")
endif ()
elseif (APPLE)
set(${PROJECT_NAME}_ICON ${CMAKE_CURRENT_SOURCE_DIR}/Resources/sample.icns)
Expand Down
29 changes: 15 additions & 14 deletions tutorials/Tutorial_203_Viewer_wxWidgets/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,28 +48,29 @@ class Easy3DApp : public wxApp {



#if 0

#ifdef VIEWER_WITH_CONSOLE_WINDOW
wxIMPLEMENT_APP_CONSOLE(Easy3DApp);
#else
wxIMPLEMENT_APP(Easy3DApp);
#endif
#if 1

#ifdef WIN32_VIEWER_WITHOUT_CONSOLE
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, wxCmdLineArgType lpCmdLine, int nCmdShow) {
wxDisableAsserts();
return wxEntry(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
}
#else

#ifdef VIEWER_WITH_CONSOLE_WINDOW
int main(int argc, char **argv) {
wxDisableAsserts();
return wxEntry(argc, argv);
}
#else
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, wxCmdLineArgType lpCmdLine, int nCmdShow) {
wxDisableAsserts();
return wxEntry(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
}
#endif

wxAppInitializer wxTheAppInitializer([]() -> wxAppConsole * { return new Easy3DApp; });

#else // WIN32_VIEWER_WITHOUT_CONSOLE
#ifdef WIN32_VIEWER_WITHOUT_CONSOLE
wxIMPLEMENT_APP(Easy3DApp);
#else
wxIMPLEMENT_APP_CONSOLE(Easy3DApp);
#endif // WIN32_VIEWER_WITHOUT_CONSOLE
#endif

0 comments on commit ecc6030

Please sign in to comment.