Changeset 492
- Timestamp:
- 05/05/16 19:37:28 (9 years ago)
- Location:
- trunk
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv/gl/gl_context.hh
r491 r492 37 37 38 38 virtual vertex_array create_vertex_array( const vertex_array_desc& desc ); 39 virtual framebuffer create_framebuffer( );39 virtual framebuffer create_framebuffer( uint32 temp_samples = 1 ); 40 40 virtual void release( vertex_array va ); 41 41 virtual void release( framebuffer f ); … … 46 46 virtual void set_read_buffer( output_slot slot ); 47 47 virtual void blit( framebuffer f, clear_state::buffers_type mask, ivec2 src1, ivec2 src2, ivec2 dst1, ivec2 dst2 ); 48 virtual void blit( framebuffer from, framebuffer to, clear_state::buffers_type mask, ivec2 src1, ivec2 src2, ivec2 dst1, ivec2 dst2 ); 48 49 49 50 virtual void attach( framebuffer f, output_slot slot, texture t ); … … 88 89 void apply_depth_test( const depth_test& depth ); 89 90 void apply_depth_mask( bool mask ); 91 void apply_multisample( bool multisample ); 90 92 void apply_depth_range( const depth_range& range ); 91 93 void apply_color_mask( const color_mask& mask ); … … 94 96 void apply_polygon_mode( const polygon_mode& mode ); 95 97 void enable( unsigned int what, bool value ); 98 void set_active_texture( texture_slot slot ); 96 99 private: 100 texture_slot m_active_slot; 101 texture m_bound_textures[ texture_slot::MAX_TEXTURES ]; 97 102 vec4 m_clear_color; 98 103 float m_clear_depth; -
trunk/nv/gui/gui_element.hh
r472 r492 18 18 #include <nv/core/io_event.hh> 19 19 #include <nv/stl/string.hh> 20 #include <nv/stl/functional/function.hh> 20 21 #include <nv/gui/gui_common.hh> 21 22 … … 40 41 rectangle m_relative; ///< Position relative to parent. 41 42 rectangle m_absolute; ///< Position relative to window/screen. 43 function<void()> m_on_click; 42 44 render_data* m_render_data; ///< -?- 43 45 }; -
trunk/nv/gui/gui_environment.hh
r491 r492 36 36 void set_text( handle e, const string_twine& text ); 37 37 void set_class( handle e, const string_view& text ); 38 void set_on_click( handle e, const function< void() >& on_click ); 38 39 void update(); 39 40 void draw(); -
trunk/nv/interface/context.hh
r491 r492 61 61 uint32 color_attachment_count; 62 62 texture depth_attachment; 63 uint32 sample_count; 63 64 }; 64 65 … … 152 153 153 154 virtual vertex_array create_vertex_array( const vertex_array_desc& desc ) = 0; 154 virtual framebuffer create_framebuffer( ) = 0;155 virtual framebuffer create_framebuffer( uint32 temp_samples = 1 ) = 0; 155 156 virtual void release( vertex_array ) = 0; 156 157 virtual void release( framebuffer ) = 0; … … 162 163 virtual void set_read_buffer( output_slot slot ) = 0; 163 164 virtual void blit( framebuffer f, clear_state::buffers_type mask, ivec2 src1, ivec2 src2, ivec2 dst1, ivec2 dst2 ) = 0; 165 virtual void blit( framebuffer from, framebuffer to, clear_state::buffers_type mask, ivec2 src1, ivec2 src2, ivec2 dst1, ivec2 dst2 ) = 0; 164 166 165 167 virtual void attach( framebuffer f, output_slot slot, texture t ) = 0; -
trunk/nv/interface/device.hh
r491 r492 52 52 TEXTURE_2D_ARRAY, 53 53 TEXTURE_1D_BUFFER, 54 TEXTURE_2D_MULTISAMPLE, 54 55 }; 55 56 … … 79 80 TEXTURE_14 = 14, 80 81 TEXTURE_15 = 15, 82 MAX_TEXTURES = 16, 81 83 }; 82 84 … … 233 235 234 236 template < typename T > 235 voidset_uniform_array( program p, const string_view& name, const T* value, uint32 count, bool fatal = true )237 bool set_uniform_array( program p, const string_view& name, const T* value, uint32 count, bool fatal = true ) 236 238 { 237 239 uniform_base* base = get_uniform( p, name, fatal ); … … 243 245 NV_ASSERT( static_cast<int>( count ) <= base->get_length(), "LENGTH CHECK FAIL" ); 244 246 static_cast< uniform<T>* >( base )->set_value( value, count ); 247 return true; 245 248 } 246 249 } 247 } 248 249 template < typename T > 250 void set_opt_uniform_array( program p, const string_view& name, const T* value, uint32 count ) 251 { 252 set_uniform_array( p, name, value, count, false ); 253 } 254 255 template < typename T > 256 void set_opt_uniform_array( program p, const string_view& name, const array_view<T>& value ) 257 { 258 set_uniform_array( p, name, value.data(), value.size(), false ); 259 } 260 261 262 template < typename T > 263 void set_uniform( program p, const string_view& name, const T& value, bool fatal = true ) 250 return false; 251 } 252 253 template < typename T > 254 bool set_opt_uniform_array( program p, const string_view& name, const T* value, uint32 count ) 255 { 256 return set_uniform_array( p, name, value, count, false ); 257 } 258 259 template < typename T > 260 bool set_opt_uniform_array( program p, const string_view& name, const array_view<T>& value ) 261 { 262 return set_uniform_array( p, name, value.data(), value.size(), false ); 263 } 264 265 266 template < typename T > 267 bool set_uniform( program p, const string_view& name, const T& value, bool fatal = true ) 264 268 { 265 269 uniform_base* base = get_uniform( p, name, fatal ); … … 269 273 { 270 274 static_cast< uniform<T>* >( base )->set_value( value ); 275 return true; 271 276 } 272 277 } 273 } 274 275 template < typename T > 276 void set_opt_uniform( program p, const string_view& name, const T& value ) 277 { 278 set_uniform( p, name, value, false ); 278 return false; 279 } 280 281 template < typename T > 282 bool set_opt_uniform( program p, const string_view& name, const T& value ) 283 { 284 return set_uniform( p, name, value, false ); 279 285 } 280 286 -
trunk/nv/interface/render_state.hh
r395 r492 199 199 nv::color_mask color_mask; 200 200 nv::polygon_mode polygon_mode; 201 bool multisample; 201 202 bool depth_mask; 202 render_state() : depth_mask( true ) {}203 render_state() : depth_mask( true ), multisample( false ) {} 203 204 }; 204 205 -
trunk/nv/lib/gl.hh
r491 r492 53 53 #define GL_GENERATE_MIPMAP 0x8191 54 54 55 #include <nv/lib/detail/gl_core/gl_types_3_ 1.inc>55 #include <nv/lib/detail/gl_core/gl_types_3_2.inc> 56 56 #if NV_PLATFORM == NV_WINDOWS 57 57 #include <nv/lib/detail/wgl_types.inc> … … 67 67 #define NV_GL_FUN_EXT NV_GL_FUN 68 68 69 #include <nv/lib/detail/gl_core/gl_functions_3_ 1.inc>69 #include <nv/lib/detail/gl_core/gl_functions_3_2.inc> 70 70 #if NV_PLATFORM == NV_WINDOWS 71 71 #include <nv/lib/detail/wgl_functions.inc> -
trunk/src/gl/gl_context.cc
r491 r492 74 74 } 75 75 76 for ( uint32 i = 0; i < info->count; ++i )77 {78 glDisableVertexAttribArray( static_cast<uint32>( info->attr[i].location ) );79 }76 // for ( uint32 i = 0; i < info->count; ++i ) 77 // { 78 // glDisableVertexAttribArray( static_cast<uint32>( info->attr[i].location ) ); 79 // } 80 80 81 81 … … 83 83 } 84 84 85 nv::framebuffer nv::gl_context::create_framebuffer( )85 nv::framebuffer nv::gl_context::create_framebuffer( uint32 temp_samples ) 86 86 { 87 87 unsigned glid = 0; … … 92 92 info->depth_rb_glid = 0; 93 93 info->color_attachment_count = 0; 94 info->sample_count = temp_samples; 94 95 return result; 95 96 } … … 192 193 glGenRenderbuffers( 1, &(info->depth_rb_glid) ); 193 194 glBindRenderbuffer( GL_RENDERBUFFER, info->depth_rb_glid ); 194 glRenderbufferStorage( GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, size.x, size.y ); 195 if ( info->sample_count > 1 ) 196 glRenderbufferStorageMultisample( GL_RENDERBUFFER, info->sample_count, GL_DEPTH_COMPONENT16, size.x, size.y ); 197 else 198 glRenderbufferStorage( GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, size.x, size.y ); 195 199 glFramebufferRenderbuffer( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, info->depth_rb_glid ); 196 200 glBindRenderbuffer( GL_RENDERBUFFER, 0 ); … … 211 215 212 216 217 void nv::gl_context::blit( framebuffer from, framebuffer to, clear_state::buffers_type mask, ivec2 src1, ivec2 src2, ivec2 dst1, ivec2 dst2 ) 218 { 219 gl_framebuffer_info* finfo = m_framebuffers.get( from ); 220 gl_framebuffer_info* tinfo = m_framebuffers.get( to ); 221 if ( finfo ) 222 { 223 glBindFramebuffer( GL_READ_FRAMEBUFFER, finfo->glid ); 224 glBindFramebuffer( GL_DRAW_FRAMEBUFFER, tinfo ? tinfo->glid : 0 ); 225 unsigned filter = mask == clear_state::COLOR_BUFFER ? GL_LINEAR : GL_NEAREST; 226 int remove_below; 227 filter = GL_NEAREST; 228 glBlitFramebuffer( src1.x, src1.y, src2.x, src2.y, dst1.x, dst1.y, dst2.x, dst2.y, clear_state_buffers_to_mask( mask ), filter ); 229 glBindFramebuffer( GL_READ_FRAMEBUFFER, 0 ); 230 if ( tinfo ) glBindFramebuffer( GL_DRAW_FRAMEBUFFER, 0 ); 231 } 232 } 233 213 234 bool nv::gl_context::check( framebuffer_slot ft ) 214 235 { … … 220 241 switch ( result ) 221 242 { 243 case GL_FRAMEBUFFER_UNDEFINED : NV_LOG_ERROR( "gl_context::check : Framebuffer undefined!" ); break; 244 case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE : NV_LOG_ERROR( "gl_context::check : Incomplete multisample!" ); break; 245 case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS : NV_LOG_ERROR( "gl_context::check : Incomplete layer targets!" ); break; 222 246 case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT : NV_LOG_ERROR( "gl_context::check : Framebuffer incomplete attachment!" ); break; 223 247 case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT : NV_LOG_ERROR( "gl_context::check : Framebuffer missing attachment!" ); break; … … 255 279 { 256 280 NV_ASSERT_ALWAYS( binfo->type == TEXTURE_BUFFER && tinfo->type == TEXTURE_1D_BUFFER, "bad texture or buffer type!" ); 257 glActiveTexture( GL_TEXTURE0 ); 258 glBindTexture( GL_TEXTURE_BUFFER, tinfo->glid ); 281 bind( t, TEXTURE_0 ); 259 282 glTexBuffer( GL_TEXTURE_BUFFER, image_format_to_internal_enum( tinfo->format.format ), binfo->glid ); 260 glBindTexture( GL_TEXTURE_BUFFER, 0 );261 283 } 262 284 } … … 276 298 void gl_context::bind( texture t, texture_slot slot ) 277 299 { 278 const gl_texture_info* info = static_cast< const gl_texture_info* >( m_device->get_texture_info( t ) ); 279 if ( info ) 280 { 281 glActiveTexture( GL_TEXTURE0 + static_cast< GLenum >( slot ) ); 282 glBindTexture( texture_type_to_enum( info->type ), info->glid ); 300 if ( m_bound_textures[ slot ] != t ) 301 { 302 const gl_texture_info* info = static_cast< const gl_texture_info* >( m_device->get_texture_info( t ) ); 303 if ( info ) 304 { 305 set_active_texture( slot ); 306 glBindTexture( texture_type_to_enum( info->type ), info->glid ); 307 } 283 308 } 284 309 } … … 318 343 } 319 344 345 void nv::gl_context::set_active_texture( texture_slot slot ) 346 { 347 if ( slot != m_active_slot ) 348 glActiveTexture( GL_TEXTURE0 + static_cast<GLenum>( slot ) ); 349 } 350 320 351 // void nv::gl_context::unbind( buffer b ) 321 352 // { … … 352 383 const gl_texture_info* info = static_cast< const gl_texture_info* >( m_device->get_texture_info( t ) ); 353 384 NV_ASSERT_ALWAYS( info->type != TEXTURE_1D_BUFFER, "Buffer texture passed to update!" ); 385 NV_ASSERT_ALWAYS( info->type != TEXTURE_2D_MULTISAMPLE, "Multisample texture passed to update!" ); 354 386 if ( info ) 355 387 { … … 358 390 unsigned gl_type = texture_type_to_enum( info->type ); 359 391 360 glBindTexture( gl_type, info->glid ); 392 if ( m_bound_textures[ m_active_slot ] != t ) 393 glBindTexture( gl_type, info->glid ); 361 394 int this_should_be_subTexImage; 362 395 if ( info->type == TEXTURE_3D || info->type == TEXTURE_2D_ARRAY ) … … 543 576 glDepthMask( mask ); 544 577 m_render_state.depth_mask = mask; 578 } 579 } 580 581 void gl_context::apply_multisample( bool multisample ) 582 { 583 if ( m_render_state.multisample != multisample ) 584 { 585 glDepthMask( multisample ); 586 m_render_state.multisample = multisample; 545 587 } 546 588 } … … 727 769 apply_color_mask( state.color_mask ); 728 770 apply_depth_mask( state.depth_mask ); 771 apply_multisample( state.multisample ); 729 772 apply_polygon_mode( state.polygon_mode ); 730 773 } … … 736 779 // TODO: configurable: 737 780 // load_gl_extensions( GL_EXT_FRAMEBUFFER_BLIT | GL_EXT_FRAMEBUFFER_OBJECT | GL_EXT_TEXTURE_ARRAY ); 781 m_active_slot = texture_slot( -1 ); 738 782 force_apply_render_state( m_render_state ); 739 783 } -
trunk/src/gl/gl_device.cc
r491 r492 98 98 unsigned glid = 0; 99 99 unsigned gl_type = texture_type_to_enum( type ); 100 GL int gl_internal = GLint( nv::image_format_to_internal_enum( aformat.format ) );100 GLenum gl_internal = GLenum( nv::image_format_to_internal_enum( aformat.format ) ); 101 101 unsigned gl_enum = nv::image_format_to_enum( aformat.format ); 102 102 … … 119 119 } 120 120 121 glTexParameteri( gl_type, GL_TEXTURE_MIN_FILTER, GLint( nv::sampler_filter_to_enum( asampler.filter_min ) ) ); 122 glTexParameteri( gl_type, GL_TEXTURE_MAG_FILTER, GLint( nv::sampler_filter_to_enum( asampler.filter_max ) ) ); 121 if ( gl_type != GL_TEXTURE_2D_MULTISAMPLE ) 122 { 123 glTexParameteri( gl_type, GL_TEXTURE_MIN_FILTER, GLint( nv::sampler_filter_to_enum( asampler.filter_min ) ) ); 124 glTexParameteri( gl_type, GL_TEXTURE_MAG_FILTER, GLint( nv::sampler_filter_to_enum( asampler.filter_max ) ) ); 125 } 123 126 124 if ( gl_ enum != GL_RED_INTEGER )127 if ( gl_type != GL_TEXTURE_2D_MULTISAMPLE && gl_enum != GL_RED_INTEGER ) 125 128 { 126 129 glTexParameteri( gl_type, GL_TEXTURE_WRAP_S, GLint( nv::sampler_wrap_to_enum( asampler.wrap_s ) ) ); … … 130 133 if ( is_depth ) 131 134 { 132 glTexParameteri( gl_type, GL_TEXTURE_MIN_FILTER, GL_LINEAR );133 glTexParameteri( gl_type, GL_TEXTURE_MAG_FILTER, GL_LINEAR );135 // glTexParameteri( gl_type, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); 136 // glTexParameteri( gl_type, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); 134 137 135 138 // This is to allow usage of shadow2DProj function in the shader … … 146 149 // glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, aniso ); 147 150 148 glTexImage2D( gl_type, 0, gl_internal, size.x, size.y, 0, gl_enum, nv::datatype_to_gl_enum(aformat.type), data ); 151 if ( gl_type != GL_TEXTURE_2D_MULTISAMPLE ) 152 glTexImage2D( gl_type, 0, gl_internal, size.x, size.y, 0, gl_enum, nv::datatype_to_gl_enum(aformat.type), data ); 153 else 154 glTexImage2DMultisample( gl_type, 4, gl_internal, size.x, size.y, 1 ); 149 155 150 156 glBindTexture( gl_type, 0 ); … … 163 169 nv::texture nv::gl_device::create_texture( texture_type type, pixel_format format ) 164 170 { 165 NV_ASSERT_ALWAYS( type == TEXTURE_1D_BUFFER );171 NV_ASSERT_ALWAYS( type == TEXTURE_1D_BUFFER, "create_texture not texture buffer!" ); 166 172 unsigned glid = 0; 167 unsigned gl_type = texture_type_to_enum( type );168 173 169 174 glGenTextures( 1, &glid ); … … 552 557 NV_ASSERT( u, "Unknown uniform type!" ); 553 558 (*p->m_uniform_map)[ name ] = u; 559 //NV_LOG_DEBUG( "Uniform : ", name, " - ", utype, "/", uni_len ); 560 554 561 } 555 562 -
trunk/src/gl/gl_enum.cc
r491 r492 15 15 switch( type ) 16 16 { 17 case TEXTURE_1D : return GL_TEXTURE_1D; 18 case TEXTURE_2D : return GL_TEXTURE_2D; 19 case TEXTURE_RECT : return GL_TEXTURE_RECTANGLE; 20 case TEXTURE_3D : return GL_TEXTURE_3D; 21 case TEXTURE_CUBE : return GL_TEXTURE_CUBE_MAP; 22 case TEXTURE_1D_ARRAY : return GL_TEXTURE_1D_ARRAY; 23 case TEXTURE_2D_ARRAY : return GL_TEXTURE_2D_ARRAY; 24 case TEXTURE_1D_BUFFER: return GL_TEXTURE_BUFFER; 17 case TEXTURE_1D : return GL_TEXTURE_1D; 18 case TEXTURE_2D : return GL_TEXTURE_2D; 19 case TEXTURE_RECT : return GL_TEXTURE_RECTANGLE; 20 case TEXTURE_3D : return GL_TEXTURE_3D; 21 case TEXTURE_CUBE : return GL_TEXTURE_CUBE_MAP; 22 case TEXTURE_1D_ARRAY : return GL_TEXTURE_1D_ARRAY; 23 case TEXTURE_2D_ARRAY : return GL_TEXTURE_2D_ARRAY; 24 case TEXTURE_1D_BUFFER : return GL_TEXTURE_BUFFER; 25 case TEXTURE_2D_MULTISAMPLE : return GL_TEXTURE_2D_MULTISAMPLE; 25 26 NV_RETURN_COVERED_DEFAULT( 0 ); 26 27 } -
trunk/src/gui/gui_environment.cc
r444 r492 182 182 { 183 183 handle h = get_element( position( ev.mbutton.x, ev.mbutton.y ) ); 184 element* e = m_elements.get( h ); 185 if ( e->m_on_click ) e->m_on_click(); 186 184 187 set_selected( h ); 185 188 return true; … … 312 315 } 313 316 317 void nv::gui::environment::set_on_click( handle e, const function< void() >& on_click ) 318 { 319 element* ep = m_elements.get( e ); 320 if ( ep != nullptr ) 321 { 322 ep->m_on_click = on_click; 323 } 324 } 325 314 326 void nv::gui::environment::set_text( handle e, const string_twine& text ) 315 327 { -
trunk/src/gui/gui_gfx_renderer.cc
r491 r492 249 249 const char* stext[] = { "", "selected", "hover" }; 250 250 const char* selector = stext[border]; 251 if ( e->m_flags[HOVER] ) selector = stext[2];252 if ( e->m_flags[SELECTED] ) selector = stext[1];251 if ( e->m_flags[HOVER] && e->m_flags[DIRTY_HOVER] ) selector = stext[2]; 252 if ( e->m_flags[SELECTED] && e->m_flags[DIRTY_SELECT] ) selector = stext[1]; 253 253 254 254 if ( m_style.get( e, "skin", selector, path ) ) -
trunk/src/lib/gl.cc
r491 r492 26 26 #define NV_GL_FUN_REN( rtype, fname, rname, fparams ) rtype (NV_GL_APIENTRY *rname) fparams = nullptr; 27 27 #define NV_GL_FUN_EXT NV_GL_FUN 28 #include <nv/lib/detail/gl_core/gl_functions_3_ 1.inc>28 #include <nv/lib/detail/gl_core/gl_functions_3_2.inc> 29 29 #if NV_PLATFORM == NV_WINDOWS 30 30 #include <nv/lib/detail/wgl_functions.inc> … … 106 106 # define NV_GL_FUN( rtype, fname, fparams ) NV_GL_LOAD( fname ) 107 107 # define NV_GL_FUN_EXT( rtype, fname, fparams ) NV_GL_LOAD_EXT( fname ) 108 # include <nv/lib/detail/gl_core/gl_functions_3_ 1.inc>108 # include <nv/lib/detail/gl_core/gl_functions_3_2.inc> 109 109 # undef NV_GL_FUN_EXT 110 110 # undef NV_GL_FUN -
trunk/src/sdl/sdl_window.cc
r491 r492 30 30 // SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, 4 ); 31 31 32 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);33 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);32 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4); 33 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); 34 34 35 35 SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE );
Note: See TracChangeset
for help on using the changeset viewer.