This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] PROCESSOR-SDK-AM437X:OpenGL 和 Wayland 问题

Guru**** 2983910 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/processors-group/processors/f/processors-forum/678227/processor-sdk-am437x-opengl-and-wayland-issue

器件型号:PROCESSOR-SDK-AM437X

您好!

我正在处理一些不在 AM437X SDK 上使用 QT 的 openglGL 应用。 我使用的是最新的 RT-Linux SDK ti-processor-sdk-linux-rt-AM437X-EVM-04.02.00.09。

我搜索了一些基于 wayland + OpenGL es 的应用程序,但我没有找到一个应用程序,在该应用程序中我可以看到 Weston 顶部有一个窗口正在打开,但我无法在该窗口上绘制任何内容。

有关如何使用 SDK 中存在的 OpenGL 库通过 wayland EGL 窗口绘制一些基元的任何帮助。

基于 AM437X EVM 的 wayland+ OpenGL/DRM+OpenGL 的任何示例应用程序源。

这里是我可以在 Weston 顶部打开窗口的示例代码,“Draw”函数可以更改窗口的颜色,但如果我尝试使用  glDrawArrays 绘制三角形/基元 ,屏幕上没有显示任何内容。  

// gcc -o test init_window.c -i. -lwayland-client -lwayland-server -lwayland-client-protocol -lpvr_wlegl -lEGL -lGLESv2
#include 
#include 
#include 
#include // Wayland EGL 必须包含在 EGL 头

#include "init_window.h"
#include "log.h"

#include 之前 
#include 

#include 

struct wL_compositor *合成器= NULL;
struct wL_surface *曲面;
struct wL_EGL_Window * EGL_Window;
struct wL_region *区域;
struct wL_shell *外壳;
struct wL_shell_surface * shell_surface;

struct _escontext ESContext ={
.native_display = NULL、
.window_width = 0、
.window_height = 0、
.native_window = 0、
.display = NULL、
.context = NULL、
.surface = NULL
};

#define true 1
#define false 0

#define Window_width 1280
#define Window_Height 720

void CreateNativeWindow (char *标题、int 宽度、int 高度){

region = wL_compositor_create_region (compositor);

wL_region_add (region、0、0、width、 高度);
WL_surface_set_不透明 区域(表面、区域);

struct WL_EGL_Window * EGL_Window =
WL_EGL_WINDOW_CREATE (表面、宽度、高度);

if (EGL_Window = EGL_NO_STICAL){
日志("无窗口!?\n");
EXIT (1);
}
else log ("创建的窗口!\n");
ESContext.window_width = width;
ESContext.window_height = height;
ESContext.native_window = EGL_Window;

}

EGLBoolean EGLContext ()
{
EGLint numConfigs;
EGLint MajorVersion;
EGLminorSurface
上下文
;EGLint EGLminorSurface 上下文;EGLint EGLint EGLint 环境
EGLConfig 配置;
EGLint fbAttribs[]=
{
EGL_surface_type、EGL_window_bit、
EGL_RENDERABLE_TYPE、EGL_OpenGL_ES2_BIT、
EGL_RED_SIZE、 8、
EGL_GREEN_SIZE、 8、
EGL_blue_size、 8、
EGL_none
};
EGLint contextAttribs[]={EGL_context_client_version、2、EGL_none、EGL_none};
EGLDisplay 显示= eglGetDisplay( ESContext.native_display );
if ( display =EGL_no_display )
{
日志("无 EGL 显示...\n");
返回 EGL_false;
}

//初始化 EGL
if (!eglInitialize (display、&MajorVersion、&minorVersion))
{
日志("未初始化...\n");
返回 EGL_false;
}

//获取配置
if (((eglGetConfigs (display、NULL、0、&numConfigs)!= EGL_true)||(numConfigs ==0))
){
日志("无配置...\n");
返回 EGL_false;
}

//如果

(((eglChooseConfig (display、fbAttribs、&config、1、&numConfigs)!= EGL_true)||(numConfigs!= 1)){,则选择 config
日志("无配置...\n");
返回 EGL_false;
}

//创建曲面
= eglCreateWindowSurface (display、config、ESContext.native_window、NULL);
if (surface == EGL_no_surface)
{
日志("无曲面...\n");
返回 EGL_false;
}

//创建 GL 上下文
上下文上下文= eglCreateContext (display、config、EGL_NO_Context、contextAtribs);
if (上下文=EGL_NO_Context)
{
日志("无上下文...\n");
如果



(!eglMakeCurrent (display、surface、surface、context))
){,则返回 EGL_false;}//使上下文为当前
log ("无法使当前窗口成为当前窗口!\n");
返回 EGL_false;
}

ESContext.display = display;
ESContext.surface = surface;
ESContext.context = context;
return EGL_true;
}

void shell_surface_ping
(void *数据、struct WL_shell_surface * shell_surface、uint32_t serial){void shell
shell shell_surface_pong (serial_surface_test *数据、struct 32



)、void * t_t_t_t_structure

= t_int32、t_t_t_tidt_t_t_t_t_t_t_t_t_t_t_t_t_t_t_t_sh
WL_EGL_Window_Resize (ESContext.native_Window、宽度、高度、0、 0);
}

void shell_surface_popup_done (void *数据、struct wL_shell_surface * shell_surface_listener


shell_surface_listener ={&shell_surface_ping
、
&shell_surface_configure、
&shell_surface_popup_done
};

EGLWithWindowContext (布尔*宽度) int height){
CreateNativeWindow (title、width、height);
return CreateEGLContext ();
}

void Draw (){
glClearColor (1.0、0.3、0.0、1.0);
glClear (gL_color_buffer_bit);
//渲染由3个顶点组成的三角形:
// glDrawgmp 数组(gL_triggers、0、3);

}

unsigned long last_click = 0;
void RefreshWindow(){eglSwapmp 缓冲器(ESContext.display、ESContext.surface);}

static void global_register_handler
(void *数据、strt registry *注册表*注册表、UWL 32_t 缓冲区、uwl 32、context、eonchar


)、"n"(如果是%t_interface、则为%t_integin)、则为%t_integin (n_interface)
合成器=
wl_registry_bind (registry、id、&wl_compositor_interface、1);

否则、如果(strcmp (interface、"wL_shell")=0)
shell = wL_registry_bind (registry、id、&wL_shell_interface、1);
}

static void global_registry_remover (
void * data、struct








void * registry、uint32_t id){log ("为%d\n"获取注册表丢失事件、id);}const struct wL_registry ={wl_display_connector_connect
={wL_static (global_display_registry

={wL_display_registry =}
if (display =NULL){
log ("无法连接到航迹显示!?\n");
exit (1);
}
log ("获得显示!");

struct wL_registry * wL_registry =
wl_display_get_registry (display);
wl_registry_add_listener (wl_registry、&listener、NULL);

//此调用附加的侦听器 global_registry_handler
wL_display_dispatch (display);
wL_display_roundTrip (display);

//如果此时,global_registry_handler 没有设置
//合成器,也没有设置 shell,则执行!
if (合成器=NULL || shell =NULL){
log ("无合成器!? 没有外壳!! 这里没有任何东西!\n");
退出(1);
}
否则{
log ("好的、我们有一个合成器和一个外壳... 这是什么!\n");
ESContext.native_display = display;
}
}

void destroyWindow (){
eglDestroySurface (ESContext.display、ESContext.surface);
WL_EGL_window_destroy (ESContext.native_Window);
WL_shell_surface_destroy (shell_surface);
WL_surface_destroy (surface);WL_surface_destroy_dest_destroy (surface);
eglDestroyContext (ESContext.display、ESContext.context);
}

int main(){
get_server_references ();

surface = WL_compositor_create_surface (compositor);
if (surface = NULL){
log ("无组合器表面! 是的...\n");
exit (1);
}
else log ("获得合成器表面!\n");

shell_surface = wL_shell_get_shell_surface (shell、surface);
wL_shell_surface_set_toplevel (shell_surface);

CreateWindowWithEGLContext ("Nya"、 1280、720);

while (1){
WL_DISPLAY_DELAG_PENDING (ESContext.native_display);
Draw ();
RefreshWindow();
}

WL_DISPLAY_DISCONNECT (ESContext.native_display);
log ("显示已断开连接!\n"\});

退出(0);
} 

此致、

Vimal Kumar

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    请参阅 Weston-simple-EGL 应用程序。 该二进制文件打包在处理器 SDK 文件系统中。 当您通过 Arago 构建软件包时、您可以找到源代码。
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    谢谢。