16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 03:29:19 +02:00

merge, with tmj renderer

This commit is contained in:
milek7
2017-08-18 00:56:05 +02:00
85 changed files with 6815 additions and 3770 deletions

View File

@@ -31,7 +31,7 @@ struct opengl_texture {
// methods
void
load();
resource_state
bool
bind();
bool
create();
@@ -78,6 +78,7 @@ private:
};
typedef int texture_handle;
int const null_handle = 0;
class texture_manager {
@@ -85,12 +86,17 @@ public:
texture_manager();
~texture_manager() { delete_textures(); }
texture_handle
create( std::string Filename, std::string const &Dir, int const Filter = -1, bool const Loadnow = true );
void
bind( texture_handle const Texture );
assign_units( GLint const Helper, GLint const Shadows, GLint const Normals, GLint const Diffuse );
void
unit( GLint const Textureunit );
texture_handle
create( std::string Filename, bool const Loadnow = true );
// binds specified texture to specified texture unit
void
bind( std::size_t const Unit, texture_handle const Texture );
opengl_texture &
texture( texture_handle const Texture ) { return *(m_textures[ Texture ].first); }
texture( texture_handle const Texture ) const { return *(m_textures[ Texture ].first); }
// performs a resource sweep
void
update();
@@ -108,6 +114,11 @@ private:
typedef std::unordered_map<std::string, std::size_t> index_map;
struct texture_unit {
GLint unit { 0 };
texture_handle texture { null_handle }; // current (most recently bound) texture
};
// methods:
// checks whether specified texture is in the texture bank. returns texture id, or npos.
texture_handle
@@ -123,7 +134,8 @@ private:
texturetimepointpair_sequence m_textures;
index_map m_texturemappings;
garbage_collector<texturetimepointpair_sequence> m_garbagecollector { m_textures, 600, 60, "texture" };
texture_handle m_activetexture { 0 }; // last i.e. currently bound texture
std::array<texture_unit, 4> m_units;
GLint m_activeunit { 0 };
};
// reduces provided data image to half of original size, using basic 2x2 average
@@ -182,3 +194,5 @@ downsample( std::size_t const Width, std::size_t const Height, char *Imagedata )
}
}
}
//---------------------------------------------------------------------------