/SleekThink.cbp
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
/SleekThink.depend
83501,7 → 83501,7
<sys/types.h>
<sys/sched.h>
 
1424962614 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/GameCore.cpp
1453723936 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/GameCore.cpp
"GameCore.h"
"../sleek/loader/texture_loader.h"
<string>
83558,7 → 83558,7
1423788568 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/define.h
"compile.h"
 
1424044770 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/compile.h
1453712621 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/compile.h
<windows.h>
<stdio.h>
<time.h>
83693,7 → 83693,7
"rtype.h"
"../math/vector3d.h"
 
1420565960 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/rtype.h
1453775981 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/rtype.h
"rtype.h"
 
1420686495 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/vertex.h
83755,7 → 83755,7
"../node.h"
"../math/timer.h"
 
1424960487 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/node/node.h
1425577494 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/node/node.h
"../reference.h"
"../driver/mesh.h"
"../driver/driver.h"
83768,8 → 83768,8
<string>
<memory>
 
1424960819 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/node/billboard/sprite.h
"../node.h"
1453774657 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/node/billboard/sprite.h
"billboard.h"
"../math/timer.h"
 
1421727472 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/node/camera/camera.h
83826,7 → 83826,7
 
1419092212 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/library/glm/detail/type_mat4x4.inl
 
1420905177 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/node/real/natif.h
1425577494 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/node/real/natif.h
"../node.h"
 
1420905177 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/node/real/octree.h
83912,7 → 83912,7
"../gui/frame.h"
<map>
 
1425516220 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/GameEngine.h
1453772981 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/GameEngine.h
"../sleek/start.h"
"../sleek/driver/mesh.h"
 
83967,7 → 83967,7
1330144422 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/library/theora/TheoraTimer.h
"TheoraExport.h"
 
1425516493 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/GameEngine.cpp
1453775502 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/GameEngine.cpp
"GameCore.h"
"GameEngine.h"
"../sleek/loader/texture_loader.h"
83976,7 → 83976,7
"GameCore.h"
"GameIntro.h"
 
1423622857 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/GameMenu.cpp
1453723893 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/app/GameMenu.cpp
"GameCore.h"
"GameMenu.h"
"../sleek/loader/texture_loader.h"
84260,7 → 84260,7
 
1420905877 /mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/library/opengl/GLTool.h
 
1424959245 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/driver.cpp
1453712034 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/driver.cpp
"../device/device.h"
"driver.h"
 
84286,7 → 84286,7
1420904789 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/mesh.cpp
"mesh.h"
 
1424044409 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/ogl3/ogl_context.cpp
1453771526 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"
84321,7 → 84321,7
"ogl.h"
"../shader.h"
 
1425572456 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/ogl3/ogl_driver.cpp
1453774736 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/ogl3/ogl_driver.cpp
"../../device/device.h"
"ogl_context.h"
"ogl_driver.h"
84339,7 → 84339,7
<stdlib.h>
<string.h>
 
1420836570 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/ogl3/ogl_texture.cpp
1453723814 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/driver/ogl3/ogl_texture.cpp
"ogl_texture.h"
<memory.h>
<GL/gl.h>
84385,7 → 84385,7
"interface.h"
"button.h"
 
1424962381 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/gui/colorpicker.cpp
1453724118 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/gui/colorpicker.cpp
"colorpicker.h"
"interface.h"
"scrollbar.h"
84418,7 → 84418,7
"interface.h"
"frame.h"
 
1424963274 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/gui/interface.cpp
1453711929 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/gui/interface.cpp
"interface.h"
"button.h"
"statictext.h"
84455,7 → 84455,7
"interface.h"
"statictext.h"
 
1424960427 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/gui/theme.cpp
1453714823 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/gui/theme.cpp
"interface.h"
"../driver/driver.h"
"theme.h"
84574,7 → 84574,7
"TheoraException.h"
<windows.h>
 
1424044976 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/loader.cpp
1453710489 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/loader.cpp
"loader.h"
"../compile.h"
"mesh_3ds.h"
84605,7 → 84605,7
"../compile.h"
<sys/stat.h>
 
1424913117 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/library/theora/TheoraVideoClip.cpp
1453710826 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/library/theora/TheoraVideoClip.cpp
<memory.h>
<ogg/ogg.h>
<vorbis/vorbisfile.h>
84643,7 → 84643,7
"TheoraVideoClip.h"
"TheoraUtil.h"
 
1423171292 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/mesh_txt.cpp
1453774280 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"
84723,14 → 84723,14
"../compile.h"
<stdlib.h>
 
1423173191 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/texture_png.cpp
1453774255 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"
<stdlib.h>
<png.h>
 
1423174432 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/texture_tiff.cpp
1453774197 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/loader/texture_tiff.cpp
"texture_tiff.h"
"../driver/texture.h"
"../compile.h"
84746,11 → 84746,11
<unistd.h>
<chrono>
 
1424960871 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/node/billboard/billboard.cpp
1453774429 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/node/billboard/billboard.cpp
"../engine.h"
"billboard.h"
 
1424960884 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/node/billboard/sprite.cpp
1453774671 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/node/billboard/sprite.cpp
"../engine.h"
"sprite.h"
 
84977,20 → 84977,20
"frustum.h"
<math.h>
 
1422762537 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/node/engine.cpp
1453774013 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/node/engine.cpp
"engine.h"
<algorithm>
 
1424960944 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/node/node.cpp
1425577494 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/node/node.cpp
"engine.h"
"node.h"
"../library/glm/detail/func_geometric.hpp"
 
1420905154 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/node/real/grid.cpp
1453775423 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/node/real/grid.cpp
"../engine.h"
"grid.h"
 
1424960930 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/node/real/natif.cpp
1453771892 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/node/real/natif.cpp
"../engine.h"
"natif.h"
 
85019,13 → 85019,26
1420770430 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/reference.cpp
"reference.h"
 
1423171321 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/video/audio.cpp
1453712637 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/video/audio.cpp
"audio.h"
<climits>
<iostream>
 
1423260374 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/video/video.cpp
1453712531 source:/mnt/windows1/Development/Project/Xtrem-Coder/Sleek Think/src/sleek/video/video.cpp
"../driver/context.h"
"video.h"
<theora/TheoraDataSource.h>
 
1449260874 /usr/include/libpng16/png.h
"pnglibconf.h"
"pngconf.h"
 
1449260874 /usr/include/libpng16/pnglibconf.h
 
1449260874 /usr/include/libpng16/pngconf.h
<limits.h>
<stddef.h>
<stdio.h>
<setjmp.h>
<time.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/GameEngine.cpp
35,52 → 35,13
mat->setMode(driver::rmd_polygon);
mat->setShadeModel(driver::rsd_flat);
mat->setFaceCulling(driver::rfc_off);
mat->setMaterialRender(driver::rmt_solid | driver::rmt_lighting);
mat->setMaterialRender(driver::rmt_solid);
// mat->setMaterialRender(driver::rmt_solid | driver::rmt_lighting);
mat->setTexture(0, crate->getIdentifier().get());
mat->setTexture(1, bundul->getIdentifier().get());
mat->setPointSize(1.f);
// mat->setShader(createShader());
 
// shader creation sample
{
auto shade = core->getContext()->createShader();
 
// only need fragment shader
shade->attacheShader(driver::shd_frag);
 
// used to get information from material (like texture binding) by callback
shade->setLinkToMaterial(mat.get());
 
shade->setFragmentShader(
"uniform sampler2D T0;\n"
"uniform sampler2D T1;\n"
"uniform float alpha;\n"
"uniform float density;\n"
"void main (void)\n"
"{\n"
" vec4 texel0, texel1;\n"
" //----------------------------------------\n"
" texel0 = texture2D(T0, gl_TexCoord[0].st)*density;\n"
" texel1 = texture2D(T1, gl_TexCoord[1].st)*(1.0 - density);\n"
" //----------------------------------------\n"
" gl_FragColor = (texel0+texel1);\n"
" gl_FragColor *= gl_Color;\n"
" gl_FragColor.a = alpha;\n"
"}\n",
"main"
);
shade->setCallback([](driver::shader *i) noexcept
{
i->setTexture("T0", i->getLinkFromMaterial()->getTexture(0), 0);
i->setTexture("T1", i->getLinkFromMaterial()->getTexture(1), 1);
i->setVariable("alpha", 0.75f);
i->setVariable("density", 0.25f);
});
shade->compileShader();
 
// link
//mat->setShader(shade);
}
 
driver::Geometry geom;
tmp.reset(geom.createCube(
math::vector3df(15),
87,6 → 48,13
math::pixel(0,0,255,255)
));
 
tmp = mom->getLoader()->loadMesh("element/cube.3ds");
 
// core->getContext()->createVBO(tmp.get(), driver::VBO_VERTEX_BUFFER);
// tmp->getIdentifier(driver::VBO_VERTEX_BUFFER)->update();
// core->getContext()->createVBO(tmp.get(), driver::VBO_INDEX_BUFFER);
// tmp->getIdentifier(driver::VBO_INDEX_BUFFER)->update();
 
scene3d::Node *grid = new scene3d::real::Grid(smgr);
smgr->addSceneNode(grid);
 
96,7 → 64,7
{
for(int z = -100;z<150; z += 50)
{
scene3d::Node *cube = new scene3d::real::Natif(smgr);
auto *cube = new scene3d::real::Natif(smgr);
cube->setPosition({x,y,z});
cube->setMaterial(mat);
cube->setMesh(tmp);
114,6 → 82,47
smgr->clear();
}
 
std::shared_ptr<sleek::driver::shader> GameEngine::createShader()
{
auto shade = core->getContext()->createShader();
 
// only need fragment shader
shade->attacheShader(driver::shd_frag);
 
// used to get information from material (like texture binding) by callback
shade->setLinkToMaterial(mat.get());
 
shade->setFragmentShader(
"uniform sampler2D T0;\n"
"uniform sampler2D T1;\n"
"uniform float alpha;\n"
"uniform float density;\n"
"void main (void)\n"
"{\n"
" vec4 texel0, texel1;\n"
" //----------------------------------------\n"
" texel0 = texture2D(T0, gl_TexCoord[0].st)*density;\n"
" texel1 = texture2D(T1, gl_TexCoord[1].st)*(1.0 - density);\n"
" //----------------------------------------\n"
" gl_FragColor = (texel0+texel1);\n"
" gl_FragColor *= gl_Color;\n"
" gl_FragColor.a = alpha;\n"
"}\n",
"main"
);
shade->setCallback([](driver::shader *i) noexcept
{
i->setTexture("T0", i->getLinkFromMaterial()->getTexture(0), 0);
i->setTexture("T1", i->getLinkFromMaterial()->getTexture(1), 1);
i->setVariable("alpha", 0.75f);
i->setVariable("density", 0.25f);
});
shade->compileShader();
 
return shade;
}
 
 
bool GameEngine::manage(sleek::device::input *a) noexcept
{
if(a->type == EVENT_KEY_UP)
/src/app/GameEngine.h
13,6 → 13,8
GameEngine(GameCore*) noexcept;
virtual ~GameEngine() noexcept;
 
std::shared_ptr<sleek::driver::shader> createShader();
 
virtual bool manage(sleek::device::input*) noexcept;
 
virtual void render() noexcept;
/src/app/GameMenu.cpp
102,17 → 102,17
 
void GameMenu::render() noexcept
{
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)
);
}
// 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)
// );
// }
}
}
/src/sleek/compile.h
20,8 → 20,8
#define texture_loader_png_support
#define texture_loader_tiff_support
 
//#define video_reader_support
//#define video_reader_audio_support
#define video_reader_support
#define video_reader_audio_support
 
#define reserved_texture 4
#define gui_frame_userdata 2
/src/sleek/driver/driver.cpp
6,7 → 6,7
namespace driver
{
driver::driver(std::shared_ptr<device::Device> dev, std::shared_ptr<context> c) noexcept
: src(dev), ctx(c), mat(nullptr)
: src(dev), ctx(c), mat(std::make_shared<material>())
{
}
 
/src/sleek/driver/ogl3/ogl_context.cpp
88,8 → 88,6
}
else printf("GL_EXT_texture3D: No\n");
 
 
 
printf("=========================================================================\n");
}
 
284,6 → 282,9
glStencilFunc(GL_ALWAYS, 0x0, 0x4);
glStencilMask(0x4);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
glEnable(GL_TEXTURE_2D);
glActiveTexture(GL_TEXTURE0_ARB);
glColor4ub(255,255,255,255);
}
 
void ogl_context::end() noexcept
/src/sleek/driver/ogl3/ogl_driver.cpp
40,7 → 40,7
glEnd();
glEndList();
 
setActiveMaterial(std::make_shared<material>());
setActiveMaterial(mat);
}
 
ogl_driver::~ogl_driver() noexcept
77,6 → 77,7
glPushMatrix();
if(mat && mat->effect)
mat->effect->update();
glColor4ub(255,255,255,255);
}
 
void ogl_driver::ObjectRenderEnd() const noexcept
482,11 → 483,17
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
 
if(m->getIdentifier(VBO_VERTEX_BUFFER))
m->getIdentifier(VBO_VERTEX_BUFFER)->unbind();
 
ObjectRenderEnd();
}
 
void ogl_driver::setActiveMaterial(std::shared_ptr<material> i) noexcept
{
static void(*_glState[2])(GLenum) = {&glDisable, &glEnable};
 
if(mat)
{
if(mat->effect)
503,66 → 510,41
glDisable(GL_BLEND);
}
 
_glState[bool(i.get())](GL_BLEND);
 
if(i)
{
_glState[bool(i->ant & ral_polygone)](GL_POLYGON_SMOOTH);
_glState[bool(i->ant & ral_line)](GL_LINE_SMOOTH);
_glState[bool(i->mat & rmt_solid)](GL_DEPTH_TEST);
_glState[bool(i->mat & rmt_lighting)](GL_LIGHTING);
_glState[bool(i->mat & rmt_fog)](GL_FOG);
_glState[bool(i->fac != rfc_off)](GL_CULL_FACE);
 
glShadeModel(i->shd & rsd_flat ? GL_FLAT : GL_SMOOTH);
glPointSize(i->psize);
glLineWidth(i->psize);
 
glShadeModel(i->shd & rsd_flat ? GL_FLAT : GL_SMOOTH);
 
if(i->ant & ral_polygone)
glEnable(GL_POLYGON_SMOOTH);
else glDisable(GL_POLYGON_SMOOTH);
 
if(i->ant & ral_line)
glEnable(GL_LINE_SMOOTH);
else glDisable(GL_LINE_SMOOTH);
 
/////////////////////////////////////////
 
if(i->fac & rfc_back && !(i->fac & rfc_front))
glCullFace(GL_BACK);
static GLenum _cull[] = {
GL_NONE, GL_BACK,
GL_FRONT, 0,
GL_FRONT_AND_BACK
};
 
if(i->fac & rfc_front && !(i->fac & rfc_back))
glCullFace(GL_FRONT);
glCullFace(_cull[i->fac]);
 
if(i->fac & rfc_front && i->fac & rfc_back)
glCullFace(GL_FRONT_AND_BACK);
 
if(i->fac & rfc_off)
glDisable(GL_CULL_FACE);
else glEnable(GL_CULL_FACE);
 
/////////////////////////////////////////
 
if(i->mat & rmt_solid)
glEnable(GL_DEPTH_TEST);
else glDisable(GL_DEPTH_TEST);
 
if(i->mat & rmt_lighting)
glEnable(GL_LIGHTING);
else glDisable(GL_LIGHTING);
 
if(i->mat & rmt_fog)
glEnable(GL_FOG);
else glDisable(GL_FOG);
 
/////////////////////////////////////////
 
glEnable(GL_BLEND);
 
if(i->mat & rmt_add)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
else if(i->mat & rmt_add)
glBlendFunc(GL_ONE, GL_ONE);
 
else if(i->mat & rmt_solid)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
else if(i->mat & rmt_sub)
glBlendFunc(GL_ONE_MINUS_SRC_COLOR, GL_ZERO);
else glBlendFunc(GL_ONE, GL_ZERO);
 
else
glBlendFunc(GL_ONE, GL_ZERO);
 
/////////////////////////////////////////
 
if(i->effect)
576,11 → 558,7
if(i->Texture[stage])
i->Texture[stage]->bind();
 
glTexEnvf(
GL_TEXTURE_ENV,
GL_COMBINE_RGB_EXT,
GL_ADD
);
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD);
}
}
}
/src/sleek/driver/ogl3/ogl_texture.cpp
56,7 → 56,9
void ogl_texture<false>::update() noexcept
{
texture *tmp = static_cast<texture*>(owner);
glBindTexture(GL_TEXTURE_2D, gl);
glEnable(GL_TEXTURE_2D);
glActiveTexture(GL_TEXTURE0_ARB);
bind();
glTexImage2D(
GL_TEXTURE_2D, 0, tmp->getFormat(),
tmp->getOriginalSize().x, tmp->getOriginalSize().y, 0,
/src/sleek/driver/rtype.h
37,9 → 37,9
};
enum render_face_culling
{
rfc_off = 0x001,
rfc_front = 0x002,
rfc_back = 0x004
rfc_off = 0x000,
rfc_front = 0x001,
rfc_back = 0x002
};
}
}
/src/sleek/gui/interface.cpp
217,9 → 217,11
 
void interface::render() noexcept
{
mom->beginTo2D();
for(u32 i = 0; i<gui.size(); ++i)
gui[i]->render();
cr->render();
mom->endFrom2D();
}
}
}
/src/sleek/gui/theme.cpp
52,8 → 52,7
void theme::drawWindowMain(window *i) noexcept
{
mom->getDrawManager()->setActiveMaterial(solid);
i->isActive ? mom->getDrawManager()->drawCube(i->box, {0, 0, 0}, color[3]) :
mom->getDrawManager()->drawCube(i->box, {0, 0, 0}, color[2]);
mom->getDrawManager()->drawCube(i->box, {0, 0, 0}, color[2 + i->isActive]);
}
 
void theme::drawWindowMainHovored(window *i) noexcept
70,8 → 69,7
void theme::drawWindowDecoration(window *i) noexcept
{
mom->getDrawManager()->setActiveMaterial(line);
i->isActive ? mom->getDrawManager()->drawCube(i->box, {0, 0, 0}, color[7]) :
mom->getDrawManager()->drawCube(i->box, {0, 0, 0}, color[1]);
mom->getDrawManager()->drawCube(i->box, {0, 0, 0}, color[1 + i->isActive*6]);
 
// title s├ęparator
 
82,8 → 80,7
b.y = a.y;
b.x -= 1;
 
i->isActive ? mom->getDrawManager()->drawLine(a, b, color[7]) :
mom->getDrawManager()->drawLine(a, b, color[1]);
mom->getDrawManager()->drawLine(a, b, color[1 + i->isActive*6]);
}
 
void theme::drawWindowDecorationHovored(window *i) noexcept
/src/sleek/loader/loader.cpp
69,24 → 69,24
bool loader::writeMesh(std::shared_ptr<driver::MeshBuffer> data, const std::string &filename) const noexcept
{
if(!fs || !data)
return nullptr;
return false;
 
for(auto e : mesh)
if(e->match(filename))
return e->write(fs.get(), data.get(), filename);
 
return nullptr;
return false;
}
bool loader::writeTexture(std::shared_ptr<driver::texture> data, const std::string &filename) const noexcept
{
if(!fs || !data)
return nullptr;
return false;
 
for(auto e : texture)
if(e->match(filename))
return e->write(fs.get(), data.get(), filename);
 
return nullptr;
return false;
}
}
}
/src/sleek/loader/mesh_txt.cpp
10,36 → 10,18
std::shared_ptr<driver::MeshBuffer> meshloader_txt::read(io::filesystem *fs, const std::string &file) const noexcept
{
#ifdef mesh_loader_txt_support
int nvert;
std::string oneline;
float rx, ry, rz;
int nvert;
std::string oneline;
float rx, ry, rz;
 
for(int i = 0; i<255; ++i)
oneline += '\0';
for(int i = 0; i<255; ++i)
oneline += '\0';
 
auto in = fs->read(file.c_str());
if(!in){ 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>();
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.c_str(), "Vertices: %d\n", &nvert);
tmp->vertices.resize(nvert);
 
for(int i=0;i<nvert;i++)
{
do
{
in->read(const_cast<char*>(oneline.c_str()), 255);
48,19 → 30,37
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.c_str(), "Vertices: %d\n", &nvert);
tmp->vertices.resize(nvert);
 
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);
for(int i=0;i<nvert;i++)
{
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);
 
driver::index<3> in;
in.vertex[0] = i+0;
in.vertex[1] = i+1;
in.vertex[2] = i+2;
tmp->indices.push_back(in);
}
driver::index<3> in;
in.vertex[0] = i+0;
in.vertex[1] = i+1;
in.vertex[2] = i+2;
tmp->indices.push_back(in);
}
 
return tmp;
return tmp;
#else
return nullptr;
#endif
69,28 → 69,28
bool meshloader_txt::write(io::filesystem *fs, driver::MeshBuffer *m, const std::string &file) const noexcept
{
#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; }
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());
printf("Write mesh: \"%s\"\n", file.c_str());
 
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)
{
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);
std::string data = "Vertices: ";
data += std::to_string(m->vertices.size());
data += '\n';
out->write(data.c_str(), data.size());
}
 
return true;
for(u32 i =0; i<m->vertices.size(); ++i)
{
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
/src/sleek/loader/texture_png.cpp
1,8 → 1,12
#include "texture_png.h"
#include "../driver/texture.h"
#include "../compile.h"
#include "libpng/png.h"
#include "../compile.h"
#include <stdlib.h>
#include <png.h>
 
extern "C" {
void* memccpy(void *dest, const void *src, int c, size_t n);
}
 
namespace sleek
{
180,6 → 184,9
 
bool textureloader_png::match(const std::string &filename) const noexcept
{
/**
* TODO
*/
return filename.substr(filename.find_last_of('.')+1, 3) == "png";
}
}
/src/sleek/loader/texture_tiff.cpp
49,37 → 49,43
std::shared_ptr<driver::texture> textureloader_tiff::read(io::filesystem *fs, const std::string &filename) const noexcept
{
#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);
auto in = fs->read(filename);
 
if(!tif)
return nullptr;
TIFF* tif = TIFFClientOpen(
"File", "r", (thandle_t)in.get(),
tiff_Read, nullptr, tiff_Seek,
tiff_Close, tiff_Size,
tiff_Map, tiff_Unmap
);
 
u32 w, h;
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w);
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h);
if(!tif)
return nullptr;
 
auto img = std::make_shared<driver::texture>(math::vector2di(w, h));
u32 w, h;
TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w);
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h);
 
//bool succ = TIFFReadRGBAImage(tif, w, h, (uint32*)img->getBuffer(), 0);
bool succ = TIFFReadRGBAImageOriented(tif, w, h, (uint32*)img->getBuffer(), ORIENTATION_TOPLEFT, 0);
TIFFClose(tif);
auto img = std::make_shared<driver::texture>(math::vector2di(w, h));
 
if(!succ)
return nullptr;
//bool succ = TIFFReadRGBAImage(tif, w, h, (uint32*)img->getBuffer(), 0);
bool succ = TIFFReadRGBAImageOriented(tif, w, h, (uint32*)img->getBuffer(), ORIENTATION_TOPLEFT, 0);
TIFFClose(tif);
 
//swap red and blue channels
int size = w*h;
unsigned char* cdata = img->getBuffer();
if(!succ)
return nullptr;
 
for(int i=0; i<size; i++)
{
unsigned char tmp = cdata[i*4];
cdata[i*4] = cdata[i*4+2];
cdata[i*4+2] = tmp;
}
//swap red and blue channels
int size = w*h;
unsigned char* cdata = img->getBuffer();
 
return img;
for(int i=0; i<size; i++)
{
unsigned char tmp = cdata[i*4];
cdata[i*4] = cdata[i*4+2];
cdata[i*4+2] = tmp;
}
 
return img;
#else
return nullptr;
#endif
/src/sleek/node/billboard/billboard.cpp
21,7 → 21,7
Node::render();
 
//if(mat->Texture[0])
// smgr->getDrawManager()->drawTextureCenter(mat->Texture[0].get(), pos, rot);
// smgr->getDrawManager()->drawTextureCenter(mat->Texture[0].get(), pos, rot);
}
}
}
/src/sleek/node/billboard/sprite.cpp
7,13 → 7,13
{
namespace billboard
{
Sprite::Sprite(engine *smgr) noexcept : Node(smgr)
Sprite::Sprite(engine *smgr) noexcept : Billboard(smgr)
{
current = 0;
timespec = 100;
}
 
Sprite::Sprite(engine*, std::vector<driver::texture*> i) noexcept : Node(smgr)
Sprite::Sprite(engine*, std::vector<driver::texture*> i) noexcept : Billboard(smgr)
{
timespec = 100;
current = 0;
62,11 → 62,10
if(time_stamp.getTimeMsec() > timespec)
{
current += time_stamp.getTimeMsec()/timespec; // sync ( ex: time_stamp = 500, timespec = 100; 500/100 = 5; frame += 5 so frame skipped = 5
if(current >= anim.size()) current = 0;
// tex = anim[current];
mat->setTexture(0, anim[current % anim.size()]->getIdentifier().get());
time_stamp.reset();
}
Node::render();
Billboard::render();
}
}
}
/src/sleek/node/billboard/sprite.h
1,7 → 1,7
#ifndef SPRITE
#define SPRITE
 
#include "../node.h"
#include "billboard.h"
#include "../math/timer.h"
 
namespace sleek
10,7 → 10,7
{
namespace billboard
{
class Sprite : public Node
class Sprite : public Billboard
{
public:
Sprite(engine*) noexcept;
/src/sleek/node/engine.cpp
9,7 → 9,7
: screen(s), mom(d)
{
cm = new camera::Camera(screen);
//setFog(100.f, 1000.f, 0.35f, texture::pixel(35,35,35,255));
// setFog(100.f, 1000.f, 0.35f, math::pixel(35,35,35,255));
}
 
engine::~engine() noexcept
49,14 → 49,12
 
void engine::render() noexcept
{
std::sort(nd.begin(), nd.end());
cm->manage(screen->getCurrentEvent());
cm->render();
for(register u32 i = 0; i<nd.size(); ++i)
{
Node *tmp = nd[i];
tmp->render();
}
 
std::sort(nd.begin(), nd.end());
for(auto &it : nd)
it->render();
}
 
void engine::enableDebugDraw(bool a) noexcept
/src/sleek/node/node.cpp
18,11 → 18,6
{
}
 
void Node::setMesh(std::shared_ptr<driver::MeshBuffer> i) noexcept
{
mesh = i;
}
 
void Node::setMaterial(std::shared_ptr<driver::material> i) noexcept
{
mat = i;
63,11 → 58,6
return mat;
}
 
std::shared_ptr<driver::MeshBuffer> Node::getMesh() const noexcept
{
return mesh;
}
 
bool Node::operator < (Node *other)
{
if(other->getMaterial()->mat == driver::rmt_solid)
/src/sleek/node/node.h
26,7 → 26,6
virtual void setRotation(const math::vector3df&) noexcept;
virtual void setScale(const math::vector3df&) noexcept;
virtual void setMaterial(std::shared_ptr<driver::material>) noexcept;
virtual void setMesh(std::shared_ptr<driver::MeshBuffer>) noexcept;
 
virtual math::vector3df getPosition() const noexcept;
virtual math::vector3df getRotation() const noexcept;
33,7 → 32,6
virtual math::vector3df getScale() const noexcept;
 
virtual std::shared_ptr<driver::material> getMaterial() noexcept;
virtual std::shared_ptr<driver::MeshBuffer> getMesh() const noexcept;
 
virtual bool operator < (Node*);
 
42,7 → 40,6
Node() noexcept {}
engine *smgr;
 
std::shared_ptr<driver::MeshBuffer> mesh;
std::shared_ptr<driver::material> mat;
math::vector3df pos, rot, sca;
};
/src/sleek/node/real/grid.cpp
46,10 → 46,9
 
void Grid::render() noexcept
{
float x, z;
Node::render();
 
for(x = space.getUpperLeft().x; x<space.getLowerRight().x; x += size)
for(float x = space.getUpperLeft().x; x<space.getLowerRight().x; x += size)
smgr->getDrawManager()->drawLine(
math::vector3df(x,0,space.getUpperLeft().y),
math::vector3df(x,0,space.getLowerRight().y),
56,7 → 55,7
color
);
 
for(z = space.getUpperLeft().y; z<space.getLowerRight().y; z += size)
for(float z = space.getUpperLeft().y; z<space.getLowerRight().y; z += size)
smgr->getDrawManager()->drawLine(
math::vector3df(space.getUpperLeft().x,0,z),
math::vector3df(space.getLowerRight().x,0,z),
/src/sleek/node/real/natif.cpp
15,6 → 15,16
{
}
 
void Natif::setMesh(std::shared_ptr<driver::MeshBuffer> i) noexcept
{
mesh = i;
}
 
std::shared_ptr<driver::MeshBuffer> Natif::getMesh() const noexcept
{
return mesh;
}
 
void Natif::render() noexcept
{
Node::render();
/src/sleek/node/real/natif.h
15,7 → 15,12
Natif(engine*) noexcept;
~Natif() noexcept;
 
virtual void setMesh(std::shared_ptr<driver::MeshBuffer>) noexcept;
virtual std::shared_ptr<driver::MeshBuffer> getMesh() const noexcept;
 
virtual void render() noexcept;
private:
std::shared_ptr<driver::MeshBuffer> mesh;
};
}
}
/src/sleek/video/audio.cpp
18,10 → 18,10
CAudioInterfaceOpenAL::CAudioInterfaceOpenAL(TheoraVideoClip* owner, int nChannels, int freq) noexcept
: TheoraAudioInterface(owner, nChannels, freq), mBuffSize(0), mNumProcessedSamples(0), mTimeOffset(0), mNumPlayedSamples(0), mTempBuffer(0)
{
mMaxBuffSize = freq * mNumChannels * 2;
mTempBuffer = new short[mMaxBuffSize];
alGenSources(1, &mSource);
owner->setTimer(this);
mMaxBuffSize = freq * mNumChannels * 2;
mTempBuffer = new short[mMaxBuffSize];
alGenSources(1, &mSource);
owner->setTimer(this);
}
 
void CAudioInterfaceOpenAL::destroy() noexcept
/src/sleek/video/video.cpp
1,6 → 1,11
#include "../driver/context.h"
#include "video.h"
 
extern "C"
{
void * memcpy ( void * destination, const void * source, size_t num );
}
 
#ifdef video_reader_support
 
#include <theora/TheoraDataSource.h>
10,7 → 15,7
namespace video
{
CVideoMaster::CVideoMaster(driver::context *cx, bool readAudio, u32 workerThreads) noexcept
: mTimer(new math::timer), context(cx), mVmgr(0), mAIF(0)
: mTimer(new math::timer), context(cx), mVmgr(0)
{
mVmgr = new TheoraVideoManager(std::max(workerThreads, 1u));
#ifdef video_reader_audio_support
19,6 → 24,7
mAIF = new CAudioInterfaceFactoryOpenAL();
mVmgr->setAudioInterfaceFactory(mAIF);
}
else mAIF = nullptr;
#endif
}