Changeset 37 for trunk


Ignore:
Timestamp:
05/28/13 01:03:00 (12 years ago)
Author:
epyon
Message:
  • gl_context added
  • removed geometry shader support from gl_program (non-GL 2.1/GLES 2.0 compatible)
  • cleaned up warnings
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/nv/gl/gl_program.hh

    r36 r37  
    4444        {
    4545        public:
    46                 gl_program( const string& vertex_program, const string& fragment_program, const string& geometry_program = "");
    47                 bool compile( const string& vertex_program, const string& fragment_program, const string& geometry_program = "" );
     46                gl_program( const string& vertex_program, const string& fragment_program );
     47                bool compile( const string& vertex_program, const string& fragment_program );
    4848
    4949                virtual void bind();
     
    6060                gl_shader vertex_shader;
    6161                gl_shader fragment_shader;
    62                 gl_shader geometry_shader;
    6362        };
    6463
  • trunk/nv/lib/gl.hh

    r35 r37  
    145145#define GL_DRAW_BUFFER 0x0C01
    146146#define GL_READ_BUFFER 0x0C02
     147#define GL_SCISSOR_TEST 0x0C11
    147148#define GL_COLOR_CLEAR_VALUE 0x0C22
    148149#define GL_COLOR_WRITEMASK 0x0C23
  • trunk/nv/types.hh

    r30 r37  
    7676
    7777        template <typename TYPE>
    78     const char* get_type_name()
     78    inline const char* get_type_name()
    7979    {
    8080        static_assert< FALSE >( "Type not implemented!" );
    8181    }
    8282
    83     template <> const char* get_type_name<sint8> () { return "sint8"; }
    84     template <> const char* get_type_name<sint16>() { return "sint16"; }
    85     template <> const char* get_type_name<sint32>() { return "sint32"; }
    86     template <> const char* get_type_name<sint64>() { return "sint64"; }
    87 
    88         template <> const char* get_type_name<uint8> () { return "uint8"; }
    89     template <> const char* get_type_name<uint16>() { return "uint16"; }
    90     template <> const char* get_type_name<uint32>() { return "uint32"; }
    91     template <> const char* get_type_name<uint64>() { return "uint64"; }
    92 
    93         template <> const char* get_type_name<f32> () { return "f32"; }
    94         template <> const char* get_type_name<f64> () { return "f64"; }
    95 
    96         template <> const char* get_type_name<bool> () { return "bool"; }
    97 
    98         template <> const char* get_type_name<std::string> () { return "string"; }
     83    template <> inline const char* get_type_name<sint8> () { return "sint8"; }
     84    template <> inline const char* get_type_name<sint16>() { return "sint16"; }
     85    template <> inline const char* get_type_name<sint32>() { return "sint32"; }
     86    template <> inline const char* get_type_name<sint64>() { return "sint64"; }
     87
     88        template <> inline const char* get_type_name<uint8> () { return "uint8"; }
     89    template <> inline const char* get_type_name<uint16>() { return "uint16"; }
     90    template <> inline const char* get_type_name<uint32>() { return "uint32"; }
     91    template <> inline const char* get_type_name<uint64>() { return "uint64"; }
     92
     93        template <> inline const char* get_type_name<f32> () { return "f32"; }
     94        template <> inline const char* get_type_name<f64> () { return "f64"; }
     95
     96        template <> inline const char* get_type_name<bool> () { return "bool"; }
     97
     98        template <> inline const char* get_type_name<std::string> () { return "string"; }
    9999
    100100        template <typename TYPE>
  • trunk/src/gl/gl_program.cc

    r36 r37  
    7373}
    7474
    75 gl_program::gl_program( const string& vertex_program, const string& fragment_program, const string& geometry_program /*= ""*/ )
    76         : vertex_shader( GL_VERTEX_SHADER ), fragment_shader( GL_FRAGMENT_SHADER ), geometry_shader( GL_GEOMETRY_SHADER )
    77 {
    78         compile( vertex_program, fragment_program, geometry_program );
     75gl_program::gl_program( const string& vertex_program, const string& fragment_program )
     76        : vertex_shader( GL_VERTEX_SHADER ), fragment_shader( GL_FRAGMENT_SHADER )
     77{
     78        compile( vertex_program, fragment_program );
    7979}
    8080
     
    8686                glDetachShader( m_name.get_value(), vertex_shader.get_id() );
    8787                glDetachShader( m_name.get_value(), fragment_shader.get_id() );
    88                 if ( geometry_shader.is_valid() )
    89                 {
    90                         glDetachShader( m_name.get_value(), geometry_shader.get_id() );
    91                 }
    92         }
    93 }
    94 
    95 bool gl_program::compile( const string& vertex_program, const string& fragment_program, const string& geometry_program /*= "" */ )
     88        }
     89}
     90
     91bool gl_program::compile( const string& vertex_program, const string& fragment_program )
    9692{
    9793        if (!vertex_shader.compile( vertex_program )) { return false; }
    9894        if (!fragment_shader.compile( fragment_program )) { return false; }
    99         if (!geometry_program.empty())
    100         {
    101                 if (!geometry_shader.compile( geometry_program )) { return false; }
    102         }
    10395
    10496        glAttachShader( m_name.get_value(), fragment_shader.get_id() );
    10597        glAttachShader( m_name.get_value(), vertex_shader.get_id() );
    106         if (!geometry_program.empty())
    107         {
    108                 glAttachShader( m_name.get_value(), geometry_shader.get_id() );
    109         }
    11098        glLinkProgram( m_name.get_value() );
    11199
     
    180168                int uni_loc = glGetUniformLocation( m_name.get_value(), name.c_str() );
    181169                type utype = gl_enum_to_type( uni_type );
    182                 m_uniform_map[ name ] = create_uniform( gl_enum_to_type( uni_type ), name, uni_loc, uni_len );
     170                m_uniform_map[ name ] = create_uniform( utype, name, uni_loc, uni_len );
    183171        }
    184172}
Note: See TracChangeset for help on using the changeset viewer.