Hi NXP,
I am currently testing filling with wayland, EGL, and OpenGLES, but nothing is being displayed on the monitor.
- There are no errors occurring.
- The sample "tiger" is displayed correctly on the monitor.
Could you please let me know if there are any possible reasons why nothing is being displayed on the monitor? Also, if there are any specific things I should investigate, please advise.
CPU: i.MX8MPlus
Here is the log and the source code I am testing with:
--------------------------
test software
--------------------------
#include <stdio.h>#include <stdlib.h>
#include <EGL/egl.h>
#include <VG/openvg.h>
#include <VG/vgu.h>
#include <errno.h>
#include <EGL/eglext.h>
#include <wayland-client.h>
#include <wayland-cursor.h>
#include <wayland-egl.h>
#include <GLES2/gl2.h>
#define WINDOW_WIDTH 1920
#define WINDOW_HEIGHT 1080
EGLDisplay egl_display = EGL_NO_DISPLAY;
EGLSurface egl_surface;
typedef struct
{
struct wl_display* display;
struct wl_compositor* compositor;
} display_t;
display_t disp;
static void _registry_global(
void *data,struct wl_registry *registry,
uint32_t id,const char *interface,uint32_t version)
{
struct display* d = (struct display*)data;
printf("_registry_global()=%s ver=%d\n",interface,version);
if(strcmp(interface, "wl_compositor") == 0)
{
disp.compositor = wl_registry_bind(registry, id, &wl_compositor_interface, 1);
}
}
static void _registry_global_remove(void *data,struct wl_registry *registry,uint32_t id)
{
printf("%s line=%d\n",__func__,__LINE__);
}
static const struct wl_registry_listener g_reg_listener = {
_registry_global, _registry_global_remove
};
static void egl_error_print(int line)
{
EGLint error = eglGetError();
printf("%s line=%d error=%d\n",__func__,line,error);
switch (error) {
case EGL_BAD_DISPLAY: printf("EGL error: EGL_BAD_DISPLAY\n"); break;
case EGL_BAD_CONFIG: printf("EGL error: EGL_BAD_CONFIG\n"); break;
case EGL_BAD_CONTEXT: printf("EGL error: EGL_BAD_CONTEXT\n"); break;
case EGL_BAD_ATTRIBUTE: printf("EGL error: EGL_BAD_ATTRIBUTE\n"); break;
default: printf("EGL error: Unknown error\n"); break;
}
}
static void gles_error_print(int line)
{
GLenum error = glGetError();
if (error != GL_NO_ERROR) {
switch (error) {
case GL_INVALID_ENUM: printf("GLES error:GL_INVALID_ENUM line=%d\n\n",line); break;
case GL_INVALID_VALUE: printf("GLES error:GL_INVALID_VALUE\n line=%d", line); break;
default: printf("GLES error:%d line=%d\n",error,line); break;
}
}
else
{
printf("GLES:GL_NO_ERROR line=%d\n",line);
}
return;
}
int main()
{
static struct wl_display *display = NULL;
static struct wl_egl_window *egl_window = NULL;
int i;
display = wl_display_connect(NULL);
if (!display)
{
printf("Failed to connect to Wayland display\n");
}
static struct wl_registry* registry = NULL;
registry = wl_display_get_registry(display);
if (registry == NULL) {
printf("Failed to create Wayland registry\n");
}
wl_registry_add_listener(registry, &g_reg_listener, NULL);
wl_display_dispatch(display);
wl_display_roundtrip(display);
egl_display = eglGetDisplay(display);
if (egl_display == EGL_NO_DISPLAY)
{
printf("display error\n");
}
EGLint major = 0, minor = 0;
if ( EGL_FALSE == eglInitialize(egl_display, &major, &minor) )
{
printf("init error\n");
}
printf("major=%d minor=%d\n",major,minor);
if( eglBindAPI(EGL_OPENGL_ES_API) == EGL_FALSE )
{
printf("bind error\n");
}
printf("%s line=%d\n",__func__,__LINE__);
EGLint config_attribs[] = {
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
EGL_DEPTH_SIZE,24,
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_SAMPLES, 0,
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
EGL_ALPHA_SIZE, 0,
EGL_NONE,
};
EGLConfig egl_config;
EGLint num_configs = 0;
if( eglChooseConfig(egl_display, config_attribs, &egl_config, 1, &num_configs) == EGL_FALSE )
{
printf("eglChooseConfig error\n");
}
printf("num_configs=%d\n",num_configs);
struct wl_surface *surface = wl_compositor_create_surface(disp.compositor);
if (surface == NULL)
{
printf("Failed to create Wayland surface\n");
}
printf("%s line=%d\n",__func__,__LINE__);
egl_window = wl_egl_window_create(surface, WINDOW_WIDTH, WINDOW_HEIGHT);
if (egl_window == NULL) {
printf("Failed to create Wayland EGL window\n");
}
printf("%s line=%d\n",__func__,__LINE__);
egl_surface = eglCreateWindowSurface(egl_display, egl_config, egl_window, NULL/*context_attribs*/);
if (egl_surface == EGL_NO_SURFACE) {
printf("Failed to create EGL surface\n");
}
printf("%s line=%d\n",__func__,__LINE__);
EGLint context_attribs[] = {
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE
};
EGLContext egl_context = eglCreateContext(egl_display, egl_config, EGL_NO_CONTEXT, context_attribs);
if (egl_context == EGL_NO_CONTEXT) {
egl_error_print(__LINE__);
printf("Failed to create EGL context\n");
}
if (eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_context) == EGL_FALSE) {
printf("Failed to make EGL context current\n");
}
printf("%s line=%d\n",__func__,__LINE__);
{
EGLint val = 0;
printf("%s\n", glGetString(GL_VENDOR));
printf("%s\n", glGetString(GL_RENDERER));
printf("%s\n", glGetString(GL_VERSION));
eglGetConfigAttrib(egl_display, egl_config, EGL_RED_SIZE, &val);
printf("EGL_RED_SIZE:%d\n", (int)val);
eglGetConfigAttrib(egl_display, egl_config, EGL_GREEN_SIZE, &val);
printf("EGL_GREEN_SIZE:%d\n", (int)val);
eglGetConfigAttrib(egl_display, egl_config, EGL_BLUE_SIZE, &val);
printf("EGL_BLUE_SIZE:%d\n", (int)val);
eglGetConfigAttrib(egl_display, egl_config, EGL_ALPHA_SIZE, &val);
printf("EGL_ALPHA_SIZE:%d\n", (int)val);
eglGetConfigAttrib(egl_display, egl_config, EGL_DEPTH_SIZE, &val);
printf("EGL_DEPTH_SIZE:%d\n", (int)val);
eglGetConfigAttrib(egl_display, egl_config, EGL_SAMPLES, &val);
printf("EGL_SAMPLES:%d\n", (int)val);
eglGetConfigAttrib(egl_display, egl_config, EGL_RENDERABLE_TYPE, &val);
printf("EGL_RENDERABLE_TYPE:%d\n", (int)val);
glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
gles_error_print(__LINE__);
glClear(GL_COLOR_BUFFER_BIT);
gles_error_print(__LINE__);
}
if( eglSwapBuffers(egl_display, egl_surface) == EGL_TRUE )
{
printf("eglSwapBuffers:Success\n");
}
else
{
printf("eglSwapBuffers:Error\n");
}
glFlush();
return 0;
}