GL texture problems

Aric Cyr Aric.Cyr at gmail.com
Mon Feb 13 21:31:42 CST 2006


H. Verbeet <hverbeet <at> gmail.com> writes:

> 
> On 13/02/06, Stefan Dösinger <stefandoesinger <at> gmx.at> wrote:
> > Hello,
> > I'm trying to change IWineD3DSurface::UnlockRect for rendertargets to avoid
> > glDrawPixels. Instead, I'd like to load the image from memory into an OpenGL
> > texture, and draw that texture with a textured quad onto the front / back
> > buffer.
> >
> 
> I've only had a quick look, so I may have overlooked it, but were do
> you bind the texture?
> 

Indeed, from looking at the patch you will need to call glGenTextures, then
glBindTexture.  Something like the following should.  However if you anticipate
the texture target getting rebound overtime, you will have to maintain the
texture  ID so you can rebind it with glBindTexture() before each call to
glTexSubImage2D.


            glGenTextures(1, &This->texture_id);
            checkGLcall("glGenTextures");
            
            glBindTexture(GL_TEXTURE_2D, This->texture_id);
            checkGLcall("glBindTexture");

            glTexImage2D(GL_TEXTURE_2D, 0,
                        D3DFmt2GLIntFmt(myDevice, This->resource.format),
                        This->pow2Width,
                        This->pow2Height,
                        0,
                        D3DFmt2GLFmt(myDevice, This->resource.format),
                        D3DFmt2GLType(myDevice, This->resource.format),
                        NULL);
            checkGLcall("glTexImage2D");

On termination you should cleanup with glDeleteTextures(1, &This->texture_id).

Regards,
  Aric




More information about the wine-devel mailing list