This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
products:sbc:common:applications:sdl2 [2022/07/04 23:18] frank Add SDL2 |
products:sbc:common:applications:sdl2 [2022/10/25 06:33] (current) nick |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== SDL2 ====== | ====== SDL2 ====== | ||
- | ===== Introduction ===== | + | < |
- | + | Only support | |
- | This document is mainly SDL2 library. You will learn how to install the SDL2 library and do simple tests. | + | |
- | + | ||
- | < | + | |
- | he default SDL2 packages from Ubuntu | + | |
</ | </ | ||
- | <WRAP alert > | + | ===== Introduction ===== |
- | * Only support Framebuffer Console mode. | + | |
- | * Install this version of library will break some official packages which depend on this library. | + | |
- | </ | + | |
+ | The Ubuntu 22.04 Gnome desktop is hardware accelerated with wayland GPU, so you can use SDL2 with GPU by default on desktop. | ||
- | ===== System Configuration ===== | ||
- | Please make sure you use the latest image, if not please follow [[/ | + | ===== Install SDL2 Packages ===== |
- | After reboot. Install SDL2: | + | ```shell |
- | ```sh | + | sudo apt update |
- | $ sudo apt update | + | sudo apt upgrade |
- | $ sudo apt install libsdl2-2.0-0 libsdl2-dev | + | sudo apt install libsdl2-2.0-0 libsdl2-dev |
- | $ mkdir /tmp/sdl2 | + | |
- | $ cd /tmp/sdl2 | + | |
- | $ wget https:// | + | |
- | $ tar xvzf sdl2.tgz | + | |
- | $ cd sdl2 | + | |
- | $ sudo dpkg -i libsdl2-2.0-0_2.0.10+dfsg1-3_arm64.deb libsdl2-dev_2.0.10+dfsg1-3_arm64.deb | + | |
``` | ``` | ||
+ | ===== Demonstration ===== | ||
- | ===== Demo Source Code ===== | + | ==== Get SDL2 Source Code ==== |
- | Get source code | + | ```shell |
- | + | cd /tmp | |
- | ```sh | + | git clone https:// |
- | $ cd /tmp | + | cd SDL |
- | $ git clone https:// | + | git checkout release-2.0.20 |
- | $ cd SDL | + | |
- | $ git checkout release-2.0.10 | + | |
``` | ``` | ||
- | Compile | + | ==== Compile |
- | ```sh | + | ```shell |
- | $ cd test | + | cd test |
- | $ ./ | + | ./ |
- | $ make | + | make |
``` | ``` | ||
- | ===== Demonstrate ===== | ||
- | ```sh | + | ==== Run Test Examples ==== |
- | $ ./ | + | |
+ | Run OpenGL ES2 Cube Demo. | ||
+ | |||
+ | ```txt | ||
+ | khadas@Khadas:/ | ||
+ | khadas@Khadas:/ | ||
+ | Couldn' | ||
+ | No plugins found, falling back on no decorations | ||
INFO: Screen bpp: 24 | INFO: Screen bpp: 24 | ||
- | INFO: | + | INFO: |
INFO: Vendor | INFO: Vendor | ||
INFO: Renderer | INFO: Renderer | ||
- | INFO: Version | + | INFO: Version |
- | INFO: Extensions : GL_ARM_rgba8 GL_ARM_mali_shader_binary GL_OES_depth24 GL_OES_depth_texture GL_OES_depth_texture_cube_map GL_OES_packed_depth_stencil GL_OES_rgb8_rgba8 GL_EXT_read_format_bgra GL_OES_compressed_paletted_texture GL_OES_compressed_ETC1_RGB8_texture GL_OES_standard_derivatives GL_OES_EGL_image GL_OES_EGL_image_external GL_OES_EGL_image_external_essl3 GL_OES_EGL_sync GL_OES_texture_npot GL_OES_vertex_half_float GL_OES_required_internalformat GL_OES_vertex_array_object GL_OES_mapbuffer GL_EXT_texture_format_BGRA8888 GL_EXT_texture_rg GL_EXT_texture_type_2_10_10_10_REV GL_OES_fbo_render_mipmap GL_OES_element_index_uint GL_EXT_shadow_samplers GL_OES_texture_compression_astc GL_KHR_texture_compression_astc_ldr GL_KHR_texture_compression_astc_hdr GL_KHR_texture_compression_astc_sliced_3d GL_EXT_texture_compression_astc_decode_mode GL_EXT_texture_compression_astc_decode_mode_rgb9e5 GL_KHR_debug GL_EXT_occlusion_query_boolean GL_EXT_disjoint_timer_query GL_EXT_blend_minmax GL_EXT_discard_framebuffer GL_OES_get_program_binary GL_OES_texture_3D GL_EXT_texture_storage | + | INFO: Extensions : GL_ARM_rgba8 GL_ARM_mali_shader_binary GL_OES_depth24 GL_OES_depth_texture GL_OES_depth_texture_cube_map GL_OES_packed_depth_stencil GL_OES_rgb8_rgba8 GL_EXT_read_format_bgra GL_OES_compressed_paletted_texture GL_OES_compressed_ETC1_RGB8_texture GL_OES_standard_derivatives GL_OES_EGL_image GL_OES_EGL_image_external GL_OES_EGL_image_external_essl3 GL_OES_EGL_sync GL_OES_texture_npot GL_OES_vertex_half_float GL_OES_required_internalformat GL_OES_vertex_array_object GL_OES_mapbuffer GL_EXT_texture_format_BGRA8888 GL_EXT_texture_rg GL_EXT_texture_type_2_10_10_10_REV GL_OES_fbo_render_mipmap GL_OES_element_index_uint GL_EXT_shadow_samplers GL_OES_texture_compression_astc GL_KHR_texture_compression_astc_ldr GL_KHR_texture_compression_astc_hdr GL_KHR_texture_compression_astc_sliced_3d GL_EXT_texture_compression_astc_decode_mode GL_EXT_texture_compression_astc_decode_mode_rgb9e5 GL_KHR_debug GL_EXT_occlusion_query_boolean GL_EXT_disjoint_timer_query GL_EXT_blend_minmax GL_EXT_discard_framebuffer GL_OES_get_program_binary GL_OES_texture_3D GL_EXT_texture_storage |
- | INFO: | + | INFO: |
INFO: SDL_GL_RED_SIZE: | INFO: SDL_GL_RED_SIZE: | ||
INFO: SDL_GL_GREEN_SIZE: | INFO: SDL_GL_GREEN_SIZE: | ||
Line 68: | Line 60: | ||
If everything is ok, you will see the cube on screen. | If everything is ok, you will see the cube on screen. | ||
- | |||
- | ===== Troubleshooting ===== | ||
- | |||
- | When you install such version of library you will break some packages (such as guvcview) which depend on the original library, if you don’t want to break the packages you can follow the instructions below to install the original SDL2 library. | ||
- | |||
- | ```sh | ||
- | $ wget http:// | ||
- | $ wget http:// | ||
- | $ sudo dpkg -i libsdl2-2.0-0_2.0.10+dfsg1-3_arm64.deb libsdl2-dev_2.0.10+dfsg1-3_arm64.deb | ||
- | $ sync | ||
- | ``` |