- Timestamp:
- 05/28/13 01:03:00 (12 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv/gl/gl_program.hh
r36 r37 44 44 { 45 45 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 ); 48 48 49 49 virtual void bind(); … … 60 60 gl_shader vertex_shader; 61 61 gl_shader fragment_shader; 62 gl_shader geometry_shader;63 62 }; 64 63 -
trunk/nv/lib/gl.hh
r35 r37 145 145 #define GL_DRAW_BUFFER 0x0C01 146 146 #define GL_READ_BUFFER 0x0C02 147 #define GL_SCISSOR_TEST 0x0C11 147 148 #define GL_COLOR_CLEAR_VALUE 0x0C22 148 149 #define GL_COLOR_WRITEMASK 0x0C23 -
trunk/nv/types.hh
r30 r37 76 76 77 77 template <typename TYPE> 78 const char* get_type_name()78 inline const char* get_type_name() 79 79 { 80 80 static_assert< FALSE >( "Type not implemented!" ); 81 81 } 82 82 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"; } 99 99 100 100 template <typename TYPE> -
trunk/src/gl/gl_program.cc
r36 r37 73 73 } 74 74 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);75 gl_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 ); 79 79 } 80 80 … … 86 86 glDetachShader( m_name.get_value(), vertex_shader.get_id() ); 87 87 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 91 bool gl_program::compile( const string& vertex_program, const string& fragment_program ) 96 92 { 97 93 if (!vertex_shader.compile( vertex_program )) { return false; } 98 94 if (!fragment_shader.compile( fragment_program )) { return false; } 99 if (!geometry_program.empty())100 {101 if (!geometry_shader.compile( geometry_program )) { return false; }102 }103 95 104 96 glAttachShader( m_name.get_value(), fragment_shader.get_id() ); 105 97 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 }110 98 glLinkProgram( m_name.get_value() ); 111 99 … … 180 168 int uni_loc = glGetUniformLocation( m_name.get_value(), name.c_str() ); 181 169 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 ); 183 171 } 184 172 }
Note: See TracChangeset
for help on using the changeset viewer.