Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - How to pass EGL surface to another program through stream on 7.1: (3 Items)
   
How to pass EGL surface to another program through stream on 7.1  
I found this example from GitHub
https://github.com/kyo504/gles-tutorials/tree/master/gles-3d-cube
Excuse me, how to pass this 3D animation to another program through the stream buffer.
I tried using the SCREEN_PROPERTY_EGL_HANDLE parameter of screen_get_buffer_property_pv but it didn't work
I refer to Screen Graphics Subsystem Developer's Guide ,Chapter 5 Resource Sharing, but can't understand

Producer Stream  -------->  Consumer Stream --> Display
(gles-3d-cube)                      (consumer process)
Attachment: Image 2022-06-23 13_47_36-Window.png 5.41 KB
Re: How to pass EGL surface to another program through stream on 7.1  
on gles-3d-cube.c  modify
screen_window_t screen_win;
screen_stream_t stream_p;//add stream
struct
{
    EGLint render_buffer[2];
    EGLint none;
} egl_surf_attr = {
    .render_buffer = {EGL_RENDER_BUFFER, EGL_BACK_BUFFER}, /* Ask for double-buffering */
    .none = EGL_NONE                                       /* End of list */
};

//on static int initScreen() function before return EXIT_SUCCESS;
//add stream-->
    int success = screen_create_stream(&stream_p, screen_ctx);
	if (success == -1) {
	printf("failed to create stream \n");
		return -1;
	}

	int buffer_size[2] = {1080, 720};
	screen_set_stream_property_iv(stream_p, SCREEN_PROPERTY_BUFFER_SIZE,buffer_size);
	screen_set_stream_property_iv(stream_p, SCREEN_PROPERTY_FORMAT,(const int[]){SCREEN_FORMAT_RGBA8888|
SCREEN_FORMAT_RGBX8888});
	screen_set_stream_property_iv(stream_p, SCREEN_PROPERTY_USAGE,(const int[]){SCREEN_USAGE_OPENGL_ES2 | 
SCREEN_USAGE_WRITE |SCREEN_USAGE_NATIVE|SCREEN_USAGE_READ});

	success = screen_create_stream_buffers(stream_p, 2);
	if (success == -1) {
		printf("failed to create stream buffer\n");
		return -1;
	}

	int permissions;
	screen_get_stream_property_iv(stream_p, SCREEN_PROPERTY_PERMISSIONS,&permissions);
	// Allow processes in the same group to access the stream
	permissions |= SCREEN_PERMISSION_IROTH;
	permissions |= SCREEN_PERMISSION_IWOTH;
	permissions |= SCREEN_PERMISSION_IXOTH;
	screen_set_stream_property_iv(stream_p, SCREEN_PROPERTY_PERMISSIONS,&permissions);

	//<--add stream

//on static int initEGL(void) function change
//egl_surface = eglCreateWindowSurface(egl_display, egl_conf, screen_win, (EGLint *)&egl_surf_attr);
    egl_surface = eglCreateWindowSurface(egl_display, egl_conf, screen_win, &egl_surf_attr);

//on void render() function change make 3d-cube work
//	glDrawArrays(GL_LINES, 0, 6);
	glDrawArrays(GL_POINTS, 0, 6);

//on int main(int argc, char *argv[]) befor while(1) add
screen_buffer_t stream_buf = nullptr;
//in while loop after check if (rc != EGL_TRUE) add
//add stream-->
        success = screen_get_stream_property_pv(  // buffers property
			// A handle to the buffer or buffers available for rendering.
			stream_p, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)&stream_buf);
		if (success == -1) {
			printf("failed to get stream buffer\n");
		  //return -1;
		}
		if (stream_buf == nullptr) {
		  printf("failed to get stream buffer form stream\n");
		  //return -1;
		}else{
			printf("%s:%d,stream_buf is not null\n",__FUNCTION__,__LINE__);
		}
		void *pointer = NULL;
		success = screen_set_buffer_property_pv(stream_buf,SCREEN_PROPERTY_EGL_HANDLE,&pointer);
		pointer = &egl_surf_attr.render_buffer[0];
		if(pointer == NULL) printf("%s:%d,pointer == NULL\n",__FUNCTION__,__LINE__);
		else printf("%s:%d,pointer is not NULL\n",__FUNCTION__,__LINE__);
		success = screen_post_stream(stream_p, stream_buf, 0, nullptr, 0);
		if (success == -1) {
			printf("%s:%d,failed to post stream\n",__FUNCTION__,__LINE__);
		}else{
			printf("%s:%d,post stream success\n",__FUNCTION__,__LINE__);
		}
        //<--add stream

==============================================================================
on Consumer  process refer from https://github.com/youngslab/qnx-stream-api-demo/blob/master/consumer/main.cpp
but that not work on SCREEN_PROPERTY_EGL_HANDLE stream
Re: How to pass EGL surface to another program through stream on 7.1  
update context
//on static int initEGL(void) function change
//egl_surface = eglCreateWindowSurface(egl_display, egl_conf, screen_win, 0);
    egl_surface = eglCreateWindowSurface(egl_display, egl_conf, screen_win, (EGLint *)&egl_surf_attr);