X-Git-Url: http://git.mutantstargoat.com?a=blobdiff_plain;f=src%2Fscene.cc;h=0666bd83663fc24b640fe7412c90b0149fe6eef5;hb=HEAD;hp=8adb7df00b7b38abb486e6dfee961bddefb46326;hpb=63d7f3b0e70ab5e3d530c579b1881967c96b0b92;p=demo diff --git a/src/scene.cc b/src/scene.cc index 8adb7df..0666bd8 100644 --- a/src/scene.cc +++ b/src/scene.cc @@ -10,18 +10,13 @@ #include +#include "gfxapi.h" + #include "mesh.h" #include "object.h" #include "scene.h" #include "texture.h" -#include "opengl/mesh-gl.h" -#include "vulkan/mesh-vk.h" - -#include "opengl/texture-gl.h" -#include "vulkan/texture-vk.h" - -extern bool use_vulkan; static Mesh *load_mesh(const aiScene *scene, unsigned int index); static Material *load_material(const aiScene *ascene, Scene *scene, unsigned int index, const char *tex_fname); @@ -149,14 +144,7 @@ static Mesh *load_mesh(const aiScene *scene, unsigned int index) return 0; } - Mesh *mesh; - if(use_vulkan) { - mesh = new MeshVK; - } - else { - mesh = new MeshGL; - } - + Mesh *mesh = gfx_create_mesh(); mesh->name = std::string(amesh->mName.data); for(unsigned int i=0; imNumVertices; i++) { @@ -217,7 +205,6 @@ static Mesh *load_mesh(const aiScene *scene, unsigned int index) else fprintf(stderr, "No faces found.\n"); - mesh->mat_idx = amesh->mMaterialIndex; return mesh; } @@ -259,13 +246,8 @@ static Material *load_material(const aiScene *ascene, Scene *scene, unsigned int mat->dtex = scene->find_texture(tex_fname.c_str()); if(!mat->dtex) { - printf("!mat->dtex\n"); - if(use_vulkan) { - mat->dtex = new TextureVK; - } - else { - mat->dtex = new TextureGL; - } + mat->dtex = gfx_create_texture(); + if(!mat->dtex->load(tex_fname.c_str())) { fprintf(stderr, "Failed to load texture data: %s.\n", tex_fname.c_str()); delete mat->dtex; @@ -304,12 +286,12 @@ Material *Scene::find_material(const char *name) return 0; } -Texture *Scene::find_texture(const char *name) { +Texture *Scene::find_texture(const char *name) +{ for(size_t i=0; iname == name) { return textures[i]; } } - fprintf(stderr, "Texture %s not found.\n", name); return 0; } \ No newline at end of file