Index: trunk/src/gl/image.cc
===================================================================
--- trunk/src/gl/image.cc	(revision 70)
+++ 	(revision )
@@ -1,57 +1,0 @@
-// Copyright (C) 2011 Kornel Kisielewicz
-// This file is part of NV Libraries.
-// For conditions of distribution and use, see copyright notice in nv.hh
-
-#include "nv/gl/image.hh"
-
-#include <cstring>
-
-using namespace nv;
-
-image::image( glm::ivec2 size, size_t depth )
-	: m_size( size ), m_depth( depth ), m_data( nullptr )
-{
-	m_data = new uint8[ m_size.x * m_size.y * m_depth ];
-}
-
-image::image( glm::ivec2 size, size_t depth, const uint8 * data, bool reversed )
-	: m_size( size ), m_depth( depth ), m_data( nullptr )
-{
-	m_data = new uint8[ m_size.x * m_size.y * m_depth ];
-
-	if ( reversed )
-	{
-		for( int i = 0; i < size.y; ++i )
-		{
-			memcpy( m_data + size.x * ( size.y - i - 1) * m_depth, data + i * size.x * m_depth, m_size.x * m_depth );
-		}
-
-	}
-	else 
-	{
-		memcpy( m_data, data, m_size.x * m_size.y * m_depth );
-	}
-}
-
-void image::fill( uint8 value )
-{
-	memset( m_data, value, m_size.x * m_size.y * m_depth );
-}
-
-void image::set_region( region r, const uint8 * data, size_t stride )
-{
-	if ( stride == 0 ) stride = r.size.x;
-
-	for( int i = 0; i < r.size.y; ++i )
- 	{
-		memcpy( m_data+((r.pos.y+i)*m_size.x + r.pos.x ) * m_depth, 
-			data + (i*stride), r.size.x * m_depth );
-	}
-}
-
-image::~image()
-{
-	delete[] m_data;
-}
-
-
Index: trunk/src/gl/texture_atlas.cc
===================================================================
--- trunk/src/gl/texture_atlas.cc	(revision 70)
+++ 	(revision )
@@ -1,133 +1,0 @@
-// Copyright (C) 2012-2013 ChaosForge / Kornel Kisielewicz
-// http://chaosforge.org/
-//
-// This file is part of NV Libraries.
-// For conditions of distribution and use, see copyright notice in nv.hh
-
-#include "nv/gl/texture_atlas.hh"
-
-#include "nv/logging.hh"
-#include <iostream>
-
-using namespace nv;
-
-texture_atlas::texture_atlas( glm::ivec2 size, size_t depth )
-	: image( size, depth ), m_used( 0 )
-{
-	m_nodes.push_back( glm::ivec3( 1, 1, m_size.x - 2 ) );
-	fill( 0 );
-}
-
-region texture_atlas::get_region( glm::ivec2 size )
-{
-	region r ( glm::ivec2(0,0), size );
-
-	int best_height = INT_MAX;
-	int best_index  = -1;
-	int best_width  = INT_MAX;
-
-	for( size_t i=0; i < m_nodes.size(); ++i )
-	{
-		int y = fit( i, size );
-		if( y >= 0 )
-		{
-			glm::ivec3 node = m_nodes[ i ];
-			if ( ( (y + size.y) < best_height ) ||
-				( ((y + size.y) == best_height) && (node.z < best_width)) )
-			{
-				best_height = y + size.y;
-				best_index = i;
-				best_width = node.z;
-				r.pos.x = node.x;
-				r.pos.y = y;
-			}
-		}
-	}
-   
-	if ( best_index == -1 )
-	{
-		return region( glm::ivec2( -1, -1 ), glm::ivec2( 0, 0 ) );
-	}
-
-	m_nodes.insert( m_nodes.begin() + best_index, glm::ivec3( r.pos.x, r.pos.y + size.y, size.x ) );
-
-	for( size_t i = best_index+1; i < m_nodes.size(); ++i )
-	{
-		glm::ivec3 node = m_nodes[ i ];
-		glm::ivec3 prev = m_nodes[ i-1 ];
-
-		if (node.x < (prev.x + prev.z) )
-		{
-			int shrink = prev.x + prev.z - node.x;
-			m_nodes[ i ].x += shrink;
-			m_nodes[ i ].z -= shrink;
-
-			if (m_nodes[ i ].z <= 0)
-			{
-				m_nodes.erase( m_nodes.begin() + i );
-				--i;
-			}
-			else
-			{
-				break;
-			}
-		}
-		else
-		{
-			break;
-		}
-	}
-	merge();
-	m_used += size.x * size.y;
-	return r;
-}
-
-int texture_atlas::fit( size_t index, glm::ivec2 size )
-{
-	glm::ivec3 node = m_nodes[ index ];
-
-	if ( (  node.x + size.x ) > ( m_size.x - 1 ) ) 
-	{
-		return -1;
-	}
-
-	int y     = node.y;
-	int wleft = size.x;
-
-	while( wleft > 0 )
-	{
-		node = m_nodes[ index ];
-		if( node.y > y )
-		{
-			y = node.y;
-		}
-		if( (y + size.y) > (m_size.y-1) )
-		{
-			return -1;
-		}
-		wleft -= node.z;
-		++index;
-	}
-	return y;
-}
-
-void texture_atlas::merge()
-{
-	for( size_t i=0; i < m_nodes.size()-1; ++i )
-    {
-		if( m_nodes[ i ].y == m_nodes[ i+1 ].y )
-		{
-			m_nodes[ i ].z += m_nodes[ i+1 ].z;
-            m_nodes.erase( m_nodes.begin()+i+1 );
-			--i;
-		}
-    }
-}
-
-void texture_atlas::clear()
-{
-	m_nodes.clear();
-	m_used = 0;
-	m_nodes.push_back( glm::ivec3( 1, 1, m_size.x - 2 ) );
-	fill( 0 );
-}
Index: trunk/src/gl/texture_font.cc
===================================================================
--- trunk/src/gl/texture_font.cc	(revision 70)
+++ 	(revision )
@@ -1,160 +1,0 @@
-// Copyright (C) 2012-2013 ChaosForge / Kornel Kisielewicz
-// http://chaosforge.org/
-//
-// This file is part of NV Libraries.
-// For conditions of distribution and use, see copyright notice in nv.hh
-#include <sstream>
-#include <stdexcept>
-
-#include "nv/gl/texture_font.hh"
-#include "nv/lib/freetype2.hh"
-
-using namespace nv;
-
-texture_glyph::texture_glyph()
-	: charcode(0), size(0,0), offset(0,0), advance(0.f,0.f), tl(0.f,0.f), br(0.f,0.f)
-{
-}
-
-float texture_glyph::get_kerning( const uint16 charcode )
-{
-	auto i = kerning.find( charcode );
-	return i != kerning.end() ? i->second : 0.0f;
-}
-
-texture_font::texture_font( texture_atlas* atlas, const char * filename, float size )
-	: m_atlas( atlas ), m_filename(filename), m_size( size ), 
-	m_height(0), m_linegap(0), m_ascender(0), m_descender(0),
-	m_hinting( true ), m_filtering( true ), m_rlibrary( nullptr ), m_rface( nullptr )
-{
-	size_t hres = 64;
-	FT_Error error;
-	FT_Matrix matrix = { 
-		(int)((1.0/hres) * 0x10000L),
-		(int)((0.0)      * 0x10000L),
-		(int)((0.0)      * 0x10000L),
-		(int)((1.0)      * 0x10000L) 
-	};
-
-	m_lcd_weights[0] = 0x10;
-	m_lcd_weights[1] = 0x40;
-	m_lcd_weights[2] = 0x70;
-	m_lcd_weights[3] = 0x40;
-	m_lcd_weights[4] = 0x10;
-	 
-	error = FT_Init_FreeType( (FT_Library*)(&m_rlibrary) );
-	if ( error ) NV_THROW( std::runtime_error, "FT_Error" );
-
-	error = FT_New_Face( (FT_Library)(m_rlibrary), filename, 0, (FT_Face*)(&m_rface) );
-	if ( error ) NV_THROW( std::runtime_error, "FT_Error" );
-
-	error = FT_Set_Char_Size( (FT_Face)(m_rface), (int)(size*64), 0, 72*64, 72 ); 
-	if ( error ) NV_THROW( std::runtime_error, "FT_Error" );
-
-    FT_Set_Transform( (FT_Face)(m_rface), &matrix, NULL );
-
-    FT_Size_Metrics metrics = ((FT_Face)(m_rface))->size->metrics; 
-    m_ascender  = (float)(metrics.ascender >> 6) / 100.0f;
-    m_descender = (float)(metrics.descender >> 6) / 100.0f;
-    m_height    = (float)(metrics.height >> 6) / 100.0f;
-    m_linegap   = m_height - m_ascender + m_descender; 
-}
-
-const texture_glyph* texture_font::get_glyph( uint16 charcode ) const
-{
-	auto i = m_glyphs.find( charcode );
-	if ( i == m_glyphs.end() )
-	{
-		return nullptr;
-	}
-	return &(i->second);
-}
-
-bool texture_font::load_glyphs( const std::string& codes )
-{
-	FT_Face face     = (FT_Face)(m_rface);
-	size_t depth     = m_atlas->get_depth();
-	glm::ivec2 asize = m_atlas->get_size();
-	FT_Int32 flags = 0; 
-	flags |= FT_LOAD_RENDER; 
-	if( !m_hinting )
-	{
-		flags |= FT_LOAD_NO_HINTING | FT_LOAD_NO_AUTOHINT;
-	}
-	else
-	{
-		flags |= FT_LOAD_FORCE_AUTOHINT;
-	} 
-
-	if( m_atlas->get_depth() == 3 )
-	{
-		FT_Library_SetLcdFilter( (FT_Library)(m_rlibrary), FT_LCD_FILTER_LIGHT );
-		flags |= FT_LOAD_TARGET_LCD;
-		if ( m_filtering )
-		{
-			FT_Library_SetLcdFilterWeights( (FT_Library)(m_rlibrary), m_lcd_weights );
-		}
-	} 
-
-	for ( char c : codes )
-	{
-		FT_UInt glyph_index = FT_Get_Char_Index( face, c ); 
-		FT_Error error = FT_Load_Glyph( face, glyph_index, flags ); 
-		if ( error )
-		{
-			std::stringstream error_msg;
-			error_msg << "FT_Error while loading glyphs, error: "
-				<< error << " code: " << c; 
-			NV_THROW( std::runtime_error, error_msg.str().c_str() );
-		}
-
-		FT_GlyphSlot slot   = face->glyph;
-		FT_Bitmap ft_bitmap = slot->bitmap;
-		int ft_bitmap_width = slot->bitmap.width;
-		int ft_bitmap_rows  = slot->bitmap.rows;
-		int ft_glyph_top    = slot->bitmap_top;
-		int ft_glyph_left   = slot->bitmap_left;
-
-		glm::ivec2 gsize( ft_bitmap_width/depth + 1, ft_bitmap_rows + 1 ); 
-		region r = m_atlas->get_region( gsize );
-		if ( r.pos.x < 0 ) 
-		{
-			std::stringstream error_msg;
-			error_msg << "Atlas full while loading glyphs, "
-				<< "r.pos.x: " << r.pos.x << " code: "
-				<< c; 
-			NV_THROW( std::runtime_error, error_msg.str().c_str() );
-		}
-		r.size.x -= 1;
-		r.size.y -= 1;
-		m_atlas->set_region( r, ft_bitmap.buffer, ft_bitmap.pitch );
-
-		m_glyphs[ c ] = texture_glyph();
-		texture_glyph* g = &(m_glyphs.find( c )->second);
-
-		g->charcode = c;
-		g->size     = gsize;
-		g->offset   = glm::ivec2( ft_glyph_left, ft_glyph_top );
-		g->tl       = glm::vec2( r.pos.x/(float)asize.x, r.pos.y/(float)asize.y );
-		g->br       = glm::vec2( ( r.pos.x + gsize.x )/(float)asize.x, (r.pos.y + gsize.y )/(float)asize.y );
-
-		// Discard hinting to get advance
-		FT_Load_Glyph( face, glyph_index, FT_LOAD_RENDER | FT_LOAD_NO_HINTING);
-		slot = face->glyph;
-		g->advance = glm::ivec2( slot->advance.x/64.0, slot->advance.y/64.0 );
-	}
-	generate_kerning();
-	return true;
-}
-
-texture_font::~texture_font()
-{
-	if ( m_rface )    FT_Done_Face( (FT_Face)(m_rface) );
-	if ( m_rlibrary ) FT_Done_FreeType( (FT_Library)(m_rlibrary) );
-}
-
-void texture_font::generate_kerning()
-{
-
-}
-
