/SleekThink.depend
75625,11 → 75625,11
<memory.h>
<GL/gl.h>
 
1420935856 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/GameCore.cpp
1422752144 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/GameCore.cpp
"GameCore.h"
"../sleek/loader/texture_loader.h"
 
1420772626 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/GameCore.h
1422752086 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/GameCore.h
"GameMenu.h"
"GameEngine.h"
"GameIntro.h"
75638,12 → 75638,13
"../sleek/start.h"
"../sleek/gui/interface.h"
 
1419998399 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/start.h
1422751935 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/start.h
"device/device.h"
"device/splash.h"
"driver/context.h"
"driver/driver.h"
"node/engine.h"
"loader/loader.h"
 
1419554614 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/core/device/device.h
"icone.h"
77602,7 → 77603,7
"../sleek/start.h"
"../sleek/driver/mesh.h"
 
1421875422 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/GameEngine.cpp
1422752144 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/GameEngine.cpp
"GameCore.h"
"GameEngine.h"
"light.h"
77610,7 → 77611,7
 
1420770021 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/light.h
 
1420935834 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/GameMenu.cpp
1422752130 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/GameMenu.cpp
"GameCore.h"
"GameMenu.h"
"../sleek/loader/texture_loader.h"
77623,7 → 77624,7
"texture.h"
"../core/math/aabbox.h"
 
1420770021 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/main.cpp
1422752197 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/main.cpp
"../sleek/device/splash.h"
"../sleek/loader/texture_loader.h"
"GameCore.h"
80887,17 → 80888,19
 
1324743734 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/mesh/post-processing.cpp
 
1422750988 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/texture_loader.h
 
1420769735 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/texture_bmp.h
1422752475 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/texture_loader.h
<string>
<memory>
 
1422751507 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/texture_bmp.h
"texture_loader.h"
 
1419884843 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/texture_jpg.h
<string>
<string>
 
1420769808 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/texture_png.h
<string>
1422751507 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/texture_png.h
"texture_loader.h"
 
1419884843 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/texture_tga.h
<string>
80914,14 → 80917,14
"cursor.h"
"../driver/fbo.h"
 
1422748781 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/mesh_3ds.cpp
1422752653 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/mesh_3ds.cpp
"mesh_3ds.h"
"../driver/mesh.h"
"../compile.h"
<sys/stat.h>
 
1419549691 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/mesh_3ds.h
<string>
<string>
1422752729 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/mesh_3ds.h
"mesh_loader.h"
 
1419901671 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/mesh_mtl.cpp
"../mesh/mesh.h"
80931,7 → 80934,8
"../mesh/mesh.h"
"../compile.h"
 
1422748800 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/mesh_txt.cpp
1422752829 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/mesh_txt.cpp
"mesh_txt.h"
"../library/glm/detail/func_geometric.hpp"
"../driver/mesh.h"
"../compile.h"
80940,7 → 80944,8
"../mesh/mesh.h"
"../compile.h"
 
1420931228 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/texture_bmp.cpp
1422752816 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/texture_bmp.cpp
"texture_bmp.h"
"../driver/texture.h"
"../compile.h"
<stdlib.h>
80949,7 → 80954,8
"../driver/texture.h"
"../driver/texture.h"
 
1420904859 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/texture_png.cpp
1422752822 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/texture_png.cpp
"texture_png.h"
"../driver/texture.h"
"../compile.h"
"libpng/png.h"
81166,7 → 81172,7
<iostream>
"console/spdlog.h"
 
1422743469 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/compile.h
1422752382 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/compile.h
 
1419891890 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/ogl_driver.cpp
"../device/device.h"
81250,10 → 81256,11
1420770430 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/reference.cpp
"reference.h"
 
1420769808 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/texture_tiff.h
<string>
1422751507 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/texture_tiff.h
"texture_loader.h"
 
1420904859 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/texture_tiff.cpp
1422752806 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/texture_tiff.cpp
"texture_tiff.h"
"../driver/texture.h"
"../compile.h"
<tiffio.h>
81649,3 → 81656,24
<vector>
"../directory.h"
 
1422752736 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/loader.h
<vector>
"mesh_loader.h"
"texture_loader.h"
 
1422752729 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/mesh_loader.h
<string>
<memory>
 
1422752996 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/loader.cpp
"loader.h"
"../compile.h"
"mesh_3ds.h"
"mesh_txt.h"
"texture_bmp.h"
"texture_png.h"
"texture_tiff.h"
 
1422752729 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/mesh_txt.h
"mesh_loader.h"
 
/bin/SleekThink
Cannot display: file marked as a binary type.
svn:mime-type = application/x-executable
/bin/gmon.out
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/src/app/GameCore.cpp
20,6 → 20,7
renderer->setAntialiasing(driver::DAM_FAST);
renderer->setViewport(screen->getInfo().size);
driver = renderer->createDriver();
loader = std::make_shared<sleek::loader::loader>();
 
guienv = sleek::gui::createGUIEnvironment(screen, driver);
 
26,7 → 27,7
guienv->getCursor()->showCursor(false);
guienv->getCursor()->showTexture(true);
 
pointor = loader::LoadTextureFromBmp("texture/pointor.bmp");
pointor = loader->loadTexture("texture/pointor.bmp");
pointor->createIdentifier(renderer.get());
pointor->getIdentifier()->update();
guienv->getCursor()->setTexture(pointor.get());
49,16 → 50,21
return screen.get();
}
 
sleek::driver::driver *GameCore::getDriver() const noexcept
sleek::driver::driver* GameCore::getDriver() const noexcept
{
return driver.get();
}
 
sleek::driver::context *GameCore::getContext() const noexcept
sleek::driver::context* GameCore::getContext() const noexcept
{
return renderer.get();
}
 
sleek::loader::loader* GameCore::getLoader() const noexcept
{
return loader.get();
}
 
void GameCore::launch() noexcept
{
// changeState(GMS_INTRO);
/src/app/GameCore.h
29,6 → 29,7
sleek::device::Device* getDevice() const noexcept;
sleek::driver::driver* getDriver() const noexcept;
sleek::driver::context* getContext() const noexcept;
sleek::loader::loader* getLoader() const noexcept;
 
bool manage(sleek::device::input *a) noexcept;
 
44,6 → 45,7
std::shared_ptr<sleek::driver::driver> driver;
std::shared_ptr<sleek::driver::context>renderer;
std::shared_ptr<sleek::driver::texture>pointor;
std::shared_ptr<sleek::loader::loader> loader;
 
GameMenu *menu;
GameEngine *game;
/src/app/GameEngine.cpp
19,8 → 19,8
 
{
// load some texture
crate = loader::LoadTextureFromPng("texture/item/crate.png");
bundul = loader::LoadTextureFromBmp("texture/item/add.bmp");
crate = mom->getLoader()->loadTexture("texture/item/crate.png");
bundul = mom->getLoader()->loadTexture("texture/item/add.bmp");
bundul->flipVertical();
 
// create hardware link
/src/app/GameMenu.cpp
35,7 → 35,7
guienv->addCustomFrame(std::shared_ptr<gui::frame>(par[i]));
}
 
background = sleek::loader::LoadTextureFromBmp("texture/background.bmp");
background = mom->getLoader()->loadTexture("texture/background.bmp");
background->createIdentifier(core->getContext());
background->getIdentifier()->update();
 
/src/app/main.cpp
36,7 → 36,9
file += std::to_string(std::rand()%5);
file += ".bmp";
 
splash->setPicture(loader::LoadTextureFromBmp(file));
auto loader = std::make_shared<sleek::loader::loader>();
 
splash->setPicture(loader->loadTexture(file));
splash->resizeFromPicture();
splash->render();
 
/src/sleek/compile.h
11,14 → 11,12
 
#define std_filesystem
 
#define mesh_loader_3ds
#define mesh_loader_txt
#define texture_loader_bmp
#define texture_loader_png
#define texture_loader_tiff
#define texture_loader_raw
 
#define mesh_loader_3ds
#define mesh_loader_txt
 
#define video_reader
#define video_reader_audio
 
/src/sleek/loader/texture_raw.cpp
File deleted
Property changes:
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: src/sleek/loader/texture_raw.h
===================================================================
--- src/sleek/loader/texture_raw.h (revision 4)
+++ src/sleek/loader/texture_raw.h (nonexistent)
@@ -1,14 +0,0 @@
-#include <string>
-#include "../math/vector2d.h"
-
-namespace sleek
-{
- namespace driver
- {
- class texture;
- }
- namespace loader
- {
- std::shared_ptr<driver::texture> LoadTextureFromRaw(const math::vector2di&, const u32 format, void*) noexcept;
- }
-}
/src/sleek/loader/texture_raw.h
Property changes:
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: src/sleek/loader/loader.cpp
===================================================================
--- src/sleek/loader/loader.cpp (nonexistent)
+++ src/sleek/loader/loader.cpp (revision 5)
@@ -0,0 +1,54 @@
+#include "loader.h"
+#include "../compile.h"
+
+#include "mesh_3ds.h"
+#include "mesh_txt.h"
+#include "texture_bmp.h"
+#include "texture_png.h"
+#include "texture_tiff.h"
+
+namespace sleek
+{
+ namespace loader
+ {
+ loader::loader()
+ {
+ #ifdef mesh_loader_3ds
+ mesh.push_back(new meshloader_3ds());
+ #endif
+
+ #ifdef mesh_loader_txt
+ mesh.push_back(new meshloader_txt());
+ #endif
+
+ #ifdef texture_loader_bmp
+ texture.push_back(new textureloader_bmp());
+ #endif
+
+ #ifdef texture_loader_png
+ texture.push_back(new textureloader_png());
+ #endif
+
+ #ifdef texture_loader_tiff
+ texture.push_back(new textureloader_tiff());
+ #endif
+ }
+ loader::~loader()
+ {
+ }
+ std::shared_ptr<driver::MeshBuffer> loader::loadMesh(const std::string &filename) const noexcept
+ {
+ for(auto e : mesh)
+ if(e->match(filename))
+ return e->read(filename);
+ return nullptr;
+ }
+ std::shared_ptr<driver::texture> loader::loadTexture(const std::string &filename) const noexcept
+ {
+ for(auto e : texture)
+ if(e->match(filename))
+ return e->read(filename);
+ return nullptr;
+ }
+ }
+}
/src/sleek/loader/loader.cpp
Property changes:
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: src/sleek/loader/loader.h
===================================================================
--- src/sleek/loader/loader.h (nonexistent)
+++ src/sleek/loader/loader.h (revision 5)
@@ -0,0 +1,32 @@
+#ifndef __LOADER__
+#define __LOADER__
+
+#include <vector>
+#include "mesh_loader.h"
+#include "texture_loader.h"
+
+namespace sleek
+{
+ namespace loader
+ {
+ class loader : public std::enable_shared_from_this<loader>
+ {
+ public:
+ loader();
+ virtual ~loader();
+
+ inline std::shared_ptr<loader> getptr() noexcept
+ {
+ return shared_from_this();
+ }
+
+ virtual std::shared_ptr<driver::MeshBuffer> loadMesh(const std::string&) const noexcept;
+ virtual std::shared_ptr<driver::texture> loadTexture(const std::string&) const noexcept;
+ public:
+ std::vector<textureloader*> texture;
+ std::vector<meshloader*> mesh;
+ };
+ }
+}
+
+#endif // __LOADER__
/src/sleek/loader/loader.h
Property changes:
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: src/sleek/loader/mesh_3ds.cpp
===================================================================
--- src/sleek/loader/mesh_3ds.cpp (revision 4)
+++ src/sleek/loader/mesh_3ds.cpp (revision 5)
@@ -1,3 +1,4 @@
+#include "mesh_3ds.h"
#include "../driver/mesh.h"
#include "../compile.h"
#include <sys/stat.h>
@@ -12,7 +13,7 @@
fstat(f, &buf);
return buf.st_size;
}
- std::shared_ptr<driver::MeshBuffer> meshloader_3ds::read(std::string &file) noexcept
+ std::shared_ptr<driver::MeshBuffer> meshloader_3ds::read(const std::string &file) const noexcept
{
#ifdef mesh_loader_3ds
unsigned char lchar = 0;
@@ -77,14 +78,14 @@
#endif
}
- bool meshloader_3ds::write(driver::MeshBuffer*,const std::string&) noexcept
+ bool meshloader_3ds::write(driver::MeshBuffer*,const std::string&) const noexcept
{
return false;
}
- bool meshloader_3ds::match(const std::string&) noexcept
+ bool meshloader_3ds::match(const std::string &filename) const noexcept
{
- return false;
+ return filename.substr(filename.find_last_of('.')+1, 3) == "3ds";
}
}
}
/src/sleek/loader/mesh_3ds.h
1,19 → 1,17
#include <string>
#include "mesh_loader.h"
 
namespace sleek
{
namespace loader
{
class MeshBuffer;
{
class meshloader_3ds : public meshloader
{
public:
std::shared_ptr<MeshBuffer> read(const std::string&) const noexcept;
virtual std::shared_ptr<driver::MeshBuffer> read(const std::string&) const noexcept;
 
bool write(MeshBuffer*, const std::string&) const noexcept;
virtual bool write(driver::MeshBuffer*, const std::string&) const noexcept;
 
bool match(const std::string&) const noexcept;
virtual bool match(const std::string&) const noexcept;
};
}
}
/src/sleek/loader/mesh_loader.h
1,3 → 1,27
#ifndef __MESH_LOADER__
#define __MESH_LOADER__
 
#include "mesh_3ds.h"
#include "mesh_txt.h"
#include <string>
#include <memory>
 
namespace sleek
{
namespace driver
{
class MeshBuffer;
}
namespace loader
{
class meshloader
{
public:
virtual std::shared_ptr<driver::MeshBuffer> read(const std::string&) const noexcept = 0;
 
virtual bool write(driver::MeshBuffer*, const std::string&) const noexcept = 0;
 
virtual bool match(const std::string&) const noexcept = 0;
};
}
}
 
#endif // __MESH_LOADER__
/src/sleek/loader/mesh_txt.cpp
1,3 → 1,4
#include "mesh_txt.h"
#include "../library/glm/detail/func_geometric.hpp"
#include "../driver/mesh.h"
#include "../compile.h"
60,19 → 61,20
#endif
}
 
bool meshloader_txt::match(const std::string &file) const noexcept
bool meshloader_txt::match(const std::string &filename) const noexcept
{
#ifdef mesh_loader_txt
FILE *filein;
char oneline[255];
filein = fopen(file.c_str(), "rt");
if(!filein){ printf("error: couldn't open \"%s\"!\n", file.c_str()); return 0; }
do { fgets(oneline, 255, filein); } while ((oneline[0] == '/') || (oneline[0] == '\n'));
if(std::string("Vertices:") == std::string(oneline).substr(0,9)) return true;
return false;
#else
return false;
#endif
// #ifdef mesh_loader_txt
// FILE *filein;
// char oneline[255];
// filein = fopen(filename.c_str(), "rt");
// if(!filein){ printf("error: couldn't open \"%s\"!\n", filename.c_str()); return 0; }
// do { fgets(oneline, 255, filein); } while ((oneline[0] == '/') || (oneline[0] == '\n'));
// if(std::string("Vertices:") == std::string(oneline).substr(0,9)) return true;
// return false;
// #else
// return false;
// #endif
return filename.substr(filename.find_last_of('.')+1, 3) == "txt";
}
}
}
/src/sleek/loader/mesh_txt.h
1,19 → 1,17
#include <string>
#include "mesh_loader.h"
 
namespace sleek
{
namespace loader
{
class MeshBuffer;
{
class meshloader_txt : public meshloader
{
public:
std::shared_ptr<MeshBuffer> read(const std::string&) const noexcept;
virtual std::shared_ptr<driver::MeshBuffer> read(const std::string&) const noexcept;
 
bool write(MeshBuffer*, const std::string&) const noexcept;
virtual bool write(driver::MeshBuffer*, const std::string&) const noexcept;
 
bool match(const std::string&) const noexcept;
virtual bool match(const std::string&) const noexcept;
};
}
}
/src/sleek/loader/texture_bmp.cpp
1,3 → 1,4
#include "texture_bmp.h"
#include "../driver/texture.h"
#include "../compile.h"
#include <stdlib.h>
8,7 → 9,7
{
#define CTOI(C) (*(int*)&C)
 
std::shared_ptr<driver::texture> LoadTextureFromBmp(const std::string &file) noexcept
std::shared_ptr<driver::texture> textureloader_bmp::read(const std::string &file) const noexcept
{
#ifdef texture_loader_bmp
FILE *filePtr;
118,7 → 119,7
#endif
}
 
bool WriteTextureToBmp(driver::texture *img, const std::string &file) noexcept
bool textureloader_bmp::write(driver::texture *img, const std::string &file) const noexcept
{
#ifdef texture_loader_bmp
FILE *filePtr;
137,18 → 138,21
#endif
}
 
bool IsTextureFormatBmp(const std::string &file) noexcept
bool textureloader_bmp::match(const std::string &filename) const noexcept
{
#ifdef texture_loader_bmp
FILE *filePtr;
unsigned char header[2];
if (!(filePtr = fopen(file.c_str(), "rb"))){ printf("error: couldn't open \"%s\"!\n", file.c_str()); return 0; }
if (fread(header,1,2,filePtr)!=2) { fclose(filePtr); return 0; }
if (header[0]!='B' || header[1]!='M') { fclose(filePtr); return 0; }
return true;
#else
return false;
#endif
// #ifdef texture_loader_bmp
// FILE *filePtr;
// unsigned char header[2];
// if (!(filePtr = fopen(filename.c_str(), "rb"))){ printf("error: couldn't open \"%s\"!\n", filename.c_str()); return 0; }
// if (fread(header,1,2,filePtr)!=2) { fclose(filePtr); return 0; }
// if (header[0]!='B' || header[1]!='M') { fclose(filePtr); return 0; }
// return true;
// #else
// return false;
// #endif
// std::cout << filename << std::endl;
// std::cout << filename.substr(filename.find_last_of('.'), 3) << std::endl;
return filename.substr(filename.find_last_of('.')+1, 3) == "bmp";
}
}
}
/src/sleek/loader/texture_bmp.h
1,15 → 1,17
#include <string>
#include "texture_loader.h"
 
namespace sleek
{
namespace driver
{
class texture;
}
namespace loader
{
std::shared_ptr<driver::texture> LoadTextureFromBmp(const std::string&) noexcept;
bool WriteTextureToBmp(driver::texture*,const std::string&) noexcept;
bool IsTextureFormatBmp(const std::string&) noexcept;
{
class textureloader_bmp : public textureloader
{
public:
virtual std::shared_ptr<driver::texture> read(const std::string&) const noexcept;
 
virtual bool write(driver::texture*,const std::string&) const noexcept;
 
virtual bool match(const std::string&) const noexcept;
};
}
}
/src/sleek/loader/texture_loader.h
1,5 → 1,27
#ifndef __TEXTURE_LOADER__
#define __TEXTURE_LOADER__
 
#include "texture_bmp.h"
#include "texture_tiff.h"
#include "texture_png.h"
#include "texture_raw.h"
#include <string>
#include <memory>
 
namespace sleek
{
namespace driver
{
class texture;
}
namespace loader
{
class textureloader
{
public:
virtual std::shared_ptr<driver::texture> read(const std::string&) const noexcept = 0;
 
virtual bool write(driver::texture*,const std::string&) const noexcept = 0;
 
virtual bool match(const std::string&) const noexcept = 0;
};
}
}
 
#endif // __TEXTURE_LOADER__
/src/sleek/loader/texture_png.cpp
1,3 → 1,4
#include "texture_png.h"
#include "../driver/texture.h"
#include "../compile.h"
#include "libpng/png.h"
7,7 → 8,7
{
namespace loader
{
std::shared_ptr<driver::texture> LoadTextureFromPng(const std::string &file) noexcept
std::shared_ptr<driver::texture> textureloader_png::read(const std::string &file) const noexcept
{
#ifdef texture_loader_png
png_byte magic[8];
93,7 → 94,7
#endif
}
 
bool WriteTextureToPng(driver::texture*, const std::string &a) noexcept
bool textureloader_png::write(driver::texture*, const std::string &a) const noexcept
{
#ifdef texture_loader_png
FILE *fp;
125,20 → 126,21
#endif
}
 
bool IsTextureFormatPng(const std::string &file) noexcept
bool textureloader_png::match(const std::string &filename) const noexcept
{
#ifdef texture_loader_png
FILE *fp;
png_byte magic[8];
 
if(!(fp = fopen (file.c_str(), "rb"))) return false;
fread (magic, 1, sizeof (magic), fp);
if(!png_check_sig (magic, sizeof (magic))){ fclose (fp); return false; }
fclose (fp);
return true;
#else
return false;
#endif
// #ifdef texture_loader_png
// FILE *fp;
// png_byte magic[8];
//
// if(!(fp = fopen (filename.c_str(), "rb"))) return false;
// fread (magic, 1, sizeof (magic), fp);
// if(!png_check_sig (magic, sizeof (magic))){ fclose (fp); return false; }
// fclose (fp);
// return true;
// #else
// return false;
// #endif
return filename.substr(filename.find_last_of('.')+1, 3) == "png";
}
}
}
/src/sleek/loader/texture_png.h
1,15 → 1,17
#include <string>
#include "texture_loader.h"
 
namespace sleek
{
namespace driver
{
class texture;
}
namespace loader
{
std::shared_ptr<driver::texture> LoadTextureFromPng(const std::string&) noexcept;
bool WriteTextureToPng(driver::texture*,const std::string&) noexcept;
bool IsTextureFormatPng(const std::string&) noexcept;
{
class textureloader_png : public textureloader
{
public:
virtual std::shared_ptr<driver::texture> read(const std::string&) const noexcept;
 
virtual bool write(driver::texture*,const std::string&) const noexcept;
 
virtual bool match(const std::string&) const noexcept;
};
}
}
/src/sleek/loader/texture_tiff.cpp
1,3 → 1,4
#include "texture_tiff.h"
#include "../driver/texture.h"
#include "../compile.h"
#include <tiffio.h>
53,7 → 54,7
}
#endif
 
std::shared_ptr<driver::texture> LoadTextureFromTiff(const std::string &filename) noexcept
std::shared_ptr<driver::texture> textureloader_tiff::read(const std::string &filename) const noexcept
{
#ifdef texture_loader_tiff
FILE *file = fopen(filename.c_str(), "r");
91,26 → 92,32
return nullptr;
#endif
}
 
bool textureloader_tiff::write(driver::texture*, const std::string&) const noexcept
{
return false;
}
 
bool IsTextureFormatTiff(const std::string &filename) noexcept
bool textureloader_tiff::match(const std::string &filename) const noexcept
{
#ifdef texture_loader_tiff
FILE *file = fopen(filename.c_str(), "r");
 
TIFF* tif = TIFFClientOpen(
"File", "r", (thandle_t)file,
tiff_Read, tiff_Write,
tiff_Seek, tiff_Close, tiff_Size,
tiff_Map, tiff_Unmap
);
 
if(tif)
{
TIFFClose(tif);
return true;
}
#endif
return false;
// #ifdef texture_loader_tiff
// FILE *file = fopen(filename.c_str(), "r");
//
// TIFF* tif = TIFFClientOpen(
// "File", "r", (thandle_t)file,
// tiff_Read, tiff_Write,
// tiff_Seek, tiff_Close, tiff_Size,
// tiff_Map, tiff_Unmap
// );
//
// if(tif)
// {
// TIFFClose(tif);
// return true;
// }
// #endif
// return false;
return filename.substr(filename.find_last_of('.')+1, 3) == "tiff";
}
}
}
/src/sleek/loader/texture_tiff.h
1,14 → 1,17
#include <string>
#include "texture_loader.h"
 
namespace sleek
{
namespace driver
{
class texture;
}
namespace loader
{
std::shared_ptr<driver::texture> LoadTextureFromTiff(const std::string&) noexcept;
bool IsTextureFormatTiff(const std::string&) noexcept;
{
class textureloader_tiff : public textureloader
{
public:
virtual std::shared_ptr<driver::texture> read(const std::string&) const noexcept;
 
virtual bool write(driver::texture*,const std::string&) const noexcept;
 
virtual bool match(const std::string&) const noexcept;
};
}
}
/src/sleek/start.h
3,3 → 3,4
#include "driver/context.h"
#include "driver/driver.h"
#include "node/engine.h"
#include "loader/loader.h"