mac上用cocoa作imshow,資料彷佛很差找,即使找到也須要和OC混編,而不是純C。這不夠純粹。考慮用opengl作通用的、跨平臺的imshow。先入門一下opengl,從glfw官方例子入手。html
glfw版本ide
3.3,下載源碼基於cmake+vs2017(注意指定CMAKE_PREFIX_INSTALL
),release模式,執行INSTALL目標。ui
glfw官方例子3d
https://www.glfw.org/docs/latest/quick_guide.htmlcode
gladhtm
看了上面的官方例子文檔,原覺得要手動下載glad,後來發現其實就是glfw源碼中example/simple.c
和deps/glad_gl.c
,把這兩個文件放到新建工程的src目錄下便可。blog
cmake腳本
CMakeLists.txt:文檔
cmake_minimum_required(VERSION 3.14) project(opengl_imshow) include_directories( "F:/zhangzhuo/dev/glfw-3.3/build/vs2017-x64/install/include" "F:/zhangzhuo/dev/glfw-3.3/deps" "F:/zhangzhuo/dev/glad/include" ) link_directories("F:/zhangzhuo/dev/glfw-3.3/build/vs2017-x64/install/lib") add_executable(imshow src/simple.c src/glad_gl.c ) #target_link_libraries(imshow glfw3 glfw3dll opengl32) target_link_libraries(imshow glfw3 opengl32)
運行結果:
get