@@ -58,34 +58,46 @@ void egl_fb_setup_default(egl_fb *fb, int width, int height)
5858 fb -> framebuffer = 0 ; /* default framebuffer */
5959}
6060
61- void egl_fb_setup_for_tex (egl_fb * fb , int width , int height ,
62- GLuint texture , bool delete )
61+ void egl_fb_setup_for_tex_target (egl_fb * fb , int width , int height ,
62+ GLuint texture , GLenum target , bool delete )
6363{
6464 egl_fb_delete_texture (fb );
6565
6666 fb -> width = width ;
6767 fb -> height = height ;
6868 fb -> texture = texture ;
69+ fb -> texture_target = target ;
6970 fb -> delete_texture = delete ;
7071 if (!fb -> framebuffer ) {
7172 glGenFramebuffers (1 , & fb -> framebuffer );
7273 }
7374
7475 glBindFramebuffer (GL_FRAMEBUFFER_EXT , fb -> framebuffer );
7576 glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT , GL_COLOR_ATTACHMENT0_EXT ,
76- GL_TEXTURE_2D , fb -> texture , 0 );
77+ fb -> texture_target , fb -> texture , 0 );
7778}
7879
79- void egl_fb_setup_new_tex (egl_fb * fb , int width , int height )
80+ void egl_fb_setup_for_tex (egl_fb * fb , int width , int height ,
81+ GLuint texture , bool delete )
82+ {
83+ egl_fb_setup_for_tex_target (fb , width , height , texture , GL_TEXTURE_2D , delete );
84+ }
85+
86+ void egl_fb_setup_new_tex_target (egl_fb * fb , int width , int height , GLenum target )
8087{
8188 GLuint texture ;
8289
8390 glGenTextures (1 , & texture );
84- glBindTexture (GL_TEXTURE_2D , texture );
85- glTexImage2D (GL_TEXTURE_2D , 0 , GL_RGBA , width , height ,
91+ glBindTexture (target , texture );
92+ glTexImage2D (target , 0 , GL_RGBA , width , height ,
8693 0 , GL_BGRA , GL_UNSIGNED_BYTE , 0 );
8794
88- egl_fb_setup_for_tex (fb , width , height , texture , true);
95+ egl_fb_setup_for_tex_target (fb , width , height , texture , target , true);
96+ }
97+
98+ void egl_fb_setup_new_tex (egl_fb * fb , int width , int height )
99+ {
100+ egl_fb_setup_new_tex_target (fb , width , height , GL_TEXTURE_2D );
89101}
90102
91103void egl_fb_blit (egl_fb * dst , egl_fb * src , bool flip )
@@ -115,7 +127,7 @@ void egl_texture_blit(QemuGLShader *gls, egl_fb *dst, egl_fb *src, bool flip)
115127 glBindFramebuffer (GL_FRAMEBUFFER_EXT , dst -> framebuffer );
116128 glViewport (0 , 0 , dst -> width , dst -> height );
117129 glEnable (GL_TEXTURE_2D );
118- glBindTexture (GL_TEXTURE_2D , src -> texture );
130+ glBindTexture (src -> texture_target , src -> texture );
119131 qemu_gl_run_texture_blit (gls , flip );
120132}
121133
@@ -131,7 +143,7 @@ void egl_texture_blend(QemuGLShader *gls, egl_fb *dst, egl_fb *src, bool flip,
131143 glViewport (x , dst -> height - h - y , w , h );
132144 }
133145 glEnable (GL_TEXTURE_2D );
134- glBindTexture (GL_TEXTURE_2D , src -> texture );
146+ glBindTexture (src -> texture_target , src -> texture );
135147 glEnable (GL_BLEND );
136148 glBlendFunc (GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA );
137149 qemu_gl_run_texture_blit (gls , flip );
0 commit comments