My environment is:
- Pi 3B running 32-bit Raspbian bullseye, with newest update.
- To make things clear, I uninstalled desktop environment.
- /boot/config.txt related lines:
Code: Select all
# camera related config
camera_auto_detect=1
dtoverlay=imx290,clock-frequency=37125000
# display related
display_auto_detect=1
dtoverlay=vc4-kms-v3d,composite
max_framebuffers=2
gpu_mem=256
Code: Select all
#include <SDL.h>
#include <cstring>
#include <iostream>
#include <thread>
#include <SDL_opengles2.h>
using namespace std::chrono_literals;
using std::clog;
using std::endl;
int main()
{
auto init_re = SDL_VideoInit("KMSDRM");
if (init_re != 0)
exit(EXIT_FAILURE);
SDL_Window *window = SDL_CreateWindow("SDL2", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480,
SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL);
if (nullptr == window)
{
std::cerr << "SDL_CreateWindow(): " << SDL_GetError() << '\n';
exit(EXIT_FAILURE);
}
auto gl = SDL_GL_CreateContext(window);
clog << "create OpenGL context " << gl << endl;
auto make_current_re = SDL_GL_MakeCurrent(window, gl);
clog << "make current ctx returned " << make_current_re << endl;
glClearColor(0.5, 0.5, 0.5, 1.0);
size_t frame_count = 0;
while (true)
{
frame_count += 1;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
clog << "frame " << frame_count << endl;
std::this_thread::sleep_for(2ms);
}
SDL_GL_DeleteContext(gl);
SDL_DestroyWindow(window);
SDL_Quit();
}
In addition, after this program is run and killed (either called with monitor, keyboard connected to pi in a local session , or called from a remote SSH session), the keyboard directly connected to the Pi does not respond to my input, and I have to take any further input actions from a remote SSH session.