mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-08-04 09:44:16 +00:00
[client/obs] improve frambuffer_read functions to support copy pitch
Fixes #244
This commit is contained in:
@@ -33,7 +33,8 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
struct EGL_Texture
|
||||
{
|
||||
enum EGL_PixelFormat pixFmt;
|
||||
size_t width, height;
|
||||
size_t width, height, stride;
|
||||
size_t bpp;
|
||||
bool streaming;
|
||||
bool ready;
|
||||
|
||||
@@ -106,6 +107,7 @@ bool egl_texture_setup(EGL_Texture * texture, enum EGL_PixelFormat pixFmt, size_
|
||||
texture->pixFmt = pixFmt;
|
||||
texture->width = width;
|
||||
texture->height = height;
|
||||
texture->stride = stride;
|
||||
texture->streaming = streaming;
|
||||
texture->ready = false;
|
||||
|
||||
@@ -113,6 +115,7 @@ bool egl_texture_setup(EGL_Texture * texture, enum EGL_PixelFormat pixFmt, size_
|
||||
{
|
||||
case EGL_PF_BGRA:
|
||||
textureCount = 1;
|
||||
texture->bpp = 4;
|
||||
texture->format = GL_BGRA;
|
||||
texture->planes[0][0] = width;
|
||||
texture->planes[0][1] = height;
|
||||
@@ -125,6 +128,7 @@ bool egl_texture_setup(EGL_Texture * texture, enum EGL_PixelFormat pixFmt, size_
|
||||
|
||||
case EGL_PF_RGBA:
|
||||
textureCount = 1;
|
||||
texture->bpp = 4;
|
||||
texture->format = GL_RGBA;
|
||||
texture->planes[0][0] = width;
|
||||
texture->planes[0][1] = height;
|
||||
@@ -137,6 +141,7 @@ bool egl_texture_setup(EGL_Texture * texture, enum EGL_PixelFormat pixFmt, size_
|
||||
|
||||
case EGL_PF_RGBA10:
|
||||
textureCount = 1;
|
||||
texture->bpp = 4;
|
||||
texture->format = GL_RGBA;
|
||||
texture->planes[0][0] = width;
|
||||
texture->planes[0][1] = height;
|
||||
@@ -149,6 +154,7 @@ bool egl_texture_setup(EGL_Texture * texture, enum EGL_PixelFormat pixFmt, size_
|
||||
|
||||
case EGL_PF_YUV420:
|
||||
textureCount = 3;
|
||||
texture->bpp = 4;
|
||||
texture->format = GL_RED;
|
||||
texture->planes[0][0] = width;
|
||||
texture->planes[0][1] = height;
|
||||
@@ -287,7 +293,16 @@ bool egl_texture_update_from_frame(EGL_Texture * texture, const FrameBuffer * fr
|
||||
if (texture->pboCount == 2)
|
||||
return true;
|
||||
|
||||
framebuffer_read(frame, texture->pboMap[texture->pboWIndex], texture->pboBufferSize);
|
||||
framebuffer_read(
|
||||
frame,
|
||||
texture->pboMap[texture->pboWIndex],
|
||||
texture->stride,
|
||||
texture->height,
|
||||
texture->width,
|
||||
texture->bpp,
|
||||
texture->stride
|
||||
);
|
||||
|
||||
texture->pboSync[texture->pboWIndex] = 0;
|
||||
|
||||
if (++texture->pboWIndex == 2)
|
||||
@@ -383,4 +398,4 @@ enum EGL_TexStatus egl_texture_bind(EGL_Texture * texture)
|
||||
int egl_texture_count(EGL_Texture * texture)
|
||||
{
|
||||
return texture->textureCount;
|
||||
}
|
||||
}
|
||||
|
@@ -1274,14 +1274,19 @@ static bool draw_frame(struct Inst * this)
|
||||
glBindTexture(GL_TEXTURE_2D, this->frames[this->texIndex]);
|
||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, this->vboID[this->texIndex]);
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT , 4);
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH , this->format.stride);
|
||||
const int bpp = this->format.bpp / 8;
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT , bpp);
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, this->format.width);
|
||||
|
||||
this->texPos = 0;
|
||||
|
||||
framebuffer_read_fn(
|
||||
this->frame,
|
||||
this->format.height,
|
||||
this->format.width,
|
||||
bpp,
|
||||
this->format.pitch,
|
||||
opengl_buffer_fn,
|
||||
this->format.height * this->format.stride * 4,
|
||||
this
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user