Changeset 406 for trunk/src/gl/gl_device.cc
- Timestamp:
- 06/20/15 00:05:17 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gl/gl_device.cc
r403 r406 53 53 assert( image->format->BytesPerPixel > 2 ); 54 54 image_format format(image->format->BytesPerPixel == 3 ? RGB : RGBA, UBYTE ); 55 image_data* data = new image_data( format, ivec2( image->w, image->h ), (nv::uint8*)image->pixels);55 image_data* data = new image_data( format, ivec2( image->w, image->h ), static_cast<nv::uint8*>( image->pixels ) ); 56 56 return data; 57 57 } … … 62 62 { 63 63 load_sdl_image_library(); 64 SDL_Surface* image = IMG_LoadTyped_RW( SDL_RWFromMem( (void*)data, (int)size), 1, "png" );64 SDL_Surface* image = IMG_LoadTyped_RW( SDL_RWFromMem( const_cast<uint8*>( data ), int( size ) ), 1, "png" ); 65 65 if ( !image ) 66 66 { … … 71 71 assert( image->format->BytesPerPixel > 2 ); 72 72 image_format format( image->format->BytesPerPixel == 3 ? RGB : RGBA, UBYTE ); 73 image_data* idata = new image_data( format, ivec2( image->w, image->h ), ( nv::uint8* )image->pixels);73 image_data* idata = new image_data( format, ivec2( image->w, image->h ), static_cast<nv::uint8*>( image->pixels ) ); 74 74 return idata; 75 75 } … … 86 86 } 87 87 88 nv::texture nv::gl_device::create_texture( texture_type type, ivec2 size, image_format aformat, sampler asampler, void* data /*= nullptr */ )88 nv::texture nv::gl_device::create_texture( texture_type type, ivec2 size, image_format aformat, sampler asampler, const void* data /*= nullptr */ ) 89 89 { 90 90 unsigned glid = 0; … … 106 106 } 107 107 108 glTexParameteri( gl_type, GL_TEXTURE_MIN_FILTER, (int)nv::sampler_filter_to_enum( asampler.filter_min) );109 glTexParameteri( gl_type, GL_TEXTURE_MAG_FILTER, (int)nv::sampler_filter_to_enum( asampler.filter_max) );110 glTexParameteri( gl_type, GL_TEXTURE_WRAP_S, (int)nv::sampler_wrap_to_enum( asampler.wrap_s) );111 glTexParameteri( gl_type, GL_TEXTURE_WRAP_T, (int)nv::sampler_wrap_to_enum( asampler.wrap_t) );112 113 glTexImage2D( gl_type, 0, (GLint)nv::image_format_to_internal_enum(aformat.format), size.x, size.y, 0, nv::image_format_to_enum(aformat.format), nv::datatype_to_gl_enum(aformat.type), data );108 glTexParameteri( gl_type, GL_TEXTURE_MIN_FILTER, GLint( nv::sampler_filter_to_enum( asampler.filter_min ) ) ); 109 glTexParameteri( gl_type, GL_TEXTURE_MAG_FILTER, GLint( nv::sampler_filter_to_enum( asampler.filter_max ) ) ); 110 glTexParameteri( gl_type, GL_TEXTURE_WRAP_S, GLint( nv::sampler_wrap_to_enum( asampler.wrap_s) ) ); 111 glTexParameteri( gl_type, GL_TEXTURE_WRAP_T, GLint( nv::sampler_wrap_to_enum( asampler.wrap_t) ) ); 112 113 glTexImage2D( gl_type, 0, GLint( nv::image_format_to_internal_enum(aformat.format) ), size.x, size.y, 0, nv::image_format_to_enum(aformat.format), nv::datatype_to_gl_enum(aformat.type), data ); 114 114 115 115 glBindTexture( gl_type, 0 ); … … 163 163 164 164 glBindBuffer( glenum, glid ); 165 glBufferData( glenum, (GLsizeiptr)size, source, buffer_hint_to_enum( hint ) );165 glBufferData( glenum, GLsizeiptr( size ), source, buffer_hint_to_enum( hint ) ); 166 166 glBindBuffer( glenum, 0 ); 167 167 … … 325 325 switch( ubase->get_type() ) 326 326 { 327 case FLOAT : glUniform1fv( uloc, ubase->get_length(), ((uniform< enum_to_type< FLOAT >::type >*)( ubase ))->get_value() ); break;328 case INT : glUniform1iv( uloc, ubase->get_length(), ((uniform< enum_to_type< INT >::type >*)( ubase ))->get_value() ); break;329 case FLOAT_VECTOR_2 : glUniform2fv( uloc, ubase->get_length(), (GLfloat*)((uniform< enum_to_type< FLOAT_VECTOR_2 >::type >*)( ubase ))->get_value()); break;330 case FLOAT_VECTOR_3 : glUniform3fv( uloc, ubase->get_length(), (GLfloat*)((uniform< enum_to_type< FLOAT_VECTOR_3 >::type >*)( ubase ))->get_value()); break;331 case FLOAT_VECTOR_4 : glUniform4fv( uloc, ubase->get_length(), (GLfloat*)((uniform< enum_to_type< FLOAT_VECTOR_4 >::type >*)( ubase ))->get_value()); break;332 case INT_VECTOR_2 : glUniform2iv( uloc, ubase->get_length(), (GLint*)((uniform< enum_to_type< INT_VECTOR_2 >::type >*)( ubase ))->get_value()); break;333 case INT_VECTOR_3 : glUniform3iv( uloc, ubase->get_length(), (GLint*)((uniform< enum_to_type< INT_VECTOR_3 >::type >*)( ubase ))->get_value()); break;334 case INT_VECTOR_4 : glUniform4iv( uloc, ubase->get_length(), (GLint*)((uniform< enum_to_type< INT_VECTOR_4 >::type >*)( ubase ))->get_value()); break;335 case FLOAT_MATRIX_2 : glUniformMatrix2fv( uloc, ubase->get_length(), GL_FALSE, (GLfloat*)((uniform< enum_to_type< FLOAT_MATRIX_2 >::type >*)( ubase ))->get_value()); break;336 case FLOAT_MATRIX_3 : glUniformMatrix3fv( uloc, ubase->get_length(), GL_FALSE, (GLfloat*)((uniform< enum_to_type< FLOAT_MATRIX_3 >::type >*)( ubase ))->get_value()); break;337 case FLOAT_MATRIX_4 : glUniformMatrix4fv( uloc, ubase->get_length(), GL_FALSE, (GLfloat*)((uniform< enum_to_type< FLOAT_MATRIX_4 >::type >*)( ubase ))->get_value()); break;327 case FLOAT : glUniform1fv( uloc, ubase->get_length(), static_cast< uniform< enum_to_type< FLOAT >::type >*>( ubase )->get_value() ); break; 328 case INT : glUniform1iv( uloc, ubase->get_length(), static_cast< uniform< enum_to_type< INT >::type >*>( ubase )->get_value() ); break; 329 case FLOAT_VECTOR_2 : glUniform2fv( uloc, ubase->get_length(), reinterpret_cast<const GLfloat*>( static_cast< uniform< enum_to_type< FLOAT_VECTOR_2 >::type >*>( ubase )->get_value())); break; 330 case FLOAT_VECTOR_3 : glUniform3fv( uloc, ubase->get_length(), reinterpret_cast<const GLfloat*>( static_cast< uniform< enum_to_type< FLOAT_VECTOR_3 >::type >*>( ubase )->get_value())); break; 331 case FLOAT_VECTOR_4 : glUniform4fv( uloc, ubase->get_length(), reinterpret_cast<const GLfloat*>( static_cast< uniform< enum_to_type< FLOAT_VECTOR_4 >::type >*>( ubase )->get_value())); break; 332 case INT_VECTOR_2 : glUniform2iv( uloc, ubase->get_length(), reinterpret_cast<const GLint*>( static_cast< uniform< enum_to_type< INT_VECTOR_2 >::type >*>( ubase )->get_value())); break; 333 case INT_VECTOR_3 : glUniform3iv( uloc, ubase->get_length(), reinterpret_cast<const GLint*>( static_cast< uniform< enum_to_type< INT_VECTOR_3 >::type >*>( ubase )->get_value())); break; 334 case INT_VECTOR_4 : glUniform4iv( uloc, ubase->get_length(), reinterpret_cast<const GLint*>( static_cast< uniform< enum_to_type< INT_VECTOR_4 >::type >*>( ubase )->get_value())); break; 335 case FLOAT_MATRIX_2 : glUniformMatrix2fv( uloc, ubase->get_length(), GL_FALSE, reinterpret_cast<const GLfloat*>( static_cast< uniform< enum_to_type< FLOAT_MATRIX_2 >::type >*>( ubase )->get_value())); break; 336 case FLOAT_MATRIX_3 : glUniformMatrix3fv( uloc, ubase->get_length(), GL_FALSE, reinterpret_cast<const GLfloat*>( static_cast< uniform< enum_to_type< FLOAT_MATRIX_3 >::type >*>( ubase )->get_value())); break; 337 case FLOAT_MATRIX_4 : glUniformMatrix4fv( uloc, ubase->get_length(), GL_FALSE, reinterpret_cast<const GLfloat*>( static_cast< uniform< enum_to_type< FLOAT_MATRIX_4 >::type >*>( ubase )->get_value())); break; 338 338 default : break; // error? 339 339 } … … 348 348 glGetProgramiv( p->glid, GL_ACTIVE_ATTRIBUTES, ¶ms ); 349 349 350 for ( unsigned i = 0; i < (unsigned)params; ++i )350 for ( unsigned i = 0; i < unsigned( params ); ++i ) 351 351 { 352 352 int attr_nlen; … … 377 377 glGetProgramiv( p->glid, GL_ACTIVE_UNIFORMS, ¶ms ); 378 378 379 for ( unsigned i = 0; i < size_t(params); ++i )379 for ( unsigned i = 0; i < unsigned( params ); ++i ) 380 380 { 381 381 int uni_nlen; … … 412 412 413 413 const char* pc = shader_code.data(); 414 int l = (int)shader_code.length();414 int l = int( shader_code.length() ); 415 415 416 416 glShaderSource( glid, 1, &pc, &l ); … … 428 428 if ( compile_ok == 0 ) 429 429 { 430 NV_LOG_ERROR( "Shader #", glid, " error: ", buffer);430 NV_LOG_ERROR( "Shader #", glid, " error: ", string_view( buffer, size_t( length ) ) ); 431 431 } 432 432 else 433 433 { 434 NV_LOG_INFO( "Shader #", glid, " compiled successfully: ", buffer);434 NV_LOG_INFO( "Shader #", glid, " compiled successfully: ", string_view( buffer, size_t( length ) ) ); 435 435 } 436 436 }
Note: See TracChangeset
for help on using the changeset viewer.