- Timestamp:
- 06/15/13 17:47:57 (12 years ago)
- Location:
- trunk
- Files:
-
- 51 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv.lua
r120 r121 12 12 includedirs { os.getenv("GLM_PATH") } 13 13 configuration "gmake" 14 buildoptions "-std=c++0x" 14 if _ACTION == "gmake-clang" then 15 buildoptions { 16 "-std=c++11", 17 "-Weverything", 18 -- obviously we don't care about C++98 compatibility 19 "-Wno-c++98-compat", 20 -- obviously we don't care about C++98 compatibility 21 "-Wno-c++98-compat-pedantic", 22 -- an evil one has to embrace 23 "-Wno-float-equal", 24 -- padding is a non-issue at the moment 25 "-Wno-padded", 26 -- we don't want to list all 128 keys of the key 27 -- enum each time, right? 28 "-Wno-switch-enum", 29 -- yes, we need exit time destructors for libraries 30 "-Wno-exit-time-destructors", 31 -- same here 32 "-Wno-global-constructors", 33 -- no reasonable way to fix this with abstract 34 -- interfaces. 35 "-Wno-weak-vtables" 36 } 37 else 38 buildoptions { "-std=c++0x" } 39 end 40 15 41 configuration "vs*" 16 42 defines { "_SECURE_SCL=0", "_CRT_SECURE_NO_WARNINGS=1" } -
trunk/nv/common.hh
r120 r121 128 128 } 129 129 130 // MSVC and GCC is too stupid to notice fully covered enums, clang 131 // is picky about it 132 #if NV_COMPILER == NV_CLANG 133 #define NV_RETURN_COVERED_DEFAULT( value ) 134 #else 135 #define NV_RETURN_COVERED_DEFAULT( value ) default : return value 136 #endif 137 138 130 139 namespace nv 131 140 { -
trunk/nv/gfx/cached_buffer.hh
r120 r121 12 12 13 13 #include <nv/common.hh> 14 #include <nv/math.hh> 14 15 #include <nv/interface/vertex_buffer.hh> 15 16 … … 109 110 if ( !m_full_update && resized ) 110 111 { 111 m_data.erase( m_data.begin() + offset, m_data.end() );112 m_min = glm::min<int>( m_min, offset );112 m_data.erase( m_data.begin() + (int)offset, m_data.end() ); 113 m_min = nv::min<size_t>( m_min, offset ); 113 114 m_full_update = true; 114 115 } … … 120 121 else if ( updated ) 121 122 { 122 std::copy( bv.cbegin(), bv.cend(), m_data.begin() + offset );123 m_min = glm::min<size_t>( m_min, offset );124 m_max = glm::max<size_t>( m_max, offset + bv.size() );123 std::copy( bv.cbegin(), bv.cend(), m_data.begin() + (int)offset ); 124 m_min = nv::min<size_t>( m_min, offset ); 125 m_max = nv::max<size_t>( m_max, offset + bv.size() ); 125 126 } 126 127 return m_full_update; … … 166 167 { 167 168 m_buffer->bind(); 168 int offset = m_min * value_type_size;169 int size = (m_max-m_min) * value_type_size;169 size_t offset = m_min * value_type_size; 170 size_t size = (m_max-m_min) * value_type_size; 170 171 m_buffer->update( m_data.data() + m_min, offset, size ); 171 172 m_buffer->unbind(); … … 177 178 } 178 179 179 int get_max_size() const180 size_t get_max_size() const 180 181 { 181 182 return m_buffer->get_size() / value_type_size; 182 183 } 183 184 184 int get_size() const185 size_t get_size() const 185 186 { 186 187 return m_data.size(); … … 197 198 } 198 199 private: 199 void create_buffer( int size )200 void create_buffer( size_t size ) 200 201 { 201 202 delete m_buffer; -
trunk/nv/gfx/image.hh
r110 r121 9 9 10 10 #include <nv/common.hh> 11 #include <nv/math.hh> 11 12 #include <nv/interface/image_data.hh> 12 #include <glm/glm.hpp>13 13 14 14 namespace nv … … 19 19 struct region 20 20 { 21 glm::ivec2 pos;22 glm::ivec2 size;21 ivec2 pos; 22 ivec2 size; 23 23 24 24 region() : pos(0,0), size(0,0) {} 25 region( glm::ivec2 pos, glm::ivec2 size ) : pos(pos), size(size) {}25 region( ivec2 apos, ivec2 asize ) : pos(apos), size(asize) {} 26 26 }; 27 27 … … 42 42 * @arg[in] depth : Depth of the image. 43 43 */ 44 image( glm::ivec2 size, size_t depth );44 image( ivec2 size, size_t depth ); 45 45 /** 46 46 * Constructor … … 61 61 * reversed or not. 62 62 */ 63 image( glm::ivec2 size, size_t depth, const uint8 * data, bool reversed = false );63 image( ivec2 size, size_t depth, const uint8 * data, bool reversed = false ); 64 64 /** 65 65 * Fills the image with a given value. … … 75 75 * @arg[in] stride : 76 76 */ 77 void set_region( region r, const uint8 * data, size_t stride = 0 );77 void set_region( region r, const uint8 * data, int stride = 0 ); 78 78 /** 79 79 * Default destructor. Deallocates data. … … 91 91 * @return Returns the size of the image as a vector. 92 92 */ 93 const glm::ivec2 get_size() const { return m_size; }93 ivec2 get_size() const { return m_size; } 94 94 /** 95 95 * Getter for depth. … … 97 97 * @return Returns depth of the image. 98 98 */ 99 constsize_t get_depth() const { return m_depth; }99 size_t get_depth() const { return m_depth; } 100 100 protected: 101 /** Defines the size of the image as a vector. */ 102 glm::ivec2 m_size; 103 /** Deefines the depth of the image. */ 104 size_t m_depth; 105 /** Holder for data. */ 106 uint8* m_data; 101 ivec2 m_size; //!< Defines the size of the image as a vector. 102 size_t m_depth; //!< Defines the depth of the image 103 uint8* m_data; //!< Holder for data 107 104 }; 108 105 -
trunk/nv/gfx/texture_atlas.hh
r96 r121 9 9 10 10 #include <nv/common.hh> 11 #include <nv/math.hh> 11 12 #include <nv/gfx/image.hh> 12 #include <glm/glm.hpp>13 13 #include <vector> 14 14 … … 19 19 { 20 20 public: 21 texture_atlas( glm::ivec2 size, size_t depth );22 region get_region( glm::ivec2 size );21 texture_atlas( ivec2 size, size_t depth ); 22 region get_region( ivec2 size ); 23 23 void clear(); 24 constsize_t get_used() const { return m_used; }24 size_t get_used() const { return m_used; } 25 25 protected: 26 int fit( size_t index, glm::ivec2 size );26 int fit( size_t index, ivec2 size ); 27 27 void merge(); 28 28 private: 29 29 size_t m_used; 30 std::vector< glm::ivec3> m_nodes;30 std::vector<ivec3> m_nodes; 31 31 }; 32 32 -
trunk/nv/gfx/texture_font.hh
r110 r121 10 10 #include <nv/common.hh> 11 11 #include <string> 12 #include <unordered_map> 13 #include <nv/math.hh> 12 14 #include <nv/gfx/texture_atlas.hh> 13 #include <glm/glm.hpp>14 #include <unordered_map>15 15 16 16 namespace nv … … 18 18 struct texture_glyph 19 19 { 20 uint16 charcode; ///< Character code value.21 glm::ivec2 size; ///< Width and height of the glyph.22 glm::ivec2 offset; ///< Offset of the glyph's position from the base line.23 glm::vec2 advance; ///< Cursor advance distance.24 glm::vec2 tl; ///< Top-left of the glyph's bounding box.25 glm::vec2 br; ///< Bottom-right of the glyph's bounding box.26 std::unordered_map< uint16, float > kerning; // /< Kerning space between other characters.20 uint16 charcode;//!< Character code value. 21 ivec2 size; //!< Width and height of the glyph. 22 ivec2 offset; //!< Offset of the glyph's position from the base line. 23 vec2 advance; //!< Cursor advance distance. 24 vec2 tl; //!< Top-left of the glyph's bounding box. 25 vec2 br; //!< Bottom-right of the glyph's bounding box. 26 std::unordered_map< uint16, float > kerning; //!< Kerning space between other characters. 27 27 28 28 /** … … 34 34 *Gets the kerning space between this character and the requested character. 35 35 * 36 *@param charcodeThe character to get the spacing for.36 *@param other The character to get the spacing for. 37 37 *@returns The amount of space for kerning. 38 38 */ 39 float get_kerning( const uint16 charcode);39 float get_kerning( const uint16 other ); 40 40 }; 41 41 … … 46 46 const texture_glyph* get_glyph( uint16 charcode ) const; 47 47 bool load_glyphs( const std::string& codes ); 48 float get_size() const { return m_size; } 48 49 ~texture_font(); 49 50 private: 50 51 void generate_kerning(); 51 52 private: 52 std::unordered_map< uint16, texture_glyph > m_glyphs; ///< Hash table of glyphs for this font. 53 texture_atlas* m_atlas; ///< Atlas Image object for this font. 54 std::string m_filename; ///< Name of the file. 55 float m_size; ///< Font size. 56 float m_height; ///< Height of the font. (x-height?) 57 float m_linegap; ///< Amount of space between lines. 58 float m_ascender; ///< Height of ascender lines (lines extending above the glyph's x-height). 59 float m_descender; ///< Height of descender lines (lines extending below the glyph's x-height). 60 bool m_hinting; ///< Whether or not glyph hints are used. 61 bool m_filtering; ///< Whether or not glyphs are color filtered for LCD displays. 62 uint8 m_lcd_weights[5]; ///< Color filtering weights. 63 void* m_rlibrary; ///< Pointer to the library. 64 void* m_rface; ///< Pointer to the font face. 53 std::unordered_map< uint16, texture_glyph > m_glyphs; //!< Hash table of glyphs for this font. 54 55 texture_atlas* m_atlas; //!< Atlas Image object for this font. 56 std::string m_filename; //!< Name of the file. 57 float m_size; //!< Font size. 58 float m_height; //!< Height of the font. (x-height?) 59 float m_linegap; //!< Amount of space between lines. 60 float m_ascender; //!< Height of ascender lines (lines extending above the glyph's x-height). 61 float m_descender; //!< Height of descender lines (lines extending below the glyph's x-height). 62 bool m_hinting; //!< Whether or not glyph hints are used. 63 bool m_filtering; //!< Whether or not glyphs are color filtered for LCD displays. 64 uint8 m_lcd_weights[5]; //!< Color filtering weights. 65 void* m_rlibrary; //!< Pointer to the library. 66 void* m_rface; //!< Pointer to the font face. 65 67 }; 66 68 } -
trunk/nv/gl/gl_context.hh
r45 r121 23 23 virtual void clear( const clear_state& cs ); 24 24 // temporary 25 virtual void draw( primitive prim, const render_state& rs, program* p, vertex_array* va, int count );25 virtual void draw( primitive prim, const render_state& rs, program* p, vertex_array* va, size_t count ); 26 26 virtual const ivec4& get_viewport(); 27 27 virtual void set_viewport( const ivec4& viewport ); … … 29 29 private: 30 30 void force_apply_render_state( const render_state& state ); 31 void force_apply_stencil_face( intface, const stencil_test_face& stencil );31 void force_apply_stencil_face( unsigned face, const stencil_test_face& stencil ); 32 32 void apply_stencil_test( const stencil_test& stencil ); 33 void apply_stencil_face( intface, stencil_test_face& stencil, const stencil_test_face& new_stencil );33 void apply_stencil_face( unsigned face, stencil_test_face& stencil, const stencil_test_face& new_stencil ); 34 34 void apply_scissor_test( const scissor_test& scissor ); 35 35 void apply_depth_test( const depth_test& depth ); -
trunk/nv/gl/gl_device.hh
r92 r121 23 23 virtual window* create_window( uint16 width, uint16 height ); 24 24 virtual program* create_program( const string& vs_source, const string& fs_source ); 25 virtual vertex_buffer* create_vertex_buffer( buffer_hint hint, int size, void* source = nullptr );26 virtual index_buffer* create_index_buffer( buffer_hint hint, int size, void* source = nullptr );25 virtual vertex_buffer* create_vertex_buffer( buffer_hint hint, size_t size, void* source = nullptr ); 26 virtual index_buffer* create_index_buffer( buffer_hint hint, size_t size, void* source = nullptr ); 27 27 virtual vertex_array* create_vertex_array(); 28 28 virtual image_data* create_image_data( const std::string& filename ); // temporary -
trunk/nv/gl/gl_names.hh
r35 r121 21 21 { 22 22 public: 23 gl_name() : m_value( 0 ) {} ;24 intget_value() const { return m_value; }23 gl_name() : m_value( 0 ) {} 24 unsigned get_value() const { return m_value; } 25 25 bool is_valid() const { return m_value != 0; } 26 26 protected: -
trunk/nv/gl/gl_program.hh
r41 r121 24 24 { 25 25 public: 26 explicit gl_shader( uint32 sh ader_type );27 gl_shader( uint32 sh ader_type, const string& shader_code );26 explicit gl_shader( uint32 sh_type ); 27 gl_shader( uint32 sh_type, const string& shader_code ); 28 28 ~gl_shader(); 29 29 -
trunk/nv/gl/gl_texture2d.hh
r70 r121 24 24 gl_texture2d( ivec2 size, image_format aformat, datatype adatatype, sampler asampler, void* data = nullptr ); 25 25 virtual void assign( void* data ); 26 virtual void bind( int slot = 0 );26 virtual void bind( size_t slot = 0 ); 27 27 virtual void unbind(); 28 28 virtual bool is_valid() const; -
trunk/nv/gl/gl_vertex_buffer.hh
r100 r121 22 22 { 23 23 public: 24 gl_vertex_buffer( buffer_hint hint, int size, void* data = nullptr );25 virtual void update( void* data, int offset, int size );24 gl_vertex_buffer( buffer_hint hint, size_t size, void* data = nullptr ); 25 virtual void update( void* data, size_t offset, size_t size ); 26 26 virtual void bind(); 27 27 virtual void unbind(); … … 34 34 { 35 35 public: 36 gl_index_buffer( buffer_hint hint, int size, void* data = nullptr );37 virtual void update( void* data, int offset, int size );36 gl_index_buffer( buffer_hint hint, size_t size, void* data = nullptr ); 37 virtual void update( void* data, size_t offset, size_t size ); 38 38 virtual void bind(); 39 39 virtual void unbind(); -
trunk/nv/gl/gl_window.hh
r98 r121 30 30 virtual bool poll_event( io_event& event ); 31 31 virtual context* get_context() { return m_context; } 32 virtual device* get_device() { return m_device; } ;32 virtual device* get_device() { return m_device; } 33 33 34 34 virtual void swap_buffers(); -
trunk/nv/gui/gui_style.hh
r104 r121 36 36 bool resolve( element* e, const std::string& entry, int type ); 37 37 protected: 38 lua::state m_lua; // < separate lua state for style calculation38 lua::state m_lua; //!< separate lua state for style calculation 39 39 }; 40 40 -
trunk/nv/interface/clear_state.hh
r120 r121 28 28 29 29 color_mask() : red( true ), green( true ), blue( true ), alpha( true ) {} 30 color_mask( bool r ed, bool green, bool blue, bool alpha )31 : red( r ed ), green( green ), blue( blue ), alpha( alpha ) {}30 color_mask( bool r, bool g, bool b, bool a ) 31 : red( r ), green( g ), blue( b ), alpha( a ) {} 32 32 33 33 bool operator==(const color_mask& rhs) const -
trunk/nv/interface/context.hh
r45 r121 37 37 virtual void clear( const clear_state& cs ) = 0; 38 38 // temporary 39 virtual void draw( primitive prim, const render_state& rs, program* p, vertex_array* va, int count ) = 0;39 virtual void draw( primitive prim, const render_state& rs, program* p, vertex_array* va, size_t count ) = 0; 40 40 virtual void apply_render_state( const render_state& state ) = 0; 41 41 virtual const ivec4& get_viewport() = 0; 42 42 virtual void set_viewport( const ivec4& viewport ) = 0; 43 virtual ~context() {} 43 44 protected: 44 45 clear_state m_clear_state; -
trunk/nv/interface/device.hh
r116 r121 30 30 virtual window* create_window( uint16 width, uint16 height ) = 0; 31 31 virtual program* create_program( const string& vs_source, const string& fs_source ) = 0; 32 virtual vertex_buffer* create_vertex_buffer( buffer_hint hint, int size, void* source = nullptr ) = 0;33 virtual index_buffer* create_index_buffer( buffer_hint hint, int size, void* source = nullptr ) = 0;32 virtual vertex_buffer* create_vertex_buffer( buffer_hint hint, size_t size, void* source = nullptr ) = 0; 33 virtual index_buffer* create_index_buffer( buffer_hint hint, size_t size, void* source = nullptr ) = 0; 34 34 virtual vertex_array* create_vertex_array() = 0; 35 35 virtual image_data* create_image_data( const std::string& filename ) = 0; // temporary … … 55 55 return result; 56 56 } 57 virtual ~device() {} 57 58 }; 58 59 -
trunk/nv/interface/image_data.hh
r95 r121 15 15 16 16 #include <nv/common.hh> 17 #include <nv/math.hh> 17 18 #include <algorithm> 18 #include <glm/glm.hpp>19 19 20 20 namespace nv … … 23 23 { 24 24 public: 25 image_data( glm::ivec2 size, size_t depth, const uint8 * data )25 image_data( ivec2 size, size_t depth, const uint8 * data ) 26 26 : m_size( size ), m_depth( depth ), m_data( nullptr ) 27 27 { 28 std::size_t bsize = m_size.x * m_size.y* m_depth;28 std::size_t bsize = static_cast<std::size_t>(m_size.x * m_size.y) * m_depth; 29 29 m_data = new uint8[ bsize ]; 30 30 std::copy( data, data + bsize, m_data ); … … 32 32 uint8* release_data() { uint8* r = m_data; m_data = nullptr; return r; } 33 33 const uint8 * get_data() const { return m_data; } 34 const glm::ivec2 get_size() const { return m_size; }35 constsize_t get_depth() const { return m_depth; }34 const ivec2 get_size() const { return m_size; } 35 size_t get_depth() const { return m_depth; } 36 36 ~image_data() { if (m_data) delete[] m_data; } 37 37 private: 38 glm::ivec2 m_size; //< Defines the size of the image as a vector39 size_t m_depth; //< Defines the depth of the image40 uint8* m_data; //< Holder for data38 ivec2 m_size; //!< Defines the size of the image as a vector 39 size_t m_depth; //!< Defines the depth of the image 40 uint8* m_data; //!< Holder for data 41 41 }; 42 42 } -
trunk/nv/interface/mesh.hh
r111 r121 35 35 virtual size_t get_size() const = 0; 36 36 virtual void* get_data() const = 0; 37 virtual ~vertex_attribute_base() {} ;37 virtual ~vertex_attribute_base() {} 38 38 private: 39 39 string m_name; … … 52 52 const list& get() const { return m_list; } 53 53 list& get() { return m_list; } 54 virtual datatype get_base_type() const { return type_to_enum<base_type>::type; } ;55 virtual size_t get_components() const { return datatype_traits<T>::size; } ;54 virtual datatype get_base_type() const { return type_to_enum<base_type>::type; } 55 virtual size_t get_components() const { return datatype_traits<T>::size; } 56 56 virtual size_t get_count() const { return m_list.size(); } 57 57 virtual size_t get_size() const { return m_list.size() * sizeof(T); } … … 67 67 typedef std::unordered_map< std::string, vertex_attribute_base* > map; 68 68 69 mesh( primitive p = TRIANGLES , culling::order_type c = culling::CCW)70 : m_map(), m_indices(), m_primitive( p ) , m_order( c ){}69 mesh( primitive p = TRIANGLES ) 70 : m_map(), m_indices(), m_primitive( p ) {} 71 71 template <typename T> 72 72 vertex_attribute<T>* add_attribute( const string& attr ) … … 126 126 vertex_attribute_base* m_indices; 127 127 primitive m_primitive; 128 culling::order_type m_order;129 130 128 }; 131 129 -
trunk/nv/interface/texture2d.hh
r70 r121 63 63 m_size( size ), m_format( aformat ), m_datatype( adatatype ), m_sampler( asampler ) {} 64 64 virtual void assign( void* data ) = 0; 65 virtual void bind( int slot = 0 ) = 0;65 virtual void bind( size_t slot = 0 ) = 0; 66 66 virtual void unbind() = 0; 67 67 virtual bool is_valid() const = 0; … … 72 72 datatype get_datatype() const { return m_datatype; } 73 73 const sampler& get_sampler() const { return m_sampler; } 74 virtual ~texture2d() {} 74 75 protected: 75 76 ivec2 m_size; -
trunk/nv/interface/vertex_buffer.hh
r119 r121 32 32 { 33 33 public: 34 buffer( buffer_hint hint, int size ) { m_size = size; m_hint = hint; }35 virtual void update( void* data, int offset, int size ) = 0;34 buffer( buffer_hint hint, size_t size ) { m_size = size; m_hint = hint; } 35 virtual void update( void* data, size_t offset, size_t size ) = 0; 36 36 virtual void bind() = 0; 37 37 virtual void unbind() = 0; 38 38 virtual bool is_valid() const = 0; 39 int get_size() const { return m_size; };40 buffer_hint get_hint() const { return m_hint; } ;39 size_t get_size() const { return m_size; } 40 buffer_hint get_hint() const { return m_hint; } 41 41 virtual ~buffer() {} 42 42 protected: 43 intm_size;43 size_t m_size; 44 44 buffer_hint m_hint; 45 45 }; … … 48 48 { 49 49 public: 50 vertex_buffer( buffer_hint hint, int size ) : buffer( hint, size ) {}50 vertex_buffer( buffer_hint hint, size_t size ) : buffer( hint, size ) {} 51 51 }; 52 52 … … 54 54 { 55 55 public: 56 index_buffer( buffer_hint hint, int size ) : buffer( hint, size ) {}56 index_buffer( buffer_hint hint, size_t size ) : buffer( hint, size ) {} 57 57 }; 58 58 … … 60 60 { 61 61 public: 62 vertex_buffer_attribute( vertex_buffer* buffer, datatype datatype, int components, int offset = 0, int stride = 0, bool owner = true )62 vertex_buffer_attribute( vertex_buffer* buffer, datatype datatype, size_t components, size_t offset = 0, size_t stride = 0, bool owner = true ) 63 63 : m_buffer( buffer ), m_datatype( datatype ), m_components( components ), m_offset( offset ), m_stride( stride ), m_owner( owner ) {} 64 64 … … 66 66 void set_buffer( vertex_buffer* b, bool owner ) { if (m_owner) delete m_buffer; m_buffer = b; m_owner = owner; } 67 67 datatype get_datatype() const { return m_datatype; } 68 int get_components() const { return m_components; }69 int get_offset() const { return m_offset; }70 int get_stride() const { return m_stride; }68 size_t get_components() const { return m_components; } 69 size_t get_offset() const { return m_offset; } 70 size_t get_stride() const { return m_stride; } 71 71 72 72 ~vertex_buffer_attribute() … … 82 82 vertex_buffer* m_buffer; 83 83 datatype m_datatype; 84 int m_components;85 int m_offset;86 int m_stride;87 bool m_owner;84 size_t m_components; 85 size_t m_offset; 86 size_t m_stride; 87 bool m_owner; 88 88 }; 89 89 … … 94 94 public: 95 95 vertex_array() : m_map(), m_index( nullptr ), m_index_owner( false ), m_index_type(USHORT) {} 96 void add_vertex_buffer( int location, vertex_buffer* buffer, datatype datatype, int components, int offset = 0, int stride = 0, bool owner = true )96 void add_vertex_buffer( int location, vertex_buffer* buffer, datatype datatype, size_t components, size_t offset = 0, size_t stride = 0, bool owner = true ) 97 97 { 98 98 auto p = new vertex_buffer_attribute( buffer, datatype, components, offset, stride, owner ); 99 99 m_map[ location ] = p; 100 } ;100 } 101 101 void update_vertex_buffer( int location, vertex_buffer* b, bool owner ) 102 102 { … … 106 106 i->second->set_buffer( b, owner ); 107 107 } 108 } ;108 } 109 109 void set_index_buffer( index_buffer* buffer, datatype datatype, bool owner ) 110 110 { … … 123 123 virtual void bind() = 0; 124 124 virtual void unbind() = 0; 125 ~vertex_array() {125 virtual ~vertex_array() { 126 126 for ( vertex_buffer_attribute_map::iterator i = m_map.begin(); i != m_map.end(); ++i ) 127 127 { -
trunk/nv/interface/window.hh
r111 r121 33 33 virtual void swap_buffers() = 0; 34 34 virtual device* get_device() = 0; 35 virtual ~window() {} ;35 virtual ~window() {} 36 36 }; 37 37 -
trunk/nv/lib/lua.hh
r5 r121 32 32 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 33 33 ******************************************************************************/ 34 35 #include <nv/common.hh> 34 36 35 37 #define NV_LUA_DYNAMIC -
trunk/nv/logger.hh
r95 r121 43 43 * Enforcement of virtual destructor. 44 44 */ 45 virtual ~log_sink() {} ;45 virtual ~log_sink() {} 46 46 }; 47 47 … … 62 62 * overriding cutoff. 63 63 */ 64 explicit logger( int llevel )64 explicit logger( unsigned int llevel ) 65 65 { 66 66 m_level = llevel; -
trunk/nv/logging.hh
r95 r121 14 14 #define NV_LOGGING_HH 15 15 16 #include <nv/common.hh> 16 17 #include <nv/singleton.hh> 17 18 #include <sstream> … … 40 41 { 41 42 return m_level; 42 } ;43 } 43 44 void set_level( unsigned int level ) 44 45 { 45 46 m_level = level; 46 } ;47 } 47 48 virtual void log( log_level level, const std::string& message ) = 0; 49 virtual ~logger_base() {} 48 50 protected: 49 51 unsigned int m_level; -
trunk/nv/lua/lua_glm.hh
r76 r121 9 9 #include <new> 10 10 #include <nv/common.hh> 11 #include < glm/glm.hpp>11 #include <nv/math.hh> 12 12 #include <nv/lib/lua.hh> 13 13 … … 41 41 } 42 42 43 template<> inline const char* nlua_metatable_name< glm::ivec2 >() { return "ivec2"; }44 template<> inline const char* nlua_metatable_name< glm::ivec3 >() { return "ivec3"; }45 template<> inline const char* nlua_metatable_name< glm::ivec4 >() { return "ivec4"; }46 template<> inline const char* nlua_metatable_name< glm::vec2 >() { return "vec2"; }47 template<> inline const char* nlua_metatable_name< glm::vec3 >() { return "vec3"; }48 template<> inline const char* nlua_metatable_name< glm::vec4 >() { return "vec4"; }43 template<> inline const char* nlua_metatable_name< nv::ivec2 >() { return "ivec2"; } 44 template<> inline const char* nlua_metatable_name< nv::ivec3 >() { return "ivec3"; } 45 template<> inline const char* nlua_metatable_name< nv::ivec4 >() { return "ivec4"; } 46 template<> inline const char* nlua_metatable_name< nv::vec2 >() { return "vec2"; } 47 template<> inline const char* nlua_metatable_name< nv::vec3 >() { return "vec3"; } 48 template<> inline const char* nlua_metatable_name< nv::vec4 >() { return "vec4"; } 49 49 50 50 #endif // NV_LUA_GLM_HH -
trunk/nv/lua/lua_raw.hh
r85 r121 7 7 #define NV_LUA_RAW_HH 8 8 9 #include <nv/common.hh> 9 10 #include <nv/lib/lua.hh> 10 #include <nv/common.hh>11 11 #include <istream> 12 12 #include <string> -
trunk/nv/lua/lua_state.hh
r86 r121 29 29 { 30 30 public: 31 stack_guard( state* L );32 stack_guard( state& L );31 stack_guard( state* aL ); 32 stack_guard( state& aL ); 33 33 int get_level() const { return m_level; } 34 34 ~stack_guard(); -
trunk/nv/position.hh
r120 r121 14 14 #define NV_POSITION_HH 15 15 16 #include <glm/glm.hpp>17 16 #include <nv/common.hh> 17 #include <nv/math.hh> 18 18 #include <utility> 19 19 20 20 namespace nv 21 21 { 22 typedef glm::ivec2 position;23 typedef glm::ivec2 dimension;22 typedef ivec2 position; 23 typedef ivec2 dimension; 24 24 25 25 struct rectangle … … 46 46 *Creates a new rectangle given an upper-left and lower-right position. 47 47 * 48 *@param ul The position of the upper-left corner of the rectangle.49 *@param lr The position of the lower-right corner of the rectangle.50 */ 51 rectangle( position ul, position lr ) : ul(ul), lr(lr) {}48 *@param aul The position of the upper-left corner of the rectangle. 49 *@param alr The position of the lower-right corner of the rectangle. 50 */ 51 rectangle( position aul, position alr ) : ul(aul), lr(alr) {} 52 52 53 53 /** 54 54 *Creates a new rectangle given an upper-left position, width, and height. 55 55 * 56 *@param ul The position of the upper-left corner of the rectangle.56 *@param aul The position of the upper-left corner of the rectangle. 57 57 *@param width The width of the rectangle. 58 58 *@param height The height of the rectangle. 59 59 */ 60 rectangle( position ul, value_type width, value_type height ) : ul(ul), lr(ul + position(width,height)) {}60 rectangle( position aul, value_type width, value_type height ) : ul(aul), lr(aul + position(width,height)) {} 61 61 62 62 /** … … 269 269 { 270 270 if (r.contains(*this)) return false; 271 ul = glm::max( ul, r.ul );272 lr = glm::min( lr, r.lr );273 ul = glm::min( ul, lr );271 ul = nv::max( ul, r.ul ); 272 lr = nv::min( lr, r.lr ); 273 ul = nv::min( ul, lr ); 274 274 return true; 275 275 } … … 284 284 { 285 285 if ( r.get_width() < get_width() || r.get_height() < get_height() ) return false; 286 (*this) += glm::min( r.ul - ul, position() );287 (*this) -= glm::min( lr - r.lr, position() );286 (*this) += nv::min( r.ul - ul, position() ); 287 (*this) -= nv::min( lr - r.lr, position() ); 288 288 return true; 289 289 } … … 305 305 void include_point( position p ) 306 306 { 307 lr = glm::max( lr, p );308 ul = glm::min( ul, p );307 lr = nv::max( lr, p ); 308 ul = nv::min( ul, p ); 309 309 } 310 310 -
trunk/nv/resource.hh
r7 r121 30 30 uid get_rid() const { return m_rid; } 31 31 uid get_size() const { return m_size; } 32 virtual ~resource() {} 32 33 private: 33 34 uint32 m_size; -
trunk/nv/time.hh
r34 r121 24 24 * @returns amount of ticks 25 25 */ 26 volatileuint64 get_ticks();26 uint64 get_ticks(); 27 27 28 28 /** 29 29 * Performs an operating system sleep call. 30 30 * 31 * @param timetime in milliseconds to sleep31 * @param ms time in milliseconds to sleep 32 32 */ 33 33 void sleep( uint32 ms ); -
trunk/nv/types.hh
r113 r121 6 6 #define NV_TYPES_HH 7 7 8 #include <glm/glm.hpp>9 8 #include <nv/common.hh> 9 #include <nv/math.hh> 10 10 #include <nv/object.hh> 11 11 #include <type_traits> … … 44 44 }; 45 45 46 template <typename T>47 struct datatype_traits48 {49 typedef T type;50 typedef T base_type;51 static const size_t size = 1;52 };53 54 template <typename T>55 struct datatype_traits< glm::detail::tvec2<T> >56 {57 typedef glm::detail::tvec2<T> type;58 typedef typename type::value_type base_type;59 static const size_t size = 2;60 };61 62 template <typename T>63 struct datatype_traits< glm::detail::tvec3<T> >64 {65 typedef glm::detail::tvec3<T> type;66 typedef typename type::value_type base_type;67 static const size_t size = 3;68 };69 70 template <typename T>71 struct datatype_traits< glm::detail::tvec4<T> >72 {73 typedef glm::detail::tvec4<T> type;74 typedef typename type::value_type base_type;75 static const size_t size = 4;76 };77 78 typedef glm::detail::tvec2<sint8> i8vec2;79 typedef glm::detail::tvec3<sint8> i8vec3;80 typedef glm::detail::tvec4<sint8> i8vec4;81 82 typedef glm::vec2 vec2;83 typedef glm::vec3 vec3;84 typedef glm::vec4 vec4;85 86 typedef glm::ivec2 ivec2;87 typedef glm::ivec3 ivec3;88 typedef glm::ivec4 ivec4;89 90 typedef glm::mat2 mat2;91 typedef glm::mat3 mat3;92 typedef glm::mat4 mat4;93 94 46 template < datatype EnumType > struct enum_to_type {}; 95 47 … … 177 129 enum type_flag 178 130 { 179 TF_POINTER = 0x01, // < field is a pointer180 TF_NOSERIALIZE = 0x02, // < ignore during serialization181 TF_INVISIBLE = 0x04, // < field invisible to API182 TF_READONLY = 0x08, // < read only field183 TF_SIMPLETYPE = 0x10, // < raw binary I/O possible131 TF_POINTER = 0x01, //!< field is a pointer 132 TF_NOSERIALIZE = 0x02, //!< ignore during serialization 133 TF_INVISIBLE = 0x04, //!< field invisible to API 134 TF_READONLY = 0x08, //!< read only field 135 TF_SIMPLETYPE = 0x10, //!< raw binary I/O possible 184 136 TF_OWNED = 0x20, 185 TF_CONTAINER = 0x40, // < is a container137 TF_CONTAINER = 0x40, //!< is a container 186 138 }; 187 139 188 140 struct type_field 189 141 { 190 std::string name; //< name of the field191 std::string type_name; //< name of the type of the field192 const std::type_info* type_inf; //< typeinfo for later retrieval of type193 type_entry* type; //< pointer to field type194 unsigned int flags; //< flags142 std::string name; //!< name of the field 143 std::string type_name; //!< name of the type of the field 144 const std::type_info* type_inf; //!< typeinfo for later retrieval of type 145 type_entry* type; //!< pointer to field type 146 unsigned int flags; //!< flags 195 147 size_t offset; 196 148 197 149 template< typename TOBJECT, typename TFIELD > 198 type_field( const char* name, TFIELD TOBJECT::*field, typename std::enable_if< is_container<TFIELD>::value, void* >::type = nullptr )199 : name( name)150 type_field( const char* aname, TFIELD TOBJECT::*field, typename std::enable_if< is_container<TFIELD>::value, void* >::type = nullptr ) 151 : name(aname) 200 152 , type_name() 201 153 , type_inf( &typeid( typename std::remove_pointer<typename TFIELD::value_type>::type ) ) … … 204 156 , offset( offset_of( field ) ) 205 157 { 206 NV_LOG( LOG_INFO, name << "-" << offset);158 NV_LOG( LOG_INFO, aname << "-" << offset); 207 159 flags = TF_CONTAINER | 208 160 ( std::is_pointer<typename TFIELD::value_type>::value ? TF_POINTER : 0 ) | … … 211 163 212 164 template< typename TOBJECT, typename TFIELD > 213 type_field( const char* name, TFIELD TOBJECT::*field, typename std::enable_if< !is_container<TFIELD>::value, void* >::type = nullptr )214 : name( name)165 type_field( const char* aname, TFIELD TOBJECT::*field, typename std::enable_if< !is_container<TFIELD>::value, void* >::type = nullptr ) 166 : name(aname) 215 167 , type_name() 216 168 , type_inf( &typeid( typename std::remove_pointer<TFIELD>::type ) ) … … 219 171 , offset( offset_of( field ) ) 220 172 { 221 NV_LOG( LOG_INFO, name << "-" << offset);173 NV_LOG( LOG_INFO, aname << "-" << offset); 222 174 flags = 223 175 ( std::is_pointer<TFIELD>::value ? TF_POINTER : 0 ) | … … 236 188 std::string name; 237 189 int value; 238 type_enum( const char* name, int value ) : name(name), value(value) {}190 type_enum( const char* aname, int avalue ) : name(aname), value(avalue) {} 239 191 }; 240 192 … … 345 297 { 346 298 base_type = type_db->get_type( typeid(TYPE) ); 299 return *this; 347 300 } 348 301 -
trunk/src/gfx/image.cc
r90 r121 12 12 : m_size( size ), m_depth( depth ), m_data( nullptr ) 13 13 { 14 m_data = new uint8[ m_size.x * m_size.y* m_depth ];14 m_data = new uint8[ static_cast<uint16>( m_size.x * m_size.y ) * m_depth ]; 15 15 } 16 16 … … 25 25 : m_size( size ), m_depth( depth ), m_data( nullptr ) 26 26 { 27 s td::size_t bsize = m_size.x * m_size.y * m_depth;28 m_data = new uint8[ m_size.x * m_size.y * m_depth];27 sint32 bsize = m_size.x * m_size.y * static_cast<sint32>( m_depth ); 28 m_data = new uint8[ bsize ]; 29 29 30 30 if ( reversed ) 31 31 { 32 s td::size_t bline = m_size.x * m_depth;32 sint32 bline = m_size.x * static_cast<sint32>( m_depth ); 33 33 for( int i = 0; i < m_size.y; ++i ) 34 34 { … … 45 45 void image::fill( uint8 value ) 46 46 { 47 std::fill( m_data, m_data + m_size.x * m_size.y * m_depth, value );47 std::fill( m_data, m_data + m_size.x * m_size.y * (int)m_depth, value ); 48 48 } 49 49 50 void image::set_region( region r, const uint8 * data, size_t stride )50 void image::set_region( region r, const uint8 * data, int stride ) 51 51 { 52 if ( stride == 0 ) stride = r.size.x * m_depth;52 if ( stride == 0 ) stride = r.size.x * static_cast<sint32>( m_depth ); 53 53 54 s td::size_t bpos = (r.pos.y*m_size.x + r.pos.x ) * m_depth;55 s td::size_t bline = m_size.x*m_depth;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 56 57 57 for( int i = 0; i < r.size.y; ++i ) -
trunk/src/gfx/texture_atlas.cc
r89 r121 37 37 { 38 38 best_height = y + size.y; 39 best_index = i;39 best_index = static_cast<int>( i ); 40 40 best_width = node.z; 41 41 r.pos.x = node.x; … … 52 52 m_nodes.insert( m_nodes.begin() + best_index, glm::ivec3( r.pos.x, r.pos.y + size.y, size.x ) ); 53 53 54 for( size_t i = best_index+1; i < m_nodes.size(); ++i )54 for( size_t i = static_cast<size_t>( best_index )+1; i < m_nodes.size(); ++i ) 55 55 { 56 56 glm::ivec3 node = m_nodes[ i ]; … … 65 65 if (m_nodes[ i ].z <= 0) 66 66 { 67 m_nodes.erase( m_nodes.begin() + i);67 m_nodes.erase( m_nodes.begin() + static_cast<int>(i) ); 68 68 --i; 69 69 } … … 79 79 } 80 80 merge(); 81 m_used += s ize.x * size.y;81 m_used += static_cast<uint16>(size.x * size.y); 82 82 return r; 83 83 } … … 119 119 { 120 120 m_nodes[ i ].z += m_nodes[ i+1 ].z; 121 m_nodes.erase( m_nodes.begin()+ i+1);121 m_nodes.erase( m_nodes.begin()+static_cast<int>(i+1) ); 122 122 --i; 123 123 } -
trunk/src/gfx/texture_font.cc
r114 r121 17 17 } 18 18 19 float texture_glyph::get_kerning( const uint16 charcode)19 float texture_glyph::get_kerning( const uint16 other ) 20 20 { 21 auto i = kerning.find( charcode);21 auto i = kerning.find( other ); 22 22 return i != kerning.end() ? i->second : 0.0f; 23 23 } … … 118 118 } 119 119 120 for ( char c : codes )120 for ( char ch : codes ) 121 121 { 122 uint16 c = static_cast<uint16>( ch ); 122 123 FT_UInt glyph_index = FT_Get_Char_Index( face, c ); 123 124 FT_Error error = FT_Load_Glyph( face, glyph_index, flags ); … … 136 137 int ft_glyph_top = slot->bitmap_top; 137 138 int ft_glyph_left = slot->bitmap_left; 138 int reg_width = ft_bitmap_width / (depth > 3 ? 3 : depth);139 int reg_width = ft_bitmap_width / (depth > 3 ? 3 : (int)depth); 139 140 140 141 glm::ivec2 gsize( reg_width + 1, ft_bitmap_rows + 1 ); -
trunk/src/gl/gl_context.cc
r116 r121 83 83 } 84 84 85 void gl_context::apply_stencil_face( intface, stencil_test_face& stencil, const stencil_test_face& new_stencil )85 void gl_context::apply_stencil_face( unsigned face, stencil_test_face& stencil, const stencil_test_face& new_stencil ) 86 86 { 87 87 if (( stencil.op_fail != new_stencil.op_fail ) || … … 317 317 } 318 318 319 void gl_context::force_apply_stencil_face( intface, const stencil_test_face& stencil )319 void gl_context::force_apply_stencil_face( unsigned face, const stencil_test_face& stencil ) 320 320 { 321 321 glStencilOpSeparate( face, … … 356 356 } 357 357 358 void gl_context::draw( primitive prim, const render_state& rs, program* p, vertex_array* va, int count )358 void gl_context::draw( primitive prim, const render_state& rs, program* p, vertex_array* va, size_t count ) 359 359 { 360 360 apply_render_state( rs ); … … 365 365 if ( va->has_index_buffer() ) 366 366 { 367 glDrawElements( primitive_to_enum(prim), count, datatype_to_gl_enum( va->get_index_buffer_type() ), 0 );367 glDrawElements( primitive_to_enum(prim), static_cast<GLsizei>( count ), datatype_to_gl_enum( va->get_index_buffer_type() ), 0 ); 368 368 } 369 369 else 370 370 { 371 glDrawArrays( primitive_to_enum(prim), 0, count);371 glDrawArrays( primitive_to_enum(prim), 0, static_cast<GLsizei>( count ) ); 372 372 } 373 373 va->unbind(); -
trunk/src/gl/gl_device.cc
r120 r121 53 53 } 54 54 55 vertex_buffer* gl_device::create_vertex_buffer( buffer_hint hint, int size, void* source /*= nullptr */ )55 vertex_buffer* gl_device::create_vertex_buffer( buffer_hint hint, size_t size, void* source /*= nullptr */ ) 56 56 { 57 57 return new gl_vertex_buffer( hint, size, source ); 58 58 } 59 59 60 index_buffer* gl_device::create_index_buffer( buffer_hint hint, int size, void* source /*= nullptr */ )60 index_buffer* gl_device::create_index_buffer( buffer_hint hint, size_t size, void* source /*= nullptr */ ) 61 61 { 62 62 return new gl_index_buffer( hint, size, source ); -
trunk/src/gl/gl_enum.cc
r70 r121 30 30 case depth_test::GREATER_OR_EQUAL : return GL_GEQUAL; 31 31 case depth_test::ALWAYS : return GL_ALWAYS; 32 default : return 0; // TODO: throw!32 NV_RETURN_COVERED_DEFAULT( 0 ); 33 33 } 34 34 } … … 53 53 case blending::ONE_MINUS_CONSTANT_ALPHA: return GL_ONE_MINUS_CONSTANT_ALPHA; 54 54 case blending::SRC_ALPHA_SATURATE : return GL_SRC_ALPHA_SATURATE; 55 default : return 0; // TODO: throw!55 NV_RETURN_COVERED_DEFAULT( 0 ); 56 56 } 57 57 } … … 66 66 case blending::MINIMUM : return GL_MIN; 67 67 case blending::MAXIMUM : return GL_MAX; 68 default : return 0; // TODO: throw!68 NV_RETURN_COVERED_DEFAULT( 0 ); 69 69 } 70 70 } … … 77 77 case culling::BACK : return GL_BACK; 78 78 case culling::FRONT_AND_BACK : return GL_FRONT_AND_BACK; 79 default : return 0; // TODO: throw!79 NV_RETURN_COVERED_DEFAULT( 0 ); 80 80 } 81 81 } … … 87 87 case culling::CW : return GL_CW; 88 88 case culling::CCW : return GL_CCW; 89 default : return 0; // TODO: throw!89 NV_RETURN_COVERED_DEFAULT( 0 ); 90 90 } 91 91 } … … 103 103 case stencil_test_face::GREATER_OR_EQUAL : return GL_GEQUAL; 104 104 case stencil_test_face::ALWAYS : return GL_ALWAYS; 105 default : return 0; // TODO: throw!105 NV_RETURN_COVERED_DEFAULT( 0 ); 106 106 } 107 107 } … … 119 119 case stencil_test_face::INCREMENT_WRAP : return GL_INCR_WRAP; 120 120 case stencil_test_face::DECREMENT_WRAP : return GL_DECR_WRAP; 121 default : return 0; // TODO: throw!121 NV_RETURN_COVERED_DEFAULT( 0 ); 122 122 } 123 123 } … … 130 130 case STREAM_DRAW : return GL_STREAM_DRAW; 131 131 case DYNAMIC_DRAW : return GL_DYNAMIC_DRAW; 132 default : return 0; // TODO: throw!132 NV_RETURN_COVERED_DEFAULT( 0 ); 133 133 } 134 134 } … … 140 140 case RGB : return GL_RGB; 141 141 case RGBA : return GL_RGBA; 142 default : return 0; // TODO: throw!142 NV_RETURN_COVERED_DEFAULT( 0 ); 143 143 } 144 144 } … … 154 154 case sampler::NEAREST_MIPMAP_LINEAR : return GL_NEAREST_MIPMAP_LINEAR; 155 155 case sampler::LINEAR_MIPMAP_LINEAR : return GL_LINEAR_MIPMAP_LINEAR; 156 default : return 0; // TODO: throw!156 NV_RETURN_COVERED_DEFAULT( 0 ); 157 157 } 158 158 } … … 166 166 case sampler::MIRRORED_REPEAT : return GL_MIRRORED_REPEAT; 167 167 case sampler::REPEAT : return GL_REPEAT; 168 default : return 0; // TODO: throw!168 NV_RETURN_COVERED_DEFAULT( 0 ); 169 169 } 170 170 } … … 181 181 case TRIANGLE_STRIP : return GL_TRIANGLE_STRIP; 182 182 case TRIANGLE_FAN : return GL_TRIANGLE_FAN; 183 default : return 0; // TODO: throw!183 NV_RETURN_COVERED_DEFAULT( 0 ); 184 184 } 185 185 } … … 209 209 case BYTE_VECTOR_3 : return GL_INT_VEC3; 210 210 case BYTE_VECTOR_4 : return GL_INT_VEC4; 211 default : return 0; // TODO: throw!211 NV_RETURN_COVERED_DEFAULT( 0 ); 212 212 } 213 213 } -
trunk/src/gl/gl_program.cc
r70 r121 14 14 using namespace nv; 15 15 16 gl_shader::gl_shader( uint32 sh ader_type )17 : object_id(0), shader_type( shader_type)16 gl_shader::gl_shader( uint32 sh_type ) 17 : shader_type( sh_type ), object_id(0) 18 18 { 19 19 // no op 20 20 } 21 21 22 gl_shader::gl_shader( uint32 sh ader_type, const string& shader_code )23 : object_id(0), shader_type( shader_type)22 gl_shader::gl_shader( uint32 sh_type, const string& shader_code ) 23 : shader_type( sh_type ), object_id(0) 24 24 { 25 25 compile( shader_code ); … … 140 140 glGetProgramiv( m_name.get_value(), GL_ACTIVE_ATTRIBUTES, ¶ms ); 141 141 142 for ( int i = 0; i <params; ++i )142 for ( unsigned i = 0; i < (unsigned)params; ++i ) 143 143 { 144 144 int attr_nlen; … … 149 149 glGetActiveAttrib( m_name.get_value(), i, 128, &attr_nlen, &attr_len, &attr_type, name_buffer ); 150 150 151 string name( name_buffer, attr_nlen);151 string name( name_buffer, size_t(attr_nlen) ); 152 152 153 153 // skip built-ins … … 165 165 glGetProgramiv( m_name.get_value(), GL_ACTIVE_UNIFORMS, ¶ms ); 166 166 167 for ( int i = 0; i < params; ++i )167 for ( unsigned i = 0; i < size_t(params); ++i ) 168 168 { 169 169 int uni_nlen; … … 174 174 glGetActiveUniform( m_name.get_value(), i, 128, &uni_nlen, &uni_len, &uni_type, name_buffer ); 175 175 176 string name( name_buffer, uni_nlen);176 string name( name_buffer, size_t(uni_nlen) ); 177 177 178 178 // skip built-ins … … 206 206 case FLOAT_MATRIX_3 : glUniformMatrix3fv( uloc, 1, GL_FALSE, glm::value_ptr(((uniform< enum_to_type< FLOAT_MATRIX_3 >::type >*)( ubase ))->get_value()) ); break; 207 207 case FLOAT_MATRIX_4 : glUniformMatrix4fv( uloc, 1, GL_FALSE, glm::value_ptr(((uniform< enum_to_type< FLOAT_MATRIX_4 >::type >*)( ubase ))->get_value()) ); break; 208 //default :error?208 default : break; // error? 209 209 } 210 210 ubase->clean(); -
trunk/src/gl/gl_texture2d.cc
r70 r121 15 15 glBindTexture( GL_TEXTURE_2D, m_name.get_value() ); 16 16 17 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, nv::sampler_filter_to_enum( m_sampler.filter_min ) );18 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, nv::sampler_filter_to_enum( m_sampler.filter_max ) );19 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, nv::sampler_wrap_to_enum( m_sampler.wrap_s) );20 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, nv::sampler_wrap_to_enum( m_sampler.wrap_t) );17 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (int)nv::sampler_filter_to_enum( m_sampler.filter_min ) ); 18 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, (int)nv::sampler_filter_to_enum( m_sampler.filter_max ) ); 19 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, (int)nv::sampler_wrap_to_enum( m_sampler.wrap_s) ); 20 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, (int)nv::sampler_wrap_to_enum( m_sampler.wrap_t) ); 21 21 22 22 glBindTexture( GL_TEXTURE_2D, 0 ); … … 31 31 { 32 32 glBindTexture( GL_TEXTURE_2D, m_name.get_value() ); 33 glTexImage2D( GL_TEXTURE_2D, 0, nv::image_format_to_enum(m_format), m_size.x, m_size.y, 0, nv::image_format_to_enum(m_format), nv::datatype_to_gl_enum(m_datatype), data );33 glTexImage2D( GL_TEXTURE_2D, 0, (GLint)nv::image_format_to_enum(m_format), m_size.x, m_size.y, 0, nv::image_format_to_enum(m_format), nv::datatype_to_gl_enum(m_datatype), data ); 34 34 glBindTexture( GL_TEXTURE_2D, 0 ); 35 35 } 36 36 37 void nv::gl_texture2d::bind( int slot )37 void nv::gl_texture2d::bind( size_t slot ) 38 38 { 39 39 glActiveTexture( GL_TEXTURE0 + slot ); -
trunk/src/gl/gl_vertex_buffer.cc
r116 r121 10 10 using namespace nv; 11 11 12 gl_vertex_buffer::gl_vertex_buffer( buffer_hint hint, int size, void* data )12 gl_vertex_buffer::gl_vertex_buffer( buffer_hint hint, size_t size, void* data ) 13 13 : vertex_buffer( hint, size ), m_name() 14 14 { 15 15 bind(); 16 glBufferData( GL_ARRAY_BUFFER, m_size, data, buffer_hint_to_enum( m_hint ) );16 glBufferData( GL_ARRAY_BUFFER, (GLsizeiptr)m_size, data, buffer_hint_to_enum( m_hint ) ); 17 17 unbind(); 18 18 } 19 19 20 void gl_vertex_buffer::update( void* data, int offset, int size )20 void gl_vertex_buffer::update( void* data, size_t offset, size_t size ) 21 21 { 22 glBufferSubData( GL_ARRAY_BUFFER, offset,size, data );22 glBufferSubData( GL_ARRAY_BUFFER, (GLintptr)offset, (GLsizeiptr)size, data ); 23 23 } 24 24 … … 39 39 } 40 40 41 gl_index_buffer::gl_index_buffer( buffer_hint hint, int size, void* data )41 gl_index_buffer::gl_index_buffer( buffer_hint hint, size_t size, void* data ) 42 42 : index_buffer( hint, size ), m_name() 43 43 { 44 44 bind(); 45 glBufferData( GL_ELEMENT_ARRAY_BUFFER, m_size, data, buffer_hint_to_enum( m_hint ) );45 glBufferData( GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)m_size, data, buffer_hint_to_enum( m_hint ) ); 46 46 unbind(); 47 47 } 48 48 49 void gl_index_buffer::update( void* data, int offset, int size )49 void gl_index_buffer::update( void* data, size_t offset, size_t size ) 50 50 { 51 glBufferSubData( GL_ELEMENT_ARRAY_BUFFER, offset,size, data );51 glBufferSubData( GL_ELEMENT_ARRAY_BUFFER, (GLintptr)offset, (GLsizeiptr)size, data ); 52 52 } 53 53 … … 76 76 for ( vertex_buffer_attribute_map::iterator i = m_map.begin(); i != m_map.end(); ++i ) 77 77 { 78 int location = i->first;78 uint32 location = static_cast<uint32>( i->first ); 79 79 vertex_buffer_attribute* va = i->second; 80 80 vertex_buffer* vb = va->get_buffer(); … … 83 83 glVertexAttribPointer( 84 84 location, 85 va->get_components(),85 static_cast<GLint>( va->get_components() ), 86 86 nv::datatype_to_gl_enum( va->get_datatype() ), 87 87 GL_FALSE, 88 va->get_stride(),88 static_cast<GLsizei>( va->get_stride() ), 89 89 (void*)va->get_offset() 90 90 ); … … 107 107 for ( vertex_buffer_attribute_map::iterator i = m_map.begin(); i != m_map.end(); ++i ) 108 108 { 109 glDisableVertexAttribArray( i->first);109 glDisableVertexAttribArray( static_cast<uint32>( i->first ) ); 110 110 } 111 111 } -
trunk/src/gl/gl_window.cc
r98 r121 21 21 if (ke.keysym.unicode >= 32 && ke.keysym.unicode < 128 ) 22 22 { 23 kevent.key.ascii = (char)ke.keysym.unicode;23 kevent.key.ascii = static_cast<char8>( ke.keysym.unicode ); 24 24 } 25 25 … … 151 151 : m_device( dev ), m_width( width ), m_height( height ), m_title("NV Engine"), m_screen( nullptr ) 152 152 { 153 intflags = SDL_OPENGL;153 uint32 flags = SDL_OPENGL; 154 154 155 155 m_screen = SDL_SetVideoMode( width, height, 32, flags ); -
trunk/src/gui/gui_style.cc
r114 r121 36 36 for (size_t i = 0; i < 4; ++i ) 37 37 { 38 lua_rawgeti( m_lua, -1, i+1);38 lua_rawgeti( m_lua, -1, static_cast<int>( i+1 ) ); 39 39 if ( lua_isnil( m_lua, -1 ) ) return true; 40 40 vec[i] = (float)lua_tonumber( m_lua, -1 ); -
trunk/src/io_event.cc
r78 r121 9 9 using namespace nv; 10 10 11 const char* get_key_name( key_code key )11 const char* nv::get_key_name( key_code key ) 12 12 { 13 13 switch ( key ) … … 16 16 # include <nv/detail/key_list.inc> 17 17 # undef NV_KEY 18 default: return "KEY_UNKNOWN";18 NV_RETURN_COVERED_DEFAULT( "KEY_UNKNOWN" ); 19 19 }; 20 20 } 21 21 22 const char* get_mouse_name( mouse_code button )22 const char* nv::get_mouse_name( mouse_code button ) 23 23 { 24 24 switch ( button ) … … 27 27 # include <nv/detail/mouse_list.inc> 28 28 # undef NV_MOUSE 29 default: return "MOUSE_UNKNOWN";29 NV_RETURN_COVERED_DEFAULT( "MOUSE_UNKNOWN" ); 30 30 }; 31 31 } 32 32 33 const char* get_io_event_name( io_event_code event )33 const char* nv::get_io_event_name( io_event_code event ) 34 34 { 35 35 switch ( event ) … … 38 38 # include <nv/detail/io_event_list.inc> 39 39 # undef NV_IO_EVENT 40 default: return "EV_UNKNOWN";40 NV_RETURN_COVERED_DEFAULT( "EV_UNKNOWN" ); 41 41 }; 42 42 } 43 43 44 void register_io_types( type_database* db )44 void nv::register_io_types( type_database* db ) 45 45 { 46 46 type_enum key_enums[] = { -
trunk/src/library.cc
r120 r121 37 37 38 38 library::library() 39 : m_ name(), m_handle( nullptr)39 : m_handle( nullptr ), m_name() 40 40 { 41 41 } -
trunk/src/logger.cc
r64 r121 21 21 22 22 // log level names 23 const char *log_level_names[] =23 static const char *log_level_names[] = 24 24 { 25 25 "NONE", … … 37 37 38 38 // log level names 39 const char *log_level_names_pad[] =39 static const char *log_level_names_pad[] = 40 40 { 41 41 "NONE ", … … 57 57 58 58 #if NV_PLATFORM == NV_WINDOWS 59 unsigned short log_color[] =59 static unsigned short log_color[] = 60 60 { 61 61 FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY, … … 72 72 }; 73 73 #else 74 const char *log_color[] =74 static const char *log_color[] = 75 75 { 76 76 "\33[37;1m", -
trunk/src/lua/lua_glm.cc
r113 r121 12 12 static size_t nlua_swizzel_lookup[256]; 13 13 14 inline bool nlua_is_swizzel( const char* str, size_t max )14 inline bool nlua_is_swizzel( const unsigned char* str, size_t max ) 15 15 { 16 16 while (*str) … … 24 24 template < typename T, size_t k > 25 25 struct nlua_vec_constructor { 26 static inline T construct( lua_State* L, int index) {26 static inline T construct( lua_State*, int ) { 27 27 return T(); 28 28 } … … 202 202 size_t len = 0; 203 203 size_t vlen = v->length(); 204 const char * key = lua_tolstring( L, 2, &len);204 const unsigned char * key = (const unsigned char *)( lua_tolstring( L, 2, &len ) ); 205 205 size_t idx = 255; 206 206 … … 240 240 size_t len = 0; 241 241 size_t vlen = v->length(); 242 const char * key = lua_tolstring( L, 2, &len);242 const unsigned char * key = (const unsigned char *)( lua_tolstring( L, 2, &len ) ); 243 243 size_t idx = 255; 244 244 if( len == 1 ) … … 321 321 { 322 322 for (size_t i = 0; i < 256; ++i ) nlua_swizzel_lookup[i] = 255; 323 nlua_swizzel_lookup['x'] = 0; 324 nlua_swizzel_lookup['r'] = 0; 325 nlua_swizzel_lookup['s'] = 0; 326 nlua_swizzel_lookup['0'] = 0; 327 nlua_swizzel_lookup['y'] = 1; 328 nlua_swizzel_lookup['g'] = 1; 329 nlua_swizzel_lookup['t'] = 0; 330 nlua_swizzel_lookup['1'] = 1; 331 nlua_swizzel_lookup['z'] = 2; 332 nlua_swizzel_lookup['b'] = 2; 333 nlua_swizzel_lookup['u'] = 0; 334 nlua_swizzel_lookup['2'] = 2; 335 nlua_swizzel_lookup['w'] = 3; 336 nlua_swizzel_lookup['a'] = 3; 337 nlua_swizzel_lookup['v'] = 0; 338 nlua_swizzel_lookup['3'] = 3; 323 using nv::char8; 324 nlua_swizzel_lookup[char8( 'x' )] = 0; 325 nlua_swizzel_lookup[char8( 'r' )] = 0; 326 nlua_swizzel_lookup[char8( 's' )] = 0; 327 nlua_swizzel_lookup[char8( '0' )] = 0; 328 nlua_swizzel_lookup[char8( 'y' )] = 1; 329 nlua_swizzel_lookup[char8( 'g' )] = 1; 330 nlua_swizzel_lookup[char8( 't' )] = 0; 331 nlua_swizzel_lookup[char8( '1' )] = 1; 332 nlua_swizzel_lookup[char8( 'z' )] = 2; 333 nlua_swizzel_lookup[char8( 'b' )] = 2; 334 nlua_swizzel_lookup[char8( 'u' )] = 0; 335 nlua_swizzel_lookup[char8( '2' )] = 2; 336 nlua_swizzel_lookup[char8( 'w' )] = 3; 337 nlua_swizzel_lookup[char8( 'a' )] = 3; 338 nlua_swizzel_lookup[char8( 'v' )] = 0; 339 nlua_swizzel_lookup[char8( '3' )] = 3; 339 340 int stack = lua_gettop( L ); 340 341 341 luaL_requiref(L, "ivec2", luaopen_vec< glm::ivec2>, 1);342 luaL_requiref(L, "ivec3", luaopen_vec< glm::ivec3>, 1);343 luaL_requiref(L, "ivec4", luaopen_vec< glm::ivec4>, 1);344 luaL_requiref(L, "vec2", luaopen_vec< glm::vec2>, 1);345 luaL_requiref(L, "vec3", luaopen_vec< glm::vec3>, 1);346 luaL_requiref(L, "vec4", luaopen_vec< glm::vec4>, 1);342 luaL_requiref(L, "ivec2", luaopen_vec<nv::ivec2>, 1); 343 luaL_requiref(L, "ivec3", luaopen_vec<nv::ivec3>, 1); 344 luaL_requiref(L, "ivec4", luaopen_vec<nv::ivec4>, 1); 345 luaL_requiref(L, "vec2", luaopen_vec<nv::vec2>, 1); 346 luaL_requiref(L, "vec3", luaopen_vec<nv::vec3>, 1); 347 luaL_requiref(L, "vec4", luaopen_vec<nv::vec4>, 1); 347 348 lua_settop( L, stack ); 348 349 } -
trunk/src/lua/lua_raw.cc
r85 r121 30 30 { 31 31 index = lua_absindex( L, index ); 32 int len = lua_rawlen( L, index);32 int len = static_cast<int>( lua_rawlen( L, index ) ); 33 33 int i = len; 34 34 lua_createtable( L, len, 0 ); -
trunk/src/lua/lua_state.cc
r86 r121 15 15 using namespace nv; 16 16 17 lua::stack_guard::stack_guard( lua::state* L )18 : L( L), m_level( lua_gettop(L->L) )19 { 20 21 } 22 23 lua::stack_guard::stack_guard( lua::state& L )24 : L(& L), m_level( lua_gettop((&L)->L) )17 lua::stack_guard::stack_guard( lua::state* aL ) 18 : L(aL), m_level( lua_gettop(aL->L) ) 19 { 20 21 } 22 23 lua::stack_guard::stack_guard( lua::state& aL ) 24 : L(&aL), m_level( lua_gettop(aL.L) ) 25 25 { 26 26 -
trunk/src/time.cc
r34 r121 42 42 static timer_impl zero_timer; 43 43 44 volatilenv::uint64 nv::get_ticks()44 nv::uint64 nv::get_ticks() 45 45 { 46 46 #if NV_COMPILER == NV_MSVC 47 47 return __rdtsc(); 48 #el if NV_COMPILER == NV_GNUC49 register long long ticks asm("eax") ;48 #else 49 register long long ticks asm("eax") = 0; 50 50 asm volatile (".byte 15, 49" : : : "eax", "edx"); 51 return ticks; 52 #else 53 return 0; // unsupported 51 return static_cast<nv::uint64>( ticks ); 54 52 #endif 55 53 } … … 59 57 #if NV_COMPILER == NV_MSVC 60 58 Sleep( ms ); 61 #el if NV_COMPILER == NV_GNUC59 #else 62 60 usleep( ms * 1000 ); 63 #else64 61 #endif 65 62 } … … 85 82 struct timeval now; 86 83 gettimeofday(&now, NULL); 87 return ( now.tv_sec - zero_timer.timeval_zero.tv_sec)*1000+(now.tv_usec-zero_timer.timeval_zero.tv_usec)/1000;84 return (uint32)( (now.tv_sec - zero_timer.timeval_zero.tv_sec)*1000+(now.tv_usec-zero_timer.timeval_zero.tv_usec)/1000 ); 88 85 #endif 89 86 } … … 99 96 struct timeval now; 100 97 gettimeofday(&now, NULL); 101 return ( now.tv_sec - zero_timer.timeval_zero.tv_sec)*1000000+(now.tv_usec - zero_timer.timeval_zero.tv_usec);98 return (uint32)( (now.tv_sec - zero_timer.timeval_zero.tv_sec)*1000000+(now.tv_usec - zero_timer.timeval_zero.tv_usec) ); 102 99 #endif 103 100 } -
trunk/tests/render_test/rl.cc
r93 r121 8 8 #include <nv/logging.hh> 9 9 #include <nv/logger.hh> 10 #include <glm/glm.hpp> 11 #include <glm/gtc/matrix_transform.hpp> 12 #include <glm/gtc/type_ptr.hpp> 10 #include <nv/math.hh> 13 11 #include <nv/string.hh> 14 12 #include <nv/types.hh> … … 19 17 const nv::uint16 size_xy = size_x * size_y; 20 18 21 nv::uint8 height[size_xy] =19 static nv::uint8 height[size_xy] = 22 20 { 23 21 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, … … 39 37 }; 40 38 41 nv::uint8 map[size_xy] =39 static nv::uint8 map[size_xy] = 42 40 { 43 41 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, … … 224 222 case nv::KEY_UP : move.z = move.z - 1.0f; break; 225 223 case nv::KEY_DOWN : move.z = move.z + 1.0f; break; 224 default: break; 226 225 } 227 226 } 228 227 break; 228 default: break; 229 229 } 230 230 }
Note: See TracChangeset
for help on using the changeset viewer.