ModelGles.h#
↰ Parent directory (OpenGLES
)
Contains a automated container class for managing Gles buffers and textures for a model.
Includes#
PVRAssets/Model.h
PVRUtils/OpenGLES/HelperGles.h
Included By#
Namespaces#
Classes#
Functions#
Source Code#
#pragma once
#include "PVRAssets/Model.h"
#include "PVRUtils/OpenGLES/HelperGles.h"
namespace pvr {
namespace utils {
class ModelGles
{
public:
struct ApiMeshGles
{
std::vector<GLuint> vbos;
GLuint ibo;
};
enum class Flags
{
None = 0,
LoadMeshes = 1,
LoadTextures = 2,
GLES2Only = 4,
loadASTCTextures = 8
};
private:
pvr::assets::ModelHandle modelHandle;
pvr::assets::Model* model;
std::vector<ApiMeshGles> meshes;
std::vector<GLuint> textures;
void destroy();
public:
pvr::assets::Model& getModel() { return *model; }
pvr::assets::ModelHandle& getModelHandle() { return modelHandle; }
ModelGles() : model(nullptr) {}
~ModelGles() { destroy(); }
void init(pvr::IAssetProvider& assetProvider, pvr::assets::Model& inModel, Flags flags = (Flags)((int)Flags::LoadMeshes | (int)Flags::LoadTextures));
void init(pvr::IAssetProvider& assetProvider, pvr::assets::ModelHandle& inModel, Flags flags = (Flags)((int)Flags::LoadMeshes | (int)Flags::LoadTextures));
GLuint getApiTextureById(uint32_t texId) { return textures[texId]; }
GLuint getApiTextureByNode(uint32_t nodeId, const pvr::StringHash& texSemantic) { return getApiTextureByMaterial(model->getNode(nodeId).getMaterialIndex(), texSemantic); }
GLuint getApiTextureByMaterial(uint32_t materialId, const pvr::StringHash& texSemantic) { return textures[model->getMaterial(materialId).getTextureIndex(texSemantic)]; }
ApiMeshGles& getApiMeshById(uint32_t meshId) { return meshes[meshId]; }
ApiMeshGles& getApiMeshByNodeId(uint32_t nodeId) { return meshes[model->getNode(nodeId).getObjectId()]; }
GLuint getVboByMeshId(uint32_t meshId, uint32_t vboId) { return meshes[meshId].vbos[vboId]; }
GLuint getIboByMeshId(uint32_t meshId) { return meshes[meshId].ibo; }
GLuint getVboByNodeId(uint32_t nodeId, uint32_t vboId) { return getVboByMeshId(model->getNode(nodeId).getObjectId(), vboId); }
GLuint getIboByNodeId(uint32_t nodeId) { return getIboByMeshId(model->getNode(nodeId).getObjectId()); }
};
inline ModelGles::Flags operator|(ModelGles::Flags lhs, ModelGles::Flags rhs) { return (ModelGles::Flags)((int)lhs | (int)rhs); }
inline ModelGles::Flags& operator|=(ModelGles::Flags& lhs, ModelGles::Flags rhs) { return lhs = (lhs | rhs); }
inline ModelGles::Flags operator&(ModelGles::Flags lhs, ModelGles::Flags rhs) { return (ModelGles::Flags)((int)lhs & (int)rhs); }
inline ModelGles::Flags& operator&=(ModelGles::Flags& lhs, ModelGles::Flags rhs) { return lhs = (lhs & rhs); }
} // namespace utils
} // namespace pvr