Raymond
Demo: Green Dragon

Articles with the tag: Resource Management

Texturing with DDS

On texturing: is there any reason the ResMan can't store the DDS data? The Material objects can be charged with storing the texture, so the texture is never stored more than once in device memory.

Scene init example:

ResMan->LoadTexture("texture1");
ResMan->LoadMaterial("material1", ResMan->GetTexture("texture1");
ResMan->LoadMesh(ResMan->GetMaterial("material1"));

Read More »


Scene Loading

[05/03/14 11:04]

Or I could just use DDS.

Because ResMan is for host memory only, it is up to the Mesh class to handle its own vertex buffer. Each ModelNode drawing the same Mesh object from ResMan must call Mesh's createVBO() function on init. Obviously this shouldn't be done every time, so the Mesh object will use a boolean is_vbo flag to prevent regeneration.

The memory will therefore persist in device memory until the scene is removed (i.e. all GraphNodes are destructed) upon which the ModelNode will scan the next scene file to be loaded to see if it should call the mesh->deleteVBO() function. This is to prevent reloading of elements in device memory between scenes.

Note: ResMan should check if resource exists before returning it, else it should throw an exception.

[05/03/14 14:12]

Testing render loop with temporary material ...

Read More »


Data type: Materials

Material contains texture GLuints.

Could shared_ptr<void> be used to save different types of materials?

Try polymorphism. If that doesn't work, try <void> (using abstract Material class).

resman->CreateTexture(texturename, filename);
Texture = resman->GetTexture(texturename);
// Or:
Texture = resman ->GetDefaultTexture(); // Return white texture in case pure colour is wanted.
// So:
resman->CreateMaterial(string matname, make_shared<SomeMaterial>(Texture, diffusecol, etc));
someMaterial = SomeMaterial{Texture* tex, GLUint texobject};
someMaterial->LoadTextures{tex -> texobject};
modelNode = ModelNode{someMaterial->LoadTextures};

Presumably need:

someMaterial->BindTextures;
someMaterial->UnbindTextures;

To be called when program is loaded, before rendering.

This is in keeping with the memory management rule: ResMan controls HDD->Host, and SceneGraph elements control Host->Device.

[04/03/14 13:41]

So how to load textures... How does WebGL do it?

DDS is a compressed image format directly compatible with openGL texture buffer objects. GLFW handles Targas for some reason.

WebGL uses the browser's image loading capabilities. OpenGL ...

Read More »


Memory management

[01/03/14 14:25]

  • ResMan parses JSON and puts meshVertices into newMesh.
  • ModelNode's job to create and copy them to VBO (on init) and transfer to device.
  • ModelNode removes them from device when destructed.
  • ModelNode sends VBO to renderer.
Thus:
  • ResMan: HDD -> Host
  • SceneGraph: Host -> Device

Read More »


Resource Identification

[27/02/14 20:50]

Implementing map of shared_ptrs for Mesh objects in ResMan.

Using simple name for ID. A game with many meshes would probably have a system of unique IDs, but not a live database as that would be too slow. A DB for the editor, maybe, which generates a unique ID for each asset.

Memory management

[27/02/14 20:51]

System of memory:
HDD -> Host -> Device

i.e. As a rule ResMan draws from HDD and stores meshes in Host memory then ModelNodes load it to GL buffers.

This stuff can be considered part of the caching process.

Read More »


ResMan and ModelNode interaction

Data types

class ResMan
{
    LoadMeshFromFile(meshname)
    Mesh* GetMesh(resourceID)
    LoadTextureFromFile(texturename)
    Texture* GetTexture(resourceID)
    ReleaseMesh(resourceID)
    UnloadMesh(meshname)
}

class ModelNode : SceneNode
{
    Mesh* _mesh
    Texture* _texture
}

class Renderer
{
SetShaderProgram()
SetVertexBuffer()
SetProjection()
SetTexture()
}

Presumably Mesh* is really a GLUint associated with an OpenGL vertex buffer. Maybe Mesh can encapsulate this. ResMan should be able to unload the mesh vertex buffer from the device memory. Somehow.

Flow

Typedef Int ResourceID;
ResourceID mesh_resource_id;
ResourceID material_resource_id;

ModelNode::Init()
{
    mesh_resource_id = resman->load_mesh(filename)
    // Widely-used materials (such as a lava texture) can be spawned in GameEnv before objects grab references of them from resman. Here a model-specific material will be generated, but resman is still relevant for clones.
    material_resource_id = resman->CreateMaterial(new MaterialType(materialName, texturename, gloss, colour, etc));
}

ModelNode::Render()
{
    Mesh* mesh = resman->get_mesh(mesh_resource_id);
    Material* material = resman->get_material(material_resource_id);
    renderer->set_projection(mat_project);
    renderer->set_material(material);
    renderer->render(mesh);
}

Renderer::set_material(material)
{
    material->update_settings();
    material->set_shader_uniforms_and_texture_buffers();
}
  • If ...

Read More »


Page 1 / 2 Older »