# Render to Texture

**URL:** https://forums.imgtec.com/t/render-to-texture/522
**Category:** PowerVR Insider
**Created:** [November 5, 2009, 1:29am UTC](https://forums.imgtec.com/t/render-to-texture/522 "2009-11-05T01:29:37Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![r2d2proton](https://avatars.discourse-cdn.com/v4/letter/r/cc9497/32.png) [@r2d2proton](https://forums.imgtec.com/u/r2d2proton)
#### Post date: [November 5, 2009, 1:29am UTC](https://forums.imgtec.com/t/render-to-texture/522/1 "2009-11-05T01:29:37Z")

</div>

I’m using OGLES-1.1\_WINDOWS\_PCEMULATION\_2.05.25.0804  
  
  
  
  
  
I am trying to render first to a texture by using a Pbuffer, and then apply the texture to geometry.  
  
  
  
  
  
After creating my window surface and its context, I make the window current, then I create the texture, then the pbuffer and its context, then I make the pbuffer current and then render. Is this correct?  
  
  
  
  
  
Here is the list:  
  
  
  
  
  
Initialize the display  
  
  
Create the window surface & context  
  
  
Make the window surface & context current  
  
  
  
  
  
Create the texture:  
  
  
  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;glGenTextures( 1, &itsMapTexture );  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;glBindTexture( GL\_TEXTURE\_2D, itsMapTexture );  
  
  
  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;glTexParameterf( GL\_TEXTURE\_2D, GL\_TEXTURE\_MIN\_FILTER, GL\_LINEAR );  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;glTexParameterf( GL\_TEXTURE\_2D, GL\_TEXTURE\_MAG\_FILTER, GL\_LINEAR );  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;glTexParameterf( GL\_TEXTURE\_2D, GL\_TEXTURE\_WRAP\_S,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GL\_CLAMP\_TO\_EDGE );  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;glTexParameterf( GL\_TEXTURE\_2D, GL\_TEXTURE\_WRAP\_T,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GL\_CLAMP\_TO\_EDGE );  
  
  
  
  
  
Create the Pbuffer and make it current:  
  
  
  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;itsPbuffer = CreatePbufferSurface( 256, 256, false );  
  
  
  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;clear the color buffer to RED (for testing)  
  
  
  
  
  
Make the window surface current  
  
  
  
  
  
And then when drawing the geometry with the texture I use:  
  
  
  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;glEnable( GL\_TEXTURE\_2D );  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;glBindTexture( GL\_TEXTURE\_2D, itsMapTexture );  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;eglBindTexImage( eglGetCurrentDisplay(), itsPbuffer, EGL\_BACK\_BUFFER );  
  
  
  
  
  
I release the texture after I am done with the current frame  
  
  
  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;eglReleaseTexImage( eglGetCurrentDisplay(), itsPbuffer, EGL\_BACK\_BUFFER );  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;glBindTexture( GL\_TEXTURE\_2D, 0 );  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;glDisable( GL\_TEXTURE\_2D );  
  
  
  
  
  
Is this the right order of steps? Could you please offer some ideas?  
  
  
  
  
  
I am not seeing the cleared buffer value of RED. In fact depending on how I change the order sometimes I see a bright blue, and other times it is a dark blue.  
  
  
  
  
  
Thank you for your help.
