Stranger render problem with textures !

Hi all

I’m implementing some OpenGL examples in dolphin smalltalk for Window XP.
The examples are from the book: “Beginning OpenGL game programming”. (Dave Astle. Kevin Hawkins)

The first examples work ok , but the texture examples don’t work well !.
Look this screens:

First: I load the example working well

Second: I load other example and work well

Third: I load again the first example and happen this:

Look at the texture of the first polygon, this texture it is the same of the second example!.
But the second example is dead and the textures are eliminated

I use glCheckError in all function call and all work well.
The strange thing is that this behavior is aleatory.

I suspect that the problem can be related with:

  1. The texture settings.
  2. The delete of the textures
  3. The opengl context settings.

The problem is that my example is the same like the C++ example.

Any idea ?

Advanced thanks kiko

PD: Here more screens

I’m no OpenGL expert by any means, but it looks like dolphin smalltalk might not release the memory buffer you are using, but the info the buffer contains remains untouched, you call the Device Context, in the third demo, after ending the second demo and the terrain texture is “ghosted”, in the language you are porting to, find a command that will erase/purge the memory area that stores the textures. For all your demos, use this erase/purge command before you send the texture in the current demo to the Device Context.

In the book, look at Chapter 7 p174: “Texture Environments and Texture Functions”. In the context of the book, you have to make sure the old texture is erased/overwritten (if you use multiple buffers - ALL buffers must be checked) before working with the new texture.

Question:

If you run a second demo other than the one you show, and you note the last texture the second demo loads, is that again the first texture used in your third demo?

Hi savalia

Thanks to reply .
Sorry for my delay :slight_smile:

Dolphin smalltalk have automatic garbage collector .

I delete all the textures before leaving my demo

You wrote:
If you run a second demo other than the one you show, and you note the last texture the second demo loads, is that again the first texture used in your third demo?

Sorry my english is not very good.
I don’t understand.

The texture in the 3 demo is similar to the texture in the 2 demo.
I cannot assure that it is the same, but they are similar.
But I only load one texture, that then I use in the 2 polygons.

Advancd thanks

kiko

Kiko,
I have the same book, I reloaded the projects you mentioned from the CD and they run correctly, the two squares textured with brick, Chapter 7, the second demo with the 4 scenes with different fog settings is chapter 8, so try reversing the order you run the demo’s, if the problem is related to the garbage collection of dolphin smalltalk, then if you try demo from ch 8, then ch 7, and finally ch 8 do you get a brick pattern in the chapter 8 demo with the 4 fog scenes?

Hi savalia

The GC work ok. All objects are destroy.
All examples in C++ work well.

then if you try demo from ch 8, then ch 7, and finally ch 8 do you get a brick pattern in the chapter 8 demo with the 4 fog scenes?

When I run one example with texture and then I run other example with texture, happen the problem.
The execution order doesn’t care, whenever I execute two examples with texture.
Look

1 ) I run enhancedFog well:

  1. I run terrain bad !

  1. I run again enhancedFog bad !

From origina code C++.

void CSkybox::Release()
{
for (int i = 0; i < 6; ++i)
glDeleteTextures(6, &m_textures[0]);
}

This code is right ?

The textures of skybox are 6. Then here repeat 6 times the called to glDeleteTexture.
Why ?

Advanced thanks

kiko

A skybox is simply a 6 sided box that is meant to surround the objects you create in a scene to add realism. OpenGL has functions to make using a skybox easier but it is still just a cube, large enough to surround all the objects of a scene with textures mapped on the inside surfaces of the cube. To generate the textures and map them OpenGL requires 6 textures - north, south, east, west, top, bottom. When the program exits, the fastest way to delete the textures is:


   for(int i=0;i<6:++i)
      glDeleteTextures(6(#of sides), &m_textures[i](array      
      holding the texture data));

it’s exactly the same as writing


    glDeleteTextures(1, &m_textures[0]);
    glDeleteTextures(1, &m_textures[1]);
    glDeleteTextures(1, &m_textures[2]);
    glDeleteTextures(1, &m_textures[3]);
    glDeleteTextures(1, &m_textures[4]);
    glDeleteTextures(1, &m_textures[5]);

I like using the loop …

…but for your original problem, your going to need to show it to someone who has knowledge of dolphin smalltalk, from your description, I assumed the language was similar to Java, but again I have no working knowledge of dolphin. If your C++/OpenGL runs correctly, and your dolphin code does what the C++ code does, the only thing that came to mind was that dolphin releases the textures, but leaves the actual data in place and usable, to make sure you don’t use an old texture, I assumed you could locate it in memory and just overwrite the data with zeros, or, if you can specify where textures are stored in memory, store them so there is no chance of overlap.

Hi savalia

Thanks .
The problem is glDeleteTextures .
I download rivaTuner and the vram is not clear.

I don’t still determine for that “glDeleteTexture” doesn’t work well

thanks again

kiko