在GDK8上使用OpenGL体验2D / 3D编程

GDK8麻雀虽小,五脏俱全;不仅拥有良好的性能,同时也包含Mali 450GPU,在处理2D / 3D这样的图像任务时,也有出色的表现。

主要步骤:

1. 从GitHub上下载代码。

geduer@gdk8:~$ git clone https://github.com/opengl-tutorials/ogl.git
Cloning into 'ogl'...
remote: Enumerating objects: 16016, done.
remote: Counting objects: 100% (1/1), done.
remote: Total 16016 (delta 0), reused 0 (delta 0), pack-reused 16015
Receiving objects: 100% (16016/16016), 84.08 MiB | 2.33 MiB/s, done.
Resolving deltas: 100% (8357/8357), done.
Checking out files: 100% (3965/3965), done.

2. 安装依赖。

sudo apt-get install libgl1-mesa-dev \
    libglu1-mesa-dev \
    freeglut3-dev

3. 进入ogl目录。

geduer@gdk8:~/ogl$ ls
BUILDING.txt    distrib                       playground               tutorial05_textured_cube       tutorial10_transparency       tutorial15_lightmaps
CMakeLists.txt  external                      tutorial01_first_window  tutorial06_keyboard_and_mouse  tutorial11_2d_fonts           tutorial16_shadowmaps
Makefile        misc01_math_cheatsheet        tutorial02_red_triangle  tutorial07_model_loading       tutorial12_extensions         tutorial17_rotations
build           misc04_building_your_own_app  tutorial03_matrices      tutorial08_basic_shading       tutorial13_normal_mapping     tutorial18_billboards_and_particles
common          misc05_picking                tutorial04_colored_cube  tutorial09_vbo_indexing        tutorial14_render_to_texture

4. 创建build目录,并进入目录内。

geduer@gdk8:~/ogl$ mkdir build
geduer@gdk8:~/ogl$ cd build
geduer@gdk8:~/ogl/build$ ls
CMakeCache.txt                          launch-tutorial04_colored_cube.sh        launch-tutorial14_render_to_texture.sh  tutorial02_red_triangle        tutorial12_extensions
CMakeFiles                              launch-tutorial05_textured_cube.sh       launch-tutorial15_lightmaps.sh          tutorial03_matrices            tutorial13_normal_mapping
Makefile                                launch-tutorial06_keyboard_and_mouse.sh  launch-tutorial16_shadowmaps.sh         tutorial04_colored_cube        tutorial14_render_to_texture
cmake_install.cmake                     launch-tutorial07_model_loading.sh       launch-tutorial16_shadowmaps_simple.sh  tutorial05_textured_cube       tutorial15_lightmaps
external                                launch-tutorial08_basic_shading.sh       launch-tutorial17_rotations.sh          tutorial06_keyboard_and_mouse  tutorial16_shadowmaps
launch-misc05_picking_BulletPhysics.sh  launch-tutorial09_AssImp.sh              launch-tutorial18_billboards.sh         tutorial07_model_loading       tutorial16_shadowmaps_simple
launch-misc05_picking_custom.sh         launch-tutorial09_several_objects.sh     launch-tutorial18_particles.sh          tutorial08_basic_shading       tutorial17_rotations
launch-misc05_picking_slow_easy.sh      launch-tutorial09_vbo_indexing.sh        misc05_picking_BulletPhysics            tutorial09_AssImp              tutorial18_billboards
launch-playground.sh                    launch-tutorial10_transparency.sh        misc05_picking_custom                   tutorial09_several_objects     tutorial18_particles
launch-tutorial01_first_window.sh       launch-tutorial11_2d_fonts.sh            misc05_picking_slow_easy                tutorial09_vbo_indexing
launch-tutorial02_red_triangle.sh       launch-tutorial12_extensions.sh          playground                              tutorial10_transparency
launch-tutorial03_matrices.sh           launch-tutorial13_normal_mapping.sh      tutorial01_first_window                 tutorial11_2d_fonts
geduer@gdk8:~/ogl/build$

5. 开始编译,先[cmake ..],再[make]。

如果没有安装cmake,可以通过sudo apt install cmake命令进行安装。

geduer@gdk8:~/ogl/build$ cmake ..
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenGL: /usr/lib/aarch64-linux-gnu/libOpenGL.so
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-- Using X11 for window creation
-- Using GLX for context creation
-- Looking for XOpenDisplay in /usr/lib/aarch64-linux-gnu/libX11.so;/usr/lib/aarch64-linux-gnu/libXext.so
-- Looking for XOpenDisplay in /usr/lib/aarch64-linux-gnu/libX11.so;/usr/lib/aarch64-linux-gnu/libXext.so - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Found X11: /usr/lib/aarch64-linux-gnu/libX11.so
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of off64_t
-- Check size of off64_t - done
-- Looking for fseeko
-- Looking for fseeko - found
-- Looking for unistd.h
-- Looking for unistd.h - found
CMake Deprecation Warning at CMakeLists.txt:24 (cmake_policy):
  The OLD behavior for policy CMP0026 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


-- Configuring done
-- Generating done
-- Build files have been written to: /home/geduer/ogl/build
geduer@gdk8:~/ogl/build$ make
[  2%] Built target glfw
[  2%] Built target GLEW_1130
[  2%] Linking CXX executable tutorial18_particles
[  3%] Built target tutorial18_particles
[  5%] Built target ANTTWEAKBAR_116_OGLCORE_GLFW
[  5%] Linking CXX executable misc05_picking_custom
[  6%] Built target misc05_picking_custom
[  6%] Linking CXX executable misc05_picking_slow_easy
[  8%] Built target misc05_picking_slow_easy
[  8%] Linking CXX executable playground
[  8%] Built target playground
[  8%] Linking CXX executable tutorial16_shadowmaps
[  9%] Built target tutorial16_shadowmaps
[  9%] Linking CXX executable tutorial16_shadowmaps_simple
[ 10%] Built target tutorial16_shadowmaps_simple
[ 10%] Linking CXX executable tutorial06_keyboard_and_mouse
[ 11%] Built target tutorial06_keyboard_and_mouse
[ 11%] Linking CXX executable tutorial05_textured_cube
[ 11%] Built target tutorial05_textured_cube
[ 11%] Linking CXX executable tutorial10_transparency
[ 12%] Built target tutorial10_transparency
[ 13%] Linking CXX executable tutorial04_colored_cube
[ 13%] Built target tutorial04_colored_cube
[ 13%] Linking CXX executable tutorial17_rotations
[ 15%] Built target tutorial17_rotations
[ 16%] Linking CXX executable tutorial13_normal_mapping
[ 17%] Built target tutorial13_normal_mapping
[ 18%] Linking CXX executable tutorial15_lightmaps
[ 19%] Built target tutorial15_lightmaps
[ 19%] Linking CXX executable tutorial03_matrices
[ 20%] Built target tutorial03_matrices
[ 20%] Linking CXX executable tutorial01_first_window
[ 21%] Built target tutorial01_first_window
[ 21%] Linking CXX executable tutorial02_red_triangle
[ 21%] Built target tutorial02_red_triangle
[ 21%] Linking CXX executable tutorial18_billboards
[ 22%] Built target tutorial18_billboards
[ 23%] Linking CXX executable tutorial08_basic_shading
[ 24%] Built target tutorial08_basic_shading
[ 24%] Linking CXX executable tutorial07_model_loading
[ 25%] Built target tutorial07_model_loading
[ 26%] Linking CXX executable tutorial09_vbo_indexing
[ 27%] Built target tutorial09_vbo_indexing
[ 29%] Built target zlib
[ 54%] Built target assimp
[ 54%] Linking CXX executable tutorial09_AssImp
[ 55%] Built target tutorial09_AssImp
[ 55%] Linking CXX executable tutorial09_several_objects
[ 56%] Built target tutorial09_several_objects
[ 58%] Built target LinearMath
[ 76%] Built target BulletCollision
[ 80%] Built target BulletDynamics
[ 80%] Linking CXX executable misc05_picking_BulletPhysics
[ 81%] Built target misc05_picking_BulletPhysics
[ 81%] Linking CXX executable tutorial11_2d_fonts
[ 82%] Built target tutorial11_2d_fonts
[ 82%] Linking CXX executable tutorial12_extensions
[ 84%] Built target tutorial12_extensions
[ 84%] Linking CXX executable tutorial14_render_to_texture
[ 85%] Built target tutorial14_render_to_texture
[ 85%] Built target wave
[ 86%] Built target gears
[ 87%] Built target boing
[ 88%] Built target heightmap
[ 89%] Built target particles
[ 90%] Built target splitview
[ 90%] Built target simple
[ 91%] Built target cursor
[ 92%] Built target msaa
[ 93%] Built target events
[ 94%] Built target glfwinfo
[ 95%] Built target threads
[ 95%] Built target clipboard
[ 95%] Built target monitors
[ 95%] Built target iconify
[ 95%] Built target gamma
[ 95%] Built target sharing
[ 96%] Built target joysticks
[ 96%] Built target title
[ 97%] Built target reopen
[ 97%] Built target empty
[ 97%] Built target tearing
[ 98%] Built target windows
[100%] Built target BulletSoftBody

6. 开始测试。

6.1 tutorial02_red_triangle

6.2 tutorial09_vbo_indexing

作者:Taylor  创建时间:2021-12-31 15:10
最后编辑:Taylor  更新时间:2024-09-14 11:25