How to manage textures

I am writing a simple 3D engine based on OpenGL (I know that there are many, but for some reason I want to learn how to do it myself). I am very pleased with my current approach to scene graphics and the like, but I am very unhappy with the texture processing. So I wonder how to do it properly.

When I look at sample code on the Internet, they never talk about how to manage textures. They simply load some textures upon application launch, demonstrate their demos, and then exit the program. But what if I often change things on stage? What if I want to display a scene with 10 textures, and then I delete the node in the scene, so 2 textures are no longer needed, and then I add a new node with 4 new textures. Thus, 2 old textures should be removed from the video memory, and I should add 4 new textures. Then I completely replace the whole scene, so all unused textures must be deleted, and new textures must be loaded, and the textures that were used earlier and which are also used in the new scene must be reused. That sounds pretty complicated.

How are textures controlled in professional 3D engines? Is this a global texture syntax manager that tracks texture usage with reference counts and cleans up video memory from time to time? Or is there a more ingenious method for this?

+3
source share
2 answers

, , , , , . , . "", , - , (, , , ), "". - script, . - "", . , , , . , pacakges , 0.

, , , , . , , , .

+4

++, " " - , . , , , . , , .

C ; , , "" , vram .

, " ", , , , , , . , , .

, .., .., , .

+3

Source: https://habr.com/ru/post/1765097/


All Articles