[SOLVED] Problem with deleting textures and vbos

Started by Katsu, March 02, 2015, 22:00:32

Previous topic - Next topic

Katsu

Hello,
I'm currently working on an engine which has a resource manager which loads and unloads all textures, meshes, shaders automatically but sometimes if a mesh/texture is unloaded, but other meshes/textures also disappear. After letting the engine print out all texture and mesh id's which you get from glGenTextures/glGenBuffers, i noticed that some id's are the same (The output from println: http://pastebin.com/ib7uATmW).
In the file on pastebin is the id of the plane ibo and the id of the logo texture (which the engine deletes from the GPU after 10secs if its not used) the same and if the logo texture gets deleted with glDeleteBuffers, all plane meshes disappear (there are still some sphere meshes in the scene which stay there)
And I don't really know if I made a really stupid mistake or if there's something wrong with glGenTextures/glGenBuffers.

Edit:
The source code of the Mesh and the Texture class:
Mesh: http://pastebin.com/wjxVdu6v
Texture: http://pastebin.com/D6iCD1U3

I hope you can understand the problem and maybe know a solution to it and thanks in advance for helping me,
Katsu :D

abcdef

for destroying textures glDeleteTextures is the way to go as the id reference counters are different to those that are used to generate buffers, this is why texture id's can be the same as the buffer id's (I get this too).

Can you post some code for where you delete things?

Katsu

I changed it to glDeleteTextures for deleting my textures while debugging (http://pastebin.com/D6iCD1U3 line 40). I just heard that you can also use glDeleteBuffers for textures which gives me the same result as if I would use glDeleteTextures. The planes which have the same id as the logo texture which I try to delete with glDeleteTextures disappear when I use glDeleteBuffers and also if I use glDeleteTextures.

Katsu

quew8

Whenever you are confused about an OpenGL function, the docs are the way to go: https://www.opengl.org/sdk/docs/man3/

From glDeleteBuffers():
QuoteglDeleteBuffers silently ignores 0's and names that do not correspond to existing buffer objects.

From glDeleteTextures():
QuoteglDeleteTextures silently ignores 0's and names that do not correspond to existing textures.

glDeleteBuffers() will never affect any textures, but will delete buffers with the same id and glDeleteTextures() will never affect buffers but will delete textures with the same id.

Where did you get the idea that they were equivalent?

Katsu

I found the bug...
glDeleteBuffers(shaderID)  :(
To delete shaders it seems that you also need to use glDeleteProgram and then glDeleteShader for every shader.
I am sorry for having bothered you and thank you all for helping me find the error and learning something really important in OpenGL.. :D

Katsu