void Reloadable::reload() { initBuffers(); initPipeline(); initVBO(); initVAO(); initUniformsCache(); }
Model::Model(Engine* engine, core::Program* program, const std::string& shapePath) : IFocusable(engine), Programmable(program), #ifdef FILLWAVE_MODEL_LOADER_ASSIMP mAnimator(nullptr), mActiveAnimation(FILLWAVE_DO_NOT_ANIMATE), #endif /* FILLWAVE_MODEL_LOADER_ASSIMP */ mLights(engine->getLightSystem()) { #ifdef FILLWAVE_MODEL_LOADER_ASSIMP const aiScene* scene = engine->getModelFromFile(shapePath); if (scene) { initAnimations(scene); initShadowing(engine); initUniformsCache(); loadNodes(scene->mRootNode, scene, engine, this); } else { FLOG_FATAL("Model: %s could not be read", shapePath.c_str()); } #else std::vector<tinyobj::shape_t> shapes; std::vector<tinyobj::material_t> materials; tinyobj::attrib_t attrib; std::string err; if (!tinyobj::LoadObj(&attrib, &shapes, &materials, &err, shapePath.c_str())) { FLOG_FATAL("Model: %s could not be read", shapePath.c_str()); } if (!err.empty()) { // `err` may contain warning message. FLOG_WARNING("%s", err.c_str()); } initShadowing(engine); for (GLuint i = 0; i < shapes.size(); i++) { if (shapes[i].mesh.material_ids.empty()) { FLOG_FATAL("No materials available"); } int materialId = shapes[i].mesh.material_ids[0]; if (materialId != -1) { attach(loadMesh(shapes[i], attrib, Material(materials[materialId]), engine->storeTexture(materials[materialId].diffuse_texname), engine->storeTexture(materials[materialId].bump_texname), engine->storeTexture(materials[materialId].specular_texname), engine)); continue; } attach(loadMesh(shapes[i], attrib, Material(), nullptr, nullptr, nullptr, engine)); } #endif }
RendererDR::RendererDR(Engine* engine, ProgramLoader& loader) : mScreenSize(engine->getScreenSize()), mLights(engine->getLightSystem()), mTextures(engine->getTextureSystem()), mProgramMain(loader.getDefaultDR()), mProgramMainAnimated(loader.getDefaultBonesDR()), mProgramDirecionalLight(loader.getDRDirectionalLights()), mProgramSpotLight(loader.getDRSpotLights()), mProgramPointLight(loader.getDRPointLights()), mProgramDepthless(loader.getDRDepthless()), mProgramAmbient(loader.getDRAmbient()), mProgramAOGeometry(loader.getAmbientOcclusionGeometry()), mProgramAOColor(loader.getAmbientOcclusionColor()), mAOGeometryBuffer(engine->storeTextureRenderable()), mAOColorBuffer(engine->storeTextureRenderable()), mIsAO(GL_FALSE), mDeferredColorAttachments(5), mDeferredDepthAttachments(1), mGBuffer( std::make_unique<core::FramebufferGeometry>(mTextures, mScreenSize[0], mScreenSize[1], mDeferredColorAttachments, mDeferredDepthAttachments)) { framework::Sphere sphere(3.0f, 10.0f, 10.0f); // xxx hardcoded values fix ! todo ! std::vector<core::VertexBasic> vertices = sphere.getVertices(); std::vector<GLuint> indices = sphere.getIndices(); core::VertexArray* vao = new core::VertexArray(); mDeferredPointLight = std::make_unique<Mesh>(engine, Material(), nullptr, nullptr, nullptr, mProgramPointLight, nullptr, nullptr, loader.getOcclusionQuery(), nullptr, nullptr, mLights, engine->storeBuffer<core::VertexBufferBasic>(vao, vertices), engine->storeBuffer<core::IndexBuffer>(vao, indices), #ifdef FILLWAVE_MODEL_LOADER_ASSIMP nullptr, #endif /* FILLWAVE_MODEL_LOADER_ASSIMP */ GL_TRIANGLES, vao); initUniforms(); initGeometryBuffer(); initGeometryShading(); initUniformsCache(); reset(mScreenSize[0], mScreenSize[1]); }
Mesh::Mesh( Engine* engine, const Material& material, core::Texture2D* diffuseMap, core::Texture2D* normalMap, core::Texture2D* specularMap, core::Program* program, core::Program* programShadow, core::Program* programShadowColor, core::Program* programOcclusion, core::Program* programAmbientOcclusionGeometry, core::Program* programAmbientOcclusionColor, LightSystem* lights, core::VertexBufferBasic* vbo, core::IndexBuffer* ibo, #ifdef FILLWAVE_MODEL_LOADER_ASSIMP Animator* animator, #endif /* FILLWAVE_MODEL_LOADER_ASSIMP */ GLenum renderMode, core::VertexArray* vao) : IReloadable(engine, vao), mMaterial(material), mDiffuseMap(diffuseMap), mNormalMap(normalMap), mSpecularMap(specularMap), mProgram(program), mProgramShadow(programShadow), mProgramShadowColor(programShadowColor), mProgramOQ(programOcclusion), mProgramAOGeometry(programAmbientOcclusionGeometry), mProgramAOColor(programAmbientOcclusionColor), mRenderMode(renderMode), mIBO(ibo), mVBO(vbo), mLights(lights) #ifdef FILLWAVE_MODEL_LOADER_ASSIMP , mAnimator(animator) #endif /* FILLWAVE_MODEL_LOADER_ASSIMP */ #ifdef FILLWAVE_GLES_3_0 #else , mConditionalRendering(GL_QUERY_WAIT) #endif { initPipeline(); initVBO(); initVAO(); initUniformsCache(); }