View Full Version : Stranger render problem with textures !

08-31-2010, 06:20 AM
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

http://www.imagenserver.com.ar/out.php/t15274_texture1.JPG (http://www.imagenserver.com.ar/show.php/15274_texture1.JPG.html)

Second: I load other example and work well

http://www.imagenserver.com.ar/out.php/t15276_texture3.JPG (http://www.imagenserver.com.ar/show.php/15276_texture3.JPG.html)

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

http://www.imagenserver.com.ar/out.php/t15275_texture2.JPG (http://www.imagenserver.com.ar/show.php/15275_texture2.JPG.html)

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

http://www.imagenserver.com.ar/out.php/t15064_Texture4.JPG (http://www.imagenserver.com.ar/show.php/15064_Texture4.JPG.html)

http://www.imagenserver.com.ar/out.php/t15062_Texture1.JPG (http://www.imagenserver.com.ar/show.php/15062_Texture1.JPG.html)

http://www.imagenserver.com.ar/out.php/t15063_Texture3.JPG (http://www.imagenserver.com.ar/show.php/15063_Texture3.JPG.html)

08-31-2010, 08:09 PM
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.


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?

09-07-2010, 05:14 AM
Hi savalia

Thanks to reply .
Sorry for my delay :)

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


09-07-2010, 07:19 PM
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?

09-08-2010, 05:16 AM
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.

1 ) I run enhancedFog well:

http://www.imagenserver.com.ar/out.php/t15276_texture3.JPG (http://www.imagenserver.com.ar/show.php/15276_texture3.JPG.html)

2) I run terrain bad !

http://www.imagenserver.com.ar/out.php/t15531_terrain1.JPG (http://www.imagenserver.com.ar/show.php/15531_terrain1.JPG.html)

3) I run again enhancedFog bad !

http://www.imagenserver.com.ar/out.php/t15532_enhancedFog.JPG (http://www.imagenserver.com.ar/show.php/15532_enhancedFog.JPG.html)

From origina code C++.

void CSkybox::Release()
for (int i = 0; i < 6; ++i)
glDeleteTextures(6, &amp;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


09-08-2010, 03:34 PM
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), &amp;m_textures[i](array
holding the texture data));

it's exactly the same as writing

glDeleteTextures(1, &amp;m_textures[0]);
glDeleteTextures(1, &amp;m_textures[1]);
glDeleteTextures(1, &amp;m_textures[2]);
glDeleteTextures(1, &amp;m_textures[3]);
glDeleteTextures(1, &amp;m_textures[4]);
glDeleteTextures(1, &amp;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.

09-10-2010, 01:37 PM
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