- Timestamp:
- 02/04/15 16:37:00 (10 years ago)
- Location:
- trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gl/gl_device.cc
r331 r350 49 49 image_data* data = new image_data( format, glm::ivec2( image->w, image->h ), (nv::uint8*)image->pixels ); 50 50 return data; 51 } 52 53 // this is a temporary function that will be removed once we find a way to 54 // pass binary file data around 55 image_data* gl_device::create_image_data( const uint8* data, uint32 size ) 56 { 57 load_sdl_image_library(); 58 SDL_Surface* image = IMG_LoadTyped_RW( SDL_RWFromMem( (void*)data, size ), 1, "tga" ); 59 if ( !image ) 60 { 61 NV_LOG( LOG_ERROR, "Image binary data cannot be loaded found!" ); 62 return nullptr; 63 } 64 // TODO: BGR vs RGB, single channel 65 assert( image->format->BytesPerPixel > 2 ); 66 image_format format( image->format->BytesPerPixel == 3 ? RGB : RGBA, UBYTE ); 67 image_data* idata = new image_data( format, glm::ivec2( image->w, image->h ), ( nv::uint8* )image->pixels ); 68 return idata; 51 69 } 52 70 -
trunk/src/gl/gl_enum.cc
r340 r350 296 296 case BYTE_VECTOR_3 : return GL_INT_VEC3; 297 297 case BYTE_VECTOR_4 : return GL_INT_VEC4; 298 default : return 0; // TODO: throw! 298 // remove, error or ? 299 case UBYTE_VECTOR_2: return GL_INT_VEC2; 300 case UBYTE_VECTOR_3: return GL_INT_VEC3; 301 case UBYTE_VECTOR_4: return GL_INT_VEC4; 302 default: return 0; // TODO: throw! 299 303 } 300 304 } -
trunk/src/gui/gui_style.cc
r319 r350 21 21 } 22 22 23 bool style::get( element* e, const std::string&entry, std::string& s )23 bool style::get( element* e, const char* centry, std::string& s ) 24 24 { 25 25 lua::stack_guard guard( m_lua ); 26 if ( !resolve( e ,entry, LUA_TSTRING ) ) return false;26 if ( !resolve( e->m_id.c_str(), e->m_class.c_str(), centry, LUA_TSTRING ) ) return false; 27 27 s = lua_tostring( m_lua, -1 ); 28 28 return true; 29 29 } 30 30 31 bool style::get( element* e, const std::string&entry, vec4& vec )31 bool style::get( element* e, const char* centry, vec4& vec ) 32 32 { 33 33 lua::stack_guard guard( m_lua ); 34 if ( !resolve( e ,entry, LUA_TTABLE ) ) return false;34 if ( !resolve( e->m_id.c_str(), e->m_class.c_str(), centry, LUA_TTABLE ) ) return false; 35 35 vec = vec4(); 36 36 for (size_t i = 0; i < 4; ++i ) … … 44 44 } 45 45 46 bool style::get( element* e, const std::string&entry, int& i )46 bool style::get( element* e, const char* centry, int& i ) 47 47 { 48 48 lua::stack_guard guard( m_lua ); 49 if ( !resolve( e ,entry, LUA_TNUMBER ) ) return false;49 if ( !resolve( e->m_id.c_str(), e->m_class.c_str(), centry, LUA_TNUMBER ) ) return false; 50 50 i = static_cast< int >( lua_tointeger( m_lua, -1 ) ); 51 51 return true; 52 52 } 53 53 54 bool style::get( element* e, const std::string&entry, double& d )54 bool style::get( element* e, const char* centry, double& d ) 55 55 { 56 56 lua::stack_guard guard( m_lua ); 57 if ( !resolve( e ,entry, LUA_TNUMBER ) ) return false;57 if ( !resolve( e->m_id.c_str(), e->m_class.c_str(), centry, LUA_TNUMBER ) ) return false; 58 58 d = lua_tonumber( m_lua, -1 ); 59 59 return true; … … 64 64 } 65 65 66 bool style::resolve( element* e, const std::string&entry, int type )66 bool style::resolve( const char* cid, const char* cclass, const char* centry, int type ) 67 67 { 68 const char* centry = entry.c_str();69 const char* cid = e->m_id.c_str();70 const char* cclass = e->m_class.c_str();71 68 lua_getglobal( m_lua, "default" ); 72 69 int global = lua_gettop( m_lua );
Note: See TracChangeset
for help on using the changeset viewer.