Changeset 228


Ignore:
Timestamp:
02/04/14 03:50:28 (11 years ago)
Author:
epyon
Message:
  • various untracked changes
Location:
trunk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/nv/formats/md2_loader.hh

    r224 r228  
    1414#define NV_MD2_LOADER_HH
    1515
     16#include <nv/common.hh>
    1617#include <unordered_map>
    1718#include <vector>
    18 #include <nv/common.hh>
    1919#include <nv/interface/mesh_loader.hh>
    2020
  • trunk/nv/formats/md3_loader.hh

    r224 r228  
    1414#define NV_MD3_LOADER_HH
    1515
     16#include <nv/common.hh>
    1617#include <unordered_map>
    1718#include <vector>
    18 #include <nv/common.hh>
    1919#include <nv/gfx/mesh_data.hh>
    2020#include <nv/interface/mesh_loader.hh>
  • trunk/nv/formats/md5_loader.hh

    r226 r228  
    1414#define NV_MD5_LOADER_HH
    1515
     16#include <nv/common.hh>
    1617#include <unordered_map>
    1718#include <vector>
    18 #include <nv/common.hh>
    1919#include <nv/interface/mesh_loader.hh>
    2020
  • trunk/nv/gfx/image.hh

    r121 r228  
    6969                void fill( uint8 value );
    7070                /**
     71                 * Fills the region with a given value.
     72                 *
     73                 * @arg[in] r : Region to be filled.
     74                 * @arg[in] value : Value to fill.
     75                 */
     76                void fill( region r, uint8 value, int stride = 0 );
     77                /**
    7178                 * Just like fill, but a region can be specified.
    7279                 *
     
    7683                 */
    7784                void set_region( region r, const uint8 * data, int stride = 0 );
     85
     86                /**
     87                 * Just like fill, but a region can be specified. Checks for data depth,
     88                 * and converts if needed.
     89                 *
     90                 * @arg[in] r : Region to be filled.
     91                 * @arg[in] data : Data to fill the region
     92                 */
     93                void set_region( region r, const image_data* idata );
     94
    7895                /**
    7996                 * Default destructor. Deallocates data.
  • trunk/nv/gl/gl_device.hh

    r153 r228  
    2121        public:
    2222                gl_device();
    23                 virtual window* create_window( uint16 width, uint16 height );
     23                virtual window* create_window( uint16 width, uint16 height, bool fullscreen );
    2424                virtual program* create_program( const string& vs_source, const string& fs_source );
    2525                virtual vertex_buffer* create_vertex_buffer( buffer_hint hint, size_t size, const void* source = nullptr );
  • trunk/nv/gl/gl_window.hh

    r171 r228  
    2222        {
    2323        public:
    24                 gl_window( device* dev, uint16 width, uint16 height );
     24                gl_window( device* dev, uint16 width, uint16 height, bool fullscreen = false );
    2525                uint16 get_width() const;
    2626                uint16 get_height() const;
  • trunk/nv/interface/device.hh

    r153 r228  
    2828        {
    2929        public:
    30                 virtual window* create_window( uint16 width, uint16 height ) = 0;
     30                virtual window* create_window( uint16 width, uint16 height, bool fullscreen ) = 0;
    3131                virtual program* create_program( const string& vs_source, const string& fs_source ) = 0;
    3232                virtual vertex_buffer* create_vertex_buffer( buffer_hint hint, size_t size, const void* source = nullptr ) = 0;
  • trunk/nv/lua/lua_state.hh

    r217 r228  
    1212#define NV_LUA_HH
    1313
     14#include <nv/common.hh>
    1415#include <istream>
    1516#include <map>
    16 #include <nv/common.hh>
    1717#include <nv/flags.hh>
    1818#include <nv/types.hh>
     
    141141                                register_native_function( detail::function_wrapper< F, f >, name );
    142142                        }
     143
     144                        template < typename C, typename F, F* f >
     145                        void register_function( const char* name )
     146                        {
     147                                register_native_function( detail::object_method_wrapper< C, F, f >, name );
     148                        }
     149
    143150                protected:
    144151                        bool is_defined( const path& p, bool global );
  • trunk/nv/lua/lua_values.hh

    r213 r228  
    221221                        {
    222222                                typedef typename type_degrade<T>::type degraded;
    223                                 p = pass_traits<degraded>::to( L, -1 );
     223                                p = (T)pass_traits<degraded>::to( L, -1 );
    224224                                detail::pop_and_discard(L, 1);
    225225                        }
     
    229229                                typedef typename type_degrade<T>::type degraded;
    230230                                T ret;
    231                                 ret = pass_traits<degraded>::to( L, -1 );
     231                                ret = (T)pass_traits<degraded>::to( L, -1 );
    232232                                detail::pop_and_discard(L, 1);
    233233                                return ret;
  • trunk/nv/random.hh

    r175 r228  
    88#define NV_RANDOM_HH
    99
     10#include <nv/common.hh>
    1011#include <random>
    11 #include <nv/common.hh>
    1212#include <nv/math.hh>
    1313
  • trunk/src/gfx/image.cc

    r128 r228  
    4848}
    4949
     50void image::fill( region r, uint8 value, int stride )
     51{
     52        if ( stride == 0 ) stride = r.size.x * static_cast<sint32>( m_depth );
     53
     54        sint32 bpos  = (r.pos.y*m_size.x + r.pos.x ) * static_cast<sint32>( m_depth );
     55        sint32 bline = m_size.x*static_cast<sint32>( m_depth );
     56
     57        for( int i = 0; i < r.size.y; ++i )
     58        {
     59                // TODO: test
     60                std::fill( m_data + bpos + bline * i, m_data + bpos + bline * i + stride, value );
     61        }
     62}
     63
     64
    5065void image::set_region( region r, const uint8 * data, int stride )
    5166{
     
    6479}
    6580
     81void image::set_region( region r, const image_data* idata )
     82{
     83        if ( idata->get_depth() == m_depth )
     84        {
     85                set_region( r, idata->get_data() );
     86                return;
     87        }
     88
     89        fill( r, 255 );
     90
     91        sint32 bpos       = (r.pos.y*m_size.x + r.pos.x ) * static_cast<sint32>( m_depth );
     92        sint32 bline      = m_size.x*static_cast<sint32>( m_depth );
     93
     94        const uint8* data = idata->get_data();
     95        sint32 depth      = idata->get_depth();
     96        sint32 dstride    = r.size.x * static_cast<sint32>( depth );
     97
     98        for( int y = 0; y < r.size.y; ++y )
     99        {
     100                sint32 pos = bpos + bline * y;
     101                for( int x = 0; x < r.size.x; ++x )
     102                {
     103                        sint32 xy = pos + x * m_depth;
     104                        for( int e = 0; e < depth; ++e )
     105                        {
     106                                m_data[ xy + e ] = data[ y*dstride + x * depth + e ];
     107                        }
     108                }
     109        }
     110}
     111
     112
    66113image::~image()
    67114{
  • trunk/src/gl/gl_device.cc

    r184 r228  
    1515using namespace nv;
    1616
    17 window* gl_device::create_window( uint16 width, uint16 height )
     17window* gl_device::create_window( uint16 width, uint16 height, bool fullscreen )
    1818{
    19         return new gl_window( this, width, height );
     19        return new gl_window( this, width, height, fullscreen );
    2020}
    2121
  • trunk/src/gl/gl_window.cc

    r184 r228  
    203203
    204204
    205 gl_window::gl_window( device* dev, uint16 width, uint16 height )
     205gl_window::gl_window( device* dev, uint16 width, uint16 height, bool fullscreen )
    206206        : m_device( dev ), m_width( width ), m_height( height ), m_title("NV Engine"), m_handle( nullptr )
    207207{
    208208#if NV_SDL_VERSION == NV_SDL_12
    209209        uint32 flags = SDL_OPENGL;
     210        if (fullscreen) flags |= SDL_FULLSCREEN;
    210211        m_handle = SDL_SetVideoMode( width, height, 32, flags );
    211212#elif NV_SDL_VERSION == NV_SDL_20
    212213        uint32 flags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN;
     214        if (fullscreen) flags |= SDL_FULLSCREEN;
    213215        m_handle = SDL_CreateWindow("Nova Engine", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
    214216                width, height, flags );
  • trunk/src/lua/lua_map_tile.cc

    r221 r228  
    130130                {
    131131                        nv::uint8 c = tile->data[ y * tile->size_x + x ];
    132                         if ( c != 0 ) area->set_cell( coord + nv::ivec2( x, y ), tile->data[ y * tile->size_x + x ] );
     132                        if ( c != 0 ) area->set_cell( coord + nv::ivec2( x, y ), c );
    133133                }
    134134
  • trunk/src/lua/lua_state.cc

    r217 r228  
    234234                for(; lib->func != NULL; lib++)
    235235                {
    236                         lib->func( m_state );
     236                        lua_pushcfunction( m_state, lib->func );
     237                        lua_call(m_state, 0, 1);
     238                        lua_setglobal( m_state, lib->name );
    237239                }
    238240                register_nova( this );
Note: See TracChangeset for help on using the changeset viewer.