1
0
Fork 0

Add resource naming convention

This commit is contained in:
Meoweg 2015-11-09 15:28:25 +00:00
parent 29c71cff88
commit 8db0b0581a
7 changed files with 17 additions and 12 deletions

View File

@ -67,9 +67,9 @@ int main()
camera.position.z = 4;
camera.position.y = 2;
suzanne = new Model("/data/models/suzanne.obj");
teapot = new Model("/data/models/teapot.obj");
bunny = new Model("/data/models/bunny.obj");
suzanne = new Model("suzanne.obj");
teapot = new Model("teapot.obj");
bunny = new Model("bunny.obj");
suzanne1 = new Object(*suzanne);
suzanne1->position.z = -2;

View File

@ -3,9 +3,9 @@
#include <string>
#include <fstream>
Material::Material(const char *const filename)
Material::Material(const std::string &name)
{
std::ifstream file(std::string("/data/materials/") + filename, std::ios::in);
std::ifstream file("/data/materials/" + name, std::ios::in);
std::string line;
while (std::getline(file, line))

View File

@ -3,10 +3,12 @@
#include "texture.hpp"
#include <string>
class Material
{
public:
Material(const char *filename);
Material(const std::string &name);
void use() const;
private:

View File

@ -3,9 +3,9 @@
#include <fstream>
#include <sstream>
Model::Model(const char *const filename)
Model::Model(const std::string &name)
{
std::ifstream file(filename, std::ios::in);
std::ifstream file("/data/models/" + name, std::ios::in);
std::vector<glm::vec3> tmp_positions;
std::vector<glm::vec2> tmp_tex_coords;

View File

@ -4,6 +4,7 @@
#include "gl.hpp"
#include "material.hpp"
#include <string>
#include <vector>
#include <glm/glm.hpp>
@ -11,7 +12,7 @@
class Model
{
public:
Model(const char *filename);
Model(const std::string &name);
void draw() const;
private:

View File

@ -4,9 +4,9 @@
#include <SDL_image.h>
Texture::Texture(const char *const filename)
Texture::Texture(const std::string &name)
{
SDL_Surface *surface = IMG_Load((std::string("/data/textures/") + filename).c_str());
SDL_Surface *surface = IMG_Load(("/data/textures/" + name).c_str());
glGenTextures(1, &_id);
glBindTexture(GL_TEXTURE_2D, _id);

View File

@ -3,10 +3,12 @@
#include "gl.hpp"
#include <string>
class Texture
{
public:
Texture(const char *filename);
Texture(const std::string &name);
void use() const;
private: