Ignore:
Timestamp:
08/08/14 13:18:41 (11 years ago)
Author:
epyon
Message:
  • program is now handle-based
  • all device constructs are now handle-based and do not dynamically allocate
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gl/gl_context.cc

    r302 r303  
    99#include "nv/lib/sdl.hh"
    1010#include "nv/gl/gl_device.hh"
    11 #include "nv/gl/gl_program.hh"
    1211
    1312using namespace nv;
     
    2322}
    2423
    25 void nv::gl_context::bind( program* p )
    26 {
    27         gl_program* glp = static_cast< gl_program* >( p );
    28         glUseProgram( glp->glid );
    29         glp->update_uniforms();
     24void nv::gl_context::bind( program p )
     25{
     26        gl_program_info* info = ((gl_device*)m_device)->m_programs.get( p );
     27        if ( info )
     28        {
     29                glUseProgram( info->glid );
     30                ((gl_device*)m_device)->update_uniforms( info );
     31        }
    3032}
    3133
     
    4143void nv::gl_context::bind( vertex_array va )
    4244{
    43         vertex_array_info* info = get_vertex_array_info( va );
     45        const vertex_array_info* info = m_device->get_vertex_array_info( va );
    4446        if ( info )
    4547        {
     
    6870}
    6971
    70 void nv::gl_context::unbind( program* )
     72void nv::gl_context::unbind( program )
    7173{
    7274        glUseProgram( 0 );
     
    8486void nv::gl_context::unbind( vertex_array va )
    8587{
    86         vertex_array_info* info = get_vertex_array_info( va );
     88        const vertex_array_info* info = m_device->get_vertex_array_info( va );
    8789        if ( info )
    8890        {
     
    483485}
    484486
    485 void gl_context::draw( primitive prim, const render_state& rs, program* p, vertex_array va, size_t count )
     487void nv::gl_context::apply_engine_uniforms( program p, const scene_state& s )
     488{
     489        gl_program_info* info = ((gl_device*)m_device)->m_programs.get( p );
     490        if ( info )
     491        {
     492                for ( auto u : info->m_engine_uniforms )
     493                {
     494                        u->set( this, &s );
     495                }
     496        }
     497}
     498
     499void gl_context::draw( primitive prim, const render_state& rs, program p, vertex_array va, size_t count )
    486500{
    487501        apply_render_state( rs );
    488         vertex_array_info* info = get_vertex_array_info( va );
     502        const vertex_array_info* info = m_device->get_vertex_array_info( va );
    489503        if ( count > 0 && info )
    490504        {
Note: See TracChangeset for help on using the changeset viewer.