graphics api abstraction
[demo] / src / scene.cc
index 99c3b01..d033a8f 100644 (file)
 
 #include <gmath/gmath.h>
 
+#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; i<amesh->mNumVertices; i++) {
@@ -260,12 +248,9 @@ 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;