Frederic BOUVIER wrote:
> Erik Hofman wrote : 
> > > Frederic Bouvier wrote: 
> > > Please ignore my previous patch. It only produce white splash. Instead, 
> > > please apply the one below. The memory is deleted in the destructor. 
> > 
> > Well, that way the texture data is kept in memory at three different places: 
> > 
> > 1. Main memory (because of your patch) 
> > 2. Main memory (OpenGL driver) 
> > 3. Texture memory. 
> > 
> > We should be able to delete the texture data after sending it to OpenGL. 
> 
> Are you sure 1. and 2. are separate areas ? Is the copy specified in 
> OpenGL ? 
> 
> After I submitted the first patch, I noticed 2 white splash in a row, then I 
> removed the delete and the clear of the pointer and the white splash 
> disappeared. 
>
> I can make more test this evening to be sure. 

It seems that SGTexture makes the assumption that when texture_data is null,
the texture is not yet created, without looking at texture_id.
For example, 

void
SGTexture::finish(unsigned int width, unsigned int height) {
    // If a texture hasn't been created then it gets created, and the contents
    // of the frame buffer gets copied into it. If the texture has already been
    // created then its contents just get updated.
    bind();
    if (!texture_data)
    {
      // Copies the contents of the frame buffer into the texture
      glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0,
                                      texture_width, texture_height, 0);

    } else {
      // Copies the contents of the frame buffer into the texture
      glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0,
                                         texture_width, texture_height);
    }

    // Set the OpenGL window back to its previous size
    resize(width, height);

    // Clear the window back to black
    glClearColor(0.0, 0.0, 0.0, 1.0);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}

The test is on texture_data and not texture_id

-Fred


_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel

Reply via email to