/SleekThink.cbp
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
/SleekThink.depend
75625,11 → 75625,11
<memory.h>
<GL/gl.h>
 
1422752144 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/GameCore.cpp
1423170422 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/GameCore.cpp
"GameCore.h"
"../sleek/loader/texture_loader.h"
 
1422752086 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/GameCore.h
1423167981 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/GameCore.h
"GameMenu.h"
"GameEngine.h"
"GameIntro.h"
77600,7 → 77600,7
"../sleek/start.h"
"../sleek/driver/mesh.h"
 
1422762252 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/GameEngine.cpp
1423173419 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/GameEngine.cpp
"GameCore.h"
"GameEngine.h"
"light.h"
77608,7 → 77608,7
 
1422762241 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/light.h
 
1422752130 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/GameMenu.cpp
1423170875 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/GameMenu.cpp
"GameCore.h"
"GameMenu.h"
"../sleek/loader/texture_loader.h"
77621,7 → 77621,7
"texture.h"
"../core/math/aabbox.h"
 
1422753941 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/main.cpp
1423168034 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/main.cpp
"../sleek/device/splash.h"
"../sleek/loader/texture_loader.h"
"GameCore.h"
79429,12 → 79429,13
"../engine.h"
"sprite.h"
 
1422292689 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/node/camera/camera.cpp
1422762611 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/node/camera/camera.cpp
"../../device/device.h"
"../../library/glm/detail/func_geometric.hpp"
"../../library/glm/gtc/matrix_transform.hpp"
"../../library/glm/gtc/type_ptr.hpp"
"camera.h"
"GL/gl.h"
 
1324743734 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/node/camera/freefly.cpp
 
79826,12 → 79827,12
"TheoraVideoClip.h"
"TheoraUtil.h"
 
1420904968 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/video/audio.cpp
1423171321 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/video/audio.cpp
"audio.h"
<climits>
<iostream>
 
1421725483 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/video/audio.h
1423171321 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/video/audio.h
"../compile.h"
<AL/al.h>
<AL/alc.h>
79840,12 → 79841,12
<theora/TheoraVideoClip.h>
<queue>
 
1420904968 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/video/video.cpp
1423171360 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/video/video.cpp
"../driver/context.h"
"video.h"
<theora/TheoraDataSource.h>
 
1421726113 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/video/video.h
1423171360 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/video/video.h
"../compile.h"
"../define.h"
"../math/vector2d.h"
80885,11 → 80886,12
 
1324743734 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/mesh/post-processing.cpp
 
1422752475 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/texture_loader.h
1423167875 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/texture_loader.h
<string>
<memory>
"../io/filesystem.h"
 
1422751507 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/texture_bmp.h
1423167875 /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
80896,7 → 80898,7
<string>
<string>
 
1422751507 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/texture_png.h
1423167875 /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
80914,13 → 80916,13
"cursor.h"
"../driver/fbo.h"
 
1422753113 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/mesh_3ds.cpp
1423171292 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>
 
1422752729 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/mesh_3ds.h
1423167875 /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
80931,7 → 80933,7
"../mesh/mesh.h"
"../compile.h"
 
1422753113 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/mesh_txt.cpp
1423171292 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"
80941,7 → 80943,7
"../mesh/mesh.h"
"../compile.h"
 
1422753113 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/texture_bmp.cpp
1423171292 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/texture_bmp.cpp
"texture_bmp.h"
"../driver/texture.h"
"../compile.h"
80951,7 → 80953,7
"../driver/texture.h"
"../driver/texture.h"
 
1422753113 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/texture_png.cpp
1423173191 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/texture_png.cpp
"texture_png.h"
"../driver/texture.h"
"../compile.h"
81169,7 → 81171,7
<iostream>
"console/spdlog.h"
 
1422752382 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/compile.h
1423175311 /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"
81210,7 → 81212,7
"ogl_texture.h"
"ogl_vbo.h"
 
1422762232 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/context.h
1423167104 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/context.h
"../compile.h"
"../device/device_stub.h"
"../math/aabbox.h"
81251,10 → 81253,10
1420770430 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/reference.cpp
"reference.h"
 
1422751507 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/texture_tiff.h
1423167875 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/texture_tiff.h
"texture_loader.h"
 
1422753113 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/texture_tiff.cpp
1423174432 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/texture_tiff.cpp
"texture_tiff.h"
"../driver/texture.h"
"../compile.h"
81349,18 → 81351,16
<vector>
"mesh.h"
 
1420904789 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/material.cpp
1423175311 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/material.cpp
"../compile.h"
"../define.h"
"context.h"
"material.h"
 
1420904789 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/shader.cpp
1423167485 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/shader.cpp
"../driver/context.h"
"material.h"
"shader.h"
"../driver/context.h"
<stdlib.h>
<string.h>
 
1420577052 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/ogl/ogl_vbo.h
"../context.h"
81516,7 → 81516,7
"ogl.h"
"../fbo.h"
 
1420905888 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/ogl3/ogl_context.cpp
1423175305 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/ogl3/ogl_context.cpp
"../../device/device.h"
"ogl_context.h"
"ogl_driver.h"
81603,19 → 81603,23
1324743730 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/library/opengl/glew.h
<GL/glu.h>
 
1422748702 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/io/filesystem.cpp
1423171415 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/io/filesystem.cpp
"filesystem.h"
"std/filesystem.h"
"../compile.h"
<memory>
 
1422748995 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/io/filesystem.h
1423167586 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/io/filesystem.h
"directory.h"
"archive.h"
"filereader.h"
"filewriter.h"
<vector>
"archive.h"
 
1422748684 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/io/archive.h
1423167619 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/io/archive.h
<memory>
<string>
"filesystem.h"
"filereader.h"
"filewriter.h"
"directory.h"
81635,10 → 81639,11
<memory>
"../define.h"
 
1422749111 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/io/std/filesystem.h
1423171241 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/io/std/filesystem.h
"../../compile.h"
"../filesystem.h"
 
1422750539 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/io/std/filesystem.cpp
1423171241 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/io/std/filesystem.cpp
"filesystem.h"
"directory.h"
"filereader.h"
81657,16 → 81662,17
<vector>
"../directory.h"
 
1422752736 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/loader.h
1423168165 /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
1423167875 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/mesh_loader.h
<string>
<memory>
"../io/filesystem.h"
 
1422752996 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/loader.cpp
1423171400 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/loader.cpp
"loader.h"
"../compile.h"
"mesh_3ds.h"
81675,7 → 81681,7
"texture_png.h"
"texture_tiff.h"
 
1422752729 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/mesh_txt.h
1423167875 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/mesh_txt.h
"mesh_loader.h"
 
1422762335 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/ogl3/ogl.h
/SleekThink.layout
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
/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,16 → 20,21
renderer->setAntialiasing(driver::DAM_FAST);
renderer->setViewport(screen->getInfo().size);
driver = renderer->createDriver();
loader = std::make_shared<sleek::loader::loader>();
 
fs = io::createFilesystem(io::FILE_SYSTEM_TYPE::FST_STD);
loader = std::make_shared<sleek::loader::loader>(fs);
 
guienv = sleek::gui::createGUIEnvironment(screen, driver);
 
guienv->getCursor()->showCursor(false);
guienv->getCursor()->showTexture(true);
 
pointor = loader->loadTexture("texture/pointor.bmp");
pointor->createIdentifier(renderer.get());
pointor->getIdentifier()->update();
if(pointor)
{
pointor->createIdentifier(renderer.get());
pointor->getIdentifier()->update();
}
 
guienv->getCursor()->setTexture(pointor.get());
 
screen->setEventReceiver(this);
/src/app/GameCore.h
44,9 → 44,11
std::shared_ptr<sleek::gui::interface> guienv;
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;
std::shared_ptr<sleek::io::filesystem> fs;
 
std::shared_ptr<sleek::driver::texture>pointor;
 
GameMenu *menu;
GameEngine *game;
GameIntro *intro;
/src/app/GameMenu.cpp
36,8 → 36,11
}
 
background = mom->getLoader()->loadTexture("texture/background.bmp");
background->createIdentifier(core->getContext());
background->getIdentifier()->update();
if(background)
{
background->createIdentifier(core->getContext());
background->getIdentifier()->update();
}
 
rebuild();
}
87,14 → 90,17
 
void GameMenu::render() noexcept
{
float aspect = float(background->getOriginalSize().x) / float(background->getOriginalSize().y);
auto size = sleek::math::vector2di(screen->getInfo().size.x, screen->getInfo().size.y);
auto pos = sleek::math::vector2di(screen->getInfo().size.x, screen->getInfo().size.x / aspect);
if(background)
{
float aspect = float(background->getOriginalSize().x) / float(background->getOriginalSize().y);
auto size = sleek::math::vector2di(screen->getInfo().size.x, screen->getInfo().size.y);
auto pos = sleek::math::vector2di(screen->getInfo().size.x, screen->getInfo().size.x / aspect);
 
core->getDriver()->drawTextureScale(
background.get(), (size-pos)/2,
sleek::math::vector3df(0, 0, 0),
sleek::math::vector3df(pos.x, pos.y, 0)
);
core->getDriver()->drawTextureScale(
background.get(), (size-pos)/2,
sleek::math::vector3df(0, 0, 0),
sleek::math::vector3df(pos.x, pos.y, 0)
);
}
}
}
/src/app/main.cpp
36,7 → 36,8
file += std::to_string(std::rand()%5);
file += ".bmp";
 
auto loader = std::make_shared<sleek::loader::loader>();
auto fs = sleek::io::createFilesystem(io::FILE_SYSTEM_TYPE::FST_STD);
auto loader = std::make_shared<sleek::loader::loader>(fs);
 
splash->setPicture(loader->loadTexture(file));
splash->resizeFromPicture();
/src/sleek/compile.h
7,17 → 7,16
#endif
 
//#define sdl2_device_support
//#define index_clockwise
 
#define std_filesystem
#define std_filesystem_support
 
#define mesh_loader_3ds
#define mesh_loader_txt
#define texture_loader_bmp
#define texture_loader_png
#define texture_loader_tiff
#define mesh_loader_3ds_support
#define mesh_loader_txt_support
#define texture_loader_bmp_support
#define texture_loader_png_support
#define texture_loader_tiff_support
 
#define video_reader
#define video_reader_audio
#define video_reader_support
#define video_reader_audio_support
 
#define GL_MAX_TEXTURE 4
#define reserved_texture 4
/src/sleek/driver/context.h
73,6 → 73,7
};
 
// build platform dependent render context
// shared context must be the same type
 
std::shared_ptr<context> createContextRenderer(
RENDER_CONTEXT,
/src/sleek/driver/material.cpp
17,7 → 17,7
mat = rmt_solid;
shd = rsd_smooth;
 
for(u16 i = 0; i<GL_MAX_TEXTURE; ++i)
for(u16 i = 0; i<reserved_texture; ++i)
Texture.push_back(0);
 
effect = 0;
69,7 → 69,7
 
void material::setTexture(const u32 i, identifier *t) noexcept
{
if(i<= GL_MAX_TEXTURE)
if(i<= reserved_texture)
Texture[i] = t;
}
 
/src/sleek/driver/ogl3/ogl_context.cpp
59,7 → 59,7
 
if(checkExtension("GL_ARB_multitexture"))
{
int texture_unity = GL_MAX_TEXTURE;
int texture_unity = reserved_texture;
glGetIntegerv(GL_MAX_TEXTURE_UNITS, &texture_unity);
glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB,&texture_unity);
printf("Max texture units initialized: %d\n", texture_unity);
/src/sleek/driver/shader.cpp
1,21 → 1,7
#include "../driver/context.h"
#include "material.h"
#include "shader.h"
#include "../driver/context.h"
#include <stdlib.h>
#include <string.h>
 
#ifndef GL_VERSION_2_0
#warning Opengl 2.0 not declared
#endif
#if defined GL_VERSION_2_0 || defined GL_ARB_shader_objects
#ifdef __linux
#define GL_SHADER_SUPPORT
#endif
#if (defined GL_ARB_geometry_shader4 || defined GL_EXT_geometry_shader4 || defined GL_NV_geometry_program4 || defined GL_NV_geometry_shader4) && defined GL_VERSION_3_0
// #define GL_GEOMETRY_SHADER
#endif
#endif
 
namespace sleek
{
namespace driver
/src/sleek/io/archive.h
4,6 → 4,7
#include <memory>
#include <string>
 
#include "filesystem.h"
#include "filereader.h"
#include "filewriter.h"
#include "directory.h"
12,14 → 13,9
{
namespace io
{
class archive : public std::enable_shared_from_this<archive>
class archive : public filesystem
{
public:
inline std::shared_ptr<archive> getptr() noexcept
{
return shared_from_this();
}
 
virtual const std::string& filename() = 0;
 
virtual std::shared_ptr<filereader> read(const std::string&) = 0;
/src/sleek/io/filesystem.cpp
1,5 → 1,9
#include "filesystem.h"
#include "std/filesystem.h"
#include "../compile.h"
 
#include <memory>
 
namespace sleek
{
namespace io
15,8 → 19,8
{
switch(e)
{
#ifdef std_filesystem
case FST_STD:
#ifdef std_filesystem_support
case FILE_SYSTEM_TYPE::FST_STD:
return std::make_shared<std_filesystem>();
#endif // std_filesystem
}
/src/sleek/io/filesystem.h
2,7 → 2,6
#define __FILE_SYSTEM__
 
#include "directory.h"
#include "archive.h"
#include "filereader.h"
#include "filewriter.h"
#include <vector>
17,6 → 16,9
FST_COUNT
};
 
class archive;
class archiveloader;
 
class filesystem : public std::enable_shared_from_this<filesystem>
{
public:
29,10 → 31,7
virtual const std::string& pwd() const noexcept = 0;
 
virtual std::shared_ptr<filereader> read(const std::string&) const noexcept = 0;
virtual std::shared_ptr<filereader> read(const std::string&, void *ptr) const noexcept = 0;
 
virtual std::shared_ptr<filewriter> write(const std::string&) const noexcept = 0;
virtual std::shared_ptr<filewriter> write(const std::string&, void *ptr) const noexcept = 0;
 
virtual std::shared_ptr<archive> load(const std::string&) const noexcept;
virtual std::shared_ptr<directory> list(const std::string&) const noexcept = 0;
44,4 → 43,6
}
}
 
#include "archive.h"
 
#endif // __FILE_SYSTEM__
/src/sleek/io/std/filesystem.cpp
1,5 → 1,6
#include "filesystem.h"
 
#ifdef std_filesystem_support
#include "directory.h"
#include "filereader.h"
#include "filewriter.h"
85,3 → 86,4
}
}
}
#endif
/src/sleek/io/std/filesystem.h
1,8 → 1,10
#ifndef __STD_FILE_SYSTEM__
#define __STD_FILE_SYSTEM__
 
#include "../../compile.h"
#include "../filesystem.h"
 
#ifdef std_filesystem_support
namespace sleek
{
namespace io
28,5 → 30,6
};
}
}
#endif
 
#endif // __FILE_SYSTEM__
/src/sleek/loader/loader.cpp
11,25 → 11,32
{
namespace loader
{
loader::loader()
loader::loader(std::shared_ptr<io::filesystem> f)
: fs(f)
{
#ifdef mesh_loader_3ds
if(!fs)
{
printf("no filesystem\n");
return;
}
 
#ifdef mesh_loader_3ds_support
mesh.push_back(new meshloader_3ds());
#endif
 
#ifdef mesh_loader_txt
#ifdef mesh_loader_txt_support
mesh.push_back(new meshloader_txt());
#endif
 
#ifdef texture_loader_bmp
#ifdef texture_loader_bmp_support
texture.push_back(new textureloader_bmp());
#endif
 
#ifdef texture_loader_png
#ifdef texture_loader_png_support
texture.push_back(new textureloader_png());
#endif
 
#ifdef texture_loader_tiff
#ifdef texture_loader_tiff_support
texture.push_back(new textureloader_tiff());
#endif
}
38,17 → 45,47
}
std::shared_ptr<driver::MeshBuffer> loader::loadMesh(const std::string &filename) const noexcept
{
if(!fs)
return nullptr;
 
for(auto e : mesh)
if(e->match(filename))
return e->read(filename);
return e->read(fs.get(), filename);
 
return nullptr;
}
std::shared_ptr<driver::texture> loader::loadTexture(const std::string &filename) const noexcept
{
if(!fs)
return nullptr;
 
for(auto e : texture)
if(e->match(filename))
return e->read(filename);
return e->read(fs.get(), filename);
 
return nullptr;
}
bool loader::writeMesh(std::shared_ptr<driver::MeshBuffer> data, const std::string &filename) const noexcept
{
if(!fs || !data)
return nullptr;
 
for(auto e : mesh)
if(e->match(filename))
return e->write(fs.get(), data.get(), filename);
 
return nullptr;
}
bool loader::writeTexture(std::shared_ptr<driver::texture> data, const std::string &filename) const noexcept
{
if(!fs || !data)
return nullptr;
 
for(auto e : texture)
if(e->match(filename))
return e->write(fs.get(), data.get(), filename);
 
return nullptr;
}
}
}
/src/sleek/loader/loader.h
12,7 → 12,7
class loader : public std::enable_shared_from_this<loader>
{
public:
loader();
loader(std::shared_ptr<io::filesystem>);
virtual ~loader();
 
inline std::shared_ptr<loader> getptr() noexcept
22,7 → 22,11
 
virtual std::shared_ptr<driver::MeshBuffer> loadMesh(const std::string&) const noexcept;
virtual std::shared_ptr<driver::texture> loadTexture(const std::string&) const noexcept;
 
virtual bool writeMesh(std::shared_ptr<driver::MeshBuffer>, const std::string&) const noexcept;
virtual bool writeTexture(std::shared_ptr<driver::texture>, const std::string&) const noexcept;
public:
std::shared_ptr<io::filesystem> fs;
std::vector<textureloader*> texture;
std::vector<meshloader*> mesh;
};
/src/sleek/loader/mesh_3ds.cpp
13,22 → 13,24
fstat(f, &buf);
return buf.st_size;
}
std::shared_ptr<driver::MeshBuffer> meshloader_3ds::read(const std::string &file) const noexcept
std::shared_ptr<driver::MeshBuffer> meshloader_3ds::read(io::filesystem *fs, const std::string &file) const noexcept
{
#ifdef mesh_loader_3ds
#ifdef mesh_loader_3ds_support
unsigned char lchar = 0;
unsigned int lchunk_lenght = 0;
unsigned short lchunk_id = 0, lqty = 0, lface_flags = 0;
unsigned short lchunk_id = 0, lqty = 0, lface_flags = 0;
 
//! original use 'rb'
auto in = fs->read(file);
 
FILE *in = fopen(file.c_str(), "rb");
if(!in){ printf("error: couldn't open \"%s\"!\n", file.c_str()); return 0; }
printf("Load mesh: \"%s\"\n", file.c_str());
 
auto tmp = std::make_shared<driver::MeshBuffer>();
while(ftell(in) < 200)
while(in->pos() < 200)
{
fread(&lchunk_id, 2, 1, in);
fread(&lchunk_lenght, 4, 1, in);
in->read(&lchunk_id, 2);
in->read(&lchunk_lenght, 4);
 
switch (lchunk_id)
{
37,38 → 39,38
case 0x4000: break;
case 0x4100: break;
case 0x4110:
fread(&lqty, sizeof (unsigned short), 1, in);
in->read(&lqty, sizeof(unsigned short));
tmp->vertices.resize(lqty);
 
for (u32 i = 0; i < lqty; i++)
for(u32 i = 0; i < lqty; i++)
{
fread(&tmp->vertices[i].Pos.x, sizeof(f32), 1, in);
fread(&tmp->vertices[i].Pos.y, sizeof(f32), 1, in);
fread(&tmp->vertices[i].Pos.z, sizeof(f32), 1, in);
in->read(&tmp->vertices[i].Pos.x, sizeof(f32));
in->read(&tmp->vertices[i].Pos.y, sizeof(f32));
in->read(&tmp->vertices[i].Pos.z, sizeof(f32));
}
break;
case 0x4120:
fread (&lqty, sizeof (unsigned short), 1, in);
in->read(&lqty, sizeof(unsigned short));
tmp->indices.resize(lqty);
 
for (u32 i = 0; i < lqty; i++)
for(u32 i = 0; i < lqty; i++)
{
fread (&tmp->indices[i].vertex[0], sizeof (unsigned short), 1, in);
fread (&tmp->indices[i].vertex[1], sizeof (unsigned short), 1, in);
fread (&tmp->indices[i].vertex[2], sizeof (unsigned short), 1, in);
fread (&lface_flags, sizeof (unsigned short), 1, in);
in->read(&tmp->indices[i].vertex[0], sizeof(unsigned short));
in->read(&tmp->indices[i].vertex[1], sizeof(unsigned short));
in->read(&tmp->indices[i].vertex[2], sizeof(unsigned short));
in->read(&lface_flags, sizeof(unsigned short));
}
break;
case 0x4140:
fread (&lqty, sizeof (unsigned short), 1, in);
for (u32 i = 0; i < lqty; i++)
in->read(&lqty, sizeof(unsigned short));
for(u32 i = 0; i < lqty; i++)
{
fread (&tmp->vertices[i].Coord.x, sizeof (f32), 1, in);
fread (&tmp->vertices[i].Coord.y, sizeof (f32), 1, in);
in->read(&tmp->vertices[i].Coord.x, sizeof(f32));
in->read(&tmp->vertices[i].Coord.y, sizeof(f32));
}
break;
default:
fseek(in, lchunk_lenght - 6, SEEK_CUR);
in->seek(lchunk_lenght - 6, true);
break;
}
}
78,7 → 80,7
#endif
}
 
bool meshloader_3ds::write(driver::MeshBuffer*,const std::string&) const noexcept
bool meshloader_3ds::write(io::filesystem *fs, driver::MeshBuffer*,const std::string&) const noexcept
{
return false;
}
/src/sleek/loader/mesh_3ds.h
7,9 → 7,9
class meshloader_3ds : public meshloader
{
public:
virtual std::shared_ptr<driver::MeshBuffer> read(const std::string&) const noexcept;
virtual std::shared_ptr<driver::MeshBuffer> read(io::filesystem*, const std::string&) const noexcept;
 
virtual bool write(driver::MeshBuffer*, const std::string&) const noexcept;
virtual bool write(io::filesystem*, driver::MeshBuffer*, const std::string&) const noexcept;
 
virtual bool match(const std::string&) const noexcept;
};
/src/sleek/loader/mesh_loader.h
3,6 → 3,7
 
#include <string>
#include <memory>
#include "../io/filesystem.h"
 
namespace sleek
{
15,9 → 16,9
class meshloader
{
public:
virtual std::shared_ptr<driver::MeshBuffer> read(const std::string&) const noexcept = 0;
virtual std::shared_ptr<driver::MeshBuffer> read(io::filesystem*, const std::string&) const noexcept = 0;
 
virtual bool write(driver::MeshBuffer*, const std::string&) const noexcept = 0;
virtual bool write(io::filesystem*, driver::MeshBuffer*, const std::string&) const noexcept = 0;
 
virtual bool match(const std::string&) const noexcept = 0;
};
/src/sleek/loader/mesh_txt.cpp
7,28 → 7,49
{
namespace loader
{
std::shared_ptr<driver::MeshBuffer> meshloader_txt::read(const std::string &file) const noexcept
std::shared_ptr<driver::MeshBuffer> meshloader_txt::read(io::filesystem *fs, const std::string &file) const noexcept
{
#ifdef mesh_loader_txt
#ifdef mesh_loader_txt_support
int nvert;
FILE *filein;
char oneline[255];
float rx, ry, rz;
std::string oneline;
float rx, ry, rz;
 
for(int i = 0; i<255; ++i)
oneline += '\0';
 
filein = fopen(file.c_str(), "rt");
if(!filein){ printf("error: couldn't open \"%s\"!\n", file.c_str()); return 0; }
auto in = fs->read(file.c_str());
if(!in){ printf("error: couldn't open \"%s\"!\n", file.c_str()); return 0; }
 
auto tmp = std::make_shared<driver::MeshBuffer>();
do { fgets(oneline, 255, filein); } while ((oneline[0] == '/') || (oneline[0] == '\n'));
if(std::string("Vertices:") != std::string(oneline).substr(0,9)) return 0;
auto tmp = std::make_shared<driver::MeshBuffer>();
 
do
{
in->read(const_cast<char*>(oneline.c_str()), 255);
int i = oneline.find('\n');
if(i != -1)
in->seek(255-i, true);
}
while(oneline[0] == '/' || oneline[0] == '\n');
 
if(oneline.substr(0,9) != "Vertices:")
return nullptr;
 
printf("Load mesh: \"%s\"\n", file.c_str());
sscanf(oneline, "Vertices: %d\n", &nvert);
sscanf(oneline.c_str(), "Vertices: %d\n", &nvert);
tmp->vertices.resize(nvert);
 
for(int i=0;i<nvert;i++)
{
do { fgets(oneline, 255, filein); } while ((oneline[0] == '/') || (oneline[0] == '\n'));
sscanf(oneline, "%f %f %f", &rx, &ry, &rz);
do
{
in->read(const_cast<char*>(oneline.c_str()), 255);
int i = oneline.find('\n');
if(i != -1)
in->seek(255-i, true);
}
while(oneline[0] == '/' || oneline[0] == '\n');
 
sscanf(oneline.c_str(), "%f %f %f", &rx, &ry, &rz);
tmp->vertices[i].Pos = math::vector3df(rx,ry,rz);
tmp->vertices[i].Normal = glm::normalize(tmp->vertices[i].Pos);
 
38,8 → 59,7
in.vertex[2] = i+2;
tmp->indices.push_back(in);
}
 
fclose(filein);
 
return tmp;
#else
return nullptr;
46,16 → 66,31
#endif
}
 
bool meshloader_txt::write(driver::MeshBuffer *m, const std::string &file) const noexcept
bool meshloader_txt::write(io::filesystem *fs, driver::MeshBuffer *m, const std::string &file) const noexcept
{
#ifdef mesh_loader_txt
FILE *out = fopen(file.c_str(), "wb+");
#ifdef mesh_loader_txt_support
auto out = fs->write(file.c_str());
if(!out){ printf("error: couldn't open \"%s\"!\n", file.c_str()); return 0; }
 
printf("Write mesh: \"%s\"\n", file.c_str());
fprintf(out,"Vertices: %d\n", m->vertices.size());
 
std::string data = "Vertices: ";
data += std::to_string(m->vertices.size());
data += '\n';
out->write(data.c_str(), data.size());
 
for(u32 i =0; i<m->vertices.size(); ++i)
fprintf(out, "%f %f %f\n", m->vertices[i].Pos.x, m->vertices[i].Pos.y, m->vertices[i].Pos.z);
return 0;
{
data = "";
data += std::to_string(m->vertices[i].Pos.x);
data += " ";
data += std::to_string(m->vertices[i].Pos.y);
data += " ";
data += std::to_string(m->vertices[i].Pos.z);
out->write(data.c_str(), data.size());
}
 
return true;
#else
return false;
#endif
63,17 → 98,6
 
bool meshloader_txt::match(const std::string &filename) const noexcept
{
// #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
7,9 → 7,9
class meshloader_txt : public meshloader
{
public:
virtual std::shared_ptr<driver::MeshBuffer> read(const std::string&) const noexcept;
virtual std::shared_ptr<driver::MeshBuffer> read(io::filesystem*, const std::string&) const noexcept;
 
virtual bool write(driver::MeshBuffer*, const std::string&) const noexcept;
virtual bool write(io::filesystem*, driver::MeshBuffer*, const std::string&) const noexcept;
 
virtual bool match(const std::string&) const noexcept;
};
/src/sleek/loader/texture_bmp.cpp
9,24 → 9,41
{
#define CTOI(C) (*(int*)&C)
 
std::shared_ptr<driver::texture> textureloader_bmp::read(const std::string &file) const noexcept
std::shared_ptr<driver::texture> textureloader_bmp::read(io::filesystem *fs, const std::string &file) const noexcept
{
#ifdef texture_loader_bmp
FILE *filePtr;
#ifdef texture_loader_bmp_support
unsigned char header[0x36];
int colorMode, imagePos;
long imageSize, imageIdx, m_width, m_height;
unsigned char m_bitCount;
 
if(!(filePtr = fopen(file.c_str(), "rb"))){ printf("error: couldn't open \"%s\"!\n", file.c_str()); return 0; }
if(fread(header,1,0x36,filePtr)!=0x36) { printf("error: \"%s\" is not a valid BMP image!\n", file.c_str()); fclose(filePtr); return 0; }
if(header[0]!='B' || header[1]!='M') { printf("error: Can't find BMP headler in \"%s\"!\n", file.c_str()); fclose(filePtr); return 0; }
switch(CTOI(header[0x1E]))
unsigned char m_bitCount;
 
auto in = fs->read(file);
if(!in)
{
case 0: case 1: case 2: case 3: break;
default: printf("error: \"%s\" unsuported compressed mode %d!\n", file.c_str(), CTOI(header[0x1E])); fclose(filePtr); return 0; break;
printf("error: couldn't open \"%s\"!\n", file.c_str());
return nullptr;
}
 
in->read(header, 0x36);
if(header[0]!='B' || header[1]!='M')
{
printf(
"error: Can't find BMP headler in \"%s\"!\n",
file.c_str()
);
return nullptr;
}
 
if(CTOI(header[0x1E]) < 0 || CTOI(header[0x1E]) > 3)
{
printf(
"error: \"%s\" unsuported compressed mode %d!\n",
file.c_str(),
CTOI(header[0x1E])
);
return nullptr;
}
 
printf("Load texture: \"%s\" compressed mode %d\n", file.c_str(), CTOI(header[0x1E]));
 
m_bitCount = CTOI(header[0x1C]);
44,14 → 61,21
if(!imageSize) imageSize = m_height* m_width*(m_bitCount/8);
if(!imagePos) imagePos = 0x36;
 
fseek(filePtr,imagePos,0);
in->seek(imagePos, false);
 
auto bmp = std::make_shared<driver::texture>(math::vector2di(m_width, m_height), (driver::TextureFormat)colorMode);
 
if (!bmp->getBuffer()) { fclose(filePtr); printf("texture: alocation fail\n"); return 0; }
if(fread(bmp->getBuffer(),1,imageSize,filePtr) != (unsigned long)imageSize);
fclose(filePtr);
if(!bmp->getBuffer())
{
printf("texture: alocation fail\n");
return nullptr;
}
 
int pos = in->pos();
in->read(bmp->getBuffer(), imageSize);
// if(in->pos() - pos != imageSize)
// return nullptr;
 
switch(CTOI(header[0x1E]))
{
case 0:
119,12 → 143,16
#endif
}
 
bool textureloader_bmp::write(driver::texture *img, const std::string &file) const noexcept
bool textureloader_bmp::write(io::filesystem *fs, driver::texture *img, const std::string &file) const noexcept
{
#ifdef texture_loader_bmp
FILE *filePtr;
if (!(filePtr = fopen(file.c_str(), "wb+")) && !img){ printf("error: couldn't open \"%s\"!\n", file.c_str()); return false; }
else printf("Write texture: \"%s\"\n", file.c_str());
#ifdef texture_loader_bmp_support
if(!img)
return false;
 
auto out = fs->write(file);
 
if(!out)
return false;
 
unsigned char header[0x36];
header[0] = 'B';
131,7 → 159,8
header[1] = 'M';
header[0x1E] = 1;
header[0x1C] = img->getFormat()*8;
fwrite(header,1,0x36,filePtr);
out->write(header,0x36);
 
return true;
#else
return false;
/src/sleek/loader/texture_bmp.h
7,9 → 7,9
class textureloader_bmp : public textureloader
{
public:
virtual std::shared_ptr<driver::texture> read(const std::string&) const noexcept;
virtual std::shared_ptr<driver::texture> read(io::filesystem*, const std::string&) const noexcept;
 
virtual bool write(driver::texture*,const std::string&) const noexcept;
virtual bool write(io::filesystem*, driver::texture*,const std::string&) const noexcept;
 
virtual bool match(const std::string&) const noexcept;
};
/src/sleek/loader/texture_loader.h
3,6 → 3,7
 
#include <string>
#include <memory>
#include "../io/filesystem.h"
 
namespace sleek
{
15,9 → 16,9
class textureloader
{
public:
virtual std::shared_ptr<driver::texture> read(const std::string&) const noexcept = 0;
virtual std::shared_ptr<driver::texture> read(io::filesystem*, const std::string&) const noexcept = 0;
 
virtual bool write(driver::texture*,const std::string&) const noexcept = 0;
virtual bool write(io::filesystem*, driver::texture*,const std::string&) const noexcept = 0;
 
virtual bool match(const std::string&) const noexcept = 0;
};
/src/sleek/loader/texture_png.cpp
7,62 → 7,110
namespace sleek
{
namespace loader
{
std::shared_ptr<driver::texture> textureloader_png::read(const std::string &file) const noexcept
{
#ifdef texture_loader_png_support
static void png_cpexcept_error(png_structp png_ptr, png_const_charp msg)
{
#ifdef texture_loader_png
printf("PNG fatal error: %s", msg);
longjmp(png_jmpbuf(png_ptr), 1);
}
 
// PNG function for warning handling
static void png_cpexcept_warn(png_structp png_ptr, png_const_charp msg)
{
printf("PNG warning: %s", msg);
}
 
void PNGAPI user_read_data_fcn(png_structp png_ptr, png_bytep data, png_size_t length)
{
png_size_t check;
 
io::filereader *file=(io::filereader*)png_get_io_ptr(png_ptr);
int pos = file->pos();
file->read((char*)data,(u32)length);
 
if((file->pos()-pos) != length)
png_error(png_ptr, "Read Error");
}
#endif
 
std::shared_ptr<driver::texture> textureloader_png::read(io::filesystem *fs, const std::string &file) const noexcept
{
#ifdef texture_loader_png_support
png_byte magic[8];
png_structp png_ptr;
png_infop info_ptr;
int bit_depth = 0, color_type = 0;
FILE *fp = 0;
png_bytep *row_pointers = 0;
png_uint_32 w = 0, h = 0;
GLubyte *texels = 0;
 
fp = fopen (file.c_str(), "rb");
if(!fp) { printf("error: couldn't open \"%s\"!\n", file.c_str()); return 0; }
fread (magic, 1, sizeof (magic), fp);
if (!png_check_sig(magic, sizeof (magic)))
auto in = fs->read(file);
if(!in)
{
printf("error: couldn't open \"%s\"!\n", file.c_str());
return nullptr;
}
 
in->read(magic, sizeof(magic));
 
if(!png_check_sig(magic, sizeof (magic)))
{
fprintf (stderr, "error: \"%s\" is not a valid PNG image!\n",file.c_str());
fclose (fp);
return 0;
fprintf(
stderr,
"error: \"%s\" is not a valid PNG image!\n",
file.c_str()
);
return nullptr;
}
printf("Load texture: \"%s\"\n", file.c_str());
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
if(!png_ptr){ fclose (fp); return 0; }
info_ptr = png_create_info_struct (png_ptr);
if (!info_ptr || setjmp(png_jmpbuf (png_ptr)))
 
png_ptr = png_create_read_struct(
PNG_LIBPNG_VER_STRING,
NULL, (png_error_ptr)png_cpexcept_error, (png_error_ptr)png_cpexcept_warn
);
if(!png_ptr)
return nullptr;
 
info_ptr = png_create_info_struct(png_ptr);
if(!info_ptr || setjmp(png_jmpbuf(png_ptr)))
{
fclose (fp);
png_destroy_read_struct (&png_ptr, &info_ptr, 0);
if (row_pointers)
free (row_pointers);
return 0;
}
png_init_io (png_ptr, fp);
png_set_sig_bytes (png_ptr, sizeof (magic));
png_read_info (png_ptr, info_ptr);
png_destroy_read_struct(&png_ptr, &info_ptr, 0);
if(row_pointers)
free(row_pointers);
return nullptr;
}
 
png_set_read_fn(png_ptr, in.get(), user_read_data_fcn);
png_set_sig_bytes(png_ptr, sizeof (magic));
png_read_info(png_ptr, info_ptr);
 
bit_depth = png_get_bit_depth(png_ptr, info_ptr);
color_type = png_get_color_type(png_ptr, info_ptr);
 
if(color_type == PNG_COLOR_TYPE_PALETTE) png_set_palette_to_rgb(png_ptr);
if(color_type == PNG_COLOR_TYPE_PALETTE)
png_set_palette_to_rgb(png_ptr);
 
if(bit_depth < 8)
{
if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) png_set_expand_gray_1_2_4_to_8(png_ptr);
if(color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
png_set_expand_gray_1_2_4_to_8(png_ptr);
else png_set_packing(png_ptr);
}
if(png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png_ptr);
if(bit_depth == 16) png_set_strip_16(png_ptr);
if(color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) png_set_gray_to_rgb(png_ptr);
}
 
if(png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
png_set_tRNS_to_alpha(png_ptr);
 
if(bit_depth == 16)
png_set_strip_16(png_ptr);
 
if(color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
png_set_gray_to_rgb(png_ptr);
 
//! internal png format change to bgr/rgb
png_set_bgr(png_ptr);
 
png_read_update_info (png_ptr, info_ptr);
png_get_IHDR (png_ptr, info_ptr, &w, &h, &bit_depth, &color_type, 0, 0, 0);
png_read_update_info(png_ptr, info_ptr);
png_get_IHDR(png_ptr, info_ptr, &w, &h, &bit_depth, &color_type, 0, 0, 0);
 
int internalFormat = 0;
if(color_type == PNG_COLOR_TYPE_GRAY) internalFormat = driver::TXFMT_LUMINANCE;
77,17 → 125,17
//for(register unsigned int i = 0; i < h; ++i) row_pointers[i] = (png_bytep)(texels+(i*w*internalFormat));
for(register unsigned int i = 0; i < h; ++i) row_pointers[i] = (png_bytep)(texels+((h-(i+1))*w*internalFormat));
 
png_read_image (png_ptr, row_pointers);
png_read_end (png_ptr, 0);
png_destroy_read_struct (&png_ptr, &info_ptr, 0);
png_read_image(png_ptr, row_pointers);
png_read_end(png_ptr, 0);
png_destroy_read_struct(&png_ptr, &info_ptr, 0);
delete row_pointers;
fclose(fp);
 
auto tmp = std::make_shared<driver::texture>(math::vector2di(w, h), (driver::TextureFormat)internalFormat);
memccpy(tmp->getBuffer(), (u8*)texels, 1, tmp->getBufferSize());
 
tmp->flipVertical();
 
 
printf("Load texture: \"%s\"\n", file.c_str());
return tmp;
#else
return nullptr;
94,32 → 142,36
#endif
}
 
bool textureloader_png::write(driver::texture*, const std::string &a) const noexcept
bool textureloader_png::write(io::filesystem *fs, driver::texture*, const std::string &a) const noexcept
{
#ifdef texture_loader_png
FILE *fp;
#ifdef texture_loader_png_support
 
png_structp png_ptr;
png_infop info_ptr;
png_colorp palette;
 
auto out = fs->write(a);
if(!out)
return false;
 
/* Open the file */
fp = fopen(a.c_str(), "wb");
if(!fp) return false;
 
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
if(!png_ptr)
return false;
 
if(!png_ptr){ fclose(fp); return false; }
info_ptr = png_create_info_struct(png_ptr);
if(!info_ptr || setjmp(png_jmpbuf(png_ptr)))
{
fclose(fp);
png_destroy_write_struct(&png_ptr, &info_ptr);
return false;
}
}
 
png_write_end(png_ptr, info_ptr);
png_destroy_write_struct(&png_ptr, &info_ptr);
 
fclose(fp);
png_destroy_write_struct(&png_ptr, &info_ptr);
 
/**
* TODO
*/
 
return true;
#else
return false;
128,18 → 180,6
 
bool textureloader_png::match(const std::string &filename) const noexcept
{
// #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
7,9 → 7,9
class textureloader_png : public textureloader
{
public:
virtual std::shared_ptr<driver::texture> read(const std::string&) const noexcept;
virtual std::shared_ptr<driver::texture> read(io::filesystem*, const std::string&) const noexcept;
 
virtual bool write(driver::texture*,const std::string&) const noexcept;
virtual bool write(io::filesystem*, driver::texture*,const std::string&) const noexcept;
 
virtual bool match(const std::string&) const noexcept;
};
/src/sleek/loader/texture_tiff.cpp
7,20 → 7,19
{
namespace loader
{
#ifdef texture_loader_tiff
#ifdef texture_loader_tiff_support
static tsize_t tiff_Read(thandle_t st, tdata_t buffer, tsize_t size) noexcept
{
return fread(buffer, size, 1, (FILE*)st);
((io::filereader*)st)->read(buffer, size);
}
 
static tsize_t tiff_Write(thandle_t st,tdata_t buffer,tsize_t size) noexcept
{
return fwrite(buffer, size, 1, (FILE*)st);
((io::filewriter*)st)->write(buffer, size);
}
 
static int tiff_Close(thandle_t i) noexcept
{
return fclose((FILE*)i);
}
 
static toff_t tiff_Seek(thandle_t st, toff_t pos, int whence) noexcept
28,19 → 27,12
if(pos == 0xFFFFFFFF)
return 0xFFFFFFFF;
 
return fseek((FILE*)st, pos, whence);
((io::filereader*)st)->seek(pos, whence);
}
 
static toff_t tiff_Size(thandle_t st) noexcept
{
long cur, end;
 
cur = ftell((FILE*)st);
fseek((FILE*)st, 0, SEEK_END);
end = ftell((FILE*)st);
fseek((FILE*)st, cur, SEEK_SET);
 
return end;
return ((io::filereader*)st)->size();
}
 
static int tiff_Map(thandle_t, tdata_t*, toff_t*) noexcept
54,11 → 46,11
}
#endif
 
std::shared_ptr<driver::texture> textureloader_tiff::read(const std::string &filename) const noexcept
std::shared_ptr<driver::texture> textureloader_tiff::read(io::filesystem *fs, 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);
#ifdef texture_loader_tiff_support
auto in = fs->read(filename);
TIFF* tif = TIFFClientOpen("File", "r", (thandle_t)in.get(), tiff_Read, nullptr, tiff_Seek, tiff_Close, tiff_Size, tiff_Map, tiff_Unmap);
 
if(!tif)
return nullptr;
76,7 → 68,7
if(!succ)
return nullptr;
 
//exchange red and blue channels
//swap red and blue channels
int size = w*h;
unsigned char* cdata = img->getBuffer();
 
93,7 → 85,7
#endif
}
 
bool textureloader_tiff::write(driver::texture*, const std::string&) const noexcept
bool textureloader_tiff::write(io::filesystem *fs, driver::texture*, const std::string&) const noexcept
{
return false;
}
100,23 → 92,6
 
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;
return filename.substr(filename.find_last_of('.')+1, 3) == "tiff";
}
}
/src/sleek/loader/texture_tiff.h
7,9 → 7,9
class textureloader_tiff : public textureloader
{
public:
virtual std::shared_ptr<driver::texture> read(const std::string&) const noexcept;
virtual std::shared_ptr<driver::texture> read(io::filesystem*, const std::string&) const noexcept;
 
virtual bool write(driver::texture*,const std::string&) const noexcept;
virtual bool write(io::filesystem*, driver::texture*,const std::string&) const noexcept;
 
virtual bool match(const std::string&) const noexcept;
};
/src/sleek/video/audio.cpp
2,7 → 2,7
#include <climits>
#include <iostream>
 
#ifdef video_reader_audio
#ifdef video_reader_audio_support
 
namespace sleek
{
/src/sleek/video/audio.h
2,7 → 2,7
#define CLASS_AUDIO_INTERFACE_OPEN_AL_H_INC
 
#include "../compile.h"
#ifdef video_reader_audio
#ifdef video_reader_audio_support
 
#include <AL/al.h>
#include <AL/alc.h>
/src/sleek/video/video.cpp
1,6 → 1,7
#include "../driver/context.h"
#include "video.h"
#ifdef video_reader
 
#ifdef video_reader_support
 
#include <theora/TheoraDataSource.h>
 
/src/sleek/video/video.h
4,7 → 4,7
#include "../compile.h"
#include "../define.h"
 
#ifdef video_reader
#ifdef video_reader_support
#include "../math/vector2d.h"
#include "../math/timer.h"
#include "../driver/texture.h"
60,7 → 60,7
driver::context *context;
 
TheoraVideoManager *mVmgr;
#ifdef video_reader_audio
#ifdef video_reader_audio_support
CAudioInterfaceFactoryOpenAL *mAIF;
#endif
std::vector<SVideoClip*> mClip;