- Timestamp:
- 06/15/16 18:34:37 (9 years ago)
- Location:
- trunk/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/engine/material_manager.cc
r498 r501 20 20 uint8 data[2 * 2 * 3]; 21 21 nv::raw_fill_n( data, 2 * 2 * 3, 0 ); 22 m_default = m_context-> get_device()->create_texture( ivec2(2,2), nv::image_format( nv::RGB ), nv::sampler(), data );22 m_default = m_context->create_texture( ivec2(2,2), nv::image_format( nv::RGB ), nv::sampler(), data ); 23 23 } 24 24 … … 34 34 if ( auto data = m_image_manager->get( mat->paths[i] ).lock() ) 35 35 { 36 result->textures[i] = m_context-> get_device()->create_texture( &*data, smp );36 result->textures[i] = m_context->create_texture( &*data, smp ); 37 37 } 38 38 } … … 53 53 for ( const texture& t : m->textures ) 54 54 { 55 m_context-> get_device()->release( t );55 m_context->release( t ); 56 56 } 57 57 } -
trunk/src/engine/particle_engine.cc
r500 r501 320 320 321 321 data.quota = table.get<uint32>("quota", 1024 ); 322 data.local = table.get<bool>("local_space", false );322 // data.local = table.get<bool>("local_space", false ); 323 323 data.accurate_facing = table.get<bool>("accurate_facing", false ); 324 324 data.emmiter_count = 0; … … 467 467 { 468 468 m_context = a_context; 469 m_device = a_context->get_device(); 470 m_program_local = m_device->create_program( nv_particle_engine_vertex_shader_local, nv_particle_engine_fragment_shader ); 471 m_program_world = m_device->create_program( nv_particle_engine_vertex_shader_world, nv_particle_engine_fragment_shader ); 469 m_program_local = m_context->create_program( nv_particle_engine_vertex_shader_local, nv_particle_engine_fragment_shader ); 470 m_program_world = m_context->create_program( nv_particle_engine_vertex_shader_world, nv_particle_engine_fragment_shader ); 472 471 473 472 register_standard_emmiters(); … … 533 532 info->count = 0; 534 533 info->quota = max_particles; 535 info->vtx_buffer = m_ device->create_buffer( VERTEX_BUFFER, STREAM_DRAW, info->quota * sizeof( particle_quad )/*, info->quads_[0].data*/ );534 info->vtx_buffer = m_context->create_buffer( VERTEX_BUFFER, STREAM_DRAW, info->quota * sizeof( particle_quad )/*, info->quads_[0].data*/ ); 536 535 vertex_array_desc desc; 537 536 desc.add_vertex_buffers< particle_vtx >( info->vtx_buffer, true ); … … 545 544 { 546 545 clear(); 547 m_ device->release( m_program_world );548 m_ device->release( m_program_local );546 m_context->release( m_program_world ); 547 m_context->release( m_program_local ); 549 548 } 550 549 … … 785 784 vec3 source; 786 785 mat3 orient; 787 bool local = info->data->local;786 // bool local = info->data->local; 788 787 // if ( !local ) 789 788 // { -
trunk/src/engine/program_manager.cc
r479 r501 36 36 } 37 37 38 add( id, m_context-> get_device()->create_program( vsource, fsource ) );38 add( id, m_context->create_program( vsource, fsource ) ); 39 39 return true; 40 40 } … … 42 42 void nv::program_manager::release( program p ) 43 43 { 44 m_context-> get_device()->release( p );44 m_context->release( p ); 45 45 } 46 46 -
trunk/src/gfx/debug_draw.cc
r499 r501 35 35 : m_context( a_context ), m_program(), m_va() 36 36 { 37 m_program = m_context-> get_device()->create_program( nv_debug_draw_vertex_shader, nv_debug_draw_fragment_shader );37 m_program = m_context->create_program( nv_debug_draw_vertex_shader, nv_debug_draw_fragment_shader ); 38 38 m_buffer_size = 0; 39 39 } … … 45 45 if ( m_va.is_valid() ) m_context->release( m_va ); 46 46 m_buffer_size = nv::max( m_data.size(), 4096U, m_buffer_size ); 47 m_vb = m_context-> get_device()->create_buffer( VERTEX_BUFFER, nv::STREAM_DRAW, m_buffer_size * sizeof( debug_vtx ) );47 m_vb = m_context->create_buffer( VERTEX_BUFFER, nv::STREAM_DRAW, m_buffer_size * sizeof( debug_vtx ) ); 48 48 vertex_array_desc va_desc; 49 49 va_desc.add_vertex_buffers< debug_vtx >( m_vb, true ); … … 89 89 { 90 90 m_context->release( m_va ); 91 m_context-> get_device()->release( m_program );91 m_context->release( m_program ); 92 92 } -
trunk/src/gl/gl_context.cc
r500 r501 66 66 } 67 67 } 68 glBindBuffer( GL_ARRAY_BUFFER, 0 );69 68 glBindVertexArray( 0 ); 70 69 … … 104 103 { 105 104 if ( info->attr[i].owner ) 106 m_device->release( info->attr[i].vbuffer );107 } 108 if ( info->index.is_valid() && info->index_owner) m_device->release( info->index );105 release( info->attr[i].vbuffer ); 106 } 107 if ( info->index.is_valid() && info->index_owner) release( info->index ); 109 108 glDeleteVertexArrays( 1, &info->glid ); 110 109 m_vertex_arrays.destroy( va ); … … 223 222 glBindFramebuffer( GL_DRAW_FRAMEBUFFER, tinfo ? tinfo->glid : 0 ); 224 223 unsigned filter = mask == clear_state::COLOR_BUFFER ? GL_LINEAR : GL_NEAREST; 225 int remove_below;226 filter = GL_NEAREST;227 224 glBlitFramebuffer( src1.x, src1.y, src2.x, src2.y, dst1.x, dst1.y, dst2.x, dst2.y, clear_state_buffers_to_mask( mask ), filter ); 228 225 glBindFramebuffer( GL_READ_FRAMEBUFFER, 0 ); … … 270 267 } 271 268 269 272 270 void nv::gl_context::bind( buffer b, texture t ) 273 271 { … … 304 302 set_active_texture( slot ); 305 303 glBindTexture( texture_type_to_enum( info->type ), info->glid ); 304 m_bound_textures[slot] = t; 306 305 } 307 306 } … … 314 313 if ( info ) 315 314 { 316 glUseProgram( info->glid ); 315 if ( m_bound_program != p ) 316 glUseProgram( info->glid ); 317 317 gdevice->update_uniforms( info ); 318 318 if ( !info->validated ) … … 320 320 validate_program( p ); 321 321 } 322 m_bound_program = p; 322 323 } 323 324 } … … 369 370 void nv::gl_context::unbind( program ) 370 371 { 371 glUseProgram( 0 ); 372 if ( m_bound_program ) 373 glUseProgram( 0 ); 374 m_bound_program = program(); 372 375 } 373 376 … … 375 378 { 376 379 if ( slot != m_active_slot ) 380 { 377 381 glActiveTexture( GL_TEXTURE0 + static_cast<GLenum>( slot ) ); 382 m_active_slot = slot; 383 } 378 384 } 379 385 … … 419 425 unsigned gl_type = texture_type_to_enum( info->type ); 420 426 421 if ( m_bound_textures[ m_active_slot ] != t ) 422 glBindTexture( gl_type, info->glid ); 423 int this_should_be_subTexImage; 427 bind( t, texture_slot::TEXTURE_0 ); 424 428 if ( info->type == TEXTURE_3D || info->type == TEXTURE_2D_ARRAY ) 425 glTexImage3D( gl_type, 0, static_cast<GLint>( nv::image_format_to_internal_enum( format.format ) ), size.x, size.y, size.z, 0, nv::image_format_to_enum( format.format ), nv::datatype_to_gl_enum( format.type ), data ); 429 // glTexImage3D( gl_type, 0, static_cast<GLint>( nv::image_format_to_internal_enum( format.format ) ), size.x, size.y, size.z, 0, nv::image_format_to_enum( format.format ), nv::datatype_to_gl_enum( format.type ), data ); 430 glTexSubImage3D( gl_type, 0, 0, 0, 0, size.x, size.y, size.z, nv::image_format_to_enum( format.format ), nv::datatype_to_gl_enum( format.type ), data ); 426 431 else 427 glTexImage2D( gl_type, 0, static_cast<GLint>( nv::image_format_to_internal_enum(format.format) ), size.x, size.y, 0, nv::image_format_to_enum(format.format), nv::datatype_to_gl_enum(format.type), data ); 432 // glTexImage2D( gl_type, 0, static_cast<GLint>( nv::image_format_to_internal_enum(format.format) ), size.x, size.y, 0, nv::image_format_to_enum(format.format), nv::datatype_to_gl_enum(format.type), data ); 433 glTexSubImage2D( gl_type, 0, 0, 0, size.x, size.y, nv::image_format_to_enum( format.format ), nv::datatype_to_gl_enum( format.type ), data ); 428 434 } 429 435 } … … 518 524 void gl_context::set_viewport( const ivec4& viewport ) 519 525 { 520 NV_ASSERT_ALWAYS( viewport.z > 0 && viewport.w > 0, "viewport dimensions must be greater than zero!" ); 521 m_viewport = viewport; 522 glViewport( viewport.x, viewport.y, viewport.z, viewport.w ); 526 if ( m_viewport != viewport ) 527 { 528 NV_ASSERT_ALWAYS( viewport.z > 0 && viewport.w > 0, "viewport dimensions must be greater than zero!" ); 529 m_viewport = viewport; 530 glViewport( viewport.x, viewport.y, viewport.z, viewport.w ); 531 } 523 532 } 524 533 … … 860 869 } 861 870 871 nv::texture nv::gl_context::create_texture( texture_type type, ivec2 size, image_format aformat, sampler asampler, const void* data /*= nullptr */ ) 872 { 873 texture result = create_texture( type, aformat.format ); 874 gl_texture_info* info = static_cast<gl_device*>( m_device )->get_full_texture_info( result ); 875 bind( result, texture_slot::TEXTURE_0 ); 876 unsigned glid = info->glid; 877 unsigned gl_type = texture_type_to_enum( type ); 878 GLenum gl_internal = GLenum( image_format_to_internal_enum( aformat.format ) ); 879 unsigned gl_enum = image_format_to_enum( aformat.format ); 880 881 bool is_depth = aformat.format == DEPTH16 || aformat.format == DEPTH24 || aformat.format == DEPTH32; 882 883 // Detect if mipmapping was requested 884 // if ( gl_type == GL_TEXTURE_2D && gl_enum != GL_RED_INTEGER && asampler.filter_min != sampler::LINEAR && asampler.filter_min != sampler::NEAREST ) 885 // { 886 // // TODO: This should not be done if we use framebuffers! 887 // glTexParameteri( gl_type, GL_GENERATE_MIPMAP, GL_TRUE); 888 // } 889 890 if ( asampler.filter_max != sampler::NEAREST ) 891 { 892 asampler.filter_max = sampler::LINEAR; 893 } 894 895 if ( gl_type != GL_TEXTURE_2D_MULTISAMPLE ) 896 { 897 glTexParameteri( gl_type, GL_TEXTURE_MIN_FILTER, GLint( nv::sampler_filter_to_enum( asampler.filter_min ) ) ); 898 glTexParameteri( gl_type, GL_TEXTURE_MAG_FILTER, GLint( nv::sampler_filter_to_enum( asampler.filter_max ) ) ); 899 } 900 901 if ( gl_type != GL_TEXTURE_2D_MULTISAMPLE && gl_enum != GL_RED_INTEGER ) 902 { 903 glTexParameteri( gl_type, GL_TEXTURE_WRAP_S, GLint( nv::sampler_wrap_to_enum( asampler.wrap_s ) ) ); 904 glTexParameteri( gl_type, GL_TEXTURE_WRAP_T, GLint( nv::sampler_wrap_to_enum( asampler.wrap_t ) ) ); 905 } 906 907 if ( is_depth ) 908 { 909 // glTexParameteri( gl_type, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); 910 // glTexParameteri( gl_type, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); 911 912 // This is to allow usage of shadow2DProj function in the shader 913 glTexParameteri( gl_type, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE ); 914 glTexParameteri( gl_type, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL ); 915 } 916 917 // #define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE 918 // #define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF 919 // 920 // float aniso = 0.0f; 921 // glGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &aniso ); 922 // NV_LOG_INFO( "Anisotropy at ", aniso, " (", int( aniso ), " ) " ); 923 // glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, aniso ); 924 925 if ( gl_type != GL_TEXTURE_2D_MULTISAMPLE ) 926 glTexImage2D( gl_type, 0, gl_internal, size.x, size.y, 0, gl_enum, nv::datatype_to_gl_enum( aformat.type ), data ); 927 else 928 glTexImage2DMultisample( gl_type, 4, gl_internal, size.x, size.y, 1 ); 929 930 if ( gl_type == GL_TEXTURE_2D && gl_enum != GL_RED_INTEGER && asampler.filter_min != sampler::LINEAR && asampler.filter_min != sampler::NEAREST ) 931 { 932 // TODO: This should not be done if we use framebuffers! 933 glGenerateMipmap( gl_type ); 934 } 935 936 bind( texture(), texture_slot::TEXTURE_0 ); 937 938 info->type = type; 939 info->format = aformat; 940 info->tsampler = asampler; 941 info->size = ivec3( size.x, size.y, 1 ); 942 info->glid = glid; 943 944 return result; 945 } 946 947 nv::texture nv::gl_context::create_texture( texture_type type, ivec3 size, image_format aformat, sampler asampler, const void* data /*= nullptr */ ) 948 { 949 texture result = create_texture( type, aformat.format ); 950 gl_texture_info* info = static_cast<gl_device*>( m_device )->get_full_texture_info( result ); 951 bind( result, texture_slot::TEXTURE_0 ); 952 unsigned glid = info->glid; 953 954 unsigned gl_type = texture_type_to_enum( type ); 955 956 bool is_depth = aformat.format == DEPTH16 || aformat.format == DEPTH24 || aformat.format == DEPTH32; 957 958 if ( asampler.filter_max != sampler::NEAREST ) 959 { 960 asampler.filter_max = sampler::LINEAR; 961 } 962 963 glTexParameteri( gl_type, GL_TEXTURE_MIN_FILTER, GLint( nv::sampler_filter_to_enum( asampler.filter_min ) ) ); 964 glTexParameteri( gl_type, GL_TEXTURE_MAG_FILTER, GLint( nv::sampler_filter_to_enum( asampler.filter_max ) ) ); 965 glTexParameteri( gl_type, GL_TEXTURE_WRAP_S, GLint( nv::sampler_wrap_to_enum( asampler.wrap_s ) ) ); 966 glTexParameteri( gl_type, GL_TEXTURE_WRAP_T, GLint( nv::sampler_wrap_to_enum( asampler.wrap_t ) ) ); 967 968 if ( is_depth ) 969 { 970 glTexParameteri( gl_type, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); 971 glTexParameteri( gl_type, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); 972 973 // This is to allow usage of shadow2DProj function in the shader 974 glTexParameteri( gl_type, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE ); 975 glTexParameteri( gl_type, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL ); 976 } 977 978 //glTexStorage3D( GL_TEXTURE_2D_ARRAY, mipLevelCount, GL_RGBA8, width, height, layerCount ); 979 glTexImage3D( gl_type, 0, GLint( nv::image_format_to_internal_enum( aformat.format ) ), size.x, size.y, size.z, 0, nv::image_format_to_enum( aformat.format ), nv::datatype_to_gl_enum( aformat.type ), data ); 980 981 bind( texture(), texture_slot::TEXTURE_0 ); 982 983 info->type = type; 984 info->format = aformat; 985 info->tsampler = asampler; 986 info->size = size; 987 info->glid = glid; 988 989 return result; 990 } 991 992 nv::buffer nv::gl_context::create_buffer( buffer_type type, buffer_hint hint, size_t size, const void* source /*= nullptr */ ) 993 { 994 buffer result = static_cast<gl_device*>( m_device )->create_buffer( type, hint ); 995 if ( size > 0 ) create_buffer( result, size, source ); 996 return result; 997 } 998 999 void nv::gl_context::create_buffer( buffer b, size_t size, const void* source /*= nullptr */ ) 1000 { 1001 gl_buffer_info* info = static_cast<gl_device*>( m_device )->get_full_buffer_info( b ); 1002 if ( info ) 1003 { 1004 unsigned glenum = buffer_type_to_enum( info->type ); 1005 glBindBuffer( glenum, info->glid ); 1006 glBufferData( glenum, GLsizeiptr( size ), source, buffer_hint_to_enum( info->hint ) ); 1007 glBindBuffer( glenum, 0 ); 1008 } 1009 } 1010 862 1011 void nv::gl_context::set_draw_buffers( uint32 count, const output_slot* slots ) 863 1012 { -
trunk/src/gl/gl_device.cc
r498 r501 94 94 } 95 95 96 nv::texture nv::gl_device::create_texture( texture_type type, ivec2 size, image_format aformat, sampler asampler, const void* data /*= nullptr */ )97 {98 NV_ASSERT_ALWAYS( type != TEXTURE_1D_BUFFER && type != TEXTURE_3D && type != TEXTURE_2D_ARRAY, "2D texture type expected!" );99 unsigned glid = 0;100 unsigned gl_type = texture_type_to_enum( type );101 GLenum gl_internal = GLenum( nv::image_format_to_internal_enum( aformat.format ) );102 unsigned gl_enum = nv::image_format_to_enum( aformat.format );103 104 bool is_depth = aformat.format == DEPTH16 || aformat.format == DEPTH24 || aformat.format == DEPTH32;105 106 glGenTextures( 1, &glid );107 108 glBindTexture( gl_type, glid );109 110 // Detect if mipmapping was requested111 // if ( gl_type == GL_TEXTURE_2D && gl_enum != GL_RED_INTEGER && asampler.filter_min != sampler::LINEAR && asampler.filter_min != sampler::NEAREST )112 // {113 // // TODO: This should not be done if we use framebuffers!114 // glTexParameteri( gl_type, GL_GENERATE_MIPMAP, GL_TRUE);115 // }116 117 if ( asampler.filter_max != sampler::NEAREST )118 {119 asampler.filter_max = sampler::LINEAR;120 }121 122 if ( gl_type != GL_TEXTURE_2D_MULTISAMPLE )123 {124 glTexParameteri( gl_type, GL_TEXTURE_MIN_FILTER, GLint( nv::sampler_filter_to_enum( asampler.filter_min ) ) );125 glTexParameteri( gl_type, GL_TEXTURE_MAG_FILTER, GLint( nv::sampler_filter_to_enum( asampler.filter_max ) ) );126 }127 128 if ( gl_type != GL_TEXTURE_2D_MULTISAMPLE && gl_enum != GL_RED_INTEGER )129 {130 glTexParameteri( gl_type, GL_TEXTURE_WRAP_S, GLint( nv::sampler_wrap_to_enum( asampler.wrap_s ) ) );131 glTexParameteri( gl_type, GL_TEXTURE_WRAP_T, GLint( nv::sampler_wrap_to_enum( asampler.wrap_t ) ) );132 }133 134 if ( is_depth )135 {136 // glTexParameteri( gl_type, GL_TEXTURE_MIN_FILTER, GL_LINEAR );137 // glTexParameteri( gl_type, GL_TEXTURE_MAG_FILTER, GL_LINEAR );138 139 // This is to allow usage of shadow2DProj function in the shader140 glTexParameteri( gl_type, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE );141 glTexParameteri( gl_type, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL );142 }143 144 // #define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE145 // #define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF146 //147 // float aniso = 0.0f;148 // glGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &aniso );149 // NV_LOG_INFO( "Anisotropy at ", aniso, " (", int( aniso ), " ) " );150 // glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, aniso );151 152 if ( gl_type != GL_TEXTURE_2D_MULTISAMPLE )153 glTexImage2D( gl_type, 0, gl_internal, size.x, size.y, 0, gl_enum, nv::datatype_to_gl_enum(aformat.type), data );154 else155 glTexImage2DMultisample( gl_type, 4, gl_internal, size.x, size.y, 1 );156 157 if ( gl_type == GL_TEXTURE_2D && gl_enum != GL_RED_INTEGER && asampler.filter_min != sampler::LINEAR && asampler.filter_min != sampler::NEAREST )158 {159 // TODO: This should not be done if we use framebuffers!160 glGenerateMipmap( gl_type );161 }162 163 164 glBindTexture( gl_type, 0 );165 166 texture result = m_textures.create();167 gl_texture_info* info = m_textures.get( result );168 info->type = type;169 info->format = aformat;170 info->tsampler = asampler;171 info->size = ivec3( size.x, size.y, 1 );172 info->glid = glid;173 return result;174 }175 176 177 96 nv::texture nv::gl_device::create_texture( texture_type type, pixel_format format ) 178 97 { 179 NV_ASSERT_ALWAYS( type == TEXTURE_1D_BUFFER, "create_texture not texture buffer!" );180 98 unsigned glid = 0; 181 99 … … 193 111 } 194 112 195 nv::texture nv::gl_device::create_texture( texture_type type, ivec3 size, image_format aformat, sampler asampler, const void* data /*= nullptr */ )196 {197 NV_ASSERT_ALWAYS( type == TEXTURE_3D || type == TEXTURE_2D_ARRAY, "3D texture type expected!" );198 unsigned glid = 0;199 unsigned gl_type = texture_type_to_enum( type );200 201 bool is_depth = aformat.format == DEPTH16 || aformat.format == DEPTH24 || aformat.format == DEPTH32;202 203 glGenTextures( 1, &glid );204 glBindTexture( gl_type, glid );205 206 if ( asampler.filter_max != sampler::NEAREST )207 {208 asampler.filter_max = sampler::LINEAR;209 }210 211 glTexParameteri( gl_type, GL_TEXTURE_MIN_FILTER, GLint( nv::sampler_filter_to_enum( asampler.filter_min ) ) );212 glTexParameteri( gl_type, GL_TEXTURE_MAG_FILTER, GLint( nv::sampler_filter_to_enum( asampler.filter_max ) ) );213 glTexParameteri( gl_type, GL_TEXTURE_WRAP_S, GLint( nv::sampler_wrap_to_enum( asampler.wrap_s ) ) );214 glTexParameteri( gl_type, GL_TEXTURE_WRAP_T, GLint( nv::sampler_wrap_to_enum( asampler.wrap_t ) ) );215 216 if ( is_depth )217 {218 glTexParameteri( gl_type, GL_TEXTURE_MIN_FILTER, GL_LINEAR );219 glTexParameteri( gl_type, GL_TEXTURE_MAG_FILTER, GL_LINEAR );220 221 // This is to allow usage of shadow2DProj function in the shader222 glTexParameteri( gl_type, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE );223 glTexParameteri( gl_type, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL );224 }225 226 //glTexStorage3D( GL_TEXTURE_2D_ARRAY, mipLevelCount, GL_RGBA8, width, height, layerCount );227 glTexImage3D( gl_type, 0, GLint( nv::image_format_to_internal_enum( aformat.format ) ), size.x, size.y, size.z, 0, nv::image_format_to_enum( aformat.format ), nv::datatype_to_gl_enum( aformat.type ), data );228 glBindTexture( gl_type, 0 );229 230 texture result = m_textures.create();231 gl_texture_info* info = m_textures.get( result );232 info->type = type;233 info->format = aformat;234 info->tsampler = asampler;235 info->size = size;236 info->glid = glid;237 return result;238 }239 240 241 242 113 void nv::gl_device::release( texture t ) 243 114 { … … 271 142 } 272 143 273 nv::buffer nv::gl_device::create_buffer( buffer_type type, buffer_hint hint , size_t size, const void* source /*= nullptr */)144 nv::buffer nv::gl_device::create_buffer( buffer_type type, buffer_hint hint ) 274 145 { 275 146 unsigned glid = 0; 276 147 unsigned glenum = buffer_type_to_enum( type ); 277 148 glGenBuffers( 1, &glid ); 278 279 if ( size > 0 )280 {281 glBindBuffer( glenum, glid );282 glBufferData( glenum, GLsizeiptr( size ), source, buffer_hint_to_enum( hint ) );283 glBindBuffer( glenum, 0 );284 }285 149 286 150 buffer result = m_buffers.create(); … … 288 152 info->type = type; 289 153 info->hint = hint; 290 info->size = size;154 info->size = 0; 291 155 info->glid = glid; 292 156 return result; 293 }294 295 void nv::gl_device::create_buffer( buffer b, size_t size, const void* source )296 {297 gl_buffer_info* info = m_buffers.get( b );298 if ( info )299 {300 unsigned glenum = buffer_type_to_enum( info->type );301 glBindBuffer( glenum, info->glid );302 glBufferData( glenum, GLsizeiptr( size ), source, buffer_hint_to_enum( info->hint ) );303 glBindBuffer( glenum, 0 );304 }305 157 } 306 158 … … 330 182 m_programs.destroy( p ); 331 183 } 184 } 185 186 nv::gl_texture_info* nv::gl_device::get_full_texture_info( texture t ) 187 { 188 return m_textures.get( t ); 189 190 } 191 192 nv::gl_buffer_info* nv::gl_device::get_full_buffer_info( buffer t ) 193 { 194 return m_buffers.get( t ); 332 195 } 333 196 -
trunk/src/gui/gui_gfx_renderer.cc
r492 r501 116 116 ~screen_render_data() 117 117 { 118 ctx-> get_device()->release( shader );118 ctx->release( shader ); 119 119 ctx->release( varray ); 120 120 } … … 157 157 screen_render_data* sr = new screen_render_data( w->get_context(), 1024 ); 158 158 m_render_data = sr; 159 sr->shader = m_window->get_ device()->create_program( nv_gui_vertex_shader, nv_gui_fragment_shader );159 sr->shader = m_window->get_context()->create_program( nv_gui_vertex_shader, nv_gui_fragment_shader ); 160 160 m_scene_state.get_camera().set_ortho( 0.0f, float( m_window->get_width() ), float( m_window->get_height() ), 0.0f ); 161 161 … … 166 166 167 167 nv::sampler sampler( nv::sampler::LINEAR, nv::sampler::CLAMP_TO_EDGE ); 168 sr->tex = m_window->get_ device()->create_texture( m_atlas.get_size(), image_format( nv::RGBA, nv::UBYTE ), sampler, nullptr );168 sr->tex = m_window->get_context()->create_texture( m_atlas.get_size(), image_format( nv::RGBA, nv::UBYTE ), sampler, nullptr ); 169 169 170 170 m_render_state.depth_test.enabled = false; … … 395 395 if ( m_render_data ) 396 396 { 397 m_context-> get_device()->release( reinterpret_cast< screen_render_data* >( m_render_data )->tex );397 m_context->release( reinterpret_cast< screen_render_data* >( m_render_data )->tex ); 398 398 delete m_render_data; 399 399 } -
trunk/src/lib/gl.cc
r492 r501 55 55 56 56 57 static void* load_gl_ext_symbol_impl( const nv::string_view& name, nv::log_level fail_level = nv::LOG_DEBUG )58 {59 void* result = gl_ext_loader( name.data() );60 NV_LOG( ( result ? nv::LOG_DEBUG : fail_level ), "load_gl_ext_symbol : ", name, ( result ? " succeded." : "failed." ) );61 return result;62 }63 64 static void* load_gl_ext_symbol( const nv::string_view& name, bool iterate, const nv::string_view& ext )65 {66 void * result = nullptr;67 nv::string128 test_name = name + ext;68 result = load_gl_ext_symbol_impl( !ext.empty() ? test_name : name );69 if ( result ) return result;70 if ( iterate )71 {72 test_name = name + "ARB"_ls;73 result = gl_ext_loader( test_name.data() );74 if ( result ) return result;75 test_name = name + "EXT"_ls;76 result = gl_ext_loader( test_name.data() );77 if ( result ) return result;78 }79 return result;80 }57 // static void* load_gl_ext_symbol_impl( const nv::string_view& name, nv::log_level fail_level = nv::LOG_DEBUG ) 58 // { 59 // void* result = gl_ext_loader( name.data() ); 60 // NV_LOG( ( result ? nv::LOG_DEBUG : fail_level ), "load_gl_ext_symbol : ", name, ( result ? " succeded." : "failed." ) ); 61 // return result; 62 // } 63 64 // static void* load_gl_ext_symbol( const nv::string_view& name, bool iterate, const nv::string_view& ext ) 65 // { 66 // void * result = nullptr; 67 // nv::string128 test_name = name + ext; 68 // result = load_gl_ext_symbol_impl( !ext.empty() ? test_name : name ); 69 // if ( result ) return result; 70 // if ( iterate ) 71 // { 72 // test_name = name + "ARB"_ls; 73 // result = gl_ext_loader( test_name.data() ); 74 // if ( result ) return result; 75 // test_name = name + "EXT"_ls; 76 // result = gl_ext_loader( test_name.data() ); 77 // if ( result ) return result; 78 // } 79 // return result; 80 // } 81 81 82 82 bool nv::load_gl_library( const char* path, bool force_reload )
Note: See TracChangeset
for help on using the changeset viewer.