Hello,
I have a basic SDL window application in C . It works fine in my host system . I need to run this application in imx6dl processor, for that I added SDL2 library dependency by using IMAGE_INSTALL += " libsdl2" in yocto and generated a bin file by cross compiling the application . While running the application , I am unable to create SDL window . And the error message generated by using SDL_GetError() is
failed to create an EGL window surface
I had, set added the opengl dependency in yocto by using the below lines :
IMAGE_INSTALL += " mesa"
DISTRO_FEATURES:append = " opengl egl gles2 wayland"
I am using x11 SDL_VideoDriver in my host to create SDL window, but the imx6dl processor has no x11 SDL_VideoDriver . It has wayland SDL_VideoDriver . So I created the SDL application with wayland SDL_VideoDriver, set the environment variable as wayland by using export SDL_VIDEODRIVER=wayland and tried to run in the imx6dl, but no use . Could anyone please help me on this issue ??
#include <SDL2/SDL.h>
#include <stdio.h>
int main(int argc, char* argv) {
// Set the SDL video driver to Wayland before SDL_Init
SDL_setenv(“SDL_VIDEODRIVER”, “wayland”, 1);
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
printf("SDL_Init Error: %s\n", SDL_GetError());
return 1;
}
int numVideoDrivers = SDL_GetNumVideoDrivers();
printf("Number of video drivers: %d\n", numVideoDrivers);
for (int i = 0; i < numVideoDrivers; ++i) {
printf("Video driver %d: %s\n", i, SDL_GetVideoDriver(i));
}
SDL_Window *win = SDL_CreateWindow("Hello SDL2", 100, 100, 640, 480, SDL_WINDOW_SHOWN);
if (win == NULL) {
printf("SDL_CreateWindow Error: %s\n", SDL_GetError());
SDL_Quit();
return 1;
}
SDL_Renderer *ren = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
if (ren == NULL) {
SDL_DestroyWindow(win);
printf("SDL_CreateRenderer Error: %s\n", SDL_GetError());
SDL_Quit();
return 1;
}
SDL_SetRenderDrawColor(ren, 255, 0, 0, 255);
SDL_RenderClear(ren);
SDL_RenderPresent(ren);
SDL_Delay(10000);
SDL_DestroyRenderer(ren);
SDL_DestroyWindow(win);
SDL_Quit();
return 0;
}
I tried with above example by setting the driver to wayland .