# can i draw framebuffer ?

**URL:** <https://forums.imgtec.com/t/can-i-draw-framebuffer/814>\
**Category:** PowerVR Insider\
**Created:** [August 26, 2010, 1:02am UTC](https://forums.imgtec.com/t/can-i-draw-framebuffer/814 "2010-08-26T01:02:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gbaup](https://avatars.discourse-cdn.com/v4/letter/g/ecccb3/32.png) [@gbaup](https://forums.imgtec.com/u/gbaup)\
**Post date:** [August 26, 2010, 1:02am UTC](https://forums.imgtec.com/t/can-i-draw-framebuffer/814/1 "2010-08-26T01:02:28Z")

</div>

i have&nbsp; RGBA5551 data ( GLushort pdata[512\*512]) ,the data \<SPAN id=result\_ =“short\_text”\>Similar \<SPAN id=result\_ =“short\_text”\>Video,away \<SPAN id=result\_ =“short\_text”\>Update.

&nbsp;
  

now my code:
  

===================
  

init 
  

{
  

&nbsp; glTexImage2D(GL\_TEXTURE\_2D, 0, GL\_RGBA, 512,512, 0, GL\_RGBA,GL\_UNSIGNED\_SHORT\_5\_5\_5\_1,pdata);
glTexParameterf(GL\_TEXTURE\_2D,GL\_TEXTURE\_MIN\_FILTER, GL\_NEAREST);  
&nbsp;glTexParameterf(GL\_TEXTURE\_2D,GL\_TEXTURE\_MAG\_FILTER, GL\_NEAREST);  

&nbsp;
  

}
  

&nbsp;
  

Render
  

{
  

&nbsp;&nbsp; update pdata[] data;
  

&nbsp; (i use memset ,so Ignore calculation Expend time)
  

&nbsp;
  

&nbsp;&nbsp;&nbsp;glTexSubImage2D( ...512,512...);
  

&nbsp;&nbsp;&nbsp; ....
  

&nbsp;&nbsp; glDrawArrays(GL\_TRIANGLE\_STRIP,0,4);
  

}
  

==========================
  

Expend 50 ms per frame.(20 FPS)
  

&nbsp;
  

(use RGB888 ,Expend&nbsp;70 ms per frame)
  

&nbsp;
  

i&nbsp;need to Faster .
  

&nbsp;
  

can i Direct draw framebuffer ?
  

Which functions?
  

&nbsp;
  

or other Suggest.
  

&nbsp;
  

tks.
gbaup2010-08-26 03:06:29

---

<div class="post-metadata">

**Author:** ![gbaup](https://avatars.discourse-cdn.com/v4/letter/g/ecccb3/32.png) [@gbaup](https://forums.imgtec.com/u/gbaup)\
**Post date:** [August 26, 2010, 6:26am UTC](https://forums.imgtec.com/t/can-i-draw-framebuffer/814/2 "2010-08-26T06:26:58Z")

</div>

i read&nbsp; OPENGL PBO for streaming textures.

&nbsp;
  

====================
  

  

 glBindBuffer(GL\_PIXEL\_UNPACK\_BUFFER\_ARB, pboBufferID);
  

====================
#define GL\_PIXEL\_UNPACK\_BUFFER\_ARB 0x88EC  

&nbsp;
  

i don't kown OPENGLES1.X 
  

&nbsp;
  

glBindBuffer( **WHAT?** , pboBufferID);
  

&nbsp;
  

  
&nbsp;

---

<div class="post-metadata">

**Author:** ![JoeDavis](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/joedavis/32/71_2.png) [@JoeDavis](https://forums.imgtec.com/u/JoeDavis)\
**Post date:** [August 26, 2010, 8:01am UTC](https://forums.imgtec.com/t/can-i-draw-framebuffer/814/3 "2010-08-26T08:01:33Z")

</div>

Unfortunately, PBO’s are unavailable in OpenGL ES (A list of all possible extensions for OpenGL ES 1.x & 2.0 is available [here](http://www.khronos.org/registry/gles/))  
  
  
  
  
  
If you have access to the IMG texture streaming extension (which I assume is a possibility, after you started [this](https://www.imgtec.com/forum/forum_posts.asp?TID=953) topic) then you may be able to create a texture stream to write your decoded images to, which will allow you to use your video frames as textures within your application. This will remove the bottle neck of regularly copying images into your application and uploading them through GL calls.Joe2010-08-27 09:51:49

---

<div class="post-metadata">

**Author:** ![gbaup](https://avatars.discourse-cdn.com/v4/letter/g/ecccb3/32.png) [@gbaup](https://forums.imgtec.com/u/gbaup)\
**Post date:** [August 26, 2010, 11:33pm UTC](https://forums.imgtec.com/t/can-i-draw-framebuffer/814/4 "2010-08-26T23:33:58Z")

</div>

&nbsp;yes.i have access to the&nbsp; IMG texture streaming extension .

&nbsp;
  

i kown "how to extension "&nbsp;,but i don't kown "how to use the Function"
  

&nbsp;
  

but ,
  

&nbsp;
  

glTexBindStreamIMG( **WHAT?,** **WHAT?);**  
glGetTexStreamDeviceAttributeivIMG(GLint device, GLenum pname, GLint \*params);  
GLubyte \* GL\_APIENTRY glGetTexStreamDeviceNameIMG(GLint device);
  

  

======================
  

the device....what is?
  

GLint \*params ....i don't kown "how to bulid".
  

&nbsp;
  

i just have&nbsp; pdata[] (decoded done)
  

&nbsp;
  

i using TI3530 ,POWERVR SGX530.

gbaup2010-08-27 01:38:56

---

<div class="post-metadata">

**Author:** ![JoeDavis](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/joedavis/32/71_2.png) [@JoeDavis](https://forums.imgtec.com/u/JoeDavis)\
**Post date:** [August 27, 2010, 7:46am UTC](https://forums.imgtec.com/t/can-i-draw-framebuffer/814/5 "2010-08-27T07:46:59Z")

</div>

If you look through the code in the link you sent in the other topic you started, there is an example of glTexBindStreamIMG being used.  
  
  
  
  
  
The first parameter passed to glTexBindStreamIMG() is the ID of the texture stream (an integer value that either can be retrieved through a driver developer specific texture stream creation/management module (such as the [TI bc-cat kernel module](http://processors.wiki.ti.com/index.php/OpenGLES_Texture_Streaming_-_bc-cat_User_Guide)), or the driver supplier should be able to tell you this value if it is hidden).  
  
  
The second parameter is an integer ID for the particular buffer within the stream that you want to bind (between 0 and the maximum number of buffers available in the texture stream).  
  
  
  
  
  
Personally, my approach is the following (where I have assumed you already know the texture stream ID you should be using and have assigned the value to i32TexStreamId):

Code:

  
/\* Query buffer device details through GL extensions \*/  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;myglGetTexStreamDeviceAttributeivIMG(i32TexStreamId, GL\_TEXTURE\_STREAM\_DEVICE\_NUM\_BUFFERS\_IMG, &i32BufferCount);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;myglGetTexStreamDeviceAttributeivIMG(i32TexStreamId, GL\_TEXTURE\_STREAM\_DEVICE\_WIDTH\_IMG, &i32Width);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;myglGetTexStreamDeviceAttributeivIMG(i32TexStreamId, GL\_TEXTURE\_STREAM\_DEVICE\_HEIGHT\_IMG, &i32Height);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;myglGetTexStreamDeviceAttributeivIMG(i32TexStreamId, GL\_TEXTURE\_STREAM\_DEVICE\_FORMAT\_IMG, &i32Format);  

  
  
  
After this, the i32TexStreamId value can be used to allocate texture handles and bind them to each buffer within the texture stream:  
  
  
  

Code:

  
/\* Allocate the required number of texture handles \*/  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puiTexture = new GLuint[i32BufferCount];  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/\* Bind a texture to each buffer in the buffer device \*/  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;glGenTextures(i32BufferCount, puiTexture);  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;glActiveTexture(GL\_TEXTURESTREAM);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(j = 0; j \< i32BufferCount ; ++j)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;glBindTexture(GL\_TEXTURE\_STREAM\_IMG, puiTexture[j]);  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;glTexParameterf(GL\_TEXTURE\_STREAM\_IMG, GL\_TEXTURE\_MIN\_FILTER, TEXTURE\_STREAM\_FILTER);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;glTexParameterf(GL\_TEXTURE\_STREAM\_IMG, GL\_TEXTURE\_MAG\_FILTER, TEXTURE\_STREAM\_FILTER);  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;myglTexBindStreamIMG(i32TexStreamId, j);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  

  
  
  
Once this has been done, the texture stream buffers can be used in a similar way as 2D textures:  
  
  
  

Code:

  
/\* Bind texture \*/  
glActiveTexture(GL\_TEXTURESTREAM);  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;glBindTexture(GL\_TEXTURE\_STREAM\_IMG, puiTexture[uiCurrentBuffId]);  

  
  
  
Let me know if this helps :)Joe2010-08-31 09:58:26

---

<div class="post-metadata">

**Author:** ![gbaup](https://avatars.discourse-cdn.com/v4/letter/g/ecccb3/32.png) [@gbaup](https://forums.imgtec.com/u/gbaup)\
**Post date:** [August 28, 2010, 11:51pm UTC](https://forums.imgtec.com/t/can-i-draw-framebuffer/814/6 "2010-08-28T23:51:18Z")

</div>

thank you very much.
