C Specification void glReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid * data); Parameters x, y Specify the window coordinates of the first pixel that is read from the frame buffer. This location is the lower left corner of a rectangular block of pixels. width, height Specify the dimensions of the pixel rectangle. width and height of one correspond to a single pixel. |
[링크 : https://docs.gl/es3/glReadPixels]
static void screenshooter_shoot(struct wl_client *client, struct wl_resource *resource, struct wl_resource *output_resource, struct wl_resource *buffer_resource) { struct wlsc_output *output = output_resource->data; struct wl_buffer *buffer = buffer_resource->data; if (!wl_buffer_is_shm(buffer)) return; if (buffer->width < output->current->width || buffer->height < output->current->height) return; glPixelStorei(GL_PACK_ALIGNMENT, 1); glReadPixels(0, 0, output->current->width, output->current->height, GL_RGBA, GL_UNSIGNED_BYTE, wl_shm_buffer_get_data(buffer)); } |
You can't take screenshots with glReadPixels! |
[링크 : https://stackoverflow.com/questions/44634621/glreadpixels-with-screen-pixels]
대충 짰는데 안되는 듯..
$ cat gl_cap.c #include <stdio.h> #include <GLES2/gl2.h> #include <EGL/egl.h> #include <EGL/eglext.h> void main() { GLubyte color[1024*768*4]; glReadPixels(0,0, 1024, 768, GL_RGBA, GL_UNSIGNED_BYTE, &color); // printf("R:%d G:%d B:%d A:%d", color[0], color[1], color[2], color[3]); for(int y =0 ; y<768;y++) for(int x =0 ; x < 1024; x++) printf("%4d,%3d R:%d G:%d B:%d A:%d\n", x,y ,color[y*1024+x+0] ,color[y*1024+x+1] ,color[y*1024+x+2] ,color[y*1024+x+3] ); } |
링크는 아래와 같이 해주면 되긴 한데...
-lwayland-egl -lGLESv2 |
흐으으으음...
# head dump 0, 0 R:0 G:0 B:0 A:0 1, 0 R:0 G:0 B:0 A:0 2, 0 R:0 G:0 B:0 A:0 3, 0 R:0 G:0 B:0 A:0 4, 0 R:0 G:0 B:0 A:0 5, 0 R:0 G:0 B:0 A:0 6, 0 R:0 G:0 B:0 A:0 7, 0 R:0 G:0 B:0 A:0 8, 0 R:0 G:0 B:0 A:0 9, 0 R:0 G:0 B:0 A:0 # tail dump 1014,767 R:0 G:0 B:0 A:0 1015,767 R:0 G:0 B:0 A:0 1016,767 R:0 G:0 B:0 A:0 1017,767 R:0 G:0 B:0 A:0 1018,767 R:0 G:0 B:0 A:0 1019,767 R:0 G:0 B:0 A:0 1020,767 R:0 G:0 B:0 A:0 1021,767 R:0 G:0 B:0 A:0 1022,767 R:0 G:0 B:0 A:0 1023,767 R:0 G:0 B:0 A:0 |
'프로그램 사용 > wayland' 카테고리의 다른 글
wayland atomic commit 패치? (0) | 2022.08.22 |
---|---|
weston screen shooter 뜯어보기 (0) | 2022.08.17 |
sway + wayvnc (0) | 2022.08.10 |
wayvnc 0.5 릴리즈 (0) | 2022.08.09 |
capture drm screen (0) | 2022.08.08 |